@poe-platform/safe-bash 0.1.755 → 0.1.757

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 (131) hide show
  1. package/dist/image-ast/index.browser.js +30 -6
  2. package/dist/image-ast/index.js +30 -6
  3. package/dist/pdf-ast/canvas.d.ts +1 -0
  4. package/dist/pdf-ast/index.js +26 -2
  5. package/dist/safe-bash/chunks/{chunk-LESPJ3OG.js → chunk-WNWIBBJZ.js} +15 -2
  6. package/dist/safe-bash/command-chunks/{chunk-S4J6MSLY.js → chunk-444OTXM7.js} +3 -3
  7. package/dist/safe-bash/command-chunks/{chunk-6AIOGLZO.js → chunk-CE6Z2ULX.js} +2 -2
  8. package/dist/safe-bash/command-chunks/{chunk-5VSGEE6J.js → chunk-F4IQCXZG.js} +5 -5
  9. package/dist/safe-bash/command-chunks/{chunk-F5MORDSU.js → chunk-FDNCPZQS.js} +32 -1
  10. package/dist/safe-bash/command-chunks/{chunk-SG3ZDZCX.js → chunk-FLMLM7Y4.js} +2 -2
  11. package/dist/safe-bash/command-chunks/{chunk-XRVNFK7Z.js → chunk-H2FQA4OU.js} +26 -2
  12. package/dist/safe-bash/command-chunks/{chunk-CT3FB722.js → chunk-J7UMKBRK.js} +1 -1
  13. package/dist/safe-bash/command-chunks/{chunk-KB2LQ4HG.js → chunk-KBBI4CSU.js} +2 -2
  14. package/dist/safe-bash/command-chunks/{chunk-QQOAK7JQ.js → chunk-KKJCKPTA.js} +1 -1
  15. package/dist/safe-bash/command-chunks/{chunk-7KS6PX4U.js → chunk-KSIGF4AG.js} +3 -3
  16. package/dist/safe-bash/command-chunks/{chunk-4HQ7WYSI.js → chunk-MED2BOOW.js} +30 -5
  17. package/dist/safe-bash/command-chunks/{chunk-JRNLDPLI.js → chunk-OZSWW23M.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-DKQ5REXF.js → chunk-QDPRSPHQ.js} +1 -1
  19. package/dist/safe-bash/command-chunks/{chunk-WOPU2VWF.js → chunk-RID3B5RE.js} +1 -1
  20. package/dist/safe-bash/command-chunks/{chunk-DVZCHNB5.js → chunk-S4MLIYSN.js} +7 -7
  21. package/dist/safe-bash/command-chunks/{chunk-REYTQLLB.js → chunk-TT2DMDBY.js} +1 -1
  22. package/dist/safe-bash/command-chunks/{chunk-UGX6MXDD.js → chunk-UIIT4ULR.js} +3 -3
  23. package/dist/safe-bash/command-chunks/{chunk-MENC7RPR.js → chunk-WI35236J.js} +1 -1
  24. package/dist/safe-bash/command-chunks/{chunk-A6NFLWZI.js → chunk-WKPOGTZY.js} +22 -6
  25. package/dist/safe-bash/command-chunks/{chunk-3DOHQQJR.js → chunk-Y64PA6IA.js} +8 -8
  26. package/dist/safe-bash/command-chunks/{chunk-6Z7OS3TZ.js → chunk-ZP5KDHB4.js} +7 -7
  27. package/dist/safe-bash/commands/pandoc/index.d.ts +1 -1
  28. package/dist/safe-bash/commands/pandoc/index.js +5 -3
  29. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  30. package/dist/safe-bash/commands/python/index.js +6 -0
  31. package/dist/safe-bash/commands/python/jspi.js +11 -2
  32. package/dist/safe-bash/core.browser.js +6 -4
  33. package/dist/safe-bash-command-csvkit/index.js +8 -8
  34. package/dist/safe-bash-command-ffmpeg/index.js +20 -2
  35. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  36. package/dist/safe-bash-command-pandoc/command.js +3 -3
  37. package/dist/safe-bash-command-pandoc/index.js +3 -3
  38. package/dist/safe-bash-command-pdfimages/index.js +26 -2
  39. package/dist/safe-bash-command-pdfinfo/index.js +26 -2
  40. package/dist/safe-bash-command-pdftk/index.js +26 -2
  41. package/dist/safe-bash-command-pdftoppm/index.js +26 -2
  42. package/dist/safe-bash-command-pdftotext/index.js +26 -2
  43. package/dist/safe-bash-command-qpdf/index.js +26 -2
  44. package/dist/safe-bash-command-sips/index.js +2 -2
  45. package/dist/safe-bash-command-soffice/index.js +17 -17
  46. package/dist/safe-bash-command-ssconvert/core.js +8 -8
  47. package/dist/safe-bash-command-ssconvert/formats/csv.js +9 -9
  48. package/dist/safe-bash-command-ssconvert/formats/ods.js +8 -8
  49. package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +1 -1
  50. package/dist/safe-bash-command-ssconvert/formats/xls.js +9 -8
  51. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +8 -8
  52. package/dist/safe-bash-command-ssconvert/index.js +133 -29
  53. package/dist/safe-bash-command-wkhtmltopdf/index.js +26 -2
  54. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  55. package/dist/safe-bash-contracts/filesystem-output.js +1 -1
  56. package/dist/safe-bash-mcp/index.js +4 -4
  57. package/dist/spreadsheet-engine/formulas/ast.d.ts +13 -0
  58. package/dist/spreadsheet-engine/formulas/conventions.js +1 -1
  59. package/dist/spreadsheet-engine/formulas/dependencies.js +2 -2
  60. package/dist/spreadsheet-engine/formulas/evaluator.js +2 -2
  61. package/dist/spreadsheet-engine/formulas/named-expressions.d.ts +2 -2
  62. package/dist/spreadsheet-engine/formulas/named-expressions.js +31 -5
  63. package/dist/spreadsheet-engine/formulas/parser.js +34 -0
  64. package/dist/spreadsheet-engine/formulas/rewriting.js +19 -1
  65. package/dist/spreadsheet-engine/formulas/serialization.js +6 -0
  66. package/dist/spreadsheet-format-xls/biff-write-formulas.js +2 -0
  67. package/dist/xlsx-ast/formula-semantics.js +2 -0
  68. package/package.json +2 -2
  69. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +1 -1
  70. package/dist/safe-bash/chunks/browser-ECQX6GMK.js +0 -6766
  71. package/dist/safe-bash/chunks/bz2-4OP3OWW3.js +0 -8
  72. package/dist/safe-bash/chunks/chunk-22XPAAOI.js +0 -173
  73. package/dist/safe-bash/chunks/chunk-44WUNUPV.js +0 -649
  74. package/dist/safe-bash/chunks/chunk-4E3SGG37.js +0 -876
  75. package/dist/safe-bash/chunks/chunk-4QTSSQKP.js +0 -898
  76. package/dist/safe-bash/chunks/chunk-5UVGPVXP.js +0 -410
  77. package/dist/safe-bash/chunks/chunk-64OE6Q6X.js +0 -3487
  78. package/dist/safe-bash/chunks/chunk-6IIFUPN2.js +0 -1526
  79. package/dist/safe-bash/chunks/chunk-6XDKK63A.js +0 -38959
  80. package/dist/safe-bash/chunks/chunk-BENDLTQD.js +0 -7065
  81. package/dist/safe-bash/chunks/chunk-BMO5LWEX.js +0 -534
  82. package/dist/safe-bash/chunks/chunk-BPMCPTNP.js +0 -1920
  83. package/dist/safe-bash/chunks/chunk-BRJTAWP5.js +0 -2955
  84. package/dist/safe-bash/chunks/chunk-C3GEIN7Q.js +0 -20054
  85. package/dist/safe-bash/chunks/chunk-CEWCRI6H.js +0 -2813
  86. package/dist/safe-bash/chunks/chunk-CGL53DQQ.js +0 -37
  87. package/dist/safe-bash/chunks/chunk-CTYJJD4O.js +0 -869
  88. package/dist/safe-bash/chunks/chunk-CWSS4MQA.js +0 -7
  89. package/dist/safe-bash/chunks/chunk-DLIGMTCP.js +0 -3266
  90. package/dist/safe-bash/chunks/chunk-EMAJ7WUW.js +0 -1031
  91. package/dist/safe-bash/chunks/chunk-FDKIZ2IJ.js +0 -1950
  92. package/dist/safe-bash/chunks/chunk-FZWJ2A7V.js +0 -3093
  93. package/dist/safe-bash/chunks/chunk-G2VCIF2J.js +0 -22
  94. package/dist/safe-bash/chunks/chunk-GVKBUQDX.js +0 -2649
  95. package/dist/safe-bash/chunks/chunk-IO2OGW3E.js +0 -28051
  96. package/dist/safe-bash/chunks/chunk-ISCZG7WA.js +0 -2648
  97. package/dist/safe-bash/chunks/chunk-JEFBTRY7.js +0 -174814
  98. package/dist/safe-bash/chunks/chunk-KJHDD4A2.js +0 -759
  99. package/dist/safe-bash/chunks/chunk-LB6HVRXS.js +0 -857
  100. package/dist/safe-bash/chunks/chunk-LLWAJOZH.js +0 -15
  101. package/dist/safe-bash/chunks/chunk-LMUKYZIJ.js +0 -708
  102. package/dist/safe-bash/chunks/chunk-M5SCNKIK.js +0 -2012
  103. package/dist/safe-bash/chunks/chunk-MJPFHANT.js +0 -3350
  104. package/dist/safe-bash/chunks/chunk-MZQW2DOL.js +0 -82
  105. package/dist/safe-bash/chunks/chunk-NB2V7EOY.js +0 -1348
  106. package/dist/safe-bash/chunks/chunk-NJVGOIYN.js +0 -17
  107. package/dist/safe-bash/chunks/chunk-OLNZHDIQ.js +0 -5141
  108. package/dist/safe-bash/chunks/chunk-OUUVROTM.js +0 -38
  109. package/dist/safe-bash/chunks/chunk-PA6GYKBQ.js +0 -151
  110. package/dist/safe-bash/chunks/chunk-PEFHZ226.js +0 -6957
  111. package/dist/safe-bash/chunks/chunk-QBB5P5KW.js +0 -4839
  112. package/dist/safe-bash/chunks/chunk-QHB7HBLA.js +0 -2317
  113. package/dist/safe-bash/chunks/chunk-RSAWYAEH.js +0 -973
  114. package/dist/safe-bash/chunks/chunk-UWLYRWT4.js +0 -739
  115. package/dist/safe-bash/chunks/chunk-V463NBQH.js +0 -13
  116. package/dist/safe-bash/chunks/chunk-WPUALYUS.js +0 -843
  117. package/dist/safe-bash/chunks/chunk-XHKFSRGU.js +0 -5747
  118. package/dist/safe-bash/chunks/chunk-XHRCLZ3N.js +0 -13391
  119. package/dist/safe-bash/chunks/chunk-XPF5XHLY.js +0 -15
  120. package/dist/safe-bash/chunks/chunk-ZBFOWARG.js +0 -305
  121. package/dist/safe-bash/chunks/chunk-ZG7GWQ5P.js +0 -1859
  122. package/dist/safe-bash/chunks/model-store-EIY3ZQLZ.js +0 -10
  123. package/dist/safe-bash/chunks/pdf-renderer-XIFUTX34.js +0 -22
  124. package/dist/safe-bash/chunks/pptx-ZL6L7KP2-O425BFIU.js +0 -30658
  125. package/dist/safe-bash/chunks/src-HHEPGR7U.js +0 -18969
  126. package/dist/safe-bash/chunks/src-V4VCM5OX.js +0 -187
  127. package/dist/safe-bash/chunks/usage-6TGVA2OM.js +0 -35
  128. package/dist/safe-bash/chunks/xz-EGQGQUEI.js +0 -8
  129. package/dist/safe-bash/chunks/xz-K2E2WLM6.js +0 -9
  130. package/dist/safe-bash/chunks/zstd-6JBLP5EF.js +0 -8
  131. package/dist/safe-bash/git_rust-C3QYOAZL.wasm +0 -0
