@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.
- package/README.md +15 -3
- 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 +12 -11
- package/bundles/officeimo-canopyx.min.js +2 -0
- package/bundles/officeimo-canopyx.min.mjs +2 -0
- package/bundles/officeimo-canopyx.mjs +6 -5
- 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.js +6 -5
- package/dist/integrations/datatables/snapshot.js +51 -6
- package/package.json +6 -2
|
@@ -12574,25 +12574,26 @@ function numericProfile(format) {
|
|
|
12574
12574
|
return { minimumFractionDigits: (match[3]?.match(/0/g) ?? []).length, maximumFractionDigits: match[3]?.length ?? 0,
|
|
12575
12575
|
percent: !!match[4], grouping: !!match[2], prefix: literal(match[1]), suffix: literal(match[5]) };
|
|
12576
12576
|
}
|
|
12577
|
-
/** Separate declared literal units before recognizing the captured numeric token.
|
|
12577
|
+
/** Separate declared literal units before recognizing the captured numeric token. U+2212 MINUS SIGN counts as a
|
|
12578
|
+
* sign like "-": the number is re-rendered with Intl's sign, so it never becomes a literal prefix. */
|
|
12578
12579
|
function capturedNumber(text, profile) {
|
|
12579
12580
|
let body = text, signBeforePrefix = false;
|
|
12580
12581
|
if (profile.prefix && body.startsWith(profile.prefix))
|
|
12581
12582
|
body = body.slice(profile.prefix.length);
|
|
12582
|
-
else if (profile.prefix && /^[
|
|
12583
|
+
else if (profile.prefix && /^[+\-\u2212]/.test(body) && body.slice(1).startsWith(profile.prefix)) {
|
|
12583
12584
|
signBeforePrefix = true;
|
|
12584
12585
|
body = body[0] + body.slice(1 + profile.prefix.length);
|
|
12585
12586
|
}
|
|
12586
12587
|
if (profile.suffix && body.endsWith(profile.suffix))
|
|
12587
12588
|
body = body.slice(0, -profile.suffix.length);
|
|
12588
|
-
const match = /^([^0-9
|
|
12589
|
+
const match = /^([^0-9+\-\u2212]*)([+\-\u2212]?\d[\d., \u00a0\u202f]*?)([^0-9]*)$/.exec(body);
|
|
12589
12590
|
return match ? { prefix: profile.prefix || match[1], number: match[2], suffix: profile.suffix || match[3], signBeforePrefix } : undefined;
|
|
12590
12591
|
}
|
|
12591
12592
|
/** Distinguish a captured thousands mark from a decimal, using the raw value. */
|
|
12592
12593
|
function groupedInteger(numeric, value) {
|
|
12593
|
-
if (!/^[
|
|
12594
|
+
if (!/^[+\-\u2212]?\d{1,3}(?:,\d{3})+$/.test(numeric) && !/^[+\-\u2212]?\d{1,3}(?:\.\d{3})+$/.test(numeric))
|
|
12594
12595
|
return false;
|
|
12595
|
-
const grouped = Number(numeric.replace(/[.,]/g, ""));
|
|
12596
|
+
const grouped = Number(numeric.replace(/[.,]/g, "").replace("\u2212", "-"));
|
|
12596
12597
|
return grouped !== 0 && Math.abs(grouped - value) <= .5;
|
|
12597
12598
|
}
|
|
12598
12599
|
/** Choose once for the document; percent text is the strongest captured culture signal. */
|
|
@@ -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"),g=le[we]||new Map;le[we]||Object.defineProperty(le,we,{value:g});const Q=g.get("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3")??(()=>{function l(t){if(t?.aborted)throw t.reason}function p(t,u){return u?new Promise((y,O)=>{const E=()=>u.removeEventListener("abort",k),k=()=>{E(),O(u.reason)};u.addEventListener("abort",k,{once:!0}),Promise.resolve(t).then(z=>{E(),y(z)},z=>{E(),O(z)}),u.aborted&&k()}):Promise.resolve(t)}async function*f(t,u){l(u);const y=t?.[Symbol.asyncIterator]?.()??t?.[Symbol.iterator]?.();if(!y)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let O=!1,E=!1;try{for(;;){l(u);const k=await p(Promise.resolve(y.next()),u);if(l(u),k.done){O=!0;return}yield k.value}}catch(k){throw E=!0,k}finally{if(!O&&y.return)try{const k=y.return();u?.aborted||E?Promise.resolve(k).catch(()=>{}):await p(Promise.resolve(k),u)}catch(k){if(!u?.aborted&&!E)throw k}}}const s=new WeakMap;function o(t){let u=!1;const y=()=>{if(u)throw new TypeError("A row source can be consumed only once.");u=!0},O={[Symbol.asyncIterator](){return y(),E()}};async function*E(){for await(const k of f(t))yield*k}return s.set(O,(k,z)=>(y(),e(t,k,L=>e(L,k,z)))),O}function n(...t){const u={async*[Symbol.asyncIterator](){for(const y of t)yield*y}};return s.set(u,async(y,O)=>{for(const E of t)await e(E,y,O)}),u}async function e(t,u,y){l(u);const O=s.get(t);if(O)return O(u,y);const E=t?.[Symbol.asyncIterator]?.()??t?.[Symbol.iterator]?.();if(!E)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let k=!1;try{for(;;){l(u);let z=E.next();const L=z;typeof L?.then=="function"&&(z=await p(L,u)),l(u);const Z=z;if(Z.done){k=!0;return}let U=Z.value;typeof U?.then=="function"&&(U=await p(U,u)),l(u);const C=y(U);C!==void 0&&await p(C,u)}}finally{if(!k&&E.return)try{Promise.resolve(E.return()).catch(()=>{})}catch{}}}let i;const r=32;function h(){i=performance.now()+r}function x(){const t=performance.now();return i??=t+r,t>=i}function a(){const t=globalThis.scheduler;return typeof t?.postTask=="function"?t.postTask(()=>{i=performance.now()+r},{priority:"user-visible"}):new Promise(u=>{setTimeout(function(){i=performance.now()+r,u()},0)})}const b=Object.freeze({checkAbort:l,withAbort:p,inputRows:f,rowsFromBatches:o,concatRows:n,consumeRows:e,beginTask:h,taskYieldDue:x,pause:a});return g.set("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3",b),b})(),re=g.get("d5c945064d81fdd257960f48c421125e106e5f270427d170bb05587dd96a44ea")??(()=>{const l=Symbol.for("@evotecit/officeimo/OfficeIMOError"),p=Symbol.for("@evotecit/officeimo/NotSupportedError");class f extends Error{code;static[Symbol.hasInstance](e){return this!==f?Function.prototype[Symbol.hasInstance].call(this,e):!!e&&typeof e=="object"&&e[l]===!0}constructor(e,i,r){super(i,r),this.code=e,Object.defineProperty(this,l,{value:!0}),this.name="OfficeIMOError"}}class s extends f{feature;static[Symbol.hasInstance](e){return this!==s?Function.prototype[Symbol.hasInstance].call(this,e):!!e&&typeof e=="object"&&e[p]===!0}constructor(e){super("NOT_SUPPORTED",e+" is not supported yet."),this.feature=e,Object.defineProperty(this,p,{value:!0}),this.name="NotSupportedError"}}const o=Object.freeze({OfficeIMOError:f,NotSupportedError:s});return g.set("d5c945064d81fdd257960f48c421125e106e5f270427d170bb05587dd96a44ea",o),o})(),pe=g.get("5337d1e3bd5ae0c1d10a476fcd31540d20337ccf7aa93c7e9e26c2b1a7dab92b")??(()=>{const{checkAbort:l,consumeRows:p,withAbort:f,pause:s,taskYieldDue:o}=Q,{OfficeIMOError:n}=re;async function e(a,b){if(a&&typeof a.getWriter=="function"){const t=a.getWriter();try{return await b({write:u=>t.write(new Uint8Array(u))})}finally{t.releaseLock()}}if(!a||typeof a.write!="function")throw new TypeError("Destination must be a ByteSink or WritableStream.");return b(a)}class i{parts=[];state="open";result;write(b){if(this.state!=="open")throw new n("INVALID_STATE","Byte sink is closed.");this.parts.push(new Uint8Array(b))}toBlob(b="application/octet-stream"){if(this.state==="discarded")throw new n("INVALID_STATE","Byte sink was discarded.");return this.state="closed",this.result||(this.result=new Blob(this.parts,{type:b}),this.parts=[]),this.result.type===b?this.result:new Blob([this.result],{type:b})}takeChunks(){if(this.state!=="open")throw new n("INVALID_STATE","Byte sink is closed.");const b=this.parts;return this.parts=[],this.state="discarded",b}discard(){this.parts=[],this.result=void 0,this.state="discarded"}}class r{sink;signal;chunkSize;text="";encoder=new TextEncoder;constructor(b,t,u=32768){if(this.sink=b,this.signal=t,this.chunkSize=u,!Number.isInteger(u)||u<2)throw new RangeError("Text chunk size must be at least 2.")}append(b){return l(this.signal),this.text+=b,this.text.length>=this.chunkSize||o()}async flush(b=!1){for(l(this.signal);this.text.length;){let t=Math.min(this.text.length,this.chunkSize);if(/[\ud800-\udbff]/.test(this.text[t-1])&&(t<this.text.length||!b)&&t--,!t)break;const u=this.encoder.encode(this.text.slice(0,t));this.text=this.text.slice(t),await f(Promise.resolve(this.sink.write(u)),this.signal),o()&&await s(),l(this.signal)}}async write(b){this.append(b)&&await this.flush()}async close(){await this.flush(!0)}}async function h(a,b,t){await p(a instanceof Uint8Array?[a]:a,t,u=>{if(!(u instanceof Uint8Array))throw new TypeError("Byte sources must yield Uint8Array chunks.");const y=b.write(u);return o()?Promise.resolve(y).then(()=>(l(t),s())):y})}const x=Object.freeze({withDestination:e,BlobByteSink:i,ChunkedTextSink:r,writeBytes:h});return g.set("5337d1e3bd5ae0c1d10a476fcd31540d20337ccf7aa93c7e9e26c2b1a7dab92b",x),x})(),ge=g.get("50b3c10b690ceff693c8c5f809195ba6845b20e60f408e791a750d2ecbd5c669")??(()=>{function l(f,s){const o={...f};for(const n of s){if(Object.hasOwn(o,n))continue;const e=f[n];e!==void 0&&(o[n]=e)}return o}const p=Object.freeze({captureFields:l});return g.set("50b3c10b690ceff693c8c5f809195ba6845b20e60f408e791a750d2ecbd5c669",p),p})(),je=g.get("42faf379960e5674a6fdfa8c8fca0bb68bbd74587231248d2524d7004def3671")??(()=>{const{OfficeIMOError:l}=re,{captureFields:p}=ge;class f{cells=0;text=0;reservedCells=0;reservedText=0;limits;constructor(e={}){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Export limits must be an object.");const i=p(e,["maxRows","maxCells","maxTextCharacters","maxOutputBytes"]);for(const[r,h]of Object.entries(i))if(h!==void 0&&(!Number.isSafeInteger(h)||h<0))throw new RangeError(r+" must be a nonnegative safe integer.");this.limits=Object.freeze(i)}check(e,i){const r=this.limits[e];if(r!==void 0&&i>r)throw new l("RESOURCE_LIMIT",e+" exceeded ("+i+" > "+r+").")}row(e){this.check("maxRows",e)}reserve(e,i){this.check("maxCells",this.cells+this.reservedCells+e),this.check("maxTextCharacters",this.text+this.reservedText+i),this.reservedCells+=e,this.reservedText+=i}release(e,i){this.reservedCells-=e,this.reservedText-=i}cell(e,i){if(i!==void 0&&this.release(1,i),this.limits.maxCells===void 0&&this.limits.maxTextCharacters===void 0)return;this.check("maxCells",this.cells+this.reservedCells+1);const r=typeof e=="string"?e.length:0;this.check("maxTextCharacters",this.text+this.reservedText+r),this.cells++,this.text+=r}}function s(n,e){let i=0;return{write(r){return e.check("maxOutputBytes",i+r.length),i+=r.length,n.write(r)}}}const o=Object.freeze({ExportBudget:f,boundedSink:s});return g.set("42faf379960e5674a6fdfa8c8fca0bb68bbd74587231248d2524d7004def3671",o),o})(),fe=g.get("501f5fccaecb27d9e514b74cf64893649e50616692250593d120ca315b510c04")??(()=>{function l(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}}const p=Object.freeze({isDate:l});return g.set("501f5fccaecb27d9e514b74cf64893649e50616692250593d120ca315b510c04",p),p})(),Ie=g.get("d363b84eac65064b2e372063af61a4e9e5c576501693c862628297c812ba7832")??(()=>{function l(f){if(!f||typeof f!="object")throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const{target:s,tooltip:o}=f;if(typeof s!="string"||!/^(?:https?:\/\/|mailto:)/i.test(s)||/[\u0000-\u0020\u007f]/.test(s))throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const n=new URL(s);if((n.protocol==="http:"||n.protocol==="https:")&&(!n.hostname||n.username||n.password))throw new TypeError("Hyperlink HTTP targets need a host and must not contain credentials.");if(o!==void 0&&typeof o!="string")throw new TypeError("Hyperlink tooltip must be text.");return Object.freeze({target:n.href,...o===void 0?{}:{tooltip:o}})}const p=Object.freeze({copyExportLink:l});return g.set("d363b84eac65064b2e372063af61a4e9e5c576501693c862628297c812ba7832",p),p})(),X=g.get("732224f6995c2478cf33a6ed01f3e3d3dcccb159a731d6db9280104bd5040fc5")??(()=>{const{isDate:l}=fe,{copyExportLink:p}=Ie,f=Symbol.for("@evotecit/officeimo/ExportCell");function s(r){if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError("Cell presentation must be an object.");const h={};for(const x of["background","color","numberFormat","bold","italic","wrapText","alignment"]){const a=r[x];if(a!==void 0){if(["bold","italic","wrapText"].includes(x)){if(typeof a!="boolean")throw new TypeError("Cell presentation "+x+" must be boolean.")}else if(typeof a!="string")throw new TypeError("Cell presentation "+x+" must be text.");if(x==="alignment"&&!["left","center","right","fill","justify","distributed"].includes(a))throw new TypeError("Invalid cell presentation alignment.");h[x]=a}}return Object.freeze(h)}class o{value;static[Symbol.hasInstance](h){return!!h&&typeof h=="object"&&h[f]===!0}text;presentation;link;constructor(h,x={}){this.value=h;const{text:a,presentation:b,link:t}=x;if(a!==void 0&&typeof a!="string")throw new TypeError("Display text must be a string.");n(h),this.text=a,this.presentation=b===void 0?void 0:s(b),this.link=t===void 0?void 0:p(t),Object.defineProperty(this,f,{value:!0}),Object.freeze(this)}}function n(r){const h=typeof r;if(!(r==null||h==="string"||h==="number"||h==="boolean"||l(r)))throw typeof r.then=="function"&&Promise.resolve(r).catch(()=>{}),new TypeError("Export values and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}function e(r){r!==null&&typeof r=="object"&&r instanceof o||n(r)}const i=Object.freeze({copyCellPresentation:s,ExportCell:o,assertScalar:n,assertExportValue:e});return g.set("732224f6995c2478cf33a6ed01f3e3d3dcccb159a731d6db9280104bd5040fc5",i),i})(),Be=g.get("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f")??(()=>{function l(f,s){if(!f)return;const o=f(s);if(o&&typeof o.then=="function")throw Promise.resolve(o).catch(()=>{}),new TypeError("onProgress must be synchronous.")}const p=Object.freeze({notifyProgress:l});return g.set("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f",p),p})(),Se=g.get("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc")??(()=>{const{assertExportValue:l}=X,{checkAbort:p}=Q,{isDate:f}=fe,{captureFields:s}=ge;function o(r,h,x,a=l){const b=r.some(t=>t.value);return(t,u=0)=>{if(Array.isArray(t)&&!b){const y=t.length;if(y>r.length)throw new RangeError("Row has more values than declared columns.");const O=new Array(y);for(let E=0;E<y;E++){const k=t[E];a(k),O[E]=k}return O}if(!t||typeof t!="object"||f(t))throw new TypeError("A row must be an array or object.");if(Array.isArray(t)&&t.length>r.length&&!r.every(y=>y.value))throw new RangeError("Project every column explicitly when selecting from a wider array row.");return r.map((y,O)=>{if(y.value){p(x);const z={rowIndex:u,columnIndex:O,column:y,...h?{sheetName:h.sheetName,worksheetRow:h.firstDataRow+u}:{}},L=y.value(t,z);return a(L),p(x),L}if(Array.isArray(t)){const z=t[O];return a(z),z}const E=y.key??y.header,k=Object.prototype.hasOwnProperty.call(t,E)?t[E]:void 0;return a(k),k})}}const n=["header","key","value","width","type","format","wrapText","alignment","rowHeader","groups","style","valueFormatter"];function e(r,h=!1){if(!Array.isArray(r))throw new TypeError("Declare the columns in export order.");return r.map(x=>{if(!x||typeof x!="object"&&typeof x!="function")throw new TypeError("Each column needs a string header and an optional string key.");const a=s(x,n);if(!h&&a.style!==void 0)throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");if(typeof a.header!="string"||a.key!==void 0&&typeof a.key!="string")throw new TypeError("Each column needs a string header and an optional string key.");if(a.value!==void 0&&typeof a.value!="function")throw new TypeError("Column value getters must be functions.");if(a.rowHeader!==void 0&&typeof a.rowHeader!="boolean")throw new TypeError("Column rowHeader must be boolean.");if(a.groups!==void 0){if(!Array.isArray(a.groups))throw new TypeError("Column groups must be an array of strings.");const b=Array.from(a.groups);if(b.some(t=>typeof t!="string"))throw new TypeError("Column groups must be an array of strings.");return{...a,groups:Object.freeze(b)}}return a})}const i=Object.freeze({createRowProjector:o,columnOptionFields:n,copyColumns:e});return g.set("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc",i),i})(),ve=g.get("e95bb0e3f342d1379b67a3d541fa808e06361da8460169a6aec152ee7deb69b2")??(()=>{const{ExportCell:l,assertExportValue:p}=X,{isDate:f}=fe;function s(n){if(p(n),f(n))return new Date(Date.prototype.getTime.call(n));if(n instanceof l){const{value:e,text:i,presentation:r,link:h}=n;return new l(f(e)?new Date(Date.prototype.getTime.call(e)):e,{...i===void 0?{}:{text:i},...r===void 0?{}:{presentation:r},...h===void 0?{}:{link:h}})}return n}const o=Object.freeze({copyExportValue:s});return g.set("e95bb0e3f342d1379b67a3d541fa808e06361da8460169a6aec152ee7deb69b2",o),o})(),Pe=g.get("d56b24243cff6f3552a2f7b45521af4491494375ec76117e9ac1ebb047ce02da")??(()=>{const{assertExportValue:l}=X,{copyExportValue:p}=ve;function f(n,e){if(!Array.isArray(n)||!n.length||n.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const i=n.map(r=>{if(!Array.isArray(r)||r.length!==e)throw new TypeError("Spanned rows must have the declared column count.");return Object.freeze(r.map(h=>{if(h===null)return null;if(!h||typeof h!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const{value:x,columnSpan:a,rowSpan:b}=h;return Object.freeze({value:p(x),...a===void 0?{}:{columnSpan:a},...b===void 0?{}:{rowSpan:b}})}))});return s(i,e),Object.freeze(i)}function s(n,e){if(!Array.isArray(n)||!n.length||n.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const i=Array.from({length:n.length},()=>new Uint8Array(e));return n.map((r,h)=>{if(!Array.isArray(r)||r.length!==e)throw new TypeError("Spanned rows must have the declared column count.");const x=[];for(let a=0;a<e;a++){const b=r[a];if(i[h][a]){if(b!==null)throw new TypeError("Covered heading/footer cells must be null.");continue}if(!b||typeof b!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const t=b.columnSpan??1,u=b.rowSpan??1;if(!Number.isInteger(t)||!Number.isInteger(u)||t<1||u<1||a+t>e||h+u>n.length)throw new RangeError("Heading/footer spans must stay inside the declared matrix.");const y=b.value;l(y);for(let O=h;O<h+u;O++)for(let E=a;E<a+t;E++){if(i[O][E])throw new TypeError("Heading/footer spans overlap.");if((O!==h||E!==a)&&n[O]?.[E]!==null)throw new TypeError("Covered heading/footer cells must be null.");i[O][E]=1}x.push(Object.freeze({first:a,span:t,rowSpan:u,value:y}))}return Object.freeze(x)})}const o=Object.freeze({captureTableSpans:f,tableSpans:s});return g.set("d56b24243cff6f3552a2f7b45521af4491494375ec76117e9ac1ebb047ce02da",o),o})(),_e=g.get("2f5c0823847e9209017d01b2a753f36056df2a9988fae1f3a1bd5fd186545220")??(()=>{const{captureTableSpans:l,tableSpans:p}=Pe;function f(o,n,e){const i=p(l(o,n),n),r=i.map(()=>Array(n).fill(""));for(let h=0;h<i.length;h++)for(const x of i[h]){if((x.span>1||x.rowSpan>1)&&e===void 0)throw new TypeError("CSV spanned headings/footers require an explicit spanMode: repeat or anchors.");const a=x.value;for(let b=h;b<h+(e==="repeat"?x.rowSpan:1);b++)for(let t=x.first;t<x.first+(e==="repeat"?x.span:1);t++)r[b][t]=a}return r}const s=Object.freeze({csvStructuredRows:f});return g.set("2f5c0823847e9209017d01b2a753f36056df2a9988fae1f3a1bd5fd186545220",s),s})(),De=g.get("9b33d9107e62ba8299c576072de40d24a261464f118de4ace64f23154fc78307")??(()=>{const l=Object.freeze({true:"True",false:"False"});function p(s){if(s===void 0)return l;if(!s||typeof s!="object")throw new TypeError("booleanText must contain true and false strings.");const o=s.true,n=s.false;if(typeof o!="string"||typeof n!="string")throw new TypeError("booleanText must contain true and false strings.");return Object.freeze({true:o,false:n})}const f=Object.freeze({defaultBooleanText:l,captureBooleanText:p});return g.set("9b33d9107e62ba8299c576072de40d24a261464f118de4ace64f23154fc78307",f),f})(),Me=g.get("f0627ba89e5c8fcb376ebe3ce72dcc8d68c34952981f8703e36b8bb1a9894208")??(()=>{const{captureFields:l}=ge;function p(s){if(!s||typeof s!="object")throw new TypeError("CSV options are required.");return l(s,["columns","signal","limits","onProgress","valueMode","delimiter","lineEnding","bom","includeHeader","headerRows","footer","spanMode","formulaInjectionProtection","quote","nullValue","booleanText"])}const f=Object.freeze({captureCsvOptions:p});return g.set("f0627ba89e5c8fcb376ebe3ce72dcc8d68c34952981f8703e36b8bb1a9894208",f),f})(),Fe=g.get("c9fde2c438e186da56f740105fcd41c265fdfdd855a4f1b811d556a02387479b")??(()=>{class l{operation;count=0;sum=0;mean=0;min=1/0;max=-1/0;constructor(o){this.operation=o}accept(o){if(!(!this.operation||typeof o!="number"||!Number.isFinite(o)))if(this.count++,this.operation==="sum"){if(this.sum+=o,!Number.isFinite(this.sum))throw new RangeError("Numeric total exceeds finite number range.")}else if(this.operation==="average"){const n=o-this.mean;this.mean=this.count===1?o:Number.isFinite(n)?this.mean+n/this.count:this.mean*((this.count-1)/this.count)+o/this.count}else this.operation==="min"?this.min=Math.min(this.min,o):this.operation==="max"&&(this.max=Math.max(this.max,o))}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 p(s,o={}){const n=s.map(e=>e.key??e.header);for(const[e,i]of Object.entries(o)){if(n.filter(r=>r===e).length!==1)throw new TypeError("Totals need an unambiguous declared column key: "+e);if(!["sum","count","average","min","max"].includes(i))throw new TypeError("Invalid total operation.")}return n.map(e=>new l(Object.prototype.hasOwnProperty.call(o,e)?o[e]:void 0))}const f=Object.freeze({NumericAggregate:l,createTotals:p});return g.set("c9fde2c438e186da56f740105fcd41c265fdfdd855a4f1b811d556a02387479b",f),f})(),Le=g.get("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a68c0")??(()=>{const{ExportCell:l,assertScalar:p}=X,{isDate:f}=fe,{checkAbort:s,inputRows:o,pause:n,taskYieldDue:e}=Q,{ExportBudget:i}=je,{OfficeIMOError:r}=re,{copyColumns:h,createRowProjector:x}=Se,{createTotals:a}=Fe,{copyExportValue:b}=ve,t=new WeakMap;function u(c){if(!c||typeof c!="object"||!t.has(c))throw new TypeError("Create grouped report sources with createGroupedReport.")}function y(c,d){return u(c),{async*[Symbol.asyncIterator](){const j=O(c,d);try{yield*j.events}finally{j.dispose()}}}}function O(c,d){u(c);const j=t.get(c),v=E(j.signal,d);return{signal:v.signal,events:j.events(v.signal),dispose:v.dispose}}function E(c,d){if(!c||!d||c===d)return{signal:c??d,dispose(){}};const j=new AbortController,v=()=>j.abort(c.reason),q=()=>j.abort(d.reason);return c.addEventListener("abort",v,{once:!0}),d.addEventListener("abort",q,{once:!0}),c.aborted?v():d.aborted&&q(),{signal:j.signal,dispose(){c.removeEventListener("abort",v),d.removeEventListener("abort",q)}}}function k(c,d,j){const v=c??d;if(!Number.isSafeInteger(v)||v<0)throw new RangeError(j+" must be a nonnegative safe integer.");return v}function z(c){return c instanceof l?c.value:c}function L(c){if(c==null)return{key:null,id:"null",text:""};if(f(c)){const j=Date.prototype.getTime.call(c);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 c=="number"&&!Number.isFinite(c))throw new TypeError("A numeric group key must be finite.");const d=String(c);return{key:c,id:typeof c+":"+d,text:d}}function Z(c){return f(c)?new Date(Date.prototype.getTime.call(c)):c}function U(c){return Object.freeze(c.map(d=>d.operation===void 0?null:d.value()))}function C(c,d,j){const v=typeof c=="string"?[c]:Array.isArray(c)?Array.from(c):void 0;if(!v||v.length<1||v.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&&v.length!==1)throw new TypeError("groupLabel is only available for one grouping level; use descriptor labels for a hierarchy.");const q=new Set;return Object.freeze(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:N,value:K,label:Y}=typeof M=="string"?{key:M,value:void 0,label:void 0}:M;if(typeof N!="string"||!N.length||q.has(N))throw new TypeError("Grouping levels need unique, nonempty stable keys.");if(q.add(N),K!==void 0&&typeof K!="function")throw new TypeError("Grouping value getters must be synchronous functions.");if(Y!==void 0&&typeof Y!="function")throw new TypeError("Grouping labels must be synchronous functions.");if(Y&&j)throw new TypeError("Specify either groupLabel or the grouping descriptor label.");const F=d.indexOf(N);if(F>=0&&K!==void 0)throw new TypeError("A declared grouping column reuses its projected value; do not provide another value getter.");if(F<0&&K===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:N,column:F,value:K,label:Y??j})}))}function B(c){return Object.freeze(c.map(({group:d})=>Object.freeze({...d,key:Z(d.key)})))}function m(c,d,j){if(!c)return j;const v=c(Z(d));if(typeof v?.then=="function"&&Promise.resolve(v).catch(()=>{}),typeof v!="string")throw new TypeError("Grouping labels must return synchronous text.");return v}function A(c,d){if(!d||typeof d!="object")throw new TypeError("Grouped report options are required.");const{columns:j,groupBy:v,totals:q,groupLabel:M,maxGroups:N,maxGroupKeyCharacters:K,signal:Y,limits:F}=d;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 I=h(j),ne=I.map(w=>w.key);if(ne.some(w=>typeof w!="string"||w.length===0)||new Set(ne).size!==ne.length)throw new TypeError("Grouped report columns need unique, nonempty stable keys.");const V=C(v,ne,M),G=Object.freeze({...q}),$=a(I,G);for(let w=0;w<I.length;w++)if($[w].operation!==void 0&&I[w].type!=="number")throw new TypeError("Grouped numeric totals require a column declared with type:number.");const oe=k(N,1e3,"maxGroups"),S=k(K,1e6,"maxGroupKeyCharacters"),D=new i(F),be=Object.freeze(I.map(w=>{const{value:he,...ye}=w;return Object.freeze(ye)}));for(const w of I){D.cell(w.header);for(const he of w.groups??[])D.reserve(0,he.length);Object.freeze(w)}let se=!1;const J=w=>Object.freeze({[Symbol.asyncIterator](){if(se)throw new TypeError("A grouped report source can be consumed only once.");return se=!0,ee(w)}}),H=J(Y);async function*ee(w){const he=x(I,void 0,w),ye=new Set,_=[];let Re=0,ae=0,me=0;for await(const ce of o(c,w)){const de=Array.isArray(ce)?Array.from(ce):ce,Ne=he(de,ae),te=[];for(let T=0;T<I.length;T++)te.push(b(Ne[T])??null);s(w);const ze=V.map((T,R)=>{s(w);const W=T.column>=0?z(te[T.column]):T.value(de,Object.freeze({rowIndex:ae,level:R,key:T.key}));return p(W),s(w),L(W)});D.row(ae+1);for(let T=0;T<te.length;T++){const R=te[T],W=z(R);if($[T].operation!==void 0&&W!=null&&(typeof W!="number"||!Number.isFinite(W)))throw new TypeError("Grouped numeric metrics must resolve to finite numbers or null.");D.cell(W),R instanceof l&&R.text!==void 0&&D.reserve(0,R.text.length)}let ie=0;for(;ie<_.length&&_[ie].id===ze[ie].id;)ie++;const xe=[];for(let T=ie;T<V.length;T++){const R=ze[T],Ee=((xe.at(-1)??_[T-1])?.group.groupIndex??-1)+":"+R.id;if(ye.has(Ee))throw new TypeError("Grouped rows must be contiguous; a closed group key occurred again within the same parent.");if(me===oe)throw new r("RESOURCE_LIMIT","maxGroups exceeded.");const Te=m(V[T].label,R.key,R.text);s(w);const ke=Re+Ee.length+Te.length;if(!Number.isSafeInteger(ke)||ke>S)throw new r("RESOURCE_LIMIT","maxGroupKeyCharacters exceeded.");D.reserve(0,Te.length),xe.push({id:R.id,group:Object.freeze({groupIndex:me,key:R.key,label:Te,level:T}),rows:0,aggregates:a(I,G)}),Re=ke,ye.add(Ee),me++}for(;_.length>ie;){s(w);const T=B(_),R=_.pop();yield Object.freeze({kind:"groupEnd",...T.at(-1),path:T,rows:R.rows,totals:U(R.aggregates)})}for(const T of xe){s(w),_.push(T);const R=B(_);yield Object.freeze({kind:"groupStart",...R.at(-1),path:R})}for(let T=0;T<te.length;T++){const R=z(te[T]);for(const W of _)W.aggregates[T].accept(R);$[T].accept(R)}for(const T of _)T.rows++;s(w),yield Object.freeze({kind:"row",values:Object.freeze(te),rowIndex:ae,groupIndex:_.at(-1).group.groupIndex,path:B(_)}),ae++,e()&&(await n(),s(w))}for(s(w);_.length;){s(w);const ce=B(_),de=_.pop();yield Object.freeze({kind:"groupEnd",...ce.at(-1),path:ce,rows:de.rows,totals:U(de.aggregates)})}s(w),yield Object.freeze({kind:"complete",rows:ae,groups:me,totals:U($)})}const ue=Object.freeze({columns:be,groupBy:Object.freeze(V.map(w=>w.key)),totals:G,events:H});return t.set(ue,{signal:Y,events:J}),ue}const P=Object.freeze({assertGroupedReportSource:u,groupedReportEvents:y,groupedReportOperation:O,createGroupedReport:A});return g.set("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a68c0",P),P})(),Ae=g.get("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00")??(()=>{const{OfficeIMOError:l}=re;function p(){let o=!1;if(typeof CompressionStream=="function")try{new CompressionStream("deflate-raw"),o=!0}catch{}return{blob:typeof Blob=="function",streams:typeof WritableStream=="function",deflateRaw:o,download:typeof document<"u"&&typeof URL.createObjectURL=="function"}}function f(o,n){if(!(o instanceof Blob)||typeof n!="string"||!n)throw new TypeError("A Blob and file name are required.");if(typeof document>"u"||typeof URL.createObjectURL!="function")throw new l("PLATFORM_UNAVAILABLE","saveBlob requires a browser document and object URLs.");const e=URL.createObjectURL(o),i=document.createElement("a");try{i.href=e,i.download=n,document.body.append(i),i.click()}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(e),3e4)}}const s=Object.freeze({OfficeIMOError:re.OfficeIMOError,NotSupportedError:re.NotSupportedError,BlobByteSink:pe.BlobByteSink,ChunkedTextSink:pe.ChunkedTextSink,writeBytes:pe.writeBytes,ExportCell:X.ExportCell,createGroupedReport:Le.createGroupedReport,checkAbort:Q.checkAbort,withAbort:Q.withAbort,inputRows:Q.inputRows,pause:Q.pause,detectFeatures:p,saveBlob:f});return g.set("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00",s),s})(),Ce=g.get("b48bcab805d4c75294dd8d8e8dc57f96d9db3f5af31a8f0ddc6562f010f566e4")??(()=>{const{beginTask:l,checkAbort:p,consumeRows:f,taskYieldDue:s,withAbort:o}=Q,{BlobByteSink:n,ChunkedTextSink:e,withDestination:i}=pe,{ExportBudget:r,boundedSink:h}=je,{ExportCell:x}=X,{isDate:a}=fe,{notifyProgress:b}=Be,{copyColumns:t,createRowProjector:u}=Se,{csvStructuredRows:y}=_e,{captureBooleanText:O}=De,{captureCsvOptions:E}=Me;function k(C,B,m,A,P){const c=typeof C;let d;if(C==null)d="";else if(c==="string")d=C;else{if(c==="number")return d=Number.isFinite(C)?String(C):"",A==="all"?'"'+d+'"':d;if(c==="boolean")d=P[C?"true":"false"];else if(a(C))d=Number.isFinite(C.getTime())?C.toISOString():"";else throw typeof C.then=="function"&&Promise.resolve(C).catch(()=>{}),new TypeError("CSV cells and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}return m&&(c==="string"||c==="boolean")&&d.charCodeAt(0)<=64&&/^ *[=+\-@\t\r\n]/.test(d)&&(d="'"+d),A==="all"||A==="strings"&&c==="string"||d.includes(B)||/["\r\n]/.test(d)?'"'+(d.includes('"')?d.replace(/"/g,'""'):d)+'"':d}async function z(C,B,m){const A=E(m);return i(B,P=>L(C,P,A))}async function L(C,B,m){l();const A=t(m.columns).map(S=>Object.freeze(S)),P=m.delimiter??",",c=m.lineEnding??"\r\n",d=m.quote??"minimal",j=O(m.booleanText);if(![",",";"," "].includes(P))throw new RangeError("Delimiter must be comma, semicolon or tab.");if(!["\r\n","\n","\r"].includes(c))throw new RangeError("Invalid line ending.");if(!["minimal","all","strings"].includes(d))throw new RangeError("Quoting must be minimal, all or strings.");if(m.valueMode!==void 0&&!["raw","display"].includes(m.valueMode))throw new RangeError("valueMode must be raw or display.");if(m.nullValue!==void 0&&typeof m.nullValue!="string")throw new TypeError("nullValue must be a string.");if(m.spanMode!==void 0&&m.spanMode!=="repeat"&&m.spanMode!=="anchors")throw new TypeError("CSV spanMode must be repeat or anchors.");const v=m.includeHeader===!1?[]:m.headerRows===void 0?A.length?[A.map(S=>S.header)]:[]:y(m.headerRows,A.length,m.spanMode),q=m.footer===void 0?[]:y(m.footer.rows,A.length,m.spanMode);for(const S of A)if(S.valueFormatter!==void 0&&typeof S.valueFormatter!="function")throw new TypeError("CSV value formatters must be functions.");const M=new r(m.limits);let N=0;const K=B;B=h({async write(S){await K.write(S),N+=S.byteLength}},M);const Y=u(A,void 0,m.signal),F=A.some(S=>S.valueFormatter),I=m.signal,ne=m.formulaInjectionProtection!==!1,V=new e(B,I);p(I),m.bom&&await o(Promise.resolve(B.write(new Uint8Array([239,187,191]))),I);let G=0;const $=S=>S!==null&&typeof S=="object"&&S instanceof x?m.valueMode==="display"&&S.text!==void 0?S.text:S.value:S;function oe(S,D=!1,be=0,se){!D&&F&&be===0&&(se=Object.freeze(A.map((H,ee)=>$(S[ee]))));let J="";for(let H=be;H<A.length;H++){p(I);const ee=A[H],ue=$(S[H]);let w=!D&&ee.valueFormatter?ee.valueFormatter(ue,{rowIndex:G,columnIndex:H,column:ee,values:se}):ue;if(w==null&&m.nullValue!==void 0&&(w=m.nullValue),M.cell(typeof w=="boolean"?j[w?"true":"false"]:w),p(I),J+=(H?P:"")+k(w,P,ne,d,j),J.length>=V.chunkSize||(H&127)===127&&s()){if(V.append(J))return V.flush().then(()=>oe(S,D,H+1,se));J=""}}if(V.append(J+c))return V.flush().then(()=>{b(m.onProgress,{phase:"rows",rows:G+(D?0:1)})})}for(const S of v)await oe(S,!0);await f(C,I,S=>{M.row(G+1);const D=oe(Y(S,G));if(D)return D.then(()=>{G++});G++});for(const S of q)await oe(S,!0);return await V.close(),b(m.onProgress,{phase:"complete",rows:G,bytes:N}),p(I),{rows:G,columns:A.length,bytes:N}}async function Z(C,B){const m=E(B),A=new n;try{let P=0;await L(C,A,{...m,onProgress:d=>{d.phase==="complete"?P=d.rows:b(m.onProgress,d)}});const c=A.toBlob("text/csv;charset=utf-8");return b(m.onProgress,{phase:"complete",rows:P,bytes:c.size}),p(m.signal),c}catch(P){throw A.discard(),P}}const U=Object.freeze({saveBlob:Ae.saveBlob,ExportCell:X.ExportCell,writeCsvTo:z,writeCsv:Z});return g.set("b48bcab805d4c75294dd8d8e8dc57f96d9db3f5af31a8f0ddc6562f010f566e4",U),U})();Object.assign(le,Ce,{core:Ae,csv:Ce})})(globalThis);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Generated by OfficeIMO.JavaScript/scripts/bundles.mjs from tsc output. MIT.
|
|
2
|
+
const Q=(()=>{function f(t){if(t?.aborted)throw t.reason}function y(t,c){return c?new Promise((m,k)=>{const x=()=>c.removeEventListener("abort",T),T=()=>{x(),k(c.reason)};c.addEventListener("abort",T,{once:!0}),Promise.resolve(t).then(R=>{x(),m(R)},R=>{x(),k(R)}),c.aborted&&T()}):Promise.resolve(t)}async function*d(t,c){f(c);const m=t?.[Symbol.asyncIterator]?.()??t?.[Symbol.iterator]?.();if(!m)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let k=!1,x=!1;try{for(;;){f(c);const T=await y(Promise.resolve(m.next()),c);if(f(c),T.done){k=!0;return}yield T.value}}catch(T){throw x=!0,T}finally{if(!k&&m.return)try{const T=m.return();c?.aborted||x?Promise.resolve(T).catch(()=>{}):await y(Promise.resolve(T),c)}catch(T){if(!c?.aborted&&!x)throw T}}}const i=new WeakMap;function a(t){let c=!1;const m=()=>{if(c)throw new TypeError("A row source can be consumed only once.");c=!0},k={[Symbol.asyncIterator](){return m(),x()}};async function*x(){for await(const T of d(t))yield*T}return i.set(k,(T,R)=>(m(),e(t,T,M=>e(M,T,R)))),k}function n(...t){const c={async*[Symbol.asyncIterator](){for(const m of t)yield*m}};return i.set(c,async(m,k)=>{for(const x of t)await e(x,m,k)}),c}async function e(t,c,m){f(c);const k=i.get(t);if(k)return k(c,m);const x=t?.[Symbol.asyncIterator]?.()??t?.[Symbol.iterator]?.();if(!x)throw new TypeError("Rows must be a synchronous or asynchronous iterable.");let T=!1;try{for(;;){f(c);let R=x.next();const M=R;typeof M?.then=="function"&&(R=await y(M,c)),f(c);const J=R;if(J.done){T=!0;return}let q=J.value;typeof q?.then=="function"&&(q=await y(q,c)),f(c);const A=m(q);A!==void 0&&await y(A,c)}}finally{if(!T&&x.return)try{Promise.resolve(x.return()).catch(()=>{})}catch{}}}let l;const r=32;function p(){l=performance.now()+r}function g(){const t=performance.now();return l??=t+r,t>=l}function o(){const t=globalThis.scheduler;return typeof t?.postTask=="function"?t.postTask(()=>{l=performance.now()+r},{priority:"user-visible"}):new Promise(c=>{setTimeout(function(){l=performance.now()+r,c()},0)})}return Object.freeze({checkAbort:f,withAbort:y,inputRows:d,rowsFromBatches:a,concatRows:n,consumeRows:e,beginTask:p,taskYieldDue:g,pause:o})})(),ae=(()=>{const f=Symbol.for("@evotecit/officeimo/OfficeIMOError"),y=Symbol.for("@evotecit/officeimo/NotSupportedError");class d extends Error{code;static[Symbol.hasInstance](e){return this!==d?Function.prototype[Symbol.hasInstance].call(this,e):!!e&&typeof e=="object"&&e[f]===!0}constructor(e,l,r){super(l,r),this.code=e,Object.defineProperty(this,f,{value:!0}),this.name="OfficeIMOError"}}class i extends d{feature;static[Symbol.hasInstance](e){return this!==i?Function.prototype[Symbol.hasInstance].call(this,e):!!e&&typeof e=="object"&&e[y]===!0}constructor(e){super("NOT_SUPPORTED",e+" is not supported yet."),this.feature=e,Object.defineProperty(this,y,{value:!0}),this.name="NotSupportedError"}}return Object.freeze({OfficeIMOError:d,NotSupportedError:i})})(),ye=(()=>{const{checkAbort:f,consumeRows:y,withAbort:d,pause:i,taskYieldDue:a}=Q,{OfficeIMOError:n}=ae;async function e(o,h){if(o&&typeof o.getWriter=="function"){const t=o.getWriter();try{return await h({write:c=>t.write(new Uint8Array(c))})}finally{t.releaseLock()}}if(!o||typeof o.write!="function")throw new TypeError("Destination must be a ByteSink or WritableStream.");return h(o)}class l{parts=[];state="open";result;write(h){if(this.state!=="open")throw new n("INVALID_STATE","Byte sink is closed.");this.parts.push(new Uint8Array(h))}toBlob(h="application/octet-stream"){if(this.state==="discarded")throw new n("INVALID_STATE","Byte sink was discarded.");return this.state="closed",this.result||(this.result=new Blob(this.parts,{type:h}),this.parts=[]),this.result.type===h?this.result:new Blob([this.result],{type:h})}takeChunks(){if(this.state!=="open")throw new n("INVALID_STATE","Byte sink is closed.");const h=this.parts;return this.parts=[],this.state="discarded",h}discard(){this.parts=[],this.result=void 0,this.state="discarded"}}class r{sink;signal;chunkSize;text="";encoder=new TextEncoder;constructor(h,t,c=32768){if(this.sink=h,this.signal=t,this.chunkSize=c,!Number.isInteger(c)||c<2)throw new RangeError("Text chunk size must be at least 2.")}append(h){return f(this.signal),this.text+=h,this.text.length>=this.chunkSize||a()}async flush(h=!1){for(f(this.signal);this.text.length;){let t=Math.min(this.text.length,this.chunkSize);if(/[\ud800-\udbff]/.test(this.text[t-1])&&(t<this.text.length||!h)&&t--,!t)break;const c=this.encoder.encode(this.text.slice(0,t));this.text=this.text.slice(t),await d(Promise.resolve(this.sink.write(c)),this.signal),a()&&await i(),f(this.signal)}}async write(h){this.append(h)&&await this.flush()}async close(){await this.flush(!0)}}async function p(o,h,t){await y(o instanceof Uint8Array?[o]:o,t,c=>{if(!(c instanceof Uint8Array))throw new TypeError("Byte sources must yield Uint8Array chunks.");const m=h.write(c);return a()?Promise.resolve(m).then(()=>(f(t),i())):m})}return Object.freeze({withDestination:e,BlobByteSink:l,ChunkedTextSink:r,writeBytes:p})})(),xe=(()=>{function f(d,i){const a={...d};for(const n of i){if(Object.hasOwn(a,n))continue;const e=d[n];e!==void 0&&(a[n]=e)}return a}return Object.freeze({captureFields:f})})(),ke=(()=>{const{OfficeIMOError:f}=ae,{captureFields:y}=xe;class d{cells=0;text=0;reservedCells=0;reservedText=0;limits;constructor(e={}){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Export limits must be an object.");const l=y(e,["maxRows","maxCells","maxTextCharacters","maxOutputBytes"]);for(const[r,p]of Object.entries(l))if(p!==void 0&&(!Number.isSafeInteger(p)||p<0))throw new RangeError(r+" must be a nonnegative safe integer.");this.limits=Object.freeze(l)}check(e,l){const r=this.limits[e];if(r!==void 0&&l>r)throw new f("RESOURCE_LIMIT",e+" exceeded ("+l+" > "+r+").")}row(e){this.check("maxRows",e)}reserve(e,l){this.check("maxCells",this.cells+this.reservedCells+e),this.check("maxTextCharacters",this.text+this.reservedText+l),this.reservedCells+=e,this.reservedText+=l}release(e,l){this.reservedCells-=e,this.reservedText-=l}cell(e,l){if(l!==void 0&&this.release(1,l),this.limits.maxCells===void 0&&this.limits.maxTextCharacters===void 0)return;this.check("maxCells",this.cells+this.reservedCells+1);const r=typeof e=="string"?e.length:0;this.check("maxTextCharacters",this.text+this.reservedText+r),this.cells++,this.text+=r}}function i(n,e){let l=0;return{write(r){return e.check("maxOutputBytes",l+r.length),l+=r.length,n.write(r)}}}return Object.freeze({ExportBudget:d,boundedSink:i})})(),le=(()=>{function f(d){if(d===null||typeof d!="object")return!1;try{return!(d instanceof Date)&&!(Symbol.toStringTag in d)&&Object.prototype.toString.call(d)!=="[object Date]"?!1:(Date.prototype.getTime.call(d),!0)}catch{return!1}}return Object.freeze({isDate:f})})(),ve=(()=>{function f(d){if(!d||typeof d!="object")throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const{target:i,tooltip:a}=d;if(typeof i!="string"||!/^(?:https?:\/\/|mailto:)/i.test(i)||/[\u0000-\u0020\u007f]/.test(i))throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");const n=new URL(i);if((n.protocol==="http:"||n.protocol==="https:")&&(!n.hostname||n.username||n.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:n.href,...a===void 0?{}:{tooltip:a}})}return Object.freeze({copyExportLink:f})})(),ee=(()=>{const{isDate:f}=le,{copyExportLink:y}=ve,d=Symbol.for("@evotecit/officeimo/ExportCell");function i(r){if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError("Cell presentation must be an object.");const p={};for(const g of["background","color","numberFormat","bold","italic","wrapText","alignment"]){const o=r[g];if(o!==void 0){if(["bold","italic","wrapText"].includes(g)){if(typeof o!="boolean")throw new TypeError("Cell presentation "+g+" must be boolean.")}else if(typeof o!="string")throw new TypeError("Cell presentation "+g+" must be text.");if(g==="alignment"&&!["left","center","right","fill","justify","distributed"].includes(o))throw new TypeError("Invalid cell presentation alignment.");p[g]=o}}return Object.freeze(p)}class a{value;static[Symbol.hasInstance](p){return!!p&&typeof p=="object"&&p[d]===!0}text;presentation;link;constructor(p,g={}){this.value=p;const{text:o,presentation:h,link:t}=g;if(o!==void 0&&typeof o!="string")throw new TypeError("Display text must be a string.");n(p),this.text=o,this.presentation=h===void 0?void 0:i(h),this.link=t===void 0?void 0:y(t),Object.defineProperty(this,d,{value:!0}),Object.freeze(this)}}function n(r){const p=typeof r;if(!(r==null||p==="string"||p==="number"||p==="boolean"||f(r)))throw typeof r.then=="function"&&Promise.resolve(r).catch(()=>{}),new TypeError("Export values and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}function e(r){r!==null&&typeof r=="object"&&r instanceof a||n(r)}return Object.freeze({copyCellPresentation:i,ExportCell:a,assertScalar:n,assertExportValue:e})})(),Ae=(()=>{function f(d,i){if(!d)return;const a=d(i);if(a&&typeof a.then=="function")throw Promise.resolve(a).catch(()=>{}),new TypeError("onProgress must be synchronous.")}return Object.freeze({notifyProgress:f})})(),Oe=(()=>{const{assertExportValue:f}=ee,{checkAbort:y}=Q,{isDate:d}=le,{captureFields:i}=xe;function a(r,p,g,o=f){const h=r.some(t=>t.value);return(t,c=0)=>{if(Array.isArray(t)&&!h){const m=t.length;if(m>r.length)throw new RangeError("Row has more values than declared columns.");const k=new Array(m);for(let x=0;x<m;x++){const T=t[x];o(T),k[x]=T}return k}if(!t||typeof t!="object"||d(t))throw new TypeError("A row must be an array or object.");if(Array.isArray(t)&&t.length>r.length&&!r.every(m=>m.value))throw new RangeError("Project every column explicitly when selecting from a wider array row.");return r.map((m,k)=>{if(m.value){y(g);const R={rowIndex:c,columnIndex:k,column:m,...p?{sheetName:p.sheetName,worksheetRow:p.firstDataRow+c}:{}},M=m.value(t,R);return o(M),y(g),M}if(Array.isArray(t)){const R=t[k];return o(R),R}const x=m.key??m.header,T=Object.prototype.hasOwnProperty.call(t,x)?t[x]:void 0;return o(T),T})}}const n=["header","key","value","width","type","format","wrapText","alignment","rowHeader","groups","style","valueFormatter"];function e(r,p=!1){if(!Array.isArray(r))throw new TypeError("Declare the columns in export order.");return r.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 o=i(g,n);if(!p&&o.style!==void 0)throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");if(typeof o.header!="string"||o.key!==void 0&&typeof o.key!="string")throw new TypeError("Each column needs a string header and an optional string key.");if(o.value!==void 0&&typeof o.value!="function")throw new TypeError("Column value getters must be functions.");if(o.rowHeader!==void 0&&typeof o.rowHeader!="boolean")throw new TypeError("Column rowHeader must be boolean.");if(o.groups!==void 0){if(!Array.isArray(o.groups))throw new TypeError("Column groups must be an array of strings.");const h=Array.from(o.groups);if(h.some(t=>typeof t!="string"))throw new TypeError("Column groups must be an array of strings.");return{...o,groups:Object.freeze(h)}}return o})}return Object.freeze({createRowProjector:a,columnOptionFields:n,copyColumns:e})})(),je=(()=>{const{ExportCell:f,assertExportValue:y}=ee,{isDate:d}=le;function i(n){if(y(n),d(n))return new Date(Date.prototype.getTime.call(n));if(n instanceof f){const{value:e,text:l,presentation:r,link:p}=n;return new f(d(e)?new Date(Date.prototype.getTime.call(e)):e,{...l===void 0?{}:{text:l},...r===void 0?{}:{presentation:r},...p===void 0?{}:{link:p}})}return n}return Object.freeze({copyExportValue:i})})(),Ce=(()=>{const{assertExportValue:f}=ee,{copyExportValue:y}=je;function d(n,e){if(!Array.isArray(n)||!n.length||n.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const l=n.map(r=>{if(!Array.isArray(r)||r.length!==e)throw new TypeError("Spanned rows must have the declared column count.");return Object.freeze(r.map(p=>{if(p===null)return null;if(!p||typeof p!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const{value:g,columnSpan:o,rowSpan:h}=p;return Object.freeze({value:y(g),...o===void 0?{}:{columnSpan:o},...h===void 0?{}:{rowSpan:h}})}))});return i(l,e),Object.freeze(l)}function i(n,e){if(!Array.isArray(n)||!n.length||n.length>16)throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");const l=Array.from({length:n.length},()=>new Uint8Array(e));return n.map((r,p)=>{if(!Array.isArray(r)||r.length!==e)throw new TypeError("Spanned rows must have the declared column count.");const g=[];for(let o=0;o<e;o++){const h=r[o];if(l[p][o]){if(h!==null)throw new TypeError("Covered heading/footer cells must be null.");continue}if(!h||typeof h!="object")throw new TypeError("Uncovered heading/footer cells need an anchor value.");const t=h.columnSpan??1,c=h.rowSpan??1;if(!Number.isInteger(t)||!Number.isInteger(c)||t<1||c<1||o+t>e||p+c>n.length)throw new RangeError("Heading/footer spans must stay inside the declared matrix.");const m=h.value;f(m);for(let k=p;k<p+c;k++)for(let x=o;x<o+t;x++){if(l[k][x])throw new TypeError("Heading/footer spans overlap.");if((k!==p||x!==o)&&n[k]?.[x]!==null)throw new TypeError("Covered heading/footer cells must be null.");l[k][x]=1}g.push(Object.freeze({first:o,span:t,rowSpan:c,value:m}))}return Object.freeze(g)})}return Object.freeze({captureTableSpans:d,tableSpans:i})})(),Re=(()=>{const{captureTableSpans:f,tableSpans:y}=Ce;function d(a,n,e){const l=y(f(a,n),n),r=l.map(()=>Array(n).fill(""));for(let p=0;p<l.length;p++)for(const g of l[p]){if((g.span>1||g.rowSpan>1)&&e===void 0)throw new TypeError("CSV spanned headings/footers require an explicit spanMode: repeat or anchors.");const o=g.value;for(let h=p;h<p+(e==="repeat"?g.rowSpan:1);h++)for(let t=g.first;t<g.first+(e==="repeat"?g.span:1);t++)r[h][t]=o}return r}return Object.freeze({csvStructuredRows:d})})(),_e=(()=>{const f=Object.freeze({true:"True",false:"False"});function y(i){if(i===void 0)return f;if(!i||typeof i!="object")throw new TypeError("booleanText must contain true and false strings.");const a=i.true,n=i.false;if(typeof a!="string"||typeof n!="string")throw new TypeError("booleanText must contain true and false strings.");return Object.freeze({true:a,false:n})}return Object.freeze({defaultBooleanText:f,captureBooleanText:y})})(),ze=(()=>{const{captureFields:f}=xe;function y(i){if(!i||typeof i!="object")throw new TypeError("CSV options are required.");return f(i,["columns","signal","limits","onProgress","valueMode","delimiter","lineEnding","bom","includeHeader","headerRows","footer","spanMode","formulaInjectionProtection","quote","nullValue","booleanText"])}return Object.freeze({captureCsvOptions:y})})(),Be=(()=>{class f{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 n=a-this.mean;this.mean=this.count===1?a:Number.isFinite(n)?this.mean+n/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 y(i,a={}){const n=i.map(e=>e.key??e.header);for(const[e,l]of Object.entries(a)){if(n.filter(r=>r===e).length!==1)throw new TypeError("Totals need an unambiguous declared column key: "+e);if(!["sum","count","average","min","max"].includes(l))throw new TypeError("Invalid total operation.")}return n.map(e=>new f(Object.prototype.hasOwnProperty.call(a,e)?a[e]:void 0))}return Object.freeze({NumericAggregate:f,createTotals:y})})(),Ie=(()=>{const{ExportCell:f,assertScalar:y}=ee,{isDate:d}=le,{checkAbort:i,inputRows:a,pause:n,taskYieldDue:e}=Q,{ExportBudget:l}=ke,{OfficeIMOError:r}=ae,{copyColumns:p,createRowProjector:g}=Oe,{createTotals:o}=Be,{copyExportValue:h}=je,t=new WeakMap;function c(s){if(!s||typeof s!="object"||!t.has(s))throw new TypeError("Create grouped report sources with createGroupedReport.")}function m(s,u){return c(s),{async*[Symbol.asyncIterator](){const O=k(s,u);try{yield*O.events}finally{O.dispose()}}}}function k(s,u){c(s);const O=t.get(s),S=x(O.signal,u);return{signal:S.signal,events:O.events(S.signal),dispose:S.dispose}}function x(s,u){if(!s||!u||s===u)return{signal:s??u,dispose(){}};const O=new AbortController,S=()=>O.abort(s.reason),V=()=>O.abort(u.reason);return s.addEventListener("abort",S,{once:!0}),u.addEventListener("abort",V,{once:!0}),s.aborted?S():u.aborted&&V(),{signal:O.signal,dispose(){s.removeEventListener("abort",S),u.removeEventListener("abort",V)}}}function T(s,u,O){const S=s??u;if(!Number.isSafeInteger(S)||S<0)throw new RangeError(O+" must be a nonnegative safe integer.");return S}function R(s){return s instanceof f?s.value:s}function M(s){if(s==null)return{key:null,id:"null",text:""};if(d(s)){const O=Date.prototype.getTime.call(s);if(!Number.isFinite(O))throw new TypeError("A group key date must be valid.");return{key:new Date(O),id:"date:"+O,text:new Date(O).toISOString()}}if(typeof s=="number"&&!Number.isFinite(s))throw new TypeError("A numeric group key must be finite.");const u=String(s);return{key:s,id:typeof s+":"+u,text:u}}function J(s){return d(s)?new Date(Date.prototype.getTime.call(s)):s}function q(s){return Object.freeze(s.map(u=>u.operation===void 0?null:u.value()))}function A(s,u,O){const S=typeof s=="string"?[s]:Array.isArray(s)?Array.from(s):void 0;if(!S||S.length<1||S.length>4)throw new TypeError("groupBy must declare between one and four grouping levels.");if(O!==void 0&&typeof O!="function")throw new TypeError("groupLabel must be a synchronous function.");if(O&&S.length!==1)throw new TypeError("groupLabel is only available for one grouping level; use descriptor labels for a hierarchy.");const V=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:L,value:W,label:Y}=typeof D=="string"?{key:D,value:void 0,label:void 0}:D;if(typeof L!="string"||!L.length||V.has(L))throw new TypeError("Grouping levels need unique, nonempty stable keys.");if(V.add(L),W!==void 0&&typeof W!="function")throw new TypeError("Grouping value getters must be synchronous functions.");if(Y!==void 0&&typeof Y!="function")throw new TypeError("Grouping labels must be synchronous functions.");if(Y&&O)throw new TypeError("Specify either groupLabel or the grouping descriptor label.");const F=u.indexOf(L);if(F>=0&&W!==void 0)throw new TypeError("A declared grouping column reuses its projected value; do not provide another value getter.");if(F<0&&W===void 0)throw new TypeError("groupBy must name a declared stable column key; hidden grouping fields need an explicit value getter.");return Object.freeze({key:L,column:F,value:W,label:Y??O})}))}function z(s){return Object.freeze(s.map(({group:u})=>Object.freeze({...u,key:J(u.key)})))}function w(s,u,O){if(!s)return O;const S=s(J(u));if(typeof S?.then=="function"&&Promise.resolve(S).catch(()=>{}),typeof S!="string")throw new TypeError("Grouping labels must return synchronous text.");return S}function v(s,u){if(!u||typeof u!="object")throw new TypeError("Grouped report options are required.");const{columns:O,groupBy:S,totals:V,groupLabel:D,maxGroups:L,maxGroupKeyCharacters:W,signal:Y,limits:F}=u;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(O)||!O.length)throw new TypeError("A grouped report needs declared columns.");const _=p(O),te=_.map(b=>b.key);if(te.some(b=>typeof b!="string"||b.length===0)||new Set(te).size!==te.length)throw new TypeError("Grouped report columns need unique, nonempty stable keys.");const G=A(S,te,D),N=Object.freeze({...V}),X=o(_,N);for(let b=0;b<_.length;b++)if(X[b].operation!==void 0&&_[b].type!=="number")throw new TypeError("Grouped numeric totals require a column declared with type:number.");const re=T(L,1e3,"maxGroups"),j=T(W,1e6,"maxGroupKeyCharacters"),I=new l(F),fe=Object.freeze(_.map(b=>{const{value:pe,...de}=b;return Object.freeze(de)}));for(const b of _){I.cell(b.header);for(const pe of b.groups??[])I.reserve(0,pe.length);Object.freeze(b)}let ne=!1;const K=b=>Object.freeze({[Symbol.asyncIterator](){if(ne)throw new TypeError("A grouped report source can be consumed only once.");return ne=!0,Z(b)}}),U=K(Y);async function*Z(b){const pe=g(_,void 0,b),de=new Set,B=[];let Ee=0,oe=0,he=0;for await(const se of a(s,b)){const ue=Array.isArray(se)?Array.from(se):se,Se=pe(ue,oe),$=[];for(let E=0;E<_.length;E++)$.push(h(Se[E])??null);i(b);const Te=G.map((E,C)=>{i(b);const H=E.column>=0?R($[E.column]):E.value(ue,Object.freeze({rowIndex:oe,level:C,key:E.key}));return y(H),i(b),M(H)});I.row(oe+1);for(let E=0;E<$.length;E++){const C=$[E],H=R(C);if(X[E].operation!==void 0&&H!=null&&(typeof H!="number"||!Number.isFinite(H)))throw new TypeError("Grouped numeric metrics must resolve to finite numbers or null.");I.cell(H),C instanceof f&&C.text!==void 0&&I.reserve(0,C.text.length)}let ie=0;for(;ie<B.length&&B[ie].id===Te[ie].id;)ie++;const me=[];for(let E=ie;E<G.length;E++){const C=Te[E],we=((me.at(-1)??B[E-1])?.group.groupIndex??-1)+":"+C.id;if(de.has(we))throw new TypeError("Grouped rows must be contiguous; a closed group key occurred again within the same parent.");if(he===re)throw new r("RESOURCE_LIMIT","maxGroups exceeded.");const be=w(G[E].label,C.key,C.text);i(b);const ge=Ee+we.length+be.length;if(!Number.isSafeInteger(ge)||ge>j)throw new r("RESOURCE_LIMIT","maxGroupKeyCharacters exceeded.");I.reserve(0,be.length),me.push({id:C.id,group:Object.freeze({groupIndex:he,key:C.key,label:be,level:E}),rows:0,aggregates:o(_,N)}),Ee=ge,de.add(we),he++}for(;B.length>ie;){i(b);const E=z(B),C=B.pop();yield Object.freeze({kind:"groupEnd",...E.at(-1),path:E,rows:C.rows,totals:q(C.aggregates)})}for(const E of me){i(b),B.push(E);const C=z(B);yield Object.freeze({kind:"groupStart",...C.at(-1),path:C})}for(let E=0;E<$.length;E++){const C=R($[E]);for(const H of B)H.aggregates[E].accept(C);X[E].accept(C)}for(const E of B)E.rows++;i(b),yield Object.freeze({kind:"row",values:Object.freeze($),rowIndex:oe,groupIndex:B.at(-1).group.groupIndex,path:z(B)}),oe++,e()&&(await n(),i(b))}for(i(b);B.length;){i(b);const se=z(B),ue=B.pop();yield Object.freeze({kind:"groupEnd",...se.at(-1),path:se,rows:ue.rows,totals:q(ue.aggregates)})}i(b),yield Object.freeze({kind:"complete",rows:oe,groups:he,totals:q(X)})}const ce=Object.freeze({columns:fe,groupBy:Object.freeze(G.map(b=>b.key)),totals:N,events:U});return t.set(ce,{signal:Y,events:K}),ce}return Object.freeze({assertGroupedReportSource:c,groupedReportEvents:m,groupedReportOperation:k,createGroupedReport:v})})(),Pe=(()=>{const{OfficeIMOError:f}=ae;function y(){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 d(a,n){if(!(a instanceof Blob)||typeof n!="string"||!n)throw new TypeError("A Blob and file name are required.");if(typeof document>"u"||typeof URL.createObjectURL!="function")throw new f("PLATFORM_UNAVAILABLE","saveBlob requires a browser document and object URLs.");const e=URL.createObjectURL(a),l=document.createElement("a");try{l.href=e,l.download=n,document.body.append(l),l.click()}finally{l.remove(),setTimeout(()=>URL.revokeObjectURL(e),3e4)}}return Object.freeze({OfficeIMOError:ae.OfficeIMOError,NotSupportedError:ae.NotSupportedError,BlobByteSink:ye.BlobByteSink,ChunkedTextSink:ye.ChunkedTextSink,writeBytes:ye.writeBytes,ExportCell:ee.ExportCell,createGroupedReport:Ie.createGroupedReport,checkAbort:Q.checkAbort,withAbort:Q.withAbort,inputRows:Q.inputRows,pause:Q.pause,detectFeatures:y,saveBlob:d})})(),De=(()=>{const{beginTask:f,checkAbort:y,consumeRows:d,taskYieldDue:i,withAbort:a}=Q,{BlobByteSink:n,ChunkedTextSink:e,withDestination:l}=ye,{ExportBudget:r,boundedSink:p}=ke,{ExportCell:g}=ee,{isDate:o}=le,{notifyProgress:h}=Ae,{copyColumns:t,createRowProjector:c}=Oe,{csvStructuredRows:m}=Re,{captureBooleanText:k}=_e,{captureCsvOptions:x}=ze;function T(A,z,w,v,P){const s=typeof A;let u;if(A==null)u="";else if(s==="string")u=A;else{if(s==="number")return u=Number.isFinite(A)?String(A):"",v==="all"?'"'+u+'"':u;if(s==="boolean")u=P[A?"true":"false"];else if(o(A))u=Number.isFinite(A.getTime())?A.toISOString():"";else throw typeof A.then=="function"&&Promise.resolve(A).catch(()=>{}),new TypeError("CSV cells and formatter results must be synchronous strings, numbers, booleans, Dates or null.")}return w&&(s==="string"||s==="boolean")&&u.charCodeAt(0)<=64&&/^ *[=+\-@\t\r\n]/.test(u)&&(u="'"+u),v==="all"||v==="strings"&&s==="string"||u.includes(z)||/["\r\n]/.test(u)?'"'+(u.includes('"')?u.replace(/"/g,'""'):u)+'"':u}async function R(A,z,w){const v=x(w);return l(z,P=>M(A,P,v))}async function M(A,z,w){f();const v=t(w.columns).map(j=>Object.freeze(j)),P=w.delimiter??",",s=w.lineEnding??"\r\n",u=w.quote??"minimal",O=k(w.booleanText);if(![",",";"," "].includes(P))throw new RangeError("Delimiter must be comma, semicolon or tab.");if(!["\r\n","\n","\r"].includes(s))throw new RangeError("Invalid line ending.");if(!["minimal","all","strings"].includes(u))throw new RangeError("Quoting must be minimal, all or strings.");if(w.valueMode!==void 0&&!["raw","display"].includes(w.valueMode))throw new RangeError("valueMode must be raw or display.");if(w.nullValue!==void 0&&typeof w.nullValue!="string")throw new TypeError("nullValue must be a string.");if(w.spanMode!==void 0&&w.spanMode!=="repeat"&&w.spanMode!=="anchors")throw new TypeError("CSV spanMode must be repeat or anchors.");const S=w.includeHeader===!1?[]:w.headerRows===void 0?v.length?[v.map(j=>j.header)]:[]:m(w.headerRows,v.length,w.spanMode),V=w.footer===void 0?[]:m(w.footer.rows,v.length,w.spanMode);for(const j of v)if(j.valueFormatter!==void 0&&typeof j.valueFormatter!="function")throw new TypeError("CSV value formatters must be functions.");const D=new r(w.limits);let L=0;const W=z;z=p({async write(j){await W.write(j),L+=j.byteLength}},D);const Y=c(v,void 0,w.signal),F=v.some(j=>j.valueFormatter),_=w.signal,te=w.formulaInjectionProtection!==!1,G=new e(z,_);y(_),w.bom&&await a(Promise.resolve(z.write(new Uint8Array([239,187,191]))),_);let N=0;const X=j=>j!==null&&typeof j=="object"&&j instanceof g?w.valueMode==="display"&&j.text!==void 0?j.text:j.value:j;function re(j,I=!1,fe=0,ne){!I&&F&&fe===0&&(ne=Object.freeze(v.map((U,Z)=>X(j[Z]))));let K="";for(let U=fe;U<v.length;U++){y(_);const Z=v[U],ce=X(j[U]);let b=!I&&Z.valueFormatter?Z.valueFormatter(ce,{rowIndex:N,columnIndex:U,column:Z,values:ne}):ce;if(b==null&&w.nullValue!==void 0&&(b=w.nullValue),D.cell(typeof b=="boolean"?O[b?"true":"false"]:b),y(_),K+=(U?P:"")+T(b,P,te,u,O),K.length>=G.chunkSize||(U&127)===127&&i()){if(G.append(K))return G.flush().then(()=>re(j,I,U+1,ne));K=""}}if(G.append(K+s))return G.flush().then(()=>{h(w.onProgress,{phase:"rows",rows:N+(I?0:1)})})}for(const j of S)await re(j,!0);await d(A,_,j=>{D.row(N+1);const I=re(Y(j,N));if(I)return I.then(()=>{N++});N++});for(const j of V)await re(j,!0);return await G.close(),h(w.onProgress,{phase:"complete",rows:N,bytes:L}),y(_),{rows:N,columns:v.length,bytes:L}}async function J(A,z){const w=x(z),v=new n;try{let P=0;await M(A,v,{...w,onProgress:u=>{u.phase==="complete"?P=u.rows:h(w.onProgress,u)}});const s=v.toBlob("text/csv;charset=utf-8");return h(w.onProgress,{phase:"complete",rows:P,bytes:s.size}),y(w.signal),s}catch(P){throw v.discard(),P}}return Object.freeze({saveBlob:Pe.saveBlob,ExportCell:ee.ExportCell,writeCsvTo:R,writeCsv:J})})(),{saveBlob:Fe,ExportCell:Me,writeCsvTo:Le,writeCsv:Ne}=De;export{Me as ExportCell,Fe as saveBlob,Ne as writeCsv,Le as writeCsvTo};
|