@poe-platform/safe-bash 0.1.745 → 0.1.747

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +5 -1
  2. package/dist/image-ast/browser/sharp.d.ts +1 -1
  3. package/dist/image-ast/index.js +133 -35
  4. package/dist/image-ast/sharp.d.ts +1 -1
  5. package/dist/safe-bash/chunks/{chunk-2F7Q532M.js → chunk-4GK4FAT6.js} +3 -3
  6. package/dist/safe-bash/chunks/{chunk-EAUCLWEZ.js → chunk-55AGFLG5.js} +540 -284
  7. package/dist/safe-bash/chunks/{chunk-WCNFCN2G.js → chunk-BS6QFRNX.js} +2 -2
  8. package/dist/safe-bash/chunks/{chunk-IZZ7KX4E.js → chunk-JCXAGOEK.js} +40 -3
  9. package/dist/safe-bash/chunks/{chunk-I3DOFJSJ.js → chunk-MUWJPSGN.js} +2 -2
  10. package/dist/safe-bash/chunks/{chunk-7RP6WOWK.js → chunk-OF2PDE3W.js} +2 -2
  11. package/dist/safe-bash/chunks/{src-FTMTU65U.js → src-T672TQJC.js} +2 -2
  12. package/dist/safe-bash/command-chunks/{chunk-DRCPJVZF.js → chunk-44N2IRVP.js} +17 -5
  13. package/dist/safe-bash/command-chunks/{chunk-LYKC7WJB.js → chunk-6742OVAC.js} +37 -3
  14. package/dist/safe-bash/command-chunks/{chunk-BMBXSLVX.js → chunk-6QU5OLPJ.js} +2 -2
  15. package/dist/safe-bash/command-chunks/{chunk-YHANNN7I.js → chunk-S3BO2NJT.js} +7 -0
  16. package/dist/safe-bash/commands/basic.d.ts +2 -0
  17. package/dist/safe-bash/commands/basic.js +236 -9
  18. package/dist/safe-bash/commands/pr/index.browser.js +1 -1
  19. package/dist/safe-bash/commands/streams.js +9 -56
  20. package/dist/safe-bash/commands/table-text/index.js +5 -1
  21. package/dist/safe-bash/commands/text.js +13 -2
  22. package/dist/safe-bash/commands/time-env/shared.js +2 -2
  23. package/dist/safe-bash/commands/time-env/sleep.js +6 -4
  24. package/dist/safe-bash/commands/timeout/index.d.ts +7 -0
  25. package/dist/safe-bash/commands/timeout/index.js +52 -32
  26. package/dist/safe-bash/commands/timeout/scheduler.js +7 -6
  27. package/dist/safe-bash/core.browser.js +2698 -543
  28. package/dist/safe-bash/opt-in/commands/shuf/random.js +2 -3
  29. package/dist/safe-bash/opt-in/shell/extensions/read/index.js +1 -1
  30. package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +1 -2
  31. package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +1 -8
  32. package/dist/safe-bash/playwright/adapter.d.ts +2 -0
  33. package/dist/safe-bash/playwright/private-target-transport.d.ts +1 -0
  34. package/dist/safe-bash/playwright/private-target-transport.js +21 -21
  35. package/dist/safe-bash/shell/runtime.d.ts +20 -1
  36. package/dist/safe-bash/shell/runtime.js +3021 -532
  37. package/dist/safe-bash/shell/sync-jq-expression.d.ts +6 -0
  38. package/dist/safe-bash/shell/sync-jq-expression.js +46 -0
  39. package/dist/safe-bash-command-cal/index.js +32 -12
  40. package/dist/safe-bash-command-hostname/index.js +22 -7
  41. package/dist/safe-bash-command-id/index.js +28 -9
  42. package/dist/safe-bash-command-pandoc/command.js +1 -1
  43. package/dist/safe-bash-command-pandoc/index.js +1 -1
  44. package/dist/safe-bash-command-ssconvert/command.d.ts +2 -2
  45. package/dist/safe-bash-command-ssconvert/contracts.d.ts +4 -0
  46. package/dist/safe-bash-command-ssconvert/engine.d.ts +2 -2
  47. package/dist/safe-bash-command-ssconvert/index.js +524 -276
  48. package/dist/safe-bash-command-whoami/index.js +26 -12
  49. package/dist/safe-bash-query-engine/index.js +3 -3
  50. package/dist/safe-bash-query-engine/interpreter.js +1 -1
  51. package/dist/safe-bash-query-engine/parser.js +1 -1
  52. package/dist/safe-bash-query-engine/query-core.js +3 -3
  53. package/dist/safe-playwright-cloudflare/browser-private-transport.js +8 -13
  54. package/dist/safe-playwright-cloudflare/browser-storage-control.js +13 -4
  55. package/dist/safe-playwright-cloudflare/browser-trace-archive.js +1 -1
  56. package/package.json +18 -14
  57. package/dist/image-ast/streams/node.d.ts +0 -10
  58. package/dist/image-ast/streams/node.js +0 -5
  59. package/dist/image-ast/streams/web.js +0 -94