@@ -38247,7 +38247,7 @@ var PdfPage = class {
38247
38247
  this.cachedContentAst = parseContentStream(bytes);
38248
38248
  this.isolatedInitialStream = false;
38249
38249
  const stm = cosStream(bytes, { compress });
38250
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38250
+ this.replaceContentStream(stm);
38251
38251
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38252
38252
  }
38253
38253
  getIsolatedContentAst() {
@@ -38264,9 +38264,33 @@ var PdfPage = class {
38264
38264
  this.cachedContentAst = [...nodes];
38265
38265
  const bytes = serializeContentAst(this.cachedContentAst);
38266
38266
  const streamObj = cosStream(bytes, { compress });
38267
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38267
+ this.replaceContentStream(streamObj);
38268
38268
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38269
38269
  }
38270
+ replaceContentStream(stream) {
38271
+ const contents = dictGet(this.pageDict, "Contents");
38272
+ if (contents?.kind === "ref") {
38273
+ let references = 0;
38274
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38275
+ const visited = /* @__PURE__ */ new Set();
38276
+ while (pending.length > 0 && references < 2) {
38277
+ const node = pending.pop();
38278
+ if (node.kind === "ref") {
38279
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38280
+ } else if (!visited.has(node)) {
38281
+ visited.add(node);
38282
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38283
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38284
+ else if (node.kind === "stream") pending.push(node.dict);
38285
+ }
38286
+ }
38287
+ if (references === 1) {
38288
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38289
+ return;
38290
+ }
38291
+ }
38292
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38293
+ }
38270
38294
  drawText(text, options) {
38271
38295
  const size = options.size ?? options.fontSize ?? 12;
38272
38296
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -11,8 +11,8 @@ import {
11
11
  readImageMetadata,
12
12
  resizeImage,
13
13
  rotateImage
14
- } from "../safe-bash/command-chunks/chunk-MENC7RPR.js";
15
- import "../safe-bash/command-chunks/chunk-XRVNFK7Z.js";
14
+ } from "../safe-bash/command-chunks/chunk-WI35236J.js";
15
+ import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
16
16
  import {
17
17
  init_buffer
18
18
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -1,37 +1,37 @@
1
1
  import {
2
2
  createEngine
3
- } from "../safe-bash/command-chunks/chunk-DVZCHNB5.js";
3
+ } from "../safe-bash/command-chunks/chunk-S4MLIYSN.js";
4
4
  import {
5
5
  xlsxFormat
6
- } from "../safe-bash/command-chunks/chunk-DKQ5REXF.js";
6
+ } from "../safe-bash/command-chunks/chunk-QDPRSPHQ.js";
7
7
  import {
8
8
  csvFormat
9
- } from "../safe-bash/command-chunks/chunk-3DOHQQJR.js";
10
- import "../safe-bash/command-chunks/chunk-UGX6MXDD.js";
9
+ } from "../safe-bash/command-chunks/chunk-Y64PA6IA.js";
10
+ import "../safe-bash/command-chunks/chunk-UIIT4ULR.js";
11
11
  import "../safe-bash/command-chunks/chunk-IDR3WWKI.js";
