sheetxl
Version:
SheetXL - Command line tool
1,489 lines • 74.8 kB
JavaScript
/**
* @license sheetxl - SheetXL - Command line tool - v0.6.0
*
* (C) 2025-present SheetXL Inc. & Michael T. Ford
* License: The license can be found at https://www.sheetxl.com/license.
*/
import { m as t, e, F as s, o as i, r as o, p as r, b as n, H as a, q as l, y as c, D as h, j as u, t as d, s as p, n as g } from "../cli.js";
import "node:util";
import "node:path";
import "node:fs";
import "node:os";
import "open";
import "node:repl";
import "chalk";
import "fs";
import "path";
import "commander";
const f = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-", m = new RegExp(`^[${f}][-${f}.0-9·̀-ͯ‿-⁀]*$`, "u");
function T(t2) {
return t2 >= 65 && t2 <= 90 || t2 >= 97 && t2 <= 122 || 58 === t2 || 95 === t2 || 8204 === t2 || 8205 === t2 || t2 >= 192 && t2 <= 214 || t2 >= 216 && t2 <= 246 || t2 >= 248 && t2 <= 767 || t2 >= 880 && t2 <= 893 || t2 >= 895 && t2 <= 8191 || t2 >= 8304 && t2 <= 8591 || t2 >= 11264 && t2 <= 12271 || t2 >= 12289 && t2 <= 55295 || t2 >= 63744 && t2 <= 64975 || t2 >= 65008 && t2 <= 65533 || t2 >= 65536 && t2 <= 983039;
}
const y = "A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-", b = new RegExp(`^[${y}][-${y}.0-9·̀-ͯ‿-⁀]*$`, "u");
function x(t2) {
return t2 >= 65 && t2 <= 90 || 95 === t2 || t2 >= 97 && t2 <= 122 || t2 >= 192 && t2 <= 214 || t2 >= 216 && t2 <= 246 || t2 >= 248 && t2 <= 767 || t2 >= 880 && t2 <= 893 || t2 >= 895 && t2 <= 8191 || t2 >= 8204 && t2 <= 8205 || t2 >= 8304 && t2 <= 8591 || t2 >= 11264 && t2 <= 12271 || t2 >= 12289 && t2 <= 55295 || t2 >= 63744 && t2 <= 64975 || t2 >= 65008 && t2 <= 65533 || t2 >= 65536 && t2 <= 983039;
}
const w = function(t2) {
return 32 === t2 || 10 === t2 || 13 === t2 || 9 === t2;
}, v = function(t2) {
return t2 >= 32 && t2 <= 55295 || 10 === t2 || 13 === t2 || 9 === t2 || t2 >= 57344 && t2 <= 65533 || t2 >= 65536 && t2 <= 1114111;
}, S = T, C = function(t2) {
return T(t2) || t2 >= 48 && t2 <= 57 || 45 === t2 || 46 === t2 || 183 === t2 || t2 >= 768 && t2 <= 879 || t2 >= 8255 && t2 <= 8256;
}, k = [32, 10, 13, 9], A = m, D = function(t2) {
return t2 >= 1 && t2 <= 55295 || t2 >= 57344 && t2 <= 65533 || t2 >= 65536 && t2 <= 1114111;
}, E = x, P = function(t2) {
return x(t2) || 45 === t2 || 46 === t2 || t2 >= 48 && t2 <= 57 || 183 === t2 || t2 >= 768 && t2 <= 879 || t2 >= 8255 && t2 <= 8256;
}, O = b, I = "http://www.w3.org/XML/1998/namespace", V = "http://www.w3.org/2000/xmlns/", L = { __proto__: null, xml: I, xmlns: V }, N = { __proto__: null, amp: "&", gt: ">", lt: "<", quot: '"', apos: "'" }, R = -1, $ = -2, M = 13, j = 33, H = 10, F = 60, X = 61, B = 62, W = 63, _ = 93, q = (t2) => 34 === t2 || 39 === t2, z = [34, 39], U = [...z, 91, B], G = [...z, F, _], Z = [X, W, ...k], Q = [...k, B, 38, F];
function J(t2, e2, s2) {
switch (e2) {
case "xml":
s2 !== I && t2.fail(`xml prefix must be bound to ${I}.`);
break;
case "xmlns":
s2 !== V && t2.fail(`xmlns prefix must be bound to ${V}.`);
}
switch (s2) {
case V:
t2.fail("" === e2 ? `the default namespace may not be set to ${s2}.` : `may not assign a prefix (even "xmlns") to the URI ${V}.`);
break;
case I:
switch (e2) {
case "xml":
break;
case "":
t2.fail(`the default namespace may not be set to ${s2}.`);
break;
default:
t2.fail("may not assign the xml namespace to another prefix.");
}
}
}
const K = (t2) => O.test(t2), Y = (t2) => A.test(t2), tt = { xmldecl: "xmldeclHandler", text: "textHandler", processinginstruction: "piHandler", doctype: "doctypeHandler", comment: "commentHandler", opentagstart: "openTagStartHandler", attribute: "attributeHandler", opentag: "openTagHandler", closetag: "closeTagHandler", cdata: "cdataHandler", error: "errorHandler", end: "endHandler", ready: "readyHandler" };
class et {
constructor(t2) {
this.i = 0, this.prevI = 0, this.opt = t2 ?? {}, this.fragmentOpt = !!this.opt.fragment;
const e2 = this.xmlnsOpt = !!this.opt.xmlns;
if (this.trackPosition = false !== this.opt.position, this.fileName = this.opt.fileName, e2) {
this.nameStartCheck = E, this.nameCheck = P, this.isName = K, this.processAttribs = this.processAttribsNS, this.pushAttrib = this.pushAttribNS, this.ns = { __proto__: null, ...L };
const t3 = this.opt.additionalNamespaces;
null != t3 && (function(t4, e3) {
for (const s2 of Object.keys(e3)) J(t4, s2, e3[s2]);
}(this, t3), Object.assign(this.ns, t3));
} else this.nameStartCheck = S, this.nameCheck = C, this.isName = Y, this.processAttribs = this.processAttribsPlain, this.pushAttrib = this.pushAttribPlain;
this.stateTable = [this.sBegin, this.sBeginWhitespace, this.sDoctype, this.sDoctypeQuote, this.sDTD, this.sDTDQuoted, this.sDTDOpenWaka, this.sDTDOpenWakaBang, this.sDTDComment, this.sDTDCommentEnding, this.sDTDCommentEnded, this.sDTDPI, this.sDTDPIEnding, this.sText, this.sEntity, this.sOpenWaka, this.sOpenWakaBang, this.sComment, this.sCommentEnding, this.sCommentEnded, this.sCData, this.sCDataEnding, this.sCDataEnding2, this.sPIFirstChar, this.sPIRest, this.sPIBody, this.sPIEnding, this.sXMLDeclNameStart, this.sXMLDeclName, this.sXMLDeclEq, this.sXMLDeclValueStart, this.sXMLDeclValue, this.sXMLDeclSeparator, this.sXMLDeclEnding, this.sOpenTag, this.sOpenTagSlash, this.sAttrib, this.sAttribName, this.sAttribNameSawWhite, this.sAttribValue, this.sAttribValueQuoted, this.sAttribValueClosed, this.sAttribValueUnquoted, this.sCloseTag, this.sCloseTagSawWhite], this._init();
}
get closed() {
return this._closed;
}
_init() {
this.openWakaBang = "", this.text = "", this.name = "", this.piTarget = "", this.entity = "", this.q = null, this.tags = [], this.tag = null, this.topNS = null, this.chunk = "", this.chunkPosition = 0, this.i = 0, this.prevI = 0, this.carriedFromPrevious = void 0, this.forbiddenState = 0, this.attribList = [];
const { fragmentOpt: t2 } = this;
this.state = t2 ? M : 0, this.reportedTextBeforeRoot = this.reportedTextAfterRoot = this.closedRoot = this.sawRoot = t2, this.xmlDeclPossible = !t2, this.xmlDeclExpects = ["version"], this.entityReturnState = void 0;
let { defaultXMLVersion: e2 } = this.opt;
if (void 0 === e2) {
if (true === this.opt.forceXMLVersion) throw new Error("forceXMLVersion set but defaultXMLVersion is not set");
e2 = "1.0";
}
this.setXMLVersion(e2), this.positionAtNewLine = 0, this.doctype = false, this._closed = false, this.xmlDecl = { version: void 0, encoding: void 0, standalone: void 0 }, this.line = 1, this.column = 0, this.ENTITIES = Object.create(N), this.readyHandler?.();
}
get position() {
return this.chunkPosition + this.i;
}
get columnIndex() {
return this.position - this.positionAtNewLine;
}
on(t2, e2) {
this[tt[t2]] = e2;
}
off(t2) {
this[tt[t2]] = void 0;
}
makeError(t2) {
let e2 = this.fileName ?? "";
return this.trackPosition && (e2.length > 0 && (e2 += ":"), e2 += `${this.line}:${this.column}`), e2.length > 0 && (e2 += ": "), new Error(e2 + t2);
}
fail(t2) {
const e2 = this.makeError(t2), s2 = this.errorHandler;
if (void 0 === s2) throw e2;
return s2(e2), this;
}
write(t2) {
if (this.closed) return this.fail("cannot write after close; assign an onready handler.");
let e2 = false;
null === t2 ? (e2 = true, t2 = "") : "object" == typeof t2 && (t2 = t2.toString()), void 0 !== this.carriedFromPrevious && (t2 = `${this.carriedFromPrevious}${t2}`, this.carriedFromPrevious = void 0);
let s2 = t2.length;
const i2 = t2.charCodeAt(s2 - 1);
!e2 && (13 === i2 || i2 >= 55296 && i2 <= 56319) && (this.carriedFromPrevious = t2[s2 - 1], s2--, t2 = t2.slice(0, s2));
const { stateTable: o2 } = this;
for (this.chunk = t2, this.i = 0; this.i < s2; ) o2[this.state].call(this);
return this.chunkPosition += s2, e2 ? this.end() : this;
}
close() {
return this.write(null);
}
getCode10() {
const t2 = this.chunk, e2 = this.i;
if (this.prevI = e2, this.i++, e2 >= t2.length) return R;
const s2 = t2.charCodeAt(e2);
if (this.column++, s2 < 55296) {
if (s2 >= 32 || 9 === s2) return s2;
switch (s2) {
case H:
return this.line++, this.column = 0, this.positionAtNewLine = this.position, H;
case 13:
return t2.charCodeAt(e2 + 1) === H && (this.i = e2 + 2), this.line++, this.column = 0, this.positionAtNewLine = this.position, $;
default:
return this.fail("disallowed character."), s2;
}
}
if (s2 > 56319) return s2 >= 57344 && s2 <= 65533 || this.fail("disallowed character."), s2;
const i2 = 65536 + 1024 * (s2 - 55296) + (t2.charCodeAt(e2 + 1) - 56320);
return this.i = e2 + 2, i2 > 1114111 && this.fail("disallowed character."), i2;
}
getCode11() {
const { chunk: t2, i: e2 } = this;
if (this.prevI = e2, this.i = e2 + 1, e2 >= t2.length) return R;
const s2 = t2.charCodeAt(e2);
if (this.column++, s2 < 55296) {
if (s2 > 31 && s2 < 127 || s2 > 159 && 8232 !== s2 || 9 === s2) return s2;
switch (s2) {
case H:
return this.line++, this.column = 0, this.positionAtNewLine = this.position, H;
case 13: {
const s3 = t2.charCodeAt(e2 + 1);
s3 !== H && 133 !== s3 || (this.i = e2 + 2);
}
case 133:
case 8232:
return this.line++, this.column = 0, this.positionAtNewLine = this.position, $;
default:
return this.fail("disallowed character."), s2;
}
}
if (s2 > 56319) return s2 >= 57344 && s2 <= 65533 || this.fail("disallowed character."), s2;
const i2 = 65536 + 1024 * (s2 - 55296) + (t2.charCodeAt(e2 + 1) - 56320);
return this.i = e2 + 2, i2 > 1114111 && this.fail("disallowed character."), i2;
}
getCodeNorm() {
const t2 = this.getCode();
return t2 === $ ? H : t2;
}
unget() {
this.i = this.prevI, this.column--;
}
captureTo(t2) {
let { i: e2 } = this;
const { chunk: s2 } = this;
for (; ; ) {
const i2 = this.getCode(), o2 = i2 === $, r2 = o2 ? H : i2;
if (r2 === R || t2.includes(r2)) return this.text += s2.slice(e2, this.prevI), r2;
o2 && (this.text += `${s2.slice(e2, this.prevI)}
`, e2 = this.i);
}
}
captureToChar(t2) {
let { i: e2 } = this;
const { chunk: s2 } = this;
for (; ; ) {
let i2 = this.getCode();
switch (i2) {
case $:
this.text += `${s2.slice(e2, this.prevI)}
`, e2 = this.i, i2 = H;
break;
case R:
return this.text += s2.slice(e2), false;
}
if (i2 === t2) return this.text += s2.slice(e2, this.prevI), true;
}
}
captureNameChars() {
const { chunk: t2, i: e2 } = this;
for (; ; ) {
const s2 = this.getCode();
if (s2 === R) return this.name += t2.slice(e2), R;
if (!C(s2)) return this.name += t2.slice(e2, this.prevI), s2 === $ ? H : s2;
}
}
skipSpaces() {
for (; ; ) {
const t2 = this.getCodeNorm();
if (t2 === R || !w(t2)) return t2;
}
}
setXMLVersion(t2) {
this.currentXMLVersion = t2, "1.0" === t2 ? (this.isChar = v, this.getCode = this.getCode10) : (this.isChar = D, this.getCode = this.getCode11);
}
sBegin() {
65279 === this.chunk.charCodeAt(0) && (this.i++, this.column++), this.state = 1;
}
sBeginWhitespace() {
const t2 = this.i, e2 = this.skipSpaces();
switch (this.prevI !== t2 && (this.xmlDeclPossible = false), e2) {
case F:
if (this.state = 15, 0 !== this.text.length) throw new Error("no-empty text at start");
break;
case R:
break;
default:
this.unget(), this.state = M, this.xmlDeclPossible = false;
}
}
sDoctype() {
const t2 = this.captureTo(U);
switch (t2) {
case B:
this.doctypeHandler?.(this.text), this.text = "", this.state = M, this.doctype = true;
break;
case R:
break;
default:
this.text += String.fromCodePoint(t2), 91 === t2 ? this.state = 4 : q(t2) && (this.state = 3, this.q = t2);
}
}
sDoctypeQuote() {
const t2 = this.q;
this.captureToChar(t2) && (this.text += String.fromCodePoint(t2), this.q = null, this.state = 2);
}
sDTD() {
const t2 = this.captureTo(G);
t2 !== R && (this.text += String.fromCodePoint(t2), t2 === _ ? this.state = 2 : t2 === F ? this.state = 6 : q(t2) && (this.state = 5, this.q = t2));
}
sDTDQuoted() {
const t2 = this.q;
this.captureToChar(t2) && (this.text += String.fromCodePoint(t2), this.state = 4, this.q = null);
}
sDTDOpenWaka() {
const t2 = this.getCodeNorm();
switch (this.text += String.fromCodePoint(t2), t2) {
case 33:
this.state = 7, this.openWakaBang = "";
break;
case W:
this.state = 11;
break;
default:
this.state = 4;
}
}
sDTDOpenWakaBang() {
const t2 = String.fromCodePoint(this.getCodeNorm()), e2 = this.openWakaBang += t2;
this.text += t2, "-" !== e2 && (this.state = "--" === e2 ? 8 : 4, this.openWakaBang = "");
}
sDTDComment() {
this.captureToChar(45) && (this.text += "-", this.state = 9);
}
sDTDCommentEnding() {
const t2 = this.getCodeNorm();
this.text += String.fromCodePoint(t2), this.state = 45 === t2 ? 10 : 8;
}
sDTDCommentEnded() {
const t2 = this.getCodeNorm();
this.text += String.fromCodePoint(t2), t2 === B ? this.state = 4 : (this.fail("malformed comment."), this.state = 8);
}
sDTDPI() {
this.captureToChar(W) && (this.text += "?", this.state = 12);
}
sDTDPIEnding() {
const t2 = this.getCodeNorm();
this.text += String.fromCodePoint(t2), t2 === B && (this.state = 4);
}
sText() {
0 !== this.tags.length ? this.handleTextInRoot() : this.handleTextOutsideRoot();
}
sEntity() {
let { i: t2 } = this;
const { chunk: e2 } = this;
t: for (; ; ) switch (this.getCode()) {
case $:
this.entity += `${e2.slice(t2, this.prevI)}
`, t2 = this.i;
break;
case 59: {
const { entityReturnState: s2 } = this, i2 = this.entity + e2.slice(t2, this.prevI);
let o2;
this.state = s2, "" === i2 ? (this.fail("empty entity name."), o2 = "&;") : (o2 = this.parseEntity(i2), this.entity = ""), s2 === M && void 0 === this.textHandler || (this.text += o2);
break t;
}
case R:
this.entity += e2.slice(t2);
break t;
}
}
sOpenWaka() {
const t2 = this.getCode();
if (S(t2)) this.state = 34, this.unget(), this.xmlDeclPossible = false;
else switch (t2) {
case 47:
this.state = 43, this.xmlDeclPossible = false;
break;
case 33:
this.state = 16, this.openWakaBang = "", this.xmlDeclPossible = false;
break;
case W:
this.state = 23;
break;
default:
this.fail("disallowed character in tag name"), this.state = M, this.xmlDeclPossible = false;
}
}
sOpenWakaBang() {
switch (this.openWakaBang += String.fromCodePoint(this.getCodeNorm()), this.openWakaBang) {
case "[CDATA[":
this.sawRoot || this.reportedTextBeforeRoot || (this.fail("text data outside of root node."), this.reportedTextBeforeRoot = true), this.closedRoot && !this.reportedTextAfterRoot && (this.fail("text data outside of root node."), this.reportedTextAfterRoot = true), this.state = 20, this.openWakaBang = "";
break;
case "--":
this.state = 17, this.openWakaBang = "";
break;
case "DOCTYPE":
this.state = 2, (this.doctype || this.sawRoot) && this.fail("inappropriately located doctype declaration."), this.openWakaBang = "";
break;
default:
this.openWakaBang.length >= 7 && this.fail("incorrect syntax.");
}
}
sComment() {
this.captureToChar(45) && (this.state = 18);
}
sCommentEnding() {
const t2 = this.getCodeNorm();
45 === t2 ? (this.state = 19, this.commentHandler?.(this.text), this.text = "") : (this.text += `-${String.fromCodePoint(t2)}`, this.state = 17);
}
sCommentEnded() {
const t2 = this.getCodeNorm();
t2 !== B ? (this.fail("malformed comment."), this.text += `--${String.fromCodePoint(t2)}`, this.state = 17) : this.state = M;
}
sCData() {
this.captureToChar(_) && (this.state = 21);
}
sCDataEnding() {
const t2 = this.getCodeNorm();
t2 === _ ? this.state = 22 : (this.text += `]${String.fromCodePoint(t2)}`, this.state = 20);
}
sCDataEnding2() {
const t2 = this.getCodeNorm();
switch (t2) {
case B:
this.cdataHandler?.(this.text), this.text = "", this.state = M;
break;
case _:
this.text += "]";
break;
default:
this.text += `]]${String.fromCodePoint(t2)}`, this.state = 20;
}
}
sPIFirstChar() {
const t2 = this.getCodeNorm();
this.nameStartCheck(t2) ? (this.piTarget += String.fromCodePoint(t2), this.state = 24) : t2 === W || w(t2) ? (this.fail("processing instruction without a target."), this.state = t2 === W ? 26 : 25) : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(t2), this.state = 24);
}
sPIRest() {
const { chunk: t2, i: e2 } = this;
for (; ; ) {
const s2 = this.getCodeNorm();
if (s2 === R) return void (this.piTarget += t2.slice(e2));
if (!this.nameCheck(s2)) {
this.piTarget += t2.slice(e2, this.prevI);
const i2 = s2 === W;
i2 || w(s2) ? "xml" === this.piTarget ? (this.xmlDeclPossible || this.fail("an XML declaration must be at the start of the document."), this.state = i2 ? j : 27) : this.state = i2 ? 26 : 25 : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(s2));
break;
}
}
}
sPIBody() {
if (0 === this.text.length) {
const t2 = this.getCodeNorm();
t2 === W ? this.state = 26 : w(t2) || (this.text = String.fromCodePoint(t2));
} else this.captureToChar(W) && (this.state = 26);
}
sPIEnding() {
const t2 = this.getCodeNorm();
if (t2 === B) {
const { piTarget: t3 } = this;
"xml" === t3.toLowerCase() && this.fail("the XML declaration must appear at the start of the document."), this.piHandler?.({ target: t3, body: this.text }), this.piTarget = this.text = "", this.state = M;
} else t2 === W ? this.text += "?" : (this.text += `?${String.fromCodePoint(t2)}`, this.state = 25);
this.xmlDeclPossible = false;
}
sXMLDeclNameStart() {
const t2 = this.skipSpaces();
t2 !== W ? t2 !== R && (this.state = 28, this.name = String.fromCodePoint(t2)) : this.state = j;
}
sXMLDeclName() {
const t2 = this.captureTo(Z);
if (t2 === W) return this.state = j, this.name += this.text, this.text = "", void this.fail("XML declaration is incomplete.");
if (w(t2) || t2 === X) {
if (this.name += this.text, this.text = "", !this.xmlDeclExpects.includes(this.name)) switch (this.name.length) {
case 0:
this.fail("did not expect any more name/value pairs.");
break;
case 1:
this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);
break;
default:
this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`);
}
this.state = t2 === X ? 30 : 29;
}
}
sXMLDeclEq() {
const t2 = this.getCodeNorm();
if (t2 === W) return this.state = j, void this.fail("XML declaration is incomplete.");
w(t2) || (t2 !== X && this.fail("value required."), this.state = 30);
}
sXMLDeclValueStart() {
const t2 = this.getCodeNorm();
if (t2 === W) return this.state = j, void this.fail("XML declaration is incomplete.");
w(t2) || (q(t2) ? this.q = t2 : (this.fail("value must be quoted."), this.q = 32), this.state = 31);
}
sXMLDeclValue() {
const t2 = this.captureTo([this.q, W]);
if (t2 === W) return this.state = j, this.text = "", void this.fail("XML declaration is incomplete.");
if (t2 === R) return;
const e2 = this.text;
switch (this.text = "", this.name) {
case "version": {
this.xmlDeclExpects = ["encoding", "standalone"];
const t3 = e2;
this.xmlDecl.version = t3, /^1\.[0-9]+$/.test(t3) ? this.opt.forceXMLVersion || this.setXMLVersion(t3) : this.fail("version number must match /^1\\.[0-9]+$/.");
break;
}
case "encoding":
/^[A-Za-z][A-Za-z0-9._-]*$/.test(e2) || this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."), this.xmlDeclExpects = ["standalone"], this.xmlDecl.encoding = e2;
break;
case "standalone":
"yes" !== e2 && "no" !== e2 && this.fail('standalone value must match "yes" or "no".'), this.xmlDeclExpects = [], this.xmlDecl.standalone = e2;
}
this.name = "", this.state = 32;
}
sXMLDeclSeparator() {
const t2 = this.getCodeNorm();
t2 !== W ? (w(t2) || (this.fail("whitespace required."), this.unget()), this.state = 27) : this.state = j;
}
sXMLDeclEnding() {
this.getCodeNorm() === B ? ("xml" !== this.piTarget ? this.fail("processing instructions are not allowed before root.") : "version" !== this.name && this.xmlDeclExpects.includes("version") && this.fail("XML declaration must contain a version."), this.xmldeclHandler?.(this.xmlDecl), this.name = "", this.piTarget = this.text = "", this.state = M) : this.fail("The character ? is disallowed anywhere in XML declarations."), this.xmlDeclPossible = false;
}
sOpenTag() {
const t2 = this.captureNameChars();
if (t2 === R) return;
const e2 = this.tag = { name: this.name, attributes: /* @__PURE__ */ Object.create(null) };
switch (this.name = "", this.xmlnsOpt && (this.topNS = e2.ns = /* @__PURE__ */ Object.create(null)), this.openTagStartHandler?.(e2), this.sawRoot = true, !this.fragmentOpt && this.closedRoot && this.fail("documents may contain only one root."), t2) {
case B:
this.openTag();
break;
case 47:
this.state = 35;
break;
default:
w(t2) || this.fail("disallowed character in tag name."), this.state = 36;
}
}
sOpenTagSlash() {
this.getCode() === B ? this.openSelfClosingTag() : (this.fail("forward-slash in opening tag not followed by >."), this.state = 36);
}
sAttrib() {
const t2 = this.skipSpaces();
t2 !== R && (S(t2) ? (this.unget(), this.state = 37) : t2 === B ? this.openTag() : 47 === t2 ? this.state = 35 : this.fail("disallowed character in attribute name."));
}
sAttribName() {
const t2 = this.captureNameChars();
t2 === X ? this.state = 39 : w(t2) ? this.state = 38 : t2 === B ? (this.fail("attribute without value."), this.pushAttrib(this.name, this.name), this.name = this.text = "", this.openTag()) : t2 !== R && this.fail("disallowed character in attribute name.");
}
sAttribNameSawWhite() {
const t2 = this.skipSpaces();
switch (t2) {
case R:
return;
case X:
this.state = 39;
break;
default:
this.fail("attribute without value."), this.text = "", this.name = "", t2 === B ? this.openTag() : S(t2) ? (this.unget(), this.state = 37) : (this.fail("disallowed character in attribute name."), this.state = 36);
}
}
sAttribValue() {
const t2 = this.getCodeNorm();
q(t2) ? (this.q = t2, this.state = 40) : w(t2) || (this.fail("unquoted attribute value."), this.state = 42, this.unget());
}
sAttribValueQuoted() {
const { q: t2, chunk: e2 } = this;
let { i: s2 } = this;
for (; ; ) switch (this.getCode()) {
case t2:
return this.pushAttrib(this.name, this.text + e2.slice(s2, this.prevI)), this.name = this.text = "", this.q = null, void (this.state = 41);
case 38:
return this.text += e2.slice(s2, this.prevI), this.state = 14, void (this.entityReturnState = 40);
case H:
case $:
case 9:
this.text += `${e2.slice(s2, this.prevI)} `, s2 = this.i;
break;
case F:
return this.text += e2.slice(s2, this.prevI), void this.fail("disallowed character.");
case R:
return void (this.text += e2.slice(s2));
}
}
sAttribValueClosed() {
const t2 = this.getCodeNorm();
w(t2) ? this.state = 36 : t2 === B ? this.openTag() : 47 === t2 ? this.state = 35 : S(t2) ? (this.fail("no whitespace between attributes."), this.unget(), this.state = 37) : this.fail("disallowed character in attribute name.");
}
sAttribValueUnquoted() {
const t2 = this.captureTo(Q);
switch (t2) {
case 38:
this.state = 14, this.entityReturnState = 42;
break;
case F:
this.fail("disallowed character.");
break;
case R:
break;
default:
this.text.includes("]]>") && this.fail('the string "]]>" is disallowed in char data.'), this.pushAttrib(this.name, this.text), this.name = this.text = "", t2 === B ? this.openTag() : this.state = 36;
}
}
sCloseTag() {
const t2 = this.captureNameChars();
t2 === B ? this.closeTag() : w(t2) ? this.state = 44 : t2 !== R && this.fail("disallowed character in closing tag.");
}
sCloseTagSawWhite() {
switch (this.skipSpaces()) {
case B:
this.closeTag();
break;
case R:
break;
default:
this.fail("disallowed character in closing tag.");
}
}
handleTextInRoot() {
let { i: t2, forbiddenState: e2 } = this;
const { chunk: s2, textHandler: i2 } = this;
t: for (; ; ) switch (this.getCode()) {
case F:
if (this.state = 15, void 0 !== i2) {
const { text: e3 } = this, o2 = s2.slice(t2, this.prevI);
0 !== e3.length ? (i2(e3 + o2), this.text = "") : 0 !== o2.length && i2(o2);
}
e2 = 0;
break t;
case 38:
this.state = 14, this.entityReturnState = M, void 0 !== i2 && (this.text += s2.slice(t2, this.prevI)), e2 = 0;
break t;
case _:
switch (e2) {
case 0:
e2 = 1;
break;
case 1:
e2 = 2;
break;
case 2:
break;
default:
throw new Error("impossible state");
}
break;
case B:
2 === e2 && this.fail('the string "]]>" is disallowed in char data.'), e2 = 0;
break;
case $:
void 0 !== i2 && (this.text += `${s2.slice(t2, this.prevI)}
`), t2 = this.i, e2 = 0;
break;
case R:
void 0 !== i2 && (this.text += s2.slice(t2));
break t;
default:
e2 = 0;
}
this.forbiddenState = e2;
}
handleTextOutsideRoot() {
let { i: t2 } = this;
const { chunk: e2, textHandler: s2 } = this;
let i2 = false;
t: for (; ; ) {
const o2 = this.getCode();
switch (o2) {
case F:
if (this.state = 15, void 0 !== s2) {
const { text: i3 } = this, o3 = e2.slice(t2, this.prevI);
0 !== i3.length ? (s2(i3 + o3), this.text = "") : 0 !== o3.length && s2(o3);
}
break t;
case 38:
this.state = 14, this.entityReturnState = M, void 0 !== s2 && (this.text += e2.slice(t2, this.prevI)), i2 = true;
break t;
case $:
void 0 !== s2 && (this.text += `${e2.slice(t2, this.prevI)}
`), t2 = this.i;
break;
case R:
void 0 !== s2 && (this.text += e2.slice(t2));
break t;
default:
w(o2) || (i2 = true);
}
}
i2 && (this.sawRoot || this.reportedTextBeforeRoot || (this.fail("text data outside of root node."), this.reportedTextBeforeRoot = true), this.closedRoot && !this.reportedTextAfterRoot && (this.fail("text data outside of root node."), this.reportedTextAfterRoot = true));
}
pushAttribNS(t2, e2) {
const { prefix: s2, local: i2 } = this.qname(t2), o2 = { name: t2, prefix: s2, local: i2, value: e2 };
if (this.attribList.push(o2), this.attributeHandler?.(o2), "xmlns" === s2) {
const t3 = e2.trim();
"1.0" === this.currentXMLVersion && "" === t3 && this.fail("invalid attempt to undefine prefix in XML 1.0"), this.topNS[i2] = t3, J(this, i2, t3);
} else if ("xmlns" === t2) {
const t3 = e2.trim();
this.topNS[""] = t3, J(this, "", t3);
}
}
pushAttribPlain(t2, e2) {
const s2 = { name: t2, value: e2 };
this.attribList.push(s2), this.attributeHandler?.(s2);
}
end() {
this.sawRoot || this.fail("document must contain a root element.");
const { tags: t2 } = this;
for (; t2.length > 0; ) {
const e3 = t2.pop();
this.fail(`unclosed tag: ${e3.name}`);
}
0 !== this.state && this.state !== M && this.fail("unexpected end.");
const { text: e2 } = this;
return 0 !== e2.length && (this.textHandler?.(e2), this.text = ""), this._closed = true, this.endHandler?.(), this._init(), this;
}
resolve(t2) {
let e2 = this.topNS[t2];
if (void 0 !== e2) return e2;
const { tags: s2 } = this;
for (let i2 = s2.length - 1; i2 >= 0; i2--) if (e2 = s2[i2].ns[t2], void 0 !== e2) return e2;
return e2 = this.ns[t2], void 0 !== e2 ? e2 : this.opt.resolvePrefix?.(t2);
}
qname(t2) {
const e2 = t2.indexOf(":");
if (-1 === e2) return { prefix: "", local: t2 };
const s2 = t2.slice(e2 + 1), i2 = t2.slice(0, e2);
return ("" === i2 || "" === s2 || s2.includes(":")) && this.fail(`malformed name: ${t2}.`), { prefix: i2, local: s2 };
}
processAttribsNS() {
const { attribList: t2 } = this, e2 = this.tag;
{
const { prefix: t3, local: s3 } = this.qname(e2.name);
e2.prefix = t3, e2.local = s3;
const i3 = e2.uri = this.resolve(t3) ?? "";
"" !== t3 && ("xmlns" === t3 && this.fail('tags may not have "xmlns" as prefix.'), "" === i3 && (this.fail(`unbound namespace prefix: ${JSON.stringify(t3)}.`), e2.uri = t3));
}
if (0 === t2.length) return;
const { attributes: s2 } = e2, i2 = /* @__PURE__ */ new Set();
for (const e3 of t2) {
const { name: t3, prefix: o2, local: r2 } = e3;
let n2, a2;
"" === o2 ? (n2 = "xmlns" === t3 ? V : "", a2 = t3) : (n2 = this.resolve(o2), void 0 === n2 && (this.fail(`unbound namespace prefix: ${JSON.stringify(o2)}.`), n2 = o2), a2 = `{${n2}}${r2}`), i2.has(a2) && this.fail(`duplicate attribute: ${a2}.`), i2.add(a2), e3.uri = n2, s2[t3] = e3;
}
this.attribList = [];
}
processAttribsPlain() {
const { attribList: t2 } = this, e2 = this.tag.attributes;
for (const { name: s2, value: i2 } of t2) void 0 !== e2[s2] && this.fail(`duplicate attribute: ${s2}.`), e2[s2] = i2;
this.attribList = [];
}
openTag() {
this.processAttribs();
const { tags: t2 } = this, e2 = this.tag;
e2.isSelfClosing = false, this.openTagHandler?.(e2), t2.push(e2), this.state = M, this.name = "";
}
openSelfClosingTag() {
this.processAttribs();
const { tags: t2 } = this, e2 = this.tag;
e2.isSelfClosing = true, this.openTagHandler?.(e2), this.closeTagHandler?.(e2), null === (this.tag = t2[t2.length - 1] ?? null) && (this.closedRoot = true), this.state = M, this.name = "";
}
closeTag() {
const { tags: t2, name: e2 } = this;
if (this.state = M, this.name = "", "" === e2) return this.fail("weird empty close tag."), void (this.text += "</>");
const s2 = this.closeTagHandler;
let i2 = t2.length;
for (; i2-- > 0; ) {
const i3 = this.tag = t2.pop();
if (this.topNS = i3.ns, s2?.(i3), i3.name === e2) break;
this.fail("unexpected close tag.");
}
0 === i2 ? this.closedRoot = true : i2 < 0 && (this.fail(`unmatched closing tag: ${e2}.`), this.text += `</${e2}>`);
}
parseEntity(t2) {
if ("#" !== t2[0]) {
const e3 = this.ENTITIES[t2];
return void 0 !== e3 ? e3 : (this.fail(this.isName(t2) ? "undefined entity." : "disallowed character in entity name."), `&${t2};`);
}
let e2 = NaN;
return "x" === t2[1] && /^#x[0-9a-f]+$/i.test(t2) ? e2 = parseInt(t2.slice(2), 16) : /^#[0-9]+$/.test(t2) && (e2 = parseInt(t2.slice(1), 10)), this.isChar(e2) ? String.fromCodePoint(e2) : (this.fail("malformed character entity."), `&${t2};`);
}
}
var st, it;
(it = st || (st = {})).Events = { XmlDecl: "xmldecl", Text: "text", ProcessingInstruction: "processinginstruction", Doctype: "doctype", Comment: "comment", OpenTagStart: "opentagstart", Attribute: "attribute", OpenTag: "opentag", CloseTag: "closetag", CDdata: "cdata", Error: "error", End: "end", Ready: "ready" }, it.parseStream = async (t2, e2, s2) => {
const i2 = new et({ position: false, ...s2 });
let o2;
if (e2.onOpenTagStart && i2.on(it.Events.OpenTagStart, e2.onOpenTagStart), e2.onOpenTag && i2.on(it.Events.OpenTag, e2.onOpenTag), e2.onCloseTag && i2.on(it.Events.CloseTag, e2.onCloseTag), e2.onAttribute && i2.on(it.Events.Attribute, e2.onAttribute), e2.onText && i2.on(it.Events.Text, e2.onText), e2.onError && i2.on(it.Events.Error, e2.onError), e2.onEnd) {
e2.onEnd;
const t3 = () => {
o2 = e2.onEnd();
};
i2.on(it.Events.End, t3);
}
for (; ; ) {
const { value: e3, done: s3 } = await t2.read();
if (s3) break;
i2.write(e3);
}
return i2.close(), o2;
};
const ot = (t2) => true === t2 || "1" === t2 || "on" === t2 || "true" === t2 || false !== t2 && "0" !== t2 && "off" !== t2 && "false" !== t2 && null, rt = (t2) => {
const e2 = parseInt(t2);
return isNaN(e2) ? null : e2;
}, nt = (t2) => {
const e2 = parseFloat(t2);
return isNaN(e2) ? null : e2;
}, at = null;
class lt {
constructor() {
this._registeredVisitors = /* @__PURE__ */ new Map();
}
registerVisitor(t2) {
this._registeredVisitors.set(t2.from, t2);
}
createEventHandler(t2, e2, s2) {
const i2 = this._registeredVisitors, o2 = [];
let r2 = null, n2 = null, a2 = null, l2 = null;
const c2 = [], h2 = { key: null, source: t2 };
let u2 = null, d2 = false;
const p2 = (t3, e3) => {
let s3 = a2.attributes[t3];
if (e3) if (Array.isArray(e3)) for (let t4 = 0; t4 < e3.length; t4++) {
if (null == s3) return;
if (s3 = e3[t4](s3), null == s3) return;
}
else {
if (null == s3) return;
if (s3 = e3(s3), null == s3) return;
}
return s3;
}, g2 = { getSource: () => u2.source, setSource: (t3) => {
u2.source = t3;
}, setKey: (t3) => {
u2.key = t3;
}, getFrom: () => a2, getAttribute: (t3, e3) => p2(t3, e3) ?? null, hasAttribute: (t3) => null !== g2.getAttribute(t3), getParent: () => c2[c2.length - 2].source, getPath: () => {
const t3 = [];
for (let e3 = 0; e3 < o2.length; e3++) t3.push(o2[e3].local);
return t3.join("\\");
}, parseAttribute: p2, copyToObject: (t3, e3, s3, i3) => {
const o3 = p2(i3 ?? e3, s3);
void 0 !== o3 && (t3[e3] = o3);
}, copyTo: (t3, e3, s3) => {
const i3 = p2(s3 ?? t3, e3);
void 0 !== i3 && (u2.source[t3] = i3);
}, warn: (t3) => {
s2 ? s2?.(t3) : console.warn(t3);
} };
return { onOpenTag: (t3) => {
let e3 = t3.name;
const s3 = e3.indexOf(":");
-1 !== s3 && (e3 = e3.slice(s3 + 1));
const p3 = i2.get(e3);
if (r2 = { local: e3, visitor: p3, tag: t3, destination: null }, d2) return o2.push(r2), n2 = e3, void (a2 = t3);
l2 = r2?.visitor ?? null, p3 && (u2 = 0 === o2.length ? h2 : null !== l2?.to ? { key: null, source: {} } : null, r2.destination = u2, u2 && c2.push(u2)), o2.push(r2), n2 = e3, a2 = t3, d2 = null === l2?.to, l2?.openTag?.(g2);
}, onCloseTag: (t3) => {
let e3 = t3.name;
const i3 = e3.indexOf(":");
if (-1 !== i3 && (e3 = e3.slice(i3 + 1)), e3 !== n2) throw new Error(`mismatch open/close tag: '${e3}'/'${n2}'`);
d2 || l2?.closeTag?.(g2);
const p3 = o2.pop() ?? null;
r2 = o2[o2.length - 1] ?? null;
const f2 = p3?.destination;
if (f2) {
c2.pop(), u2 = c2[c2.length - 1] ?? h2;
const t4 = p3.visitor;
t4 && t4.to && void 0 !== f2.source && (Array.isArray(t4.to) ? u2.source.push ? u2.source.push(f2.source) : s2?.(`Unable to parse array for ${t4.from} at ${g2.getPath()}`) : f2.key ? u2.source[f2.key] = f2.source : "string" == typeof t4.to && (u2.source[t4.to] = f2.source));
}
n2 = r2?.local ?? null, a2 = r2?.tag ?? null, l2 = r2?.visitor ?? null, d2 = !r2?.destination;
}, onText: (t3) => {
l2?.text?.(t3, g2);
}, onEnd: e2 };
}
}
const ct = (t2, e2, s2, i2 = null) => {
if (!t2) return null;
let o2 = t2;
o2.startsWith("/") && (o2 = o2.substring(1));
let r2 = i2?.parsedRefs?.get(t2);
if (void 0 !== r2) return r2;
const n2 = e2(o2);
if (!n2) return null;
let a2 = n2.content;
try {
s2 && (a2 = s2(a2));
} catch (t3) {
console.warn(t3);
}
return i2?.parsedRefs?.set(t2, a2), a2;
}, ht = (t2, e2, s2, i2, o2 = null) => {
if (!t2) return null;
let r2 = t2;
r2.startsWith("/") && (r2 = r2.substring(1));
let n2 = o2?.parsedRefs?.get(t2);
if (void 0 !== n2) return n2;
const a2 = e2(r2);
if (!a2) return null;
const l2 = a2.content;
try {
const e3 = new TextDecoder().decode(l2), r3 = s2.parseFromString(e3, "text/xml"), n3 = i2.convert(r3, t2, o2);
return o2?.parsedRefs?.set(t2, n3), n3;
} catch (t3) {
console.warn(t3);
}
return null;
}, ut = (t2, e2, s2, i2, o2 = null) => {
const r2 = /* @__PURE__ */ new Map();
let n2 = e2.Directory[t2];
const a2 = n2 ? n2.length : 0;
for (let t3 = 0; t3 < a2; t3++) {
const a3 = n2[t3];
if (!a3) continue;
let l2 = a3;
l2.startsWith("/") && (l2 = l2.substring(1));
const c2 = ht(l2, (t4) => e2.files[t4], s2, i2, o2);
r2.set(l2, c2);
}
return r2;
}, dt = ["lt1", "dk1", "lt2", "dk2", "accent1", "accent2", "accent3", "accent4", "accent5", "accent6", "hlink", "folHlink"], pt = (t2, e2 = "dk1") => {
let s2;
const i2 = t2("auto");
void 0 === i2 || "1" !== i2 && "true" !== i2 || (s2 = e2);
const o2 = t2("indexed");
o2 && (s2 = `index${o2}`);
const r2 = t2("rgb");
r2 && (s2 = r2.toLowerCase(), 8 !== r2.length || r2.startsWith("FF") || (s2 = "FF" + r2.substring(2, r2.length)));
const n2 = t2("theme");
n2 && (s2 = dt[n2]);
let a2 = t2("tint");
if (a2 && (s2 += ` ${h.AdjustmentType.ETint} ${parseFloat(a2)}`), s2) return s2;
}, gt = (t2) => t2 ? t2.replace(/^\{([\s\S]+)\}$/, "$1") : t2, ft = (t2) => t2 ? n.roundAccurately(parseFloat(t2) / 12700, 4) : null, mt = (t2) => t2 ? n.roundAccurately(parseFloat(t2) / 9525, 1) : null, Tt = (t2) => parseFloat(t2) / 1e3, yt = (t2) => parseFloat(t2) / 6e4, bt = (t2) => "true" === t2 || "1" === t2;
class xt {
static {
this.Collapsed = 1;
}
static {
this.CustomFormat = 2;
}
static {
this.CustomHeight = 4;
}
static {
this.Hidden = 8;
}
static {
this.Ht = 16;
}
static {
this.OutlineLevel = 32;
}
static {
this.Ph = 64;
}
static {
this.R = 128;
}
static {
this.S = 256;
}
static {
this.Spans = 512;
}
static {
this.ThickBot = 1024;
}
static {
this.ThickTop = 2048;
}
}
const wt = (t2, e2, s2) => {
if (t2[0].value[0] === t2[1].value[0]) return e2;
}, vt = { colStart: 0, colEnd: 0, rowStart: 0, rowEnd: 0 }, St = Object.freeze(Object.defineProperty({ __proto__: null, fromBufferXLSX: async (t2, h2) => {
const { password: f2, onWarning: m2, createWorkbookOptions: T2 = {}, ...y2 } = h2 ?? {}, b2 = import("./DRaOLlMgixvUTDbQ.js"), x2 = import("./DctXdNPdLo-sd0WC.js");
let w2 = null;
try {
w2 = new DOMParser();
} catch (t3) {
}
let v2 = null;
w2 || (v2 = import("./B1yj9MPM4dhKOhzd.js").then((t3) => t3.i));
let S2 = null, C2 = null, k2 = null;
try {
const t3 = await Promise.all([b2, x2, v2]);
S2 = t3[0], C2 = t3[1], k2 = t3[2];
} catch (t3) {
throw new Error("Unable to load XLSX parser.", { cause: t3 });
}
try {
const h3 = S2.read(t2, { type: "array", sheets: [], cellStyles: false, bookFiles: true });
if (!h3.Directory) throw new Error("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");
h3.Directory.richstructure = ["/xl/richData/rdrichvaluestructure.xml"], h3.Directory.richdata = ["/xl/richData/rdrichvalue.xml"];
const p2 = new C2.FromOOXMLConverter(), f3 = w2 ?? new k2.DOMParser(), y3 = T2?.resources ?? new s(), b3 = y3.beginPersist(), x3 = {}, v3 = /* @__PURE__ */ new Set(), A2 = /* @__PURE__ */ new Map();
A2.set("richTypes", []);
const D2 = /* @__PURE__ */ new Map(), E2 = [], P2 = (t3) => h3.files[t3], O2 = (t3, e2) => {
const s2 = t3.lastIndexOf("/"), i2 = t3.substring(0, s2 + 1) + "_rels/" + t3.substring(s2 + 1, t3.length) + ".rels";
let o2 = e2.get(i2);
return o2 || (o2 = ((t4, e3, s3, i3, o3 = null) => {
if (!t4) return null;
const r2 = ht(t4, e3, s3, i3, o3);
if (!r2) return null;
const n2 = /* @__PURE__ */ new Map(), a2 = Object.keys(r2), l2 = a2.length;
for (let t5 = 0; t5 < l2; t5++) {
const e4 = a2[t5], s4 = r2[e4];
n2.set(e4, s4);
}
return n2;
})(i2, P2, f3, p2, V2), e2.set(i2, o2)), o2;
}, I2 = (t3, s2, a2, l2 = D2) => {
let c2 = O2(s2, l2).get(t3), h4 = c2?.target;
if (!h4) return null;
if ("External" === c2.targetMode) return c2.target;
const T3 = s2.lastIndexOf("/"), w3 = s2.substring(0, T3 + 1);
h4.startsWith("/") || (h4 = w3 + h4), h4 = ((t4) => {
const e2 = t4.split(/\/+/);
return e2.reduce((t5, e3, s3) => ("." === e3 ? t5.splice(s3, 1) : ".." === e3 && t5.splice(s3 - 1, 2), t5), e2).join("/");
})(h4);
const S3 = p2?.getVisitorParamsState().get("dxfs");
let C3 = l2.get(h4);
if (!C3) {
const t4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";
if (c2.type === t4) {
const t5 = {};
C3 = t5;
const s3 = async () => {
const s4 = ((t6, s5, n2, a4, l3, c4, h5) => {
const p4 = new lt(), f5 = new i.TransposedBuilder();
let m3 = null;
p4.registerVisitor({ from: "autoFilter", to: "filter", openTag: (t7) => {
t7.copyTo("ref", at);
} }), p4.registerVisitor({ from: "conditionalFormatting", to: {}, openTag: (t7) => {
const e2 = t7.getParent();
e2.conditionals || (e2.conditionals = []), e2.conditionals.push(t7.getSource());
const s6 = t7.getAttribute("sqref");
s6 && (t7.getSource().ref = s6.split(" ").join(",")), t7.copyTo("pivot", ot);
}, closeTag: (t7) => {
const e2 = t7.getSource();
if (e2.rule) {
const t8 = Object.keys(e2.rule);
for (let s6 = 0; s6 < t8.length; s6++) {
const i2 = t8[s6];
"rule" !== i2 && (e2[i2] = e2.rule[i2]);
}
}
delete e2.rule;
} }), p4.registerVisitor({ from: "cfRule", to: "rule", openTag: (t7) => {
const e2 = t7.getParent();
t7.copyToObject(e2, "type", at), t7.copyToObject(e2, "priority", rt), t7.copyToObject(e2, "stopIfTrue", ot);
const s6 = t7.getAttribute("dxfId", rt);
if (null !== s6) {
let i2 = a4?.get(s6);
i2 || (c4?.(`Unable to load conditional color. Invalid dxfI: '${s6}' at '${t7.getPath()}'.`), i2 = {}), e2.style = i2;
}
t7.copyToObject(e2, "aboveAverage", ot), t7.copyToObject(e2, "equalAverage", ot), t7.copyToObject(e2, "stdDev", rt), t7.copyToObject(e2, "bottom", ot), t7.copyToObject(e2, "percent", ot), t7.copyToObject(e2, "rank", rt), t7.copyToObject(e2, "operator", at), t7.copyToObject(e2, "text", at), t7.copyToObject(e2, "timePeriod", at);
} }), p4.registerVisitor({ from: "colorScale", to: "colorScale" }), p4.registerVisitor({ from: "dataBar", to: "dataBar", openTag: (t7) => {
t7.copyTo("maxLength", rt), t7.copyTo("minLength", rt), t7.copyTo("showValue", ot);
} }), p4.registerVisitor({ from: "iconSet", to: "iconSet", openTag: (t7) => {
t7.copyTo("iconSet", at), t7.copyTo("reverse", ot), t7.copyTo("showValue", ot);
} }), p4.registerVisitor({ from: "formula", to: null, text: (t7, e2) => {
const s6 = e2.getParent();
let i2 = s6.formulas;
i2 || (i2 = [], s6.formulas = i2), i2.push(t7);
} }), p4.registerVisitor({ from: "cfvo", to: {}, openTag: (t7) => {
const e2 = t7.getParent();
e2.conditions || (e2.conditions = []), e2.conditions.push(t7.getSource()), t7.copyTo("type", at), t7.copyTo("value", nt, "val"), t7.copyTo("gte", ot);
} }), p4.registerVisitor({ from: "color", to: {}, openTag: (t7) => {
const e2 = t7.getParent();
e2.colors || (e2.colors = []);
const s6 = pt((e3) => t7.getAttribute(e3));
e2.colors.push(s6);
} }), p4.registerVisitor({ from: "filterColumn", to: "filterColumn", openTag: (t7) => {
const e2 = t7.getParent();
e2.fields || (e2.fields = []), e2.fields.push(t7.getSource()), t7.copyTo("offset", rt, "colId"), t7.copyTo("hiddenButton", ot), t7.copyTo("showButton", ot);
} }), p4.registerVisitor({ from: "colorFilter", to: "colorFilter", openTag: (t7) => {
const e2 = t7.getParent();
e2.criteria || (e2.criteria = []), e2.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Color, t7.copyTo("cellColor", ot), t7.copyTo("styleId", rt, "dxfId");
} }), p4.registerVisitor({ from: "dynamicFilter", to: "dynamicFilter", openTag: (t7) => {
const e2 = t7.getParent();
e2.criteria || (e2.criteria = []), e2.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Dynamic, t7.copyTo("dynamicType", at, "type"), t7.copyTo("val", nt), t7.copyTo("maxVal", nt, "maxVal");
} }), p4.registerVisitor({ from: "iconFilter", to: "iconFilter", openTag: (t7) => {
const e2 = t7.getParent();
e2.criteria || (e2.criteria = []), e2.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Icon, t7.copyTo("iconId", rt), t7.copyTo("iconSet", at);
} }), p4.registerVisitor({ from: "top10", to: "top10", openTag: (t7) => {
const e2 = t7.getParent();
e2.criteria || (e2.criteria = []), e2.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Top10, t7.copyTo("filterVal", nt), t7.copyTo("percent", ot), t7.copyTo("top", ot), t7.copyTo("val", nt);
} }), p4.registerVisitor({ from: "filters", to: "filters", openTag: (t7) => {
const e2 = t7.getParent();
e2.criteria || (e2.criteria = []), e2.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Items, t7.copyTo("blank", ot), t7.copyTo("calendarType", at);
} }), p4.registerVisitor({ from: "dateGroupItem", to: "dateGroupItem", openTag: (t7) => {
const e2 = t7.getParent();
e2.dateGroups || (e2.dateGroups = []), e2.dateGroups.push(t7.getSource()), t7.copyTo("group", at, "dateTimeGrouping"), t7.copyTo("day", rt), t7.copyTo("hour", rt), t7.copyTo("minute", rt), t7.copyTo("month", rt), t7.copyTo("second", rt), t7.copyTo("year", rt);
} }), p4.registerVisitor({ from: "filter", to: "filter", openTag: (t7) => {
const e2 = t7.getParent();
e2.items || (e2.items = []), e2.items.push(t7.getAttribute("val", nt));
} }), p4.registerVisitor({ from: "customFilters", to: "customFilters", openTag: (t7) => {
const e2 = t7.getParent();
e2.criteria || (e2.criteria = []), e2.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Custom, t7.copyTo("and", ot);
} }), p4.registerVisitor({ from: "customFilter", to: "customFilter", openTag: (t7) => {
const e2 = t7.getParent();
e2.filters || (e2.filters = []), e2.filters.push(t7.getSource()), t7.copyTo("operator", at), t7.copyTo("value", nt, "val");
} }), p4.registerVisitor({ from: "sortState", to: "sort", openTag: (t7) => {
t7.copyTo("ref", at);
} }), p4.registerVisitor({ from: "sortCondition", to: "sortCondition", openTag: (t7) => {
const e2 = t7.getParent();
e2.fields || (e2.fields = []);
const s6 = t7.getSource();
e2.fields.push(s6), t7.copyTo("sortOn", at, "sortBy"), t7.copyTo("dxfId", at, "sortBy"), t7.copyTo("iconSet", at), t7.copyTo("customList", at);
const i2 = t7.getAttribute("ref");
if (i2) {
const t8 = r.fastStringToRange(i2, vt).colStart, o2 = r.fastStringToRange(e2.ref, vt), n3 = o2.colStart;
s6.offset = o2 ? t8 - n3 : t8;
}
s6.reverse = t7.getAttribute("descending", ot) ?? false;
} }), p4.registerVisitor({ from: "AlternateContent", to: null });
const T5 = (t7) => {
m3 = t7.getSource(), t7.copyTo("topLeft", at, "topLeftCell");
const e2 = bt(t7.getAttribute("defaultGridColor")), s6 = t7.getAttribute("colorId");
null === s6 || e2 || (t7.getSource().gridLineColor = "index" + parseFloat(s6)), t7.copyTo("showZeros", ot), t7.copyTo("showFormulas", ot), t7.copyTo("zoomScale", rt), t7.copyTo("showRowHeaders", ot, "showRowColHeaders"), t7.copyTo("showColumnHeaders", ot, "showRowColHeaders"), t7.copyTo("showRowGridlines", ot, "showGridLines"), t7.copyTo("showColumnGridlines", ot, "showGridLines");
};
p4.registerVisitor({ from: "sheetView", to: "view", openTag: (t7) => {
T5(t7);
}, closeTag: () => {
m3 = null;
} }), p4.registerVisitor({ from: "customSheetViews", to: "customSheetViews", openTag: (t7) => {
t7.setSource([]);
} }), p4.registerVisitor({ from: "customSheetView", to: [], openTag: (t7) => {
T5(t7);
}, closeTag: () => {
m3 = null;
} }), p4.registerVisitor({ from: "selection", to: "selection", openTag: (t7) => {
if (!m3) return;
t7.copyTo("cell", at, "activeCell"), t7.copyTo("rangeIndex", rt, "activeCellId");
const e2 = t7.getAttribute("activeCell"), s6 = t7.getAttribute("sqref");
s6 && s6 !== e2 && (t7.getSource().ranges = s6.split(" "));
} }), p4.registerVisitor({ from: "pane", to: "pane", openTag: (t7) => {
if (m3 && "frozen" === t7.getAttribute("state")) {
const e2 = {};
m3.freezePanes = e2, t7.copyToObject(e2, "topLeft", at, "topLeftCell");
const s6 = m3.topLeft ? r.fastStringToCell(m3.topLeft) : { colIndex: 0, rowIndex: 0 }, i2 = { colIndex: 0, rowIndex: 0 };
t7.copyToObject(i2, "colIndex", rt, "xSplit"), t7.copyToObject(i2, "rowIndex", rt, "ySplit");
const o2 = { colIndex: s6.colIndex + i2.colIndex, rowIndex: s6.rowIndex + i2.rowIndex };
e2.coords = r.cellToString(o2);
}
} }), p4.registerVisitor({ from: "tabColor", to: null, openTag: (e2) => {
const s6 = pt((t7) => e2.getAttribute(t7));
s6 && (t6.tabColor = s6);
} }), p4.registerVisitor({ from: "pageSetUpPr", to: "pageSetUpPr", openTag: (t7) => {
} }), p4.registerVisitor({ from: "outlinePr", to: "outlinePr", openTag: (t7) => {
} }), p4.registerVisitor({ from: "pageMargins", to: "pageMargins", openTag: (t7) => {
} }), p4.registerVisitor({ from: "pageSetup", to: "pageSetup", openTag: (t7) => {
} }), p4.registerVisitor({ from: "printOptions", to: "printOptions", openTag: (t7) => {
} }), p4.registerVisitor({ from: "mergeCells", to: "merges", openTag: (t7) => {
t7.setSource([]);
} }), p4.registerVisitor({ from: "mergeCell", to: [], openTag: (t7) => {
const e2 = t7.getAttribute("ref");
t7.setSource(e2);
} }), p4.registerVisitor({ from: "hyperlinks", to: "hyperlinks", openTag: (t7) => {
t7.setSource([]);
} }), p4.registerVisitor({ from: "hyperlink", to: [], openTag: (t7) => {
const e2 = t7.getAttribute("r:id"), i2 = t7.getAttribute("ref");
if (!i2) return void console.warn("No ref found for hyperlink");
t7.setKey(i2);
let o2 = e2 ? s5(e2) : "";
if ("string" != typeof o2) return void console.warn("Invalid address ", o2);
const r2 = t7.getAttribute("location");
o2.endsWith("\\") && (o2 = o2.substring(0, o2.length - 1));
const n3 = t7.getAttribute("location");
if (n3 && (r2 && r2 !== n3 && console.warn("display and location are different", r2, n3), o2 += "#" + n3), !o2) return void console.warn("No address found for hyperlink. r:id", e2);
let a5;
const l4 = t7.getAttribute("tooltip");
a5 = l4 ? { address: o2, tooltip: l4 } : o2, t7.setSource({ r: i2, v: a5 });
} }), p4.registerVisitor({ from: "drawing", to: "movables", openTag: (t7) => {
const e2 = t7.getAttribute("r:id");
if (!e2) return;
const i2 = s5(e2);
i2 ? t7.setSource(i2.movables) : console.warn("no drawing found for rId", e2);
} }), p4.registerVisitor({ from: "tableParts", to: "tables", openTag: (t7) => {
t7.setSource([]);
} }), p4.registerVisitor({ from: "tablePart", to: [], openTag: (t7) => {
const e2 = t7.getAttribute("r:id");
if (!e2) return;
const i2 = s5(e2);
i2 ? t7.setSource(i2) : console.warn("no table found for rId", e2);
} }), p4.registerVisitor({ from: "worksheet", to: "worksheet", openTag: (t7) => {
} }), p4.registerVisitor({ from: "sheetProtection", to: "protection", openTag: (t7) => {
let e2 = false;
if (t7.hasAttribute("sheet") && ot(t7.getAttribute("sheet")) && (e2 = true), !e2) return void t7.setSource(void 0);
const s6 = (t8) => true === t8 || "1" === t8 || "on" === t8 || "true" === t8 || false === t8 || "0" === t8 || "off" === t8 || "false" === t8 || null;
t7.copyTo("autoFilter", s6), t7.copyTo("deleteColumns", s6), t7.copyTo("formatCells", s6), t7.copyTo("formatColumns", s6), t7.copyTo("formatRows", s6), t7.copyTo("insertColumns", s6), t7.copyTo("insertHyperlinks", s6), t7.copyTo("insertRows", s6), t7.copyTo("objects", s6), t7.copyTo("pivotTables", s6), t7.copyTo("scenarios", s6), t7.copyTo("selectUnlockedCells", s6), t7.copyTo("selectUnlockedCells", s6), t7.copyTo("sort", s6);
const i2 = {};
t7.copyToObject(i2, "hash", at, "hashValue"), t7.copyToObject(i2, "algorithm", at, "algorithmName"), t7.copyToObject(i2, "salt", at, "saltValue"), t7.copyToObject(i2, "spinCount", rt), Object.keys(i2).length > 0 && (t7.getSource().password = i2);
} }), p4.registerVisitor({ from: "protectedRanges", to: "protectedRanges", openTag: (t7) => {
t7.setSource({});
} }), p4.registerVisitor({ from: "protectedRange", to: {}, openTag: (t7) => {
const e2 = t7.getAttribute("sqref");
t7.setKey(e2), t7.copyTo("name"), t7.copyTo("securityDescriptor");
const s6 = {};
t7.copyToObject(s6, "hash", at, "hashValue"), t7.copyToObject(s6, "algorithm", at, "algorithmName"), t7.copyToObject(s6, "salt", at, "saltValue"), t7.copyToObject(s6, "spinCount", rt), Object.keys(s6).length > 0 && (t7.getSource().password = s6);
} }), p4.registerVisitor({ from: "sheetFormatPr", to: "sheetFormatPr", openTag: (e2) => {
e2.copyToObject(t6, "defaultColSize", nt, "defaultColWidth"), e2.copyToObject(t6, "outlineLevelCol", rt, "outlineLevelCol");
const s6 = e2.getAttribute("customHeight");
"1" !== s6 && "true" !== s6 || e2.copyToObject(t6, "defaultRowSize", nt, "defaultRowHeight"), e2.copyToObject(t6, "outlineLevelRow", rt, "outlineLevelRow");
} }), p4.registerVisitor({ from: "cols", to: "cols", openTag: (t7) => {
t7.setSource([]);
} }), p4.registerVisitor({ from: "col", to: [], openTag: (t7) => {
t7.copyTo("min", (t8) => parseInt(t8) - 1), t7.copyTo("max", (t8) => parseInt(t8) - 1), t7.copyTo("sz", nt, "width"), t7.copyTo("cs", ot, "customWidth"), t7.copyTo("h", ot, "hidden"), t7.copyTo("l", rt, "outlineLevel"), t7.copyTo("s", rt, "style");
} }), p4.registerVisitor({ from: "oleObjects", to: null, openTag: (t7) => {
t7.warn("'OLE Objects' are not supported.");
} });
let y4 = null;
const b4 = { onOpenTag: (t7) => {
null === y4 && (y4 = "");
}, onText: (t7) => {
y4 += t7;
}, onEnd: () => {
const t7 = n2(y4);
return y4 = null, t7;
}, onError: (t7) => {
} };
return ((t7, s6, i2, o2, n3, a5) => {
let l4 = false, c5 = false, h6 = [], p5 = false, f6 = null, m4 = null, T6 = null, y5 = null, b5 = null, x4 = null;
const w4 = a5?.get("richData") ?? [], v4 = r.normalizeA1ToR1C1, S4 = u.createConflatingRanges(), C4 = /* @__PURE__ */ new Map(), k3 = [];
let A3 = null;
const D3 = u.createConflatingRanges();
let E3, P3 = false, O3 = -1, I3 = -1, V3 = null, L3 = null;
const N3 = [];
let R3 = null, $3 = -2, M3 = 0, j3 = "", H3 = "", F3 = "", X3 = "", B3 = "", W3 = "", _3 = "", q3 = "", z3 = "", U3 = "", G3 = "", Z3 = "", Q3 = "", J3 = "", K2 = true, Y2 = null;
return { ...i2, onEnd: () => {
N3.length > 0 && (s6.rows = N3);
let e2 = S4.done(wt);
const o3 = e2.length;
if (o3 > 0) {
const t8 = new Array(o3);
for (let s7 = 0; s7 < o3; s7++) {
const i3 = e2[s7], o4 = r.rangeToString(i3), n5 = i3.value[1], a7 = r.resolveRelativeToA1(n5, i3.rowStart, i3.colStart);
t8[s7] = [o4, a7];
}
s6.formulas = t8;
}
const n4 = D3.done(true), a6 = n4.length;
if (a6 > 0) {
const t8 = new Array(a6);
for (let e3 = 0; e3 < a6; e3++) {
const s7 = n4[e3], i3 = r.rangeToString(s7);
t8[e3] = i3;
}
s6.volatile = t8;
}
if (k3.length > 0 && (s6.dynamicArray = [...k3]), h6.length > 0) {
h6.sort(u.createRangeComparator(d.Orientation.Column));
const t8 = [];
let e3 = null, i3 = -1, o4 = -1, r2 = -1, n5 = -1, a7 = null;
const l6 = h6.length;
l6 > 0 && (e3 = h6[0], i3 = e3.colStart, o4 = e3.colEnd, r2 = e3.rowEnd, n5 = e3.value, t8.push(e3));
for (let s7 = 1; s7 < l6; s7++) a7 = h6[s7], n5 !== a7.value || i3 !== a7.colStart || o4 !== a7.colEnd || r2 + 1 !== a7.rowEnd ? (t8.push(a7), e3 = a7, i3 = e3.colStart, o4 = e3.colEnd, r2 = e3.rowEnd, n5 = e3.value) : (r2 = a7.rowEnd, e3.rowEnd = r2);
let c6 = [];
for (let e4 = 0; e4 < t8.length; e4++) {
const s7 = t8[e4];
c6.push({ r: { colStart: s7.colStart, colEnd: s7.colEnd, rowStart: s7.rowStart, rowEnd: s7.rowEnd }, v: s7.value });
}
s6.directStyles = c6;
}
const l5 = t7.build();
if (l5) {
const t8 = l5.tuples;
s6.data = t8;
}
i2?.onEnd?.();
}, onOpenTag: (t8) => {
let e2 = t8.name;
const s7 = e2.indexOf(":");
if (-1 !== s7 && (e2 = e2.slice(s7 + 1)), E3) {
const s8 = t8.attributes;
switch (e2) {
case "v":
c5 = true;
break;
case "f":
switch (s8.t ?? null) {
case null:
case "normal":
p5 = true;
break;
case "shared":
const t9 = s8.si;
m4 = s8.ref, f6 = t9;
break;
case "array":
p5 = true, m4 = s8.ref, A3 = [m4, false];
break;
case "datatable":
p5 = true, m4 = s8.ref, p5 = true;
}
void 0 !== s8.ca && D3.append(O3, I3);
break;
case "is":
return void (P3 = true);
}
return void (P3 && n3?.onOpenTag(t8));
}
if (l4) {
if ("c" === e2) {
E3 = t8;
const e3 = t8.attributes.r;
I3 = r.fastStringToCol(e3);
const s8 = t8.attributes.t;
void 0 === s8 ? L3 = null : (L3 = s8, "str" === L3 && (P3 = true));
let i3 = t8.attributes.s;
void 0 !== i3 && (i3 = parseInt(i3), Y2 && Y2.value === i3 && Y2.colEnd + 1 === I3 ? Y2.colEnd = I3 : (Y2 = { colStart: I3, rowStart: O3, colEnd: I3, rowEnd: O3, value: i3 }, h6.push(Y2)));
}
} else {
if ("row" === e2) {
l4 = true;
const e3 = t8.attributes.r;
if (O3 = parseInt(e3) - 1, M3 = 0, H3 = t8.attributes.customHeight, void 0 !== H3 && (M3 |= xt.CustomHeight), H3 !== z3 && (K2 = true, z3 = H3), j3 = t8.attributes.ht, void 0 !== j3 && (M3 |= xt.Ht), j3 !== q3 && (K2 = true, q3 = j3), F3 = t8.attributes.hidden, void 0 !== F3 && (M3 |= xt.Hidden), F3 !== U3 && (K2 = true, U3 = F3), B3 = t8.attributes.s, void 0 !== B3 && (M3 |= xt.S), B3 !== Z3 && (K2 = true, Z3 = B3), X3 = t8.attributes.customFormat, void 0 !== X3 && (M3 |= xt.CustomFormat), X3 !== G3 && (K2 = true, G3 = X3), W3 = t8.attributes.outlineLevel, void 0 !== W3 && (M3 |= xt.OutlineLevel), W3 !== Q3 && (K2 = true, Q3 = W3), _3 = t8.attributes.collapsed, void 0 !== _3 && (M3 |= xt.Collapsed), _3 !== J3 && (K2 = true, J3 = _3), 0 !== M3) if ($3 + 1 !== O3 || K2) {
const t9 = void 0 !== H3 && ("1" === H3 || "true" === H3), e4 = void 0 !== X3 && ("1" === X3 || "true" === X3);
R3 = { min: O3, max: O3, sz: t9 && void 0 !== j3 ? parseFloat(j3) : -1, csz: t9, h: void 0 !== F3 && ("1" === F3 || "true" === F3), s: t9 && void 0 !== B3 && "0" !== B3 ? parseInt(B3) : 0, cs: e4, l: void 0 === W3 || "0" === W3 ? 0 : parseInt(W3), cl: void 0 !== _3 && ("1" === _3 || "true" === _3) }, N3.push(R3);
} else R3.max = O3;
return $3 = O3, void (K2 = false);
}
i2?.onOpenTag(t8);
}
}, onCloseTag: (e2) => {
if (E3) {
let s7 = e2.name;
const i3 = s7.indexOf(":");
if (-1 !== i3 && (s7 = s7.slice(i3 + 1)), P3) if ("is" === s7 || "v" === s7) {
const e3 = n3?.onEnd();
null !== e3 && t7.addValue(O3, I3, "" + e3);
} else n3?.onCloseTag?.(e2);
return c5 && (c5 = false), void ("c" === s7 && (E3 = null, P3 = false));
}
if (l4) return l4 = false, void (Y2 = null);
i2?.onCloseTag(e2);
}, onText: (s7) => {
if (s7 = s7.trim(), c5) {
switch (V3 = null, L3) {
case null:
case "n":
V3 = parseFloat(s7);
break;
case "b":
V3 = "1" === s7 || "true" === s7;
break;
case "s":
V3 = s7;
break;
case "e":
if ("#VALUE!" === s7) {
const t9 = E3.attributes.vm;
if (void 0 !== t9) {
const s8 = w4[parseInt(t9) - 1];
if (s8 && s8.isFormulaError) {
V3 = { t: e.Error, v: s8.getCode() };
break;
}
}
}
const t8 = g.getBuiltInByLabel(s7);
t8 ? V3 = { t: e.Error, v: t8.getCode() } : (V3 = s7, o2?.(`Unknown formula error '${s7}' in cell ${r.cellToString({ colIndex: I3, rowIndex: O3 })}`));
break;
case "str":
case "inlineStr":
P3 = true;
}
null !== V3 && t7.addValue(O3, I3, V3);
}
if (A3 && ("e" === L3 && (A3[1] = true), k3.push(A3), A3 = null), f6) if (b5 === f6) y5 = x4;
else {
if (y5 = C4.get(f6), !y5) {
const t8 = [];
T6 = v4(s7, O3, I3, t8), y5 = [T6, t8, s7], C4.set(f6, y5);
}
b5 = f6, x4 = y5;
}
if (p5) {
const t8 = [];
T6 = v4(s7, O3, I3, t8), y5 = [T6, t8, s7];
}
if (y5) return S4.append(O3, I3, y5), y5 = null, p5 = false, f6 = null, void (m4 = null);
P3 ? n3?.onText(s7) : l4 || i2?.onText(s7);
} };
})(f5, t6, p4.createEventHandler(t6, () => {
}, c4), c4, b4, h5);
})(t5, (t6, e2 = false) => I2(t6, h4, e2) ?? null, j2, S3, 0, (t6) => {
m2 && (t6 = h4 + ": " + t6, m2?.(t6));
}, A2), a3 = ct(h4, P2), c3 = await (async (t6, e2 = 8388608) => {
await (async () => {
if ("undefined" == typeof ReadableStream) if ("undefined" == typeof window) {
const { ReadableStream: t7 } = await import("./CZako-U8KpGMYsbe.js");
globalThis.ReadableStream = t7;
} else console.warn("Browser does not support ReadableStream; consider loading a polyfill.");
})();
const s5 = new TextDecoder("utf-8");
let i2 = 0;
const o2 = t6 instanceof Uint8Array ? t6 : new Uint8Array(t6);
return new ReadableStream({ pull(t7) {
if (i2 >= o2.byteLength) return void t7.close();
const r2 = o2.subarray(i2, Math.min(i2 + e2, o2.byteLength)), n2 = s5.decode(r2, { stream: i2 + e2 < o2.byteLength });
t7.enqueue(n2), i2 += r2.length;
} }).getReader();
})(a3);
try {
await st.parseStream(c3, s4, { xmlns: false });
} catch (t6) {
throw console.warn(`Error parsing sheet: '${h4}'`, t6), new Error(`Error parsing sheet: '${h4}'`, { cause: t6 });
}
const p3 = O2(h4, l2);
let f4, T4 = /* @__PURE__ */ new Map();
if (p3) {
const e2 = "http://schemas.microsoft.com/office/2017/10/relationships/threadedComment";
let s5;
p3.forEach((t6, s6) => {
if (t6.type === e2) {
const t7 = I2(s6, h4, false, l2);
f4 = t7?.comments, f4 && f4.forEach((t8) => {
T4.set(t8.id, t8);
});
}
});
const i2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
if (p3.forEach((t6, e3) => {
if (t6.type === i2) {
const t7 = I2(e3, h4, false, l2);
s5 = t7;
}
}), s5 || f4) {
const e3 = f4 ?? [], i3 = s5?.comments;
if (i3) {
const t6 = s5?.authors;
for (let s6 = 0; s6 < i3.length; s6++) {
const o2 = i3[s6];
let r2 = void 0 !== o2.authorId ? t6[o2.authorId] : void 0;
if ((!r2 || r2.startsWith("tc=")) && (r2 = gt(r2.substring(3)), T4.has(r2))) continue;
let a4 = H2.get(r2);
a4 || (a4 = F2.get(r2)), a4 || (a4 = { id: n.uuidV4(), displayName: r2 }, F2.set(a4.displayName, a4), H2.set(a4.id, a4)), r2 = a4?.id ?? null;
const l3 = { id: n.uuidV4(), personId: r2, ref: o2.ref, done: false, asNote: true, content: o2.content };
e3.push(l3);
}
}
t5.comments = e3;
}
}
};
E2.push(s3());
} else C3 = a2 ? ct(h4, P2, (t5) => {
const e2 = y3.add({ buffer: t5 });
return e2.addReference(x3), v3.add(e2), b3.toResourceId(e2);
}, V2) : ht(h4, P2, f3, p2, V2);
}
return C3;
}, V2 = { paramMap: A2, getRefs: O2, getRef: I2, parsedRefs: D2, onWarning: m2, addPerson: (t3) => null }, L2 = [];
let N2 = 0;
h3.Strings && (N2 = parseInt(h3.Strings.Unique ?? h3.Strings.length ?? 0));
const R2 = h3.Strings ?? [];
for (let t3 = 0; t3 < N2; t3++) L2.push(R2[t3]?.t ?? "");
const $2 = /* @__PURE__ */ new Map();
let M2 = N2;
const j2 = (t3) => {
const e2 = $2.get(t3);
if (void 0 !== e2) return e2;
const s2 = M2;
return $2.set(t3, M2++), L2.push(t3), s2;
}, H2 = (ut("richstructure", h3, f3, p2, V2), ut("richdata", h3, f3, p2, V2), /* @__PURE__ */ new Map()), F2 = /* @__PURE__ */ new Map(), X2 = ut("people", h3, f3, p2);
let B2 = null;
if (X2.size > 0 && (B2 = X2.entries().next()?.value?.[1]?.persons, B2)) {
const t3 = B2.length;
for (let e2 = 0; e2 < t3; e2++) {
const t4 = B2[e2];
H2.set(t4.id, t4), H2.set(t4.displayName, t4);
}
}
const W2 = ut("themes", h3, f3, p2, V2);
let _2 = null;
if (W2 && W2.entries) {
let t3 = W2.entries().next();
t3?.value?.[1] && (_2 = t3.value[1]);
}
const q2 = new a(_2), z2 = ut("styles", h3, f3, p2, V2);
let U2 = z2.entries().next()?.value[1];
U2 && (U2 = JSON.parse(l(U2)));
const G2 = ut("workbooks", h3, f3, p2, V2);
await Promise.all(E2);
const Z2 = { ...G2.entries().next().value[1], styles: U2, theme: q2.toJSON() };
L2.length > 0 && (Z2.strings = L2), B2 && B2.length > 0 && (Z2.people = B2);
const Q2 = { ...T2, resources: y3, json: Z2 }, J2 = new c(Q2);
return v3.forEach((t3) => {
t3.deleteReference(x3);
}), b3.endPersist(), J2;
} catch (t3) {
let e2 = "Unable to parse XLSX.";
throw t3 instanceof p && (e2 = "Unable to open XLSX. There are too many rows or columns."), new Error(e2, { cause: t3 });
}
}, toBufferXLSX: async (s2, i2) => {
const o2 = await import("./DRaOLlMgixvUTDbQ.js"), r2 = await s2.toJSON(true), n2 = o2.utils.book_new();
for (let i3 = 0; i3 < r2.sheets.length; i3++) {
const a2 = r2.sheets[i3], l2 = o2.utils.json_to_sheet([{}]);
o2.utils.book_append_sheet(n2, l2, a2.name);
const c2 = a2.sheet, h2 = s2.getSheetAt(i3), u2 = h2.getUsedRange();
if (u2 ? (l2["!ref"] = u2.getA1(), u2.forEach((s3, i4) => {
const o3 = { t: "z" }, r3 = i4.getCell().getStyle();
if (!r3.isNormal()) {
let e2 = r3.getNumberFormat();
e2 !== t.Type.General && (e2 === t.Type.ShortDate ? e2 = "m/d/yyyy" : e2 === t.Type.MediumDate ? e2 = "d-mmm-yy" : e2 === t.Type.LongDate ? e2 = "[$-x-sysdate]dddd, mmmm dd, yyyy" : e2 === t.Type.ShortTime ? e2 = "h:mm" : e2 === t.Type.MediumTime ? e2 = "h:mm AM/PM" : e2 === t.Type.LongTime && (e2 = "h:mm:ss AM/PM"), o3.z = e2);
}
if (null !== s3) switch (i4.getType()) {
case e.Number:
o3.t = "n", o3.v = s3;
break;
case e.String:
o3.t = "s", o3.v = s3;
break;
case e.Boolean:
o3.t = "b", o3.v = s3;
break;
case e.Error:
o3.t = "e", o3.v = s3.toString();
case e.RichData:
}
l2[i4.getA1()] = o3;
})) : l2["!ref"] = "A1:A1", c2.merges?.length > 0) {
const t2 = [];
l2["!merges"] = t2;
for (let e2 = 0; e2 < c2.merges.length; e2++) t2.push(o2.utils.decode_range(c2.merges[e2]));
}
if (c2.cols?.length > 0) {
const t2 = [];
l2["!cols"] = t2;
const e2 = c2.cols, s3 = { width: c2.defaultColSize ?? h2.getColumnWidthAsFontUnit(h2.getColumnHeaders().getDefaultSize()) };
for (let i4 = 0; i4 < e2.length; i4++) {
const o3 = e2[i4];
for (let e3 = t2.length; e3 <= o3.min - 1; e3++) t2.push(s3);
const r3 = {};
void 0 !== o3.sz && (r3.width = o3.sz), void 0 !== o3.h && (r3.hidden = o3.h), void 0 !== o3.l && (r3.level = o3.l);
for (let e3 = o3.min; e3 <= o3.max; e3++) t2.push(r3);
}
}
}
return o2.write(n2, { type: "array", bookType: "xlsx" }), o2.write(n2, { type: "array", bookType: "xlsx" });
} }, Symbol.toStringTag, { value: "Module" }));
export {
Tt as a,
bt as b,
mt as c,
pt as d,
St as i,
yt as p,
gt as r,
ft as t
};