@evotecit/officeimo 0.1.4 → 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.
- package/README.md +18 -4
- package/bundles/officeimo-canopyx-adapter.js +1444 -0
- package/bundles/officeimo-canopyx-adapter.min.js +2 -0
- package/bundles/officeimo-canopyx-adapter.min.mjs +2 -0
- package/bundles/officeimo-canopyx-adapter.mjs +1426 -0
- package/bundles/officeimo-canopyx.js +108 -50
- package/bundles/officeimo-canopyx.min.js +2 -0
- package/bundles/officeimo-canopyx.min.mjs +2 -0
- package/bundles/officeimo-canopyx.mjs +96 -38
- package/bundles/officeimo-csv.min.js +2 -0
- package/bundles/officeimo-csv.min.mjs +2 -0
- package/bundles/officeimo-datatables-adapter.js +626 -0
- package/bundles/officeimo-datatables-adapter.min.js +2 -0
- package/bundles/officeimo-datatables-adapter.min.mjs +2 -0
- package/bundles/officeimo-datatables-adapter.mjs +617 -0
- package/bundles/officeimo-datatables.js +55 -10
- package/bundles/officeimo-datatables.min.js +2 -0
- package/bundles/officeimo-datatables.min.mjs +2 -0
- package/bundles/officeimo-datatables.mjs +51 -6
- package/bundles/officeimo-execution.min.js +2 -0
- package/bundles/officeimo-execution.min.mjs +2 -0
- package/bundles/officeimo-pdf.min.js +2 -0
- package/bundles/officeimo-pdf.min.mjs +2 -0
- package/bundles/officeimo-xlsx.min.js +2 -0
- package/bundles/officeimo-xlsx.min.mjs +2 -0
- package/bundles/officeimo.min.js +2 -0
- package/bundles/officeimo.min.mjs +2 -0
- package/bundles/officeimo.mjs +2 -1
- package/dist/integrations/canopyx/pdf-number.d.ts +1 -1
- package/dist/integrations/canopyx/pdf-number.js +89 -35
- package/dist/integrations/canopyx/pivot.d.ts +1 -1
- package/dist/integrations/canopyx/pivot.js +4 -0
- package/dist/integrations/canopyx/source.js +2 -2
- package/dist/integrations/canopyx/types.d.ts +1 -0
- package/dist/integrations/datatables/snapshot.js +51 -6
- package/package.json +6 -2
|
@@ -11663,6 +11663,31 @@ function safeOptions(options) {
|
|
|
11663
11663
|
value(result);
|
|
11664
11664
|
} } : {}) };
|
|
11665
11665
|
}
|
|
11666
|
+
/** Buttons builds the heading structures before customizeData runs; carry changed leaf labels into their bottom row. */
|
|
11667
|
+
function customizedStructure(structure, before, after, kind) {
|
|
11668
|
+
if (!before || !Array.isArray(structure) || !structure.length)
|
|
11669
|
+
return structure;
|
|
11670
|
+
const changed = after.map((label, index) => !Object.is(label, before[index]));
|
|
11671
|
+
if (!changed.some(Boolean))
|
|
11672
|
+
return structure;
|
|
11673
|
+
return structure.map((row, level) => !Array.isArray(row) ? row : row.map((cell, index) => {
|
|
11674
|
+
if (cell == null || level + (Number(member(cell, "rowspan")) || 1) !== structure.length)
|
|
11675
|
+
return cell;
|
|
11676
|
+
const span = Number(member(cell, "colspan")) || 1;
|
|
11677
|
+
if (!changed.slice(index, index + span).some(Boolean))
|
|
11678
|
+
return cell;
|
|
11679
|
+
if (span !== 1)
|
|
11680
|
+
throw new TypeError("customizeData cannot change one column of a spanning " + kind + " cell.");
|
|
11681
|
+
return { ...cell, title: after[index] };
|
|
11682
|
+
}));
|
|
11683
|
+
}
|
|
11684
|
+
/** A customizeData reorder is visible as a permutation of distinct leaf labels; map each output column to its source. */
|
|
11685
|
+
function reorderedSources(before, after) {
|
|
11686
|
+
if (!before || before.length !== after.length || new Set(before).size !== before.length)
|
|
11687
|
+
return undefined;
|
|
11688
|
+
const sources = after.map(label => before.indexOf(label));
|
|
11689
|
+
return sources.every(source => source >= 0) && new Set(sources).size === sources.length && sources.some((source, index) => source !== index) ? sources : undefined;
|
|
11690
|
+
}
|
|
11666
11691
|
/** Capture export scope and headings, then produce values in bounded batches using public DataTables APIs. */
|
|
11667
11692
|
function createDataTablesExport(host, table, options = {}) {
|
|
11668
11693
|
return captureDataTablesExport(host, table, options);
|
|
@@ -11714,16 +11739,35 @@ function captureDataTablesExport(host, table, options = {}, omitted) {
|
|
|
11714
11739
|
throw new RangeError("A selected row exceeds maxBatchCells.");
|
|
11715
11740
|
if (new Set(rowIndexes).size !== rowIndexes.length || new Set(columnIndexes).size !== columnIndexes.length)
|
|
11716
11741
|
throw new TypeError("DataTables export indexes must be unique.");
|
|
11717
|
-
|
|
11742
|
+
let before;
|
|
11743
|
+
const customize = config.customizeData;
|
|
11744
|
+
const data = call(table.buttons, "exportData", { ...config, modifier, ...(mode === "batched" ? { rows: [] } : {}),
|
|
11745
|
+
...(customize ? { customizeData: (input) => {
|
|
11746
|
+
const footer = member(input, "footer");
|
|
11747
|
+
before = { header: [...array(member(input, "header"))], footer: footer == null ? undefined : [...array(footer)] };
|
|
11748
|
+
customize(input);
|
|
11749
|
+
} } : {}) });
|
|
11718
11750
|
const leaf = array(member(data, "header"));
|
|
11719
11751
|
if (leaf.length !== columnIndexes.length)
|
|
11720
11752
|
throw new TypeError("Export header must match the selected columns.");
|
|
11721
|
-
|
|
11753
|
+
// Only structured output reaches the source structures' bottom row; leaf and grouped headings take the leaf labels.
|
|
11754
|
+
const structured = headingMode === "structured" && !omitted?.header;
|
|
11755
|
+
const sourceStructure = omitted?.header ? undefined : member(data, "headerStructure");
|
|
11756
|
+
const heading = headings(structured ? customizedStructure(sourceStructure, before?.header, leaf, "header") : sourceStructure, leaf, omitted?.header ? "leaf" : headingMode);
|
|
11757
|
+
const reordered = reorderedSources(before?.header, leaf);
|
|
11758
|
+
if (reordered && heading.rows.length > 1)
|
|
11759
|
+
throw new TypeError("customizeData cannot reorder columns under grouped headings; select headings: 'leaf' or reorder the table's columns.");
|
|
11760
|
+
// Column options and keys follow each column to its new position after a customizeData reorder. Any other heading
|
|
11761
|
+
// change (a rename, or a reorder with a rename) leaves no reliable source mapping for column options.
|
|
11762
|
+
if (before && !reordered && before.header.some((label, index) => !Object.is(label, leaf[index])) &&
|
|
11763
|
+
columnIndexes.some(index => options.columnOptions?.[index] !== undefined))
|
|
11764
|
+
throw new TypeError("customizeData changed column headings, so columnOptions cannot be matched to columns; rename columns with columnOptions header instead.");
|
|
11765
|
+
const sourceColumns = reordered ? reordered.map(source => columnIndexes[source]) : columnIndexes;
|
|
11722
11766
|
for (const index of columnIndexes)
|
|
11723
11767
|
if (member(options.columnOptions?.[index], "value") !== undefined)
|
|
11724
11768
|
throw new TypeError("DataTables columnOptions describes columns; resolve values with project.");
|
|
11725
11769
|
const columns = Object.freeze(copyColumns(leaf.map((label, index) => ({
|
|
11726
|
-
header: text(label), key: "dt:" +
|
|
11770
|
+
header: text(label), key: "dt:" + sourceColumns[index], ...options.columnOptions?.[sourceColumns[index]],
|
|
11727
11771
|
...(heading.groups[index].length ? { groups: Object.freeze(heading.groups[index]) } : {})
|
|
11728
11772
|
}))).map(column => Object.freeze(column)));
|
|
11729
11773
|
// Explicit heading overrides also apply to CSV's leaf heading.
|
|
@@ -11732,8 +11776,8 @@ function captureDataTablesExport(host, table, options = {}, omitted) {
|
|
|
11732
11776
|
const headerStructure = heading.structure?.map((row, level) => Object.freeze(row.map((cell, index) => {
|
|
11733
11777
|
if (!cell || level + (cell.rowSpan ?? 1) !== heading.structure.length)
|
|
11734
11778
|
return cell;
|
|
11735
|
-
const override = options.columnOptions?.[
|
|
11736
|
-
if ((cell.columnSpan ?? 1) > 1 &&
|
|
11779
|
+
const override = options.columnOptions?.[sourceColumns[index]]?.header;
|
|
11780
|
+
if ((cell.columnSpan ?? 1) > 1 && sourceColumns.slice(index, index + (cell.columnSpan ?? 1)).some(c => options.columnOptions?.[c]?.header !== undefined))
|
|
11737
11781
|
throw new TypeError("A spanning leaf heading cannot have per-column header overrides.");
|
|
11738
11782
|
return override === undefined ? cell : Object.freeze({ ...cell, value: override });
|
|
11739
11783
|
})));
|
|
@@ -11745,7 +11789,8 @@ function captureDataTablesExport(host, table, options = {}, omitted) {
|
|
|
11745
11789
|
const footer = rawFooter == null ? undefined : array(rawFooter).map(value);
|
|
11746
11790
|
if (footer && footer.length !== columns.length)
|
|
11747
11791
|
throw new TypeError("Export footer must match the selected columns.");
|
|
11748
|
-
const footerHeading = footer && Array.isArray(footerStructure) && footerStructure.length
|
|
11792
|
+
const footerHeading = footer && Array.isArray(footerStructure) && footerStructure.length
|
|
11793
|
+
? headings(headingMode === "structured" ? customizedStructure(footerStructure, before?.footer, array(rawFooter), "footer") : footerStructure, footer, headingMode === "structured" ? "structured" : "grouped") : undefined;
|
|
11749
11794
|
const body = mode === "compatibility" ? array(member(data, "body")) : undefined;
|
|
11750
11795
|
const count = columns.length ? body?.length ?? rowIndexes.length : 0;
|
|
11751
11796
|
budget.check("maxRows", count);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Generated by OfficeIMO.JavaScript/scripts/bundles.mjs from tsc output. MIT.
|
|
2
|
+
(function(Oe){"use strict";const le=Oe.OfficeIMO||(Oe.OfficeIMO={}),we=Symbol.for("@evotecit/officeimo/modules"),A=le[we]||new Map;le[we]||Object.defineProperty(le,we,{value:A});const te=A.get("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3")??(()=>{function a(r){if(r?.aborted)throw r.reason}function b(r,f){return f?new Promise((h,C)=>{const E=()=>f.removeEventListener("abort",k),k=()=>{E(),C(f.reason)};f.addEventListener("abort",k,{once:!0}),Promise.resolve(r).then(e=>{E(),h(e)},e=>{E(),C(e)}),f.aborted&&k()}):Promise.resolve(r)}async function*i(r,f){a(f);const h=r?.[Symbol.asyncIterator]?.()??r?.[Symbol.iterator]?.();if(!h)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let C=!1,E=!1;try{for(;;){a(f);const k=await b(Promise.resolve(h.next()),f);if(a(f),k.done){C=!0;return}yield k.value}}catch(k){throw E=!0,k}finally{if(!C&&h.return)try{const k=h.return();f?.aborted||E?Promise.resolve(k).catch(()=>{}):await b(Promise.resolve(k),f)}catch(k){if(!f?.aborted&&!E)throw k}}}const l=new WeakMap;function s(r){let f=!1;const h=()=>{if(f)throw new TypeError("A row source can be consumed only once.");f=!0},C={[Symbol.asyncIterator](){return h(),E()}};async function*E(){for await(const k of i(r))yield*k}return l.set(C,(k,e)=>(h(),t(r,k,u=>t(u,k,e)))),C}function c(...r){const f={async*[Symbol.asyncIterator](){for(const h of r)yield*h}};return l.set(f,async(h,C)=>{for(const E of r)await t(E,h,C)}),f}async function t(r,f,h){a(f);const C=l.get(r);if(C)return C(f,h);const E=r?.[Symbol.asyncIterator]?.()??r?.[Symbol.iterator]?.();if(!E)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let k=!1;try{for(;;){a(f);let e=E.next();const u=e;typeof u?.then=="function"&&(e=await b(u,f)),a(f);const _=e;if(_.done){k=!0;return}let D=_.value;typeof D?.then=="function"&&(D=await b(D,f)),a(f);const w=h(D);w!==void 0&&await b(w,f)}}finally{if(!k&&E.return)try{Promise.resolve(E.return()).catch(()=>{})}catch{}}}let p;const n=32;function O(){p=performance.now()+n}function B(){const r=performance.now();return p??=r+n,r>=p}function d(){const r=globalThis.scheduler;return typeof r?.postTask=="function"?r.postTask(()=>{p=performance.now()+n},{priority:"user-visible"}):new Promise(f=>{setTimeout(function(){p=performance.now()+n,f()},0)})}const m=Object.freeze({checkAbort:a,withAbort:b,inputRows:i,rowsFromBatches:s,concatRows:c,consumeRows:t,beginTask:O,taskYieldDue:B,pause:d});return A.set("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3",m),m})(),oe=A.get("d5c945064d81fdd257960f48c421125e106e5f270427d170bb05587dd96a44ea")??(()=>{const a=Symbol.for("@evotecit/officeimo/OfficeIMOError"),b=Symbol.for("@evotecit/officeimo/NotSupportedError");class i extends Error{code;static[Symbol.hasInstance](t){return this!==i?Function.prototype[Symbol.hasInstance].call(this,t):!!t&&typeof t=="object"&&t[a]===!0}constructor(t,p,n){super(p,n),this.code=t,Object.defineProperty(this,a,{value:!0}),this.name="OfficeIMOError"}}class l extends i{feature;static[Symbol.hasInstance](t){return this!==l?Function.prototype[Symbol.hasInstance].call(this,t):!!t&&typeof t=="object"&&t[b]===!0}constructor(t){super("NOT_SUPPORTED",t+" is not supported yet."),this.feature=t,Object.defineProperty(this,b,{value:!0}),this.name="NotSupportedError"}}const s=Object.freeze({OfficeIMOError:i,NotSupportedError:l});return A.set("d5c945064d81fdd257960f48c421125e106e5f270427d170bb05587dd96a44ea",s),s})(),pe=A.get("5337d1e3bd5ae0c1d10a476fcd31540d20337ccf7aa93c7e9e26c2b1a7dab92b")??(()=>{const{checkAbort:a,consumeRows:b,withAbort:i,pause:l,taskYieldDue:s}=te,{OfficeIMOError:c}=oe;async function t(d,m){if(d&&typeof d.getWriter=="function"){const r=d.getWriter();try{return await m({write:f=>r.write(new Uint8Array(f))})}finally{r.releaseLock()}}if(!d||typeof d.write!="function")throw new TypeError("Destination must be a ByteSink or WritableStream.");return m(d)}class p{parts=[];state="open";result;write(m){if(this.state!=="open")throw new c("INVALID_STATE","Byte sink is closed.");this.parts.push(new Uint8Array(m))}toBlob(m="application/octet-stream"){if(this.state==="discarded")throw new c("INVALID_STATE","Byte sink was discarded.");return this.state="closed",this.result||(this.result=new Blob(this.parts,{type:m}),this.parts=[]),this.result.type===m?this.result:new Blob([this.result],{type:m})}takeChunks(){if(this.state!=="open")throw new c("INVALID_STATE","Byte sink is closed.");const m=this.parts;return this.parts=[],this.state="discarded",m}discard(){this.parts=[],this.result=void 0,this.state="discarded"}}class n{sink;signal;chunkSize;text="";encoder=new TextEncoder;constructor(m,r,f=32768){if(this.sink=m,this.signal=r,this.chunkSize=f,!Number.isInteger(f)||f<2)throw new RangeError("Text chunk size must be at least 2.")}append(m){return a(this.signal),this.text+=m,this.text.length>=this.chunkSize||s()}async flush(m=!1){for(a(this.signal);this.text.length;){let r=Math.min(this.text.length,this.chunkSize);if(/[\ud800-\udbff]/.test(this.text[r-1])&&(r<this.text.length||!m)&&r--,!r)break;const f=this.encoder.encode(this.text.slice(0,r));this.text=this.text.slice(r),await i(Promise.resolve(this.sink.write(f)),this.signal),s()&&await l(),a(this.signal)}}async write(m){this.append(m)&&await this.flush()}async close(){await this.flush(!0)}}async function O(d,m,r){await b(d instanceof Uint8Array?[d]:d,r,f=>{if(!(f instanceof Uint8Array))throw new TypeError("Byte sources must yield Uint8Array chunks.");const h=m.write(f);return s()?Promise.resolve(h).then(()=>(a(r),l())):h})}const B=Object.freeze({withDestination:t,BlobByteSink:p,ChunkedTextSink:n,writeBytes:O});return A.set("5337d1e3bd5ae0c1d10a476fcd31540d20337ccf7aa93c7e9e26c2b1a7dab92b",B),B})(),Re=A.get("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f")??(()=>{function a(i,l){if(!i)return;const s=i(l);if(s&&typeof s.then=="function")throw Promise.resolve(s).catch(()=>{}),new TypeError("onProgress must be synchronous.")}const b=Object.freeze({notifyProgress:a});return A.set("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f",b),b})(),ce=A.get("501f5fccaecb27d9e514b74cf64893649e50616692250593d120ca315b510c04")??(()=>{function a(i){if(i===null||typeof i!="object")return!1;try{return!(i instanceof Date)&&!(Symbol.toStringTag in i)&&Object.prototype.toString.call(i)!=="[object Date]"?!1:(Date.prototype.getTime.call(i),!0)}catch{return!1}}const b=Object.freeze({isDate:a});return A.set("501f5fccaecb27d9e514b74cf64893649e50616692250593d120ca315b510c04",b),b})(),Ae=A.get("d363b84eac65064b2e372063af61a4e9e5c576501693c862628297c812ba7832")??(()=>{function a(i){if(!i||typeof i!="object")throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const{target:l,tooltip:s}=i;if(typeof l!="string"||!/^(?:https?:\/\/|mailto:)/i.test(l)||/[\u0000-\u0020\u007f]/.test(l))throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const c=new URL(l);if((c.protocol==="http:"||c.protocol==="https:")&&(!c.hostname||c.username||c.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:c.href,...s===void 0?{}:{tooltip:s}})}const b=Object.freeze({copyExportLink:a});return A.set("d363b84eac65064b2e372063af61a4e9e5c576501693c862628297c812ba7832",b),b})(),fe=A.get("732224f6995c2478cf33a6ed01f3e3d3dcccb159a731d6db9280104bd5040fc5")??(()=>{const{isDate:a}=ce,{copyExportLink:b}=Ae,i=Symbol.for("@evotecit/officeimo/ExportCell");function l(n){if(!n||typeof n!="object"||Array.isArray(n))throw new TypeError("Cell presentation must be an object.");const O={};for(const B of["background","color","numberFormat","bold","italic","wrapText","alignment"]){const d=n[B];if(d!==void 0){if(["bold","italic","wrapText"].includes(B)){if(typeof d!="boolean")throw new TypeError("Cell presentation "+B+" must be boolean.")}else if(typeof d!="string")throw new TypeError("Cell presentation "+B+" must be text.");if(B==="alignment"&&!["left","center","right","fill","justify","distributed"].includes(d))throw new TypeError("Invalid cell presentation alignment.");O[B]=d}}return Object.freeze(O)}class s{value;static[Symbol.hasInstance](O){return!!O&&typeof O=="object"&&O[i]===!0}text;presentation;link;constructor(O,B={}){this.value=O;const{text:d,presentation:m,link:r}=B;if(d!==void 0&&typeof d!="string")throw new TypeError("Display text must be a string.");c(O),this.text=d,this.presentation=m===void 0?void 0:l(m),this.link=r===void 0?void 0:b(r),Object.defineProperty(this,i,{value:!0}),Object.freeze(this)}}function c(n){const O=typeof n;if(!(n==null||O==="string"||O==="number"||O==="boolean"||a(n)))throw typeof n.then=="function"&&Promise.resolve(n).catch(()=>{}),new TypeError("Export values and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}function t(n){n!==null&&typeof n=="object"&&n instanceof s||c(n)}const p=Object.freeze({copyCellPresentation:l,ExportCell:s,assertScalar:c,assertExportValue:t});return A.set("732224f6995c2478cf33a6ed01f3e3d3dcccb159a731d6db9280104bd5040fc5",p),p})(),me=A.get("50b3c10b690ceff693c8c5f809195ba6845b20e60f408e791a750d2ecbd5c669")??(()=>{function a(i,l){const s={...i};for(const c of l){if(Object.hasOwn(s,c))continue;const t=i[c];t!==void 0&&(s[c]=t)}return s}const b=Object.freeze({captureFields:a});return A.set("50b3c10b690ceff693c8c5f809195ba6845b20e60f408e791a750d2ecbd5c669",b),b})(),Ce=A.get("42faf379960e5674a6fdfa8c8fca0bb68bbd74587231248d2524d7004def3671")??(()=>{const{OfficeIMOError:a}=oe,{captureFields:b}=me;class i{cells=0;text=0;reservedCells=0;reservedText=0;limits;constructor(t={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Export limits must be an object.");const p=b(t,["maxRows","maxCells","maxTextCharacters","maxOutputBytes"]);for(const[n,O]of Object.entries(p))if(O!==void 0&&(!Number.isSafeInteger(O)||O<0))throw new RangeError(n+" must be a nonnegative safe integer.");this.limits=Object.freeze(p)}check(t,p){const n=this.limits[t];if(n!==void 0&&p>n)throw new a("RESOURCE_LIMIT",t+" exceeded ("+p+" > "+n+").")}row(t){this.check("maxRows",t)}reserve(t,p){this.check("maxCells",this.cells+this.reservedCells+t),this.check("maxTextCharacters",this.text+this.reservedText+p),this.reservedCells+=t,this.reservedText+=p}release(t,p){this.reservedCells-=t,this.reservedText-=p}cell(t,p){if(p!==void 0&&this.release(1,p),this.limits.maxCells===void 0&&this.limits.maxTextCharacters===void 0)return;this.check("maxCells",this.cells+this.reservedCells+1);const n=typeof t=="string"?t.length:0;this.check("maxTextCharacters",this.text+this.reservedText+n),this.cells++,this.text+=n}}function l(c,t){let p=0;return{write(n){return t.check("maxOutputBytes",p+n.length),p+=n.length,c.write(n)}}}const s=Object.freeze({ExportBudget:i,boundedSink:l});return A.set("42faf379960e5674a6fdfa8c8fca0bb68bbd74587231248d2524d7004def3671",s),s})(),ve=A.get("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc")??(()=>{const{assertExportValue:a}=fe,{checkAbort:b}=te,{isDate:i}=ce,{captureFields:l}=me;function s(n,O,B,d=a){const m=n.some(r=>r.value);return(r,f=0)=>{if(Array.isArray(r)&&!m){const h=r.length;if(h>n.length)throw new RangeError("Row has more values than declared columns.");const C=new Array(h);for(let E=0;E<h;E++){const k=r[E];d(k),C[E]=k}return C}if(!r||typeof r!="object"||i(r))throw new TypeError("A row must be an array or object.");if(Array.isArray(r)&&r.length>n.length&&!n.every(h=>h.value))throw new RangeError("Project every column explicitly when selecting from a wider array row.");return n.map((h,C)=>{if(h.value){b(B);const e={rowIndex:f,columnIndex:C,column:h,...O?{sheetName:O.sheetName,worksheetRow:O.firstDataRow+f}:{}},u=h.value(r,e);return d(u),b(B),u}if(Array.isArray(r)){const e=r[C];return d(e),e}const E=h.key??h.header,k=Object.prototype.hasOwnProperty.call(r,E)?r[E]:void 0;return d(k),k})}}const c=["header","key","value","width","type","format","wrapText","alignment","rowHeader","groups","style","valueFormatter"];function t(n,O=!1){if(!Array.isArray(n))throw new TypeError("Declare the columns in export order.");return n.map(B=>{if(!B||typeof B!="object"&&typeof B!="function")throw new TypeError("Each column needs a string header and an optional string key.");const d=l(B,c);if(!O&&d.style!==void 0)throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");if(typeof d.header!="string"||d.key!==void 0&&typeof d.key!="string")throw new TypeError("Each column needs a string header and an optional string key.");if(d.value!==void 0&&typeof d.value!="function")throw new TypeError("Column value getters must be functions.");if(d.rowHeader!==void 0&&typeof d.rowHeader!="boolean")throw new TypeError("Column rowHeader must be boolean.");if(d.groups!==void 0){if(!Array.isArray(d.groups))throw new TypeError("Column groups must be an array of strings.");const m=Array.from(d.groups);if(m.some(r=>typeof r!="string"))throw new TypeError("Column groups must be an array of strings.");return{...d,groups:Object.freeze(m)}}return d})}const p=Object.freeze({createRowProjector:s,columnOptionFields:c,copyColumns:t});return A.set("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc",p),p})(),Be=A.get("c9fde2c438e186da56f740105fcd41c265fdfdd855a4f1b811d556a02387479b")??(()=>{class a{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 c=s-this.mean;this.mean=this.count===1?s:Number.isFinite(c)?this.mean+c/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 b(l,s={}){const c=l.map(t=>t.key??t.header);for(const[t,p]of Object.entries(s)){if(c.filter(n=>n===t).length!==1)throw new TypeError("Totals need an unambiguous declared column key: "+t);if(!["sum","count","average","min","max"].includes(p))throw new TypeError("Invalid total operation.")}return c.map(t=>new a(Object.prototype.hasOwnProperty.call(s,t)?s[t]:void 0))}const i=Object.freeze({NumericAggregate:a,createTotals:b});return A.set("c9fde2c438e186da56f740105fcd41c265fdfdd855a4f1b811d556a02387479b",i),i})(),Le=A.get("e95bb0e3f342d1379b67a3d541fa808e06361da8460169a6aec152ee7deb69b2")??(()=>{const{ExportCell:a,assertExportValue:b}=fe,{isDate:i}=ce;function l(c){if(b(c),i(c))return new Date(Date.prototype.getTime.call(c));if(c instanceof a){const{value:t,text:p,presentation:n,link:O}=c;return new a(i(t)?new Date(Date.prototype.getTime.call(t)):t,{...p===void 0?{}:{text:p},...n===void 0?{}:{presentation:n},...O===void 0?{}:{link:O}})}return c}const s=Object.freeze({copyExportValue:l});return A.set("e95bb0e3f342d1379b67a3d541fa808e06361da8460169a6aec152ee7deb69b2",s),s})(),Pe=A.get("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a68c0")??(()=>{const{ExportCell:a,assertScalar:b}=fe,{isDate:i}=ce,{checkAbort:l,inputRows:s,pause:c,taskYieldDue:t}=te,{ExportBudget:p}=Ce,{OfficeIMOError:n}=oe,{copyColumns:O,createRowProjector:B}=ve,{createTotals:d}=Be,{copyExportValue:m}=Le,r=new WeakMap;function f(o){if(!o||typeof o!="object"||!r.has(o))throw new TypeError("Create grouped report sources with createGroupedReport.")}function h(o,g){return f(o),{async*[Symbol.asyncIterator](){const S=C(o,g);try{yield*S.events}finally{S.dispose()}}}}function C(o,g){f(o);const S=r.get(o),I=E(S.signal,g);return{signal:I.signal,events:S.events(I.signal),dispose:I.dispose}}function E(o,g){if(!o||!g||o===g)return{signal:o??g,dispose(){}};const S=new AbortController,I=()=>S.abort(o.reason),L=()=>S.abort(g.reason);return o.addEventListener("abort",I,{once:!0}),g.addEventListener("abort",L,{once:!0}),o.aborted?I():g.aborted&&L(),{signal:S.signal,dispose(){o.removeEventListener("abort",I),g.removeEventListener("abort",L)}}}function k(o,g,S){const I=o??g;if(!Number.isSafeInteger(I)||I<0)throw new RangeError(S+" must be a nonnegative safe integer.");return I}function e(o){return o instanceof a?o.value:o}function u(o){if(o==null)return{key:null,id:"null",text:""};if(i(o)){const S=Date.prototype.getTime.call(o);if(!Number.isFinite(S))throw new TypeError("A group key date must be valid.");return{key:new Date(S),id:"date:"+S,text:new Date(S).toISOString()}}if(typeof o=="number"&&!Number.isFinite(o))throw new TypeError("A numeric group key must be finite.");const g=String(o);return{key:o,id:typeof o+":"+g,text:g}}function _(o){return i(o)?new Date(Date.prototype.getTime.call(o)):o}function D(o){return Object.freeze(o.map(g=>g.operation===void 0?null:g.value()))}function w(o,g,S){const I=typeof o=="string"?[o]:Array.isArray(o)?Array.from(o):void 0;if(!I||I.length<1||I.length>4)throw new TypeError("groupBy must declare between one and four grouping levels.");if(S!==void 0&&typeof S!="function")throw new TypeError("groupLabel must be a synchronous function.");if(S&&I.length!==1)throw new TypeError("groupLabel is only available for one grouping level; use descriptor labels for a hierarchy.");const L=new Set;return Object.freeze(I.map(z=>{if(typeof z!="string"&&(!z||typeof z!="object"||Array.isArray(z)))throw new TypeError("A grouping level must name a stable column key or provide a descriptor.");const{key:F,value:V,label:K}=typeof z=="string"?{key:z,value:void 0,label:void 0}:z;if(typeof F!="string"||!F.length||L.has(F))throw new TypeError("Grouping levels need unique, nonempty stable keys.");if(L.add(F),V!==void 0&&typeof V!="function")throw new TypeError("Grouping value getters must be synchronous functions.");if(K!==void 0&&typeof K!="function")throw new TypeError("Grouping labels must be synchronous functions.");if(K&&S)throw new TypeError("Specify either groupLabel or the grouping descriptor label.");const G=g.indexOf(F);if(G>=0&&V!==void 0)throw new TypeError("A declared grouping column reuses its projected value; do not provide another value getter.");if(G<0&&V===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:F,column:G,value:V,label:K??S})}))}function y(o){return Object.freeze(o.map(({group:g})=>Object.freeze({...g,key:_(g.key)})))}function P(o,g,S){if(!o)return S;const I=o(_(g));if(typeof I?.then=="function"&&Promise.resolve(I).catch(()=>{}),typeof I!="string")throw new TypeError("Grouping labels must return synchronous text.");return I}function x(o,g){if(!g||typeof g!="object")throw new TypeError("Grouped report options are required.");const{columns:S,groupBy:I,totals:L,groupLabel:z,maxGroups:F,maxGroupKeyCharacters:V,signal:K,limits:G}=g;if(G!==void 0&&(!G||typeof G!="object"||Array.isArray(G)))throw new TypeError("Grouped source limits must be an object.");if(G!==void 0&&"maxOutputBytes"in G)throw new TypeError("Set maxOutputBytes on the format writer, not the grouped source.");if(!Array.isArray(S)||!S.length)throw new TypeError("A grouped report needs declared columns.");const T=O(S),N=T.map(j=>j.key);if(N.some(j=>typeof j!="string"||j.length===0)||new Set(N).size!==N.length)throw new TypeError("Grouped report columns need unique, nonempty stable keys.");const J=w(I,N,z),Y=Object.freeze({...L}),Q=d(T,Y);for(let j=0;j<T.length;j++)if(Q[j].operation!==void 0&&T[j].type!=="number")throw new TypeError("Grouped numeric totals require a column declared with type:number.");const X=k(F,1e3,"maxGroups"),he=k(V,1e6,"maxGroupKeyCharacters"),Z=new p(G),ge=Object.freeze(T.map(j=>{const{value:q,...re}=j;return Object.freeze(re)}));for(const j of T){Z.cell(j.header);for(const q of j.groups??[])Z.reserve(0,q.length);Object.freeze(j)}let be=!1;const ue=j=>Object.freeze({[Symbol.asyncIterator](){if(be)throw new TypeError("A grouped report source can be consumed only once.");return be=!0,W(j)}}),M=ue(K);async function*W(j){const q=B(T,void 0,j),re=new Set,H=[];let Se=0,se=0,ye=0;for await(const ie of s(o,j)){const de=Array.isArray(ie)?Array.from(ie):ie,Me=q(de,se),ne=[];for(let R=0;R<T.length;R++)ne.push(m(Me[R])??null);l(j);const Ie=J.map((R,U)=>{l(j);const ee=R.column>=0?e(ne[R.column]):R.value(de,Object.freeze({rowIndex:se,level:U,key:R.key}));return b(ee),l(j),u(ee)});Z.row(se+1);for(let R=0;R<ne.length;R++){const U=ne[R],ee=e(U);if(Q[R].operation!==void 0&&ee!=null&&(typeof ee!="number"||!Number.isFinite(ee)))throw new TypeError("Grouped numeric metrics must resolve to finite numbers or null.");Z.cell(ee),U instanceof a&&U.text!==void 0&&Z.reserve(0,U.text.length)}let ae=0;for(;ae<H.length&&H[ae].id===Ie[ae].id;)ae++;const xe=[];for(let R=ae;R<J.length;R++){const U=Ie[R],Ee=((xe.at(-1)??H[R-1])?.group.groupIndex??-1)+":"+U.id;if(re.has(Ee))throw new TypeError("Grouped rows must be contiguous; a closed group key occurred again within the same parent.");if(ye===X)throw new n("RESOURCE_LIMIT","maxGroups exceeded.");const ke=P(J[R].label,U.key,U.text);l(j);const Te=Se+Ee.length+ke.length;if(!Number.isSafeInteger(Te)||Te>he)throw new n("RESOURCE_LIMIT","maxGroupKeyCharacters exceeded.");Z.reserve(0,ke.length),xe.push({id:U.id,group:Object.freeze({groupIndex:ye,key:U.key,label:ke,level:R}),rows:0,aggregates:d(T,Y)}),Se=Te,re.add(Ee),ye++}for(;H.length>ae;){l(j);const R=y(H),U=H.pop();yield Object.freeze({kind:"groupEnd",...R.at(-1),path:R,rows:U.rows,totals:D(U.aggregates)})}for(const R of xe){l(j),H.push(R);const U=y(H);yield Object.freeze({kind:"groupStart",...U.at(-1),path:U})}for(let R=0;R<ne.length;R++){const U=e(ne[R]);for(const ee of H)ee.aggregates[R].accept(U);Q[R].accept(U)}for(const R of H)R.rows++;l(j),yield Object.freeze({kind:"row",values:Object.freeze(ne),rowIndex:se,groupIndex:H.at(-1).group.groupIndex,path:y(H)}),se++,t()&&(await c(),l(j))}for(l(j);H.length;){l(j);const ie=y(H),de=H.pop();yield Object.freeze({kind:"groupEnd",...ie.at(-1),path:ie,rows:de.rows,totals:D(de.aggregates)})}l(j),yield Object.freeze({kind:"complete",rows:se,groups:ye,totals:D(Q)})}const $=Object.freeze({columns:ge,groupBy:Object.freeze(J.map(j=>j.key)),totals:Y,events:M});return r.set($,{signal:K,events:ue}),$}const v=Object.freeze({assertGroupedReportSource:f,groupedReportEvents:h,groupedReportOperation:C,createGroupedReport:x});return A.set("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a68c0",v),v})(),_e=A.get("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00")??(()=>{const{OfficeIMOError:a}=oe;function b(){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 i(s,c){if(!(s instanceof Blob)||typeof c!="string"||!c)throw new TypeError("A Blob and file name are required.");if(typeof document>"u"||typeof URL.createObjectURL!="function")throw new a("PLATFORM_UNAVAILABLE","saveBlob requires a browser document and object URLs.");const t=URL.createObjectURL(s),p=document.createElement("a");try{p.href=t,p.download=c,document.body.append(p),p.click()}finally{p.remove(),setTimeout(()=>URL.revokeObjectURL(t),3e4)}}const l=Object.freeze({OfficeIMOError:oe.OfficeIMOError,NotSupportedError:oe.NotSupportedError,BlobByteSink:pe.BlobByteSink,ChunkedTextSink:pe.ChunkedTextSink,writeBytes:pe.writeBytes,ExportCell:fe.ExportCell,createGroupedReport:Pe.createGroupedReport,checkAbort:te.checkAbort,withAbort:te.withAbort,inputRows:te.inputRows,pause:te.pause,detectFeatures:b,saveBlob:i});return A.set("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00",l),l})(),je=A.get("3aeb365cb54a2f47af0ef0db0c06b8eab1c49f3bb740e70535ee0115d45ce698")??(()=>{const{ExportCell:a,NotSupportedError:b,OfficeIMOError:i}=_e,{assertExportValue:l,assertScalar:s,copyCellPresentation:c}=fe,{copyExportLink:t}=Ae,{isDate:p}=ce,n="@evotecit/officeimo/worker-export/1";function O(e){if(!e||typeof e!="object")return;const u=e;return u.protocol===n&&typeof u.job=="string"&&typeof u.kind=="string"?u:void 0}function B(e){const u={batchRows:e.batchRows??64,maxBatchCells:e.maxBatchCells??65536,maxBatchCharacters:e.maxBatchCharacters??1e6,maxChunkBytes:e.maxChunkBytes??65536,maxSetupBytes:e.maxSetupBytes??16777216,maxSetupNodes:e.maxSetupNodes??1e5};for(const[_,D]of Object.entries(u))if(!Number.isSafeInteger(D)||D<1)throw new RangeError(_+" must be a positive safe integer.");return Object.freeze(u)}function d(e,u){let _=0,D=0;const w=new Set;function y(x=0){if(D+=x,D>u.maxSetupBytes||++_>u.maxSetupNodes)throw new i("RESOURCE_LIMIT","Worker configuration exceeds its message budget.")}function P(x,v){if(v>32)throw new RangeError("Worker configuration nesting exceeds 32 levels.");if(y(typeof x=="string"?x.length*2:0),x==null||["string","number","boolean"].includes(typeof x))return x;if(p(x))return y(8),new Date(x.getTime());if(ArrayBuffer.isView(x)&&Object.prototype.toString.call(x)==="[object Uint8Array]")return y(x.byteLength),new Uint8Array(x);if(typeof x!="object")throw new TypeError("Worker configuration requires portable data without functions or symbols.");if(w.has(x))throw new TypeError("Worker configuration cannot contain cycles.");const o=Object.getPrototypeOf(x),g=o==null?void 0:Object.getOwnPropertyDescriptor(o,"constructor")?.value,S=o===null||Object.getPrototypeOf(o)===null&&typeof g=="function"&&Function.prototype.toString.call(g)===Function.prototype.toString.call(Object);if(!Array.isArray(x)&&!S)throw new TypeError("Worker configuration supports plain records, arrays, Dates and Uint8Array bytes; reconstruct font instances in the worker.");w.add(x);try{if(Array.isArray(x)){if(x.length>u.maxSetupNodes-_)throw new i("RESOURCE_LIMIT","Worker configuration exceeds its message budget.");const L=[];for(let z=0;z<x.length;z++){const F=Object.getOwnPropertyDescriptor(x,String(z));if(F&&!Object.prototype.hasOwnProperty.call(F,"value"))throw new TypeError("Worker configuration cannot contain accessors.");L.push(P(F?.value,v+1))}return L}const I={};for(const L of Reflect.ownKeys(x)){if(typeof L!="string")throw new TypeError("Worker configuration keys must be strings.");const z=Object.getOwnPropertyDescriptor(x,L);if(z.enumerable){if(!Object.prototype.hasOwnProperty.call(z,"value"))throw new TypeError("Worker configuration cannot contain accessors.");y(L.length*2),Object.defineProperty(I,L,{value:P(z.value,v+1),enumerable:!0,configurable:!0,writable:!0})}}return I}finally{w.delete(x)}}return P(e,0)}function m(e){if(!Array.isArray(e))throw new TypeError("Worker export rows must be projected arrays.");let u=0;const _=w=>(typeof w=="string"&&(u+=w.length),p(w)?new Date(w.getTime()):w);return{cells:e.map(w=>{if(l(w),!(w instanceof a))return{value:_(w)};const y=w.value,P=w.text,x=w.presentation,v=w.link;if(s(y),P!==void 0&&typeof P!="string")throw new TypeError("Display text must be a string.");const o={...P===void 0?{}:{text:P},...x===void 0?{}:{presentation:c(x)},...v===void 0?{}:{link:t(v)}};u+=P?.length??0;for(const g of Object.values(o.presentation??{}))typeof g=="string"&&(u+=g.length);return u+=(o.link?.target.length??0)+(o.link?.tooltip?.length??0),{value:_(y),options:o}}),characters:u}}function r(e,u){if(!Array.isArray(e)||e.length>u.batchRows)throw new TypeError("Invalid worker row batch.");let _=0,D=0;return e.map(w=>{if(!Array.isArray(w))throw new TypeError("Invalid worker row.");if(_+w.length>u.maxBatchCells)throw new i("RESOURCE_LIMIT","Worker row batch exceeds its message budget.");const y=w.map(x=>{if(!x||typeof x!="object")throw new TypeError("Invalid worker cell.");const v=x.options===void 0?x.value:new a(x.value,x.options);return l(v),v}),P=m(y);if(_+=w.length,D+=P.characters,_>u.maxBatchCells||D>u.maxBatchCharacters)throw new i("RESOURCE_LIMIT","Worker row batch exceeds its message budget.");return y})}function f(e,u){if(!e||!["rows","complete"].includes(e.phase)||!Number.isSafeInteger(e.rows)||e.rows<0)throw new TypeError("Invalid worker progress.");for(const _ of["bytes","sheetRows","totalRows"])if(e[_]!==void 0&&(!Number.isSafeInteger(e[_])||e[_]<0))throw new TypeError("Invalid worker progress count.");if(e.sheetName!==void 0&&(typeof e.sheetName!="string"||e.sheetName.length>u.maxBatchCharacters))throw new TypeError("Invalid or oversized worker sheet name.");return{phase:e.phase,rows:e.rows,...e.bytes===void 0?{}:{bytes:e.bytes},...e.sheetRows===void 0?{}:{sheetRows:e.sheetRows},...e.totalRows===void 0?{}:{totalRows:e.totalRows},...e.sheetName===void 0?{}:{sheetName:e.sheetName}}}function h(e){return{name:e instanceof Error?e.name:"Error",message:e instanceof Error?e.message:String(e),...e instanceof i?{code:e.code}:{},...e instanceof b?{feature:e.feature}:{}}}function C(e){if(!e||typeof e.message!="string")return new Error("Worker export failed.");const u=e.code==="NOT_SUPPORTED"&&typeof e.feature=="string"?new b(e.feature):e.code===void 0?new Error(e.message):new i(e.code,e.message);return u.message=e.message,typeof e.name=="string"&&(u.name=e.name),u}function E(e){if(!e||[e.rows,e.columns,e.bytes].some(u=>!Number.isSafeInteger(u)||u<0))throw new TypeError("Invalid worker export result.");return{rows:e.rows,columns:e.columns,bytes:e.bytes}}const k=Object.freeze({protocol:n,message:O,bounds:B,captureInput:d,captureRow:m,restoreRows:r,captureProgress:f,wireError:h,restoreError:C,result:E});return A.set("3aeb365cb54a2f47af0ef0db0c06b8eab1c49f3bb740e70535ee0115d45ce698",k),k})(),De=A.get("5eb1b2f44c2625f90d0da30bfaacdba77d42da043ff12996de9c650d4ea249fe")??(()=>{const{checkAbort:a,inputRows:b,withAbort:i}=te,{withDestination:l}=pe,{notifyProgress:s}=Re,{OfficeIMOError:c}=oe,{bounds:t,captureInput:p,captureProgress:n,captureRow:O,message:B,protocol:d,restoreError:m,result:r,wireError:f}=je,{captureFields:h}=me,C=new WeakSet;let E=0;async function k(u,_,D,w={}){const y=h(w,["input","signal","onProgress","batchRows","maxBatchCells","maxBatchCharacters","maxChunkBytes","maxSetupBytes","maxSetupNodes"]),P=y.signal,x=y.onProgress;a(P);const v=t(y),o=p(y.input,v);if(C.has(u))throw new c("INVALID_STATE","A worker endpoint already has an active export.");C.add(u);try{return await l(D,g=>new Promise((S,I)=>{const L=new AbortController,z="export-"+ ++E,F=b(_,L.signal);let V=!1,K=!1,G=!1,T=!1,N=0,J;const Y=M=>u.postMessage({protocol:d,job:z,...M});function Q(){u.removeEventListener("message",ue),u.removeEventListener("error",Z),u.removeEventListener("messageerror",Z),P?.removeEventListener("abort",he),T||F.return(void 0).catch(()=>{}),J=void 0}function X(M){if(!V){V=!0,L.abort(M);try{Y({kind:"cancel",error:f(M)})}catch{}Q(),I(M)}}const he=()=>{try{a(P)}catch(M){X(M)}},Z=M=>X(new Error(M.message||"Worker messaging failed."));async function ge(M){if(K)throw new c("INVALID_STATE","Only one worker row request may be pending.");K=!0;try{const W=[];let $=0,j=0;for(;W.length<v.batchRows&&!T;){let q=J;if(J=void 0,!q){const re=await i(F.next(),L.signal);if(V)return;if(re.done){T=!0;break}if(!Array.isArray(re.value)||re.value.length>v.maxBatchCells)throw new c("RESOURCE_LIMIT","A worker row exceeds its message cell budget.");q=O(re.value)}if(q.cells.length>v.maxBatchCells||q.characters>v.maxBatchCharacters)throw new c("RESOURCE_LIMIT","A worker row exceeds its message budget.");if(W.length&&($+q.cells.length>v.maxBatchCells||j+q.characters>v.maxBatchCharacters)){J=q;break}W.push(q.cells),$+=q.cells.length,j+=q.characters}V||Y({kind:"rows",id:M,rows:W,done:T})}finally{K=!1}}async function be(M){if(G||!(M.bytes instanceof Uint8Array)||M.bytes.length>v.maxChunkBytes)throw new c("INVALID_STATE","Invalid or overlapping worker output chunk.");G=!0;try{await i(Promise.resolve(g.write(M.bytes)),L.signal),V||(N+=M.bytes.length,Y({kind:"ack",id:M.id}))}finally{G=!1}}const ue=M=>{const W=B(M.data);if(!(V||!W||W.job!==z))try{if(W.kind==="complete"){const $=r(W.result);if(G||K||$.bytes!==N)throw new c("INVALID_STATE","Worker completion does not match acknowledged output.");V=!0,Q(),S($)}else if(W.kind==="failed")X(m(W.error));else{if(!Number.isSafeInteger(W.id)||W.id<1)throw new TypeError("Invalid worker request identifier.");if(W.kind==="requestRows")ge(W.id).catch(X);else if(W.kind==="output")be(W).catch(X);else if(W.kind==="progress"){if(!W.progress)throw new TypeError("Invalid worker progress.");s(x,n(W.progress,v)),Y({kind:"ack",id:W.id})}else throw new TypeError("Unexpected worker export message.")}}catch($){X($)}};u.addEventListener("message",ue),u.addEventListener("error",Z),u.addEventListener("messageerror",Z),P?.addEventListener("abort",he,{once:!0});try{u.start?.(),a(P),Y({kind:"start",input:o,bounds:v})}catch(M){X(M)}}))}finally{C.delete(u)}}const e=Object.freeze({executeWorkerExport:k});return A.set("5eb1b2f44c2625f90d0da30bfaacdba77d42da043ff12996de9c650d4ea249fe",e),e})(),ze=A.get("1debadc47480abb9b6d830fe7108967a2b45877aa9ce0e2ae81914f343463ede")??(()=>{const{checkAbort:a,withAbort:b}=te,{OfficeIMOError:i}=oe,{bounds:l,captureInput:s,captureProgress:c,message:t,protocol:p,restoreError:n,restoreRows:O,result:B,wireError:d}=je,m=new WeakSet;function r(h,C){if(m.has(h))throw new i("INVALID_STATE","A worker export handler is already installed.");if(typeof C!="function")throw new TypeError("A worker export operation is required.");m.add(h);let E,k=!1;const e=(w,y)=>h.postMessage({protocol:p,job:w,...y});async function u(w){const y=new AbortController,P=l(w.bounds??{}),x=s(w.input,P),v=new Map;let o=0,g=!1,S=!1,I,L;const z=()=>{for(const T of v.values())T.reject(y.signal.reason);v.clear(),I=void 0};y.signal.addEventListener("abort",z,{once:!0}),E={job:w.job,controller:y,deliver(T){const N=v.get(T.id);N&&(v.delete(T.id),N.resolve(T))}};const F=(T,N={})=>(a(y.signal),new Promise((J,Y)=>{const Q=++o;v.set(Q,{resolve:J,reject:Y});try{e(w.job,{kind:T,id:Q,...N})}catch(X){v.delete(Q),Y(X)}}));function V(T){a(y.signal),I=c(T,P),L||(L=(async()=>{for(;I;){const N=I;I=void 0,await F("progress",{progress:N})}})().finally(()=>{L=void 0}),L.catch(N=>y.abort(N)))}const K={[Symbol.asyncIterator](){if(S)throw new TypeError("Worker rows can be consumed only once.");return S=!0,(async function*(){for(;;){const T=await F("requestRows");if(T.kind!=="rows"||typeof T.done!="boolean")throw new TypeError("Invalid worker row response.");for(const N of O(T.rows,P))a(y.signal),yield N;if(T.done)return}})()}},G={async write(T){if(a(y.signal),g||!(T instanceof Uint8Array))throw new i("INVALID_STATE","Await each worker output write.");g=!0;try{for(let N=0;N<T.length;N+=P.maxChunkBytes)await F("output",{bytes:new Uint8Array(T.subarray(N,Math.min(T.length,N+P.maxChunkBytes)))})}finally{g=!1}}};try{const T=B(await b(C({input:x,rows:K,sink:G,signal:y.signal,onProgress:V}),y.signal));if(L&&await b(L,y.signal),v.size)throw new i("INVALID_STATE","Await worker row and output operations before completing.");e(w.job,{kind:"complete",result:T})}catch(T){y.abort(T);try{e(w.job,{kind:"failed",error:d(T)})}catch{}}finally{y.signal.removeEventListener("abort",z),z(),E=void 0}}const _=w=>{const y=t(w.data);if(!(!y||k))if(y.kind==="start"){if(E){e(y.job,{kind:"failed",error:d(new i("INVALID_STATE","The worker already has an active export."))});return}u(y).catch(P=>{try{e(y.job,{kind:"failed",error:d(P)})}catch{}})}else y.job===E?.job&&(y.kind==="cancel"?E.controller.abort(n(y.error)):E.deliver(y))},D=w=>E?.controller.abort(new Error(w.message||"Worker messaging failed."));return h.addEventListener("message",_),h.addEventListener("error",D),h.addEventListener("messageerror",D),h.start?.(),{dispose(w=new DOMException("Worker export handler disposed.","AbortError")){k||(k=!0,E?.controller.abort(w),h.removeEventListener("message",_),h.removeEventListener("error",D),h.removeEventListener("messageerror",D),m.delete(h))}}}const f=Object.freeze({handleWorkerExports:r});return A.set("1debadc47480abb9b6d830fe7108967a2b45877aa9ce0e2ae81914f343463ede",f),f})(),Ne=A.get("85e009dee350af7c8594b36740a1100f30104a08ab6b887240ef3113714be29e")??(()=>{const a=Object.freeze({executeWorkerExport:De.executeWorkerExport,handleWorkerExports:ze.handleWorkerExports});return A.set("85e009dee350af7c8594b36740a1100f30104a08ab6b887240ef3113714be29e",a),a})();Object.assign(le,Ne)})(globalThis);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Generated by OfficeIMO.JavaScript/scripts/bundles.mjs from tsc output. MIT.
|
|
2
|
+
const te=(()=>{function u(r){if(r?.aborted)throw r.reason}function k(r,l){return l?new Promise((d,R)=>{const x=()=>l.removeEventListener("abort",O),O=()=>{x(),R(l.reason)};l.addEventListener("abort",O,{once:!0}),Promise.resolve(r).then(e=>{x(),d(e)},e=>{x(),R(e)}),l.aborted&&O()}):Promise.resolve(r)}async function*s(r,l){u(l);const d=r?.[Symbol.asyncIterator]?.()??r?.[Symbol.iterator]?.();if(!d)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let R=!1,x=!1;try{for(;;){u(l);const O=await k(Promise.resolve(d.next()),l);if(u(l),O.done){R=!0;return}yield O.value}}catch(O){throw x=!0,O}finally{if(!R&&d.return)try{const O=d.return();l?.aborted||x?Promise.resolve(O).catch(()=>{}):await k(Promise.resolve(O),l)}catch(O){if(!l?.aborted&&!x)throw O}}}const p=new WeakMap;function a(r){let l=!1;const d=()=>{if(l)throw new TypeError("A row source can be consumed only once.");l=!0},R={[Symbol.asyncIterator](){return d(),x()}};async function*x(){for await(const O of s(r))yield*O}return p.set(R,(O,e)=>(d(),t(r,O,c=>t(c,O,e)))),R}function i(...r){const l={async*[Symbol.asyncIterator](){for(const d of r)yield*d}};return p.set(l,async(d,R)=>{for(const x of r)await t(x,d,R)}),l}async function t(r,l,d){u(l);const R=p.get(r);if(R)return R(l,d);const x=r?.[Symbol.asyncIterator]?.()??r?.[Symbol.iterator]?.();if(!x)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let O=!1;try{for(;;){u(l);let e=x.next();const c=e;typeof c?.then=="function"&&(e=await k(c,l)),u(l);const L=e;if(L.done){O=!0;return}let P=L.value;typeof P?.then=="function"&&(P=await k(P,l)),u(l);const w=d(P);w!==void 0&&await k(w,l)}}finally{if(!O&&x.return)try{Promise.resolve(x.return()).catch(()=>{})}catch{}}}let h;const n=32;function T(){h=performance.now()+n}function B(){const r=performance.now();return h??=r+n,r>=h}function f(){const r=globalThis.scheduler;return typeof r?.postTask=="function"?r.postTask(()=>{h=performance.now()+n},{priority:"user-visible"}):new Promise(l=>{setTimeout(function(){h=performance.now()+n,l()},0)})}return Object.freeze({checkAbort:u,withAbort:k,inputRows:s,rowsFromBatches:a,concatRows:i,consumeRows:t,beginTask:T,taskYieldDue:B,pause:f})})(),re=(()=>{const u=Symbol.for("@evotecit/officeimo/OfficeIMOError"),k=Symbol.for("@evotecit/officeimo/NotSupportedError");class s extends Error{code;static[Symbol.hasInstance](t){return this!==s?Function.prototype[Symbol.hasInstance].call(this,t):!!t&&typeof t=="object"&&t[u]===!0}constructor(t,h,n){super(h,n),this.code=t,Object.defineProperty(this,u,{value:!0}),this.name="OfficeIMOError"}}class p extends s{feature;static[Symbol.hasInstance](t){return this!==p?Function.prototype[Symbol.hasInstance].call(this,t):!!t&&typeof t=="object"&&t[k]===!0}constructor(t){super("NOT_SUPPORTED",t+" is not supported yet."),this.feature=t,Object.defineProperty(this,k,{value:!0}),this.name="NotSupportedError"}}return Object.freeze({OfficeIMOError:s,NotSupportedError:p})})(),he=(()=>{const{checkAbort:u,consumeRows:k,withAbort:s,pause:p,taskYieldDue:a}=te,{OfficeIMOError:i}=re;async function t(f,g){if(f&&typeof f.getWriter=="function"){const r=f.getWriter();try{return await g({write:l=>r.write(new Uint8Array(l))})}finally{r.releaseLock()}}if(!f||typeof f.write!="function")throw new TypeError("Destination must be a ByteSink or WritableStream.");return g(f)}class h{parts=[];state="open";result;write(g){if(this.state!=="open")throw new i("INVALID_STATE","Byte sink is closed.");this.parts.push(new Uint8Array(g))}toBlob(g="application/octet-stream"){if(this.state==="discarded")throw new i("INVALID_STATE","Byte sink was discarded.");return this.state="closed",this.result||(this.result=new Blob(this.parts,{type:g}),this.parts=[]),this.result.type===g?this.result:new Blob([this.result],{type:g})}takeChunks(){if(this.state!=="open")throw new i("INVALID_STATE","Byte sink is closed.");const g=this.parts;return this.parts=[],this.state="discarded",g}discard(){this.parts=[],this.result=void 0,this.state="discarded"}}class n{sink;signal;chunkSize;text="";encoder=new TextEncoder;constructor(g,r,l=32768){if(this.sink=g,this.signal=r,this.chunkSize=l,!Number.isInteger(l)||l<2)throw new RangeError("Text chunk size must be at least 2.")}append(g){return u(this.signal),this.text+=g,this.text.length>=this.chunkSize||a()}async flush(g=!1){for(u(this.signal);this.text.length;){let r=Math.min(this.text.length,this.chunkSize);if(/[\ud800-\udbff]/.test(this.text[r-1])&&(r<this.text.length||!g)&&r--,!r)break;const l=this.encoder.encode(this.text.slice(0,r));this.text=this.text.slice(r),await s(Promise.resolve(this.sink.write(l)),this.signal),a()&&await p(),u(this.signal)}}async write(g){this.append(g)&&await this.flush()}async close(){await this.flush(!0)}}async function T(f,g,r){await k(f instanceof Uint8Array?[f]:f,r,l=>{if(!(l instanceof Uint8Array))throw new TypeError("Byte sources must yield Uint8Array chunks.");const d=g.write(l);return a()?Promise.resolve(d).then(()=>(u(r),p())):d})}return Object.freeze({withDestination:t,BlobByteSink:h,ChunkedTextSink:n,writeBytes:T})})(),je=(()=>{function u(s,p){if(!s)return;const a=s(p);if(a&&typeof a.then=="function")throw Promise.resolve(a).catch(()=>{}),new TypeError("onProgress must be synchronous.")}return Object.freeze({notifyProgress:u})})(),ue=(()=>{function u(s){if(s===null||typeof s!="object")return!1;try{return!(s instanceof Date)&&!(Symbol.toStringTag in s)&&Object.prototype.toString.call(s)!=="[object Date]"?!1:(Date.prototype.getTime.call(s),!0)}catch{return!1}}return Object.freeze({isDate:u})})(),Te=(()=>{function u(s){if(!s||typeof s!="object")throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const{target:p,tooltip:a}=s;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 i=new URL(p);if((i.protocol==="http:"||i.protocol==="https:")&&(!i.hostname||i.username||i.password))throw new TypeError("Hyperlink HTTP targets need a host and must not contain credentials.");if(a!==void 0&&typeof a!="string")throw new TypeError("Hyperlink tooltip must be text.");return Object.freeze({target:i.href,...a===void 0?{}:{tooltip:a}})}return Object.freeze({copyExportLink:u})})(),fe=(()=>{const{isDate:u}=ue,{copyExportLink:k}=Te,s=Symbol.for("@evotecit/officeimo/ExportCell");function p(n){if(!n||typeof n!="object"||Array.isArray(n))throw new TypeError("Cell presentation must be an object.");const T={};for(const B of["background","color","numberFormat","bold","italic","wrapText","alignment"]){const f=n[B];if(f!==void 0){if(["bold","italic","wrapText"].includes(B)){if(typeof f!="boolean")throw new TypeError("Cell presentation "+B+" must be boolean.")}else if(typeof f!="string")throw new TypeError("Cell presentation "+B+" must be text.");if(B==="alignment"&&!["left","center","right","fill","justify","distributed"].includes(f))throw new TypeError("Invalid cell presentation alignment.");T[B]=f}}return Object.freeze(T)}class a{value;static[Symbol.hasInstance](T){return!!T&&typeof T=="object"&&T[s]===!0}text;presentation;link;constructor(T,B={}){this.value=T;const{text:f,presentation:g,link:r}=B;if(f!==void 0&&typeof f!="string")throw new TypeError("Display text must be a string.");i(T),this.text=f,this.presentation=g===void 0?void 0:p(g),this.link=r===void 0?void 0:k(r),Object.defineProperty(this,s,{value:!0}),Object.freeze(this)}}function i(n){const T=typeof n;if(!(n==null||T==="string"||T==="number"||T==="boolean"||u(n)))throw typeof n.then=="function"&&Promise.resolve(n).catch(()=>{}),new TypeError("Export values and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}function t(n){n!==null&&typeof n=="object"&&n instanceof a||i(n)}return Object.freeze({copyCellPresentation:p,ExportCell:a,assertScalar:i,assertExportValue:t})})(),xe=(()=>{function u(s,p){const a={...s};for(const i of p){if(Object.hasOwn(a,i))continue;const t=s[i];t!==void 0&&(a[i]=t)}return a}return Object.freeze({captureFields:u})})(),Se=(()=>{const{OfficeIMOError:u}=re,{captureFields:k}=xe;class s{cells=0;text=0;reservedCells=0;reservedText=0;limits;constructor(t={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Export limits must be an object.");const h=k(t,["maxRows","maxCells","maxTextCharacters","maxOutputBytes"]);for(const[n,T]of Object.entries(h))if(T!==void 0&&(!Number.isSafeInteger(T)||T<0))throw new RangeError(n+" must be a nonnegative safe integer.");this.limits=Object.freeze(h)}check(t,h){const n=this.limits[t];if(n!==void 0&&h>n)throw new u("RESOURCE_LIMIT",t+" exceeded ("+h+" > "+n+").")}row(t){this.check("maxRows",t)}reserve(t,h){this.check("maxCells",this.cells+this.reservedCells+t),this.check("maxTextCharacters",this.text+this.reservedText+h),this.reservedCells+=t,this.reservedText+=h}release(t,h){this.reservedCells-=t,this.reservedText-=h}cell(t,h){if(h!==void 0&&this.release(1,h),this.limits.maxCells===void 0&&this.limits.maxTextCharacters===void 0)return;this.check("maxCells",this.cells+this.reservedCells+1);const n=typeof t=="string"?t.length:0;this.check("maxTextCharacters",this.text+this.reservedText+n),this.cells++,this.text+=n}}function p(i,t){let h=0;return{write(n){return t.check("maxOutputBytes",h+n.length),h+=n.length,i.write(n)}}}return Object.freeze({ExportBudget:s,boundedSink:p})})(),Ie=(()=>{const{assertExportValue:u}=fe,{checkAbort:k}=te,{isDate:s}=ue,{captureFields:p}=xe;function a(n,T,B,f=u){const g=n.some(r=>r.value);return(r,l=0)=>{if(Array.isArray(r)&&!g){const d=r.length;if(d>n.length)throw new RangeError("Row has more values than declared columns.");const R=new Array(d);for(let x=0;x<d;x++){const O=r[x];f(O),R[x]=O}return R}if(!r||typeof r!="object"||s(r))throw new TypeError("A row must be an array or object.");if(Array.isArray(r)&&r.length>n.length&&!n.every(d=>d.value))throw new RangeError("Project every column explicitly when selecting from a wider array row.");return n.map((d,R)=>{if(d.value){k(B);const e={rowIndex:l,columnIndex:R,column:d,...T?{sheetName:T.sheetName,worksheetRow:T.firstDataRow+l}:{}},c=d.value(r,e);return f(c),k(B),c}if(Array.isArray(r)){const e=r[R];return f(e),e}const x=d.key??d.header,O=Object.prototype.hasOwnProperty.call(r,x)?r[x]:void 0;return f(O),O})}}const i=["header","key","value","width","type","format","wrapText","alignment","rowHeader","groups","style","valueFormatter"];function t(n,T=!1){if(!Array.isArray(n))throw new TypeError("Declare the columns in export order.");return n.map(B=>{if(!B||typeof B!="object"&&typeof B!="function")throw new TypeError("Each column needs a string header and an optional string key.");const f=p(B,i);if(!T&&f.style!==void 0)throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");if(typeof f.header!="string"||f.key!==void 0&&typeof f.key!="string")throw new TypeError("Each column needs a string header and an optional string key.");if(f.value!==void 0&&typeof f.value!="function")throw new TypeError("Column value getters must be functions.");if(f.rowHeader!==void 0&&typeof f.rowHeader!="boolean")throw new TypeError("Column rowHeader must be boolean.");if(f.groups!==void 0){if(!Array.isArray(f.groups))throw new TypeError("Column groups must be an array of strings.");const g=Array.from(f.groups);if(g.some(r=>typeof r!="string"))throw new TypeError("Column groups must be an array of strings.");return{...f,groups:Object.freeze(g)}}return f})}return Object.freeze({createRowProjector:a,columnOptionFields:i,copyColumns:t})})(),Re=(()=>{class u{operation;count=0;sum=0;mean=0;min=1/0;max=-1/0;constructor(a){this.operation=a}accept(a){if(!(!this.operation||typeof a!="number"||!Number.isFinite(a)))if(this.count++,this.operation==="sum"){if(this.sum+=a,!Number.isFinite(this.sum))throw new RangeError("Numeric total exceeds finite number range.")}else if(this.operation==="average"){const i=a-this.mean;this.mean=this.count===1?a:Number.isFinite(i)?this.mean+i/this.count:this.mean*((this.count-1)/this.count)+a/this.count}else this.operation==="min"?this.min=Math.min(this.min,a):this.operation==="max"&&(this.max=Math.max(this.max,a))}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 k(p,a={}){const i=p.map(t=>t.key??t.header);for(const[t,h]of Object.entries(a)){if(i.filter(n=>n===t).length!==1)throw new TypeError("Totals need an unambiguous declared column key: "+t);if(!["sum","count","average","min","max"].includes(h))throw new TypeError("Invalid total operation.")}return i.map(t=>new u(Object.prototype.hasOwnProperty.call(a,t)?a[t]:void 0))}return Object.freeze({NumericAggregate:u,createTotals:k})})(),Ce=(()=>{const{ExportCell:u,assertExportValue:k}=fe,{isDate:s}=ue;function p(i){if(k(i),s(i))return new Date(Date.prototype.getTime.call(i));if(i instanceof u){const{value:t,text:h,presentation:n,link:T}=i;return new u(s(t)?new Date(Date.prototype.getTime.call(t)):t,{...h===void 0?{}:{text:h},...n===void 0?{}:{presentation:n},...T===void 0?{}:{link:T}})}return i}return Object.freeze({copyExportValue:p})})(),_e=(()=>{const{ExportCell:u,assertScalar:k}=fe,{isDate:s}=ue,{checkAbort:p,inputRows:a,pause:i,taskYieldDue:t}=te,{ExportBudget:h}=Se,{OfficeIMOError:n}=re,{copyColumns:T,createRowProjector:B}=Ie,{createTotals:f}=Re,{copyExportValue:g}=Ce,r=new WeakMap;function l(o){if(!o||typeof o!="object"||!r.has(o))throw new TypeError("Create grouped report sources with createGroupedReport.")}function d(o,m){return l(o),{async*[Symbol.asyncIterator](){const j=R(o,m);try{yield*j.events}finally{j.dispose()}}}}function R(o,m){l(o);const j=r.get(o),S=x(j.signal,m);return{signal:S.signal,events:j.events(S.signal),dispose:S.dispose}}function x(o,m){if(!o||!m||o===m)return{signal:o??m,dispose(){}};const j=new AbortController,S=()=>j.abort(o.reason),_=()=>j.abort(m.reason);return o.addEventListener("abort",S,{once:!0}),m.addEventListener("abort",_,{once:!0}),o.aborted?S():m.aborted&&_(),{signal:j.signal,dispose(){o.removeEventListener("abort",S),m.removeEventListener("abort",_)}}}function O(o,m,j){const S=o??m;if(!Number.isSafeInteger(S)||S<0)throw new RangeError(j+" must be a nonnegative safe integer.");return S}function e(o){return o instanceof u?o.value:o}function c(o){if(o==null)return{key:null,id:"null",text:""};if(s(o)){const j=Date.prototype.getTime.call(o);if(!Number.isFinite(j))throw new TypeError("A group key date must be valid.");return{key:new Date(j),id:"date:"+j,text:new Date(j).toISOString()}}if(typeof o=="number"&&!Number.isFinite(o))throw new TypeError("A numeric group key must be finite.");const m=String(o);return{key:o,id:typeof o+":"+m,text:m}}function L(o){return s(o)?new Date(Date.prototype.getTime.call(o)):o}function P(o){return Object.freeze(o.map(m=>m.operation===void 0?null:m.value()))}function w(o,m,j){const S=typeof o=="string"?[o]:Array.isArray(o)?Array.from(o):void 0;if(!S||S.length<1||S.length>4)throw new TypeError("groupBy must declare between one and four grouping levels.");if(j!==void 0&&typeof j!="function")throw new TypeError("groupLabel must be a synchronous function.");if(j&&S.length!==1)throw new TypeError("groupLabel is only available for one grouping level; use descriptor labels for a hierarchy.");const _=new Set;return Object.freeze(S.map(D=>{if(typeof D!="string"&&(!D||typeof D!="object"||Array.isArray(D)))throw new TypeError("A grouping level must name a stable column key or provide a descriptor.");const{key:M,value:G,label:H}=typeof D=="string"?{key:D,value:void 0,label:void 0}:D;if(typeof M!="string"||!M.length||_.has(M))throw new TypeError("Grouping levels need unique, nonempty stable keys.");if(_.add(M),G!==void 0&&typeof G!="function")throw new TypeError("Grouping value getters must be synchronous functions.");if(H!==void 0&&typeof H!="function")throw new TypeError("Grouping labels must be synchronous functions.");if(H&&j)throw new TypeError("Specify either groupLabel or the grouping descriptor label.");const F=m.indexOf(M);if(F>=0&&G!==void 0)throw new TypeError("A declared grouping column reuses its projected value; do not provide another value getter.");if(F<0&&G===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:M,column:F,value:G,label:H??j})}))}function y(o){return Object.freeze(o.map(({group:m})=>Object.freeze({...m,key:L(m.key)})))}function v(o,m,j){if(!o)return j;const S=o(L(m));if(typeof S?.then=="function"&&Promise.resolve(S).catch(()=>{}),typeof S!="string")throw new TypeError("Grouping labels must return synchronous text.");return S}function b(o,m){if(!m||typeof m!="object")throw new TypeError("Grouped report options are required.");const{columns:j,groupBy:S,totals:_,groupLabel:D,maxGroups:M,maxGroupKeyCharacters:G,signal:H,limits:F}=m;if(F!==void 0&&(!F||typeof F!="object"||Array.isArray(F)))throw new TypeError("Grouped source limits must be an object.");if(F!==void 0&&"maxOutputBytes"in F)throw new TypeError("Set maxOutputBytes on the format writer, not the grouped source.");if(!Array.isArray(j)||!j.length)throw new TypeError("A grouped report needs declared columns.");const E=T(j),z=E.map(A=>A.key);if(z.some(A=>typeof A!="string"||A.length===0)||new Set(z).size!==z.length)throw new TypeError("Grouped report columns need unique, nonempty stable keys.");const Y=w(S,z,D),K=Object.freeze({..._}),J=f(E,K);for(let A=0;A<E.length;A++)if(J[A].operation!==void 0&&E[A].type!=="number")throw new TypeError("Grouped numeric totals require a column declared with type:number.");const Q=O(M,1e3,"maxGroups"),le=O(G,1e6,"maxGroupKeyCharacters"),X=new h(F),ye=Object.freeze(E.map(A=>{const{value:V,...ee}=A;return Object.freeze(ee)}));for(const A of E){X.cell(A.header);for(const V of A.groups??[])X.reserve(0,V.length);Object.freeze(A)}let pe=!1;const ae=A=>Object.freeze({[Symbol.asyncIterator](){if(pe)throw new TypeError("A grouped report source can be consumed only once.");return pe=!0,W(A)}}),N=ae(H);async function*W(A){const V=B(E,void 0,A),ee=new Set,q=[];let Ee=0,ne=0,de=0;for await(const se of a(o,A)){const ce=Array.isArray(se)?Array.from(se):se,Ae=V(ce,ne),oe=[];for(let I=0;I<E.length;I++)oe.push(g(Ae[I])??null);p(A);const ke=Y.map((I,U)=>{p(A);const $=I.column>=0?e(oe[I.column]):I.value(ce,Object.freeze({rowIndex:ne,level:U,key:I.key}));return k($),p(A),c($)});X.row(ne+1);for(let I=0;I<oe.length;I++){const U=oe[I],$=e(U);if(J[I].operation!==void 0&&$!=null&&(typeof $!="number"||!Number.isFinite($)))throw new TypeError("Grouped numeric metrics must resolve to finite numbers or null.");X.cell($),U instanceof u&&U.text!==void 0&&X.reserve(0,U.text.length)}let ie=0;for(;ie<q.length&&q[ie].id===ke[ie].id;)ie++;const we=[];for(let I=ie;I<Y.length;I++){const U=ke[I],me=((we.at(-1)??q[I-1])?.group.groupIndex??-1)+":"+U.id;if(ee.has(me))throw new TypeError("Grouped rows must be contiguous; a closed group key occurred again within the same parent.");if(de===Q)throw new n("RESOURCE_LIMIT","maxGroups exceeded.");const be=v(Y[I].label,U.key,U.text);p(A);const ge=Ee+me.length+be.length;if(!Number.isSafeInteger(ge)||ge>le)throw new n("RESOURCE_LIMIT","maxGroupKeyCharacters exceeded.");X.reserve(0,be.length),we.push({id:U.id,group:Object.freeze({groupIndex:de,key:U.key,label:be,level:I}),rows:0,aggregates:f(E,K)}),Ee=ge,ee.add(me),de++}for(;q.length>ie;){p(A);const I=y(q),U=q.pop();yield Object.freeze({kind:"groupEnd",...I.at(-1),path:I,rows:U.rows,totals:P(U.aggregates)})}for(const I of we){p(A),q.push(I);const U=y(q);yield Object.freeze({kind:"groupStart",...U.at(-1),path:U})}for(let I=0;I<oe.length;I++){const U=e(oe[I]);for(const $ of q)$.aggregates[I].accept(U);J[I].accept(U)}for(const I of q)I.rows++;p(A),yield Object.freeze({kind:"row",values:Object.freeze(oe),rowIndex:ne,groupIndex:q.at(-1).group.groupIndex,path:y(q)}),ne++,t()&&(await i(),p(A))}for(p(A);q.length;){p(A);const se=y(q),ce=q.pop();yield Object.freeze({kind:"groupEnd",...se.at(-1),path:se,rows:ce.rows,totals:P(ce.aggregates)})}p(A),yield Object.freeze({kind:"complete",rows:ne,groups:de,totals:P(J)})}const Z=Object.freeze({columns:ye,groupBy:Object.freeze(Y.map(A=>A.key)),totals:K,events:N});return r.set(Z,{signal:H,events:ae}),Z}return Object.freeze({assertGroupedReportSource:l,groupedReportEvents:d,groupedReportOperation:R,createGroupedReport:b})})(),Be=(()=>{const{OfficeIMOError:u}=re;function k(){let a=!1;if(typeof CompressionStream=="function")try{new CompressionStream("deflate-raw"),a=!0}catch{}return{blob:typeof Blob=="function",streams:typeof WritableStream=="function",deflateRaw:a,download:typeof document<"u"&&typeof URL.createObjectURL=="function"}}function s(a,i){if(!(a instanceof Blob)||typeof i!="string"||!i)throw new TypeError("A Blob and file name are required.");if(typeof document>"u"||typeof URL.createObjectURL!="function")throw new u("PLATFORM_UNAVAILABLE","saveBlob requires a browser document and object URLs.");const t=URL.createObjectURL(a),h=document.createElement("a");try{h.href=t,h.download=i,document.body.append(h),h.click()}finally{h.remove(),setTimeout(()=>URL.revokeObjectURL(t),3e4)}}return Object.freeze({OfficeIMOError:re.OfficeIMOError,NotSupportedError:re.NotSupportedError,BlobByteSink:he.BlobByteSink,ChunkedTextSink:he.ChunkedTextSink,writeBytes:he.writeBytes,ExportCell:fe.ExportCell,createGroupedReport:_e.createGroupedReport,checkAbort:te.checkAbort,withAbort:te.withAbort,inputRows:te.inputRows,pause:te.pause,detectFeatures:k,saveBlob:s})})(),Oe=(()=>{const{ExportCell:u,NotSupportedError:k,OfficeIMOError:s}=Be,{assertExportValue:p,assertScalar:a,copyCellPresentation:i}=fe,{copyExportLink:t}=Te,{isDate:h}=ue,n="@evotecit/officeimo/worker-export/1";function T(e){if(!e||typeof e!="object")return;const c=e;return c.protocol===n&&typeof c.job=="string"&&typeof c.kind=="string"?c:void 0}function B(e){const c={batchRows:e.batchRows??64,maxBatchCells:e.maxBatchCells??65536,maxBatchCharacters:e.maxBatchCharacters??1e6,maxChunkBytes:e.maxChunkBytes??65536,maxSetupBytes:e.maxSetupBytes??16777216,maxSetupNodes:e.maxSetupNodes??1e5};for(const[L,P]of Object.entries(c))if(!Number.isSafeInteger(P)||P<1)throw new RangeError(L+" must be a positive safe integer.");return Object.freeze(c)}function f(e,c){let L=0,P=0;const w=new Set;function y(b=0){if(P+=b,P>c.maxSetupBytes||++L>c.maxSetupNodes)throw new s("RESOURCE_LIMIT","Worker configuration exceeds its message budget.")}function v(b,C){if(C>32)throw new RangeError("Worker configuration nesting exceeds 32 levels.");if(y(typeof b=="string"?b.length*2:0),b==null||["string","number","boolean"].includes(typeof b))return b;if(h(b))return y(8),new Date(b.getTime());if(ArrayBuffer.isView(b)&&Object.prototype.toString.call(b)==="[object Uint8Array]")return y(b.byteLength),new Uint8Array(b);if(typeof b!="object")throw new TypeError("Worker configuration requires portable data without functions or symbols.");if(w.has(b))throw new TypeError("Worker configuration cannot contain cycles.");const o=Object.getPrototypeOf(b),m=o==null?void 0:Object.getOwnPropertyDescriptor(o,"constructor")?.value,j=o===null||Object.getPrototypeOf(o)===null&&typeof m=="function"&&Function.prototype.toString.call(m)===Function.prototype.toString.call(Object);if(!Array.isArray(b)&&!j)throw new TypeError("Worker configuration supports plain records, arrays, Dates and Uint8Array bytes; reconstruct font instances in the worker.");w.add(b);try{if(Array.isArray(b)){if(b.length>c.maxSetupNodes-L)throw new s("RESOURCE_LIMIT","Worker configuration exceeds its message budget.");const _=[];for(let D=0;D<b.length;D++){const M=Object.getOwnPropertyDescriptor(b,String(D));if(M&&!Object.prototype.hasOwnProperty.call(M,"value"))throw new TypeError("Worker configuration cannot contain accessors.");_.push(v(M?.value,C+1))}return _}const S={};for(const _ of Reflect.ownKeys(b)){if(typeof _!="string")throw new TypeError("Worker configuration keys must be strings.");const D=Object.getOwnPropertyDescriptor(b,_);if(D.enumerable){if(!Object.prototype.hasOwnProperty.call(D,"value"))throw new TypeError("Worker configuration cannot contain accessors.");y(_.length*2),Object.defineProperty(S,_,{value:v(D.value,C+1),enumerable:!0,configurable:!0,writable:!0})}}return S}finally{w.delete(b)}}return v(e,0)}function g(e){if(!Array.isArray(e))throw new TypeError("Worker export rows must be projected arrays.");let c=0;const L=w=>(typeof w=="string"&&(c+=w.length),h(w)?new Date(w.getTime()):w);return{cells:e.map(w=>{if(p(w),!(w instanceof u))return{value:L(w)};const y=w.value,v=w.text,b=w.presentation,C=w.link;if(a(y),v!==void 0&&typeof v!="string")throw new TypeError("Display text must be a string.");const o={...v===void 0?{}:{text:v},...b===void 0?{}:{presentation:i(b)},...C===void 0?{}:{link:t(C)}};c+=v?.length??0;for(const m of Object.values(o.presentation??{}))typeof m=="string"&&(c+=m.length);return c+=(o.link?.target.length??0)+(o.link?.tooltip?.length??0),{value:L(y),options:o}}),characters:c}}function r(e,c){if(!Array.isArray(e)||e.length>c.batchRows)throw new TypeError("Invalid worker row batch.");let L=0,P=0;return e.map(w=>{if(!Array.isArray(w))throw new TypeError("Invalid worker row.");if(L+w.length>c.maxBatchCells)throw new s("RESOURCE_LIMIT","Worker row batch exceeds its message budget.");const y=w.map(b=>{if(!b||typeof b!="object")throw new TypeError("Invalid worker cell.");const C=b.options===void 0?b.value:new u(b.value,b.options);return p(C),C}),v=g(y);if(L+=w.length,P+=v.characters,L>c.maxBatchCells||P>c.maxBatchCharacters)throw new s("RESOURCE_LIMIT","Worker row batch exceeds its message budget.");return y})}function l(e,c){if(!e||!["rows","complete"].includes(e.phase)||!Number.isSafeInteger(e.rows)||e.rows<0)throw new TypeError("Invalid worker progress.");for(const L of["bytes","sheetRows","totalRows"])if(e[L]!==void 0&&(!Number.isSafeInteger(e[L])||e[L]<0))throw new TypeError("Invalid worker progress count.");if(e.sheetName!==void 0&&(typeof e.sheetName!="string"||e.sheetName.length>c.maxBatchCharacters))throw new TypeError("Invalid or oversized worker sheet name.");return{phase:e.phase,rows:e.rows,...e.bytes===void 0?{}:{bytes:e.bytes},...e.sheetRows===void 0?{}:{sheetRows:e.sheetRows},...e.totalRows===void 0?{}:{totalRows:e.totalRows},...e.sheetName===void 0?{}:{sheetName:e.sheetName}}}function d(e){return{name:e instanceof Error?e.name:"Error",message:e instanceof Error?e.message:String(e),...e instanceof s?{code:e.code}:{},...e instanceof k?{feature:e.feature}:{}}}function R(e){if(!e||typeof e.message!="string")return new Error("Worker export failed.");const c=e.code==="NOT_SUPPORTED"&&typeof e.feature=="string"?new k(e.feature):e.code===void 0?new Error(e.message):new s(e.code,e.message);return c.message=e.message,typeof e.name=="string"&&(c.name=e.name),c}function x(e){if(!e||[e.rows,e.columns,e.bytes].some(c=>!Number.isSafeInteger(c)||c<0))throw new TypeError("Invalid worker export result.");return{rows:e.rows,columns:e.columns,bytes:e.bytes}}return Object.freeze({protocol:n,message:T,bounds:B,captureInput:f,captureRow:g,restoreRows:r,captureProgress:l,wireError:d,restoreError:R,result:x})})(),ve=(()=>{const{checkAbort:u,inputRows:k,withAbort:s}=te,{withDestination:p}=he,{notifyProgress:a}=je,{OfficeIMOError:i}=re,{bounds:t,captureInput:h,captureProgress:n,captureRow:T,message:B,protocol:f,restoreError:g,result:r,wireError:l}=Oe,{captureFields:d}=xe,R=new WeakSet;let x=0;async function O(c,L,P,w={}){const y=d(w,["input","signal","onProgress","batchRows","maxBatchCells","maxBatchCharacters","maxChunkBytes","maxSetupBytes","maxSetupNodes"]),v=y.signal,b=y.onProgress;u(v);const C=t(y),o=h(y.input,C);if(R.has(c))throw new i("INVALID_STATE","A worker endpoint already has an active export.");R.add(c);try{return await p(P,m=>new Promise((j,S)=>{const _=new AbortController,D="export-"+ ++x,M=k(L,_.signal);let G=!1,H=!1,F=!1,E=!1,z=0,Y;const K=N=>c.postMessage({protocol:f,job:D,...N});function J(){c.removeEventListener("message",ae),c.removeEventListener("error",X),c.removeEventListener("messageerror",X),v?.removeEventListener("abort",le),E||M.return(void 0).catch(()=>{}),Y=void 0}function Q(N){if(!G){G=!0,_.abort(N);try{K({kind:"cancel",error:l(N)})}catch{}J(),S(N)}}const le=()=>{try{u(v)}catch(N){Q(N)}},X=N=>Q(new Error(N.message||"Worker messaging failed."));async function ye(N){if(H)throw new i("INVALID_STATE","Only one worker row request may be pending.");H=!0;try{const W=[];let Z=0,A=0;for(;W.length<C.batchRows&&!E;){let V=Y;if(Y=void 0,!V){const ee=await s(M.next(),_.signal);if(G)return;if(ee.done){E=!0;break}if(!Array.isArray(ee.value)||ee.value.length>C.maxBatchCells)throw new i("RESOURCE_LIMIT","A worker row exceeds its message cell budget.");V=T(ee.value)}if(V.cells.length>C.maxBatchCells||V.characters>C.maxBatchCharacters)throw new i("RESOURCE_LIMIT","A worker row exceeds its message budget.");if(W.length&&(Z+V.cells.length>C.maxBatchCells||A+V.characters>C.maxBatchCharacters)){Y=V;break}W.push(V.cells),Z+=V.cells.length,A+=V.characters}G||K({kind:"rows",id:N,rows:W,done:E})}finally{H=!1}}async function pe(N){if(F||!(N.bytes instanceof Uint8Array)||N.bytes.length>C.maxChunkBytes)throw new i("INVALID_STATE","Invalid or overlapping worker output chunk.");F=!0;try{await s(Promise.resolve(m.write(N.bytes)),_.signal),G||(z+=N.bytes.length,K({kind:"ack",id:N.id}))}finally{F=!1}}const ae=N=>{const W=B(N.data);if(!(G||!W||W.job!==D))try{if(W.kind==="complete"){const Z=r(W.result);if(F||H||Z.bytes!==z)throw new i("INVALID_STATE","Worker completion does not match acknowledged output.");G=!0,J(),j(Z)}else if(W.kind==="failed")Q(g(W.error));else{if(!Number.isSafeInteger(W.id)||W.id<1)throw new TypeError("Invalid worker request identifier.");if(W.kind==="requestRows")ye(W.id).catch(Q);else if(W.kind==="output")pe(W).catch(Q);else if(W.kind==="progress"){if(!W.progress)throw new TypeError("Invalid worker progress.");a(b,n(W.progress,C)),K({kind:"ack",id:W.id})}else throw new TypeError("Unexpected worker export message.")}}catch(Z){Q(Z)}};c.addEventListener("message",ae),c.addEventListener("error",X),c.addEventListener("messageerror",X),v?.addEventListener("abort",le,{once:!0});try{c.start?.(),u(v),K({kind:"start",input:o,bounds:C})}catch(N){Q(N)}}))}finally{R.delete(c)}}return Object.freeze({executeWorkerExport:O})})(),Le=(()=>{const{checkAbort:u,withAbort:k}=te,{OfficeIMOError:s}=re,{bounds:p,captureInput:a,captureProgress:i,message:t,protocol:h,restoreError:n,restoreRows:T,result:B,wireError:f}=Oe,g=new WeakSet;function r(d,R){if(g.has(d))throw new s("INVALID_STATE","A worker export handler is already installed.");if(typeof R!="function")throw new TypeError("A worker export operation is required.");g.add(d);let x,O=!1;const e=(w,y)=>d.postMessage({protocol:h,job:w,...y});async function c(w){const y=new AbortController,v=p(w.bounds??{}),b=a(w.input,v),C=new Map;let o=0,m=!1,j=!1,S,_;const D=()=>{for(const E of C.values())E.reject(y.signal.reason);C.clear(),S=void 0};y.signal.addEventListener("abort",D,{once:!0}),x={job:w.job,controller:y,deliver(E){const z=C.get(E.id);z&&(C.delete(E.id),z.resolve(E))}};const M=(E,z={})=>(u(y.signal),new Promise((Y,K)=>{const J=++o;C.set(J,{resolve:Y,reject:K});try{e(w.job,{kind:E,id:J,...z})}catch(Q){C.delete(J),K(Q)}}));function G(E){u(y.signal),S=i(E,v),_||(_=(async()=>{for(;S;){const z=S;S=void 0,await M("progress",{progress:z})}})().finally(()=>{_=void 0}),_.catch(z=>y.abort(z)))}const H={[Symbol.asyncIterator](){if(j)throw new TypeError("Worker rows can be consumed only once.");return j=!0,(async function*(){for(;;){const E=await M("requestRows");if(E.kind!=="rows"||typeof E.done!="boolean")throw new TypeError("Invalid worker row response.");for(const z of T(E.rows,v))u(y.signal),yield z;if(E.done)return}})()}},F={async write(E){if(u(y.signal),m||!(E instanceof Uint8Array))throw new s("INVALID_STATE","Await each worker output write.");m=!0;try{for(let z=0;z<E.length;z+=v.maxChunkBytes)await M("output",{bytes:new Uint8Array(E.subarray(z,Math.min(E.length,z+v.maxChunkBytes)))})}finally{m=!1}}};try{const E=B(await k(R({input:b,rows:H,sink:F,signal:y.signal,onProgress:G}),y.signal));if(_&&await k(_,y.signal),C.size)throw new s("INVALID_STATE","Await worker row and output operations before completing.");e(w.job,{kind:"complete",result:E})}catch(E){y.abort(E);try{e(w.job,{kind:"failed",error:f(E)})}catch{}}finally{y.signal.removeEventListener("abort",D),D(),x=void 0}}const L=w=>{const y=t(w.data);if(!(!y||O))if(y.kind==="start"){if(x){e(y.job,{kind:"failed",error:f(new s("INVALID_STATE","The worker already has an active export."))});return}c(y).catch(v=>{try{e(y.job,{kind:"failed",error:f(v)})}catch{}})}else y.job===x?.job&&(y.kind==="cancel"?x.controller.abort(n(y.error)):x.deliver(y))},P=w=>x?.controller.abort(new Error(w.message||"Worker messaging failed."));return d.addEventListener("message",L),d.addEventListener("error",P),d.addEventListener("messageerror",P),d.start?.(),{dispose(w=new DOMException("Worker export handler disposed.","AbortError")){O||(O=!0,x?.controller.abort(w),d.removeEventListener("message",L),d.removeEventListener("error",P),d.removeEventListener("messageerror",P),g.delete(d))}}}return Object.freeze({handleWorkerExports:r})})(),Pe=Object.freeze({executeWorkerExport:ve.executeWorkerExport,handleWorkerExports:Le.handleWorkerExports}),{executeWorkerExport:De,handleWorkerExports:ze}=Pe;export{De as executeWorkerExport,ze as handleWorkerExports};
|