12
- import "../safe-bash/command-chunks/chunk-6AIOGLZO.js";
13
- import "../safe-bash/command-chunks/chunk-JRNLDPLI.js";
12
+ import "../safe-bash/command-chunks/chunk-CE6Z2ULX.js";
13
+ import "../safe-bash/command-chunks/chunk-OZSWW23M.js";
14
14
  import {
15
15
  odsFormat
16
- } from "../safe-bash/command-chunks/chunk-6Z7OS3TZ.js";
17
- import "../safe-bash/command-chunks/chunk-S4J6MSLY.js";
18
- import "../safe-bash/command-chunks/chunk-REYTQLLB.js";
19
- import "../safe-bash/command-chunks/chunk-5VSGEE6J.js";
20
- import "../safe-bash/command-chunks/chunk-SG3ZDZCX.js";
16
+ } from "../safe-bash/command-chunks/chunk-ZP5KDHB4.js";
17
+ import "../safe-bash/command-chunks/chunk-444OTXM7.js";
18
+ import "../safe-bash/command-chunks/chunk-TT2DMDBY.js";
19
+ import "../safe-bash/command-chunks/chunk-F4IQCXZG.js";
20
+ import "../safe-bash/command-chunks/chunk-FLMLM7Y4.js";
21
21
  import "../safe-bash/command-chunks/chunk-KOM3FNCE.js";
22
- import "../safe-bash/command-chunks/chunk-CT3FB722.js";
22
+ import "../safe-bash/command-chunks/chunk-J7UMKBRK.js";
23
23
  import "../safe-bash/command-chunks/chunk-6X2OX6IJ.js";
24
- import "../safe-bash/command-chunks/chunk-WOPU2VWF.js";
25
- import "../safe-bash/command-chunks/chunk-A6NFLWZI.js";
26
- import "../safe-bash/command-chunks/chunk-4HQ7WYSI.js";
27
- import "../safe-bash/command-chunks/chunk-F5MORDSU.js";
24
+ import "../safe-bash/command-chunks/chunk-RID3B5RE.js";
25
+ import "../safe-bash/command-chunks/chunk-WKPOGTZY.js";
26
+ import "../safe-bash/command-chunks/chunk-MED2BOOW.js";
27
+ import "../safe-bash/command-chunks/chunk-FDNCPZQS.js";
28
28
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
29
29
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
30
30
  import {
31
31
  PdfDocument,
32
32
  decodeFlate,
33
33
  rgb
34
- } from "../safe-bash/command-chunks/chunk-XRVNFK7Z.js";
34
+ } from "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
35
35
  import {
36
36
  init_buffer
37
37
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -3,13 +3,13 @@ import {
3
3
  createRegistry,
4
4
  createResourceIO,
5
5
  defaultSsconvertLimits
6
- } from "../safe-bash/command-chunks/chunk-DVZCHNB5.js";
7
- import "../safe-bash/command-chunks/chunk-6AIOGLZO.js";
8
- import "../safe-bash/command-chunks/chunk-JRNLDPLI.js";
9
- import "../safe-bash/command-chunks/chunk-S4J6MSLY.js";
10
- import "../safe-bash/command-chunks/chunk-REYTQLLB.js";
11
- import "../safe-bash/command-chunks/chunk-A6NFLWZI.js";
12
- import "../safe-bash/command-chunks/chunk-4HQ7WYSI.js";
6
+ } from "../safe-bash/command-chunks/chunk-S4MLIYSN.js";
7
+ import "../safe-bash/command-chunks/chunk-CE6Z2ULX.js";
8
+ import "../safe-bash/command-chunks/chunk-OZSWW23M.js";
9
+ import "../safe-bash/command-chunks/chunk-444OTXM7.js";
10
+ import "../safe-bash/command-chunks/chunk-TT2DMDBY.js";
11
+ import "../safe-bash/command-chunks/chunk-WKPOGTZY.js";
12
+ import "../safe-bash/command-chunks/chunk-MED2BOOW.js";
13
13
  import {
14
14
  DEFAULT_SHEET_SIZE,
15
15
  MAX_SHEET_SIZE,
@@ -23,7 +23,7 @@ import {
23
23
  snapshotWorkbook,
24
24
  updateWorkbook,
25
25
  validSheetSize
26
- } from "../safe-bash/command-chunks/chunk-F5MORDSU.js";
26
+ } from "../safe-bash/command-chunks/chunk-FDNCPZQS.js";
27
27
  import {
28
28
  init_buffer
29
29
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  csvFormat
3
- } from "../../safe-bash/command-chunks/chunk-3DOHQQJR.js";
4
- import "../../safe-bash/command-chunks/chunk-UGX6MXDD.js";
3
+ } from "../../safe-bash/command-chunks/chunk-Y64PA6IA.js";
4
+ import "../../safe-bash/command-chunks/chunk-UIIT4ULR.js";
5
5
  import "../../safe-bash/command-chunks/chunk-IDR3WWKI.js";
