@evotecit/officeimo 0.1.5 → 0.1.9

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.
@@ -0,0 +1,2 @@
1
+ // Generated by OfficeIMO.JavaScript/scripts/bundles.mjs from tsc output. MIT.
2
+ const he=(()=>{function R(s){if(s?.aborted)throw s.reason}function D(s,o){return o?new Promise((h,t)=>{const i=()=>o.removeEventListener("abort",e),e=()=>{i(),t(o.reason)};o.addEventListener("abort",e,{once:!0}),Promise.resolve(s).then(n=>{i(),h(n)},n=>{i(),t(n)}),o.aborted&&e()}):Promise.resolve(s)}async function*F(s,o){R(o);const h=s?.[Symbol.asyncIterator]?.()??s?.[Symbol.iterator]?.();if(!h)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let t=!1,i=!1;try{for(;;){R(o);const e=await D(Promise.resolve(h.next()),o);if(R(o),e.done){t=!0;return}yield e.value}}catch(e){throw i=!0,e}finally{if(!t&&h.return)try{const e=h.return();o?.aborted||i?Promise.resolve(e).catch(()=>{}):await D(Promise.resolve(e),o)}catch(e){if(!o?.aborted&&!i)throw e}}}const P=new WeakMap;function S(s){let o=!1;const h=()=>{if(o)throw new TypeError("A row source can be consumed only once.");o=!0},t={[Symbol.asyncIterator](){return h(),i()}};async function*i(){for await(const e of F(s))yield*e}return P.set(t,(e,n)=>(h(),f(s,e,l=>f(l,e,n)))),t}function p(...s){const o={async*[Symbol.asyncIterator](){for(const h of s)yield*h}};return P.set(o,async(h,t)=>{for(const i of s)await f(i,h,t)}),o}async function f(s,o,h){R(o);const t=P.get(s);if(t)return t(o,h);const i=s?.[Symbol.asyncIterator]?.()??s?.[Symbol.iterator]?.();if(!i)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let e=!1;try{for(;;){R(o);let n=i.next();const l=n;typeof l?.then=="function"&&(n=await D(l,o)),R(o);const a=n;if(a.done){e=!0;return}let d=a.value;typeof d?.then=="function"&&(d=await D(d,o)),R(o);const u=h(d);u!==void 0&&await D(u,o)}}finally{if(!e&&i.return)try{Promise.resolve(i.return()).catch(()=>{})}catch{}}}let T;const E=32;function w(){T=performance.now()+E}function g(){const s=performance.now();return T??=s+E,s>=T}function c(){const s=globalThis.scheduler;return typeof s?.postTask=="function"?s.postTask(()=>{T=performance.now()+E},{priority:"user-visible"}):new Promise(o=>{setTimeout(function(){T=performance.now()+E,o()},0)})}return Object.freeze({checkAbort:R,withAbort:D,inputRows:F,rowsFromBatches:S,concatRows:p,consumeRows:f,beginTask:w,taskYieldDue:g,pause:c})})(),ae=(()=>{const R=Symbol.for("@evotecit/officeimo/OfficeIMOError"),D=Symbol.for("@evotecit/officeimo/NotSupportedError");class F extends Error{code;static[Symbol.hasInstance](f){return this!==F?Function.prototype[Symbol.hasInstance].call(this,f):!!f&&typeof f=="object"&&f[R]===!0}constructor(f,T,E){super(T,E),this.code=f,Object.defineProperty(this,R,{value:!0}),this.name="OfficeIMOError"}}class P extends F{feature;static[Symbol.hasInstance](f){return this!==P?Function.prototype[Symbol.hasInstance].call(this,f):!!f&&typeof f=="object"&&f[D]===!0}constructor(f){super("NOT_SUPPORTED",f+" is not supported yet."),this.feature=f,Object.defineProperty(this,D,{value:!0}),this.name="NotSupportedError"}}return Object.freeze({OfficeIMOError:F,NotSupportedError:P})})(),Be=(()=>{const{checkAbort:R,consumeRows:D,withAbort:F,pause:P,taskYieldDue:S}=he,{OfficeIMOError:p}=ae;async function f(c,r){if(c&&typeof c.getWriter=="function"){const s=c.getWriter();try{return await r({write:o=>s.write(new Uint8Array(o))})}finally{s.releaseLock()}}if(!c||typeof c.write!="function")throw new TypeError("Destination must be a ByteSink or WritableStream.");return r(c)}class T{parts=[];state="open";result;write(r){if(this.state!=="open")throw new p("INVALID_STATE","Byte sink is closed.");this.parts.push(new Uint8Array(r))}toBlob(r="application/octet-stream"){if(this.state==="discarded")throw new p("INVALID_STATE","Byte sink was discarded.");return this.state="closed",this.result||(this.result=new Blob(this.parts,{type:r}),this.parts=[]),this.result.type===r?this.result:new Blob([this.result],{type:r})}takeChunks(){if(this.state!=="open")throw new p("INVALID_STATE","Byte sink is closed.");const r=this.parts;return this.parts=[],this.state="discarded",r}discard(){this.parts=[],this.result=void 0,this.state="discarded"}}class E{sink;signal;chunkSize;text="";encoder=new TextEncoder;constructor(r,s,o=32768){if(this.sink=r,this.signal=s,this.chunkSize=o,!Number.isInteger(o)||o<2)throw new RangeError("Text chunk size must be at least 2.")}append(r){return R(this.signal),this.text+=r,this.text.length>=this.chunkSize||S()}async flush(r=!1){for(R(this.signal);this.text.length;){let s=Math.min(this.text.length,this.chunkSize);if(/[\ud800-\udbff]/.test(this.text[s-1])&&(s<this.text.length||!r)&&s--,!s)break;const o=this.encoder.encode(this.text.slice(0,s));this.text=this.text.slice(s),await F(Promise.resolve(this.sink.write(o)),this.signal),S()&&await P(),R(this.signal)}}async write(r){this.append(r)&&await this.flush()}async close(){await this.flush(!0)}}async function w(c,r,s){await D(c instanceof Uint8Array?[c]:c,s,o=>{if(!(o instanceof Uint8Array))throw new TypeError("Byte sources must yield Uint8Array chunks.");const h=r.write(o);return S()?Promise.resolve(h).then(()=>(R(s),P())):h})}return Object.freeze({withDestination:f,BlobByteSink:T,ChunkedTextSink:E,writeBytes:w})})(),tt=(()=>{function R(F,P){if(!F)return;const S=F(P);if(S&&typeof S.then=="function")throw Promise.resolve(S).catch(()=>{}),new TypeError("onProgress must be synchronous.")}return Object.freeze({notifyProgress:R})})(),De=(()=>{function R(F){if(F===null||typeof F!="object")return!1;try{return!(F instanceof Date)&&!(Symbol.toStringTag in F)&&Object.prototype.toString.call(F)!=="[object Date]"?!1:(Date.prototype.getTime.call(F),!0)}catch{return!1}}return Object.freeze({isDate:R})})(),We=(()=>{function R(F){if(!F||typeof F!="object")throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const{target:P,tooltip:S}=F;if(typeof P!="string"||!/^(?:https?:\/\/|mailto:)/i.test(P)||/[\u0000-\u0020\u007f]/.test(P))throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const p=new URL(P);if((p.protocol==="http:"||p.protocol==="https:")&&(!p.hostname||p.username||p.password))throw new TypeError("Hyperlink HTTP targets need a host and must not contain credentials.");if(S!==void 0&&typeof S!="string")throw new TypeError("Hyperlink tooltip must be text.");return Object.freeze({target:p.href,...S===void 0?{}:{tooltip:S}})}return Object.freeze({copyExportLink:R})})(),Se=(()=>{const{isDate:R}=De,{copyExportLink:D}=We,F=Symbol.for("@evotecit/officeimo/ExportCell");function P(E){if(!E||typeof E!="object"||Array.isArray(E))throw new TypeError("Cell presentation must be an object.");const w={};for(const g of["background","color","numberFormat","bold","italic","wrapText","alignment"]){const c=E[g];if(c!==void 0){if(["bold","italic","wrapText"].includes(g)){if(typeof c!="boolean")throw new TypeError("Cell presentation "+g+" must be boolean.")}else if(typeof c!="string")throw new TypeError("Cell presentation "+g+" must be text.");if(g==="alignment"&&!["left","center","right","fill","justify","distributed"].includes(c))throw new TypeError("Invalid cell presentation alignment.");w[g]=c}}return Object.freeze(w)}class S{value;static[Symbol.hasInstance](w){return!!w&&typeof w=="object"&&w[F]===!0}text;presentation;link;constructor(w,g={}){this.value=w;const{text:c,presentation:r,link:s}=g;if(c!==void 0&&typeof c!="string")throw new TypeError("Display text must be a string.");p(w),this.text=c,this.presentation=r===void 0?void 0:P(r),this.link=s===void 0?void 0:D(s),Object.defineProperty(this,F,{value:!0}),Object.freeze(this)}}function p(E){const w=typeof E;if(!(E==null||w==="string"||w==="number"||w==="boolean"||R(E)))throw typeof E.then=="function"&&Promise.resolve(E).catch(()=>{}),new TypeError("Export values and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}function f(E){E!==null&&typeof E=="object"&&E instanceof S||p(E)}return Object.freeze({copyCellPresentation:P,ExportCell:S,assertScalar:p,assertExportValue:f})})(),je=(()=>{function R(F,P){const S={...F};for(const p of P){if(Object.hasOwn(S,p))continue;const f=F[p];f!==void 0&&(S[p]=f)}return S}return Object.freeze({captureFields:R})})(),He=(()=>{const{assertExportValue:R}=Se,{checkAbort:D}=he,{isDate:F}=De,{captureFields:P}=je;function S(E,w,g,c=R){const r=E.some(s=>s.value);return(s,o=0)=>{if(Array.isArray(s)&&!r){const h=s.length;if(h>E.length)throw new RangeError("Row has more values than declared columns.");const t=new Array(h);for(let i=0;i<h;i++){const e=s[i];c(e),t[i]=e}return t}if(!s||typeof s!="object"||F(s))throw new TypeError("A row must be an array or object.");if(Array.isArray(s)&&s.length>E.length&&!E.every(h=>h.value))throw new RangeError("Project every column explicitly when selecting from a wider array row.");return E.map((h,t)=>{if(h.value){D(g);const n={rowIndex:o,columnIndex:t,column:h,...w?{sheetName:w.sheetName,worksheetRow:w.firstDataRow+o}:{}},l=h.value(s,n);return c(l),D(g),l}if(Array.isArray(s)){const n=s[t];return c(n),n}const i=h.key??h.header,e=Object.prototype.hasOwnProperty.call(s,i)?s[i]:void 0;return c(e),e})}}const p=["header","key","value","width","type","format","wrapText","alignment","rowHeader","groups","style","valueFormatter"];function f(E,w=!1){if(!Array.isArray(E))throw new TypeError("Declare the columns in export order.");return E.map(g=>{if(!g||typeof g!="object"&&typeof g!="function")throw new TypeError("Each column needs a string header and an optional string key.");const c=P(g,p);if(!w&&c.style!==void 0)throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");if(typeof c.header!="string"||c.key!==void 0&&typeof c.key!="string")throw new TypeError("Each column needs a string header and an optional string key.");if(c.value!==void 0&&typeof c.value!="function")throw new TypeError("Column value getters must be functions.");if(c.rowHeader!==void 0&&typeof c.rowHeader!="boolean")throw new TypeError("Column rowHeader must be boolean.");if(c.groups!==void 0){if(!Array.isArray(c.groups))throw new TypeError("Column groups must be an array of strings.");const r=Array.from(c.groups);if(r.some(s=>typeof s!="string"))throw new TypeError("Column groups must be an array of strings.");return{...c,groups:Object.freeze(r)}}return c})}return Object.freeze({createRowProjector:S,columnOptionFields:p,copyColumns:f})})(),nt=(()=>{const{OfficeIMOError:R}=ae,{captureFields:D}=je;class F{cells=0;text=0;reservedCells=0;reservedText=0;limits;constructor(f={}){if(!f||typeof f!="object"||Array.isArray(f))throw new TypeError("Export limits must be an object.");const T=D(f,["maxRows","maxCells","maxTextCharacters","maxOutputBytes"]);for(const[E,w]of Object.entries(T))if(w!==void 0&&(!Number.isSafeInteger(w)||w<0))throw new RangeError(E+" must be a nonnegative safe integer.");this.limits=Object.freeze(T)}check(f,T){const E=this.limits[f];if(E!==void 0&&T>E)throw new R("RESOURCE_LIMIT",f+" exceeded ("+T+" > "+E+").")}row(f){this.check("maxRows",f)}reserve(f,T){this.check("maxCells",this.cells+this.reservedCells+f),this.check("maxTextCharacters",this.text+this.reservedText+T),this.reservedCells+=f,this.reservedText+=T}release(f,T){this.reservedCells-=f,this.reservedText-=T}cell(f,T){if(T!==void 0&&this.release(1,T),this.limits.maxCells===void 0&&this.limits.maxTextCharacters===void 0)return;this.check("maxCells",this.cells+this.reservedCells+1);const E=typeof f=="string"?f.length:0;this.check("maxTextCharacters",this.text+this.reservedText+E),this.cells++,this.text+=E}}function P(p,f){let T=0;return{write(E){return f.check("maxOutputBytes",T+E.length),T+=E.length,p.write(E)}}}return Object.freeze({ExportBudget:F,boundedSink:P})})(),qe=(()=>{const{ExportCell:R,assertExportValue:D}=Se,{isDate:F}=De;function P(p){if(D(p),F(p))return new Date(Date.prototype.getTime.call(p));if(p instanceof R){const{value:f,text:T,presentation:E,link:w}=p;return new R(F(f)?new Date(Date.prototype.getTime.call(f)):f,{...T===void 0?{}:{text:T},...E===void 0?{}:{presentation:E},...w===void 0?{}:{link:w}})}return p}return Object.freeze({copyExportValue:P})})(),rt=(()=>{const{assertExportValue:R}=Se,{copyExportValue:D}=qe;function F(p,f){if(!Array.isArray(p)||!p.length||p.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const T=p.map(E=>{if(!Array.isArray(E)||E.length!==f)throw new TypeError("Spanned rows must have the declared column count.");return Object.freeze(E.map(w=>{if(w===null)return null;if(!w||typeof w!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const{value:g,columnSpan:c,rowSpan:r}=w;return Object.freeze({value:D(g),...c===void 0?{}:{columnSpan:c},...r===void 0?{}:{rowSpan:r}})}))});return P(T,f),Object.freeze(T)}function P(p,f){if(!Array.isArray(p)||!p.length||p.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const T=Array.from({length:p.length},()=>new Uint8Array(f));return p.map((E,w)=>{if(!Array.isArray(E)||E.length!==f)throw new TypeError("Spanned rows must have the declared column count.");const g=[];for(let c=0;c<f;c++){const r=E[c];if(T[w][c]){if(r!==null)throw new TypeError("Covered heading/footer cells must be null.");continue}if(!r||typeof r!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const s=r.columnSpan??1,o=r.rowSpan??1;if(!Number.isInteger(s)||!Number.isInteger(o)||s<1||o<1||c+s>f||w+o>p.length)throw new RangeError("Heading/footer spans must stay inside the declared matrix.");const h=r.value;R(h);for(let t=w;t<w+o;t++)for(let i=c;i<c+s;i++){if(T[t][i])throw new TypeError("Heading/footer spans overlap.");if((t!==w||i!==c)&&p[t]?.[i]!==null)throw new TypeError("Covered heading/footer cells must be null.");T[t][i]=1}g.push(Object.freeze({first:c,span:s,rowSpan:o,value:h}))}return Object.freeze(g)})}return Object.freeze({captureTableSpans:F,tableSpans:P})})(),Ae=(()=>{const{captureFields:R}=je;function D(p,f,T=14400){if(!Number.isFinite(p)||p<=0||p>T)throw new RangeError(f+" must be positive and at most "+T+".");return p}function F(p){if(typeof p!="string"||!/^#?[0-9a-f]{6}$/i.test(p))throw new TypeError("PDF colors must be six-digit RGB hex strings.");const f=p.replace(/^#/,"");return[0,2,4].map(T=>String(Math.round(parseInt(f.slice(T,T+2),16)/255*1e4)/1e4)).join(" ")}function P(p={}){if(!p||typeof p!="object")throw new TypeError("PDF presentation must be an object.");const f=R(p,["background","color","numberFormat","bold","italic","wrapText","alignment"]);f.background!==void 0&&F(f.background),f.color!==void 0&&F(f.color);for(const T of["bold","italic","wrapText"])if(f[T]!==void 0&&typeof f[T]!="boolean")throw new TypeError("PDF presentation "+T+" must be boolean.");if(f.alignment!==void 0&&!["left","center","right"].includes(f.alignment))throw new TypeError("PDF table alignment supports left, center and right.");return Object.freeze(f)}return Object.freeze({positive:D,color:F,presentation:P})})(),Ve=(()=>{const{OfficeIMOError:R}=ae,{positive:D,presentation:F}=Ae,P=["fontSize","presentation","keepTogether","keepWithNext","spaceBefore","spaceAfter"],S=["bold","italic","color","alignment"];function p(w){if(w&&typeof w.then=="function")throw Promise.resolve(w).catch(()=>{}),new TypeError("PDF paragraph styles must be synchronous objects.");if(!w||typeof w!="object"||Array.isArray(w)||Object.keys(w).some(t=>!P.includes(t)))throw new TypeError("PDF paragraph styles support fontSize, presentation, keepTogether, keepWithNext, spaceBefore and spaceAfter.");const{fontSize:g,presentation:c,keepTogether:r,keepWithNext:s,spaceBefore:o,spaceAfter:h}=w;g!==void 0&&D(g,"Paragraph font size",144);for(const[t,i]of[["keepTogether",r],["keepWithNext",s]])if(i!==void 0&&typeof i!="boolean")throw new TypeError("Paragraph "+t+" must be boolean.");for(const t of[o,h])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(c!==void 0&&(!c||typeof c!="object"||Array.isArray(c)||Object.keys(c).some(t=>!S.includes(t))))throw new TypeError("PDF paragraph presentation supports bold, italic, color and alignment.");return Object.freeze({...g===void 0?{}:{fontSize:g},...c===void 0?{}:{presentation:F(c)},...r===void 0?{}:{keepTogether:r},...s===void 0?{}:{keepWithNext:s},...o===void 0?{}:{spaceBefore:o},...h===void 0?{}:{spaceAfter:h}})}function f(w,g){if(!Number.isSafeInteger(g)||g<0)throw new RangeError("maxParagraphStyles must be a nonnegative safe integer.");const c=Object.create(null);if(w===void 0)return Object.freeze(c);if(w&&typeof w.then=="function")throw Promise.resolve(w).catch(()=>{}),new TypeError("paragraphStyles must be a synchronous record.");if(!w||typeof w!="object"||Array.isArray(w))throw new TypeError("paragraphStyles must be a record of named paragraph styles.");const r=Object.keys(w);if(r.length>g)throw new R("RESOURCE_LIMIT","maxParagraphStyles exceeded.");for(const s of r){if(!s.trim())throw new TypeError("Paragraph style names must be nonempty text.");c[s]=p(w[s])}return Object.freeze(c)}function T(w,g,c){let r={};if(w!==void 0){if(typeof w!="string"||!Object.prototype.hasOwnProperty.call(c,w))throw new TypeError("Unknown PDF paragraph style: "+String(w));r=c[w]}const s=p(g);return Object.freeze({...r,...s,...r.presentation||s.presentation?{presentation:Object.freeze({...r.presentation,...s.presentation})}:{}})}return Object.freeze({captureParagraphStyle:p,captureParagraphStyles:f,resolveParagraphStyle:T})})(),it=(()=>{const R=Object.freeze({true:"True",false:"False"});function D(P){if(P===void 0)return R;if(!P||typeof P!="object")throw new TypeError("booleanText must contain true and false strings.");const S=P.true,p=P.false;if(typeof S!="string"||typeof p!="string")throw new TypeError("booleanText must contain true and false strings.");return Object.freeze({true:S,false:p})}return Object.freeze({defaultBooleanText:R,captureBooleanText:D})})(),Te=(()=>{const{OfficeIMOError:R}=ae,{ExportBudget:D}=nt,{copyColumns:F}=He,{captureTableSpans:P}=rt,{copyExportValue:S}=qe,{captureFields:p}=je,{captureParagraphStyles:f}=Ve,{captureBooleanText:T}=it,{positive:E,color:w,presentation:g}=Ae,c={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}},r=["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"],s=["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(a){if(!a||typeof a!="object"||Array.isArray(a))throw new TypeError("PDF options must be an object.");const d=p(a,r),u=d.wideTable;return{...d,...u===void 0?{}:{wideTable:i(u)}}}function h(a){if(!a||typeof a!="object"||Array.isArray(a))throw new TypeError("PDF limits must be an object.");const d=p(a,s);for(const[u,x]of Object.entries(d))if(x!==void 0&&(!Number.isSafeInteger(x)||x<0))throw new RangeError(u+" must be a nonnegative safe integer.");return Object.freeze(d)}function t(a,d){if(!a||typeof a!="object"||Array.isArray(a))throw new TypeError("PDF footer must be an object.");const{values:u,totals:x,rows:b}=a;if(u!==void 0&&!Array.isArray(u))throw new TypeError("PDF footer values must be an array.");return Object.freeze({...u===void 0?{}:{values:Object.freeze(u.map(S))},...x===void 0?{}:{totals:Object.freeze({...x})},...b===void 0?{}:{rows:P(b,d)}})}function i(a){if(a===void 0||a==="fit"||a==="reject")return a;if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(y=>!["mode","minimumColumnWidth","repeatColumns"].includes(y)))throw new TypeError("wideTable must be fit, reject or a bands policy.");const{mode:d,minimumColumnWidth:u,repeatColumns:x}=a;if(d!=="bands")throw new TypeError("wideTable.mode must be bands.");if(u!==void 0&&E(u,"Minimum PDF column width"),x!==void 0&&!Array.isArray(x))throw new TypeError("repeatColumns must be an array.");const b=x===void 0?[]:[...x];if(b.some(y=>typeof y=="number"?!Number.isSafeInteger(y)||y<0:typeof y!="string"||!y.length))throw new RangeError("repeatColumns must contain nonnegative indices or nonempty stable keys.");if(b.every(y=>typeof y=="number")&&b.some((y,C)=>C>0&&y<=b[C-1]))throw new RangeError("Numeric repeatColumns must contain sorted unique nonnegative indices.");return Object.freeze({mode:d,...u===void 0?{}:{minimumColumnWidth:u},repeatColumns:Object.freeze(b)})}function e(a,d){if(typeof a!="object")return Object.freeze([]);const u=new Set;for(const x of a.repeatColumns??[]){let b;if(typeof x=="number")b=x;else if(b=d.findIndex(y=>y.key===x),b<0||d.some((y,C)=>C!==b&&y.key===x))throw new TypeError("repeatColumns requires an unambiguous selected column key: "+x);if(b>=d.length)throw new RangeError("repeatColumns index exceeds the declared columns.");if(u.has(b))throw new TypeError("repeatColumns selects the same column more than once.");u.add(b)}return Object.freeze([...u].sort((x,b)=>x-b))}function n(a,d=!1){const u={...o(a)};if(u.booleanText=T(u.booleanText),u.limits!==void 0&&(u.limits=h(u.limits)),u.pageSize&&typeof u.pageSize=="object"&&(u.pageSize=Object.freeze(p(u.pageSize,["width","height"]))),u.margins&&typeof u.margins=="object"&&(u.margins=Object.freeze(p(u.margins,["top","right","bottom","left"]))),u.pageNumberLabels!==void 0){const B=u.pageNumberLabels;if(!B||typeof B!="object"||Array.isArray(B))throw new TypeError("pageNumberLabels must provide literal text.");const{prefix:L="Page ",separator:H=" of ",suffix:G=""}=B;if([L,H,G].some(W=>typeof W!="string"))throw new TypeError("Page-number labels must be text.");u.pageNumberLabels=Object.freeze({prefix:L,separator:H,suffix:G})}const x=u.textShaper,b=x?.shapeLine;if(x!==void 0&&(!x||typeof b!="function"))throw new TypeError("textShaper must provide shapeLine.");if(u.textDirection!==void 0&&!["auto","ltr","rtl"].includes(u.textDirection))throw new TypeError("textDirection must be auto, ltr or rtl.");const y=d?[]:F(u.columns).map(B=>Object.freeze(B));if(d&&(u.includeHeader=!1),!y.length&&!d)throw new TypeError("PDF tables need at least one declared column.");const C=u.fonts===void 0?void 0:p(u.fonts,["regular","bold","italic","boldItalic"]),m={...u,columns:y,...x?{textShaper:Object.freeze({shapeLine:b.bind(x)})}:{},...u.tagged?{tagged:Object.freeze(p(u.tagged,["language"]))}:{},...u.headerRows?{headerRows:P(u.headerRows,y.length)}:{},...C?{fonts:Object.freeze(C)}:{},...u.columnWidths?{columnWidths:Object.freeze([...u.columnWidths])}:{},...u.footer===void 0?{}:{footer:t(u.footer,y.length)},headerPresentation:Object.freeze({background:"e7edf5",bold:!0,...g(u.headerPresentation)}),footerPresentation:Object.freeze({background:"eef2f6",bold:!0,...g(u.footerPresentation)})},k=new D(m.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 B of Object.keys(I)){const L=m.limits?.[B];L!==void 0&&(I[B]=L)}const v=f(m.paragraphStyles,I.maxParagraphStyles);if(y.length>I.maxColumns)throw new R("RESOURCE_LIMIT","maxColumns exceeded.");const j=typeof m.pageSize=="string"||m.pageSize===void 0?c[m.pageSize??"A4"]:m.pageSize;if(!j)throw new TypeError("Unsupported PDF page size.");if(E(j.width,"Page width"),E(j.height,"Page height"),m.orientation!==void 0&&!["portrait","landscape"].includes(m.orientation))throw new TypeError("Invalid PDF orientation.");const M=m.orientation==="landscape",_={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)},A={top:36,right:36,bottom:36,left:36,...typeof m.margins=="number"?{top:m.margins,right:m.margins,bottom:m.margins,left:m.margins}:m.margins};for(const B of Object.values(A))if(!Number.isFinite(B)||B<0)throw new RangeError("PDF margins must be finite and nonnegative.");if(A.left+A.right>=_.width||A.top+A.bottom>=_.height)throw new RangeError("PDF margins leave no content area.");const N=E(m.fontSize??9,"Font size",144),z=m.padding??4;if(!Number.isFinite(z)||z<0||z>72)throw new RangeError("PDF padding must be from 0 through 72 points.");for(const B of["title","messageTop","messageBottom"])if(m[B]!==void 0&&typeof m[B]!="string")throw new TypeError(B+" must be text.");for(const B of["pageHeader","pageFooter"])if(m[B]!==void 0&&typeof m[B]!="string"&&typeof m[B]!="function")throw new TypeError(B+" must be text or a synchronous callback.");for(const B of["formatValue","formatRuns"])if(m[B]!==void 0&&typeof m[B]!="function")throw new TypeError(B+" must be a synchronous function.");for(const B of["compression","includeHeader","pageNumbers"])if(m[B]!==void 0&&typeof m[B]!="boolean")throw new TypeError(B+" must be boolean.");if(m.alternateRowColor!==void 0&&w(m.alternateRowColor),m.footer?.values&&m.footer.values.length>y.length)throw new RangeError("Footer has more values than declared columns.");if(m.footer?.rows&&(m.footer.values!==void 0||m.footer.totals!==void 0))throw new TypeError("Structured footer rows cannot be combined with values/totals.");if(m.headerRows&&m.includeHeader===!1)throw new TypeError("headerRows requires includeHeader.");if(m.tagged!==void 0){if(!m.tagged||typeof m.tagged!="object"||typeof m.tagged.language!="string"||m.tagged.language.length>63)throw new TypeError("tagged.language must be a language tag such as en or en-US.");try{if(Intl.getCanonicalLocales(m.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 O=m.limits?.maxImageWorkingBytes;return{options:{...m,paragraphStyles:v},paragraphStyles:v,page:_,margins:A,fontSize:N,padding:z,repeatedColumns:d?Object.freeze([]):e(m.wideTable,y),limits:{...I,...O===void 0?{}:{maxImageWorkingBytes:O}},budget:k}}return Object.freeze({positive:Ae.positive,color:Ae.color,presentation:Ae.presentation,pdfOptionFields:r,pdfLimitFields:s,capturePdfOptions:o,capturePdfLimits:h,captureWideTable:i,settings:n})})(),ut=(()=>{function D(S,p,f,T){if(!Number.isSafeInteger(f)||f<0||f>=2**(T*8))throw new RangeError("Invalid PDF cross-reference field.");for(let E=T-1;E>=0;E--)S[p+E]=f%256,f=Math.floor(f/256)}function*F(S,p){if(S.length!==p.length)throw new Error("PDF cross-reference locations must align.");const f=Math.floor(32768/11);for(let T=0;T<S.length;T+=f){const E=Math.min(f,S.length-T),w=new Uint8Array(E*11);for(let g=0;g<E;g++){const c=T+g,r=g*11,s=S[c],o=p.at(c);if(s===void 0)throw new Error("PDF contains unwritten objects.");w[r]=c===0?0:o===void 0?1:2,D(w,r+1,s,8),D(w,r+9,c===0?65535:o??0,2)}yield w}}return Object.freeze({pdfXrefEntryBytes:11,pdfXrefChunks:F})})(),Pe=(()=>{const{checkAbort:R,withAbort:D,pause:F,taskYieldDue:P}=he,{OfficeIMOError:S}=ae,{pdfXrefChunks:p,pdfXrefEntryBytes:f}=ut,T=256,E=32768,w=4096;class g{count;chunks=[];constructor(t){this.count=t}get length(){return this.count}reserve(){this.count++}set(t,i){const e=this.chunks[Math.floor(t/w)]??=new Uint16Array(w);e[t%w]=i+1}at(t){const i=this.chunks[Math.floor(t/w)]?.[t%w]??0;return i?i-1:void 0}}function c(h){if(!Number.isFinite(h)||Math.abs(h)>1e9)throw new RangeError("PDF coordinates and metrics must be finite and bounded.");return String(Math.round(h*1e3)/1e3)}function r(h){let t="";for(let i=0;i<h.length;i++){const e=h.charCodeAt(i);if(e>=55296&&e<=56319&&!(h.charCodeAt(i+1)>=56320&&h.charCodeAt(i+1)<=57343)||e>=56320&&e<=57343&&!(h.charCodeAt(i-1)>=55296&&h.charCodeAt(i-1)<=56319))throw new TypeError("PDF text contains an unpaired UTF-16 surrogate.");t+=e.toString(16).padStart(4,"0")}return t}class s{sink;signal;maxBytes;compressObjects;offsets=[0];compactIndices;compactBatch;compactArena;compactUnavailable=!1;encoder=new TextEncoder;buffer=new Uint8Array(32768);buffered=0;bytes=0;constructor(t,i,e=Number.MAX_SAFE_INTEGER,n=!1){this.sink=t,this.signal=i,this.maxBytes=e,this.compressObjects=n}reserve(){return this.offsets.push(void 0),this.compactIndices?.reserve(),this.offsets.length-1}async raw(t){if(R(this.signal),!Number.isSafeInteger(this.bytes+t.length)||this.bytes+t.length>this.maxBytes)throw new S("RESOURCE_LIMIT","maxOutputBytes exceeded.");this.bytes+=t.length;for(let i=0;i<t.length;){const e=Math.min(this.buffer.length-this.buffered,t.length-i);this.buffer.set(t.subarray(i,i+e),this.buffered),i+=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 D(Promise.resolve(this.sink.write(t)),this.signal),this.buffered=0}P()&&await F(),R(this.signal)}tryCompactObject(t,i){R(this.signal),this.validateObject(t);const e=this.compactBatch;if(!e||!this.compressObjects||this.compactUnavailable||typeof CompressionStream!="function"||i.length>E||e.ids.length+1>=T)return!1;const n=String(t).length+String(e.bodyBytes).length+2,l=this.encodeCompactBody(i,e.bodyBytes,E-e.indexBytes-n-e.bodyBytes-2);return l===void 0?!1:(this.storeCompactBody(e,t,l),!0)}async compactObject(t,i){if(R(this.signal),this.validateObject(t),!this.compressObjects||this.compactUnavailable||i.length>E)return this.object(t,i);if(typeof CompressionStream!="function"){if(this.compactIndices)throw new Error("PDF object compression became unavailable.");return this.compactUnavailable=!0,this.object(t,i)}const e=String(t).length+4;let n=this.compactBatch;const l=String(t).length+String(n?.bodyBytes??0).length+2;let a=n&&n.ids.length<T?this.encodeCompactBody(i,n.bodyBytes,E-n.indexBytes-l-n.bodyBytes-2):void 0;if(n&&a===void 0&&(await this.flushCompact(),n=void 0,R(this.signal)),!n){if(a=this.encodeCompactBody(i,0,E-e-1),a===void 0)return this.object(t,i);let d;if(!this.compactIndices)try{d=new CompressionStream("deflate")}catch{return this.compactUnavailable=!0,this.object(t,i)}n={id:this.reserve(),compressor:d,ids:[],bodyOffsets:[],bodyBytes:0,indexBytes:1},this.compactIndices??=new g(this.offsets.length),this.compactBatch=n}this.storeCompactBody(n,t,a),n.ids.length===T&&await this.flushCompact()}storeCompactBody(t,i,e){this.offsets[i]=t.id,this.compactIndices.set(i,t.ids.length),t.indexBytes+=String(i).length+String(t.bodyBytes).length+2,t.ids.push(i),t.bodyOffsets.push(t.bodyBytes),this.compactArena[t.bodyBytes+e]=10,t.bodyBytes+=e+1}encodeCompactBody(t,i,e){if(e<0)return;const n=(this.compactArena??=new Uint8Array(E)).subarray(i,i+e);if(typeof this.encoder.encodeInto=="function"){const a=this.encoder.encodeInto(t,n);return a.read===t.length?a.written:void 0}const l=this.encoder.encode(t);if(!(l.length>e))return n.set(l),l.length}async flushCompact(){const t=this.compactBatch;if(!t)return;this.compactBatch=void 0;let i="";for(let a=0;a<t.ids.length;a++)i+=t.ids[a]+" "+t.bodyOffsets[a]+" ";const e=this.encoder.encode(i+"\n"),n=t.ids.length,l=this.compactArena.subarray(0,t.bodyBytes);t.ids.length=0,t.bodyOffsets.length=0,t.compressor?await this.compressedStream(t.id,l,"/Type /ObjStm /N "+n+" /First "+e.length,t.compressor,e):(this.start(t.id),await this.text(t.id+" 0 obj\n<< /Length "+(e.length+l.length)+" /Type /ObjStm /N "+n+" /First "+e.length+" >>\nstream\n"),await this.raw(e),await this.raw(l),await this.text("\nendstream\nendobj\n"))}async object(t,i){if(this.start(t),typeof i=="string"){await this.text(t+" 0 obj\n"+i+"\nendobj\n");return}let e=t+" 0 obj\n";for(const n of i)for(let l=0;l<n.length;){const a=Math.min(n.length,l+32768-e.length);if(e+=n.slice(l,a),l=a,e.length===32768){const d=e.charCodeAt(e.length-1),u=d>=55296&&d<=56319?e.length-1:e.length;await this.text(e.slice(0,u)),e=e.slice(u)}}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,i,e="",n=!0,l=!1){const a=typeof i=="string"?this.encoder.encode(i):i;let d;if(n&&typeof CompressionStream=="function"&&a.length)try{d=new CompressionStream("deflate")}catch{}if(!d){this.start(t),await this.text(t+" 0 obj\n<< /Length "+a.length+" "+e+" >>\nstream\n"),await this.raw(a),await this.text("\nendstream\nendobj\n");return}const u=typeof i=="string"||l?a:new Uint8Array(a);await this.compressedStream(t,u,e,d)}async compressedStream(t,i,e,n,l){const d=new ReadableStream({start(y){l&&y.enqueue(l),y.enqueue(i),y.close()}}).pipeThrough(n).getReader(),u=this.reserve();let x=0,b=!1;try{for(this.start(t),await this.text(t+" 0 obj\n<< /Length "+u+" 0 R /Filter /FlateDecode "+e+" >>\nstream\n");;){const y=await D(d.read(),this.signal);if(y.done){b=!0;break}x+=y.value.length,await this.raw(y.value)}await this.text("\nendstream\nendobj\n"),await this.object(u,String(x))}finally{b||d.cancel(this.signal?.reason).catch(()=>{}),d.releaseLock()}}async finish(t,i){await this.flushCompact();for(let n=1;n<this.offsets.length;n++)if(this.offsets[n]===void 0)throw new Error("PDF contains unwritten objects.");if(this.bytes>9999999999)throw new S("RESOURCE_LIMIT","PDF exceeds classic cross-reference offset capacity.");if(this.compactIndices)return this.finishCompact(t,i);const e=this.bytes;await this.text("xref\n0 "+this.offsets.length+"\n0000000000 65535 f \n");for(let n=1;n<this.offsets.length;n++)await this.text(String(this.offsets[n]).padStart(10,"0")+" 00000 n \n");await this.text("trailer\n<< /Size "+this.offsets.length+" /Root "+t+" 0 R /Info "+i+" 0 R >>\nstartxref\n"+e+"\n%%EOF\n"),await this.flush()}async finishCompact(t,i){const e=this.reserve(),n=this.bytes,l=this.offsets.length*f;if(!Number.isSafeInteger(l))throw new S("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 "+i+" 0 R /Length "+l+" >>\nstream\n");for(const a of p(this.offsets,this.compactIndices))await this.raw(a);await this.text("\nendstream\nendobj\nstartxref\n"+n+"\n%%EOF\n"),await this.flushBytes()}}return Object.freeze({pdfNumber:c,unicodeHex:r,PdfObjects:s})})(),st=(()=>{class R{bytes;view;constructor(p){this.bytes=p,this.view=new DataView(p.buffer,p.byteOffset,p.byteLength)}range(p,f){if(!Number.isSafeInteger(p)||!Number.isSafeInteger(f)||p<0||f<0||p+f>this.bytes.length)throw new TypeError("Truncated or invalid TrueType table.")}u16(p){return this.range(p,2),this.view.getUint16(p)}i16(p){return this.range(p,2),this.view.getInt16(p)}u32(p){return this.range(p,4),this.view.getUint32(p)}tag(p){return this.range(p,4),String.fromCharCode(...this.bytes.subarray(p,p+4))}}function D(S){let p=0;for(let f=0;f<S.length;f+=4)p=p+((S[f]??0)*16777216+((S[f+1]??0)<<16)+((S[f+2]??0)<<8)+(S[f+3]??0))>>>0;return p}return Object.freeze({FontReader:R,checksum:D,align4:S=>Math.ceil(S/4)*4})})(),pt=(()=>{const{align4:R}=st,{checkAbort:D,pause:F,taskYieldDue:P}=he;function S(r,s,o){const h=f(r,s,o);for(;;){const t=h.next();if(t.done)return t.value}}async function p(r,s,o,h){D(h);const t=f(r,s,o);for(;;){const i=t.next();if(i.done)return D(h),i.value;P()&&await F(),D(h)}}function*f(r,s,o){const h=new Set([0,...s]),t=r.table("glyf"),i=[...h],e=new Map;let n=0;for(let O=0;O<i.length;O++){(++n&1023)===0&&(yield);const B=i[O];if(!Number.isInteger(B)||B<0||B>=r.glyphCount)throw new TypeError("Invalid subset glyph.");const L=r.offsets[B],H=r.offsets[B+1];if(L===H)continue;if(H-L<10)throw new TypeError("Truncated TrueType glyph header.");if(r.i16(t.offset+L)>=0)continue;let G=t.offset+L+10,W;const X=[];e.set(B,X);const K=t.offset+H;do{if(G+4>K)throw new TypeError("Truncated TrueType composite.");W=r.u16(G);const V=r.u16(G+2);if(V>=r.glyphCount)throw new TypeError("Invalid TrueType composite dependency.");if(X.push(V),(++n&1023)===0&&(yield),h.has(V)||(h.add(V),i.push(V)),G+=4+(W&1?4:2)+(W&8?2:W&64?4:W&128?8:0),G>K)throw new TypeError("Truncated TrueType composite transform.")}while(W&32);if(W&256&&(G+2>K||G+2+r.u16(G)>K))throw new TypeError("Truncated composite instructions.")}const l=new Set,a=new Set;function*d(O,B){if((++n&1023)===0&&(yield),a.has(O))throw new TypeError("Cyclic TrueType composite dependency.");if(B>64)throw new TypeError("TrueType composite nesting exceeds 64 levels.");if(!l.has(O)){a.add(O);for(const L of e.get(O)??[])yield*d(L,B+1);a.delete(O),l.add(O)}}for(const O of h)yield*d(O,0);const u=new Uint32Array(r.glyphCount+1);let x=0;for(let O=0;O<r.glyphCount;O++)u[O]=x,h.has(O)&&(x+=R(r.offsets[O+1]-r.offsets[O])),(O&1023)===1023&&(yield);u[r.glyphCount]=x;const b=new Uint8Array(x);for(const O of h)yield*w(r.bytes.subarray(t.offset+r.offsets[O],t.offset+r.offsets[O+1]),b,u[O]),(++n&1023)===0&&(yield);const y=new Uint8Array(u.length*4),C=new DataView(y.buffer);for(let O=0;O<u.length;O++)C.setUint32(O*4,u[O]),(O&1023)===1023&&(yield);const m=new Set(["OS/2","cmap","cvt ","fpgm","gasp","glyf","head","hhea","hmtx","loca","maxp","name","post","prep"]),k=yield*E(o),I=yield*T(r,h),v=[];for(const[O,B]of[...r.tables].filter(([L])=>m.has(L)).sort(([L],[H])=>L<H?-1:1)){const L=O==="glyf"?b:O==="loca"?y:O==="cmap"?k:O==="hmtx"?I:void 0,H=L??new Uint8Array(B.length);if(L||(yield*w(r.bytes.subarray(B.offset,B.offset+B.length),H)),O==="head"){const G=new DataView(H.buffer);G.setUint32(8,0),G.setInt16(50,1)}v.push({tag:O,bytes:H})}const j=12+v.length*16+v.reduce((O,B)=>O+R(B.bytes.length),0),M=new Uint8Array(j),_=new DataView(M.buffer);_.setUint32(0,65536),_.setUint16(4,v.length);const A=2**Math.floor(Math.log2(v.length));_.setUint16(6,A*16),_.setUint16(8,Math.log2(A)),_.setUint16(10,v.length*16-A*16);let N=12+v.length*16,z=0;for(let O=0;O<v.length;O++){const B=v[O],L=12+O*16;for(let H=0;H<4;H++)M[L+H]=B.tag.charCodeAt(H);_.setUint32(L+4,yield*g(B.bytes)),_.setUint32(L+8,N),_.setUint32(L+12,B.bytes.length),yield*w(B.bytes,M,N),B.tag==="head"&&(z=N),N+=R(B.bytes.length)}return _.setUint32(z+8,2981146554-(yield*g(M))>>>0),M}function*T(r,s){let o=0;const h=r.u16(r.table("hhea").offset+34),t=r.table("hmtx"),i=new Uint8Array(h*4+(r.glyphCount-h)*2);for(const e of s){(++o&1023)===0&&(yield);const n=e<h?e*4:h*4+(e-h)*2,l=e<h?4:2;if(i.set(r.bytes.subarray(t.offset+n,t.offset+n+l),n),e>=h){const a=(h-1)*4;i.set(r.bytes.subarray(t.offset+a,t.offset+a+2),a)}}return i}function*E(r){let s=0;const o=[...r].sort(([e],[n])=>e-n),h=[];for(const[e,n]of o){(++s&1023)===0&&(yield);const l=h.at(-1);l&&e===l.last+1&&n===l.glyph+e-l.first?l.last=e:h.push({first:e,last:e,glyph:n})}const t=new Uint8Array(28+h.length*12),i=new DataView(t.buffer);i.setUint16(2,1),i.setUint16(4,3),i.setUint16(6,10),i.setUint32(8,12),i.setUint16(12,12),i.setUint32(16,t.length-12),i.setUint32(24,h.length);for(let e=0;e<h.length;e++){const n=h[e],l=28+e*12;i.setUint32(l,n.first),i.setUint32(l+4,n.last),i.setUint32(l+8,n.glyph),(e&1023)===1023&&(yield)}return t}function*w(r,s,o=0){for(let h=0;h<r.length;h+=65536)s.set(r.subarray(h,Math.min(r.length,h+65536)),o+h),yield}function*g(r){let s=0;for(let o=0;o<r.length;o+=4)s=s+((r[o]??0)*16777216+((r[o+1]??0)<<16)+((r[o+2]??0)<<8)+(r[o+3]??0))>>>0,(o&65535)===65532&&(yield);return s}return Object.freeze({subsetTrueType:S,subsetTrueTypeCooperatively:p})})(),gt=(()=>{const{NotSupportedError:R}=ae,{FontReader:D}=st,{subsetTrueType:F,subsetTrueTypeCooperatively:P}=pt,{checkAbort:S,pause:p,taskYieldDue:f}=he;class T extends D{tables;glyphCount;units;ascent;descent;bbox;widths;offsets;canSubset;cmaps;constructor(c,r){super(c);const s=E(this);let o=r;if(!o)for(;;){const h=s.next();if(h.done){o=h.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(c,r){S(r);const s=E(new D(c));for(;;){const o=s.next();if(o.done)return S(r),new T(c,o.value);f()&&await p(),S(r)}}table(c,r=0){const s=this.tables.get(c);if(!s||s.length<r)throw new TypeError("Missing or truncated TrueType table: "+c);return s}glyph(c){for(const r of this.cmaps){const s=r.offset,o=this.u16(s);let h=0;if(o===12){let t=0,i=this.u32(s+12)-1;for(;t<=i;){const e=t+i>>>1,n=s+16+e*12,l=this.u32(n),a=this.u32(n+4);if(c<l)i=e-1;else if(c>a)t=e+1;else{h=this.u32(n+8)+c-l;break}}}else if(c<=65535){const t=this.u16(s+6)/2;let i=0,e=t-1;for(;i<e;){const l=i+e>>>1;c>this.u16(s+14+l*2)?i=l+1:e=l}const n=this.u16(s+16+t*2+i*2);if(c>=n&&c<=this.u16(s+14+i*2)){const l=this.i16(s+16+t*4+i*2),a=s+16+t*6+i*2,d=this.u16(a);if(!d)h=c+l&65535;else{const u=a+d+(c-n)*2;if(u+2>s+r.length)throw new TypeError("cmap glyph array exceeds its table.");h=this.u16(u),h&&(h=h+l&65535)}}}if(h>=this.glyphCount)throw new TypeError("cmap references an invalid glyph.");if(h)return h}return 0}subset(c,r){return this.canSubset?F(this,c,r):this.bytes}async subsetCooperatively(c,r,s){return S(s),this.canSubset?P(this,c,r,s):this.bytes}}function*E(g){const c=new Map,r=(O,B=0)=>{const L=c.get(O);if(!L||L.length<B)throw new TypeError("Missing or truncated TrueType table: "+O);return L};if(g.u32(0)!==65536)throw new R("PDF fonts require a static TrueType .ttf with glyf outlines; collections, CFF and WOFF are unsupported.");const s=g.u16(4);if(!s||s>256)throw new TypeError("Invalid TrueType table count.");g.range(12,s*16);for(let O=0;O<s;O++){const B=12+O*16,L=g.tag(B),H=g.u32(B+8),G=g.u32(B+12);if(g.range(H,G),c.has(L))throw new TypeError("Duplicate TrueType table: "+L);c.set(L,{offset:H,length:G})}if(c.has("fvar"))throw new R("Instantiate a variable font as a static TrueType font before PDF export.");const o=r("head",54),h=r("maxp",6),t=r("hhea",36),i=r("OS/2",10);if(g.u32(o.offset+12)!==1594834165)throw new TypeError("Invalid TrueType head magic.");const e=g.u16(h.offset+4),n=g.u16(o.offset+18);if(!e||n<16||n>16384)throw new TypeError("Invalid TrueType metrics.");const l=g.u16(i.offset+8);if(l&514)throw new R("The font's embedding permissions prohibit outline embedding.");const a=!(l&256),d=1e3/n,u=g.i16(t.offset+4)*d,x=g.i16(t.offset+6)*d,b=[36,38,40,42].map(O=>g.i16(o.offset+O)*d),y=g.u16(t.offset+34);if(!y||y>e)throw new TypeError("Invalid TrueType horizontal metric count.");const C=r("hmtx",y*4+(e-y)*2),m=[];for(let O=0;O<e;O++)m.push(g.u16(C.offset+Math.min(O,y-1)*4)*d),(O&1023)===1023&&(yield);const k=g.i16(o.offset+50);if(k!==0&&k!==1)throw new TypeError("Unsupported TrueType loca index.");const I=r("loca",(e+1)*(k?4:2)),v=r("glyf"),j=[];for(let O=0;O<=e;O++)j.push(k?g.u32(I.offset+O*4):g.u16(I.offset+O*2)*2),(O&1023)===1023&&(yield);for(let O=0;O<=e;O++)if(j[O]>v.length||O&&j[O]<j[O-1])throw new TypeError("Invalid TrueType glyph offsets.");const M=r("cmap",4),_=[],A=new Set,N=g.u16(M.offset+2);if(4+N*8>M.length)throw new TypeError("Invalid TrueType cmap directory.");for(let O=0;O<N;O++){const B=M.offset+4+O*8,L=g.u16(B),H=g.u16(B+2),G=g.u32(B+4);if(L!==0&&!(L===3&&(H===1||H===10)))continue;if(G+4>M.length)throw new TypeError("Invalid cmap subtable offset.");const W=M.offset+G,X=g.u16(W);if(X!==4&&X!==12||A.has(W))continue;if(X===12&&G+16>M.length)throw new TypeError("Truncated cmap format 12.");const K=X===12?g.u32(W+4):g.u16(W+2);if(K<16||G+K>M.length)throw new TypeError("Invalid cmap length.");if(X===12){const V=g.u32(W+12);if(16+V*12>K)throw new TypeError("Invalid cmap groups.");let se=-1;for(let oe=0;oe<V;oe++){const fe=W+16+oe*12,ge=g.u32(fe),J=g.u32(fe+4),Q=g.u32(fe+8);if(ge<=se||ge>J||J>1114111||Q+J-ge>=e)throw new TypeError("Invalid cmap scalar/glyph group.");se=J,(oe&1023)===1023&&(yield)}}else{const V=g.u16(W+6)/2;if(!Number.isInteger(V)||!V||16+V*8>K)throw new TypeError("Invalid cmap segments.");let se=-1;for(let oe=0;oe<V;oe++){const fe=g.u16(W+14+oe*2),ge=g.u16(W+16+V*2+oe*2);if(fe<=se||ge>fe)throw new TypeError("Invalid cmap segment ordering.");se=fe,(oe&1023)===1023&&(yield)}}A.add(W),_.push({offset:W,length:K})}const z=_.sort((O,B)=>g.u16(B.offset)-g.u16(O.offset));if(!_.length)throw new R("TrueType font needs a Unicode cmap format 4 or 12.");return{tables:c,glyphCount:e,units:n,ascent:u,descent:x,bbox:b,widths:m,offsets:j,canSubset:a,cmaps:z}}return Object.freeze({TrueTypeFont:T})})(),_e=(()=>{const{TrueTypeFont:R}=gt,{beginTask:D,checkAbort:F}=he,P=new WeakMap,S=Symbol.for("@evotecit/officeimo/PdfFont");function p(E){let w=P.get(E);if(!w){if(!(E instanceof f)||typeof E.toBytes!="function")throw new TypeError("Invalid PdfFont instance.");const g=new f(E.toBytes());w=P.get(g),P.set(E,w)}return w}class f{static[Symbol.hasInstance](w){return!!w&&typeof w=="object"&&w[S]===!0}brand=!0;constructor(w){if(!(w instanceof Uint8Array))throw new TypeError("PdfFont requires TrueType bytes as a Uint8Array.");if(w.length>64*1024*1024)throw new RangeError("A TrueType font must not exceed 64 MiB.");P.set(this,new R(w.slice())),this.brand,Object.defineProperty(this,S,{value:!0}),Object.freeze(this)}static async create(w,g={}){if(F(g.signal),!(w instanceof Uint8Array))throw new TypeError("PdfFont requires TrueType bytes as a Uint8Array.");const c=g.maxBytes??16*1024*1024;if(!Number.isSafeInteger(c)||c<0||c>64*1024*1024)throw new RangeError("Font preparation maxBytes must be a nonnegative safe integer at most 64 MiB.");if(w.length>c)throw new RangeError("TrueType font exceeds the preparation byte limit.");D();const r=await R.create(new Uint8Array(w),g.signal);F(g.signal);const s=Object.create(f.prototype);return P.set(s,r),Object.defineProperty(s,"brand",{value:!0}),Object.defineProperty(s,S,{value:!0}),Object.freeze(s),s}toBytes(){return p(this).bytes.slice()}}return Object.freeze({fontProgram:p,PdfFont:f})})(),mt=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]]])}),ot=(()=>{const{OfficeIMOError:R}=ae,{PdfFont:D,fontProgram:F}=_e,{helveticaWidths:P}=mt,S=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((g,c)=>[g,c+128]));function p(g){return g>=32&&g<=126||g>=160&&g<=255?g:g?S.get(g):void 0}function f(g,c,r){if(g>=55296&&g<=57343)return{supported:!1,code:"unpaired-surrogate",message:"PDF text contains an unpaired UTF-16 surrogate."};if(g<32||g>=127&&g<160)return{supported:!1,code:"unsupported-control",message:"PDF text contains an unsupported control character."};const s=String.fromCodePoint(g);if(/[\p{Mark}\p{Format}]/u.test(s)||!/[\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(s)||g>=4352&&g<=4607||g>=127995&&g<=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(!c){if(p(g)===void 0)return{supported:!1,code:"embedded-font-required",message:"Text U+"+g.toString(16).toUpperCase()+" needs an embedded Unicode TrueType font; supply fonts.regular."};const h=P.get(g===160?32:g===173?45:g);return h?{supported:!0,width:h[r?1:0]}:{supported:!1,code:"missing-glyph",message:"Standard font has no metric for this character."}}let o=c.glyph(g);if(!o&&g===8239){const h=c.glyph(8201);h&&c.offsets[h]===c.offsets[h+1]&&(o=h)}return o?{supported:!0,glyph:o,width:c.widths[o]}:{supported:!1,code:"missing-glyph",message:"The supplied font has no glyph for U+"+g.toString(16).toUpperCase()+"."}}function T(g,c){if(!g)return;if(!(g.regular instanceof D))throw new TypeError("fonts.regular must be a PdfFont.");const r=new Set;for(const[s,o]of Object.entries(g)){if(!["regular","bold","italic","boldItalic"].includes(s)||!(o instanceof D))throw new TypeError("Invalid PDF font family.");r.add(o)}if(c!==void 0&&[...r].reduce((s,o)=>s+F(o).bytes.length,0)>c)throw new R("RESOURCE_LIMIT","maxFontBytes exceeded.")}function E(g,c,r){const s=g&&(c&&r?g.boldItalic:c?g.bold:r?g.italic:g.regular),o=s??g?.regular;return{font:o,syntheticBold:!!o&&c&&!s,syntheticItalic:!!o&&r&&!s}}return Object.freeze({standardCode:p,resolveScalar:f,validateFonts:T,selectFont:E})})(),wt=(()=>{const{NotSupportedError:R,OfficeIMOError:D}=ae,{fontProgram:F}=_e,{resolveScalar:P,selectFont:S,standardCode:p,validateFonts:f}=ot,{pdfNumber:T,unicodeHex:E}=Pe,{checkAbort:w,pause:g,taskYieldDue:c}=he,r=Object.freeze(Array.from({length:256},(i,e)=>e.toString(16).padStart(2,"0")));function s(i){return r[i>>>8]+r[i&255]}class o{index;bold;italic;font;shared;signal;name;object;program;syntheticBold;syntheticItalic;mappings=new Map;standardWidths=new Map;constructor(e,n,l,a,d,u,x,b,y){this.index=e,this.bold=n,this.italic=l,this.font=a,this.shared=b,this.signal=y,this.name=b?.name??"F"+e,this.object=b?.object??d.reserve(),this.program=a?F(a):void 0,this.syntheticBold=u,this.syntheticItalic=x}width(e){if(this.shared)return this.shared.width(e);if(this.program){const d=this.mappings.get(e);if(d)return d.width}else{const d=this.standardWidths.get(e);if(d!==void 0)return d}const n=P(e,this.program,this.bold);if(!n.supported)throw n.code==="unpaired-surrogate"?new TypeError(n.message):new R(n.message);if(!this.program)return this.standardWidths.set(e,n.width),n.width;if(this.mappings.size>=65535)throw new D("RESOURCE_LIMIT","A PDF font supports at most 65,535 distinct Unicode scalars.");const l=this.mappings.size+1,a={cid:l,hex:s(l),glyph:n.glyph,width:n.width,text:String.fromCodePoint(e)};return this.mappings.set(e,a),a.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 n="";for(const l of e){const a=l.codePointAt(0);if(this.program){let d=this.mappings.get(a);d||(this.width(a),d=this.mappings.get(a)),n+=d.hex}else this.standardWidths.has(a)||this.width(a),n+=r[p(a)]}return"<"+n+">"}encodeGlyph(e,n){if(this.shared)return this.shared.encodeGlyph(e,n);if(!this.program||!Number.isSafeInteger(e)||e<=0||e>=this.program.glyphCount)throw new TypeError("Invalid shaped TrueType glyph.");const l=e+":"+n;let a=this.mappings.get(l);if(!a){if(this.mappings.size>=65535)throw new D("RESOURCE_LIMIT","A PDF font supports at most 65,535 distinct CID mappings.");const d=this.mappings.size+1;a={cid:d,hex:s(d),glyph:e,width:this.program.widths[e],text:n},this.mappings.set(l,a)}return"<"+a.hex+">"}async write(e,n){if(w(this.signal),!this.program){const A="Helvetica"+(this.bold&&this.italic?"-BoldOblique":this.bold?"-Bold":this.italic?"-Oblique":"");await e.object(this.object,"<< /Type /Font /Subtype /Type1 /BaseFont /"+A+" /Encoding /WinAnsiEncoding >>");return}const l=this.program,a=[...this.mappings],d=new Set(a.map(([,A])=>A.glyph)),u=(l.canSubset?"OIMOAA+":"")+"OfficeIMOFont"+this.index,x=e.reserve(),b=e.reserve(),y=e.reserve(),C=e.reserve(),m=e.reserve(),k=new Map;for(const[A,N]of a)if(typeof A=="number")k.set(A,N.glyph);else for(const z of N.text){const O=z.codePointAt(0),B=l.glyph(O);B&&(k.set(O,B),d.add(B))}const I=await l.subsetCooperatively(d,k,this.signal);await e.stream(x,I,"/Length1 "+I.length,n,!0),await e.object(b,"<< /Type /FontDescriptor /FontName /"+u+" /Flags 32 /FontBBox ["+l.bbox.map(T).join(" ")+"] /ItalicAngle 0 /Ascent "+T(l.ascent)+" /Descent "+T(l.descent)+" /CapHeight "+T(l.ascent)+" /StemV 80 /FontFile2 "+x+" 0 R >>");const v=new Uint8Array((a.length+1)*2),j=new DataView(v.buffer);for(let A=0;A<a.length;A++){const N=a[A][1];j.setUint16(N.cid*2,N.glyph),(A&1023)===1023&&(c()&&await g(),w(this.signal))}await e.stream(C,v,"",n,!0),await e.object(y,"<< /Type /Font /Subtype /CIDFontType2 /BaseFont /"+u+" /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /FontDescriptor "+b+" 0 R /CIDToGIDMap "+C+" 0 R"+(a.length?" /W [1 ["+a.map(([,A])=>T(A.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 _=a.filter(([,A])=>A.text.length);for(let A=0;A<_.length;A+=100){const N=_.slice(A,A+100);M+=N.length+" beginbfchar\n";for(const[,z]of N)M+="<"+z.hex+"> <"+E(z.text)+">\n";M+="endbfchar\n",c()&&await g(),w(this.signal)}M+="endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\n",await e.stream(m,M,"",n),await e.object(this.object,"<< /Type /Font /Subtype /Type0 /BaseFont /"+u+" /Encoding /Identity-H /DescendantFonts ["+y+" 0 R] /ToUnicode "+m+" 0 R >>")}}class h{objects;fonts;maxBytes;signal;resources=[];selections=new Map;programs=new Map;explicitSelections=new Map;registered=new Set;fontBytes=0;constructor(e,n,l=16*1024*1024,a){this.objects=e,this.fonts=n,this.maxBytes=l,this.signal=a,f(n,l);for(const d of Object.values(n??{}))this.registerFont(d)}registerFont(e){if(this.registered.has(e))return;const n=F(e).bytes.length;if(this.fontBytes+n>this.maxBytes)throw new D("RESOURCE_LIMIT","maxFontBytes exceeded.");this.fontBytes+=n,this.registered.add(e)}select(e=!1,n=!1,l){l&&this.registerFont(l);let a=this.selections;if(l){const k=this.explicitSelections.get(l);a=k??new Map,k||this.explicitSelections.set(l,a)}const d=(e?2:0)|(n?1:0),u=a.get(d);if(u)return u;const{font:x,syntheticBold:b,syntheticItalic:y}=l?{font:l,syntheticBold:e,syntheticItalic:n}:S(this.fonts,e,n),C=x?this.programs.get(x):void 0,m=new o(this.resources.length+1,e,n,x,this.objects,b,y,C,this.signal);return C||(this.resources.push(m),x&&this.programs.set(x,m)),a.set(d,m),m}dictionary(){return"<< "+this.resources.map(e=>"/"+e.name+" "+e.object+" 0 R").join(" ")+" >>"}}return Object.freeze({PdfFontResource:o,PdfFontResources:h})})(),at=(()=>{class R{operation;count=0;sum=0;mean=0;min=1/0;max=-1/0;constructor(S){this.operation=S}accept(S){if(!(!this.operation||typeof S!="number"||!Number.isFinite(S)))if(this.count++,this.operation==="sum"){if(this.sum+=S,!Number.isFinite(this.sum))throw new RangeError("Numeric total exceeds finite number range.")}else if(this.operation==="average"){const p=S-this.mean;this.mean=this.count===1?S:Number.isFinite(p)?this.mean+p/this.count:this.mean*((this.count-1)/this.count)+S/this.count}else this.operation==="min"?this.min=Math.min(this.min,S):this.operation==="max"&&(this.max=Math.max(this.max,S))}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 D(P,S={}){const p=P.map(f=>f.key??f.header);for(const[f,T]of Object.entries(S)){if(p.filter(E=>E===f).length!==1)throw new TypeError("Totals need an unambiguous declared column key: "+f);if(!["sum","count","average","min","max"].includes(T))throw new TypeError("Invalid total operation.")}return p.map(f=>new R(Object.prototype.hasOwnProperty.call(S,f)?S[f]:void 0))}return Object.freeze({NumericAggregate:R,createTotals:D})})(),Me=(()=>{const{OfficeIMOError:R}=ae,{ExportCell:D,assertExportValue:F}=Se,{checkAbort:P,pause:S,taskYieldDue:p}=he,{isDate:f}=De,{defaultBooleanText:T}=it;function E(h,t){return t.limits.maxTextCharacters===void 0?h:h.replace(/[\t\r\n]/g,i=>i===" "?" ":"")}function w(h,t){if(typeof h=="string")return h;throw h&&typeof h.then=="function"&&Promise.resolve(h).catch(()=>{}),new TypeError(t+" must return a synchronous string.")}function g(h,t,i){if(F(h),h instanceof D&&h.text!==void 0)return h.text;const e=h instanceof D?h.value:h;return t.formatValue?w(t.formatValue(e,i),"formatValue"):e==null?"":f(e)?Number.isFinite(e.getTime())?e.toISOString():"":typeof e=="number"&&!Number.isFinite(e)?"":typeof e=="boolean"?(t.booleanText??T)[e?"true":"false"]:String(e)}function c(h,t,i,e,n,l,a=!0){const d=s(h,t,i,e,n,l,a);for(;;){const u=d.next();if(u.done)return u.value}}async function r(h,t,i,e,n,l,a=!0,d){P(d);const u=s(h,t,i,e,n,l,a);for(;;){const x=u.next();if(x.done)return x.value;p()&&await S(),P(d)}}function*s(h,t,i,e,n,l,a){if(h.length>n)throw new R("RESOURCE_LIMIT","maxCellCharacters exceeded.");const d=[];let u=0;function x(b,y){if(d.length>=l)throw new R("RESOURCE_LIMIT","maxRowLines exceeded.");d.push({text:b.join(""),width:y})}for(const b of h.replace(/\r\n?/g,"\n").replace(/\t/g," ").split("\n")){let y=[],C=[],m=0,k=-1;for(const I of b){(++u&4095)===0&&(yield);const v=t.width(I.codePointAt(0))*i/1e3;if(v>e+.001)throw new RangeError("PDF column is too narrow for a glyph. Increase page/column width or reduce padding/font size.");if(m+v>e+.001){if(!a)throw new RangeError("Unwrapped PDF cell exceeds its column width.");const j=k>=0?k+1:y.length,M=C.slice(0,j).reduce((_,A)=>_+A,0);x(y.slice(0,j),M),y=y.slice(j),C=C.slice(j),m=C.reduce((_,A)=>_+A,0),k=-1;for(let _=0;_<y.length;_++)y[_]===" "&&(k=_);m+v>e+.001&&(x(y,m),y=[],C=[],m=0,k=-1)}y.push(I),C.push(v),m+=v,I===" "&&(k=y.length-1)}x(y,m),(++u&4095)===0&&(yield)}return d}return Object.freeze({pdfBudgetText:E,synchronousText:w,displayText:g,wrapText:c,wrapTextCooperatively:r})})(),yt=(()=>{const{NotSupportedError:R,OfficeIMOError:D}=ae,{checkAbort:F,pause:P,taskYieldDue:S,withAbort:p}=he,f=(c,r)=>r===0||r===c.length||!(c.charCodeAt(r)>=56320&&c.charCodeAt(r)<=57343&&c.charCodeAt(r-1)>=55296&&c.charCodeAt(r-1)<=56319);function T(c,r){const s=[{text:"",owners:[]}];let o=0,h=c.runs[0]?.text.length??0;for(let t=0;t<c.text.length;){for(;t>=h&&o<c.runs.length-1;)h+=c.runs[++o].text.length;const i=c.text.codePointAt(t),e=String.fromCodePoint(i);if(t+=e.length,i>=55296&&i<=57343)throw new TypeError("PDF text contains an unpaired UTF-16 surrogate.");if(t>h&&o<c.runs.length-1)throw new R("A shaped presentation boundary cannot split a UTF-16 scalar.");if(e==="\n"||e==="\r"){if(e==="\r"&&c.text[t]==="\n"&&t++,s.length>=r)throw new D("RESOURCE_LIMIT","maxRowLines exceeded.");s.push({text:"",owners:[]});continue}if(i<32&&i!==9||i>=127&&i<160)throw new R("PDF text contains an unsupported control character.");const n=e===" "?" ":e,l=s.at(-1);if(l.text.length+n.length>4096)throw new D("RESOURCE_LIMIT","Shaped PDF text supports at most 4,096 UTF-16 units per physical paragraph.");l.text+=n;for(let a=0;a<n.length;a++)l.owners.push(o)}return s}function E(c,r,s,o,h,t){if(!Array.isArray(c)||c.length>32768)throw new TypeError("Invalid shaped run array.");let i=0,e=0;const n=new Uint8Array(o-s),l=new Map,a=new Map,d=[];for(const b of c){if(!b||!Array.isArray(b.glyphs)||!h.some(C=>C.font===b.font))throw new TypeError("Shaping must use an exact registered PdfFont identity.");if(i+=b.glyphs.length,i>32768)throw new D("RESOURCE_LIMIT","Shaped PDF text exceeded 32,768 glyphs.");const y=[];for(const C of b.glyphs){const{id:m,clusterStart:k,clusterEnd:I,xAdvance:v,yAdvance:j,xOffset:M,yOffset:_}=C??{},A=h[r.owners[k]??-1];if(!A||A.font!==b.font||!A.program||!Number.isSafeInteger(m)||m<=0||m>=A.program.glyphCount)throw new TypeError("Shaping returned an invalid glyph or font identity.");if(!Number.isSafeInteger(k)||!Number.isSafeInteger(I)||k<s||I<=k||I>o||!f(r.text,k)||!f(r.text,I))throw new TypeError("Shaping returned an invalid UTF-16 cluster range.");if(![v,j,M,_].every(O=>Number.isFinite(O)&&Math.abs(O)<=1e5)||v<0||j!==0)throw new TypeError("Shaping requires finite bounded horizontal glyph metrics.");const N=t.runs[r.owners[k]];for(let O=k;O<I;O++){const B=t.runs[r.owners[O]];if(h[r.owners[O]].font!==b.font||N.style.bold!==B.style.bold||N.style.italic!==B.style.italic||N.style.color!==B.style.color||N.link!==B.link)throw new R("A PDF presentation, font or link boundary cannot split an indivisible shaped cluster.");n[O-s]=1}const z=l.get(k);if(z!==void 0&&z!==I)throw new TypeError("Inconsistent shaped cluster ranges.");l.set(k,I),a.set(k,(a.get(k)??0)+v),e+=v,y.push(Object.freeze({id:m,clusterStart:k,clusterEnd:I,xAdvance:v,yAdvance:j,xOffset:M,yOffset:_}))}d.push(Object.freeze({font:b.font,glyphs:Object.freeze(y)}))}if(n.some(b=>!b))throw new TypeError("Shaping omitted logical source text.");const u=[...l].sort((b,y)=>b[0]-y[0]);let x=s;for(const[b,y]of u){if(b!==x)throw new TypeError("Shaped clusters overlap or leave a logical gap.");x=y}return{runs:d,boundaries:u.map(([,b])=>b),advances:a,width:e}}async function w(c,r,s,o,h,t){const i=c.runs.map(u=>r.select(u.style.bold,u.style.italic,u.font)),e=r.select();if(i.some((u,x)=>!u.font&&c.runs[x].text.length))throw new R("Shaped PDF text requires explicit embedded TrueType fonts.");const n=[],l=h.options.textShaper,a=h.options.signal,d=(u,x,b,y)=>{if(n.length>=h.limits.maxRowLines)throw new D("RESOURCE_LIMIT","maxRowLines exceeded.");const C=[];let m=e.lineHeight(s),k=(e.program?.ascent??800)*s/1e3;const I=new Set;let v=-1,j,M=[],_=0;const A=()=>{if(v<0||!j)return;const z=c.runs[v],B=M.filter(L=>L.logicalText).sort((L,H)=>L.clusterStart-H.clusterStart).map(L=>L.logicalText).join("");C.push({text:B,actualText:B,logicalStart:Math.min(...M.map(L=>L.clusterStart)),width:_*s/1e3,font:j,glyphs:M,...z.style.color===void 0?{}:{color:z.style.color},...z.link?{link:z.link}:{}}),M=[],_=0};for(const z of y?.runs??[])for(const O of z.glyphs){const B=u.owners[O.clusterStart],L=i[B];(v!==B||j!==L)&&(A(),v=B,j=L);const H=I.has(O.clusterStart)?"":u.text.slice(O.clusterStart,O.clusterEnd);I.add(O.clusterStart),M.push({...O,logicalText:H}),_+=O.xAdvance,m=Math.max(m,L.lineHeight(s)),k=Math.max(k,L.program.ascent*s/1e3)}A();const N=u.text.slice(x,b);n.push({text:N,actualText:N,segments:C,width:(y?.width??0)*s/1e3,lineHeight:m,ascent:k})};for(const u of T(c,h.limits.maxRowLines)){if(F(a),!u.text){d(u,0,0);continue}const x=[];for(let I=0;I<u.text.length;){const v=u.owners[I];let j=I+1;for(;j<u.text.length&&u.owners[j]===v;)j++;x.push(Object.freeze({start:I,end:j,font:i[v].font})),I=j}Object.freeze(x);let b=0;const y=async(I,v)=>{if(++b>16385)throw new D("RESOURCE_LIMIT","Shaped line fitting exceeded its bounded work limit.");S()&&await P(),F(a);const j=await p(Promise.resolve(l.shapeLine(Object.freeze({text:u.text,start:I,end:v,runs:x,direction:h.options.textDirection??"auto",...a?{signal:a}:{}}))),a);return F(a),E(j,u,I,v,i,c)},C=await y(0,u.text.length),m=C.boundaries;if(!t){if(C.width*s/1e3>o+.001)throw new RangeError("Unwrapped PDF cell exceeds its column width.");d(u,0,u.text.length,C);continue}let k=0;for(;k<m.length;){const I=k?m[k-1]:0;let v=k,j=0,M=-1;for(;v<m.length;){const A=v?m[v-1]:0,N=C.advances.get(A)*s/1e3;if(j+N>o+.001&&v>k||(j+=N,u.text[m[v]-1]===" "&&(M=v+1),v++,j>o+.001))break}v<m.length&&M>k&&(v=M);let _=I===0&&v===m.length?C:await y(I,m[v-1]);if(_.width*s/1e3>o+.001){let A=k+1,N=v-1,z,O=0;for(;A<=N;){const B=Math.floor((A+N)/2),L=await y(I,m[B-1]);L.width*s/1e3<=o+.001?(z=L,O=B,A=B+1):N=B-1}if(!z)throw new RangeError("PDF column is too narrow for an indivisible shaped cluster.");_=z,v=O}d(u,I,m[v-1],_),k=v}}return n}return Object.freeze({wrapShapedPdfText:w})})(),Ne=(()=>{const{NotSupportedError:R,OfficeIMOError:D}=ae,{copyExportLink:F}=We,{checkAbort:P,pause:S,taskYieldDue:p}=he,{presentation:f,color:T}=Te,{wrapShapedPdfText:E}=yt,{PdfFont:w}=_e,{pdfBudgetText:g}=Me;function c(o,h,t,i,e=!0,n=!0){if(typeof o=="string"){if(o.length>t.limits.maxCellCharacters)throw new D("RESOURCE_LIMIT","maxCellCharacters exceeded.");return n&&(o.length||e)&&t.budget.reserve(1,g(o,t.budget).length),Object.freeze({text:o,runs:Object.freeze([Object.freeze({text:o,style:h})])})}const l=o;if(!Array.isArray(l))throw l&&typeof l.then=="function"&&Promise.resolve(l).catch(()=>{}),new TypeError("PDF text must be a string or a synchronous array of text runs.");if(l.length>t.limits.maxTextRuns)throw new D("RESOURCE_LIMIT","maxTextRuns exceeded.");let a=0,d=0;const u=[];for(const x of l){if(!x||typeof x!="object"||Object.keys(x).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:b,bold:y,italic:C,color:m,link:k,font:I}=x;if(typeof b!="string")throw new TypeError("PDF run text must be a string.");if(I!==void 0){if(!(I instanceof w))throw new TypeError("A PDF run font must be a PdfFont.");i.registerFont(I)}if(a+=b.length,a>t.limits.maxCellCharacters)throw new D("RESOURCE_LIMIT","maxCellCharacters exceeded.");n&&(d+=g(b,t.budget).length);const v=f({...h,...y===void 0?{}:{bold:y},...C===void 0?{}:{italic:C},...m===void 0?{}:{color:m}});if(t.options.tagged&&k!==void 0&&b.length&&!b.trim())throw new TypeError("Tagged PDF inline links require nonempty displayed text.");u.push(Object.freeze({text:b,style:v,...I===void 0?{}:{font:I},...k===void 0?{}:{link:F(k)}}))}return n&&(a||e)&&t.budget.reserve(1,d),Object.freeze({text:u.map(x=>x.text).join(""),runs:Object.freeze(u)})}async function r(o,h,t,i,e,n=!0){if(e.options.textShaper)return E(o,h,t,i,e,n);const{signal:l}=e.options,{text:a,runs:d}=o;P(l);const u=d.length===1?d[0]:void 0,x=u&&h.select(u.style.bold,u.style.italic,u.font),b=x?void 0:d.map(B=>h.select(B.style.bold,B.style.italic,B.font)),y=h.select();if(u&&a.length>0&&a.length<4096){const B=u,L=x;let H=0,G=!0;for(let W=0;W<a.length;){const X=a.codePointAt(W);if(X===9||X===10||X===13){G=!1;break}const K=L.width(X)*t/1e3;if(K>i+.001||H+K>i+.001){G=!1;break}H+=K,W+=X>65535?2:1}if(G){if(e.limits.maxRowLines<1)throw new D("RESOURCE_LIMIT","maxRowLines exceeded.");return[{text:a,width:H,segments:[{text:a,width:H,font:L,...B.style.color===void 0?{}:{color:B.style.color},...B.link?{link:B.link}:{}}],lineHeight:L.lineHeight(t),ascent:Math.max(0,(L.program?.ascent??800)*t/1e3)}]}}const C=b??[x],m=[];let k=[],I=[],v=[],j=0,M=-1,_=0,A=d[0]?.text.length??0,N=0;const z=B=>{if(m.length>=e.limits.maxRowLines)throw new D("RESOURCE_LIMIT","maxRowLines exceeded.");const L=[];let H=0,G=0,W=0;for(let X=0;X<B;){const K=v[X],V=d[K],se=C[K];let oe=X+1;for(;oe<B&&v[oe]===K;)oe++;const fe=I.slice(X,oe).reduce((ge,J)=>ge+J,0);L.push({text:k.slice(X,oe).join(""),width:fe,font:se,...V.style.color===void 0?{}:{color:V.style.color},...V.link?{link:V.link}:{}}),H+=fe,G=Math.max(G,se.lineHeight(t)),W=Math.max(W,(se.program?.ascent??800)*t/1e3),X=oe}if(!L.length){const X=C[0]??y;L.push({text:"",width:0,font:X,...d[0]?.style.color===void 0?{}:{color:d[0].style.color}}),G=X.lineHeight(t),W=(X.program?.ascent??800)*t/1e3}m.push({text:k.slice(0,B).join(""),width:H,segments:L,lineHeight:G,ascent:W}),k=k.slice(B),I=I.slice(B),v=v.slice(B),j=I.reduce((X,K)=>X+K,0),M=-1;for(let X=0;X<k.length;X++)k[X]===" "&&(M=X)},O=(B,L)=>{const H=C[L].width(B.codePointAt(0))*t/1e3;if(H>i+.001)throw new RangeError("PDF column is too narrow for a glyph. Increase page/column width or reduce padding/font size.");if(j+H>i+.001){if(!n)throw new RangeError("Unwrapped PDF cell exceeds its column width.");z(M>=0?M+1:k.length),j+H>i+.001&&z(k.length)}k.push(B),I.push(H),v.push(L),j+=H,B===" "&&(M=k.length-1)};for(let B=0;B<a.length;){for(;B>=A&&_<d.length-1;)A+=d[++_].text.length;const L=_,H=a.codePointAt(B),G=String.fromCodePoint(H);if(B+G.length>A&&_<d.length-1){let W=_+1;for(;!d[W].text.length;)W++;const X=d[L],K=d[W],V=C[L],se=C[W];if(!(V.font===se.font&&(V.font?V.syntheticBold===se.syntheticBold&&V.syntheticItalic===se.syntheticItalic:V.bold===se.bold&&V.italic===se.italic))||T(X.style.color??"111827")!==T(K.style.color??"111827")||X.link?.target!==K.link?.target||X.link?.tooltip!==K.link?.tooltip)throw new R("A PDF presentation boundary cannot split a UTF-16 scalar.")}if(B+=G.length,G==="\r"||G==="\n")G==="\r"&&a[B]==="\n"&&B++,z(k.length);else if(G===" ")for(let W=0;W<4;W++)O(" ",L);else O(G,L);(++N&4095)===0&&(p()&&await S(),P(l))}return z(k.length),m}return Object.freeze({capturePdfText:c,wrapPdfText:r})})(),bt=(()=>{const{OfficeIMOError:R}=ae,{wrapPdfText:D}=Ne;function F(f,T){if(typeof T.options.wideTable!="object")return;const w=T.page.width-T.margins.left-T.margins.right,g=T.repeatedColumns,c=new Set(g),r=f.map((i,e)=>e).filter(i=>!c.has(i)),s=g.reduce((i,e)=>i+f[e],0);if(s>w+.001)throw new RangeError("Repeated PDF columns exceed the printable width.");const o=[];let h=[...g],t=s;for(const i of r){const e=f[i];if(s+e>w+.001)throw new RangeError("A PDF column and its repeated identifiers cannot fit a band.");t+e>w+.001&&(o.push(h),h=[...g],t=s),h.push(i),t+=e}if(h.length&&o.push(h),o.length>T.limits.maxTableBands)throw new R("RESOURCE_LIMIT","maxTableBands exceeded.");if(T.limits.maxTableWindowRows<1)throw new R("RESOURCE_LIMIT","maxTableWindowRows must allow at least one row fragment.");return Object.freeze(o.map(i=>{let e=T.margins.left;const n=i.map(l=>{const a=e;return e+=f[l],a});return Object.freeze({columns:Object.freeze(i),lefts:Object.freeze(n)})}))}async function P(f,T,E,w,g){const c=[];for(const r of f){const s=[];for(const o of r.cells){if(o.span===1){const h=T.columns.indexOf(o.first);h>=0&&s.push({...o,source:o.source??o,first:h});continue}for(let h=0;h<T.columns.length;){const t=T.columns[h];if(t<o.first||t>=o.first+o.span){h++;continue}let i=h+1;for(;i<T.columns.length&&T.columns[i]===T.columns[i-1]+1&&T.columns[i]<o.first+o.span;)i++;const e=T.columns.slice(h,i).reduce((l,a)=>l+E[a],0),n=await D(o.captured,g,w.fontSize,e-w.padding*2,w,o.style.wrapText!==!1);s.push({...o,source:o.source??o,first:h,span:i-h,width:e,lines:n,lineHeight:n.reduce((l,a)=>Math.max(l,a.lineHeight),o.font.lineHeight(w.fontSize))}),h=i}}s.sort((o,h)=>o.first-h.first),c.push({...r,source:r.source??r,cells:s})}return c}function S(f,T){if(!f.length||!f[0].length)return f;const E=f[0].length,w=Array.from({length:E},(g,c)=>Math.max(...f.map(r=>Math.max(T.padding*2+r[c].lineHeight,...r[c].cells.filter(s=>(s.rowSpan??1)===1).map(s=>s.lines.length*s.lineHeight+T.padding*2)))));for(const g of f)for(const[c,r]of g.entries())for(const s of r.cells){const o=s.rowSpan??1,h=w.slice(c,c+o).reduce((i,e)=>i+e,0),t=s.lines.length*s.lineHeight+T.padding*2;if(t>h)for(let i=c;i<c+o;i++)w[i]+=(t-h)/o}return f.map(g=>g.map((c,r)=>({...c,structured:!0,height:w[r],cells:c.cells.map(s=>({...s,height:w.slice(r,r+(s.rowSpan??1)).reduce((o,h)=>o+h,0)}))})))}return Object.freeze({planTableBands:F,projectBandRows:P,alignBandBlocks:S})})(),Ke=(()=>{const{ExportCell:R}=Se,{copyExportLink:D}=We,{tableSpans:F}=rt,{createTotals:P}=at,{presentation:S,positive:p}=Te,{displayText:f,pdfBudgetText:T}=Me,{capturePdfText:E,wrapPdfText:w}=Ne,{planTableBands:g,projectBandRows:c,alignBandBlocks:r}=bt;class s{settings;fonts;bands;widths;lefts;lineHeight;headings;totals;repeatedColumns;structuredBandRows=new WeakMap;dataPresentations=[];constructor(t,i){this.settings=t,this.fonts=i;const{options:e,padding:n,fontSize:l,page:a,margins:d}=t,u=e.columns,x=a.width-d.left-d.right;this.repeatedColumns=new Set(t.repeatedColumns);let b;if(e.columnWidths&&e.columnWidths.length!==u.length)throw new RangeError("columnWidths must declare one point width per column.");const y=typeof e.wideTable=="object"?e.wideTable.minimumColumnWidth??72:0,C=u.map((j,M)=>p(e.columnWidths?.[M]??Math.max(y,j.width===void 0?x/u.length:p(j.width,"Column width",255)*(b??=i.select().width(48)*l/1e3)+n*2),"PDF column width")),m=C.reduce((j,M)=>j+M,0);if(m>x+.001&&e.wideTable==="reject")throw new RangeError("Table widths exceed the printable page width.");this.bands=g(C,t),this.widths=!this.bands&&m>x?C.map(j=>j*x/m):C;let k=d.left;if(this.lefts=this.widths.map(j=>{const M=k;return k+=j,M}),this.widths.some(j=>j<=n*2))throw new RangeError("Page is too narrow for this many columns and the requested padding.");this.lineHeight=i.select().lineHeight(l);const I=u.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 v=[];if(e.includeHeader!==!1){for(let j=0;j<I;j++){const M=[];for(let _=0;_<u.length;){let A=_;const N=u[_].groups?.[j]??"",z=JSON.stringify(u[_].groups?.slice(0,j+1));for(;N&&A+1<u.length&&JSON.stringify(u[A+1].groups?.slice(0,j+1))===z;)A++;M.push({first:_,span:A-_+1,text:N}),_=A+1}v.push(M)}v.push(u.map((j,M)=>({first:M,span:1,text:j.header})))}this.headings=v,this.totals=P(u,e.footer?.totals)}async cell(t,i,e,n,l,a=!1){const{options:d,padding:u,fontSize:x,budget:b}=this.settings,y=d.columns[i],C=t instanceof R?t.presentation:void 0,m=t instanceof R&&t.link?D(t.link):void 0,k=a&&n%2&&d.alternateRowColor?d.alternateRowColor:void 0,I=i*2+(k?1:0),v=a&&C===void 0;let j=v?this.dataPresentations[I]:void 0;if(!j){const H=a?k?{background:k}:{}:l;j=S({...y.alignment===void 0?{}:{alignment:y.alignment},...y.wrapText===void 0?{}:{wrapText:y.wrapText},...H,...C}),v&&(this.dataPresentations[I]=j)}const M=this.fonts.select(j.bold,j.italic),_=e===1?this.widths[i]:this.widths.slice(i,i+e).reduce((H,G)=>H+G,0),A={rowIndex:n,columnIndex:i,column:y},N=t instanceof R?t.value:t;let z;if(d.formatRuns&&n>=0&&!(t instanceof R&&t.text!==void 0)){const H=d.formatRuns(N,A);if(!Array.isArray(H))throw H&&typeof H.then=="function"&&Promise.resolve(H).catch(()=>{}),new TypeError("formatRuns must return a synchronous array of PDF text runs.");z=H}else z=f(t,d,A);const O=E(z,j,this.settings,this.fonts);if(d.tagged&&m&&!O.text.trim())throw new TypeError("Tagged PDF cell links require nonempty displayed text.");if(m&&O.runs.some(H=>H.link))throw new TypeError("A PDF cell link cannot be combined with inline run links.");const B=T(O.text,b);this.bands?b.release(1,B.length):b.cell(B,B.length);const L=await w(O,this.fonts,x,_-u*2,this.settings,j.wrapText!==!1);return{first:i,span:e,width:_,font:M,style:j,lineHeight:L.reduce((H,G)=>Math.max(H,G.lineHeight),M.lineHeight(x)),...m?{link:m}:{},...this.bands?{captured:O}:{},lines:L}}row(t){let i=1,e=this.lineHeight;for(let n=0;n<t.length;n++){const l=t[n];i=Math.max(i,l.lines.length),e=Math.max(e,l.lineHeight)}return{cells:t,lines:i,lineHeight:e,height:i*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,...i}=this.settings.options,e=[];for(const n of this.headings){const l=[];for(const a of n)l.push(await this.cell(new R(a.text,{text:a.text}),a.first,a.span,-1,i.headerPresentation??{}));e.push(this.row(l))}return e}async block(t,i){const e=F(t,this.settings.options.columns.length),{formatValue:n,...l}=this.settings.options,a=[];for(const u of e){const x=[];for(const b of u){const y=b.value instanceof R?b.value:new R(b.value),C=new R(y.value,{text:f(y,l,{rowIndex:-1,columnIndex:b.first,column:l.columns[b.first]}),...y.presentation?{presentation:y.presentation}:{},...y.link?{link:y.link}:{}});x.push({...await this.cell(C,b.first,b.span,-1,i),rowSpan:b.rowSpan})}a.push(x)}const d=a.map(u=>Math.max(this.lineHeight+this.settings.padding*2,...u.filter(x=>x.rowSpan===1).map(x=>x.lines.length*x.lineHeight+this.settings.padding*2)));return a.forEach((u,x)=>u.forEach(b=>{const y=d.slice(x,x+b.rowSpan).reduce((m,k)=>m+k,0),C=b.lines.length*b.lineHeight+this.settings.padding*2;if(C>y)for(let m=x;m<x+b.rowSpan;m++)d[m]+=(C-y)/b.rowSpan})),a.map((u,x)=>({cells:u.map(b=>({...b,height:d.slice(x,x+b.rowSpan).reduce((y,C)=>y+C,0)})),lines:Math.max(1,Math.ceil((d[x]-this.settings.padding*2)/this.lineHeight)),lineHeight:this.lineHeight,height:d[x],structured:!0}))}minimumRowLines(t){let i=1;if(this.bands)for(const e of t.cells)this.repeatedColumns.has(e.first)&&(i=Math.max(i,e.lines.length));return i}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,n)=>e+n.height,0)}async bandRows(t,i=!1){if(!this.bands)throw new Error("Horizontal bands were not planned.");if(!i)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,i){const e=[],n=new Set;for(const l of this.bands){const a=await c(t,l,this.widths,this.settings,this.fonts);e.push(a.map(d=>({...d,cells:d.cells.map(u=>{const x=u.source,b=n.has(x);return n.add(x),b?{...u,semanticArtifact:!0}:u})})))}return i?r(e,this.settings):e}async data(t,i,e=!1){const{options:n}=this.settings,l=[];for(let a=0;a<n.columns.length;a++){const d=t[a],u=d instanceof R?d.value:d;e||this.totals[a].accept(u);const x=await this.cell(d,a,1,i,e?n.footerPresentation??{}:void 0,!e);l.push(!e&&n.columns[a].rowHeader?{...x,rowHeader:!0}:x)}return this.row(l)}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 i=this.totals.map((e,n)=>e.operation?e.value():this.settings.options.footer?.values?.[n]);return[await this.data(i,t,!0)]}}return Object.freeze({PdfTableLayout:s})})(),xt=(()=>{const{OfficeIMOError:R}=ae,{checkAbort:D}=he;class F{layout;headings;painter;caption;continuation;entries=[];height=0;count=0;firstWindow=!0;firstCapacity;painted=!1;constructor(p,f,T,E,w){this.layout=p,this.headings=f,this.painter=T,this.caption=E,this.continuation=w,this.firstCapacity=T.firstCapacity}get capacity(){return this.firstWindow?this.firstCapacity:this.painter.continuationCapacity}async accept(p){if(this.entries.length&&(this.height+p.height>this.capacity+.001||this.count+p.count>this.layout.settings.limits.maxTableWindowRows)&&await this.flush(),this.firstWindow&&!this.entries.length&&p.height>this.capacity+.001&&p.height<=this.painter.firstFullCapacity+.001&&(await this.painter.moveFirstToFreshPage(),this.firstCapacity=this.painter.firstFullCapacity),p.height>this.capacity+.001)throw new RangeError("PDF band window cannot fit the requested table fragment.");this.entries.push(p),this.height+=p.height,this.count+=p.count,this.count>=this.layout.settings.limits.maxTableWindowRows&&await this.flush()}async row(p,f=!1){const{padding:T,fontSize:E,options:w}=this.layout.settings,g=this.layout.minimumRowLines(p),c=g*p.lineHeight+T*2;if(c>this.painter.firstFullCapacity+.001||c>this.painter.continuationCapacity+.001)throw new RangeError("Repeated PDF identifiers must fit intact below the first and continued band headings/context.");this.entries.length&&p.height<=this.painter.continuationCapacity+.001&&p.height>this.capacity-this.height+.001&&await this.flush(),!f&&this.firstWindow&&!this.entries.length&&p.height>this.capacity+.001&&p.height<=this.painter.firstFullCapacity+.001&&(await this.painter.moveFirstToFreshPage(),this.firstCapacity=this.painter.firstFullCapacity),await this.painter.prepareRow?.(p);let r=0;for(;r<p.lines;){if(D(w.signal),this.entries.length&&this.capacity-this.height+.001<c&&await this.flush(),this.firstWindow&&!this.entries.length&&this.capacity+.001<c&&(await this.painter.moveFirstToFreshPage(),this.firstCapacity=this.painter.firstFullCapacity),this.capacity-this.height+.001<c)throw new RangeError("PDF band window cannot fit its complete repeated identifiers.");const s=Math.min(p.lines-r,Math.floor((this.capacity-this.height-T*2+.001)/p.lineHeight));if(s<1)throw new RangeError("PDF page cannot fit a table line below horizontal band headings.");const o=Math.max(s,g),h=o*p.lineHeight+T*2,t=await this.layout.bandRows([p]),i=[],e=t.map((n,l)=>{let a=!1;const d=n[0].cells.map(b=>{const y=this.layout.bands[l].columns[b.first],C=this.layout.repeatedColumn(y),m=b.span===1&&(b.source?.span??1)===1&&(b.rowSpan??1)===1&&b.height===void 0&&r===0&&(C||s>=b.lines.length),k=C||m?b.lines:b.lines.slice(r,r+s);if(!C&&(k.length>0||b.link!==void 0)&&(a=!0),m)return b;const{height:I,...v}=b;return{...v,lines:k,lineHeight:k.reduce((j,M)=>Math.max(j,M.lineHeight),b.font.lineHeight(E)),...r>0&&C?{semanticArtifact:!0}:{}}}),u=Math.max(1,...d.map(b=>b.lines.length)),x=Math.max(this.layout.lineHeight,...d.filter(b=>b.lines.length>0).map(b=>b.lineHeight));return i.push(r>0&&!a),[{...n[0],cells:d,lines:u,lineHeight:x,height:u*x+T*2}]});await this.accept({rows:e,height:h,count:1,completed:r+s>=p.lines?[p]:[],exhaustedBands:i}),r+=s,r<p.lines&&await this.flush()}}async block(p){const f=await this.layout.bandRows(p,!0),T=f[0].reduce((E,w)=>E+w.height,0);if(p.length>this.layout.settings.limits.maxTableWindowRows)throw new R("RESOURCE_LIMIT","A structured PDF block exceeds maxTableWindowRows.");for(const E of p)await this.painter.prepareRow?.(E);await this.accept({rows:f,height:T,count:p.length,completed:p,exhaustedBands:f.map(()=>!1)})}async keptRows(p,f=!1){const T=p.reduce((w,g)=>w+g.height,0),E=T<=this.painter.continuationCapacity+.001;this.entries.length&&E&&T>this.capacity-this.height+.001&&await this.flush();for(const[w,g]of p.entries())await this.row(g,!E&&w===0&&f)}async flush(p=!1){if(!(!this.entries.length&&(!p||this.painted||!this.headings.some(f=>f.length)))){for(let f=0;f<this.layout.bands.length;f++)D(this.layout.settings.options.signal),!(!this.firstWindow&&this.entries.length>0&&this.entries.every(T=>T.exhaustedBands[f]))&&await this.painter.paint(f,this.headings[f],this.entries.flatMap(T=>T.rows[f]),this.firstWindow?this.caption:this.continuation,this.firstWindow,f===0);for(const f of this.entries)for(const T of f.completed)await this.painter.completeRow?.(T);this.entries=[],this.height=0,this.count=0,this.firstWindow=!1,this.painted=!0}}}return Object.freeze({PdfTableBandFlow:F})})(),Tt=(()=>{class R{structure;table;headers;cells=new WeakMap;rows=new WeakMap;columnHeaders=[];ordinaryAttributes=[];headerCount=0;headersPrepared=!1;constructor(P,S,p){this.structure=P,this.table=S,this.headers=p}async prepareHeaders(){if(!this.headersPrepared){for(let P=0;P<this.headers.length;P++){const S=this.headers[P],p=this.structure.element("TR",this.table);this.rows.set(S,p);for(const f of S.cells){const T=f.lines.some(g=>g.text.trim().length>0),E=this.associations(f,P),w=this.structure.element(T?"TH":"TD",p,this.attributes(f,E,T?"Column":void 0));if(this.cells.set(f,w),T){const g={row:P,order:this.headerCount++,identifier:await this.structure.identifier(w)};for(let c=f.first;c<f.first+f.span;c++)(this.columnHeaders[c]??=[]).push(g)}}}this.headersPrepared=!0}}async completeHeaders(){for(const P of this.headers)await this.completeRow(P)}async prepareRow(P,S="data",p=this.table,f){if(this.rows.get(P)!==void 0)return P.cells.map(c=>this.cells.get(c));const E=this.structure.element("TR",p);this.rows.set(P,E);const w=P.cells.map((c,r)=>{const s=f===void 0?c.rowHeader===!0:r===f,o=this.structure.element(s?"TH":"TD",E);return this.cells.set(c,o),o});let g;for(let c=0;c<w.length;c++)(f===void 0?P.cells[c].rowHeader===!0:c===f)&&(g??=[]).push(await this.structure.identifier(w[c]));for(let c=0;c<P.cells.length;c++){const r=P.cells[c];if(!g&&r.span===1&&(r.rowSpan??1)===1){const h=this.ordinaryAttributes[r.first]??=await this.structure.attributeReference(this.attributeDictionary(r,this.associations(r)));this.structure.setAttributes(w[c],h);continue}const s=this.associations(r),o=f===void 0?r.rowHeader===!0:c===f;!o&&g&&s.push(...g),this.structure.setAttributes(w[c],this.attributes(r,s,o?"Row":void 0))}return w}owner(P){return this.cells.get(P)}async completeRow(P){await this.structure.complete(this.rows.get(P))}async finish(){await this.completeHeaders(),await this.structure.complete(this.table)}associations(P,S=Number.POSITIVE_INFINITY){if(P.span===1)return(this.columnHeaders[P.first]??[]).filter(f=>f.row<S).map(f=>f.identifier);const p=new Set;for(let f=P.first;f<P.first+P.span;f++)for(const T of this.columnHeaders[f]??[])T.row<S&&p.add(T);return[...p].sort((f,T)=>f.order-T.order).map(f=>f.identifier)}attributes(P,S,p){return" /A "+this.attributeDictionary(P,S,p)}attributeDictionary(P,S,p){return"<< /O /Table"+(p===void 0?"":" /Scope /"+p)+(P.span>1?" /ColSpan "+P.span:"")+((P.rowSpan??1)>1?" /RowSpan "+P.rowSpan:"")+(S.length?" /Headers ["+S.map(f=>"("+f+")").join(" ")+"]":"")+" >>"}}return Object.freeze({PdfTableStructure:R})})(),Et=(()=>{const{OfficeIMOError:R}=ae,{pdfNumber:D,unicodeHex:F}=Pe,P=new TextEncoder;function S(f,T,E,w,g,c,r,s){const o="<< /Type /Annot /Subtype /Link /F 4 /Border [0 0 0] /Rect ["+[T,E,T+w,E+g].map(D).join(" ")+"]"+(r===void 0?"":" /StructParent "+r)+(s===void 0?"":" /P "+s+" 0 R")+" /A << /S /URI /URI <",h="> >>"+(f.tooltip===void 0?"":" /Contents <feff")+" >>",t=o.length+h.length+(f.tooltip===void 0?0:f.tooltip.length*4+1),i=()=>{throw new R("RESOURCE_LIMIT","maxPageBytes exceeded.")};t+f.target.length*2>c&&i();let e=0;for(let l=0;l<f.target.length;l++){const a=f.target.charCodeAt(l);a<128?e++:a<2048?e+=2:a>=55296&&a<=56319&&l+1<f.target.length&&f.target.charCodeAt(l+1)>=56320&&f.target.charCodeAt(l+1)<=57343?(e+=4,l++):e+=3,t+e*2>c&&i()}let n="";for(const l of P.encode(f.target))n+=l.toString(16).padStart(2,"0");return o+n+"> >>"+(f.tooltip===void 0?"":" /Contents <feff"+F(f.tooltip)+">")+" >>"}return Object.freeze({linkAnnotation:S})})(),Xe=(()=>{const{OfficeIMOError:R}=ae,{unicodeHex:D}=Pe,{captureFields:F}=je;function P(f,T){if(f===void 0)return;if(!f||typeof f!="object")throw new TypeError("PDF bookmark must provide a title and optional level.");const{title:E,level:w=1}=f;if(typeof E!="string"||!E.trim())throw new TypeError("PDF bookmark title must be nonempty text.");if(E.length>T.limits.maxCellCharacters)throw new R("RESOURCE_LIMIT","maxCellCharacters exceeded by bookmark title.");if(!Number.isInteger(w)||w<1||w>6)throw new TypeError("PDF bookmark level must be an integer from 1 through 6.");return D(E),Object.freeze({title:E,level:w})}function S(f,T){if(!f||f.kind!=="section")throw new TypeError("PDF section boundary required.");if(Object.keys(f).some(l=>!["kind","title","level","includeHeading","bookmark","headingStyle","pageSize","orientation","margins","pageHeader","pageFooter","pageNumbers"].includes(l)))throw new TypeError("PDF sections support title, heading/bookmark controls, page geometry and decorations only.");const{title:E,level:w,includeHeading:g=!0,bookmark:c=!0,headingStyle:r,pageSize:s,orientation:o,margins:h,pageHeader:t,pageFooter:i,pageNumbers:e}=f,n=P({title:E,...w===void 0?{}:{level:w}},T);for(const[l,a]of[["includeHeading",g],["bookmark",c],["pageNumbers",e]])if(a!==void 0&&typeof a!="boolean")throw new TypeError("PDF section "+l+" must be boolean.");if(r!==void 0&&(typeof r!="string"||!r.trim()))throw new TypeError("PDF section headingStyle must be nonempty text.");return Object.freeze({kind:"section",title:n.title,level:n.level,includeHeading:g,bookmark:c,...r===void 0?{}:{headingStyle:r},...s===void 0?{}:{pageSize:typeof s=="object"?Object.freeze(F(s,["width","height"])):s},...o===void 0?{}:{orientation:o},...h===void 0?{}:{margins:typeof h=="object"?Object.freeze(F(h,["top","right","bottom","left"])):h},...t===void 0?{}:{pageHeader:t},...i===void 0?{}:{pageFooter:i},...e===void 0?{}:{pageNumbers:e}})}return Object.freeze({captureBookmark:P,captureSection:S})})(),Pt=(()=>{const{settings:R}=Te;function D(P,S){const{pageSize:p,orientation:f,margins:T,pageHeader:E,pageFooter:w,pageNumbers:g}=S,c={...P.options,...p===void 0?{}:{pageSize:p},...f===void 0?{}:{orientation:f},...T===void 0?{}:{margins:T},...E===void 0?{}:{pageHeader:E},...w===void 0?{}:{pageFooter:w},...g===void 0?{}:{pageNumbers:g}},r=R(c,!0);return{...P,page:r.page,margins:r.margins,options:c}}return Object.freeze({sectionSettings:D})})(),kt=(()=>{const{OfficeIMOError:R}=ae,{checkAbort:D}=he,{pdfNumber:F}=Pe,{color:P}=Te,{PdfTableBandFlow:S}=xt,{PdfTableStructure:p}=Tt,{wrapText:f,wrapTextCooperatively:T,synchronousText:E,pdfBudgetText:w}=Me,{linkAnnotation:g}=Et,{unicodeHex:c}=Pe,{captureSection:r,captureBookmark:s}=Xe,{sectionSettings:o}=Pt;class h{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,n,l,a,d,u,x,b){this.objects=e,this.baseSettings=n,this.fonts=l,this.parent=a,this.resources=d,this.layout=u,this.structure=x,this.outlines=b,this.activeSettings=n}measurePageNumbers(){const e=this.settings,n=this.fonts.select(),l=e.limits.maxPages,d=Math.max(...Array.from({length:Math.min(10,l)},(b,y)=>n.width(l<10?49+y:48+y)))*String(l).length*e.fontSize/1e3,u=e.options.pageNumberLabels;return f((u?.prefix??"Page ")+(u?.separator??" of ")+(u?.suffix??""),n,e.fontSize,Number.MAX_SAFE_INTEGER,e.limits.maxCellCharacters,1,!1)[0].width+d*2+2}get settings(){return this.activeSettings}async ensureStarted(){this.current||await this.start(!1)}async beginSection(e){const n=r(e,this.baseSettings),l=o(this.baseSettings,n);if(++this.sectionCount>this.baseSettings.limits.maxSections)throw new R("RESOURCE_LIMIT","maxSections exceeded.");return this.current&&(this.bodyAdded?await this.finishPage():(this.pendingPage=this.current,this.current=0)),this.activeSettings=l,this.sectionPages=0,this.sectionTitle=n.title,await this.structure?.beginSection(),n}addBookmark(e){const n=s(e,this.settings);if((this.outlines?.count??0)+this.pendingBookmarks.length>=this.settings.limits.maxBookmarks)throw new R("RESOURCE_LIMIT","maxBookmarks exceeded.");this.settings.budget.cell(n.title),this.current?this.outlines?.add(n,this.current,this.y):this.pendingBookmarks.push(n)}add(e){this.retainPageBytes(e.length),this.commands+=e}retainPageBytes(e){if(this.commandBytes+=e,this.commandBytes>this.settings.limits.maxPageBytes)throw new R("RESOURCE_LIMIT","maxPageBytes exceeded.")}rgb(e){let n=this.colors.get(e);return n||(n=P(e),this.colors.size<1024&&this.colors.set(e,n)),n}artifact(e,n="Layout"){return this.structure?"/Artifact << /Type /"+n+" >> BDC\n"+e+"EMC\n":e}text(e,n,l,a,d,u="111827",x){const b=F;if(n!==this.textFont||l!==this.textSize||u!==this.textColor){const C=n.syntheticItalic?.213:0,m=this.rgb(u);this.textPrefix="q "+m+" rg "+m+" RG\nBT /"+n.name+" "+b(l)+" Tf "+(n.syntheticBold?b(l*.025)+" w 2 Tr ":"0 Tr ")+"1 0 "+b(C)+" 1 ",this.textFont=n,this.textSize=l,this.textColor=u}const y=this.textPrefix+b(a)+" "+b(d)+" Tm "+n.encode(e)+" Tj ET Q\n";this.add(this.structure&&x!==void 0?this.structure.mark(x)+y+"EMC\n":this.artifact(y,"Pagination"))}link(e,n,l,a,d,u){if(a<=0)return;if(++this.hyperlinks>this.settings.limits.maxHyperlinks)throw new R("RESOURCE_LIMIT","maxHyperlinks exceeded.");const x=this.objects.reserve(),b=this.structure&&u!==void 0?this.structure.annotation(u,x):void 0,y=g(e,n,l,a,d,this.settings.limits.maxPageBytes-this.commandBytes,b,this.structure?this.current:void 0);this.retainPageBytes(y.length),this.annotations.push({id:x,body:y})}inline(e,n,l,a,d,u=d){const x=!this.structure&&e.actualText!==void 0&&e.actualText.length>0;x&&this.add("/Span << /ActualText <FEFF"+c(e.actualText)+"> >> BDC\n");let b;if(e.actualText!==void 0&&this.structure&&d!==void 0){b=new Map;for(const y of[...e.segments].sort((C,m)=>(C.logicalStart??0)-(m.logicalStart??0))){const C=y.link?this.structure.link(d,y.link):d;b.set(y,{owner:C,mark:this.structure.mark(C,y.actualText)})}}for(const y of e.segments){const C=b?.get(y),m=C?.owner??(y.link&&this.structure&&d!==void 0?this.structure.link(d,y.link):d);if(y.glyphs){const k=y.font,I=F,v=k.syntheticItalic?.213:0,j=this.rgb(y.color??"111827");let M=l,_="q "+j+" rg "+j+" RG\nBT /"+k.name+" "+I(n)+" Tf "+(k.syntheticBold?I(n*.025)+" w 2 Tr ":"0 Tr ");for(const A of y.glyphs)_+="1 0 "+I(v)+" 1 "+I(M+(A.xOffset+v*A.yOffset)*n/1e3)+" "+I(a+A.yOffset*n/1e3)+" Tm "+k.encodeGlyph(A.id,A.logicalText)+" Tj\n",M+=A.xAdvance*n/1e3;_+="ET Q\n",this.add(this.structure&&m!==void 0?(C?.mark??this.structure.mark(m,y.actualText))+_+"EMC\n":this.artifact(_,"Pagination"))}else this.text(y.text,y.font,n,l,a,y.color,m);if(y.link){const k=(y.font.program?.ascent??800)*n/1e3,I=(y.font.program?.descent??-200)*n/1e3,v=m??(this.structure&&u!==void 0?this.structure.link(u,y.link):void 0);this.link(y.link,l,a+I,y.width,k-I,v)}l+=y.width}x&&this.add("EMC\n")}decorationText(e){return e===void 0?"":(D(this.settings.options.signal),E(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,n,l,a){if(!e)return;this.settings.budget.cell(w(e,this.settings.budget));const d=this.fonts.select(),u=f(e,d,this.settings.fontSize,a,this.settings.limits.maxCellCharacters,1,!1);this.text(u[0].text,d,this.settings.fontSize,n,l)}async start(e=!0,n){if(this.pendingPage===void 0&&this.references.length>=this.settings.limits.maxPages)throw new R("RESOURCE_LIMIT","maxPages exceeded.");const{page:l,margins:a,options:d,fontSize:u}=this.settings,x=this.fonts.select().lineHeight(u);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++,d.pageNumbers!==!1&&(this.totalPages??=this.objects.reserve(),this.numberSettings??=this.settings,this.pageNumberWidth||(this.pageNumberWidth=this.measurePageNumbers()),this.pageNumberWidth>l.width-a.left-a.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=l.height-a.top;const b=this.decorationText(d.pageHeader),y=this.decorationText(d.pageFooter);if(b&&a.top<x+4)throw new RangeError("Top margin is too small for a page header.");if((y||d.pageNumbers!==!1)&&a.bottom<x+4)throw new RangeError("Bottom margin is too small for page decorations.");const C=this.fonts.select(),m=((C.program?.ascent??800)+(C.program?.descent??-200))*u/2e3;this.decoration(b,a.left,l.height-a.top/2-m,l.width-a.left-a.right);const k=l.width-a.left-a.right-(d.pageNumbers!==!1?this.pageNumberWidth+this.settings.padding*2:0);if(k<=0&&y)throw new RangeError("Page is too narrow for both footer text and page numbers.");if(this.decoration(y,a.left,a.bottom/2-m,k),d.pageNumbers!==!1){const M=d.pageNumberLabels,_=M?.suffix??"",A=l.width-a.right-this.pageNumberWidth+1,N=a.bottom/2-m,z=(M?.prefix??"Page ")+this.references.length+(M?.separator??" of "),O=f(z,C,u,this.pageNumberWidth,this.settings.limits.maxCellCharacters,1,!1)[0];this.settings.budget.cell(z+_),this.text(z,C,u,A,N),this.add(this.artifact("q 1 0 0 1 "+F(A+O.width)+" "+F(N)+" 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&&(d.title&&await this.paragraph(d.title,{bold:!0},u*1.5,!1,1),d.messageTop&&await this.paragraph(d.messageTop,{},u,!1));const I=n??(e&&this.layout?this.activeHeadings??=await this.layout.headers():[]),v=I.reduce((M,_)=>M+_.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],v+x+this.settings.padding*2,!0,{artifact:!0,...this.tableCaptionOwner===void 0?{}:{annotationParent:this.tableCaptionOwner}})),this.continuationTop=l.height-a.top-v-(j?.height??0),this.y-v-x-this.settings.padding*2<a.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 p(this.structure,this.tableElement,I),await this.tableStructure.prepareHeaders()),await this.drawHeadings(I),this.dataTop=this.y}async drawHeadings(e){for(const n of e){for(const d of n.cells)!this.bandCellBudget&&this.paintedHeaderBudgetCells.has(d.source??d)&&this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters===void 0?"":d.lines.map(u=>u.text).join(""));const l=this.tableStructure?n.cells.map(d=>this.tableStructure.owner(d.source??d)):void 0,a=n.cells.map(d=>this.paintedHeaderCells.has(d.source??d));this.draw(n,0,n.lines,l,a);for(const d of n.cells)this.paintedHeaderCells.add(d.source??d),this.paintedHeaderBudgetCells.add(d.source??d)}}async rowElements(e){const n=e.source??e;return this.tableStructure?.prepareRow(n,"data",this.tableElement,this.summaryRows.has(n)?0:void 0)}draw(e,n,l,a,d=[]){if(!this.layout)throw new Error("A table layout is required before drawing rows.");this.bodyAdded=!0;const{padding:u,fontSize:x}=this.settings,b=F,y=l*e.lineHeight+u*2,C=this.layout.lefts;this.rectangleLefts!==C&&(this.rectangleLefts=C,this.rectangleColumns=[]);let m,k="",I="";for(const[v,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(n,n+l):j.lines).map(L=>L.text).join(""));const M=C[j.first],_=j.height??y;_!==m&&(k=b(this.y-_),I=b(_),m=_);let A=this.rectangleColumns[j.first];(!A||A.x!==M||A.width!==j.width)&&(A={x:M,width:j.width,left:b(M),widthText:b(j.width)},this.rectangleColumns[j.first]=A);const N=A.left+" "+k+" "+A.widthText+" "+I;j.style.background&&this.add(this.artifact("q "+this.rgb(j.style.background)+" rg "+N+" re f Q\n")),this.add(this.artifact("q 0.82 0.85 0.89 RG 0.4 w "+N+" re S Q\n"));const z=a?.[v],O=j.semanticArtifact||d[v],B=j.link&&this.structure&&z!==void 0?this.structure.link(z,j.link):z;for(let L=n;L<Math.min(j.lines.length,j.height?j.lines.length:n+l);L++){const H=j.lines[L],G=j.style.alignment==="right"?j.width-u-H.width:j.style.alignment==="center"?(j.width-H.width)/2:u;this.inline(H,x,M+G,this.y-u-H.ascent-(L-n)*(e.structured?j.lineHeight:e.lineHeight),O?void 0:B,B)}j.link&&this.link(j.link,M,this.y-_,j.width,_,B)}this.y-=e.structured?e.height:y,this.sealCommands()}async block(e){if(this.bandFlow)return this.bandFlow.block(e);const n=e.reduce((a,d)=>a+d.height,0),l=this.settings.margins.bottom;if(n>this.y-l&&(await this.finishPage(),await this.start()),n>this.dataTop-l)throw new RangeError("A structured footer must fit on one page below the repeated headings.");for(const a of e){const d=await this.rowElements(a);this.draw(a,0,a.lines,d),await this.tableStructure?.completeRow(a.source??a)}}async row(e,n=!1){if(this.bandFlow)return this.bandFlow.row(e,n);const l=await this.rowElements(e),{margins:a,padding:d}=this.settings,u=this.continuationTop-a.bottom;!n&&e.height<=u+.001&&e.height>this.y-a.bottom+.001&&(await this.finishPage(),await this.start());let x=0;for(;x<e.lines;){let b=Math.min(e.lines-x,Math.floor((this.y-a.bottom-d*2+.001)/e.lineHeight));if(b<=0&&(await this.finishPage(),await this.start(),b=Math.min(e.lines-x,Math.floor((this.y-a.bottom-d*2+.001)/e.lineHeight))),b<=0)throw new RangeError("PDF page cannot fit a table line.");this.draw(e,x,b,l),x+=b,x<e.lines&&(await this.finishPage(),await this.start())}await this.tableStructure?.completeRow(e.source??e)}async keptRows(e,n=!1){if(this.bandFlow)return this.bandFlow.keptRows(e,n);const l=e.reduce((u,x)=>u+x.height,0),a=this.settings.margins.bottom,d=l<=this.continuationTop-a+.001;d&&l>this.y-a+.001&&(await this.finishPage(),await this.start());for(const[u,x]of e.entries())await this.row(x,!d&&u===0&&n)}async paragraph(e,n={},l=this.settings.fontSize,a=!0,d){await this.ensureStarted();const{margins:u,page:x,limits:b}=this.settings,y=this.fonts.select(n.bold,n.italic),C=y.lineHeight(l);this.settings.budget.cell(w(e,this.settings.budget));const m=await T(e,y,l,x.width-u.left-u.right,b.maxCellCharacters,b.maxRowLines,!0,this.settings.options.signal);if(C>x.height-u.top-u.bottom)throw new RangeError("PDF page cannot fit a paragraph line at the selected font metrics.");if(!a&&this.y-m.length*C-8<u.bottom)throw new RangeError("PDF title/message exceeds the first page's content area.");const k=this.structure?.element(d?"H"+d:"P");for(const I of m){this.y-C<u.bottom&&(await this.finishPage(),await this.start(!1));const v=n.alignment==="right"?x.width-u.right-I.width:n.alignment==="center"?u.left+(x.width-u.left-u.right-I.width)/2:u.left;this.bodyAdded=!0,this.text(I.text,y,l,v,this.y-(y.program?.ascent??800)*l/1e3,n.color,k),this.y-=C}this.y-=8,await this.structure?.complete(k)}async reserveSpace(e,n="Kept PDF content"){await this.ensureStarted();const{page:l,margins:a}=this.settings,d=l.height-a.top-a.bottom;if(e>d+.001)throw new RangeError(n+" exceeds a fresh page's content area.");e>this.y-a.bottom+.001&&await this.pageBreak()}async paragraphs(e,n=0,l=!1,a={}){const d=e.filter(x=>x.lines.length>0);if(!d.length)return;await this.ensureStarted();const u=new Array(d.length).fill(0);for(let x=d.length-1;x>=0;x--){const b=d[x],y=d[x+1];u[x]=b.keepWithNext?y?y.keepTogether||y.keepWithNext?y.height+u[x+1]:y.firstHeight:n:0}l&&d.length&&await this.reserveSpace(d.reduce((x,b)=>x+b.height,0)+u.at(-1),"Kept PDF paragraph group");for(const[x,b]of d.entries()){b.budgetOnPaint&&this.settings.budget.cell(w(b.text.text,this.settings.budget)),(b.keepTogether||b.keepWithNext)&&await this.reserveSpace(b.height+u[x],"Kept PDF paragraph chain");const{margins:y,page:C}=this.settings;if(b.firstHeight>C.height-y.top-y.bottom+.001)throw new RangeError("PDF page cannot fit a paragraph line and its leading spacing.");this.y-b.firstHeight<y.bottom&&await this.pageBreak(),this.y-=b.spaceBefore,b.bookmark&&this.addBookmark(b.bookmark);const m=a.artifact?void 0:a.owner??this.structure?.element(a.role??(b.headingLevel?"H"+b.headingLevel:"P"),a.parent??this.groupParent);let k=!0;for(const I of b.lines){if(I.lineHeight>C.height-y.top-y.bottom+.001)throw new RangeError("PDF page cannot fit a paragraph line at the selected font metrics.");this.y-I.lineHeight<y.bottom&&await this.pageBreak();const v=y.left+(a.indent??0),j=C.width-y.right-v,M=b.style.alignment==="right"?C.width-y.right-I.width:b.style.alignment==="center"?v+(j-I.width)/2:v;k&&a.marker&&this.inline(a.marker.line,b.size,v-a.marker.gap-a.marker.line.width,this.y-I.ascent,a.marker.owner),this.bodyAdded=!0,this.inline(I,b.size,M,this.y-I.ascent,m,a.annotationParent??m),this.y-=I.lineHeight,k=!1}this.y-=b.spaceAfter,a.keepOpen||await this.structure?.complete(m)}}get groupParent(){return this.groups.at(-1)?.element}async beginGroup(e,n,l){if(e!==this.groups.length)throw new Error("PDF analytical groups must open in hierarchical order.");await this.ensureStarted();const a=this.structure?.element("Sect",this.groupParent);this.groups.push({level:e,headingLevel:n.headingLevel??e+2,element:a}),await this.paragraphs([n],l,!0,{role:"H"+(n.headingLevel??e+2),...a===void 0?{}:{parent:a}})}async endGroup(e){const n=this.groups.at(-1);if(!n||n.level!==e)throw new Error("PDF analytical groups must close in hierarchical order.");await this.structure?.complete(n.element),this.outlines?.closeGroup(n.headingLevel),this.groups.pop()}summary(e){this.summaryRows.add(e)}async beginTable(e,n,l=e.lineHeight+this.settings.padding*2,a,d,u=!1,x=!1,b=!1){if(e.bands)return this.beginBands(e,n,l,a,d,x,b);await this.ensureStarted(),this.layout=e,this.paintedHeaderCells=new WeakSet,this.continuationCaption=d,this.continuationCaptionPaints=0,this.tableCaptionOwner=void 0,this.tableElement=this.structure?.element("Table",this.groupParent);const y=n??await e.headers();this.activeHeadings=y;const C=u&&this.bodyAdded&&!this.structure?[]:y,m=C.reduce((k,I)=>k+I.height,0);if(a&&!(x&&b)&&(await this.reserveSpace(a.height+m+l,"Kept PDF table caption and first data fragment"),this.tableCaptionOwner=x?this.captionAnnotations(a):a.lines.length?this.structure?.element("Caption",this.tableElement):void 0,await this.paragraphs([a],m+l,!0,x?{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 p(this.structure,this.tableElement,y),await this.tableStructure.prepareHeaders()),this.y-m-l<this.settings.margins.bottom){await this.finishPage(),await this.start(!0,y);return}this.continuationTop=this.settings.page.height-this.settings.margins.top-y.reduce((k,I)=>k+I.height,0)-(d?.height??0),await this.drawHeadings(C),this.dataTop=this.y}async beginBands(e,n,l,a,d,u,x){await this.ensureStarted();const b=n??await e.headers(),y=await e.bandRows(b,!0),C=y[0].reduce((O,B)=>O+B.height,0),{page:m,margins:k,padding:I}=this.settings,v=m.height-k.top-k.bottom-C-(a?.height??0),j=l<=v+.001?l:e.lineHeight+I*2,M=m.height-k.top-k.bottom-C-(d?.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 _=u&&x;this.y-k.bottom-C-(_?0:a?.height??0)+.001<j&&(await this.pageBreak(),_=!1);const A=this.y-k.bottom-C-(_?0:a?.height??0);if(A+.001<j)throw new RangeError("PDF band caption and headings leave no room for a data line.");let N=0;this.tableElement=this.structure?.element("Table",this.groupParent),this.paintedHeaderCells=new WeakSet;let z=this.structure&&a?.lines.length?u?this.captionAnnotations(a):this.structure.element("Caption",this.tableElement):void 0;this.structure&&(this.tableStructure=new p(this.structure,this.tableElement,b)),this.layout=void 0,this.continuationCaption=void 0,this.activeHeadings=void 0,this.bandFlow=new S(e,y,{firstCapacity:A,firstFullCapacity:v,continuationCapacity:M,prepareRow:async O=>{await this.tableStructure?.prepareHeaders(),await this.rowElements(O)},completeRow:async O=>{await this.tableStructure?.completeRow(O.source??O)},moveFirstToFreshPage:async()=>{await this.pageBreak(),_=!1},paint:async(O,B,L,H,G,W)=>{G&&W||await this.pageBreak();const X=e.bands[O];this.layout={lefts:X.lefts,lineHeight:e.lineHeight,headers:async()=>B},this.bandCellBudget=!0;try{if(H?.lines.length&&!(G&&W&&_)){!G&&N++===0&&(z=this.captionAnnotations(H,z));const K=z;await this.paragraphs([H],C+j,!0,G&&W&&!u?{role:"Caption",keepOpen:!0,...z===void 0?{}:{owner:z}}:{artifact:!0,...K===void 0?{}:{annotationParent:K}})}await this.tableStructure?.prepareHeaders(),await this.drawHeadings(B),this.dataTop=this.y;for(const K of L){D(this.settings.options.signal);const V=this.tableStructure?K.cells.map(se=>this.tableStructure.owner(se.source??se)):void 0;this.draw(K,0,K.lines,V)}}finally{this.bandCellBudget=!1}}},a,d)}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,n){if(!this.structure||!e.text.runs.some(a=>a.link&&a.text.trim()))return n;const l=n??this.structure.element("Caption",this.tableElement);for(const a of e.text.runs)a.link&&a.text.trim()&&this.structure.link(l,a.link,a.text);return l}async pageBreak(){await this.ensureStarted(),await this.finishPage(),await this.start(!1)}registerXObject(e,n){this.externalObjects.set(e,n)}graphicHeight(e,n){const{page:l,margins:a}=this.settings;return n*Math.min(1,(l.width-a.left-a.right)/e,(l.height-a.top-a.bottom)/n)}async graphic(e,n,l,a,d,u){await this.ensureStarted();const{page:x,margins:b}=this.settings,y=x.width-b.left-b.right,C=Math.min(1,y/e,(x.height-b.top-b.bottom)/n);e*=C,n*=C;const m=this.structure&&d!==void 0?this.structure.element("Figure",void 0," /Alt <feff"+c(d)+">"):void 0;if(u){if(d===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");await this.reserveSpace(u.height+n,"Kept PDF graphic and caption"),await this.paragraphs([u],n,!0,{role:"Caption",...m===void 0?{}:{parent:m}})}this.y-n<b.bottom&&await this.pageBreak();const k=l==="right"?x.width-b.right-e:l==="center"?b.left+(y-e)/2:b.left,I=a(k,this.y-n,e,n);this.bodyAdded=!0,this.add(this.structure&&m!==void 0?this.structure.mark(m)+I+"EMC\n":this.artifact(I)),this.y-=n+8,await this.structure?.complete(m)}async listItem(e,n){if(await this.ensureStarted(),this.structure&&n===void 0)throw new Error("A tagged list item requires a logical list owner.");const l=this.structure?.element("LI",n),a=l===void 0?void 0:this.structure.element("Lbl",l),d=l===void 0?void 0:this.structure.element("LBody",l);await this.paragraphs([e.paragraph],0,!1,{...d===void 0?{}:{parent:d},role:"P",indent:e.indent,marker:{line:e.marker,gap:e.markerGap,...a===void 0?{}:{owner:a}}}),await this.structure?.complete(l)}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:n,options:l}=this.settings;await this.objects.stream(e,this.takeCommands(),"",l.compression!==!1);const a=[];for(const d of this.annotations)a.push(d.id),await this.objects.object(d.id,d.body);await this.objects.object(this.current,"<< /Type /Page /Parent "+this.parent+" 0 R /MediaBox [0 0 "+F(n.width)+" "+F(n.height)+"] /Resources "+this.resources+" 0 R /Contents "+e+" 0 R"+(this.structure?.pageDictionary??"")+(a.length?" /Annots ["+a.map(d=>d+" 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(),n=String(this.references.length),l=n+(this.numberSettings.options.pageNumberLabels?.suffix??""),a=this.numberSettings.fontSize;this.settings.budget.cell(n);const d="BT /"+e.name+" "+F(a)+" Tf 1 0 0 1 0 0 Tm "+e.encode(l)+" Tj ET\n",u=f(l,e,a,this.numberSettings.page.width,this.settings.limits.maxCellCharacters,1,!1)[0].width,x=(e.program?.bbox[1]??-250)*a/1e3-1,b=(e.program?.bbox[3]??1e3)*a/1e3+1;await this.objects.stream(this.totalPages,d,"/Type /XObject /Subtype /Form /BBox [-1 "+F(x)+" "+F(u+1)+" "+F(b)+"] /Resources << /Font "+this.fonts.dictionary()+" >>",this.settings.options.compression!==!1)}}xobjects(){const e=[...this.externalObjects].map(([n,l])=>"/"+n+" "+l+" 0 R");return this.totalPages&&e.push("/TotalPages "+this.totalPages+" 0 R"),e.length?" /XObject << "+e.join(" ")+" >>":""}}return Object.freeze({PdfPages:h})})(),St=(()=>{class R{objects;root;entries=[];levels=[];lastKey=-1;constructor(P,S){this.objects=P,this.root=S}async append(P,S){if(P<=this.lastKey)throw new Error("PDF ParentTree keys must be appended in increasing order.");this.lastKey=P,this.entries.push({key:P,value:S}),this.entries.length===64&&await this.leaf()}async leaf(){if(!this.entries.length)return;const P=this.objects.reserve(),S=this.entries[0].key,p=this.entries.at(-1).key,f="<< /Limits ["+S+" "+p+"] /Nums ["+this.entries.map(T=>T.key+" "+T.value+" 0 R").join(" ")+"] >>";this.entries.length=0,await this.objects.object(P,f),await this.node({id:P,first:S,last:p},0)}async node(P,S){const p=this.levels[S]??=[];if(p.push(P),p.length===64){const f=await this.branch(p);p.length=0,await this.node(f,S+1)}}async branch(P){const S=this.objects.reserve(),p=P[0].first,f=P.at(-1).last;return await this.objects.object(S,"<< /Limits ["+p+" "+f+"] /Kids ["+P.map(T=>T.id+" 0 R").join(" ")+"] >>"),{id:S,first:p,last:f}}async finish(){await this.leaf();for(let S=0;S<this.levels.length-1;S++){const p=this.levels[S];if(p.length){const f=await this.branch(p);p.length=0,await this.node(f,S+1)}}const P=this.levels.at(-1)??[];await this.objects.object(this.root,P.length?"<< /Kids ["+P.map(S=>S.id+" 0 R").join(" ")+"] >>":"<< /Nums [] >>")}}return Object.freeze({PdfParentTree:R})})(),ct=(()=>{const{OfficeIMOError:R}=ae,{checkAbort:D}=he,{unicodeHex:F}=Pe,{PdfParentTree:P}=St;function S(c){return typeof c=="number"?c<0?-c-1+" ":c+" 0 R ":c+" "}function p(c){return"<< /Type /StructElem /S /"+c.role+" /P "+c.parent+" 0 R"+(c.markedPage===void 0?"":" /Pg "+c.markedPage+" 0 R")+(c.identifier===void 0?"":" /ID ("+c.identifier+")")+" /K ["}function f(c,r){const s=32768-r.length-c.attributes.length-4;if(s<0)return;let o="";for(const h of c.children){const t=S(h);if(o.length+t.length>s)return;o+=t}return r+o+"]"+c.attributes+" >>"}class T{objects;root;entries=[];levels=[];lastKey="";constructor(r,s){this.objects=r,this.root=s}async append(r,s){if(r<=this.lastKey)throw new Error("PDF structure IDs must be appended in increasing order.");this.lastKey=r,this.entries.push({key:r,value:s}),this.entries.length===64&&await this.leaf()}async leaf(){if(!this.entries.length)return;const r=this.objects.reserve(),s=this.entries[0].key,o=this.entries.at(-1).key,h="<< /Limits [("+s+") ("+o+")] /Names ["+this.entries.map(t=>"("+t.key+") "+t.value+" 0 R").join(" ")+"] >>";this.entries.length=0,await this.objects.object(r,h),await this.node({id:r,first:s,last:o},0)}async node(r,s){const o=this.levels[s]??=[];if(o.push(r),o.length===64){const h=await this.branch(o);o.length=0,await this.node(h,s+1)}}async branch(r){const s=this.objects.reserve(),o=r[0].first,h=r.at(-1).last;return await this.objects.object(s,"<< /Limits [("+o+") ("+h+")] /Kids ["+r.map(t=>t.id+" 0 R").join(" ")+"] >>"),{id:s,first:o,last:h}}async finish(){await this.leaf();for(let s=0;s<this.levels.length-1;s++){const o=this.levels[s];if(o.length){const h=await this.branch(o);o.length=0,await this.node(h,s+1)}}const r=this.levels.at(-1)??[];await this.objects.object(this.root,r.length?"<< /Kids ["+r.map(s=>s.id+" 0 R").join(" ")+"] >>":"<< /Names [] >>")}}class E{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(r,s){this.objects=r,this.settings=s,this.root=r.reserve(),this.parentTree=r.reserve(),this.parentTreeWriter=new P(r,this.parentTree),this.document=this.element("Document",this.root)}element(r,s=this.section??this.document,o=""){if(D(this.settings.options.signal),++this.allocated>this.settings.limits.maxStructureElements)throw new R("RESOURCE_LIMIT","maxStructureElements exceeded.");const h=this.objects.reserve(),t={id:h,parent:s,role:r,children:[],attributes:o};this.elements.set(h,t);const i=this.elements.get(s);return r==="Caption"&&i?.role==="Table"?i.children.unshift(h):i?.children.push(h),h}setAttributes(r,s){const o=this.elements.get(r);if(!o)throw new Error("PDF structure attributes require an open logical owner.");o.attributes=s}async attributeReference(r){D(this.settings.options.signal);const s=this.objects.reserve();return await this.objects.object(s,r)," /A "+s+" 0 R"}async beginSection(){await this.complete(this.section),this.section=this.element("Sect",this.document)}async identifier(r){D(this.settings.options.signal);const s=this.elements.get(r);if(!s)throw new Error("PDF structure IDs require an open logical owner.");if(s.identifier!==void 0)return s.identifier;const o="e"+String(r).padStart(16,"0");return this.identifiers??=new T(this.objects,this.objects.reserve()),await this.identifiers.append(o,r),s.identifier=o,o}beginPage(r){this.pageId=r,this.pageParents=[],this.pageKey=this.nextParentKey++}link(r,s,o){let h=this.links.get(s);h||(h=new Map,this.links.set(s,h));const t=h.get(r);if(t!==void 0)return t;const i=this.element("Link",r,o===void 0?"":" /Alt <feff"+F(o)+">");h.set(r,i);const e=this.elements.get(r);return(e.linkIdentities??=[]).push(s),i}annotation(r,s){D(this.settings.options.signal);const o=this.elements.get(r);if(!o||o.role!=="Link")throw new Error("Tagged link annotations require a logical Link owner.");const h=this.nextParentKey++;return o.children.push("<< /Type /OBJR /Obj "+s+" 0 R /Pg "+this.pageId+" 0 R >>"),this.annotations.push({key:h,owner:r}),h}mark(r,s){if(++this.references>this.settings.limits.maxMarkedContentReferences)throw new R("RESOURCE_LIMIT","maxMarkedContentReferences exceeded.");const o=this.elements.get(r);if(!o)throw new Error("Marked content requires an open logical owner.");const h=this.pageParents.length;return this.pageParents.push(r),o.markedPage??=this.pageId,o.children.push(o.markedPage===this.pageId?-(h+1):"<< /Type /MCR /Pg "+this.pageId+" 0 R /MCID "+h+" >>"),"/"+o.role+" << /MCID "+h+(s===void 0?"":" /ActualText <FEFF"+F(s)+">")+" >> BDC\n"}get pageDictionary(){return" /StructParents "+this.pageKey+" /Tabs /S"}get catalogDictionary(){return" /MarkInfo << /Marked true >> /Lang <feff"+F(this.settings.options.tagged.language)+"> /StructTreeRoot "+this.root+" 0 R"}async finishPage(){const r=this.objects.reserve();await this.objects.object(r,"["+this.pageParents.map(s=>s+" 0 R").join(" ")+"]"),await this.parentTreeWriter.append(this.pageKey,r);for(const s of this.annotations)await this.parentTreeWriter.append(s.key,s.owner);this.annotations.length=0,this.pageParents=[]}async complete(r){if(r===void 0)return;const s=this.elements.get(r);if(!s)return;for(const t of s.children)typeof t=="number"&&t>0&&!this.completeBuffered(t)&&await this.complete(t);D(this.settings.options.signal);const o=p(s),h=f(s,o);h!==void 0?this.objects.tryCompactObject(r,h)||await this.objects.compactObject(r,h):await this.objects.object(r,this.body(s,o)),this.releaseElement(s)}completeBuffered(r){const s=this.elements.get(r);if(!s)return!0;for(const h of s.children)if(typeof h=="number"&&h>0&&!this.completeBuffered(h))return!1;D(this.settings.options.signal);const o=f(s,p(s));return o===void 0||!this.objects.tryCompactObject(r,o)?!1:(this.releaseElement(s),!0)}releaseElement(r){if(r.linkIdentities)for(const s of r.linkIdentities){const o=this.links.get(s);o?.delete(r.id),o?.size||this.links.delete(s)}this.elements.delete(r.id)}*body(r,s){yield s;for(const o of r.children)yield S(o);yield"]"+r.attributes+" >>"}async completeRow(r){r?.length&&await this.complete(this.elements.get(r[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 w(c,r){const s=c.decorative,o=c.alternativeText;if(s!==void 0&&typeof s!="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>r.limits.maxCellCharacters)throw new R("RESOURCE_LIMIT","maxCellCharacters exceeded by graphic alternativeText.");if(F(o),s)throw new TypeError("A decorative graphic cannot also have alternativeText.")}if(r.options.tagged&&o===void 0&&s!==!0)throw new TypeError("Tagged PDF graphics require alternativeText or decorative:true.");return r.options.tagged&&o!==void 0&&r.budget.cell(o),o}return Object.freeze({PdfStructure:E,graphicAlternative:w})})(),jt=(()=>{const{OfficeIMOError:R}=ae,{checkAbort:D}=he,{pdfNumber:F,unicodeHex:P}=Pe;class S{objects;settings;root;items=[];top=[];stack=[];constructor(T,E){this.objects=T,this.settings=E}add(T,E,w){if(D(this.settings.options.signal),this.items.length>=this.settings.limits.maxBookmarks)throw new R("RESOURCE_LIMIT","maxBookmarks exceeded.");this.root??=this.objects.reserve();const g=T.level??1;for(;this.stack.length&&this.stack.at(-1).level>=g;)this.stack.pop();const c=this.stack.at(-1),r=c?.children??this.top,s=r.at(-1),o={id:this.objects.reserve(),title:T.title,page:E,y:w,level:g,parent:c?.id??this.root,children:[],previous:s?.id,next:void 0};s&&(s.next=o.id),r.push(o),this.items.push(o),this.stack.push(o)}get count(){return this.items.length}closeGroup(T){for(;this.stack.length&&this.stack.at(-1).level>=T;)this.stack.pop()}get catalogDictionary(){return this.root===void 0?"":" /Outlines "+this.root+" 0 R"}async finish(){if(this.root===void 0)return;const T=new Map;for(const E of[...this.items].reverse())T.set(E.id,E.children.reduce((w,g)=>w+1+T.get(g.id),0));for(const E of this.items)D(this.settings.options.signal),await this.objects.object(E.id,"<< /Title <feff"+P(E.title)+"> /Parent "+E.parent+" 0 R"+(E.previous===void 0?"":" /Prev "+E.previous+" 0 R")+(E.next===void 0?"":" /Next "+E.next+" 0 R")+(E.children.length?" /First "+E.children[0].id+" 0 R /Last "+E.children.at(-1).id+" 0 R /Count "+T.get(E.id):"")+" /Dest ["+E.page+" 0 R /XYZ null "+F(E.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:S})})(),ht=(()=>{const{PdfObjects:R,unicodeHex:D}=Pe,{PdfFontResources:F}=wt,{PdfTableLayout:P}=Ke,{PdfPages:S}=kt,{PdfStructure:p}=ct,{PdfOutlines:f}=jt;class T{settings;objects;fonts;pages;layout;structure;outlines;root;parent;resources;info;constructor(g,c,r=!1){this.settings=c,this.objects=new R(g,c.options.signal,c.budget.limits.maxOutputBytes,c.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=c.options.tagged?new p(this.objects,c):void 0,this.outlines=new f(this.objects,c),this.fonts=new F(this.objects,c.options.fonts,c.limits.maxFontBytes,c.options.signal),this.layout=r?new P(c,this.fonts):void 0,this.pages=new S(this.objects,c,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:g}=this.settings,{objects:c,fonts:r,pages:s}=this;await s.finish();for(const o of r.resources)await o.write(c,g.compression!==!1);await c.object(this.resources,"<< /Font "+r.dictionary()+s.xobjects()+" >>"),await c.object(this.parent,"<< /Type /Pages /Count "+s.references.length+" /Kids ["+s.references.map(o=>o+" 0 R").join(" ")+"] >>"),this.structure&&await this.structure.finish(),await this.outlines.finish(),await c.object(this.root,"<< /Type /Catalog /Pages "+this.parent+" 0 R"+(this.structure?.catalogDictionary??"")+this.outlines.catalogDictionary+" >>"),await c.object(this.info,"<< /Producer (OfficeIMO.js)"+(g.title===void 0?"":" /Title <feff"+D(g.title)+">")+" >>"),await c.finish(this.root,this.info)}}return Object.freeze({PdfWriteSession:T})})(),lt=(()=>{const{BlobByteSink:R,withDestination:D}=Be,{beginTask:F,checkAbort:P,consumeRows:S,pause:p,taskYieldDue:f}=he,{notifyProgress:T}=tt,{createRowProjector:E}=He,{settings:w}=Te,{PdfWriteSession:g}=ht;async function c(o,h){const t=new R;try{return await r(o,t,h),t.toBlob("application/pdf")}catch(i){throw t.discard(),i}}async function r(o,h,t){const i=w(t),{options:e,budget:n}=i;return F(),P(e.signal),D(h,async l=>{const a=new g(l,i,!0),{objects:d,pages:u}=a,x=a.layout,b=E(e.columns,void 0,e.signal);let y=0;await a.start();const C=()=>{if(y++,y%256===0&&(T(e.onProgress,{phase:"rows",rows:y,bytes:d.bytes}),f()))return p().then(()=>{P(e.signal)});P(e.signal)};await S(o,e.signal,async k=>{n.row(y+1);const I=b(k,y);return u.row(await x.data(I,y)).then(C)});const m=await x.footer(y);return m&&(e.footer?.rows?await u.block(m):await u.row(m[0])),x.bands&&await u.endTable(),e.messageBottom&&await u.paragraph(e.messageBottom),await a.finish(),T(e.onProgress,{phase:"complete",rows:y,bytes:d.bytes}),P(e.signal),{rows:y,columns:e.columns.length,bytes:d.bytes}})}return Object.freeze({writePdf:c,writePdfTo:r})})(),ze=(()=>{const{ExportCell:R,assertScalar:D}=Se,{isDate:F}=De,{checkAbort:P,inputRows:S,pause:p,taskYieldDue:f}=he,{ExportBudget:T}=nt,{OfficeIMOError:E}=ae,{copyColumns:w,createRowProjector:g}=He,{createTotals:c}=at,{copyExportValue:r}=qe,s=new WeakMap;function o(m){if(!m||typeof m!="object"||!s.has(m))throw new TypeError("Create grouped report sources with createGroupedReport.")}function h(m,k){return o(m),{async*[Symbol.asyncIterator](){const I=t(m,k);try{yield*I.events}finally{I.dispose()}}}}function t(m,k){o(m);const I=s.get(m),v=i(I.signal,k);return{signal:v.signal,events:I.events(v.signal),dispose:v.dispose}}function i(m,k){if(!m||!k||m===k)return{signal:m??k,dispose(){}};const I=new AbortController,v=()=>I.abort(m.reason),j=()=>I.abort(k.reason);return m.addEventListener("abort",v,{once:!0}),k.addEventListener("abort",j,{once:!0}),m.aborted?v():k.aborted&&j(),{signal:I.signal,dispose(){m.removeEventListener("abort",v),k.removeEventListener("abort",j)}}}function e(m,k,I){const v=m??k;if(!Number.isSafeInteger(v)||v<0)throw new RangeError(I+" must be a nonnegative safe integer.");return v}function n(m){return m instanceof R?m.value:m}function l(m){if(m==null)return{key:null,id:"null",text:""};if(F(m)){const I=Date.prototype.getTime.call(m);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 m=="number"&&!Number.isFinite(m))throw new TypeError("A numeric group key must be finite.");const k=String(m);return{key:m,id:typeof m+":"+k,text:k}}function a(m){return F(m)?new Date(Date.prototype.getTime.call(m)):m}function d(m){return Object.freeze(m.map(k=>k.operation===void 0?null:k.value()))}function u(m,k,I){const v=typeof m=="string"?[m]:Array.isArray(m)?Array.from(m):void 0;if(!v||v.length<1||v.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&&v.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(v.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:_,value:A,label:N}=typeof M=="string"?{key:M,value:void 0,label:void 0}:M;if(typeof _!="string"||!_.length||j.has(_))throw new TypeError("Grouping levels need unique, nonempty stable keys.");if(j.add(_),A!==void 0&&typeof A!="function")throw new TypeError("Grouping value getters must be synchronous functions.");if(N!==void 0&&typeof N!="function")throw new TypeError("Grouping labels must be synchronous functions.");if(N&&I)throw new TypeError("Specify either groupLabel or the grouping descriptor label.");const z=k.indexOf(_);if(z>=0&&A!==void 0)throw new TypeError("A declared grouping column reuses its projected value; do not provide another value getter.");if(z<0&&A===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:_,column:z,value:A,label:N??I})}))}function x(m){return Object.freeze(m.map(({group:k})=>Object.freeze({...k,key:a(k.key)})))}function b(m,k,I){if(!m)return I;const v=m(a(k));if(typeof v?.then=="function"&&Promise.resolve(v).catch(()=>{}),typeof v!="string")throw new TypeError("Grouping labels must return synchronous text.");return v}function y(m,k){if(!k||typeof k!="object")throw new TypeError("Grouped report options are required.");const{columns:I,groupBy:v,totals:j,groupLabel:M,maxGroups:_,maxGroupKeyCharacters:A,signal:N,limits:z}=k;if(z!==void 0&&(!z||typeof z!="object"||Array.isArray(z)))throw new TypeError("Grouped source limits must be an object.");if(z!==void 0&&"maxOutputBytes"in z)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 O=w(I),B=O.map(Q=>Q.key);if(B.some(Q=>typeof Q!="string"||Q.length===0)||new Set(B).size!==B.length)throw new TypeError("Grouped report columns need unique, nonempty stable keys.");const L=u(v,B,M),H=Object.freeze({...j}),G=c(O,H);for(let Q=0;Q<O.length;Q++)if(G[Q].operation!==void 0&&O[Q].type!=="number")throw new TypeError("Grouped numeric totals require a column declared with type:number.");const W=e(_,1e3,"maxGroups"),X=e(A,1e6,"maxGroupKeyCharacters"),K=new T(z),V=Object.freeze(O.map(Q=>{const{value:Ee,...xe}=Q;return Object.freeze(xe)}));for(const Q of O){K.cell(Q.header);for(const Ee of Q.groups??[])K.reserve(0,Ee.length);Object.freeze(Q)}let se=!1;const oe=Q=>Object.freeze({[Symbol.asyncIterator](){if(se)throw new TypeError("A grouped report source can be consumed only once.");return se=!0,ge(Q)}}),fe=oe(N);async function*ge(Q){const Ee=g(O,void 0,Q),xe=new Set,ue=[];let ke=0,Y=0,ee=0;for await(const re of S(m,Q)){const te=Array.isArray(re)?Array.from(re):re,ce=Ee(te,Y),le=[];for(let U=0;U<O.length;U++)le.push(r(ce[U])??null);P(Q);const pe=L.map((U,q)=>{P(Q);const Z=U.column>=0?n(le[U.column]):U.value(te,Object.freeze({rowIndex:Y,level:q,key:U.key}));return D(Z),P(Q),l(Z)});K.row(Y+1);for(let U=0;U<le.length;U++){const q=le[U],Z=n(q);if(G[U].operation!==void 0&&Z!=null&&(typeof Z!="number"||!Number.isFinite(Z)))throw new TypeError("Grouped numeric metrics must resolve to finite numbers or null.");K.cell(Z),q instanceof R&&q.text!==void 0&&K.reserve(0,q.text.length)}let de=0;for(;de<ue.length&&ue[de].id===pe[de].id;)de++;const $=[];for(let U=de;U<L.length;U++){const q=pe[U],ie=(($.at(-1)??ue[U-1])?.group.groupIndex??-1)+":"+q.id;if(xe.has(ie))throw new TypeError("Grouped rows must be contiguous; a closed group key occurred again within the same parent.");if(ee===W)throw new E("RESOURCE_LIMIT","maxGroups exceeded.");const ne=b(L[U].label,q.key,q.text);P(Q);const ye=ke+ie.length+ne.length;if(!Number.isSafeInteger(ye)||ye>X)throw new E("RESOURCE_LIMIT","maxGroupKeyCharacters exceeded.");K.reserve(0,ne.length),$.push({id:q.id,group:Object.freeze({groupIndex:ee,key:q.key,label:ne,level:U}),rows:0,aggregates:c(O,H)}),ke=ye,xe.add(ie),ee++}for(;ue.length>de;){P(Q);const U=x(ue),q=ue.pop();yield Object.freeze({kind:"groupEnd",...U.at(-1),path:U,rows:q.rows,totals:d(q.aggregates)})}for(const U of $){P(Q),ue.push(U);const q=x(ue);yield Object.freeze({kind:"groupStart",...q.at(-1),path:q})}for(let U=0;U<le.length;U++){const q=n(le[U]);for(const Z of ue)Z.aggregates[U].accept(q);G[U].accept(q)}for(const U of ue)U.rows++;P(Q),yield Object.freeze({kind:"row",values:Object.freeze(le),rowIndex:Y,groupIndex:ue.at(-1).group.groupIndex,path:x(ue)}),Y++,f()&&(await p(),P(Q))}for(P(Q);ue.length;){P(Q);const re=x(ue),te=ue.pop();yield Object.freeze({kind:"groupEnd",...re.at(-1),path:re,rows:te.rows,totals:d(te.aggregates)})}P(Q),yield Object.freeze({kind:"complete",rows:Y,groups:ee,totals:d(G)})}const J=Object.freeze({columns:V,groupBy:Object.freeze(L.map(Q=>Q.key)),totals:H,events:fe});return s.set(J,{signal:N,events:oe}),J}return Object.freeze({assertGroupedReportSource:o,groupedReportEvents:h,groupedReportOperation:t,createGroupedReport:y})})(),Ct=(()=>{const R=new Uint32Array(256).map((P,S)=>{let p=S;for(let f=0;f<8;f++)p=p&1?3988292384^p>>>1:p>>>1;return p>>>0});class D{crc=4294967295;update(S){let p=this.crc;for(let f=0;f<S.length;f++)p=R[(p^S[f])&255]^p>>>8;this.crc=p}get value(){return(this.crc^4294967295)>>>0}}return Object.freeze({Crc32:D})})(),Rt=(()=>{const{NotSupportedError:R,OfficeIMOError:D}=ae,{checkAbort:F,pause:P,taskYieldDue:S,withAbort:p}=he,{Crc32:f}=Ct,T=[137,80,78,71,13,10,26,10],E=new Set(["PLTE","tRNS","iCCP","sRGB","gAMA","cHRM","cICP","mDCV","cLLI","sBIT","eXIf","acTL","fcTL","fdAT"]);async function w(t,i,e,n){F(e);const l=s(t,i),a=l.width*l.height,d=t.length+a*l.components+(l.components===4?l.width*8:0);if(n!==void 0&&d>n)throw new D("RESOURCE_LIMIT","maxImageWorkingBytes exceeded by PNG source, image planes and scanlines.");const u=new Uint8Array(t),x=await r(u,l,e);F(e);let b;try{if(typeof DecompressionStream!="function")throw new TypeError("Missing DecompressionStream");b=new DecompressionStream("deflate")}catch(G){throw new D("PLATFORM_UNAVAILABLE",'PNG intake requires native DecompressionStream("deflate").',{cause:G})}const{width:y,height:C,components:m}=x,k=y*m,I=(k+1)*C;if(!Number.isSafeInteger(I)||I>2147483647)throw new D("RESOURCE_LIMIT","PNG filtered data exceeds the supported decoded byte length.");const v=new Uint8Array(y*C*3),j=m===4?new Uint8Array(a):void 0;let M=m===4?new Uint8Array(k):void 0,_=m===4?new Uint8Array(k):void 0;const A=g(u,x,e).pipeThrough(b).getReader();let N=0,z=0,O=0,B=0,L=0,H=0;try{for(;;){const G=await p(A.read(),e).catch(W=>{throw F(e),new TypeError("Invalid PNG zlib image data.",{cause:W})});if(F(e),G.done)break;if(G.value.length>I-N)throw new TypeError("PNG inflated bytes exceed the exact IHDR scanline length.");for(let W=0;W<G.value.length;W++){const X=G.value[W];if(L===0){if(H=X,H>4)throw new TypeError("Invalid PNG scanline filter.")}else{const K=L-1;let V=X;if(H!==0){const se=L>m?_?_[K-m]:v[z-m]:0,oe=M?M[K]:z>=k?v[z-k]:0,fe=L>m?M?M[K-m]:z>=k?v[z-k-m]:0:0;V=X+(H===1?se:H===2?oe:H===3?Math.floor((se+oe)/2):o(se,oe,fe))&255}_?_[K]=V:v[z]=V,z++}if(L===k){if(L=0,_&&j){for(let V=0;V<k;V+=4)v[O++]=_[V],v[O++]=_[V+1],v[O++]=_[V+2],j[B++]=_[V+3],(V&16383)===16380&&(S()&&await P(),F(e));const K=_;_=M,M=K}}else L++;(W&16383)===16383&&(S()&&await P(),F(e))}N+=G.value.length,S()&&await P(),F(e)}if(N!==I)throw new TypeError("PNG inflated bytes must match the exact IHDR scanline length.");return await c(u,x,I,e),{width:y,height:C,components:3,data:v,...j?{alpha:j}:{}}}catch(G){throw A.cancel(G).catch(()=>{}),G}finally{A.releaseLock()}}function g(t,i,e,n=!1){const l=new DataView(t.buffer,t.byteOffset,t.byteLength);let a=i.firstData,d=a+8,u=d+l.getUint32(a);return new ReadableStream({pull(x){for(F(e);d===u;){if(a=u+4,a===i.dataEnd){x.close();return}d=a+8,u=d+l.getUint32(a)}if(n&&d===i.lastDataByte){x.enqueue(Uint8Array.of(t[d++]^1));return}const b=Math.min(u,d+4096,n&&d<i.lastDataByte?i.lastDataByte:u);x.enqueue(t.subarray(d,b)),d=b}},{highWaterMark:0})}async function c(t,i,e,n){const l=g(t,i,n,!0).pipeThrough(new DecompressionStream("deflate")).getReader();let a=!1,d=0;try{for(;;){let u;try{u=await p(l.read(),n)}catch{F(n),a=!0;break}if(F(n),u.done)break;if(d+=u.value.length,d>e)throw new TypeError("Invalid PNG zlib image data.");S()&&await P(),F(n)}if(!a)throw new TypeError("Invalid PNG zlib image data: trailing bytes after the checksum.")}finally{l.cancel().catch(()=>{}),l.releaseLock()}}async function r(t,i,e){const n=new DataView(t.buffer,t.byteOffset,t.byteLength);let l=0,a=0,d=-1,u=!1;for(let x=8;x<t.length;){if(F(e),x+12>t.length)throw new TypeError("Truncated PNG chunk.");const b=n.getUint32(x),y=x+12+b;if(b>2147483647||y>t.length)throw new TypeError("Truncated or oversized PNG chunk.");const C=String.fromCharCode(...t.subarray(x+4,x+8));if(!/^[A-Za-z]{2}[A-Z][A-Za-z]$/.test(C))throw new TypeError("Invalid PNG chunk type.");const m=new f;for(let k=x+4;k<y-4;k+=65536)m.update(t.subarray(k,Math.min(y-4,k+65536))),S()&&await P(),F(e);if(m.value!==n.getUint32(y-4))throw new TypeError("PNG chunk CRC mismatch: "+C+".");if(x===8&&C!=="IHDR")throw new TypeError("PNG IHDR must be the first chunk.");if(C==="IHDR"){if(x!==8||b!==13)throw new TypeError("PNG requires one 13-byte IHDR first.")}else if(C==="IDAT"){if(u)throw new TypeError("PNG IDAT chunks must be consecutive.");l||=x,a=y,b&&(d=y-5)}else{if(l&&(u=!0),C==="IEND"){if(b!==0||!l||y!==t.length)throw new TypeError("PNG requires a final empty IEND after IDAT.");return{...i,firstData:l,dataEnd:a,lastDataByte:d}}if(E.has(C))throw new R("PNG chunk "+C+"; normalize color, orientation, transparency or animation first");if((t[x+4]&32)===0)throw new R("Required PNG chunk "+C)}x=y}throw new TypeError("PNG requires a complete final IEND chunk.")}function s(t,i){if(t.length<33||T.some((d,u)=>t[u]!==d))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 n=e.getUint32(16),l=e.getUint32(20);if(!n||!l||n>2147483647||l>2147483647)throw new TypeError("Invalid PNG dimensions.");if(!Number.isSafeInteger(n*l)||n*l>i)throw new D("RESOURCE_LIMIT","PNG dimensions exceed maxImagePixels.");if(t[24]!==8||![2,6].includes(t[25]))throw new R("PNG intake requires 8-bit RGB or RGBA pixels");if(t[26]!==0||t[27]!==0)throw new R("PNG compression or filter method");if(t[28]!==0)throw new R("Interlaced PNG intake");const a=t[25]===6?4:3;if(!Number.isSafeInteger((n*a+1)*l)||(n*a+1)*l>2147483647)throw new D("RESOURCE_LIMIT","PNG filtered data exceeds the supported decoded byte length.");return{width:n,height:l,components:a}}function o(t,i,e){const n=t+i-e,l=Math.abs(n-t),a=Math.abs(n-i),d=Math.abs(n-e);return l<=a&&l<=d?t:a<=d?i:e}return Object.freeze({pngPixels:w})})(),Ot=(()=>{const{NotSupportedError:R,OfficeIMOError:D}=ae,{checkAbort:F,pause:P,taskYieldDue:S}=he,{pngPixels:p}=Rt;class f{objects;settings;images=new Map;bytes=0;constructor(g,c){this.objects=g,this.settings=c}async prepare(g){const c=this.images.get(g);if(c)return c;const{limits:r,options:s}=this.settings;if(!g||typeof g!="object")throw new TypeError("PDF images require a byte array.");const o=g.data,h=g.format;if(!(o instanceof Uint8Array))throw new TypeError("PDF images require a byte array.");const t=o.length;if(this.bytes+t>r.maxImageBytes)throw new D("RESOURCE_LIMIT","maxImageBytes exceeded.");let i,e,n,l,a;const d=r.maxImageWorkingBytes;if(h==="png")({width:i,height:e,components:n,data:l,alpha:a}=await p(o,r.maxImagePixels,s.signal,d));else if(h==="jpeg")({width:i,height:e,components:n}=T(o));else if(h==="rgb"||h==="rgba")({width:i,height:e}=g),n=h==="rgba"?4:3;else throw new R("PDF images support unprofiled PNG/JPEG or decoded RGB/RGBA pixels.");if(!Number.isSafeInteger(i)||!Number.isSafeInteger(e)||i<1||e<1||!Number.isSafeInteger(i*e)||i*e>r.maxImagePixels)throw new D("RESOURCE_LIMIT","Image dimensions must be positive integers within maxImagePixels.");if((h==="rgb"||h==="rgba")&&t!==i*e*n)throw new RangeError("Raw image bytes must match width × height × channels exactly.");if(h!=="png"&&d!==void 0&&t+(n===4?i*e:0)>d)throw new D("RESOURCE_LIMIT","maxImageWorkingBytes exceeded by image snapshot and alpha plane.");F(s.signal);const u=this.objects.reserve(),x="Image"+(this.images.size+1);this.bytes+=t;const b=l??new Uint8Array(o);let y=b,C=a,m;if(n===4){y=b.subarray(0,i*e*3),C=new Uint8Array(i*e);for(let v=0;v<C.length;v++)y[v*3]=b[v*4],y[v*3+1]=b[v*4+1],y[v*3+2]=b[v*4+2],C[v]=b[v*4+3],(v&16383)===16383&&(S()&&await P(),F(s.signal))}C&&(m=this.objects.reserve(),await this.objects.stream(m,C,"/Type /XObject /Subtype /Image /Width "+i+" /Height "+e+" /ColorSpace /DeviceGray /BitsPerComponent 8",s.compression!==!1,!0));const k="/Type /XObject /Subtype /Image /Width "+i+" /Height "+e+" /ColorSpace /"+(n===1?"DeviceGray":"DeviceRGB")+" /BitsPerComponent 8"+(m?" /SMask "+m+" 0 R":"")+(h==="jpeg"?" /Filter /DCTDecode":"");await this.objects.stream(u,y,k,h==="jpeg"?!1:s.compression!==!1,!0);const I={name:x,id:u,width:i,height:e};return this.images.set(g,I),I}}function T(w){if(w.length<4||w[0]!==255||w[1]!==216||w[w.length-2]!==255||w[w.length-1]!==217)throw new TypeError("JPEG images need complete SOI/EOI markers.");let g;for(let c=2;c<w.length;){if(w[c++]!==255)throw new TypeError("Invalid JPEG marker.");for(;w[c]===255;)c++;const r=w[c++];if(r===218){if(!g)throw new TypeError("JPEG scan precedes its frame header.");return g}if(r===217)break;if(c+2>w.length)throw new TypeError("Truncated JPEG segment.");const s=w[c]*256+w[c+1],o=c+s;if(s<2||o>w.length)throw new TypeError("Truncated JPEG segment.");if(r===226&&s>=14&&String.fromCharCode(...w.subarray(c+2,c+14))==="ICC_PROFILE\0")throw new R("Normalize ICC-profiled JPEG colors before PDF embedding.");if(r===225&&s>=8&&String.fromCharCode(...w.subarray(c+2,c+8))==="Exif\0\0")throw new R("Normalize JPEG EXIF orientation before PDF embedding.");if(r>=192&&r<=207&&![196,200,204].includes(r)){if(![192,193,194].includes(r)||s<8||w[c+2]!==8)throw new R("PDF JPEG images require 8-bit baseline, sequential or progressive frames.");const h=w[c+7];if(![1,3].includes(h)||s!==8+h*3)throw new R("PDF JPEG images require grayscale or RGB components; CMYK is unsupported.");if(h===3){const t=[w[c+8],w[c+11],w[c+14]].join(",");if(t!=="1,2,3"&&t!=="82,71,66")throw new R("Unsupported JPEG component color layout.")}if(g)throw new R("Multiple JPEG frame headers are unsupported.");g={width:w[c+5]*256+w[c+6],height:w[c+3]*256+w[c+4],components:h}}c=o}throw new TypeError("JPEG image has no complete frame and scan.")}return Object.freeze({PdfDocumentImages:f})})(),It=(()=>{const{OfficeIMOError:R}=ae,{checkAbort:D,pause:F,taskYieldDue:P}=he,{color:S,positive:p}=Te,{pdfNumber:f}=Pe;async function T(w,g,c){const r=p(w.width,"Vector width"),s=p(w.height,"Vector height"),o=w.commands;if(!Array.isArray(o))throw new TypeError("Vector commands must be an array.");if(c+o.length>g.limits.maxVectorCommands)throw new R("RESOURCE_LIMIT","maxVectorCommands exceeded.");const h=o.map(y=>{if(!y||typeof y!="object")throw new TypeError("Invalid vector command.");const C=y.op;if(C==="move"||C==="line")return{op:C,x:y.x,y:y.y};if(C==="cubic")return{op:C,x1:y.x1,y1:y.y1,x2:y.x2,y2:y.y2,x:y.x,y:y.y};if(C==="close")return{op:C};throw new TypeError("Unsupported vector command.")}),t=w.fill,i=w.stroke,e=t===void 0?void 0:S(t),n=i===void 0?void 0:S(i);if(e===void 0&&n===void 0)throw new TypeError("A vector path requires fill or stroke.");const l=p(w.strokeWidth??1,"Vector stroke width",144),a=w.fillRule;if(a!==void 0&&!["nonzero","evenodd"].includes(a))throw new TypeError("Invalid vector fill rule.");const d=[];let u=0,x=!1;const b=(y,C)=>{if(!Number.isFinite(y)||y<0||y>C)throw new RangeError("Vector coordinates must stay inside their declared bounds.");return f(y)};for(let y=0;y<h.length;y++){const C=h[y];let m;if(!C||typeof C!="object")throw new TypeError("Invalid vector command.");if(C.op==="move"||C.op==="line"){if(C.op==="line"&&!x)throw new TypeError("A vector subpath must begin with move.");m=b(C.x,r)+" "+b(C.y,s)+(C.op==="move"?" m\n":" l\n"),x=!0}else if(C.op==="cubic"){if(!x)throw new TypeError("A vector subpath must begin with move.");m=[b(C.x1,r),b(C.y1,s),b(C.x2,r),b(C.y2,s),b(C.x,r),b(C.y,s)].join(" ")+" c\n"}else if(C.op==="close"){if(!x)throw new TypeError("Cannot close an empty vector path.");m="h\n"}else throw new TypeError("Unsupported vector command.");if(u+=m.length,u>g.limits.maxPageBytes-256)throw new R("RESOURCE_LIMIT","maxPageBytes exceeded by vector commands.");d.push(m),(y&1023)===1023&&(P()&&await F(),D(g.options.signal))}if(!x)throw new TypeError("A vector path needs at least one command.");return{width:r,height:s,count:h.length,content:(e===void 0?"":e+" rg\n")+(n===void 0?"":n+" RG\n"+f(l)+" w\n")+d.join("")+(e!==void 0&&n!==void 0?"B":e!==void 0?"f":"S")+(e!==void 0&&a==="evenodd"?"*":"")+"\n"}}return Object.freeze({vectorCommands:T})})(),vt=(()=>{const{NotSupportedError:R,OfficeIMOError:D}=ae,{checkAbort:F,pause:P,taskYieldDue:S}=he,{color:p,positive:f}=Te,{pdfNumber:T}=Pe;function E(t,i,e){if(!t||typeof t!="object"||Array.isArray(t)||Reflect.ownKeys(t).some(n=>typeof n!="string"||!i.includes(n)))throw new TypeError("Unsupported "+e+" properties.");return t}function w(t){E(t,["kind","drawing","alignment","alternativeText","decorative","caption"],"drawing block")}function g(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 c(t){const i=E(t,["x","y","width","height"],"drawing clip");return{x:g(i.x),y:g(i.y),width:f(i.width,"Drawing clip width",1e6),height:f(i.height,"Drawing clip height",1e6)}}async function r(t){S()&&await P(),F(t.options.signal)}function s(t,i,e){F(i.options.signal);const n=E(t,["version","width","height","elements"],"drawing");if(n.version!==1)throw new R("Only portable drawing version 1 is supported.");const l=f(n.width,"Drawing width"),a=f(n.height,"Drawing height");let d=e.commands,u=e.elements;const x=new Set;function b(k){E(k,["kind","commands","fill","stroke","strokeWidth","fillRule","lineCap","lineJoin"],"drawing path");const I=k.commands;if(!Array.isArray(I))throw new TypeError("Drawing path commands must be an array.");if(d+I.length>i.limits.maxVectorCommands)throw new D("RESOURCE_LIMIT","maxVectorCommands exceeded.");F(i.options.signal);const v=I.slice(),j=[];let M=!1;d+=v.length;const _=k.fill,A=k.stroke,N=_===void 0?void 0:p(_),z=A===void 0?void 0:p(A);if(N===void 0&&z===void 0)throw new TypeError("A drawing path requires fill or stroke.");const O=f(k.strokeWidth??1,"Drawing stroke width"),B=k.fillRule,L=k.lineCap,H=k.lineJoin;if(B!==void 0&&!["nonzero","evenodd"].includes(B))throw new TypeError("Invalid drawing fillRule.");if(L!==void 0&&!["butt","round","square"].includes(L))throw new TypeError("Invalid drawing lineCap.");if(H!==void 0&&!["miter","round","bevel"].includes(H))throw new TypeError("Invalid drawing lineJoin.");for(let G=0;G<v.length;G++){const W=v[G];if(!W||typeof W!="object")throw new TypeError("Invalid drawing path command.");const X=W.op;if(X==="move"||X==="line"){if(E(W,["op","x","y"],"drawing path command"),X==="line"&&!M)throw new TypeError("A drawing subpath must begin with move.");j.push({op:X,x:g(W.x),y:g(W.y)}),M=!0}else if(X==="cubic"){if(E(W,["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:g(W.x1),y1:g(W.y1),x2:g(W.x2),y2:g(W.y2),x:g(W.x),y:g(W.y)})}else if(X==="close"){if(E(W,["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.");(G&1023)===1023&&F(i.options.signal)}if(!M)throw new TypeError("A drawing path needs at least one command.");return{kind:"path",commands:j,style:(N===void 0?"":N+" rg\n")+(z===void 0?"":z+" RG\n"+T(O)+" w\n")+String(["butt","round","square"].indexOf(L??"butt"))+" J\n"+String(["miter","round","bevel"].indexOf(H??"miter"))+" j\n10 M\n",paint:(N!==void 0&&z!==void 0?"B":N!==void 0?"f":"S")+(N!==void 0&&B==="evenodd"?"*":"")+"\n"}}function y(k){E(k,["kind","text","x","y","font","fontSize","color"],"drawing text");const I=k.text,v=k.font;if(typeof I!="string")throw new TypeError("Drawing text must be a string.");if(I.length>i.limits.maxCellCharacters)throw new D("RESOURCE_LIMIT","maxCellCharacters exceeded.");if(/[\r\n\u2028\u2029]/.test(I))throw new R("Drawing text must be a single baseline without line breaks.");if(!["regular","bold","italic","boldItalic"].includes(v))throw new TypeError("Invalid drawing font slot.");const j=g(k.x),M=g(k.y),_=f(k.fontSize,"Drawing font size"),A=p(k.color);return i.budget.cell(I),{kind:"text",text:I,x:j,y:M,size:_,color:A,font:v}}function C(k,I){if(!Array.isArray(k))throw new TypeError("Drawing elements must be an array.");if(I>32&&k.length)throw new RangeError("Drawing groups support at most 32 element levels.");if(u+k.length>i.limits.maxDrawingElements)throw new D("RESOURCE_LIMIT","maxDrawingElements exceeded.");F(i.options.signal);const v=k.slice(),j=[];for(let M=0;M<v.length;M++){if(++u>i.limits.maxDrawingElements)throw new D("RESOURCE_LIMIT","maxDrawingElements exceeded.");const _=v[M];if(!_||typeof _!="object")throw new TypeError("Invalid drawing element.");if(x.has(_))throw new TypeError("Drawing groups cannot contain cycles.");const A=_.kind;if(A==="path")j.push(b(_));else if(A==="text")j.push(y(_));else if(A==="group"){E(_,["kind","clip","elements"],"drawing group");const N=_.clip,z=N===void 0?void 0:c(N);x.add(_),j.push({kind:"group",...z?{clip:z}:{},children:C(_.elements,I+1)}),x.delete(_)}else throw new TypeError("Unsupported drawing element kind.");(M&255)===255&&F(i.options.signal)}return j}const m=C(n.elements,1);return F(i.options.signal),{width:l,height:a,plan:m,commands:d-e.commands,elements:u-e.elements}}async function o(t,i,e,n){const l=s(t,i,n),a=new Map;function d(M){const _=a.get(M);if(_)return _;const A=e.select(M==="bold"||M==="boldItalic",M==="italic"||M==="boldItalic");if(!A.program||A.syntheticBold||A.syntheticItalic)throw new R("Drawing text without an exact embedded font face at fonts."+M);return a.set(M,A),A}let u=0,x=0;async function b(M){for(let _=0;_<M.length;_++){const A=M[_];if(A.kind==="group")await b(A.children);else if(A.kind==="text"){const N=d(A.font);for(const z of A.text)N.width(z.codePointAt(0)),(++u&1023)===0&&await r(i)}(++x&255)===0&&await r(i)}}await b(l.plan);const y=[];let C=0;function m(M){if(C+=M.length,C>i.limits.maxPageBytes-256)throw new D("RESOURCE_LIMIT","maxPageBytes exceeded by drawing content.");y.push(M)}let k=0,I=0,v=0;async function j(M){for(let _=0;_<M.length;_++){const A=M[_];if(m("q\n"),A.kind==="group")A.clip&&m([A.clip.x,A.clip.y,A.clip.width,A.clip.height].map(T).join(" ")+" re W n\n"),await j(A.children);else if(A.kind==="path"){m(A.style);for(let N=0;N<A.commands.length;N++){const z=A.commands[N];m(z.op==="move"||z.op==="line"?T(z.x)+" "+T(z.y)+(z.op==="move"?" m\n":" l\n"):z.op==="cubic"?[z.x1,z.y1,z.x2,z.y2,z.x,z.y].map(T).join(" ")+" c\n":"h\n"),(++I&1023)===0&&await r(i)}m(A.paint)}else{const N=d(A.font);m(A.color+" rg\nBT /"+N.name+" "+T(A.size)+" Tf 0 Tr 1 0 0 -1 "+T(A.x)+" "+T(A.y)+" Tm <");let z="";for(const O of A.text)z+=O,(++k&1023)===0&&(m(N.encode(z).slice(1,-1)),z="",await r(i));z&&m(N.encode(z).slice(1,-1)),m("> Tj ET\n")}m("Q\n"),(++v&255)===0&&await r(i)}}return await j(l.plan),F(i.options.signal),{width:l.width,height:l.height,content:y.join(""),commands:l.commands,elements:l.elements}}return Object.freeze({checkDrawingBlock:w,prepareDrawing:o})})(),Je=(()=>{const{OfficeIMOError:R}=ae,{capturePdfText:D,wrapPdfText:F}=Ne,{positive:P}=Te,{resolveParagraphStyle:S}=Ve,{captureBookmark:p}=Xe,{captureFields:f}=je,{pdfBudgetText:T}=Me;function E(o,h,t,i=!1){if(!o||o.kind!=="paragraph")throw new TypeError("PDF paragraph groups accept paragraph blocks only.");const{text:e,headingLevel:n,presentation:l,fontSize:a,keepTogether:d,keepWithNext:u,spaceBefore:x,spaceAfter:b,style:y,bookmark:C}=o;if(n!==void 0&&(!Number.isInteger(n)||n<1||n>6))throw new TypeError("Paragraph headingLevel must be an integer from 1 through 6.");const m=S(y,{...a===void 0?{}:{fontSize:a},...l===void 0?{}:{presentation:l},...d===void 0?{}:{keepTogether:d},...u===void 0?{}:{keepWithNext:u},...x===void 0?{}:{spaceBefore:x},...b===void 0?{}:{spaceAfter:b}},h.paragraphStyles),k=m.presentation??Object.freeze({}),I=P(m.fontSize??h.fontSize,"Paragraph font size",144),v=p(C,h);return Object.freeze({text:D(e,k,h,t,!1,!i),style:k,size:I,...i?{budgetOnPaint:!0}:{},...n===void 0?{}:{headingLevel:n},...v===void 0?{}:{bookmark:v},keepTogether:m.keepTogether??!1,keepWithNext:m.keepWithNext??!1,spaceBefore:m.spaceBefore??0,spaceAfter:m.spaceAfter??8})}function w(o,h,t){if(!o||typeof o!="object"||Array.isArray(o)||Object.keys(o).some(i=>!["text","style","fontSize","presentation","spaceBefore","spaceAfter"].includes(i)))throw new TypeError("PDF captions support text, style, fontSize, presentation, spaceBefore and spaceAfter.");return E({...f(o,["text","style","fontSize","presentation","spaceBefore","spaceAfter"]),kind:"paragraph",keepTogether:!0,keepWithNext:!0},h,t,!0)}async function g(o,h,t,i=h.page.width-h.margins.left-h.margins.right){if(!o.text.text)return{...o,lines:[],height:0,firstHeight:0};if(!o.budgetOnPaint){const n=T(o.text.text,h.budget);h.budget.cell(n,n.length)}const e=await F(o.text,t,o.size,P(i,"Paragraph width"),h);return{...o,lines:e,height:o.spaceBefore+e.reduce((n,l)=>n+l.lineHeight,0)+o.spaceAfter,firstHeight:o.spaceBefore+e[0].lineHeight}}function c(o,h){if(o.length>h.limits.maxGroupBlocks)throw new R("RESOURCE_LIMIT","maxGroupBlocks exceeded.");let t=0,i=0;for(const e of o){if(t+=e.text.text.length,i+=e.text.runs.length,t>h.limits.maxCellCharacters)throw new R("RESOURCE_LIMIT","maxCellCharacters exceeded by a paragraph group or keep chain.");if(i>h.limits.maxTextRuns)throw new R("RESOURCE_LIMIT","maxTextRuns exceeded by a paragraph group or keep chain.")}}function r(o){const h=o.filter(i=>i.lines.length>0);let t=0;for(let i=h.length-1;i>=0;i--){const e=h[i];t=e.keepWithNext?e.height+t:e.keepTogether?e.height:e.firstHeight}return t}return Object.freeze({captureParagraph:E,captureCaption:w,prepareParagraph:g,checkParagraphBuffer:c,paragraphStartHeight:r})})(),Ft=(()=>{const{capturePdfText:R,wrapPdfText:D}=Ne,{captureParagraph:F,prepareParagraph:P}=Je,{resolveParagraphStyle:S}=Ve;function p(E,w){const{items:g,ordered:c=!1,start:r,itemStyle:s,indent:o,markerGap:h}=E,t=r===void 0?1:r;if(typeof c!="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(!c&&r!==void 0)throw new TypeError("PDF list start requires ordered:true.");for(const[i,e]of[["indent",o],["markerGap",h]])if(e!==void 0&&(!Number.isFinite(e)||e<0||e>14400))throw new RangeError("PDF list "+i+" must be from zero through 14,400 points.");if(S(s,{},w.paragraphStyles).keepWithNext)throw new TypeError("PDF list item styles cannot use keepWithNext.");return Object.freeze({items:g,ordered:c,start:t,...s===void 0?{}:{itemStyle:s},...o===void 0?{}:{indent:o},...h===void 0?{}:{markerGap:h}})}async function f(E,w,g,c,r){if(!E||typeof E!="object"||Array.isArray(E)||Object.keys(E).some(C=>!["text","style","keepTogether"].includes(C)))throw new TypeError("PDF list items support text, style and keepTogether.");if(!Number.isSafeInteger(w)||w<0||!Number.isSafeInteger(g.start+w))throw new RangeError("PDF list numbering must remain within positive safe integers.");const{text:s,style:o=g.itemStyle,keepTogether:h}=E,t=F({kind:"paragraph",text:s,...o===void 0?{}:{style:o},...h===void 0?{}:{keepTogether:h}},c,r);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 i=g.ordered?String(g.start+w)+".":"•",e=R(i,t.style,c,r);c.budget.cell(i,i.length);const n=c.page.width-c.margins.left-c.margins.right,l=(await D(e,r,t.size,n,c,!1))[0],a=g.markerGap??t.size/2,d=g.indent??Math.max(t.size*2,l.width+a);if(l.width+a>d+.001)throw new RangeError("PDF list indent cannot fit its marker and gap.");if(d>=n)throw new RangeError("PDF list indent leaves no body text area.");const u=await P(t,c,r,n-d),x=u.lines[0],b=Math.max(x.lineHeight,l.lineHeight),y=Math.max(x.ascent,l.ascent);return{marker:l,indent:d,markerGap:a,paragraph:{...u,lines:[{...x,lineHeight:b,ascent:y},...u.lines.slice(1)],height:u.height+b-x.lineHeight,firstHeight:u.spaceBefore+b}}}return Object.freeze({captureListOptions:p,prepareListItem:f})})(),Ye=(()=>{const{assertGroupedReportSource:R}=ze,{captureFields:D}=je,{captureWideTable:F}=Te,{presentation:P}=Ae,S=["labelColumn","subtotalLabel","grandTotalLabel","includeGrandTotal","continuationLabel","groupHeadingLevel"],p=["includeHeader","headerPresentation","footerPresentation","alternateRowColor","columnWidths","wideTable","formatValue","formatRuns",...S];function f(w,g){return R(w),Object.freeze({kind:"groupedTable",report:w,options:T(g)})}function T(w){if(!w||typeof w!="object"||Array.isArray(w)||Object.keys(w).some(n=>!p.includes(n)))throw new TypeError("Grouped PDF table options support table presentation and labels; document settings belong on writePdfDocument.");const g=D(w,p),{labelColumn:c,subtotalLabel:r,grandTotalLabel:s,includeGrandTotal:o,continuationLabel:h,groupHeadingLevel:t}=g;if(!c||typeof c!="object")throw new TypeError("Grouped PDF needs a leading labelColumn.");const{header:i,width:e}=c;if(typeof i!="string")throw new TypeError("The grouped label column header must be text.");for(const[n,l]of[["subtotalLabel",r],["grandTotalLabel",s]])if(typeof l!="function")throw new TypeError(n+" must be a synchronous text callback.");if(h!==void 0&&typeof h!="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({...g,...g.wideTable===void 0?{}:{wideTable:F(g.wideTable)},labelColumn:Object.freeze({header:i,...e===void 0?{}:{width:e}}),...g.columnWidths===void 0?{}:{columnWidths:Object.freeze([...g.columnWidths])},...g.headerPresentation===void 0?{}:{headerPresentation:P(g.headerPresentation)},...g.footerPresentation===void 0?{}:{footerPresentation:P(g.footerPresentation)}})}return Object.freeze({groupedPdfLabelFields:S,groupedPdfTableFields:p,pdfGroupedTable:f,captureGroupedPdfTableOptions:T})})(),Bt=(()=>{const{assertGroupedReportSource:R,groupedReportOperation:D}=ze,{consumeRows:F}=he,{ExportCell:P}=Se,{captureGroupedPdfTableOptions:S}=Ye,{settings:p}=Te,{PdfTableLayout:f}=Ke,{captureCaption:T,captureParagraph:E,prepareParagraph:w}=Je,{synchronousText:g}=Me;async function c(s,o){const{report:h}=s,{pages:t,fonts:i,prepared:e,controller:n}=o;R(h);const l=e.options.tagged!==void 0,a=S(s.options),{labelColumn:d,subtotalLabel:u,grandTotalLabel:x,includeGrandTotal:b=!0,continuationLabel:y,groupHeadingLevel:C=2,...m}=a,k=Object.freeze([Object.freeze({...d}),...h.columns]);let I=-1;const v=z=>({rowIndex:I,columnIndex:z.columnIndex-1,column:h.columns[z.columnIndex-1]}),j=p({...t.settings.options,...m,columns:k,includeHeader:m.includeHeader??!0,...m.formatValue===void 0?{}:{formatValue:(z,O)=>m.formatValue(z,v(O))},...m.formatRuns===void 0?{}:{formatRuns:(z,O)=>m.formatRuns(z,v(O))}}),M={...j,budget:e.budget},_=new f(M,i);o.acceptColumns(k.length);const A=D(h,n.signal),N=()=>n.abort(A.signal?.reason);A.signal?.addEventListener("abort",N,{once:!0}),A.signal?.aborted&&N();try{const z=await _.headers(),O=await _.blockHeight(z);let B=[],L=!1,H=!1,G=!1,W=0;const X=new WeakMap;let K;const V=[],se=h.columns.flatMap((Y,ee)=>Object.hasOwn(h.totals,Y.key)?[ee]:[]),oe=(Y,ee,re)=>Object.freeze([new P(Y,{text:Y,presentation:j.options.footerPresentation}),...(re?re.map(te=>ee[te]):ee).map(te=>new P(te,{presentation:j.options.footerPresentation}))]),fe=new Map,ge=Y=>{const ee=fe.get(Y);if(ee)return ee;const re=[0,...se.map(U=>U+1)],te=re.map(U=>{const q=k[U];if(!Y)return q;const{groups:Z,...ie}=q;return ie}),ce=U=>{const q=re[U.columnIndex];return{...U,columnIndex:q,column:k[q]}},le=re.flatMap((U,q)=>U===0||j.repeatedColumns.includes(U)?[q]:[]),pe=j.options.wideTable,de={...M,repeatedColumns:Object.freeze(le),options:{...j.options,columns:te,...j.options.columnWidths===void 0?{}:{columnWidths:re.map(U=>j.options.columnWidths[U])},...typeof pe!="object"?{}:{wideTable:{...pe,repeatColumns:le}},...j.options.formatValue===void 0?{}:{formatValue:(U,q)=>j.options.formatValue(U,ce(q))},...j.options.formatRuns===void 0?{}:{formatRuns:(U,q)=>j.options.formatRuns(U,ce(q))}}},$=new f(de,i);return fe.set(Y,$),$},J=async()=>{const Y=await w(T({text:B.map(re=>re.label).join("\n"),presentation:{bold:!0},spaceAfter:4},t.settings,i),t.settings,i),ee=await w(T({text:B.map(re=>{if(y===void 0)return re.label;const te=l?X.get(re):void 0;if(te!==void 0)return te;const ce=g(y(re),"continuationLabel");return l&&X.set(re,ce),ce}).join("\n"),presentation:{bold:!0},spaceAfter:4},t.settings,i),t.settings,i);return{caption:Y,continuation:ee}},Q=async()=>{if(K)if(L||await xe(K),V.length&&!G)await t.keptRows([K,...V],H);else if(V.length){await t.row(K,H);for(const Y of V)await t.row(Y)}else await t.row(K,H);else for(const Y of V)await t.row(Y);K=void 0,V.length=0,H=!1,G=!1},Ee=async()=>{!L&&!K||(await Q(),await t.endTable(),L=!1)},xe=async Y=>{const{caption:ee,continuation:re}=await J(),te=Y.height+V.reduce((Z,ie)=>Z+ie.height,0),ce=j.page.height-j.margins.top-j.margins.bottom-O-Math.max(ee?.height??0,re.height);G=V.length>0&&te>ce+.001;const le=V.length>0&&!G?te:_.minimumRowHeight(Y),pe=[];if(l)for(const Z of B.slice(W))pe.push(await w(E({kind:"paragraph",text:Z.label.trim()?Z.label:"",headingLevel:C+Z.level,presentation:{bold:!0},keepTogether:!0,keepWithNext:!0,spaceAfter:4,...Z.label.trim()?{bookmark:{title:Z.label,level:C+Z.level}}:{}},t.settings,i),t.settings,i));const de=pe.reduce((Z,ie)=>Z+ie.height,0),$=l&&W>0?await w(T({text:B.slice(0,W).map(Z=>Z.label).join("\n"),presentation:{bold:!0},spaceAfter:4},t.settings,i),t.settings,i):void 0,U=l?($?.height??0)+de:ee.height;await o.flushParagraphs(U+O+le),$&&await t.paragraphs([$],de+O+le,!0,{artifact:!0});let q=de+(l?0:ee.height)+O+le;for(const Z of pe)q-=Z.height,await t.beginGroup(W++,Z,q);await t.beginTable(_,z,le,ee,re,!1,l,l),L=!0,H=(ee?.lines.length??0)>0||pe.some(Z=>Z.lines.length>0)},ue=async(Y,ee,re)=>{if(ee===h.groupBy.length-1){t.summary(Y),V.push(Y),await Ee(),await t.endGroup(ee),W=ee,B=B.slice(0,ee);return}await Ee();const{caption:te,continuation:ce}=await J(),le=ge(!1),pe=await le.headers(),de=await le.data(re,0,!0),$=le.minimumRowHeight(de);await o.flushParagraphs(te.height+await le.blockHeight(pe)+$),await t.beginTable(le,pe,$,te,ce,!1,!0),t.summary(de),await t.row(de,te.lines.length>0||pe.length>0),await t.endTable(),await t.endGroup(ee),W=ee,B=B.slice(0,ee)},ke=async Y=>{if(await Ee(),!b&&Y.rows!==0)return;const ee=Y.rows===0?_:ge(!0),re=Y.rows===0?z:await ee.headers();I=-1;let te;if(b&&(o.acceptRow(!1),te=await ee.data(oe(g(x(Y),"grandTotalLabel"),Y.totals,Y.rows===0?void 0:se),0,!0)),!re.length&&!te)return;const ce=te?ee.minimumRowHeight(te):0;await o.flushParagraphs(await ee.blockHeight(re)+ce),await t.beginTable(ee,re,ce),te&&(l&&t.summary(te),await t.row(te)),await t.endTable()};await F(A.events,A.signal,async Y=>{switch(Y.kind){case"groupStart":if(await Ee(),l&&C+Y.level>6)throw new RangeError("groupHeadingLevel and the opened group depth exceed heading level 6.");B=Object.freeze([...B.slice(0,Y.level),Y]);break;case"row":{K&&await Q(),I=Y.rowIndex,o.acceptRow(!0),K=await _.data([new P("",{text:""}),...Y.values],Y.rowIndex);break}case"groupEnd":{I=-1,o.acceptRow(!1);const ee=l&&Y.level!==h.groupBy.length-1,re=oe(g(u(Y),"subtotalLabel"),Y.totals,ee?se:void 0),te=ee?void 0:await _.data(re,0,!0);l?await ue(te,Y.level,re):V.push(te);break}case"complete":await ke(Y);break}})}finally{A.signal?.removeEventListener("abort",N),A.dispose()}}return Object.freeze({renderGroupedPdfTable:c})})(),Ue=(()=>{const{BlobByteSink:R,withDestination:D}=Be,{OfficeIMOError:F}=ae,{beginTask:P,checkAbort:S,consumeRows:p,pause:f,taskYieldDue:T}=he,{notifyProgress:E}=tt,{copyColumns:w,createRowProjector:g}=He,{captureFields:c}=je,{settings:r,captureWideTable:s}=Te,{pdfNumber:o}=Pe,{PdfTableLayout:h}=Ke,{PdfWriteSession:t}=ht,{PdfDocumentImages:i}=Ot,{vectorCommands:e}=It,{graphicAlternative:n}=ct,{checkDrawingBlock:l,prepareDrawing:a}=vt,{captureParagraph:d,captureCaption:u,prepareParagraph:x,checkParagraphBuffer:b,paragraphStartHeight:y}=Je,{captureListOptions:C,prepareListItem:m}=Ft,{captureSection:k}=Xe,{renderGroupedPdfTable:I}=Bt,v=["columns","includeHeader","headerRows","footer","headerPresentation","footerPresentation","alternateRowColor","columnWidths","wideTable","formatValue","formatRuns"];function j(O,B){const L=N(B);return Object.freeze({kind:"table",rows:O,options:Object.freeze({...L,columns:Object.freeze(w(L.columns))})})}async function M(O,B={}){const L=new R;try{return await _(O,L,B),L.toBlob("application/pdf")}catch(H){throw L.discard(),H}}async function _(O,B,L={}){const H=r(L,!0),G=new AbortController,W=H.options.signal,X=()=>G.abort(W?.reason);W?.addEventListener("abort",X,{once:!0}),W?.aborted&&X();const K={...H,options:{...H.options,signal:G.signal}},{options:V,budget:se}=K;try{return P(),S(V.signal),await D(B,async oe=>{const fe=new t(oe,K),{objects:ge,pages:J,fonts:Q}=fe,Ee=new i(ge,K);let xe=0,ue=0,ke=0,Y=0,ee=0,re=0,te=[];const ce=async($=0)=>{const U=[];for(const q of te)U.push(await x(q,J.settings,Q));te=[],await J.paragraphs(U,$)},le=async $=>{const U=d($,J.settings,Q);U.text.text&&(te.length||U.keepWithNext?(te.push(U),b(te,J.settings),U.keepWithNext||await ce()):await J.paragraphs([await x(U,J.settings,Q)]))},pe=async $=>$===void 0?void 0:x($,J.settings,Q),de=$=>$===void 0?void 0:u($,J.settings,Q);return await fe.start(),await p(O,V.signal,async $=>{if(!$||typeof $!="object")throw new TypeError("PDF document blocks must be objects.");switch($.kind){case"section":{const U=k($,K);await ce();const q=await J.beginSection(U);q.includeHeading?await le({kind:"paragraph",text:q.title,headingLevel:q.level,...q.headingStyle===void 0?{fontSize:J.settings.fontSize*1.5,presentation:{bold:!0}}:{style:q.headingStyle},keepTogether:!0,keepWithNext:!0,...q.bookmark?{bookmark:{title:q.title,level:q.level}}:{}}):q.bookmark&&J.addBookmark({title:q.title,level:q.level});break}case"paragraph":await le($);break;case"list":{const U=C($,J.settings);let q=0,Z;await p(U.items,V.signal,async ie=>{if(++re>K.limits.maxListItems)throw new F("RESOURCE_LIMIT","maxListItems exceeded.");const ne=await m(ie,q++,U,J.settings,Q);q===1&&(await ce(ne.paragraph.keepTogether?ne.paragraph.height:ne.paragraph.firstHeight),Z=fe.structure?.element("L")),await J.listItem(ne,Z),T()&&await f(),S(V.signal)}),await fe.structure?.complete(Z);break}case"group":{const U=$.blocks,q=$.keepTogether;if(!Array.isArray(U))throw new TypeError("PDF paragraph group blocks must be an array.");if(q!==void 0&&typeof q!="boolean")throw new TypeError("PDF paragraph group keepTogether must be boolean.");if(U.length>K.limits.maxGroupBlocks)throw new F("RESOURCE_LIMIT","maxGroupBlocks exceeded.");const Z=[];for(const ne of U)Z.push(d(ne,J.settings,Q)),b(Z,K);if(Z.filter(ne=>ne.text.text).at(-1)?.keepWithNext)throw new TypeError("The last paragraph in a group cannot keepWithNext beyond the group's boundary.");const ie=[];for(const ne of Z)ie.push(await x(ne,J.settings,Q));if(!ie.some(ne=>ne.lines.length>0))break;await ce(q!==!1?ie.reduce((ne,ye)=>ne+ye.height,0):y(ie)),await J.paragraphs(ie,0,q!==!1);break}case"pageBreak":await ce(),await J.pageBreak();break;case"groupedTable":await I($,{prepared:K,pages:J,fonts:Q,controller:G,flushParagraphs:ce,acceptColumns:U=>{ke=Math.max(ke,U)},acceptRow:U=>{se.row(++ue),U&&++xe%256===0&&E(V.onProgress,{phase:"rows",rows:xe,bytes:ge.bytes})}});break;case"table":{const{options:U,rows:q,caption:Z,continuationCaption:ie}=$,ne=N(U),ye=de(Z),Ce=de(ie),me=r({...J.settings.options,...ne,columns:ne?.columns,includeHeader:ne?.includeHeader??!0}),we=new h({...me,budget:se},Q),be=await pe(ye),Re=await pe(Ce),Ge=g(me.options.columns,void 0,V.signal);let ve=0,Oe=!1;ke=Math.max(ke,me.options.columns.length);const Fe=await we.headers(),Ze=await we.blockHeight(Fe);await p(q,V.signal,async Le=>{se.row(++ue);const $e=await we.data(Ge(Le,ve),ve),dt=!Oe&&(te.length>0||!!be?.lines.length);if(!Oe){const et=we.minimumRowHeight($e);await ce((be?.height??0)+Ze+et),await J.beginTable(we,Fe,et,be,Re),Oe=!0}await J.row($e,dt),ve++,xe++,xe%256===0&&E(V.onProgress,{phase:"rows",rows:xe,bytes:ge.bytes}),T()&&await f(),S(V.signal)});const Ie=await we.footer(ve),ft=!Oe&&(te.length>0||!!be?.lines.length);if(!Oe){if(!Fe.length&&!Ie?.length)break;const Le=Ie?.length?me.options.footer?.rows?await we.blockHeight(Ie):we.minimumRowHeight(Ie[0]):0;await ce((be?.height??0)+Ze+Le),await J.beginTable(we,Fe,Le,be,Re)}Ie&&(me.options.footer?.rows?await J.block(Ie):await J.row(Ie[0],ft)),await J.endTable();break}case"image":{const{width:U,height:q,image:Z,caption:ie}=$,ne=de(ie),ye=n($,J.settings),Ce=A($.alignment);if(ne&&ye===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");const me=await Ee.prepare(Z),we=await pe(ne),be=U??(q===void 0?me.width*.75:q*me.width/me.height),Re=q??be*me.height/me.width;if(!Number.isFinite(be)||be<=0||!Number.isFinite(Re)||Re<=0)throw new RangeError("Image display dimensions must be finite and positive.");await ce((we?.height??0)+J.graphicHeight(be,Re)),J.registerXObject(me.name,me.id),await J.graphic(be,Re,Ce,(Ge,ve,Oe,Fe)=>"q "+[Oe,0,0,Fe,Ge,ve].map(o).join(" ")+" cm /"+me.name+" Do Q\n",ye,we);break}case"vector":{const U=de($.caption),q=n($,J.settings),Z=A($.alignment);if(U&&q===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");const ie=await e($,J.settings,Y),ne=await pe(U);Y+=ie.count,await ce((ne?.height??0)+J.graphicHeight(ie.width,ie.height)),await J.graphic(ie.width,ie.height,Z,(ye,Ce,me,we)=>"q "+[me/ie.width,0,0,-we/ie.height,ye,Ce+we].map(o).join(" ")+" cm 0 0 "+o(ie.width)+" "+o(ie.height)+" re W n\n"+ie.content+"Q\n",q,ne);break}case"drawing":{l($);const U=$.drawing,q=de($.caption),Z=n($,J.settings),ie=A($.alignment);if(q&&Z===void 0)throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");const ne=await a(U,J.settings,Q,{commands:Y,elements:ee}),ye=await pe(q);Y+=ne.commands,ee+=ne.elements,await ce((ye?.height??0)+J.graphicHeight(ne.width,ne.height)),await J.graphic(ne.width,ne.height,ie,(Ce,me,we,be)=>"q "+[we/ne.width,0,0,-be/ne.height,Ce,me+be].map(o).join(" ")+" cm 0 0 "+o(ne.width)+" "+o(ne.height)+" re W n\n"+ne.content+"Q\n",Z,ye);break}default:throw new TypeError("Unsupported PDF document block.")}T()&&await f(),S(V.signal)}),await ce(),V.messageBottom&&await J.paragraph(V.messageBottom),await fe.finish(),E(V.onProgress,{phase:"complete",rows:xe,bytes:ge.bytes}),S(V.signal),{rows:xe,columns:ke,bytes:ge.bytes}})}finally{W?.removeEventListener("abort",X)}}function A(O){if(O!==void 0&&!["left","center","right"].includes(O))throw new TypeError("Invalid graphic alignment.");return O??"left"}function N(O){if(!O||typeof O!="object"||Object.keys(O).some(L=>!v.includes(L)))throw new TypeError("Table options support columns, headings, footers, widths and presentation; document settings belong on writePdfDocument.");const B=c(O,v);return{...B,...B.wideTable===void 0?{}:{wideTable:s(B.wideTable)}}}return Object.freeze({pdfTable:j,writePdfDocument:M,writePdfDocumentTo:_})})(),Qe=(()=>{const{assertGroupedReportSource:R}=ze,{BlobByteSink:D}=Be,{writePdfDocumentTo:F}=Ue,{pdfOptionFields:P}=Te,{captureFields:S}=je,{pdfGroupedTable:p,groupedPdfLabelFields:f,groupedPdfTableFields:T}=Ye,E=[...P,...f];async function w(r,s){const o=new D;try{return await g(r,o,s),o.toBlob("application/pdf")}catch(h){throw o.discard(),h}}async function g(r,s,o){if(R(r),!o||typeof o!="object")throw new TypeError("Grouped PDF options are required.");const h=S(o,E),t=Object.fromEntries(T.filter(e=>Object.hasOwn(h,e)).map(e=>[e,h[e]])),i={...h};for(const e of T)delete i[e];return delete i.columns,delete i.headerRows,delete i.footer,F([p(r,t)],s,i)}return Object.freeze({pdfGroupedTable:Ye.pdfGroupedTable,writeGroupedPdf:w,writeGroupedPdfTo:g})})(),At=(()=>{const{fontProgram:R}=_e,{resolveScalar:D,selectFont:F,validateFonts:P}=ot;function S(f,T={}){if(typeof f!="string")throw new TypeError("PDF preflight text must be a string.");if(!T||typeof T!="object")throw new TypeError("PDF preflight options must be an object.");for(const r of["bold","italic"])if(T[r]!==void 0&&typeof T[r]!="boolean")throw new TypeError("PDF preflight "+r+" must be boolean.");P(T.fonts);const E=T.bold??!1,{font:w}=F(T.fonts,E,T.italic??!1),g=w?R(w):void 0,c=new Set;for(let r=0;r<f.length;){const s=f.codePointAt(r),o=s===9?32:s;if(s!==10&&s!==13&&!c.has(o)){const h=D(o,g,E);if(!h.supported)return{...h,index:r,...h.code==="unpaired-surrogate"?{}:{scalar:s}};c.add(o)}r+=s>65535?2:1}return{supported:!0}}return Object.freeze({preflightPdfText:S})})(),Dt=(()=>{const{OfficeIMOError:R}=ae;function D(){let S=!1;if(typeof CompressionStream=="function")try{new CompressionStream("deflate-raw"),S=!0}catch{}return{blob:typeof Blob=="function",streams:typeof WritableStream=="function",deflateRaw:S,download:typeof document<"u"&&typeof URL.createObjectURL=="function"}}function F(S,p){if(!(S instanceof Blob)||typeof p!="string"||!p)throw new TypeError("A Blob and file name are required.");if(typeof document>"u"||typeof URL.createObjectURL!="function")throw new R("PLATFORM_UNAVAILABLE","saveBlob requires a browser document and object URLs.");const f=URL.createObjectURL(S),T=document.createElement("a");try{T.href=f,T.download=p,document.body.append(T),T.click()}finally{T.remove(),setTimeout(()=>URL.revokeObjectURL(f),3e4)}}return Object.freeze({OfficeIMOError:ae.OfficeIMOError,NotSupportedError:ae.NotSupportedError,BlobByteSink:Be.BlobByteSink,ChunkedTextSink:Be.ChunkedTextSink,writeBytes:Be.writeBytes,ExportCell:Se.ExportCell,createGroupedReport:ze.createGroupedReport,checkAbort:he.checkAbort,withAbort:he.withAbort,inputRows:he.inputRows,pause:he.pause,detectFeatures:D,saveBlob:F})})(),_t=Object.freeze({writePdf:lt.writePdf,writePdfTo:lt.writePdfTo,writeGroupedPdf:Qe.writeGroupedPdf,writeGroupedPdfTo:Qe.writeGroupedPdfTo,pdfGroupedTable:Qe.pdfGroupedTable,createGroupedReport:ze.createGroupedReport,writePdfDocument:Ue.writePdfDocument,writePdfDocumentTo:Ue.writePdfDocumentTo,pdfTable:Ue.pdfTable,PdfFont:_e.PdfFont,preflightPdfText:At.preflightPdfText,ExportCell:Se.ExportCell,saveBlob:Dt.saveBlob}),{writePdf:Mt,writePdfTo:zt,writeGroupedPdf:Lt,writeGroupedPdfTo:Ht,pdfGroupedTable:Nt,createGroupedReport:Ut,writePdfDocument:Gt,writePdfDocumentTo:Wt,pdfTable:qt,PdfFont:Vt,preflightPdfText:Kt,ExportCell:Xt,saveBlob:Jt}=_t;export{Xt as ExportCell,Vt as PdfFont,Ut as createGroupedReport,Nt as pdfGroupedTable,qt as pdfTable,Kt as preflightPdfText,Jt as saveBlob,Lt as writeGroupedPdf,Ht as writeGroupedPdfTo,Mt as writePdf,Gt as writePdfDocument,Wt as writePdfDocumentTo,zt as writePdfTo};