@@ -6,10 +6,10 @@ import {
6
6
  // packages/safe-bash-command-ssconvert/dist/index.js
7
7
  init_buffer();
8
8
  import { parseXmlSteps } from "@poe-platform/safe-fs/xml";
9
- import { parseXmlSteps as parseXmlSteps2, XmlLimitError } from "@poe-platform/safe-fs/xml";
10
- import { parseXmlSteps as parseXmlSteps3, XmlLimitError as XmlLimitError2 } from "@poe-platform/safe-fs/xml";
9
+ import { parseXmlSteps as parseXmlSteps2 } from "@poe-platform/safe-fs/xml";
10
+ import { parseXmlSteps as parseXmlSteps3, XmlLimitError } from "@poe-platform/safe-fs/xml";
11
+ import { parseXmlSteps as parseXmlSteps4, XmlLimitError as XmlLimitError2 } from "@poe-platform/safe-fs/xml";
11
12
  import { parseXmlSteps as parseXmlSteps5, XmlLimitError as XmlLimitError3 } from "@poe-platform/safe-fs/xml";
12
- import { parseXmlSteps as parseXmlSteps4 } from "@poe-platform/safe-fs/xml";
13
13
  import { parseXmlSteps as parseXmlSteps6, XmlLimitError as XmlLimitError4 } from "@poe-platform/safe-fs/xml";
14
14
  import { retainFileSystemCleanup } from "@poe-platform/safe-fs/core";
15
15
  import {
@@ -76424,9 +76424,9 @@ function parseExpression(source, options) {
76424
76424
  }
76425
76425
  let sheetRelative;
76426
76426
  const readSheet = () => {
76427
+ if (grammar3.bracketReferences && grammar3.absoluteSheetReferences) sheetRelative = source[offset] !== "$";
76428
+ if (grammar3.absoluteSheetReferences && source[offset] === "$") offset++;
76427
76429
  if (grammar3.bracketReferences) {
76428
- if (grammar3.absoluteSheetReferences) sheetRelative = source[offset] !== "$";
76429
- if (grammar3.absoluteSheetReferences && source[offset] === "$") offset++;
76430
76430
  if (source[offset] === "'") return quoted("'", grammar3.stringEscape);
76431
76431
  const begin2 = offset;
76432
76432
  while (offset < source.length && source[offset] !== grammar3.sheetSeparator && !" []:' \r\n".includes(source[offset])) offset++;
@@ -76434,7 +76434,6 @@ function parseExpression(source, options) {
76434
76434
  }
76435
76435
  if (grammar3.unquotedSheets) {
76436
76436
  const begin2 = offset;
76437
- if (grammar3.absoluteSheetReferences && source[offset] === "$") offset++;
76438
76437
  while (letter(source[offset]) || digit(source[offset])) offset++;
76439
76438
  return source.slice(begin2, offset);
76440
76439
  }
@@ -76458,7 +76457,6 @@ function parseExpression(source, options) {
76458
76457
  return {};
76459
76458
  }
76460
76459
  offset++;
76461
- if (grammar3.absoluteSheetReferences && !grammar3.bracketReferences && sheet.startsWith("$")) sheet = sheet.slice(1);
76462
76460
  if (sheet.startsWith("[")) {
76463
76461
  const close = sheet.indexOf("]");
76464
76462
  if (close >= 0) {
@@ -78281,6 +78279,371 @@ var chartDataTypes = Object.freeze(Object.fromEntries(Object.entries({
78281
78279
  GODataVectorStr: { storage: "literal", dimensions: 1 },
78282
78280
  GODataMatrixVal: { storage: "literal", dimensions: 2 }
78283
78281
  }).map(([name, descriptor3]) => [name, Object.freeze(descriptor3)])));
78282
+ var urn = "urn:oasis:names:tc:opendocument:xmlns:";
78283
+ var odfEncryptionNamespace = "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0";
78284
+ var odfNamespaces = {
78285
+ xml: "http://www.w3.org/XML/1998/namespace",
78286
+ office: urn + "office:1.0",
78287
+ style: urn + "style:1.0",
78288
+ text: urn + "text:1.0",
78289
+ table: urn + "table:1.0",
78290
+ draw: urn + "drawing:1.0",
78291
+ fo: urn + "xsl-fo-compatible:1.0",
78292
+ xlink: "http://www.w3.org/1999/xlink",
78293
+ dc: "http://purl.org/dc/elements/1.1/",
78294
+ meta: urn + "meta:1.0",
78295
+ number: urn + "datastyle:1.0",
78296
+ svg: urn + "svg-compatible:1.0",
78297
+ chart: urn + "chart:1.0",
78298
+ config: urn + "config:1.0",
78299
+ form: urn + "form:1.0",
78300
+ script: urn + "script:1.0",
78301
+ of: urn + "of:1.2",
78302
+ manifest: urn + "manifest:1.0",
78303
+ gnm: "http://www.gnumeric.org/odf-extension/1.0",
78304
+ calcext: "urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
78305
+ };
78306
+ function odfObject(value3) {
78307
+ return value3 !== null && typeof value3 === "object" && !Array.isArray(value3) ? value3 : void 0;
78308
+ }
78309
+ function odfAttributes(value3, namespace5) {
78310
+ const source = odfObject(value3)?.attributes;
78311
+ if (Array.isArray(source)) return Object.fromEntries(source.flatMap((a3) => {
78312
+ const v = odfObject(a3);
78313
+ return typeof v?.name === "string" && typeof v.value === "string" && (namespace5 === void 0 || v.namespace === namespace5) ? [[v.name, v.value]] : [];
78314
+ }));
78315
+ if (namespace5 !== void 0) return {};
78316
+ return Object.fromEntries(Object.entries(odfObject(source) ?? {}).filter((entry2) => typeof entry2[1] === "string"));
78317
+ }
78318
+ function odfChildren(value3) {
78319
+ const source = odfObject(value3)?.children;
78320
+ return Array.isArray(source) ? source : [];
78321
+ }
78322
+ function createOdfXml(context, extended) {
78323
+ let work = 0, nodes = 0;
78324
+ const encoder3 = new TextEncoder(), names2 = /* @__PURE__ */ new Set();
78325
+ const declarations = {
78326
+ ...Object.fromEntries(Object.entries(odfNamespaces).map(([prefix, uri]) => ["xmlns:" + prefix, uri])),
78327
+ "xmlns:loext": odfEncryptionNamespace
78328
+ };
78329
+ function charge(amount = 1) {
78330
+ context.signal.throwIfAborted();
78331
+ if (!Number.isSafeInteger(amount) || amount < 0 || amount > (context.limits.workbookWork ?? Infinity) - work)
78332
+ throw new SsconvertError("resource-limit", "ssconvert OpenDocument work limit exceeded");
78333
+ work += amount;
78334
+ }
78335
+ function name(value3) {
78336
+ charge(value3.length);
78337
+ if (names2.has(value3)) return;
78338
+ try {
78339
+ const parser = parseXmlSteps(`<${value3} ${Object.entries(declarations).map(([k, v]) => `${k}="${v}"`).join(" ")}/>`, { maxNodes: 1, maxAttributes: 100 });
78340
+ let step = parser.next();
78341
+ while (!step.done) step = parser.next();
78342
+ if (step.value.name !== value3 || step.value.children.length) throw new Error("name");
78343
+ } catch {
78344
+ throw new SsconvertError("invalid-request", "Invalid OpenDocument XML name");
78345
+ }
78346
+ names2.add(value3);
78347
+ }
78348
+ function escape3(value3) {
78349
+ charge(value3.length);
78350
+ let result2 = "";
78351
+ for (const c4 of value3) {
78352
+ const code = c4.codePointAt(0);
78353
+ if (code < 32 && !" \n\r".includes(c4) || code === 65534 || code === 65535 || code >= 55296 && code <= 57343)
78354
+ throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: non-XML OpenDocument character");
78355
+ result2 += c4 === "&" ? "&amp;" : c4 === "<" ? "&lt;" : c4 === ">" ? "&gt;" : c4 === '"' ? "&quot;" : c4 === "\r" ? "&#13;" : c4 === "\n" ? "&#10;" : c4 === " " ? "&#9;" : c4;
78356
+ }
78357
+ return result2;
78358
+ }
78359
+ function element2(tag, attributes4 = {}, content2 = "") {
78360
+ charge();
78361
+ if (++nodes > (context.limits.workbookNodes ?? Infinity))
78362
+ throw new SsconvertError("resource-limit", "ssconvert OpenDocument XML nodes limit exceeded");
78363
+ name(tag);
78364
+ let result2 = "<" + tag;
78365
+ for (const [key, value3] of Object.entries(attributes4)) if (value3 !== void 0) {
78366
+ if (!key.startsWith("xmlns:")) name(key);
78367
+ result2 += ` ${key}="${escape3(String(value3))}"`;
78368
+ }
78369
+ result2 += content2 ? ">" + content2 + "</" + tag + ">" : "/>";
78370
+ if (result2.length > context.limits.outputBytes || encoder3.encode(result2).length > context.limits.outputBytes)
78371
+ throw new SsconvertError("resource-limit", "ssconvert OpenDocument output bytes limit exceeded");
78372
+ return result2;
78373
+ }
78374
+ function text2(value3) {
78375
+ charge(value3.length);
78376
+ let result2 = "", plain = "";
78377
+ function flush() {
78378
+ result2 += escape3(plain);
78379
+ plain = "";
78380
+ }
78381
+ for (let i = 0; i < value3.length; i++) {
78382
+ const c4 = value3[i];
78383
+ if (c4 === " ") {
78384
+ flush();
78385
+ let count = 1;
78386
+ while (value3[i + 1] === " ") {
78387
+ i++;
78388
+ count++;
78389
+ }
78390
+ result2 += element2("text:s", count > 1 ? { "text:c": count } : {});
78391
+ } else if (c4 === " " || c4 === "\n") {
78392
+ flush();
78393
+ result2 += element2(c4 === " " ? "text:tab" : "text:line-break");
78394
+ } else plain += c4;
78395
+ }
78396
+ flush();
78397
+ return result2;
78398
+ }
78399
+ const active = /* @__PURE__ */ new Set();
78400
+ function retained2(value3, depth = 0, hyperlink, hyperlinkContent = false) {
78401
+ charge();
78402
+ const v = odfObject(value3);
78403
+ if (!v || typeof v.name !== "string" || typeof v.namespace !== "string") return "";
78404
+ if (depth > (context.limits.xmlDepth ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert OpenDocument metadata depth limit exceeded");
78405
+ if (active.has(v)) throw new SsconvertError("invalid-request", "Invalid cyclic OpenDocument metadata");
78406
+ const prefix = Object.entries(odfNamespaces).find(([, uri]) => uri === v.namespace)?.[0];
78407
+ if (!prefix || !extended && ["gnm", "calcext"].includes(prefix)) return "";
78408
+ active.add(v);
78409
+ try {
78410
+ const attributes4 = {};
78411
+ if (Array.isArray(v.attributes)) for (const a3 of v.attributes) {
78412
+ charge();
78413
+ const attribute5 = odfObject(a3);
78414
+ if (typeof attribute5?.name !== "string" || typeof attribute5.value !== "string" || typeof attribute5.namespace !== "string") continue;
78415
+ const p2 = Object.entries(odfNamespaces).find(([, uri]) => uri === attribute5.namespace)?.[0];
78416
+ if (attribute5.namespace && (!p2 || !extended && ["gnm", "calcext"].includes(p2))) continue;
78417
+ attributes4[(p2 ? p2 + ":" : "") + attribute5.name] = attribute5.value;
78418
+ }
78419
+ if (prefix === "text" && v.name === "a" && attributes4["xlink:href"] !== void 0 && hyperlink)
78420
+ attributes4["xlink:href"] = hyperlink(attributes4["xlink:href"]);
78421
+ const children7 = odfChildren(v);
78422
+ const childHyperlinkContent = Boolean(hyperlink) && prefix === "text" && v.name === "a" && attributes4["xlink:href"] !== void 0;
78423
+ const content2 = Array.isArray(v.content) ? v.content.map((c4) => {
78424
+ charge();
78425
+ const item = odfObject(c4);
78426
+ if (item?.kind === "text" && typeof item.text === "string") return escape3(item.text);
78427
+ if (item?.kind !== "element") return "";
78428
+ if (item.index === void 0) return retained2(item.value, depth + 1, hyperlink, childHyperlinkContent);
78429
+ if (typeof item.index !== "number" || !Number.isSafeInteger(item.index) || item.index < 0 || item.index >= children7.length)
78430
+ throw new SsconvertError("invalid-request", "Invalid OpenDocument metadata child index");
78431
+ return retained2(children7[item.index], depth + 1, hyperlink, childHyperlinkContent);
78432
+ }).join("") : (typeof v.text === "string" ? escape3(v.text) : "") + children7.map((c4) => retained2(c4, depth + 1, hyperlink, childHyperlinkContent)).join("");
78433
+ if (hyperlinkContent && prefix === "text" && !content2 && !children7.length) {
78434
+ if (v.name === "s" && Object.keys(attributes4).every((key) => key === "text:c")) {
78435
+ const count = Number(attributes4["text:c"] ?? "1");
78436
+ if (!Number.isSafeInteger(count) || count < 0) throw new SsconvertError("invalid-request", "Invalid OpenDocument whitespace count");
78437
+ if (count > context.limits.outputBytes) throw new SsconvertError("resource-limit", "ssconvert OpenDocument output bytes limit exceeded");
78438
+ charge(count);
78439
+ return " ".repeat(count);
78440
+ }
78441
+ if (!Object.keys(attributes4).length && (v.name === "tab" || v.name === "line-break"))
78442
+ return escape3(v.name === "tab" ? " " : "\n");
78443
+ }
78444
+ return element2(prefix + ":" + v.name, attributes4, content2);
78445
+ } finally {
78446
+ active.delete(v);
78447
+ }
78448
+ }
78449
+ function document6(tag, body) {
78450
+ return '<?xml version="1.0" encoding="UTF-8"?>\n' + element2(tag, { ...declarations, "xmlns:loext": void 0, "office:version": "1.2" }, body);
78451
+ }
78452
+ return { element: element2, escape: escape3, text: text2, retained: retained2, document: document6, charge };
78453
+ }
78454
+ var linkGrammar = { ...excelGrammar, id: "odf-hyperlink", sheetSeparator: ".", absoluteSheetReferences: true };
78455
+ function decodeFragment(source, charge) {
78456
+ let result2 = "";
78457
+ for (let at = 0; at < source.length; ) {
78458
+ charge();
78459
+ const high = "0123456789abcdef".indexOf(source[at + 1]?.toLowerCase() ?? " ");
78460
+ const low = "0123456789abcdef".indexOf(source[at + 2]?.toLowerCase() ?? " ");
78461
+ if (source[at] !== "%" || high < 0 || low < 0) {
78462
+ result2 += source[at++];
78463
+ continue;
78464
+ }
78465
+ const octet = high * 16 + low;
78466
+ const length = octet >= 192 && octet <= 223 ? 6 : octet >= 224 && octet <= 239 ? 9 : octet >= 240 && octet <= 244 ? 12 : 3;
78467
+ const encoded2 = source.slice(at, at + length);
78468
+ try {
78469
+ result2 += decodeURIComponent(encoded2);
78470
+ at += length;
78471
+ } catch {
78472
+ result2 += source.slice(at, at + 3).toUpperCase();
78473
+ at += 3;
78474
+ }
78475
+ }
78476
+ return result2;
78477
+ }
78478
+ function encodeFragment(source) {
78479
+ return "#" + encodeURI(source).split("#").join("%23").split("?").join("%3F");
78480
+ }
78481
+ function translateOdfHyperlink(source, direction, charge, sheetNames = []) {
78482
+ charge(source.length);
78483
+ if (direction === "normalize" && !source.startsWith("#")) return source;
78484
+ function findSheet(name) {
78485
+ const folded = foldSheetName(name);
78486
+ return sheetNames.find((candidate) => {
78487
+ charge(candidate.length);
78488
+ return foldSheetName(candidate) === folded;
78489
+ });
78490
+ }
78491
+ let target = direction !== "export" && source.startsWith("#") ? source.slice(1) : source;
78492
+ if (direction !== "export") {
78493
+ target = decodeFragment(target, charge);
78494
+ const separator2 = target.indexOf(" (");
78495
+ if (separator2 > 0 && target.endsWith(")")) {
78496
+ const name = target.slice(0, separator2), sheet = findSheet(target.slice(separator2 + 2, -1));
78497
+ if (sheet !== void 0) {
78498
+ const qualified = quoteNativeSheet(sheet) + "!" + name;
78499
+ const parsed2 = parseExpression("=" + qualified, { position: { sheet, row: 0, column: 0 }, onWork: charge });
78500
+ if (parsed2.ok && parsed2.document.root.kind === "name" && parsed2.document.root.name === name && parsed2.document.root.sheet === sheet)
78501
+ return direction === "import" ? qualified : encodeFragment(target);
78502
+ }
78503
+ }
78504
+ }
78505
+ const parsed = parseExpression("=" + target, {
78506
+ grammar: direction !== "export" ? linkGrammar : gnumericGrammar,
78507
+ position: { sheet: "", row: 0, column: 0 },
78508
+ onWork: charge
78509
+ });
78510
+ if (parsed.ok) {
78511
+ const node3 = parsed.document.root;
78512
+ if (node3.kind === "name" && node3.workbook === void 0 || node3.kind === "reference" && !node3.label && node3.first.workbook === void 0 && node3.last?.workbook === void 0) {
78513
+ const sheet = direction !== "import" && node3.kind === "name" && node3.sheet !== void 0 ? findSheet(node3.sheet) : void 0;
78514
+ if (sheet !== void 0 && node3.kind === "name") return encodeFragment(node3.name + " (" + sheet + ")");
78515
+ if (direction !== "normalize") target = serializeExpression(parsed.document, direction === "import" ? { ...gnumericGrammar, quoteSheetName: quoteNativeSheet } : linkGrammar, false, true).slice(1);
78516
+ }
78517
+ }
78518
+ return direction === "import" ? target : direction === "normalize" ? source : encodeFragment(target);
78519
+ }
78520
+ function rewriteWorkbookHyperlinks(book, names2, context) {
78521
+ let work = 0;
78522
+ const maximum = context.limits.workbookWork ?? context.limits.inputBytes + context.limits.cells * 32;
78523
+ function charge(amount = 1) {
78524
+ context.signal.throwIfAborted();
78525
+ if (amount > maximum - work) throw new SsconvertError("resource-limit", "ssconvert hyperlink work limit exceeded");
78526
+ work += amount;
78527
+ }
78528
+ const sheets = [...book.sheets, ...book.detachedSheets ?? []].map((sheet2) => sheet2.name);
78529
+ const changes = new Map(sheets.flatMap((name) => {
78530
+ charge(name.length);
78531
+ const next = names2.get(foldSheetName(name));
78532
+ return next === void 0 || next === name ? [] : [[foldSheetName(name), next]];
78533
+ }));
78534
+ if (!changes.size) return book;
78535
+ const renamedSheets = sheets.map((name) => names2.get(foldSheetName(name)) ?? name);
78536
+ function target(source, odf) {
78537
+ charge(source.length);
78538
+ if (odf && !source.startsWith("#")) return source;
78539
+ const native = odf ? translateOdfHyperlink(source, "import", charge, sheets) : source;
78540
+ const parsed = parseExpression("=" + native, { position: { sheet: "", row: 0, column: 0 }, onWork: charge, signal: context.signal });
78541
+ if (!parsed.ok) return source;
78542
+ const node3 = parsed.document.root;
78543
+ const spellings = node3.kind === "name" && node3.workbook === void 0 ? [node3.sheet] : node3.kind === "reference" && !node3.label && node3.first.workbook === void 0 && node3.last?.workbook === void 0 ? [node3.first.sheet, node3.last?.sheet] : [];
78544
+ const replacements = /* @__PURE__ */ new Map();
78545
+ for (const spelling of spellings) if (spelling !== void 0) {
78546
+ charge(spelling.length);
78547
+ const name = changes.get(foldSheetName(spelling));
78548
+ if (name !== void 0 && name !== spelling) replacements.set(spelling, name);
78549
+ }
78550
+ if (!replacements.size) return source;
78551
+ const rewritten = rewriteReferences(parsed.document, { sheets: replacements, signal: context.signal }).slice(1);
78552
+ charge(rewritten.length);
78553
+ return odf ? translateOdfHyperlink(rewritten, "export", charge, renamedSheets) : rewritten;
78554
+ }
78555
+ function xml2(value3, odf, root, implicitNamespace = false) {
78556
+ let result2 = value3;
78557
+ const pending = [{ value: value3, role: root, depth: 0, assign: (next) => {
78558
+ result2 = next;
78559
+ } }];
78560
+ while (pending.length) {
78561
+ const item = pending.pop();
78562
+ charge();
78563
+ const node3 = odfObject(item.value);
78564
+ if (!node3 || typeof node3.name !== "string" || node3.name !== item.role) continue;
78565
+ const validNamespace = odf ? node3.namespace === odfNamespaces.text || node3.namespace === "http://openoffice.org/2000/text" : node3.namespace === "http://www.gnumeric.org/v10.dtd" || implicitNamespace && (node3.namespace === void 0 || node3.namespace === "");
78566
+ if (!validNamespace) continue;
78567
+ if (item.depth > (context.limits.xmlDepth ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert hyperlink depth limit exceeded");
78568
+ const updated = { ...node3 };
78569
+ item.assign(updated);
78570
+ const attributes4 = odfObject(node3.attributes);
78571
+ const list = Array.isArray(node3.attributes) ? node3.attributes : [];
78572
+ const field = (name, namespace5) => {
78573
+ if (attributes4 && !namespace5 && typeof attributes4[name] === "string") return attributes4[name];
78574
+ for (const value4 of list) {
78575
+ charge();
78576
+ const attribute5 = odfObject(value4);
78577
+ if (attribute5?.name === name && attribute5.namespace === namespace5 && typeof attribute5.value === "string") return attribute5.value;
78578
+ }
78579
+ return void 0;
78580
+ };
78581
+ const link = odf ? node3.name === "a" : node3.name === "HyperLink" && field("type", "") === "GnmHLinkCurWB";
78582
+ if (link) {
78583
+ const name = odf ? "href" : "target", namespace5 = odf ? odfNamespaces.xlink : "";
78584
+ const source = field(name, namespace5);
78585
+ if (source !== void 0) {
78586
+ const rewritten = target(source, odf);
78587
+ updated.attributes = attributes4 ? { ...attributes4, [name]: rewritten } : list.map((value4) => {
78588
+ charge();
78589
+ const attribute5 = odfObject(value4);
78590
+ return attribute5?.name === name && attribute5.namespace === namespace5 ? { ...attribute5, value: rewritten } : value4;
78591
+ });
78592
+ }
78593
+ }
78594
+ const childRole = odf ? void 0 : node3.name === "Styles" ? "StyleRegion" : node3.name === "StyleRegion" ? "Style" : node3.name === "Style" ? "HyperLink" : "";
78595
+ const enqueue = (value4, assign) => {
78596
+ charge();
78597
+ const child7 = odfObject(value4);
78598
+ if (typeof child7?.name === "string") pending.push({ value: value4, role: childRole ?? child7.name, depth: item.depth + 1, assign });
78599
+ };
78600
+ if (Array.isArray(node3.children)) {
78601
+ const children7 = [...node3.children];
78602
+ updated.children = children7;
78603
+ children7.forEach((child7, index2) => enqueue(child7, (next) => {
78604
+ children7[index2] = next;
78605
+ }));
78606
+ }
78607
+ if (odf && Array.isArray(node3.content)) {
78608
+ const content2 = [...node3.content];
78609
+ updated.content = content2;
78610
+ content2.forEach((value4, index2) => {
78611
+ charge();
78612
+ const entry2 = odfObject(value4);
78613
+ if (entry2?.kind === "element" && entry2.index === void 0 && entry2.value !== void 0)
78614
+ enqueue(entry2.value, (next) => {
78615
+ content2[index2] = { ...entry2, value: next };
78616
+ });
78617
+ });
78618
+ }
78619
+ }
78620
+ return result2;
78621
+ }
78622
+ const style2 = (value3) => {
78623
+ charge();
78624
+ return value3?.gnumeric === void 0 ? value3 : { ...value3, gnumeric: xml2(value3.gnumeric, false, "Style", true) };
78625
+ };
78626
+ const sheet = (value3) => ({
78627
+ ...value3,
78628
+ cells: value3.cells.map((cell) => {
78629
+ charge();
78630
+ return { ...cell, ...cell.style ? { style: style2(cell.style) } : {} };
78631
+ }),
78632
+ ...value3.rows ? { rows: value3.rows.map((row) => ({ ...row, ...row.style ? { style: style2(row.style) } : {} })) } : {},
78633
+ ...value3.columns ? { columns: value3.columns.map((column) => ({ ...column, ...column.style ? { style: style2(column.style) } : {} })) } : {},
78634
+ ...value3.unsupportedRecords ? { unsupportedRecords: value3.unsupportedRecords.map((record7) => {
78635
+ charge();
78636
+ if (record7.disposition !== "retained" || record7.data === void 0) return record7;
78637
+ if (record7.source === "Gnumeric_XmlIO:sax" && record7.kind === "Styles") return { ...record7, data: xml2(record7.data, false, "Styles") };
78638
+ if (record7.kind === "p" && (record7.source === "Gnumeric_OpenCalc:openoffice" || record7.source === "odf:cell-content")) {
78639
+ const data3 = odfObject(record7.data);
78640
+ return data3?.xml === void 0 ? { ...record7, data: xml2(record7.data, true, "p") } : { ...record7, data: { ...data3, xml: xml2(data3.xml, true, "p") } };
78641
+ }
78642
+ return record7;
78643
+ }) } : {}
78644
+ });
78645
+ return { ...book, sheets: book.sheets.map(sheet), ...book.detachedSheets ? { detachedSheets: book.detachedSheets.map(sheet) } : {} };
78646
+ }
78284
78647
  function rewriteWorkbook(book, context, rewrite) {
78285
78648
  let work = 0;
78286
78649
  const maximum = context.limits.workbookWork ?? context.limits.inputBytes + context.limits.cells * 32;
@@ -78337,14 +78700,14 @@ function renameWorkbookSheet(book, sheetId, name, context) {
78337
78700
  if (!sheet || !name || name.includes("\0") || book.sheets.some((s) => s.id !== sheetId && foldSheetName(s.name) === foldSheetName(name)))
78338
78701
  throw new SsconvertError("invalid-request", "Invalid sheet rename");
78339
78702
  if (sheet.name === name) return book;
78340
- const renamed = rewriteWorkbook(book, context, (document6) => {
78703
+ const renamed = rewriteWorkbookHyperlinks(rewriteWorkbook(book, context, (document6) => {
78341
78704
  const spellings = /* @__PURE__ */ new Map();
78342
78705
  visitFormula(document6.root, (node3) => {
78343
78706
  const names2 = node3.kind === "reference" ? [node3.first.sheet, node3.last?.sheet] : node3.kind === "name" ? [node3.sheet] : [];
78344
78707
  for (const spelling of names2) if (spelling !== void 0 && foldSheetName(spelling) === foldSheetName(sheet.name)) spellings.set(spelling, name);
78345
78708
  });
78346
78709
  return rewriteReferences(document6, { sheets: spellings, signal: context.signal });
78347
- });
78710
+ }), /* @__PURE__ */ new Map([[foldSheetName(sheet.name), name]]), context);
78348
78711
  return snapshotWorkbook({
78349
78712
  ...renamed,
78350
78713
  sheets: renamed.sheets.map((s) => s.id === sheetId ? { ...s, name } : s),
@@ -78354,15 +78717,15 @@ function renameWorkbookSheet(book, sheetId, name, context) {
78354
78717
  function remapWorkbookSheets(book, mapping, context) {
78355
78718
  context.signal.throwIfAborted();
78356
78719
  book = snapshotWorkbook(book, context.limits);
78357
- const names2 = new Map(book.sheets.map((sheet) => [foldSheetName(sheet.name), mapping.get(sheet.id)?.name ?? sheet.name]));
78358
- const rewritten = rewriteWorkbook(book, context, (document6) => {
78720
+ const names2 = new Map([...book.sheets, ...book.detachedSheets ?? []].map((sheet) => [foldSheetName(sheet.name), mapping.get(sheet.id)?.name ?? sheet.name]));
78721
+ const rewritten = rewriteWorkbookHyperlinks(rewriteWorkbook(book, context, (document6) => {
78359
78722
  const spellings = /* @__PURE__ */ new Map();
78360
78723
  visitFormula(document6.root, (node3) => {
78361
78724
  const refs = node3.kind === "reference" ? [node3.first.sheet, node3.last?.sheet] : node3.kind === "name" ? [node3.sheet] : [];
78362
78725
  for (const spelling of refs) if (spelling !== void 0 && names2.has(foldSheetName(spelling))) spellings.set(spelling, names2.get(foldSheetName(spelling)));
78363
78726
  });
78364
78727
  return rewriteReferences(document6, { sheets: spellings, signal: context.signal });
78365
- });
78728
+ }), names2, context);
78366
78729
  const id = (value3) => mapping.get(value3)?.id ?? value3;
78367
78730
  const renamedTitles = new Map(book.sheets.flatMap((sheet) => {
78368
78731
  const target = mapping.get(sheet.id);
@@ -84428,7 +84791,7 @@ var german = Object.freeze({
84428
84791
  shortWeekdays: Object.freeze(["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"])
84429
84792
  });
84430
84793
  function formattingLocale(name) {
84431
- if (["C", "POSIX", "C.UTF-8", "C.utf8", "en_US", "en_US.UTF-8"].includes(name)) return english;
84794
+ if (["C", "POSIX", "C.UTF-8", "C.utf8", "en_US", "en_US.UTF-8", "en_US.utf8"].includes(name)) return english;
84432
84795
  if (["de_DE", "de_DE.UTF-8", "de_DE.utf8"].includes(name)) return german;
84433
84796
  throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: uncaptured format locale");
84434
84797
  }
@@ -100501,7 +100864,7 @@ function createXlsxXml(context) {
100501
100864
  try {
100502
100865
  if (parts.length > 2) throw new Error("qualified name");
100503
100866
  for (const part of parts) {
100504
- const parser = parseXmlSteps(`<${part}/>`, { maxNodes: 1, maxAttributes: 1 });
100867
+ const parser = parseXmlSteps2(`<${part}/>`, { maxNodes: 1, maxAttributes: 1 });
100505
100868
  let step = parser.next();
100506
100869
  while (!step.done) step = parser.next();
100507
100870
  if (step.value.name !== part || step.value.namespace || step.value.children.length || step.value.attributes.length)
@@ -106961,7 +107324,10 @@ var capturedLocales = Object.freeze({
106961
107324
  C: "C",
106962
107325
  POSIX: "C",
106963
107326
  "C.UTF-8": "C.UTF-8",
106964
- "C.utf8": "C.UTF-8"
107327
+ "C.utf8": "C.UTF-8",
107328
+ en_US: "en_US",
107329
+ "en_US.UTF-8": "en_US.UTF-8",
107330
+ "en_US.utf8": "en_US.UTF-8"
106965
107331
  });
106966
107332
  function localeCategory(environment, category) {
106967
107333
  const env = environment.env;
@@ -108356,7 +108722,7 @@ async function openPackage(bytes, context) {
108356
108722
  const text2 = new TextDecoder(encoding, { fatal: true }).decode(plain);
108357
108723
  textBytes += plain.length;
108358
108724
  if (textBytes > (context.limits.workbookTextBytes ?? bounds2.maxTotalBytes)) limit("XML text");
108359
- const parser = parseXmlSteps2(text2, {
108725
+ const parser = parseXmlSteps3(text2, {
108360
108726
  expectedEncoding: encoding,
108361
108727
  maxDepth: context.limits.xmlDepth ?? Infinity,
108362
108728
  maxNodes: (context.limits.workbookNodes ?? Infinity) - nodes,
@@ -127757,7 +128123,8 @@ function encodeText(text2, charset, transliterate, context) {
127757
128123
  const suffixTransliteration = parts.length > 1 && parts.slice(1).every((part) => part.toLowerCase() === "translit");
127758
128124
  if (suffixTransliteration) transliterate = true;
127759
128125
  const base = suffixTransliteration ? parts[0] : charset;
127760
- const name = base === "" ? converterLocale(context.environment) === "C" ? "ascii" : "utf-8" : encodingName(base);
128126
+ const locale = base === "" ? converterLocale(context.environment) : void 0;
128127
+ const name = base === "" ? locale === "C" ? "ascii" : locale === "en_US" ? "iso-8859-1" : "utf-8" : encodingName(base);
127761
128128
  const admit2 = (length) => {
127762
128129
  context.signal.throwIfAborted();
127763
128130
  if (length > context.limits.outputBytes)
@@ -131084,7 +131451,7 @@ async function document3(bytes, context, probe = false) {
131084
131451
  const at = text2.indexOf(declared, encodingAt + 8);
131085
131452
  text2 = text2.slice(0, at) + "UTF-8" + text2.slice(at + declared.length);
131086
131453
  } else text2 = new TextDecoder(encoding, { fatal: true }).decode(bytes);
131087
- const parser = parseXmlSteps3(text2, {
131454
+ const parser = parseXmlSteps4(text2, {
131088
131455
  expectedEncoding: encoding,
131089
131456
  maxDepth: context.limits.xmlDepth ?? Infinity,
131090
131457
  maxNodes: context.limits.workbookNodes ?? Infinity,
@@ -139533,6 +139900,13 @@ function probeLotus(bytes, context) {
139533
139900
  return (b3.u16(0) === 0 || b3.u16(0) === 255) && ([1028, 1029, 1030].includes(version) ? length === 2 : [4098, 4099, 4100, 4101].includes(version) && length >= 19);
139534
139901
  }
139535
139902
  var lmbcsDoubleByteCodepages = { 16: 932, 17: 949, 18: 950, 19: 936 };
139903
+ function decodeSheetName(bytes) {
139904
+ const zero2 = bytes.indexOf(0);
139905
+ return Array.from(zero2 < 0 ? bytes : bytes.subarray(0, zero2), (byte) => {
139906
+ const character = singleByteTables["windows-1252"][byte];
139907
+ return character === "\uFFFF" ? String.fromCharCode(byte) : character;
139908
+ }).join("");
139909
+ }
139536
139910
  async function lmbcs(bytes, group, context) {
139537
139911
  let text2 = "";
139538
139912
  const warn = async (message) => context.diagnostic?.({ code: "lotus", severity: "warning", message });
@@ -139981,7 +140355,7 @@ async function readLotus(bytes, context) {
139981
140355
  at += length;
139982
140356
  if (id === 0) {
139983
140357
  if (modern) {
139984
- if (length >= 18) group = data3.u8(16);
140358
+ if (version >= 4098 && length >= 18) group = data3.u8(16);
139985
140359
  } else {
139986
140360
  active = sheets.length;
139987
140361
  sheet(active);
@@ -139997,8 +140371,7 @@ async function readLotus(bytes, context) {
139997
140371
  consumeOperation();
139998
140372
  if (length < 5) await warn(`Record with type 0x23 has wrong length ${length}.`);
139999
140373
  else {
140000
- const nameBytes = data3.bytes.subarray(4), zero2 = nameBytes.indexOf(0);
140001
- const name = new TextDecoder("windows-1252").decode(zero2 < 0 ? nameBytes : nameBytes.subarray(0, zero2));
140374
+ const name = decodeSheetName(data3.bytes.subarray(4));
140002
140375
  if (name) sheet(data3.u16(2)).name = name;
140003
140376
  }
140004
140377
  continue;
@@ -140200,8 +140573,7 @@ async function readLotus(bytes, context) {
140200
140573
  consumeOperation();
140201
140574
  if (length < 5) await warn(`Record with type 0x1b has wrong length ${length}.`);
140202
140575
  else {
140203
- const nameBytes = data3.bytes.subarray(4), zero2 = nameBytes.indexOf(0);
140204
- const name = new TextDecoder("windows-1252").decode(zero2 < 0 ? nameBytes : nameBytes.subarray(0, zero2));
140576
+ const name = decodeSheetName(data3.bytes.subarray(4));
140205
140577
  if (name) sheet(data3.u16(2)).name = name;
140206
140578
  }
140207
140579
  } else if (subtype === 4001) {
@@ -143177,50 +143549,6 @@ function prepareOdfFormulaLabels(book, context, tick) {
143177
143549
  });
143178
143550
  return { book, documents: documents2 };
143179
143551
  }
143180
- var linkGrammar = { ...excelGrammar, id: "odf-hyperlink", sheetSeparator: "." };
143181
- function translateOdfHyperlink(source, direction, charge, sheetNames = []) {
143182
- charge(source.length);
143183
- if (direction === "normalize" && !source.startsWith("#")) return source;
143184
- function findSheet(name) {
143185
- const folded = foldSheetName(name);
143186
- return sheetNames.find((candidate) => {
143187
- charge(candidate.length);
143188
- return foldSheetName(candidate) === folded;
143189
- });
143190
- }
143191
- let target = direction !== "export" && source.startsWith("#") ? source.slice(1) : source;
143192
- if (direction !== "export") {
143193
- try {
143194
- target = decodeURIComponent(target);
143195
- } catch {
143196
- if (direction === "normalize") return source;
143197
- }
143198
- const separator2 = target.indexOf(" (");
143199
- if (separator2 > 0 && target.endsWith(")")) {
143200
- const name = target.slice(0, separator2), sheet = findSheet(target.slice(separator2 + 2, -1));
143201
- if (sheet !== void 0) {
143202
- const qualified = quoteNativeSheet(sheet) + "!" + name;
143203
- const parsed2 = parseExpression("=" + qualified, { position: { sheet, row: 0, column: 0 }, onWork: charge });
143204
- if (parsed2.ok && parsed2.document.root.kind === "name" && parsed2.document.root.name === name && parsed2.document.root.sheet === sheet)
143205
- return direction === "import" ? qualified : source;
143206
- }
143207
- }
143208
- }
143209
- const parsed = parseExpression("=" + target, {
143210
- grammar: direction !== "export" ? linkGrammar : gnumericGrammar,
143211
- position: { sheet: "", row: 0, column: 0 },
143212
- onWork: charge
143213
- });
143214
- if (parsed.ok) {
143215
- const node3 = parsed.document.root;
143216
- if (node3.kind === "name" && node3.workbook === void 0 || node3.kind === "reference" && !node3.label && node3.first.workbook === void 0 && node3.last?.workbook === void 0) {
143217
- const sheet = direction !== "import" && node3.kind === "name" && node3.sheet !== void 0 ? findSheet(node3.sheet) : void 0;
143218
- if (sheet !== void 0 && node3.kind === "name") return "#" + encodeURI(node3.name + " (" + sheet + ")");
143219
- if (direction !== "normalize") target = serializeExpression(parsed.document, direction === "import" ? { ...gnumericGrammar, quoteSheetName: quoteNativeSheet } : linkGrammar, false, true).slice(1);
143220
- }
143221
- }
143222
- return direction === "import" ? target : direction === "normalize" ? source : "#" + encodeURI(target);
143223
- }
143224
143552
  var odfReaderStates = {
143225
143553
  opendoc_content_dtd: `START OFFICE OO_NS_OFFICE document-content
143226
143554
  OFFICE SCRIPT OO_NS_OFFICE scripts
@@ -143332,6 +143660,7 @@ TEXT_SPAN TEXT_LINE_BREAK OO_NS_TEXT line-break
143332
143660
  TEXT_SPAN TEXT_TAB OO_NS_TEXT tab
143333
143661
  TEXT_SPAN TEXT_ADDR OO_NS_TEXT a
143334
143662
  TEXT_ADDR TEXT_S OO_NS_TEXT s
143663
+ TEXT_ADDR TEXT_LINE_BREAK OO_NS_TEXT line-break
143335
143664
  TEXT_ADDR TEXT_TAB OO_NS_TEXT tab
143336
143665
  TEXT_ADDR TEXT_SPAN OO_NS_TEXT span
143337
143666
  CONTENT_VALIDATION HELP_MESSAGE OO_NS_TABLE help-message
@@ -143772,13 +144101,13 @@ MASTER_PAGE_FOOTER MASTER_PAGE_HF_R_RIGHT OO_NS_STYLE region-right
143772
144101
  MASTER_PAGE_FOOTER MASTER_PAGE_HF_R_CENTER OO_NS_STYLE region-center
143773
144102
  MASTER_PAGE_FOOTER MASTER_PAGE_HF_P OO_NS_TEXT p`
143774
144103
  };
143775
- var urn = "urn:oasis:names:tc:opendocument:xmlns:";
144104
+ var urn2 = "urn:oasis:names:tc:opendocument:xmlns:";
143776
144105
  var ns = {
143777
- table: [urn + "table:1.0", "http://openoffice.org/2000/table"],
143778
- office: [urn + "office:1.0", "http://openoffice.org/2000/office"],
143779
- text: [urn + "text:1.0", "http://openoffice.org/2000/text"],
143780
- style: [urn + "style:1.0", "http://openoffice.org/2000/style"],
143781
- fo: [urn + "xsl-fo-compatible:1.0", "http://www.w3.org/1999/XSL/Format"],
144106
+ table: [urn2 + "table:1.0", "http://openoffice.org/2000/table"],
144107
+ office: [urn2 + "office:1.0", "http://openoffice.org/2000/office"],
144108
+ text: [urn2 + "text:1.0", "http://openoffice.org/2000/text"],
144109
+ style: [urn2 + "style:1.0", "http://openoffice.org/2000/style"],
144110
+ fo: [urn2 + "xsl-fo-compatible:1.0", "http://www.w3.org/1999/XSL/Format"],
143782
144111
  dc: ["http://purl.org/dc/elements/1.1/"],
143783
144112
  xlink: ["http://www.w3.org/1999/xlink"],
143784
144113
  gnm: ["http://www.gnumeric.org/odf-extension/1.0"]
@@ -144020,8 +144349,8 @@ function odfDatabaseRanges(spreadsheet, sheetName2, charge) {
144020
144349
  var tableNamespaces = ["urn:oasis:names:tc:opendocument:xmlns:table:1.0", "http://openoffice.org/2000/table"];
144021
144350
  function readOdfLabelRanges(parent, sheets, context, charge) {
144022
144351
  const byName = new Map(sheets.map((sheet) => {
144023
- charge();
144024
- return [sheet.name, sheet];
144352
+ charge(1 + sheet.name.length);
144353
+ return [foldSheetName(sheet.name), sheet];
144025
144354
  }));
144026
144355
  const ranges2 = /* @__PURE__ */ new Map();
144027
144356
  const sizes = new Map(sheets.map((sheet) => {
@@ -144057,8 +144386,9 @@ function readOdfLabelRanges(parent, sheets, context, charge) {
144057
144386
  });
144058
144387
  if (!parsed.ok || parsed.document.root.kind !== "reference") return invalid10();
144059
144388
  const first = parsed.document.root.first, last = parsed.document.root.last ?? first;
144060
- const sheet = first.sheet === void 0 ? void 0 : byName.get(first.sheet);
144061
- if (!sheet || first.workbook !== void 0 || last.workbook !== void 0 || last.sheet && last.sheet !== first.sheet || !first.row || !first.column || !last.row || !last.column) return invalid10();
144389
+ const sheet = first.sheet === void 0 ? void 0 : byName.get(foldSheetName(first.sheet));
144390
+ const lastSheet = last.sheet === void 0 ? sheet : byName.get(foldSheetName(last.sheet));
144391
+ if (!sheet || first.workbook !== void 0 || last.workbook !== void 0 || lastSheet !== sheet || !first.row || !first.column || !last.row || !last.column) return invalid10();
144062
144392
  const range3 = { startRow: first.row.value, endRow: last.row.value, startColumn: first.column.value, endColumn: last.column.value };
144063
144393
  if (Object.values(range3).some((value3) => !Number.isSafeInteger(value3) || value3 < 0) || range3.startRow > range3.endRow || range3.startColumn > range3.endColumn || range3.endRow >= MAX_SHEET_SIZE.rows || range3.endColumn >= MAX_SHEET_SIZE.columns) return invalid10();
144064
144394
  return { sheet, range: range3 };
@@ -144089,166 +144419,6 @@ function readOdfLabelRanges(parent, sheets, context, charge) {
144089
144419
  return { ...sheet, size: sizes.get(sheet.id), ...pairs ? { labelRanges: pairs } : {} };
144090
144420
  });
144091
144421
  }
144092
- var urn2 = "urn:oasis:names:tc:opendocument:xmlns:";
144093
- var odfEncryptionNamespace = "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0";
144094
- var odfNamespaces = {
144095
- xml: "http://www.w3.org/XML/1998/namespace",
144096
- office: urn2 + "office:1.0",
144097
- style: urn2 + "style:1.0",
144098
- text: urn2 + "text:1.0",
144099
- table: urn2 + "table:1.0",
144100
- draw: urn2 + "drawing:1.0",
144101
- fo: urn2 + "xsl-fo-compatible:1.0",
144102
- xlink: "http://www.w3.org/1999/xlink",
144103
- dc: "http://purl.org/dc/elements/1.1/",
144104
- meta: urn2 + "meta:1.0",
144105
- number: urn2 + "datastyle:1.0",
144106
- svg: urn2 + "svg-compatible:1.0",
144107
- chart: urn2 + "chart:1.0",
144108
- config: urn2 + "config:1.0",
144109
- form: urn2 + "form:1.0",
144110
- script: urn2 + "script:1.0",
144111
- of: urn2 + "of:1.2",
144112
- manifest: urn2 + "manifest:1.0",
144113
- gnm: "http://www.gnumeric.org/odf-extension/1.0",
144114
- calcext: "urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
144115
- };
144116
- function odfObject(value3) {
144117
- return value3 !== null && typeof value3 === "object" && !Array.isArray(value3) ? value3 : void 0;
144118
- }
144119
- function odfAttributes(value3, namespace5) {
144120
- const source = odfObject(value3)?.attributes;
144121
- if (Array.isArray(source)) return Object.fromEntries(source.flatMap((a3) => {
144122
- const v = odfObject(a3);
144123
- return typeof v?.name === "string" && typeof v.value === "string" && (namespace5 === void 0 || v.namespace === namespace5) ? [[v.name, v.value]] : [];
144124
- }));
144125
- if (namespace5 !== void 0) return {};
144126
- return Object.fromEntries(Object.entries(odfObject(source) ?? {}).filter((entry2) => typeof entry2[1] === "string"));
144127
- }
144128
- function odfChildren(value3) {
144129
- const source = odfObject(value3)?.children;
144130
- return Array.isArray(source) ? source : [];
144131
- }
144132
- function createOdfXml(context, extended) {
144133
- let work = 0, nodes = 0;
144134
- const encoder3 = new TextEncoder(), names2 = /* @__PURE__ */ new Set();
144135
- const declarations = {
144136
- ...Object.fromEntries(Object.entries(odfNamespaces).map(([prefix, uri]) => ["xmlns:" + prefix, uri])),
144137
- "xmlns:loext": odfEncryptionNamespace
144138
- };
144139
- function charge(amount = 1) {
144140
- context.signal.throwIfAborted();
144141
- if (!Number.isSafeInteger(amount) || amount < 0 || amount > (context.limits.workbookWork ?? Infinity) - work)
144142
- throw new SsconvertError("resource-limit", "ssconvert OpenDocument work limit exceeded");
144143
- work += amount;
144144
- }
144145
- function name(value3) {
144146
- charge(value3.length);
144147
- if (names2.has(value3)) return;
144148
- try {
144149
- const parser = parseXmlSteps4(`<${value3} ${Object.entries(declarations).map(([k, v]) => `${k}="${v}"`).join(" ")}/>`, { maxNodes: 1, maxAttributes: 100 });
144150
- let step = parser.next();
144151
- while (!step.done) step = parser.next();
144152
- if (step.value.name !== value3 || step.value.children.length) throw new Error("name");
144153
- } catch {
144154
- throw new SsconvertError("invalid-request", "Invalid OpenDocument XML name");
144155
- }
144156
- names2.add(value3);
144157
- }
144158
- function escape3(value3) {
144159
- charge(value3.length);
144160
- let result2 = "";
144161
- for (const c4 of value3) {
144162
- const code = c4.codePointAt(0);
144163
- if (code < 32 && !" \n\r".includes(c4) || code === 65534 || code === 65535 || code >= 55296 && code <= 57343)
144164
- throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: non-XML OpenDocument character");
144165
- result2 += c4 === "&" ? "&amp;" : c4 === "<" ? "&lt;" : c4 === ">" ? "&gt;" : c4 === '"' ? "&quot;" : c4 === "\r" ? "&#13;" : c4 === "\n" ? "&#10;" : c4 === " " ? "&#9;" : c4;
144166
- }
144167
- return result2;
144168
- }
144169
- function element2(tag, attributes4 = {}, content2 = "") {
144170
- charge();
144171
- if (++nodes > (context.limits.workbookNodes ?? Infinity))
144172
- throw new SsconvertError("resource-limit", "ssconvert OpenDocument XML nodes limit exceeded");
144173
- name(tag);
144174
- let result2 = "<" + tag;
144175
- for (const [key, value3] of Object.entries(attributes4)) if (value3 !== void 0) {
144176
- if (!key.startsWith("xmlns:")) name(key);
144177
- result2 += ` ${key}="${escape3(String(value3))}"`;
144178
- }
144179
- result2 += content2 ? ">" + content2 + "</" + tag + ">" : "/>";
144180
- if (result2.length > context.limits.outputBytes || encoder3.encode(result2).length > context.limits.outputBytes)
144181
- throw new SsconvertError("resource-limit", "ssconvert OpenDocument output bytes limit exceeded");
144182
- return result2;
144183
- }
144184
- function text2(value3) {
144185
- charge(value3.length);
144186
- let result2 = "", plain = "";
144187
- function flush() {
144188
- result2 += escape3(plain);
144189
- plain = "";
144190
- }
144191
- for (let i = 0; i < value3.length; i++) {
144192
- const c4 = value3[i];
144193
- if (c4 === " ") {
144194
- flush();
144195
- let count = 1;
144196
- while (value3[i + 1] === " ") {
144197
- i++;
144198
- count++;
144199
- }
144200
- result2 += element2("text:s", count > 1 ? { "text:c": count } : {});
144201
- } else if (c4 === " " || c4 === "\n") {
144202
- flush();
144203
- result2 += element2(c4 === " " ? "text:tab" : "text:line-break");
144204
- } else plain += c4;
144205
- }
144206
- flush();
144207
- return result2;
144208
- }
144209
- const active = /* @__PURE__ */ new Set();
144210
- function retained2(value3, depth = 0, hyperlink) {
144211
- charge();
144212
- const v = odfObject(value3);
144213
- if (!v || typeof v.name !== "string" || typeof v.namespace !== "string") return "";
144214
- if (depth > (context.limits.xmlDepth ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert OpenDocument metadata depth limit exceeded");
144215
- if (active.has(v)) throw new SsconvertError("invalid-request", "Invalid cyclic OpenDocument metadata");
144216
- const prefix = Object.entries(odfNamespaces).find(([, uri]) => uri === v.namespace)?.[0];
144217
- if (!prefix || !extended && ["gnm", "calcext"].includes(prefix)) return "";
144218
- active.add(v);
144219
- try {
144220
- const attributes4 = {};
144221
- if (Array.isArray(v.attributes)) for (const a3 of v.attributes) {
144222
- charge();
144223
- const attribute5 = odfObject(a3);
144224
- if (typeof attribute5?.name !== "string" || typeof attribute5.value !== "string" || typeof attribute5.namespace !== "string") continue;
144225
- const p2 = Object.entries(odfNamespaces).find(([, uri]) => uri === attribute5.namespace)?.[0];
144226
- if (attribute5.namespace && (!p2 || !extended && ["gnm", "calcext"].includes(p2))) continue;
144227
- attributes4[(p2 ? p2 + ":" : "") + attribute5.name] = attribute5.value;
144228
- }
144229
- if (prefix === "text" && v.name === "a" && attributes4["xlink:href"] !== void 0 && hyperlink)
144230
- attributes4["xlink:href"] = hyperlink(attributes4["xlink:href"]);
144231
- const children7 = odfChildren(v);
144232
- const content2 = Array.isArray(v.content) ? v.content.map((c4) => {
144233
- charge();
144234
- const item = odfObject(c4);
144235
- if (item?.kind === "text" && typeof item.text === "string") return escape3(item.text);
144236
- if (item?.kind !== "element") return "";
144237
- if (item.index === void 0) return retained2(item.value, depth + 1, hyperlink);
144238
- if (typeof item.index !== "number" || !Number.isSafeInteger(item.index) || item.index < 0 || item.index >= children7.length)
144239
- throw new SsconvertError("invalid-request", "Invalid OpenDocument metadata child index");
144240
- return retained2(children7[item.index], depth + 1, hyperlink);
144241
- }).join("") : (typeof v.text === "string" ? escape3(v.text) : "") + children7.map((c4) => retained2(c4, depth + 1, hyperlink)).join("");
144242
- return element2(prefix + ":" + v.name, attributes4, content2);
144243
- } finally {
144244
- active.delete(v);
144245
- }
144246
- }
144247
- function document6(tag, body) {
144248
- return '<?xml version="1.0" encoding="UTF-8"?>\n' + element2(tag, { ...declarations, "xmlns:loext": void 0, "office:version": "1.2" }, body);
144249
- }
144250
- return { element: element2, escape: escape3, text: text2, retained: retained2, document: document6, charge };
144251
- }
144252
144422
  var iterations = 1024;
144253
144423
  var argon2 = { t: 3, m: 65536, p: 4, dkLen: 32, version: 19, maxmem: 64 * 1024 * 1024, asyncTick: 10 };
144254
144424
  var odfEncryptionProfiles = /* @__PURE__ */ new Map([
@@ -144563,8 +144733,8 @@ function createOdfStyles(xml2, extended, book, context) {
144563
144733
  }
144564
144734
  return { register, styles };
144565
144735
  }
144566
- function odfPrintStyles(records, index2, xml2, extended) {
144567
- const e = xml2.element, properties = { "style:print": "charts drawings objects" };
144736
+ function odfPrintProperties(records, xml2, extended) {
144737
+ const properties = { "style:print": "charts drawings objects" };
144568
144738
  for (const source of records) for (const n of odfChildren(source)) {
144569
144739
  xml2.charge();
144570
144740
  const v = odfObject(n), a3 = odfAttributes(n);
@@ -144582,10 +144752,80 @@ function odfPrintStyles(records, index2, xml2, extended) {
144582
144752
  } else if (a3.percentage) properties["style:scale-to"] = a3.percentage + "%";
144583
144753
  }
144584
144754
  }
144585
- return {
144586
- layout: e("style:page-layout", { "style:name": "pl" + index2 }, e("style:page-layout-properties", properties)),
144587
- master: e("style:master-page", { "style:name": "mp" + index2, "style:page-layout-name": "pl" + index2 })
144588
- };
144755
+ return properties;
144756
+ }
144757
+ function createOdfStyleDefinitions(book, xml2) {
144758
+ const sections = /* @__PURE__ */ new Map();
144759
+ const shapes2 = /* @__PURE__ */ new Map();
144760
+ const names2 = /* @__PURE__ */ new Set();
144761
+ let anonymous = 0;
144762
+ for (const record7 of book.unsupportedRecords ?? []) {
144763
+ xml2.charge();
144764
+ if (record7.source !== "Gnumeric_OpenCalc:openoffice") continue;
144765
+ const data3 = odfObject(record7.data);
144766
+ const section = record7.kind === "automatic-styles" ? data3?.packagePart === "styles.xml" ? "stylesAutomatic" : "contentAutomatic" : record7.kind === "master-styles" ? "masters" : record7.kind === "font-face-decls" ? "fonts" : record7.kind === "styles" ? "styles" : void 0;
144767
+ if (!section) continue;
144768
+ let entries = sections.get(section);
144769
+ if (!entries) {
144770
+ entries = /* @__PURE__ */ new Map();
144771
+ sections.set(section, entries);
144772
+ }
144773
+ for (const child7 of odfChildren(data3?.xml)) {
144774
+ xml2.charge();
144775
+ const node3 = odfObject(child7), attributes4 = odfAttributes(child7, odfNamespaces.style);
144776
+ const key = attributes4.name ? JSON.stringify([node3?.namespace, node3?.name, attributes4.family ?? "", attributes4.name]) : "anonymous:" + anonymous++;
144777
+ entries.set(key, child7);
144778
+ if (attributes4.name) names2.add(attributes4.name);
144779
+ }
144780
+ }
144781
+ for (const [section, entries] of sections) {
144782
+ const byShape = /* @__PURE__ */ new Map();
144783
+ shapes2.set(section, byShape);
144784
+ for (const child7 of entries.values()) {
144785
+ xml2.charge();
144786
+ const node3 = odfObject(child7), name = odfAttributes(child7, odfNamespaces.style).name;
144787
+ if (!node3 || !name || !Array.isArray(node3.attributes)) continue;
144788
+ const attributes4 = node3.attributes.filter((value3) => {
144789
+ xml2.charge();
144790
+ const attribute5 = odfObject(value3);
144791
+ return attribute5?.namespace !== odfNamespaces.style || attribute5?.name !== "name";
144792
+ });
144793
+ byShape.set(xml2.retained({ ...node3, attributes: attributes4 }), name);
144794
+ }
144795
+ }
144796
+ function register(section, tag, preferredName, attributes4, content2 = "") {
144797
+ const shape = xml2.element(tag, attributes4, content2);
144798
+ let byShape = shapes2.get(section);
144799
+ const existing = byShape?.get(shape);
144800
+ if (existing !== void 0) return existing;
144801
+ let name = preferredName, suffix = 1;
144802
+ while (names2.has(name)) {
144803
+ xml2.charge();
144804
+ name = preferredName + "_" + suffix++;
144805
+ }
144806
+ names2.add(name);
144807
+ let entries = sections.get(section);
144808
+ if (!entries) {
144809
+ entries = /* @__PURE__ */ new Map();
144810
+ sections.set(section, entries);
144811
+ }
144812
+ entries.set("generated:" + name, xml2.element(tag, { "style:name": name, ...attributes4 }, content2));
144813
+ if (!byShape) {
144814
+ byShape = /* @__PURE__ */ new Map();
144815
+ shapes2.set(section, byShape);
144816
+ }
144817
+ byShape.set(shape, name);
144818
+ return name;
144819
+ }
144820
+ function render(section) {
144821
+ let result2 = "";
144822
+ for (const value3 of sections.get(section)?.values() ?? []) {
144823
+ xml2.charge();
144824
+ result2 += typeof value3 === "string" ? value3 : xml2.retained(value3);
144825
+ }
144826
+ return result2;
144827
+ }
144828
+ return { register, render };
144589
144829
  }
144590
144830
  var odfWriterFunctionNames = Object.freeze({
144591
144831
  "ABS": "ABS",
@@ -145422,7 +145662,8 @@ async function readOdf(bytes, context) {
145422
145662
  const dateSystem = attr5(children5(calculation, "null-date")[0], "date-value")?.startsWith("1904") ? "1904" : "1900";
145423
145663
  const unsupportedRecords = [];
145424
145664
  const styles = readStyles(styleRoots, pkg.charge);
145425
- for (const r of styleRoots) for (const node3 of r.children) if (["styles", "automatic-styles", "master-styles", "font-face-decls", "font-decls"].includes(node3.localName)) unsupportedRecords.push(record4(node3));
145665
+ for (const r of styleRoots) for (const node3 of r.children) if (["styles", "automatic-styles", "master-styles", "font-face-decls", "font-decls"].includes(node3.localName))
145666
+ unsupportedRecords.push(record4(node3, { packagePart: r === preparseRoot ? "content.xml" : "styles.xml" }));
145426
145667
  if (manifest) unsupportedRecords.push(record4(manifest));
145427
145668
  for (const name of ["meta.xml", "settings.xml"]) if (pkg.entries.has(name)) unsupportedRecords.push(record4(await pkg.document(name)));
145428
145669
  const resources = /* @__PURE__ */ new Set();
@@ -145730,6 +145971,8 @@ async function readOdf(bytes, context) {
145730
145971
  if (calculation) unsupportedRecords.push(record4(calculation));
145731
145972
  if (!sheets.length) invalid4("no sheets");
145732
145973
  const iteration = children5(calculation, "iteration")[0];
145974
+ const iterationMaximum = Number(attr5(iteration, "steps") ?? "100");
145975
+ if (!Number.isSafeInteger(iterationMaximum) || iterationMaximum < 0) invalid4("invalid iteration count");
145733
145976
  const lookup = attr5(calculation, "automatic-find-labels");
145734
145977
  if (lookup !== void 0 && !["true", "false"].includes(lookup)) invalid4("invalid automatic label lookup setting");
145735
145978
  const book = {
@@ -145741,7 +145984,7 @@ async function readOdf(bytes, context) {
145741
145984
  unsupportedRecords,
145742
145985
  ...iteration ? { iteration: {
145743
145986
  enabled: attr5(iteration, "status") === "enable",
145744
- maximum: 100,
145987
+ maximum: iterationMaximum,
145745
145988
  tolerance: Number(attr5(iteration, "maximum-difference") ?? "0.001")
145746
145989
  } } : {}
145747
145990
  };
@@ -145999,40 +146242,40 @@ function createOdfWriter(profile) {
145999
146242
  "table:maximum-difference": iteration?.tolerance ?? 1e-3
146000
146243
  })
146001
146244
  );
146002
- let automatic = "", masters = "", styleBody = "", fontFaces = "", pageLayouts = "", spreadsheet = "", validations = "", databaseRanges = "";
146245
+ const definitions4 = createOdfStyleDefinitions(book, xml2);
146246
+ let automatic = "", spreadsheet = "", validations = "", databaseRanges = "";
146003
146247
  for (const record7 of book.unsupportedRecords ?? []) {
146004
146248
  xml2.charge();
146005
146249
  const v = odfObject(record7.data), node3 = odfObject(v?.xml);
146006
146250
  if (record7.source === "Gnumeric_OpenCalc:openoffice" && node3) {
146007
- if (["automatic-styles", "font-face-decls", "styles", "master-styles"].includes(record7.kind)) {
146008
- const content2 = odfChildren(node3).map((n) => xml2.retained(n)).join("");
146009
- if (record7.kind === "automatic-styles") automatic += content2;
146010
- else if (record7.kind === "master-styles") masters += content2;
146011
- else if (record7.kind === "font-face-decls") fontFaces += content2;
146012
- else styleBody += content2;
146013
- } else if (record7.kind === "content-validations") validations += odfChildren(node3).map((n) => xml2.retained(n)).join("");
146251
+ if (record7.kind === "content-validations") validations += odfChildren(node3).map((n) => xml2.retained(n)).join("");
146014
146252
  else if (record7.kind === "database-ranges") databaseRanges += xml2.retained(node3);
146015
146253
  }
146016
146254
  }
146017
146255
  for (const [index2, sheet] of book.sheets.entries()) {
146018
146256
  xml2.charge();
146019
- const sheetStyle = "ta" + index2;
146020
146257
  const view2 = odfObject(sheet.view?.gnumeric) ?? {}, properties = odfChildren(sheet.view?.odf).find((n) => odfObject(n)?.name === "table-properties");
146021
146258
  const originalProperties = odfAttributes(properties, odfNamespaces.gnm);
146022
- const print = odfPrintStyles((sheet.unsupportedRecords ?? []).filter((r) => r.kind === "PrintInformation").flatMap((r) => r.data ? [r.data] : []), index2, xml2, extended);
146023
- pageLayouts += print.layout;
146024
- masters += print.master;
146025
- automatic += e("style:style", { "style:name": sheetStyle, "style:family": "table", "style:master-page-name": "mp" + index2 }, e("style:table-properties", {
146026
- "table:display": sheet.visibility && sheet.visibility !== "visible" ? "false" : "true",
146027
- "style:writing-mode": Number(view2.RTL_Layout ?? 0) ? "rl-tb" : "lr-tb",
146028
- ...extended ? {
146029
- "gnm:display-formulas": String(Boolean(Number(view2.DisplayFormulas ?? 0))),
146030
- "gnm:display-col-header": String(!Number(view2.HideColHeader ?? 0)),
146031
- "gnm:display-row-header": String(!Number(view2.HideRowHeader ?? 0)),
146032
- "gnm:tab-color": originalProperties["tab-color"],
146033
- "gnm:tab-text-color": originalProperties["tab-text-color"]
146034
- } : {}
146035
- }));
146259
+ const print = odfPrintProperties((sheet.unsupportedRecords ?? []).filter((r) => r.kind === "PrintInformation").flatMap((r) => r.data ? [r.data] : []), xml2, extended);
146260
+ const layoutName = definitions4.register("stylesAutomatic", "style:page-layout", "pl" + index2, {}, e("style:page-layout-properties", print));
146261
+ const masterName = definitions4.register("masters", "style:master-page", "mp" + index2, { "style:page-layout-name": layoutName });
146262
+ const sheetStyle = definitions4.register(
146263
+ "contentAutomatic",
146264
+ "style:style",
146265
+ "ta" + index2,
146266
+ { "style:family": "table", "style:master-page-name": masterName },
146267
+ e("style:table-properties", {
146268
+ "table:display": sheet.visibility && sheet.visibility !== "visible" ? "false" : "true",
146269
+ "style:writing-mode": Number(view2.RTL_Layout ?? 0) ? "rl-tb" : "lr-tb",
146270
+ ...extended ? {
146271
+ "gnm:display-formulas": String(Boolean(Number(view2.DisplayFormulas ?? 0))),
146272
+ "gnm:display-col-header": String(!Number(view2.HideColHeader ?? 0)),
146273
+ "gnm:display-row-header": String(!Number(view2.HideRowHeader ?? 0)),
146274
+ "gnm:tab-color": originalProperties["tab-color"],
146275
+ "gnm:tab-text-color": originalProperties["tab-text-color"]
146276
+ } : {}
146277
+ })
146278
+ );
146036
146279
  const addresses = /* @__PURE__ */ new Map(), rowCells = /* @__PURE__ */ new Map();
146037
146280
  for (const cell of sheet.cells) {
146038
146281
  coordinate(cell.row, MAX_SHEET_SIZE.rows);
@@ -146270,8 +146513,9 @@ function createOdfWriter(profile) {
146270
146513
  }
146271
146514
  }
146272
146515
  xml2.charge(originalParagraphs.size);
146273
- const renderedText = cell.displayedText ?? await renderCellText(cell, book, context), rendered2 = xml2.text(renderedText), paragraph = originalParagraphs.get(key) ?? [...originalParagraphs.values()].find((p2) => row >= p2.range.startRow && row <= p2.range.endRow && start >= p2.range.startColumn && start <= p2.range.endColumn);
146516
+ const renderedText = cell.displayedText ?? await renderCellText(cell, book, context), paragraph = originalParagraphs.get(key) ?? [...originalParagraphs.values()].find((p2) => row >= p2.range.startRow && row <= p2.range.endRow && start >= p2.range.startColumn && start <= p2.range.endColumn);
146274
146517
  const link = meta?.link ?? links.get(key);
146518
+ const rendered2 = link ? xml2.escape(renderedText) : xml2.text(renderedText);
146275
146519
  content2 += paragraph?.text === renderedText ? paragraph.xml : e("text:p", {}, link ? e("text:a", link, rendered2) : rendered2);
146276
146520
  }
146277
146521
  const next = !cell && !merge && meta ? Math.min(meta.range.endColumn + 1, stops.find((s) => s > start) ?? meta.range.endColumn + 1) : start + 1;
@@ -146310,7 +146554,8 @@ function createOdfWriter(profile) {
146310
146554
  if (pair.axis !== "row" && pair.axis !== "column") throw new SsconvertError("invalid-request", "Invalid OpenDocument label orientation");
146311
146555
  const dataSheet = pair.dataSheet === void 0 ? sheet : labelSheets.get(pair.dataSheet);
146312
146556
  if (!dataSheet) throw new SsconvertError("unsupported-feature", "OpenDocument label data sheet is not exported");
146313
- const address = (r, name) => "$" + quoteFormulaString(name, "'", odfGrammar) + "." + formatA1(r.startRow, r.startColumn) + ":." + formatA1(r.endRow, r.endColumn);
146557
+ const absolute = (row, column) => "$" + formatA1(0, column).slice(0, -1) + "$" + (row + 1);
146558
+ const address = (r, name) => "$" + quoteFormulaString(name, "'", odfGrammar) + "." + absolute(r.startRow, r.startColumn) + ":." + absolute(r.endRow, r.endColumn);
146314
146559
  labelRanges += e("table:label-range", {
146315
146560
  "table:label-cell-range-address": address(pair.labels, sheet.name),
146316
146561
  "table:data-cell-range-address": address(pair.data, dataSheet.name),
@@ -146326,8 +146571,8 @@ function createOdfWriter(profile) {
146326
146571
  parts.set(name, encoder3.encode(value3));
146327
146572
  }
146328
146573
  part("mimetype", "application/vnd.oasis.opendocument.spreadsheet");
146329
- part("content.xml", xml2.document("office:document-content", e("office:scripts") + e("office:font-face-decls") + e("office:automatic-styles", {}, automatic + cellStyles.styles.join("")) + e("office:body", {}, e("office:spreadsheet", {}, spreadsheet))));
146330
- part("styles.xml", xml2.document("office:document-styles", e("office:font-face-decls", {}, fontFaces) + e("office:styles", {}, styleBody) + e("office:automatic-styles", {}, pageLayouts) + e("office:master-styles", {}, masters)));
146574
+ part("content.xml", xml2.document("office:document-content", e("office:scripts") + e("office:font-face-decls") + e("office:automatic-styles", {}, definitions4.render("contentAutomatic") + automatic + cellStyles.styles.join("")) + e("office:body", {}, e("office:spreadsheet", {}, spreadsheet))));
146575
+ part("styles.xml", xml2.document("office:document-styles", e("office:font-face-decls", {}, definitions4.render("fonts")) + e("office:styles", {}, definitions4.render("styles")) + e("office:automatic-styles", {}, definitions4.render("stylesAutomatic")) + e("office:master-styles", {}, definitions4.render("masters"))));
146331
146576
  part("meta.xml", xml2.document("office:document-meta", e("office:meta", {}, e("meta:generator", {}, "Gnumeric/1.12.61"))));
146332
146577
  part("settings.xml", xml2.document("office:document-settings", e("office:settings", {}, e(
146333
146578
  "config:config-item-set",
@@ -163715,7 +163960,7 @@ function bounded2(value3, maximum, name) {
163715
163960
  if (!Number.isSafeInteger(value3) || value3 < 0 || value3 > maximum)
163716
163961
  throw new SsconvertError("resource-limit", `ssconvert ${name} limit exceeded`);
163717
163962
  }
163718
- function createEngine(supplied) {
163963
+ function createEngine(supplied = {}) {
163719
163964
  const config = {
163720
163965
  ...supplied,
163721
163966
  ...supplied.entropy === void 0 ? {} : { entropy: Object.freeze({ read: supplied.entropy.read.bind(supplied.entropy) }) },
@@ -163723,16 +163968,19 @@ function createEngine(supplied) {
163723
163968
  ...supplied.fonts === void 0 ? {} : { fonts: Object.freeze({ resolve: supplied.fonts.resolve.bind(supplied.fonts) }) },
163724
163969
  ...supplied.password === void 0 ? {} : { password: Object.freeze({ read: supplied.password.read.bind(supplied.password) }) },
163725
163970
  ...supplied.runtimeFunctions === void 0 ? {} : { runtimeFunctions: snapshotRuntimeFunctions(supplied.runtimeFunctions) },
163971
+ codecs: supplied.codecs ?? [],
163726
163972
  limits: Object.freeze({ ...defaultSsconvertLimits, ...supplied.limits }),
163727
163973
  environment: Object.freeze({
163728
163974
  ...supplied.environment,
163729
- cwd: supplied.filesystem?.cwd ?? supplied.environment.cwd ?? supplied.environment.env.PWD ?? "/",
163730
- env: Object.freeze({ ...supplied.environment.env })
163975
+ locale: supplied.environment?.locale ?? "C",
163976
+ timezone: supplied.environment?.timezone ?? "UTC",
163977
+ cwd: supplied.filesystem?.cwd ?? supplied.environment?.cwd ?? supplied.environment?.env?.PWD ?? "/",
163978
+ env: Object.freeze({ ...supplied.environment?.env })
163731
163979
  })
163732
163980
  };
163733
163981
  if (config.datasource && Object.hasOwn(config.runtimeFunctions ?? {}, "ATL_LAST"))
163734
163982
  throw new TypeError("Conflicting ssconvert datasource runtime function: ATL_LAST");
163735
- if ((supplied.filesystem?.cwd !== void 0 || supplied.environment.cwd !== void 0) && (!config.environment.cwd.startsWith("/") || config.environment.cwd.includes("\0")))
163983
+ if ((supplied.filesystem?.cwd !== void 0 || supplied.environment?.cwd !== void 0) && (!config.environment.cwd.startsWith("/") || config.environment.cwd.includes("\0")))
163736
163984
  throw new TypeError("ssconvert cwd must be an absolute VFS path");
163737
163985
  for (const name of ["inputBytes", "outputBytes", "cells", "sheets", "operations"]) {
163738
163986
  const value3 = config.limits[name];