6
- import "../../safe-bash/command-chunks/chunk-6AIOGLZO.js";
7
- import "../../safe-bash/command-chunks/chunk-JRNLDPLI.js";
8
- import "../../safe-bash/command-chunks/chunk-S4J6MSLY.js";
9
- import "../../safe-bash/command-chunks/chunk-REYTQLLB.js";
6
+ import "../../safe-bash/command-chunks/chunk-CE6Z2ULX.js";
7
+ import "../../safe-bash/command-chunks/chunk-OZSWW23M.js";
8
+ import "../../safe-bash/command-chunks/chunk-444OTXM7.js";
9
+ import "../../safe-bash/command-chunks/chunk-TT2DMDBY.js";
10
10
  import "../../safe-bash/command-chunks/chunk-KOM3FNCE.js";
11
- import "../../safe-bash/command-chunks/chunk-A6NFLWZI.js";
12
- import "../../safe-bash/command-chunks/chunk-4HQ7WYSI.js";
13
- import "../../safe-bash/command-chunks/chunk-F5MORDSU.js";
11
+ import "../../safe-bash/command-chunks/chunk-WKPOGTZY.js";
12
+ import "../../safe-bash/command-chunks/chunk-MED2BOOW.js";
13
+ import "../../safe-bash/command-chunks/chunk-FDNCPZQS.js";
14
14
  import {
15
15
  init_buffer
16
16
  } from "../../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  odsFormat
3
- } from "../../safe-bash/command-chunks/chunk-6Z7OS3TZ.js";
4
- import "../../safe-bash/command-chunks/chunk-S4J6MSLY.js";
5
- import "../../safe-bash/command-chunks/chunk-REYTQLLB.js";
6
- import "../../safe-bash/command-chunks/chunk-CT3FB722.js";
3
+ } from "../../safe-bash/command-chunks/chunk-ZP5KDHB4.js";
4
+ import "../../safe-bash/command-chunks/chunk-444OTXM7.js";
5
+ import "../../safe-bash/command-chunks/chunk-TT2DMDBY.js";
6
+ import "../../safe-bash/command-chunks/chunk-J7UMKBRK.js";
7
7
  import "../../safe-bash/command-chunks/chunk-6X2OX6IJ.js";
8
- import "../../safe-bash/command-chunks/chunk-WOPU2VWF.js";
9
- import "../../safe-bash/command-chunks/chunk-A6NFLWZI.js";
10
- import "../../safe-bash/command-chunks/chunk-4HQ7WYSI.js";
11
- import "../../safe-bash/command-chunks/chunk-F5MORDSU.js";
8
+ import "../../safe-bash/command-chunks/chunk-RID3B5RE.js";
9
+ import "../../safe-bash/command-chunks/chunk-WKPOGTZY.js";
10
+ import "../../safe-bash/command-chunks/chunk-MED2BOOW.js";
11
+ import "../../safe-bash/command-chunks/chunk-FDNCPZQS.js";
12
12
  import "../../safe-bash/command-chunks/chunk-MKQVQMXO.js";
13
13
  import "../../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
14
14
  import {
@@ -12,7 +12,7 @@ import {
12
12
  parseExpression,
13
13
  quoteNativeSheet,
14
14
  serializeExpression
15
- } from "../../safe-bash/command-chunks/chunk-F5MORDSU.js";
15
+ } from "../../safe-bash/command-chunks/chunk-FDNCPZQS.js";
16
16
  import {
17
17
  init_buffer
18
18
  } from "../../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  encodeText
3
- } from "../../safe-bash/command-chunks/chunk-UGX6MXDD.js";
3
+ } from "../../safe-bash/command-chunks/chunk-UIIT4ULR.js";
4
4
  import "../../safe-bash/command-chunks/chunk-IDR3WWKI.js";
5
- import "../../safe-bash/command-chunks/chunk-JRNLDPLI.js";
5
+ import "../../safe-bash/command-chunks/chunk-OZSWW23M.js";
6
6
  import {
7
7
  exportOptionPairs
8
- } from "../../safe-bash/command-chunks/chunk-REYTQLLB.js";
8
+ } from "../../safe-bash/command-chunks/chunk-TT2DMDBY.js";
9
9
  import {
10
10
  BiffStrings,
11
11
  Binary,
@@ -16,20 +16,20 @@ import {
16
16
  isCfb,
17
17
  readBiffRecords,
18
18
  readCfb
19
- } from "../../safe-bash/command-chunks/chunk-QQOAK7JQ.js";
19
+ } from "../../safe-bash/command-chunks/chunk-KKJCKPTA.js";
20
20
  import {
21
21
  expandIndexSheetAreas,
22
22
  metadataNode
23
- } from "../../safe-bash/command-chunks/chunk-SG3ZDZCX.js";
23
+ } from "../../safe-bash/command-chunks/chunk-FLMLM7Y4.js";
24
24
  import {
25
25
  singleByteTables
26
26
  } from "../../safe-bash/command-chunks/chunk-KOM3FNCE.js";
27
- import "../../safe-bash/command-chunks/chunk-WOPU2VWF.js";
27
+ import "../../safe-bash/command-chunks/chunk-RID3B5RE.js";
28
28
  import {
29
29
  cellValueFormat,
30
30
  functionDescriptors,
31
31
  parseNamedExpression
32
- } from "../../safe-bash/command-chunks/chunk-4HQ7WYSI.js";
32
+ } from "../../safe-bash/command-chunks/chunk-MED2BOOW.js";
33
33
  import {
34
34
  DEFAULT_SHEET_SIZE,
35
35
  SsconvertError,
@@ -40,7 +40,7 @@ import {
40
40
  parseA1,
41
41
  parseExpression,
42
42
  quoteFormulaString
43
- } from "../../safe-bash/command-chunks/chunk-F5MORDSU.js";
43
+ } from "../../safe-bash/command-chunks/chunk-FDNCPZQS.js";
44
44
  import {
45
45
  init_buffer
46
46
  } from "../../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -5611,6 +5611,7 @@ var BiffFormulaWriter = class {
5611
5611
  push(last.subarray(2));
5612
5612
  } else push(first);
5613
5613
  } else if (node.kind === "name") {
5614
+ if (node.relocation) throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: live name relocation in BIFF output");
5614
5615
  if (node.workbook) {
5615
5616
  const bookIndex = this.externalBook(node.workbook), book = this.externalBooks[bookIndex];
5616
5617
  const scope2 = node.sheet === void 0 ? void 0 : this.externalScope(bookIndex, node.sheet);
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  xlsxFormat
3
- } from "../../safe-bash/command-chunks/chunk-DKQ5REXF.js";
4
- import "../../safe-bash/command-chunks/chunk-5VSGEE6J.js";
5
- import "../../safe-bash/command-chunks/chunk-SG3ZDZCX.js";
6
- import "../../safe-bash/command-chunks/chunk-CT3FB722.js";
3
+ } from "../../safe-bash/command-chunks/chunk-QDPRSPHQ.js";
4
+ import "../../safe-bash/command-chunks/chunk-F4IQCXZG.js";
5
+ import "../../safe-bash/command-chunks/chunk-FLMLM7Y4.js";
6
+ import "../../safe-bash/command-chunks/chunk-J7UMKBRK.js";
7
7
  import "../../safe-bash/command-chunks/chunk-6X2OX6IJ.js";
8
- import "../../safe-bash/command-chunks/chunk-WOPU2VWF.js";
9
- import "../../safe-bash/command-chunks/chunk-A6NFLWZI.js";
10
- import "../../safe-bash/command-chunks/chunk-4HQ7WYSI.js";
11
- import "../../safe-bash/command-chunks/chunk-F5MORDSU.js";
8
+ import "../../safe-bash/command-chunks/chunk-RID3B5RE.js";
9
+ import "../../safe-bash/command-chunks/chunk-WKPOGTZY.js";
10
+ import "../../safe-bash/command-chunks/chunk-MED2BOOW.js";
11
+ import "../../safe-bash/command-chunks/chunk-FDNCPZQS.js";
12
12
  import "../../safe-bash/command-chunks/chunk-MKQVQMXO.js";
13
13
  import "../../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
14
14
  import {
@@ -73156,7 +73156,7 @@ var odfGrammar = Object.freeze({
73156
73156
  prefixes: Object.freeze(["of:=", "oooc:=", "="]),
73157
73157
  functionPrefixes: Object.freeze(["ORG.GNUMERIC.", "COM.MICROSOFT."])
73158
73158
  });
73159
- var internalOdfGrammar = Object.freeze({ ...odfGrammar, internalLabels: true });
73159
+ var internalOdfGrammar = Object.freeze({ ...odfGrammar, internalLabels: true, internalNames: true });
73160
73160
  var sylkGrammar = Object.freeze({ ...gnumericGrammar, id: "sylk", address: "r1c1" });
73161
73161
  var sylkWriterGrammar = Object.freeze({ ...sylkGrammar, id: "sylk-writer", stringEscape: "raw" });
73162
73162
  var legacyOpenOfficeGrammar = Object.freeze({
@@ -74602,6 +74602,40 @@ function parseExpression(source, options) {
74602
74602
  throw new SsconvertError("resource-limit", "ssconvert formula node limit exceeded");
74603
74603
  try {
74604
74604
  const c4 = source[offset];
74605
+ if (source.startsWith("@name.", offset)) {
74606
+ if (grammar3.id !== "gnumeric" && !grammar3.internalNames)
74607
+ fail2("Internal live name in native formula");
74608
+ offset += 6;
74609
+ const relative = source.startsWith("relative", offset);
74610
+ if (!relative && !source.startsWith("absolute", offset))
74611
+ fail2("Invalid live name mode");
74612
+ offset += 8;
74613
+ const fixedSheet = source.startsWith(".fixed-sheet", offset);
74614
+ if (fixedSheet)
74615
+ offset += 12;
74616
+ if (source[offset++] !== "[")
74617
+ fail2("Invalid live name mode");
74618
+ const displacement = (separator2) => {
74619
+ const start2 = offset;
74620
+ if (source[offset] === "-")
74621
+ offset++;
74622
+ const begin = offset;
74623
+ while (digit(source[offset]))
74624
+ offset++;
74625
+ const value3 = Number(source.slice(start2, offset));
74626
+ if (offset === begin || !Number.isSafeInteger(value3) || source[offset++] !== separator2)
74627
+ fail2("Invalid live name displacement");
74628
+ return value3;
74629
+ };
74630
+ const row = displacement(","), column = displacement(","), sheet = displacement("]");
74631
+ if (!relative && (row !== 0 || column !== 0) || source[offset++] !== ":" || source[offset] !== '"')
74632
+ fail2("Invalid live name");
74633
+ const name = quoted('"', grammar3.stringEscape);
74634
+ if (!name)
74635
+ fail2("Empty live name");
74636
+ options.onName?.(name);
74637
+ return node3({ kind: "name", name, workbook: "", relocation: { relative, row, column, sheet, ...fixedSheet ? { sheetRelative: false } : {} }, start, end: offset });
74638
+ }
74605
74639
  if (c4 === "@" && !internalLabels)
74606
74640
  fail2("Internal label reference in native formula");
74607
74641
  if (c4 === "@" && internalLabels) {
@@ -75058,23 +75092,51 @@ function parseExpression(source, options) {
75058
75092
  return { ok: false, source, diagnostic };
75059
75093
  }
75060
75094
  }
75061
- function parseNamedExpression(name, book, parse3, tick, maximumDepth = Infinity) {
75095
+ function parseNamedExpression(name, book, parse3, tick, maximumDepth = Infinity, relocation) {
75062
75096
  if (name.expression === "" || name.expression === "=") {
75063
75097
  tick();
75064
75098
  return { kind: "literal", value: { kind: "blank" }, start: 0, end: 0 };
75065
75099
  }
75066
75100
  const position = name.position ?? { sheet: name.sheet ?? book.sheets[0]?.id ?? "", row: 0, column: 0 };
75101
+ function displace(ref, fallback) {
75102
+ if (!relocation || ref.workbook !== void 0)
75103
+ return ref;
75104
+ const origin = book.sheets.findIndex((sheet) => sheet.id === position.sheet);
75105
+ const index2 = ref.sheetRelative ? origin + (ref.sheetOffset ?? 0) : ref.sheet !== void 0 || fallback !== void 0 ? book.sheets.findIndex((sheet) => foldSheetName(sheet.name) === foldSheetName(ref.sheet ?? fallback)) : origin;
75106
+ const target = index2 >= 0 ? book.sheets[index2 + relocation.sheet] : void 0;
75107
+ if (!target)
75108
+ return void 0;
75109
+ const axis = (value3, key) => ({ value: value3.value + (value3.relative ? position[key] : 0) + relocation[key], relative: false });
75110
+ return { ...ref, sheet: target.name, sheetRelative: false, ...ref.row ? { row: axis(ref.row, "row") } : {}, ...ref.column ? { column: axis(ref.column, "column") } : {} };
75111
+ }
75067
75112
  function bind(node3, depth = 0) {
75068
75113
  tick();
75069
75114
  if (depth > maximumDepth)
75070
75115
  throw new SsconvertError("resource-limit", "ssconvert formula dependency depth limit exceeded");
75071
- if (node3.kind === "name" && (node3.workbook === void 0 || node3.workbook === "" && node3.sheet !== void 0)) {
75116
+ if (node3.kind === "reference" && relocation) {
75117
+ const first = displace(node3.first), last = node3.last ? displace(node3.last, node3.first.sheet) : void 0;
75118
+ if (!first || node3.last && !last)
75119
+ return { kind: "literal", value: { kind: "error", value: "#REF!" }, start: node3.start, end: node3.end };
75120
+ return { ...node3, first, ...last ? { last } : {} };
75121
+ }
75122
+ if (node3.kind === "name" && (node3.workbook === void 0 || node3.workbook === "")) {
75123
+ const inherited = relocation ? {
75124
+ ...relocation,
75125
+ row: relocation.row + (node3.relocation?.row ?? 0),
75126
+ column: relocation.column + (node3.relocation?.column ?? 0),
75127
+ sheet: relocation.sheet + (node3.relocation?.sheet ?? 0)
75128
+ } : node3.relocation;
75129
+ const bound = inherited ? { ...node3, relocation: inherited } : node3;
75130
+ if (node3.workbook === "" && node3.sheet === void 0)
75131
+ return bound;
75072
75132
  const scope = node3.sheet === void 0 ? name.sheet : book.sheets.find((sheet2) => foldSheetName(sheet2.name) === foldSheetName(node3.sheet))?.id;
75073
75133
  const target = resolveName(book, node3.name, scope);
75074
- if (target?.sheet === void 0)
75075
- return { kind: "name", name: node3.name, workbook: "", start: node3.start, end: node3.end };
75134
+ if (target?.sheet === void 0) {
75135
+ const { sheet: ignoredSheet, ...global2 } = bound;
75136
+ return { ...global2, workbook: "" };
75137
+ }
75076
75138
  const sheet = book.sheets.find((sheet2) => sheet2.id === target.sheet);
75077
- return sheet ? { ...node3, sheet: sheet.name } : node3;
75139
+ return sheet ? { ...bound, sheet: sheet.name } : bound;
75078
75140
  }
75079
75141
  if (node3.kind === "parentheses" || node3.kind === "unary")
75080
75142
  return { ...node3, child: bind(node3.child, depth + 1) };
@@ -75470,7 +75532,7 @@ function buildDependencyGraph(book, roots, resolve, parse3, tick, onRange, maxim
75470
75532
  const name = named(node3, position);
75471
75533
  if (!name || names2.has(name))
75472
75534
  return [];
75473
- return staticRanges(parseNamedExpression(name, book, parse3, tick, maximumDepth), position, /* @__PURE__ */ new Set([...names2, name]), depth + 1);
75535
+ return staticRanges(parseNamedExpression(name, book, parse3, tick, maximumDepth, node3.relocation), position, /* @__PURE__ */ new Set([...names2, name]), depth + 1);
75474
75536
  }
75475
75537
  if (node3.kind === "call" && (node3.name === "IF" || node3.name === "CHOOSE")) {
75476
75538
  const ranges3 = [];
@@ -75579,7 +75641,7 @@ function buildDependencyGraph(book, roots, resolve, parse3, tick, onRange, maxim
75579
75641
  if (node3.kind === "name" && (node3.workbook === void 0 || node3.workbook === "")) {
75580
75642
  const name = named(node3, position2);
75581
75643
  if (name && !names3.has(name)) {
75582
- pending.push({ node: parseNamedExpression(name, book, parse3, tick, maximumDepth), position: position2, names: /* @__PURE__ */ new Set([...names3, name]), depth: depth + 1 });
75644
+ pending.push({ node: parseNamedExpression(name, book, parse3, tick, maximumDepth, node3.relocation), position: position2, names: /* @__PURE__ */ new Set([...names3, name]), depth: depth + 1 });
75583
75645
  }
75584
75646
  }
75585
75647
  const children8 = node3.kind === "unary" || node3.kind === "parentheses" ? [node3.child] : node3.kind === "binary" ? [node3.left, node3.right] : node3.kind === "call" ? node3.args : node3.kind === "array" ? node3.rows.flat() : [];
@@ -76018,6 +76080,12 @@ function serializeExpression(document6, grammar3 = document6.grammar, preserveSo
76018
76080
  case "reference":
76019
76081
  return value3.label ? grammar3.quotedLabels === "openformula" && options.quotedLabel ? quoteFormulaString(options.quotedLabel(value3), "'", grammar3) : serializeLabelReference(value3, grammar3, position) : serializeReference(options.relativeSheets === "fixed" ? { ...value3.first, sheetRelative: false } : value3.first, options.relativeSheets === "fixed" && value3.last ? { ...value3.last, sheetRelative: false } : value3.last, grammar3, position);
76020
76082
  case "name": {
76083
+ if (value3.relocation) {
76084
+ if (grammar3.id !== "gnumeric" && !grammar3.internalNames)
76085
+ throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: live name relocation in target grammar");
76086
+ const { relative, row, column, sheet } = value3.relocation;
76087
+ return `@name.${relative ? "relative" : "absolute"}${value3.relocation.sheetRelative === false ? ".fixed-sheet" : ""}[${row},${column},${sheet}]:` + quoteFormulaString(value3.name, '"', grammar3);
76088
+ }
76021
76089
  if (grammar3.qualifiedNames === false && (value3.sheet !== void 0 || value3.workbook !== void 0))
76022
76090
  throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: qualified formula name in target grammar");
76023
76091
  if (value3.workbook === "" && grammar3.bracketReferences && value3.sheet === void 0)
@@ -76192,6 +76260,23 @@ function rewriteReferences(document6, edit) {
76192
76260
  const position = { ...target, sheet: document6.sheetNames?.[target.sheet] ?? target.sheet };
76193
76261
  changes.push({ start: node3.start, end: node3.end, text: label ? serializeLabelReference({ ...node3, first, ...last ? { last } : {}, label }, document6.grammar, position) : serializeReference(first, last, document6.grammar, position) });
76194
76262
  }
76263
+ } else if (node3.kind === "name" && node3.relocation && edit.translation === "copy") {
76264
+ const relocation = { ...node3.relocation };
76265
+ if (relocation.relative) {
76266
+ relocation.row += target.row - document6.position.row;
76267
+ relocation.column += target.column - document6.position.column;
76268
+ }
76269
+ if (relocation.sheetRelative !== false && target.sheet !== document6.position.sheet) {
76270
+ const origin = document6.sheetOrder?.indexOf(document6.position.sheet) ?? -1;
76271
+ const destination = document6.sheetOrder?.indexOf(target.sheet) ?? -1;
76272
+ if (origin < 0 || destination < 0)
76273
+ throw new SsconvertError("invalid-request", "Cross-sheet formula copy requires workbook tab order");
76274
+ relocation.sheet += destination - origin;
76275
+ }
76276
+ if (![relocation.row, relocation.column, relocation.sheet].every(Number.isSafeInteger))
76277
+ throw new SsconvertError("invalid-request", "Invalid live name displacement");
76278
+ const text2 = serializeExpression({ ...document6, root: { ...node3, relocation } }, document6.grammar, false).slice(document6.grammar.prefixes[0]?.length ?? 0);
76279
+ changes.push({ start: node3.start, end: node3.end, text: text2 });
76195
76280
  } else if (node3.kind === "name" && (node3.workbook === void 0 || node3.workbook === "") && node3.sheet && renamedSheet(node3.sheet) !== void 0) {
76196
76281
  const text2 = quoteFormulaString(renamedSheet(node3.sheet), "'", document6.grammar) + document6.grammar.sheetSeparator + node3.name;
76197
76282
  changes.push({ start: node3.start, end: node3.end, text: document6.grammar.bracketReferences ? "[" + text2 + "]" : text2 });
@@ -98933,7 +99018,7 @@ function* recalculateWorkbookSteps(input, context, options = false, onDiagnostic
98933
99018
  const name = book.names?.find((entry2) => entry2.sheet === sheet && matches(entry2)) ?? book.names?.find((entry2) => entry2.sheet === void 0 && matches(entry2));
98934
99019
  if (!name || names2.has(name))
98935
99020
  return error("#REF!");
98936
- return indirectRange(parseNamedExpression(name, book, parse3, tick, context.limits.formulaDependencyDepth ?? Infinity), position, /* @__PURE__ */ new Set([...names2, name]), depth2 + 1);
99021
+ return indirectRange(parseNamedExpression(name, book, parse3, tick, context.limits.formulaDependencyDepth ?? Infinity, node3.relocation), position, /* @__PURE__ */ new Set([...names2, name]), depth2 + 1);
98937
99022
  }
98938
99023
  function scalar2(value3, position) {
98939
99024
  const label = scalarLabels.get(value3);
@@ -99027,7 +99112,7 @@ function* recalculateWorkbookSteps(input, context, options = false, onDiagnostic
99027
99112
  const name = book.names?.find((entry2) => entry2.sheet === sheet && matches(entry2)) ?? book.names?.find((entry2) => entry2.sheet === void 0 && matches(entry2));
99028
99113
  if (!name || names2.has(name))
99029
99114
  return error("#NAME?");
99030
- return evaluate(parseNamedExpression(name, book, parse3, tick, context.limits.formulaDependencyDepth ?? Infinity), position, array, /* @__PURE__ */ new Set([...names2, name]), wantReference);
99115
+ return evaluate(parseNamedExpression(name, book, parse3, tick, context.limits.formulaDependencyDepth ?? Infinity, node3.relocation), position, array, /* @__PURE__ */ new Set([...names2, name]), wantReference);
99031
99116
  }
99032
99117
  if (node3.kind === "unary") {
99033
99118
  const apply = (value3) => {
@@ -126101,6 +126186,8 @@ var BiffFormulaWriter = class {
126101
126186
  } else
126102
126187
  push(first);
126103
126188
  } else if (node3.kind === "name") {
126189
+ if (node3.relocation)
126190
+ throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: live name relocation in BIFF output");
126104
126191
  if (node3.workbook) {
126105
126192
  const bookIndex = this.externalBook(node3.workbook), book = this.externalBooks[bookIndex];
126106
126193
  const scope2 = node3.sheet === void 0 ? void 0 : this.externalScope(bookIndex, node3.sheet);
@@ -136412,6 +136499,8 @@ function nativeOpenFormula(source, position, context, arrayStringLiterals = fals
136412
136499
  throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: automatic label intersection in Gnumeric output");
136413
136500
  if (node3.kind === "reference" && node3.label)
136414
136501
  throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: live label reference in Gnumeric output");
136502
+ if (node3.kind === "name" && node3.relocation)
136503
+ throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: live name relocation in Gnumeric output");
136415
136504
  });
136416
136505
  if (!source.startsWith("of:="))
136417
136506
  return source;
@@ -146798,17 +146887,8 @@ async function lotusFormula(bytes, format2, group, row, column, sheetIndex, shee
146798
146887
  stack.push("#NAME?");
146799
146888
  }
146800
146889
  } else {
146801
- const crossSheet = range3.first.sheet !== range3.last.sheet;
146802
- const endpoint = (point) => (point.sheet === sheetIndex && !crossSheet ? "" : quoteFormulaString(sheetName2(point.sheet), "'", gnumericGrammar) + "!") + ref(point.row, point.column, op === 7, op === 7);
146803
- const single = range3.first.row === range3.last.row && range3.first.column === range3.last.column && range3.first.sheet === range3.last.sheet;
146804
- const source = endpoint(range3.first) + (single ? "" : ":" + endpoint(range3.last));
146805
- stack.push(source);
146806
- if (crossSheet) indexRanges.set(source, {
146807
- firstSheet: range3.first.sheet,
146808
- lastSheet: range3.last.sheet,
146809
- first: ref(range3.first.row, range3.first.column, op === 7, op === 7),
146810
- last: ref(range3.last.row, range3.last.column, op === 7, op === 7)
146811
- });
146890
+ const fixedSheet = range3.first.sheet !== sheetIndex || range3.last.sheet !== sheetIndex;
146891
+ stack.push(`@name.${op === 7 ? "relative" : "absolute"}${fixedSheet ? ".fixed-sheet" : ""}[0,0,0]:` + quoteFormulaString(name, '"', gnumericGrammar));
146812
146892
  }
146813
146893
  } else if (modern && op >= 9 && op <= 11) {
146814
146894
  const length = op === 9 ? 4 : op === 10 ? 5 : 11;
@@ -146957,14 +147037,14 @@ async function lotusFormula(bytes, format2, group, row, column, sheetIndex, shee
146957
147037
  if (!parsed.ok) throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: Lotus relative-sheet formula");
146958
147038
  const substitute = (node3) => {
146959
147039
  context.signal.throwIfAborted();
146960
- if (node3.kind === "name") return relativeReferences.get(node3.name) ?? node3;
147040
+ if (node3.kind === "name") return node3.relocation ? node3 : relativeReferences.get(node3.name) ?? node3;
146961
147041
  if (node3.kind === "unary" || node3.kind === "parentheses") return { ...node3, child: substitute(node3.child) };
146962
147042
  if (node3.kind === "binary") return { ...node3, left: substitute(node3.left), right: substitute(node3.right) };
146963
147043
  if (node3.kind === "call") return { ...node3, args: node3.args.map(substitute) };
146964
147044
  if (node3.kind === "array") return { ...node3, rows: node3.rows.map((row2) => row2.map(substitute)) };
146965
147045
  return node3;
146966
147046
  };
146967
- const expression2 = serializeExpression({ ...parsed.document, root: substitute(parsed.document.root) }, odfGrammar, false, true);
147047
+ const expression2 = serializeExpression({ ...parsed.document, root: substitute(parsed.document.root) }, internalOdfGrammar, false, true);
146968
147048
  if (expression2.length > (context.limits.workbookTextBytes ?? context.limits.inputBytes))
146969
147049
  throw new SsconvertError("resource-limit", "ssconvert Lotus formula length limit exceeded");
146970
147050
  return expression2;
@@ -211564,7 +211644,7 @@ var PdfPage = class {
211564
211644
  this.cachedContentAst = parseContentStream(bytes);
211565
211645
  this.isolatedInitialStream = false;
211566
211646
  const stm = cosStream(bytes, { compress });
211567
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
211647
+ this.replaceContentStream(stm);
211568
211648
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
211569
211649
  }
211570
211650
  getIsolatedContentAst() {
@@ -211581,9 +211661,33 @@ var PdfPage = class {
211581
211661
  this.cachedContentAst = [...nodes];
211582
211662
  const bytes = serializeContentAst(this.cachedContentAst);
211583
211663
  const streamObj = cosStream(bytes, { compress });
211584
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
211664
+ this.replaceContentStream(streamObj);
211585
211665
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
211586
211666
  }
211667
+ replaceContentStream(stream) {
211668
+ const contents = dictGet(this.pageDict, "Contents");
211669
+ if (contents?.kind === "ref") {
211670
+ let references = 0;
211671
+ const pending = [...this.cosDoc.objects.values()].map((object5) => object5.value);
211672
+ const visited = /* @__PURE__ */ new Set();
211673
+ while (pending.length > 0 && references < 2) {
211674
+ const node3 = pending.pop();
211675
+ if (node3.kind === "ref") {
211676
+ if (node3.objectNumber === contents.objectNumber && node3.generationNumber === contents.generationNumber) references++;
211677
+ } else if (!visited.has(node3)) {
211678
+ visited.add(node3);
211679
+ if (node3.kind === "array") for (const item of node3.items) pending.push(item);
211680
+ else if (node3.kind === "dict") for (const entry2 of node3.entries) pending.push(entry2.value);
211681
+ else if (node3.kind === "stream") pending.push(node3.dict);
211682
+ }
211683
+ }
211684
+ if (references === 1) {
211685
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
211686
+ return;
211687
+ }
211688
+ }
211689
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
211690
+ }
211587
211691
  drawText(text2, options) {
211588
211692
  const size = options.size ?? options.fontSize ?? 12;
211589
211693
  const color5 = options.color ?? { r: 0, g: 0, b: 0 };
@@ -218595,7 +218699,7 @@ function forwardFileDescriptor(descriptor3, operation, capabilities, snapshot =
218595
218699
  write: (retained2, buffer, position, options) => operation("write", options, () => retained2.write(buffer, position, options)),
218596
218700
  truncate: (retained2, length, options) => operation("ftruncate", options, () => retained2.truncate(length, options)),
218597
218701
  sync: (retained2, dataOnly, options) => operation(dataOnly ? "fdatasync" : "fsync", options, () => retained2.sync(dataOnly, options)),
218598
- close: (retained2) => operation("close", {}, () => retained2.close())
218702
+ close: (retained2, options) => operation("close", {}, () => retained2.close(options))
218599
218703
  };
218600
218704
  }
218601
218705
  function integer6(value3, syscall, path2) {
@@ -218763,10 +218867,10 @@ var ManagedFileDescriptor = class {
218763
218867
  await backend.sync(backend.resource, dataOnly, forwarded);
218764
218868
  });
218765
218869
  }
218766
- close() {
218870
+ close(options = {}) {
218767
218871
  this.#closing ??= this.#pending.then(async () => {
218768
218872
  try {
218769
- await this.#backend.close(this.#backend.resource);
218873
+ await this.#backend.close(this.#backend.resource, options);
218770
218874
  } finally {
218771
218875
  this.#backend = void 0;
218772
218876
  this.#getPosition = void 0;
@@ -218824,7 +218928,7 @@ async function openFileDescriptor(path2, options, capabilities, acquire) {
218824
218928
  signal?.throwIfAborted();
218825
218929
  return descriptor3;
218826
218930
  } catch (error2) {
218827
- await finishCleanup(() => backend.close(backend.resource), true);
218931
+ await finishCleanup(() => backend.close(backend.resource, {}), true);
218828
218932
  signal?.throwIfAborted();
218829
218933
  throw error2;
218830
218934
  }