@poe-platform/safe-bash 0.1.816 → 0.1.817

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 (48) hide show
  1. package/dist/pdf-ast/content/evaluator.d.ts +4 -0
  2. package/dist/pdf-ast/cos/value-parser.d.ts +2 -0
  3. package/dist/pdf-ast/fonts/resolve.d.ts +5 -1
  4. package/dist/pdf-ast/index.js +172 -165
  5. package/dist/safe-bash/command-chunks/biff-KLS4T7FP-UO3CXFFF.js +5581 -0
  6. package/dist/safe-bash/command-chunks/chunk-2J4OQT3F.js +153 -0
  7. package/dist/safe-bash/command-chunks/{chunk-K7VDCBXW.js → chunk-ABL2DPJI.js} +20 -20
  8. package/dist/safe-bash/command-chunks/{chunk-RINR7XPR.js → chunk-E64ZI2YB.js} +121 -4
  9. package/dist/safe-bash/command-chunks/{chunk-GEDO5V32.js → chunk-FSG6UC2N.js} +243 -105
  10. package/dist/safe-bash/command-chunks/{chunk-4QEJPP3K.js → chunk-S5X7PBO4.js} +1 -1
  11. package/dist/safe-bash/command-chunks/{chunk-IHLZ6HNQ.js → chunk-TSKJNCKD.js} +3 -2
  12. package/dist/safe-bash/command-chunks/{chunk-DBZCTL7C.js → chunk-UYZ6EFZE.js} +20 -18
  13. package/dist/safe-bash/command-chunks/{chunk-B2C3UPJS.js → chunk-W42SUPD6.js} +13 -1
  14. package/dist/safe-bash/command-chunks/chunk-ZHHALBM7.js +398 -0
  15. package/dist/safe-bash/command-chunks/{command-engine-GHE6QUHU.js → command-engine-2QXVRRH3.js} +8 -4
  16. package/dist/safe-bash/command-chunks/{engine-RG6HQCCB-FXYZS264.js → engine-T4GP6QOK-ECFKMR5V.js} +1 -1
  17. package/dist/safe-bash/command-chunks/odf-SL5TG4B3-XI3FNOTN.js +3041 -0
  18. package/dist/safe-bash/command-chunks/{xlsx-RE54MFCS-IQ6OXXKK.js → xlsx-RE54MFCS-4UZ5W3U7.js} +1 -1
  19. package/dist/safe-bash-command-apply-patch/apply.js +1 -1
  20. package/dist/safe-bash-command-apply-patch/index.js +1 -1
  21. package/dist/safe-bash-command-csvkit/index.js +1 -1
  22. package/dist/safe-bash-command-diff/diff.js +1 -1
  23. package/dist/safe-bash-command-diff/index.js +1 -1
  24. package/dist/safe-bash-command-pptx/engine.js +1 -1
  25. package/dist/safe-bash-command-ssconvert/index.js +5 -5
  26. package/dist/safe-bash-presentation-engine/index.js +1 -1
  27. package/dist/safe-bash-presentation-engine/retained-tags.d.ts +20 -0
  28. package/dist/safe-bash-presentation-engine/tags.d.ts +2 -0
  29. package/dist/safe-bash-presentation-engine/tags.js +11 -3
  30. package/dist/safe-bash-xml-engine/document.js +2 -2
  31. package/dist/safe-bash-xml-engine/index.js +2 -2
  32. package/dist/safe-bash-xml-engine/stored-document.d.ts +2 -0
  33. package/dist/safe-bash-xml-engine/stored-document.js +1 -1
  34. package/dist/safe-bash-xml-engine/stored-evaluate.js +2 -2
  35. package/dist/safe-bash-xml-engine/stored-namespaces.d.ts +21 -0
  36. package/dist/safe-bash-zip-engine/zip/safety.js +1 -1
  37. package/dist/safe-bash-zip-engine/zip/volumes.js +1 -1
  38. package/dist/spreadsheet-format-xls/biff-properties-merge.js +3 -3
  39. package/dist/spreadsheet-format-xls/biff-properties.d.ts +4 -2
  40. package/dist/spreadsheet-format-xls/biff-properties.js +141 -122
  41. package/dist/spreadsheet-format-xls/biff-property-names.d.ts +24 -0
  42. package/dist/spreadsheet-format-xls/biff-property-names.js +167 -0
  43. package/dist/xlsx-ast/comment-geometry.js +1 -1
  44. package/package.json +3 -2
  45. package/dist/safe-bash/command-chunks/biff-UBP2BZLK-JPODPKS3.js +0 -5448
  46. package/dist/safe-bash/command-chunks/chunk-O2HNOQQG.js +0 -161
  47. package/dist/safe-bash/command-chunks/chunk-ZUP5TBRG.js +0 -99
  48. package/dist/safe-bash/command-chunks/odf-3EA3EVSD-7B5GVNTC.js +0 -3097
@@ -715,12 +715,12 @@ var RecordReader = class {
715
715
  continue;
716
716
  }
717
717
  if (remaining === -1) {
718
- const field2 = (await this.take(1))[0];
719
- if (field2 === 9 /* End */) {
718
+ const field3 = (await this.take(1))[0];
719
+ if (field3 === 9 /* End */) {
720
720
  remaining = 0;
721
721
  continue;
722
722
  }
723
- if (field2 !== 4 /* String */) throw new Error("Invalid capture key");
723
+ if (field3 !== 4 /* String */) throw new Error("Invalid capture key");
724
724
  await this.discard(await this.size(4 /* String */) * 2);
725
725
  } else remaining--;
726
726
  const current = tag ?? (await this.take(1))[0];
@@ -747,9 +747,9 @@ var RecordReader = class {
747
747
  }
748
748
  let matched = false;
749
749
  for (; ; ) {
750
- const field2 = (await this.take(1))[0];
751
- if (field2 === 9 /* End */) return matched;
752
- if (field2 !== 4 /* String */) throw new Error("Invalid capture key");
750
+ const field3 = (await this.take(1))[0];
751
+ if (field3 === 9 /* End */) return matched;
752
+ if (field3 !== 4 /* String */) throw new Error("Invalid capture key");
753
753
  if (await this.stringEquals(path[depth])) matched = await this.matches(path, expected, depth + 1);
754
754
  else await this.skip();
755
755
  }
@@ -763,10 +763,10 @@ var RecordReader = class {
763
763
  if (tag === 8 /* Object */) {
764
764
  const value2 = {};
765
765
  for (; ; ) {
766
- const field2 = (await this.take(1))[0];
767
- if (field2 === 9 /* End */) return value2;
768
- if (field2 !== 4 /* String */) throw new Error("Invalid capture key");
769
- const key = await this.value(field2);
766
+ const field3 = (await this.take(1))[0];
767
+ if (field3 === 9 /* End */) return value2;
768
+ if (field3 !== 4 /* String */) throw new Error("Invalid capture key");
769
+ const key = await this.value(field3);
770
770
  Object.defineProperty(value2, key, {
771
771
  value: await this.value(),
772
772
  enumerable: true,
@@ -15005,17 +15005,17 @@ var Type1Font = class {
15005
15005
  "StdHW",
15006
15006
  "StdVW"
15007
15007
  ];
15008
- for (const field2 of fields2) {
15009
- if (!properties.privateData.has(field2)) {
15008
+ for (const field3 of fields2) {
15009
+ if (!properties.privateData.has(field3)) {
15010
15010
  continue;
15011
15011
  }
15012
- const value = properties.privateData.get(field2);
15012
+ const value = properties.privateData.get(field3);
15013
15013
  if (Array.isArray(value)) {
15014
15014
  for (let j = value.length - 1; j > 0; j--) {
15015
15015
  value[j] -= value[j - 1];
15016
15016
  }
15017
15017
  }
15018
- privateDict.setByName(field2, value);
15018
+ privateDict.setByName(field3, value);
15019
15019
  }
15020
15020
  cff.topDict.privateDict = privateDict;
15021
15021
  const subrIndex = new CFFIndex();
@@ -28378,6 +28378,7 @@ function* repairCandidateSteps(size) {
28378
28378
  // packages/pdf-ast/src/cos/value-parser.ts
28379
28379
  function* parseValueSteps(lexer, maxDepth, repair = false, maxNodes = Infinity, options = {}) {
28380
28380
  yield;
28381
+ if (options.deferArrayValues && !options.deferDictionaryValues) throw new TypeError("Deferred array values require deferred dictionary values");
28381
28382
  if (options.deferDictionaryValues && (!options.dictionaryStorage || options.arrayStorage !== options.dictionaryStorage || options.stringStorage !== options.dictionaryStorage || options.containerStorage !== options.dictionaryStorage)) throw new TypeError("Deferred resource values require shared caller backing");
28382
28383
  let work = 0;
28383
28384
  let nodes = 0;
@@ -28421,7 +28422,7 @@ function* parseValueSteps(lexer, maxDepth, repair = false, maxNodes = Infinity,
28421
28422
  while (true) {
28422
28423
  if (++work % 16 === 0) yield;
28423
28424
  const parent = current;
28424
- const deferred = options.deferDictionaryValues && (parent?.deferred || parent?.kind === "dict" && parent.storedEntries);
28425
+ const deferred = options.deferDictionaryValues && (parent?.deferred || parent?.kind === "dict" && parent.storedEntries || options.deferArrayValues && parent?.kind === "array" && parent.storedItems);
28425
28426
  const selectedString = parent?.kind === "dict" && parent.key && options.storedStringKeys?.includes(parent.key.decoded) || !parent && options.storeRootString;
28426
28427
  lexer.setStringStorage?.(options.stringStorage && (selectedString || deferred) ? options.stringStorage : void 0);
28427
28428
  const tok = yield "token";
@@ -31845,27 +31846,27 @@ function* parseXrefRevisionAtSteps(bytes, xrefOffset, maxDecompressedBytes, maxR
31845
31846
  const objNum = startObj + i;
31846
31847
  const field0 = w0 > 0 ? readInt(w0) : 1;
31847
31848
  const field1 = readInt(w1);
31848
- const field2 = w2 > 0 ? readInt(w2) : 0;
31849
+ const field22 = w2 > 0 ? readInt(w2) : 0;
31849
31850
  if (field0 === 0) {
31850
31851
  entries.set(objNum, {
31851
31852
  type: "free",
31852
31853
  objectNumber: objNum,
31853
31854
  nextFreeObjectNumber: field1,
31854
- generationNumber: field2
31855
+ generationNumber: field22
31855
31856
  });
31856
31857
  } else if (field0 === 1) {
31857
31858
  entries.set(objNum, {
31858
31859
  type: "uncompressed",
31859
31860
  objectNumber: objNum,
31860
31861
  offset: field1,
31861
- generationNumber: field2
31862
+ generationNumber: field22
31862
31863
  });
31863
31864
  } else if (field0 === 2) {
31864
31865
  entries.set(objNum, {
31865
31866
  type: "compressed",
31866
31867
  objectNumber: objNum,
31867
31868
  objectStreamNumber: field1,
31868
- indexInStream: field2
31869
+ indexInStream: field22
31869
31870
  });
31870
31871
  } else {
31871
31872
  throw new PdfError("E_PARSE", `Invalid XRef entry type: ${field0}`);
@@ -33469,6 +33470,12 @@ function embedTrueTypeFontInCos(doc, font, usedGlyphs) {
33469
33470
  }
33470
33471
 
33471
33472
  // packages/pdf-ast/src/fonts/resolve.ts
33473
+ function* field(dict, key) {
33474
+ if (!dict.storedEntries) return dictGet(dict, key);
33475
+ const value = yield { kind: "dictionary-value", dict, key };
33476
+ if (value && !("kind" in value)) throw new TypeError("Expected a font dictionary value");
33477
+ return value;
33478
+ }
33472
33479
  function* resolve(node, storeRootArray = false, storeRootDictionary = false, arrayPathPrefix) {
33473
33480
  const value = yield { kind: "resolve", node, storeRootArray, storeRootDictionary, ...arrayPathPrefix ? { arrayPathPrefix } : {} };
33474
33481
  if (value && !("kind" in value)) throw new TypeError("Font lookup returned stream bytes instead of a COS value");
@@ -33506,10 +33513,10 @@ function* resolvePageFontsSteps(rootRef, resourcesDict, selectedName, options =
33506
33513
  const allocationOptions = { onAllocation: (bytes) => allocation.admit(bytes) };
33507
33514
  const fonts = /* @__PURE__ */ new Map();
33508
33515
  const catalog = yield* resolveDict2(rootRef);
33509
- const acroForm = catalog ? yield* resolveDict2(dictGet(catalog, "AcroForm")) : void 0;
33510
- const drDict = acroForm ? yield* resolveDict2(dictGet(acroForm, "DR")) : void 0;
33511
- const drFontDict = drDict ? yield* resolveDict2(dictGet(drDict, "Font"), true) : void 0;
33512
- const pageFontDict = resourcesDict ? yield* resolveDict2(dictGet(resourcesDict, "Font"), true) : void 0;
33516
+ const acroForm = catalog ? yield* resolveDict2(yield* field(catalog, "AcroForm")) : void 0;
33517
+ const drDict = acroForm ? yield* resolveDict2(yield* field(acroForm, "DR")) : void 0;
33518
+ const drFontDict = drDict ? yield* resolveDict2(yield* field(drDict, "Font"), true) : void 0;
33519
+ const pageFontDict = resourcesDict ? yield* resolveDict2(yield* field(resourcesDict, "Font"), true) : void 0;
33513
33520
  for (const dictionary of [drFontDict, pageFontDict]) {
33514
33521
  if (!dictionary) continue;
33515
33522
  const cursor = new PdfDictionaryCursor(dictionary);
@@ -33520,17 +33527,17 @@ function* resolvePageFontsSteps(rootRef, resourcesDict, selectedName, options =
33520
33527
  const fName = entry.key.decoded;
33521
33528
  if (selectedName !== void 0 && fName !== selectedName)
33522
33529
  continue;
33523
- const fObj = yield* resolveDict2(entry.value);
33530
+ const fObj = yield* resolveDict2(entry.value, true);
33524
33531
  if (!fObj)
33525
33532
  continue;
33526
33533
  allocation.admit(1024);
33527
- const subtypeNode = yield* resolve(dictGet(fObj, "Subtype"));
33534
+ const subtypeNode = yield* resolve(yield* field(fObj, "Subtype"));
33528
33535
  const subtype = subtypeNode?.kind === "name" ? subtypeNode.decoded : "Type1";
33529
- const baseFontNode = yield* resolve(dictGet(fObj, "BaseFont"));
33536
+ const baseFontNode = yield* resolve(yield* field(fObj, "BaseFont"));
33530
33537
  const baseFont = baseFontNode?.kind === "name" ? baseFontNode.decoded : "Helvetica";
33531
33538
  let cmap;
33532
33539
  let storedCMap;
33533
- const toUniNode = yield* resolve(dictGet(fObj, "ToUnicode"));
33540
+ const toUniNode = yield* resolve(yield* field(fObj, "ToUnicode"));
33534
33541
  if (toUniNode?.kind === "stream") {
33535
33542
  try {
33536
33543
  const value = yield { kind: "decode", stream: toUniNode, purpose: "unicode-cmap" };
@@ -33544,17 +33551,14 @@ function* resolvePageFontsSteps(rootRef, resourcesDict, selectedName, options =
33544
33551
  throw error;
33545
33552
  }
33546
33553
  }
33547
- const encNode = yield* resolve(dictGet(fObj, "Encoding"));
33554
+ let encNode = yield* resolve(yield* field(fObj, "Encoding"), false, true);
33555
+ let differenceArray;
33548
33556
  if (encNode?.kind === "dict") {
33549
- const diffRef = dictGet(encNode, "Differences");
33550
- if (diffRef?.kind === "ref") {
33551
- const resolvedDiff = yield* resolve(diffRef, true);
33552
- if (resolvedDiff?.kind === "array") {
33553
- dictSet(encNode, "Differences", resolvedDiff);
33554
- }
33555
- }
33557
+ differenceArray = yield* field(encNode, "Differences");
33558
+ if (differenceArray?.kind === "ref") differenceArray = yield* resolve(differenceArray, true);
33559
+ const baseEncoding = yield* field(encNode, "BaseEncoding");
33560
+ encNode = cosDict({ ...baseEncoding ? { BaseEncoding: baseEncoding } : {}, ...differenceArray ? { Differences: differenceArray } : {} });
33556
33561
  }
33557
- const differenceArray = encNode?.kind === "dict" ? dictGet(encNode, "Differences") : void 0;
33558
33562
  let storedEncoding;
33559
33563
  if (options.resourceStorage && differenceArray?.kind === "array") {
33560
33564
  const value = yield { kind: "font-encoding", array: differenceArray };
@@ -33580,28 +33584,29 @@ function* resolvePageFontsSteps(rootRef, resourcesDict, selectedName, options =
33580
33584
  let charProcs;
33581
33585
  let fontResources;
33582
33586
  if (subtype === "Type3") {
33583
- const fmArr = yield* resolveArray2(dictGet(fObj, "FontMatrix"));
33584
- if (fmArr && fmArr.items.length >= 6) {
33585
- const mn = function* (idx, fb = 0) {
33586
- const r = yield* resolve(fmArr.items[idx]);
33587
- return r?.kind === "number" ? r.value : fb;
33588
- };
33589
- fontMatrix = [yield* mn(0, 1e-3), yield* mn(1, 0), yield* mn(2, 0), yield* mn(3, 1e-3), yield* mn(4, 0), yield* mn(5, 0)];
33587
+ const fmArr = yield* resolveArray2(yield* field(fObj, "FontMatrix"), true);
33588
+ if (fmArr && (fmArr.storedItems?.length ?? fmArr.items.length) >= 6) {
33589
+ const cursor2 = arrayCursor(fmArr);
33590
+ fontMatrix = [1e-3, 0, 0, 1e-3, 0, 0];
33591
+ for (let i = 0; i < 6; i++) {
33592
+ const value = yield* resolve(yield* cursor2.next());
33593
+ if (value?.kind === "number") fontMatrix[i] = value.value;
33594
+ }
33590
33595
  } else {
33591
33596
  fontMatrix = [1e-3, 0, 0, 1e-3, 0, 0];
33592
33597
  }
33593
- charProcs = yield* resolveDict2(dictGet(fObj, "CharProcs"));
33594
- fontResources = yield* resolveDict2(dictGet(fObj, "Resources"), false, ["Resources"]);
33598
+ charProcs = yield* resolveDict2(yield* field(fObj, "CharProcs"), true);
33599
+ fontResources = yield* resolveDict2(yield* field(fObj, "Resources"), false, ["Resources"]);
33595
33600
  }
33596
33601
  const type3Scale1000 = subtype === "Type3" && fontMatrix ? Math.hypot(fontMatrix[0], fontMatrix[1]) * 1e3 : 1;
33602
+ const descendants = subtype === "Type0" ? yield* resolveArray2(yield* field(fObj, "DescendantFonts"), true) : void 0;
33603
+ const cidDict = descendants ? yield* resolveDict2(yield* arrayCursor(descendants).next(), true) : void 0;
33597
33604
  if (subtype === "Type0") {
33598
- const descArr = yield* resolveArray2(dictGet(fObj, "DescendantFonts"));
33599
- const cidDict = descArr && descArr.items[0] ? yield* resolveDict2(descArr.items[0]) : void 0;
33600
33605
  if (cidDict) {
33601
- const dwNode = yield* resolve(dictGet(cidDict, "DW"));
33606
+ const dwNode = yield* resolve(yield* field(cidDict, "DW"));
33602
33607
  if (dwNode?.kind === "number")
33603
33608
  defaultWidth = dwNode.value;
33604
- const wArr = yield* resolveArray2(dictGet(cidDict, "W"), true);
33609
+ const wArr = yield* resolveArray2(yield* field(cidDict, "W"), true);
33605
33610
  if (wArr) {
33606
33611
  const cursor2 = arrayCursor(wArr);
33607
33612
  while (cursor2.remaining) {
@@ -33627,11 +33632,11 @@ function* resolvePageFontsSteps(rootRef, resourcesDict, selectedName, options =
33627
33632
  }
33628
33633
  }
33629
33634
  } else {
33630
- const firstCharNode = yield* resolve(dictGet(fObj, "FirstChar"));
33631
- const widthsArr = yield* resolveArray2(dictGet(fObj, "Widths"), true);
33635
+ const firstCharNode = yield* resolve(yield* field(fObj, "FirstChar"));
33636
+ const widthsArr = yield* resolveArray2(yield* field(fObj, "Widths"), true);
33632
33637
  if (widthsArr) {
33633
- const descriptor = yield* resolveDict2(dictGet(fObj, "FontDescriptor"));
33634
- const missingWidth = descriptor ? yield* resolve(dictGet(descriptor, "MissingWidth")) : void 0;
33638
+ const descriptor = yield* resolveDict2(yield* field(fObj, "FontDescriptor"), true);
33639
+ const missingWidth = descriptor ? yield* resolve(yield* field(descriptor, "MissingWidth")) : void 0;
33635
33640
  defaultWidth = (missingWidth?.kind === "number" ? missingWidth.value : 0) * type3Scale1000;
33636
33641
  const firstChar = firstCharNode?.kind === "number" ? firstCharNode.value : 0;
33637
33642
  const cursor2 = arrayCursor(widthsArr);
@@ -33654,13 +33659,11 @@ function* resolvePageFontsSteps(rootRef, resourcesDict, selectedName, options =
33654
33659
  let storedTrueType;
33655
33660
  let embeddedTrueType;
33656
33661
  let simpleToGid;
33657
- const fDescDirect = yield* resolveDict2(dictGet(fObj, "FontDescriptor"));
33658
- const descArrForTt = subtype === "Type0" ? yield* resolveArray2(dictGet(fObj, "DescendantFonts")) : void 0;
33659
- const cidDictForTt = descArrForTt && descArrForTt.items[0] ? yield* resolveDict2(descArrForTt.items[0]) : void 0;
33660
- const fDesc = fDescDirect ?? (cidDictForTt ? yield* resolveDict2(dictGet(cidDictForTt, "FontDescriptor")) : void 0);
33662
+ const fDescDirect = yield* resolveDict2(yield* field(fObj, "FontDescriptor"), true);
33663
+ const fDesc = fDescDirect ?? (cidDict ? yield* resolveDict2(yield* field(cidDict, "FontDescriptor"), true) : void 0);
33661
33664
  let cidToGid;
33662
33665
  let storedCidToGid;
33663
- const cidMap = cidDictForTt ? yield* resolve(dictGet(cidDictForTt, "CIDToGIDMap")) : void 0;
33666
+ const cidMap = cidDict ? yield* resolve(yield* field(cidDict, "CIDToGIDMap")) : void 0;
33664
33667
  if (cidMap?.kind === "stream") {
33665
33668
  const bytes = yield { kind: "decode", stream: cidMap, purpose: "cid-map" };
33666
33669
  if (bytes && "byteLength" in bytes && "storage" in bytes) storedCidToGid = bytes;
@@ -33672,15 +33675,15 @@ function* resolvePageFontsSteps(rootRef, resourcesDict, selectedName, options =
33672
33675
  } else throw new TypeError("Font decoder did not return CID map bytes");
33673
33676
  }
33674
33677
  if (fDesc) {
33675
- const type1Program = yield* resolve(dictGet(fDesc, "FontFile"));
33676
- const program = (yield* resolve(dictGet(fDesc, "FontFile2"))) ?? (yield* resolve(dictGet(fDesc, "FontFile3"))) ?? type1Program;
33678
+ const type1Program = yield* resolve(yield* field(fDesc, "FontFile"));
33679
+ const program = (yield* resolve(yield* field(fDesc, "FontFile2"))) ?? (yield* resolve(yield* field(fDesc, "FontFile3"))) ?? type1Program;
33677
33680
  if (program?.kind === "stream") {
33678
- const programType = yield* resolve(dictGet(program.dict, "Subtype"));
33679
- const baseEncoding = encNode?.kind === "dict" ? yield* resolve(dictGet(encNode, "BaseEncoding")) : encNode;
33681
+ const programType = yield* resolve(yield* field(program.dict, "Subtype"));
33682
+ const baseEncoding = encNode?.kind === "dict" ? yield* resolve(yield* field(encNode, "BaseEncoding")) : encNode;
33680
33683
  if (program === type1Program) {
33681
- const length1 = yield* resolve(dictGet(program.dict, "Length1"));
33682
- const length2 = yield* resolve(dictGet(program.dict, "Length2"));
33683
- const flags = yield* resolve(dictGet(fDesc, "Flags"));
33684
+ const length1 = yield* resolve(yield* field(program.dict, "Length1"));
33685
+ const length2 = yield* resolve(yield* field(program.dict, "Length2"));
33686
+ const flags = yield* resolve(yield* field(fDesc, "Flags"));
33684
33687
  const type1Properties = {
33685
33688
  length1: length1?.kind === "number" ? length1.value : 0,
33686
33689
  length2: length2?.kind === "number" ? length2.value : 0,
@@ -33800,7 +33803,7 @@ function resolvePageFonts(doc, resourcesDict, selectedName) {
33800
33803
  while (!step.done) {
33801
33804
  let value;
33802
33805
  try {
33803
- if (step.value.kind === "dictionary-entry" || step.value.kind === "font-encoding" || step.value.kind === "font-label" || step.value.kind === "array-item" || step.value.kind === "truetype-map" || step.value.kind === "font-width-set") throw new TypeError("Stored font requires asynchronous evaluation");
33806
+ if (step.value.kind === "dictionary-value" || step.value.kind === "dictionary-entry" || step.value.kind === "font-encoding" || step.value.kind === "font-label" || step.value.kind === "array-item" || step.value.kind === "truetype-map" || step.value.kind === "font-width-set") throw new TypeError("Stored font requires asynchronous evaluation");
33804
33807
  value = step.value.kind === "resolve" ? doc.resolve(step.value.node) : doc.decodeStream(step.value.stream);
33805
33808
  } catch (error) {
33806
33809
  step = steps.throw(error);
@@ -35414,7 +35417,7 @@ var StoredJbigIndex = class {
35414
35417
  *set(key, value) {
35415
35418
  const record = yield* StoredJbigList.create(9);
35416
35419
  const fields2 = value instanceof StoredJbigHuffman ? [2, value.nodes.length, value.nodes.capacity, value.nodes.buffer.position, value.nodes.buffer.length] : value instanceof StoredJbigList ? [0, value.length, value.capacity, value.buffer.position, value.buffer.length] : [1, value.width, value.height, value.length, value.bitmap.position, value.bitmap.length, value.bitmap.rowSize, value.bitmap.width, value.bitmap.height];
35417
- for (const field2 of fields2) yield* record.push(field2);
35420
+ for (const field3 of fields2) yield* record.push(field3);
35418
35421
  const slot = yield* this.find(key, true);
35419
35422
  yield { kind: "number-write", ...slot, value: record.buffer.position + 1 };
35420
35423
  }
@@ -38361,7 +38364,7 @@ var JpxImage = class {
38361
38364
  } };
38362
38365
  const tile = yield* this.parseCodestreamTileSteps(data, start, end, selected);
38363
38366
  const values = [tile.left, tile.top, tile.width, tile.height, tile.items.position, tile.items.length];
38364
- for (let field2 = 0; field2 < 6; field2++) yield* jpxVectorWrite(records2, number * 6 + field2, values[field2]);
38367
+ for (let field3 = 0; field3 < 6; field3++) yield* jpxVectorWrite(records2, number * 6 + field3, values[field3]);
38365
38368
  }
38366
38369
  this.storedTiles = { length: count, records: records2 };
38367
38370
  }
@@ -38843,8 +38846,8 @@ function* buildCodeblocks(context, subband, dimensions) {
38843
38846
  if (context.storedPlanes) {
38844
38847
  codeblock.record = codeblocks.records;
38845
38848
  codeblock.recordIndex = codeblocks.length++;
38846
- for (let field2 = 0; field2 < jpxCodeblockGeometry.length; field2++) {
38847
- yield* jpxVectorWrite(codeblock.record, codeblock.recordIndex * 18 + field2, codeblock[jpxCodeblockGeometry[field2]]);
38849
+ for (let field3 = 0; field3 < jpxCodeblockGeometry.length; field3++) {
38850
+ yield* jpxVectorWrite(codeblock.record, codeblock.recordIndex * 18 + field3, codeblock[jpxCodeblockGeometry[field3]]);
38848
38851
  }
38849
38852
  yield* writeJpxCodeblock(codeblock);
38850
38853
  } else codeblocks.push(codeblock);
@@ -38898,8 +38901,8 @@ function* writeJpxPrecinct(precinct) {
38898
38901
  precinct.zeroBitPlanesTree ? precinct.zeroBitPlanesTree.root.position + 1 : 0,
38899
38902
  precinct.zeroBitPlanesTree ? precinct.zeroBitPlanesTree.presence.position + 1 : 0
38900
38903
  ];
38901
- for (let field2 = 0; field2 < values.length; field2++) {
38902
- yield* jpxVectorWrite(collection.records, precinct.number * 8 + field2, values[field2]);
38904
+ for (let field3 = 0; field3 < values.length; field3++) {
38905
+ yield* jpxVectorWrite(collection.records, precinct.number * 8 + field3, values[field3]);
38903
38906
  }
38904
38907
  collection.cached = precinct;
38905
38908
  }
@@ -38908,7 +38911,7 @@ function* readJpxPrecinct(collection, number) {
38908
38911
  if (collection.cached?.number === number) return collection.cached;
38909
38912
  if (!(yield* jpxVectorRead(collection.records, number * 8))) return void 0;
38910
38913
  const values = [];
38911
- for (let field2 = 1; field2 < 8; field2++) values.push(yield* jpxVectorRead(collection.records, number * 8 + field2));
38914
+ for (let field3 = 1; field3 < 8; field3++) values.push(yield* jpxVectorRead(collection.records, number * 8 + field3));
38912
38915
  const precinct = { collection, number, cbxMin: values[0], cbyMin: values[1], cbxMax: values[2], cbyMax: values[3] };
38913
38916
  if (values[4]) {
38914
38917
  const width = precinct.cbxMax - precinct.cbxMin + 1, height = precinct.cbyMax - precinct.cbyMin + 1;
@@ -38937,8 +38940,8 @@ function* writeJpxCodeblock(block) {
38937
38940
  data?.totalLength ?? 0,
38938
38941
  data?.codingpasses ?? 0
38939
38942
  ];
38940
- for (let field2 = 0; field2 < values.length; field2++) {
38941
- yield* jpxVectorWrite(block.record, block.recordIndex * 18 + 7 + field2, values[field2]);
38943
+ for (let field3 = 0; field3 < values.length; field3++) {
38944
+ yield* jpxVectorWrite(block.record, block.recordIndex * 18 + 7 + field3, values[field3]);
38942
38945
  }
38943
38946
  }
38944
38947
  function* readJpxCodeblock(subband, index2, withPrecinct = true) {
@@ -38946,8 +38949,8 @@ function* readJpxCodeblock(subband, index2, withPrecinct = true) {
38946
38949
  if (!blocks.records) return blocks[index2];
38947
38950
  const block = { record: blocks.records, recordIndex: index2, subbandType: subband.type };
38948
38951
  const values = [];
38949
- for (let field2 = 0; field2 < 18; field2++) values.push(yield* jpxVectorRead(blocks.records, index2 * 18 + field2));
38950
- for (let field2 = 0; field2 < jpxCodeblockGeometry.length; field2++) block[jpxCodeblockGeometry[field2]] = values[field2];
38952
+ for (let field3 = 0; field3 < 18; field3++) values.push(yield* jpxVectorRead(blocks.records, index2 * 18 + field3));
38953
+ for (let field3 = 0; field3 < jpxCodeblockGeometry.length; field3++) block[jpxCodeblockGeometry[field3]] = values[field3];
38951
38954
  if (withPrecinct) block.precinct = yield* readJpxPrecinct(subband.precincts, block.precinctNumber);
38952
38955
  block.Lblock = values[7];
38953
38956
  if (values[8]) block.included = true;
@@ -39261,12 +39264,12 @@ var jpxSubbandFields = ["tbx0", "tby0", "tbx1", "tby1"];
39261
39264
  var jpxBlockFields = ["codeblockWidth", "codeblockHeight", "numcodeblockwide", "numcodeblockhigh"];
39262
39265
  var jpxSubbandTypes = ["LL", "HL", "LH", "HH"];
39263
39266
  function* writeJpxResolution(collection, resolution) {
39264
- const values = jpxResolutionFields.map((field2) => resolution[field2]);
39265
- values.push(...jpxPrecinctFields.map((field2) => resolution.precinctParameters[field2]), resolution.subbands.length);
39267
+ const values = jpxResolutionFields.map((field3) => resolution[field3]);
39268
+ values.push(...jpxPrecinctFields.map((field3) => resolution.precinctParameters[field3]), resolution.subbands.length);
39266
39269
  for (const band of resolution.subbands) values.push(
39267
39270
  jpxSubbandTypes.indexOf(band.type),
39268
- ...jpxSubbandFields.map((field2) => band[field2]),
39269
- ...jpxBlockFields.map((field2) => band.codeblockParameters[field2]),
39271
+ ...jpxSubbandFields.map((field3) => band[field3]),
39272
+ ...jpxBlockFields.map((field3) => band.codeblockParameters[field3]),
39270
39273
  band.codeblocks.length,
39271
39274
  band.codeblocks.records.position,
39272
39275
  band.codeblocks.records.length,
@@ -39291,13 +39294,13 @@ function* readJpxResolution(collection, index2) {
39291
39294
  return yield* jpxVectorRead(collection.records, offset++);
39292
39295
  };
39293
39296
  const resolution = { onAllocation: context.onAllocation, packetAdmission: 128, precinctParameters: {}, subbands: [] };
39294
- for (const field2 of jpxResolutionFields) resolution[field2] = yield* read();
39295
- for (const field2 of jpxPrecinctFields) resolution.precinctParameters[field2] = yield* read();
39297
+ for (const field3 of jpxResolutionFields) resolution[field3] = yield* read();
39298
+ for (const field3 of jpxPrecinctFields) resolution.precinctParameters[field3] = yield* read();
39296
39299
  const count = yield* read();
39297
39300
  for (let i = 0; i < count; i++) {
39298
39301
  const band = { type: jpxSubbandTypes[yield* read()], resolution, codeblockParameters: {} };
39299
- for (const field2 of jpxSubbandFields) band[field2] = yield* read();
39300
- for (const field2 of jpxBlockFields) band.codeblockParameters[field2] = yield* read();
39302
+ for (const field3 of jpxSubbandFields) band[field3] = yield* read();
39303
+ for (const field3 of jpxBlockFields) band.codeblockParameters[field3] = yield* read();
39301
39304
  band.codeblocks = { length: yield* read(), records: { position: yield* read(), length: yield* read(), bytesPerElement: 8, integer: false } };
39302
39305
  band.precincts = { records: { position: yield* read(), length: yield* read(), bytesPerElement: 8, integer: false }, admission: entry.trees[i] };
39303
39306
  resolution.subbands.push(band);
@@ -42768,7 +42771,8 @@ function* runColorProgramSteps(doc, work, sources) {
42768
42771
  let step = work.next();
42769
42772
  while (!step.done) {
42770
42773
  const request = step.value;
42771
- if (request.kind === "resolve") step = work.next(doc?.resolve(request.node));
42774
+ if (request.kind === "dictionary-value") step = work.next(dictGet(request.dict, request.key));
42775
+ else if (request.kind === "resolve") step = work.next(doc?.resolve(request.node));
42772
42776
  else if (request.kind === "resource") {
42773
42777
  const map = doc?.resolveDict(dictGet(request.resources, request.category));
42774
42778
  step = work.next(map ? dictGet(map, request.name) : void 0);
@@ -43346,7 +43350,7 @@ function* evaluateMaskTransferSteps(doc, transfer, sources) {
43346
43350
  function* resolveMaskParameterSteps(mask, form, activeResources) {
43347
43351
  const group = yield* resolveColorNode(dictGet(form.dict, "Group"), "dict");
43348
43352
  const colorSpace = group ? dictGet(group, "CS") : void 0;
43349
- const bc = yield* resolveColorNode(dictGet(mask, "BC"), "array");
43353
+ const bc = yield* resolveColorNode(yield { kind: "dictionary-value", dict: mask, key: "BC" }, "array");
43350
43354
  let components;
43351
43355
  if (bc) {
43352
43356
  components = [];
@@ -43356,7 +43360,7 @@ function* resolveMaskParameterSteps(mask, form, activeResources) {
43356
43360
  }
43357
43361
  }
43358
43362
  const [r, g, b] = components ? yield* convertContentColorSteps(true, colorSpace, "DeviceRGB", components, activeResources) : [0, 0, 0];
43359
- const transfer = yield* resolveColorNode(dictGet(mask, "TR"));
43363
+ const transfer = yield* resolveColorNode(yield { kind: "dictionary-value", dict: mask, key: "TR" });
43360
43364
  const transferMap = transfer?.kind === "dict" || transfer?.kind === "stream" ? yield { kind: "transfer", node: transfer } : void 0;
43361
43365
  return { backdrop: { r, g, b }, transferMap };
43362
43366
  }
@@ -43747,12 +43751,12 @@ function* evaluateContentSteps(params) {
43747
43751
  const extDict = yield* resolveEvaluationDict(dictGet(activeResources, "ExtGState"), ["Resources", "ExtGState"]);
43748
43752
  const gsDict = extDict ? yield* resolveEvaluationDict(yield* lookupEvaluationDictionary(extDict, ops[0].decoded, true), ["Resources", "ExtGState", ops[0].decoded], true) : void 0;
43749
43753
  if (gsDict) {
43750
- const mask = yield* resolveEvaluationNode(yield* lookupEvaluationDictionary(gsDict, "SMask"));
43754
+ const mask = yield* resolveEvaluationNode(yield* lookupEvaluationDictionary(gsDict, "SMask", true), false, void 0, true);
43751
43755
  if (mask?.kind === "name" && mask.decoded === "None") {
43752
43756
  st.softMask = void 0;
43753
43757
  } else if (mask?.kind === "dict") {
43754
- const subtype = yield* resolveEvaluationNode(dictGet(mask, "S"));
43755
- const form = yield* resolveEvaluationNode(dictGet(mask, "G"));
43758
+ const subtype = yield* resolveEvaluationNode(yield* lookupEvaluationDictionary(mask, "S"));
43759
+ const form = yield* resolveEvaluationNode(yield* lookupEvaluationDictionary(mask, "G"));
43756
43760
  if (form?.kind === "stream" && subtype?.kind === "name" && (subtype.decoded === "Alpha" || subtype.decoded === "Luminosity")) {
43757
43761
  if (depth >= 8) throw new PdfError("E_LIMIT", "Soft-mask nesting exceeds the form depth limit");
43758
43762
  const parentOperations = capturedOperations;
@@ -44366,7 +44370,7 @@ function* evaluateContentSteps(params) {
44366
44370
  explicitName = reply.node?.kind === "name" ? reply.node.decoded : void 0;
44367
44371
  }
44368
44372
  const gName = explicitName ?? item.unicode;
44369
- const procNode = gName ? yield* resolveEvaluationNode(dictGet(font.charProcs, gName)) : void 0;
44373
+ const procNode = gName ? yield* resolveEvaluationNode(yield* lookupEvaluationDictionary(font.charProcs, gName)) : void 0;
44370
44374
  if (procNode?.kind === "stream") {
44371
44375
  const fm = font.fontMatrix ?? [1e-3, 0, 0, 1e-3, 0, 0];
44372
44376
  const source2 = { stream: procNode };
@@ -49458,11 +49462,11 @@ async function* readCosXrefRevision(source, offset, options = {}) {
49458
49462
  for (let i = 0; i < count; i++) {
49459
49463
  const type = w0 ? await reader.integer(w0) : 1;
49460
49464
  const field1 = await reader.integer(w1);
49461
- const field2 = w2 ? await reader.integer(w2) : 0;
49465
+ const field22 = w2 ? await reader.integer(w2) : 0;
49462
49466
  signal?.throwIfAborted();
49463
- if (type === 0) yield { type: "free", objectNumber: start + i, nextFreeObjectNumber: field1, generationNumber: field2 };
49464
- else if (type === 1) yield { type: "uncompressed", objectNumber: start + i, offset: field1, generationNumber: field2 };
49465
- else if (type === 2) yield { type: "compressed", objectNumber: start + i, objectStreamNumber: field1, indexInStream: field2 };
49467
+ if (type === 0) yield { type: "free", objectNumber: start + i, nextFreeObjectNumber: field1, generationNumber: field22 };
49468
+ else if (type === 1) yield { type: "uncompressed", objectNumber: start + i, offset: field1, generationNumber: field22 };
49469
+ else if (type === 2) yield { type: "compressed", objectNumber: start + i, objectStreamNumber: field1, indexInStream: field22 };
49466
49470
  else throw new PdfError("E_PARSE", `Invalid XRef entry type: ${type}`);
49467
49471
  if (++turns % 64 === 0) await new Promise((resolve2) => setTimeout(resolve2, 0));
49468
49472
  }
@@ -49900,7 +49904,7 @@ function integer2(value, name, minimum = 0) {
49900
49904
  function maximum2(value, name) {
49901
49905
  return value === void 0 || value === Infinity ? Number.MAX_SAFE_INTEGER : integer2(value, name);
49902
49906
  }
49903
- function field(dict, key) {
49907
+ function field2(dict, key) {
49904
49908
  const value = dictGet(dict, key);
49905
49909
  if (value?.kind !== "number" || !Number.isSafeInteger(value.value) || value.value < 0) throw new PdfError("E_PARSE", `Invalid object stream /${key}`);
49906
49910
  return value.value;
@@ -50169,8 +50173,8 @@ var PdfObjectReader = class {
50169
50173
  }
50170
50174
  const object = await this.load(number, generation, active);
50171
50175
  if (object?.value.kind !== "dict" || !object.stream || dictGet(object.value, "Type")?.kind !== "name" || dictGet(object.value, "Type").decoded !== "ObjStm") throw new PdfError("E_PARSE", "Invalid object stream dictionary");
50172
- const count = field(object.value, "N");
50173
- const first = field(object.value, "First");
50176
+ const count = field2(object.value, "N");
50177
+ const first = field2(object.value, "First");
50174
50178
  if (count > maximum2(this.options.maxObjectStreamMembers, "maxObjectStreamMembers") || count > Math.floor(Number.MAX_SAFE_INTEGER / 16)) throw new PdfError("E_LIMIT", "PDF object stream member limit exceeded");
50175
50179
  active.add(number);
50176
50180
  let dict;
@@ -51354,8 +51358,8 @@ function createRetainedColorAccess(document2, storage, options, storedFunctions
51354
51358
  const item = dictGet(dict, key);
51355
51359
  if (!item) continue;
51356
51360
  charge(64);
51357
- const field2 = key === "Functions" ? await snapshotFunction(item, depth + 1) : await snapshotNumbers(item);
51358
- selected.entries.push({ key: cosName(key), value: field2 ?? { kind: "null" } });
51361
+ const field3 = key === "Functions" ? await snapshotFunction(item, depth + 1) : await snapshotNumbers(item);
51362
+ selected.entries.push({ key: cosName(key), value: field3 ?? { kind: "null" } });
51359
51363
  }
51360
51364
  if (value?.kind === "stream" && (kind === 0 || kind === 4) && storedFunctions) return storeFunction(value, selected);
51361
51365
  return value?.kind === "stream" && (kind === 0 || kind === 4) ? cosStream(selected, await decode2(value)) : selected;
@@ -51536,7 +51540,8 @@ async function runRetainedColorProgram(document2, storage, options, work) {
51536
51540
  options.signal?.throwIfAborted();
51537
51541
  const request = step.value;
51538
51542
  let result;
51539
- if (request.kind === "resolve") result = await resolve2(request.node);
51543
+ if (request.kind === "dictionary-value") result = await readPdfDictionaryValue(request.dict, request.key, options.signal);
51544
+ else if (request.kind === "resolve") result = await resolve2(request.node);
51540
51545
  else if (request.kind === "resource") result = await resource(request);
51541
51546
  else if (request.kind === "decode") result = await decode2(request.stream, request.length, request.start);
51542
51547
  else if (request.kind === "calibrated") result = createCalibratedColorSpace(context, request.family, await snapshot(request.parameters));
@@ -53460,8 +53465,8 @@ async function readType1Header(lexer, initialMatrix, storage, signal) {
53460
53465
  if (!await token2.equals("/")) continue;
53461
53466
  switch (await (await lexer.next())?.keyword()) {
53462
53467
  case "FontMatrix": {
53463
- const field2 = await readType1NumberArray(lexer);
53464
- matrix2 = field2.count > 6 ? [...field2.values, 0] : field2.values;
53468
+ const field3 = await readType1NumberArray(lexer);
53469
+ matrix2 = field3.count > 6 ? [...field3.values, 0] : field3.values;
53465
53470
  break;
53466
53471
  }
53467
53472
  case "FontBBox":
@@ -53736,8 +53741,8 @@ async function parseStoredType1Cid(source, properties, storage, signal) {
53736
53741
  const key = await keyToken?.keyword();
53737
53742
  switch (key) {
53738
53743
  case "FontMatrix": {
53739
- const field2 = await readType1NumberArray(lexer);
53740
- properties.fontMatrix = field2.count > 6 ? [...field2.values, 0] : field2.values;
53744
+ const field3 = await readType1NumberArray(lexer);
53745
+ properties.fontMatrix = field3.count > 6 ? [...field3.values, 0] : field3.values;
53741
53746
  break;
53742
53747
  }
53743
53748
  case "FontBBox":
@@ -54494,8 +54499,8 @@ async function readCffDictionary(source, selected) {
54494
54499
  var TOP_FIELDS = /* @__PURE__ */ new Set([15, 16, 17, 18, 3079, 3102, 3108, 3109]);
54495
54500
  var PRIVATE_FIELDS = /* @__PURE__ */ new Set([19]);
54496
54501
  var DEFAULT_MATRIX = [1e-3, 0, 0, 1e-3, 0, 0];
54497
- function scalar(dict, field2, fallback = 0) {
54498
- return dict.get(field2)?.values[0] ?? fallback;
54502
+ function scalar(dict, field3, fallback = 0) {
54503
+ return dict.get(field3)?.values[0] ?? fallback;
54499
54504
  }
54500
54505
  function matrix(dict) {
54501
54506
  const entry = dict.get(3079);
@@ -55437,8 +55442,8 @@ async function resolveRetainedFont(document2, storage, resources, name, options
55437
55442
  }
55438
55443
  let value;
55439
55444
  if (step.value.kind === "resolve") {
55440
- const retained = await document2.lookup(step.value.node, options.resourceStorage ? { dictionaryStorage: options.resourceStorage, deferDictionaryValues: true, containerStorage: options.resourceStorage, stringStorage: options.resourceStorage, storedDictionaryKeys: ["Font", "XObject", "Properties"], storedDictionaryPaths: [["Resources", "*"]], storeRootDictionary: step.value.storeRootDictionary ?? false, arrayStorage: options.resourceStorage, storedArrayKeys: ["Widths", "W", "Differences"], storeRootArray: step.value.storeRootArray ?? false } : {}, step.value.arrayPathPrefix);
55441
- value = retained ? await materializeResourceValue(retained.value, signal) : void 0;
55445
+ const retained = await document2.lookup(step.value.node, options.resourceStorage ? { dictionaryStorage: options.resourceStorage, deferDictionaryValues: true, deferArrayValues: true, containerStorage: options.resourceStorage, stringStorage: options.resourceStorage, storedDictionaryKeys: ["Font", "XObject", "Properties"], storedDictionaryPaths: [["Resources", "*"]], storeRootDictionary: step.value.storeRootDictionary ?? false, arrayStorage: options.resourceStorage, storedArrayKeys: ["Widths", "W", "Differences"], storeRootArray: step.value.storeRootArray ?? false } : {}, step.value.arrayPathPrefix);
55446
+ value = retained ? options.resourceStorage && (step.value.storeRootDictionary || step.value.storeRootArray) ? retained.value : await materializeResourceValue(retained.value, signal) : void 0;
55442
55447
  if (retained?.stream) {
55443
55448
  if (retained.value.kind !== "dict" || !retained.reference) throw new PdfError("E_PARSE", "Font stream has no retained identity");
55444
55449
  allocation.admit(256);
@@ -55446,6 +55451,8 @@ async function resolveRetainedFont(document2, storage, resources, name, options
55446
55451
  identities.set(stream, retained.reference);
55447
55452
  value = stream;
55448
55453
  }
55454
+ } else if (step.value.kind === "dictionary-value") {
55455
+ value = await readPdfDictionaryValue(step.value.dict, step.value.key, signal, { preserveDeferred: true });
55449
55456
  } else if (step.value.kind === "dictionary-entry") {
55450
55457
  const record = await readStoredRecord(step.value.entries.storage, step.value.position, signal);
55451
55458
  value = cosArray([record.value.key, record.value.value, cosNumber(record.next)]);
@@ -58714,8 +58721,8 @@ async function* walkRetainedFormFieldDetails(document2, storage, options = {}) {
58714
58721
  yield value2;
58715
58722
  }
58716
58723
  }
58717
- async function* appearances(field2) {
58718
- const appearance = await resolve2(dictGet(field2, "AP"));
58724
+ async function* appearances(field3) {
58725
+ const appearance = await resolve2(dictGet(field3, "AP"));
58719
58726
  const normal = appearance?.kind === "dict" ? await resolve2(dictGet(appearance, "N")) : void 0;
58720
58727
  if (normal?.kind === "dict") for (const pair of normal.entries) {
58721
58728
  await checkpoint();
@@ -58728,8 +58735,8 @@ async function* walkRetainedFormFieldDetails(document2, storage, options = {}) {
58728
58735
  yield* appearances(dict);
58729
58736
  const kids = await resolve2(dictGet(dict, "Kids"));
58730
58737
  if (kids?.kind === "array") for (const kid of kids.items) {
58731
- const field2 = await resolve2(kid);
58732
- if (field2?.kind === "dict") yield* appearances(field2);
58738
+ const field3 = await resolve2(kid);
58739
+ if (field3?.kind === "dict") yield* appearances(field3);
58733
58740
  }
58734
58741
  if (count === 1) yield* unique("Yes");
58735
58742
  }
@@ -60413,7 +60420,7 @@ async function* walkRetainedJavaScripts(document2, storage, options) {
60413
60420
  const kids = await resolve2(dictGet(dict, "Kids"));
60414
60421
  if (kids?.kind === "array") for (const kid of kids.items) yield* tree(kid, depth + 1);
60415
60422
  }
60416
- async function* field2(node, fallback, depth = 0) {
60423
+ async function* field3(node, fallback, depth = 0) {
60417
60424
  if (depth > options.maxDepth) throw new PdfError("E_LIMIT", "PDF JavaScript field depth limit exceeded");
60418
60425
  const dict = await dictionary(node, "field");
60419
60426
  if (!dict) return;
@@ -60422,7 +60429,7 @@ async function* walkRetainedJavaScripts(document2, storage, options) {
60422
60429
  yield* action(dictGet(dict, "A"), `${label} Action`);
60423
60430
  yield* additional(dictGet(dict, "AA"), label);
60424
60431
  const kids = await resolve2(dictGet(dict, "Kids"));
60425
- if (kids?.kind === "array") for (const kid of kids.items) yield* field2(kid, label, depth + 1);
60432
+ if (kids?.kind === "array") for (const kid of kids.items) yield* field3(kid, label, depth + 1);
60426
60433
  }
60427
60434
  try {
60428
60435
  const root = await dictionary(document2.crossReference.rootRef);
@@ -60435,11 +60442,11 @@ async function* walkRetainedJavaScripts(document2, storage, options) {
60435
60442
  const label = `Page ${page2.index + 1}`;
60436
60443
  yield* additional(dictGet(page2.dict, "AA"), label);
60437
60444
  const annots = await resolve2(dictGet(page2.dict, "Annots"));
60438
- if (annots?.kind === "array") for (let i = 0; i < annots.items.length; i++) yield* field2(annots.items[i], `${label} Annot ${i + 1}`);
60445
+ if (annots?.kind === "array") for (let i = 0; i < annots.items.length; i++) yield* field3(annots.items[i], `${label} Annot ${i + 1}`);
60439
60446
  }
60440
60447
  const form = await dictionary(dictGet(root, "AcroForm"));
60441
60448
  const fields2 = form ? await resolve2(dictGet(form, "Fields")) : void 0;
60442
- if (fields2?.kind === "array") for (let i = 0; i < fields2.items.length; i++) yield* field2(fields2.items[i], `Field ${i + 1}`);
60449
+ if (fields2?.kind === "array") for (let i = 0; i < fields2.items.length; i++) yield* field3(fields2.items[i], `Field ${i + 1}`);
60443
60450
  } catch (error) {
60444
60451
  failed = true;
60445
60452
  throw error;
@@ -62381,14 +62388,14 @@ async function createRetainedPageCopy(input, indicesOrStorage, storageOrOptions,
62381
62388
  if (fields2?.kind === "array" && acro?.kind === "dict") {
62382
62389
  let addedFields = false;
62383
62390
  const rootNumbers = new IntegerTable6(backing, 64);
62384
- for (const field2 of fields2.items) {
62385
- if (!await hasCloned(field2)) continue;
62386
- const cloned = await clone(field2);
62391
+ for (const field3 of fields2.items) {
62392
+ if (!await hasCloned(field3)) continue;
62393
+ const cloned = await clone(field3);
62387
62394
  if (cloned.kind !== "ref") continue;
62388
- const dict = await targetDict(cloned), source = await sourceValue(field2), sourceKids = source?.kind === "dict" ? await sourceValue(dictGet(source, "Kids")) : void 0;
62395
+ const dict = await targetDict(cloned), source = await sourceValue(field3), sourceKids = source?.kind === "dict" ? await sourceValue(dictGet(source, "Kids")) : void 0;
62389
62396
  let kids = dict && dictGet(dict, "Kids");
62390
62397
  if (kids?.kind === "ref") kids = (await store.get(kids.objectNumber))?.value;
62391
- if (dict && kids?.kind === "array" && field2.kind === "ref" && sourceKids?.kind === "array" && sourceKids.items.length === kids.items.length) {
62398
+ if (dict && kids?.kind === "array" && field3.kind === "ref" && sourceKids?.kind === "array" && sourceKids.items.length === kids.items.length) {
62392
62399
  const filtered = [];
62393
62400
  for (let i = 0; i < kids.items.length; i++) if (await hasCloned(sourceKids.items[i])) filtered.push(kids.items[i]);
62394
62401
  if (filtered.length) {
@@ -62435,12 +62442,12 @@ async function createRetainedPageCopy(input, indicesOrStorage, storageOrOptions,
62435
62442
  }
62436
62443
  }
62437
62444
  const encoder = new TextEncoder();
62438
- async function* dictionary(dict, field2, values) {
62445
+ async function* dictionary(dict, field3, values) {
62439
62446
  yield encoder.encode("<<\n");
62440
62447
  for (const entry of dict.entries) {
62441
62448
  yield* serializeCosNodeChunks(entry.key, { chunkBytes: options.chunkBytes ?? 16384, maxRecursionDepth: maximumDepth, signal }, 1);
62442
62449
  yield encoder.encode(" ");
62443
- if (entry.key.decoded === field2) {
62450
+ if (entry.key.decoded === field3) {
62444
62451
  if (values.count && maximumDepth < 2) throw new PdfError("E_LIMIT", "PDF page copy depth limit exceeded");
62445
62452
  yield encoder.encode("[ ");
62446
62453
  for await (const reference of references(values)) yield encoder.encode(`${reference.objectNumber} 0 R `);
@@ -62468,10 +62475,10 @@ async function createRetainedPageCopy(input, indicesOrStorage, storageOrOptions,
62468
62475
  const pageTree = cosDict({ Type: cosName("Pages"), Count: cosNumber(pageCount), Kids: cosArray([]) });
62469
62476
  if (pageLabels) await store.setSerializedValue(pageLabels);
62470
62477
  if (attachmentNames) await store.setSerializedValue(attachmentNames);
62471
- async function saveList(number, dict, field2, values) {
62478
+ async function saveList(number, dict, field3, values) {
62472
62479
  let length = 0;
62473
- for await (const bytes of dictionary(dict, field2, values)) length += bytes.length;
62474
- await store.setSerializedValue({ objectNumber: number, generationNumber: 0, body: { length, chunks: dictionary(dict, field2, values) } });
62480
+ for await (const bytes of dictionary(dict, field3, values)) length += bytes.length;
62481
+ await store.setSerializedValue({ objectNumber: number, generationNumber: 0, body: { length, chunks: dictionary(dict, field3, values) } });
62475
62482
  }
62476
62483
  await saveList(2, pageTree, "Kids", pages);
62477
62484
  if (formRef) await saveList(formRef.objectNumber, (await store.get(formRef.objectNumber)).value, "Fields", formFields);
@@ -63171,9 +63178,9 @@ q ${sx} 0 0 ${sy} ${tx} ${ty} cm /${name} Do Q
63171
63178
  if (!firstPage) return;
63172
63179
  for (let i = 0; i < fieldCount; i++) {
63173
63180
  await checkpoint();
63174
- const location = (await readStoredRecord(backing, Number(await fields2.get(BigInt(i))), signal)).value, field2 = await locate(location);
63175
- if (field2?.value.kind !== "dict" || await baked.get(BigInt(await identity(field2.location)))) continue;
63176
- const rect = await resolve2(dictGet(field2.value, "Rect")), items = rect?.kind === "array" ? rect.items : [], x = await number(items[0], 50), y = await number(items[1], 700), value = await resolve2(dictGet(field2.value, "V") ?? dictGet(field2.value, "AS"));
63181
+ const location = (await readStoredRecord(backing, Number(await fields2.get(BigInt(i))), signal)).value, field3 = await locate(location);
63182
+ if (field3?.value.kind !== "dict" || await baked.get(BigInt(await identity(field3.location)))) continue;
63183
+ const rect = await resolve2(dictGet(field3.value, "Rect")), items = rect?.kind === "array" ? rect.items : [], x = await number(items[0], 50), y = await number(items[1], 700), value = await resolve2(dictGet(field3.value, "V") ?? dictGet(field3.value, "AS"));
63177
63184
  await draw(firstPage, await textValue(value, false), x + 2, y + 4);
63178
63185
  }
63179
63186
  const latest = await locate(form);
@@ -63744,21 +63751,21 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
63744
63751
  continue;
63745
63752
  }
63746
63753
  await checkpoint(frame.depth);
63747
- const field2 = await locate(frame.location);
63748
- if (field2?.value.kind !== "dict") continue;
63749
- if (!field2.location.path.length) {
63750
- const id = field2.location.reference.objectNumber;
63754
+ const field3 = await locate(frame.location);
63755
+ if (field3?.value.kind !== "dict") continue;
63756
+ if (!field3.location.path.length) {
63757
+ const id = field3.location.reference.objectNumber;
63751
63758
  if (await active.get(BigInt(id)) === 1n) continue;
63752
63759
  await active.set(BigInt(id), 1n);
63753
63760
  await push({ exit: id });
63754
63761
  }
63755
- const name = await resolve2(dictGet(field2.value, "T")), ft = await resolve2(dictGet(field2.value, "FT"));
63762
+ const name = await resolve2(dictGet(field3.value, "T")), ft = await resolve2(dictGet(field3.value, "FT"));
63756
63763
  const partial = name?.kind === "name" ? name.decoded : name?.kind === "string" ? decodePdfString(name) : "";
63757
63764
  const named = update ? frame.named && partial ? `${frame.named}.${partial}` : partial || frame.named : frame.named || partial ? "1" : "";
63758
- const inherited = { ...frame, named, ft: ft?.kind === "name" ? ft.decoded : frame.ft, ff: await number(dictGet(field2.value, "Ff"), frame.ff), q: await number(dictGet(field2.value, "Q"), frame.q) };
63759
- const maxLen = await resolve2(dictGet(field2.value, "MaxLen"));
63765
+ const inherited = { ...frame, named, ft: ft?.kind === "name" ? ft.decoded : frame.ft, ff: await number(dictGet(field3.value, "Ff"), frame.ff), q: await number(dictGet(field3.value, "Q"), frame.q) };
63766
+ const maxLen = await resolve2(dictGet(field3.value, "MaxLen"));
63760
63767
  if (maxLen?.kind === "number") inherited.maxLen = maxLen.value;
63761
- const kids = await locate(child(field2.location, "Kids"));
63768
+ const kids = await locate(child(field3.location, "Kids"));
63762
63769
  if (kids?.value.kind === "array" && kids.value.items.length) {
63763
63770
  let namedKids = false;
63764
63771
  for (let i = 0; i < kids.value.items.length; i++) {
@@ -63783,14 +63790,14 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
63783
63790
  matched = true;
63784
63791
  const value2 = update.value;
63785
63792
  if (typeof value2 === "boolean" || inherited.ft === "Btn") {
63786
- const on = await onValue(field2.location);
63793
+ const on = await onValue(field3.location);
63787
63794
  const checked = typeof value2 === "boolean" ? value2 : value2 !== "Off" && value2 !== "false" && value2 !== "0" && value2 !== "";
63788
63795
  const chosen = typeof value2 === "string" && value2 !== "true" && value2 !== "false" && value2 !== "Off" ? value2 : on;
63789
63796
  const state = cosName(checked ? chosen : "Off");
63790
- dictSet(field2.value, "FT", cosName("Btn"));
63791
- dictSet(field2.value, "V", state);
63792
- dictSet(field2.value, "AS", state);
63793
- await store.set(field2.owner);
63797
+ dictSet(field3.value, "FT", cosName("Btn"));
63798
+ dictSet(field3.value, "V", state);
63799
+ dictSet(field3.value, "AS", state);
63800
+ await store.set(field3.owner);
63794
63801
  if (kids?.value.kind === "array") for (let i = 0; i < kids.value.items.length; i++) {
63795
63802
  await checkpoint();
63796
63803
  const kid = await locate(itemLocation(kids.location, i, kids.value.items[i]));
@@ -63802,13 +63809,13 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
63802
63809
  }
63803
63810
  continue;
63804
63811
  }
63805
- if (!inherited.ft) dictSet(field2.value, "FT", cosName("Tx"));
63812
+ if (!inherited.ft) dictSet(field3.value, "FT", cosName("Tx"));
63806
63813
  let text2 = String(value2);
63807
63814
  const multi = inherited.ft === "Ch" && !!(inherited.ff & 1 << 21) && text2.includes(",");
63808
63815
  const selected = multi ? text2.split(",").map((value3) => value3.trim()).filter(Boolean) : [text2];
63809
- dictSet(field2.value, "V", multi ? cosArray(selected.map((value3) => cosString(value3))) : cosString(text2));
63816
+ dictSet(field3.value, "V", multi ? cosArray(selected.map((value3) => cosString(value3))) : cosString(text2));
63810
63817
  if (inherited.ft === "Ch") {
63811
- const choices = await resolve2(dictGet(field2.value, "Opt")), indices = [];
63818
+ const choices = await resolve2(dictGet(field3.value, "Opt")), indices = [];
63812
63819
  if (choices?.kind === "array") for (let i = 0; i < choices.items.length; i++) {
63813
63820
  await checkpoint();
63814
63821
  const option = await resolve2(choices.items[i]);
@@ -63831,10 +63838,10 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
63831
63838
  }
63832
63839
  }
63833
63840
  }
63834
- if (indices.length) dictSet(field2.value, "I", cosArray(indices.map((value3) => cosNumber(value3))));
63841
+ if (indices.length) dictSet(field3.value, "I", cosArray(indices.map((value3) => cosNumber(value3))));
63835
63842
  }
63836
- await store.set(field2.owner);
63837
- await synthesize(field2.location, text2, inherited);
63843
+ await store.set(field3.owner);
63844
+ await synthesize(field3.location, text2, inherited);
63838
63845
  if (kids?.value.kind === "array") for (let i = 0; i < kids.value.items.length; i++) {
63839
63846
  await checkpoint();
63840
63847
  const kid = await locate(itemLocation(kids.location, i, kids.value.items[i]));
@@ -63842,24 +63849,24 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
63842
63849
  }
63843
63850
  continue;
63844
63851
  }
63845
- const value = await resolve2(dictGet(field2.value, "V"));
63852
+ const value = await resolve2(dictGet(field3.value, "V"));
63846
63853
  if (!value) continue;
63847
- const appearance = await resolve2(dictGet(field2.value, "AP")), hasNormal = appearance?.kind === "dict" && dictGet(appearance, "N") !== void 0;
63854
+ const appearance = await resolve2(dictGet(field3.value, "AP")), hasNormal = appearance?.kind === "dict" && dictGet(appearance, "N") !== void 0;
63848
63855
  if (!force && hasNormal) continue;
63849
63856
  if (inherited.ft === "Btn") {
63850
- dictSet(field2.value, "AS", cosName(value.kind === "name" ? value.decoded : value.kind === "string" ? decodePdfString(value) : "Off"));
63857
+ dictSet(field3.value, "AS", cosName(value.kind === "name" ? value.decoded : value.kind === "string" ? decodePdfString(value) : "Off"));
63851
63858
  if (!hasNormal) {
63852
- const name2 = await onValue(field2.location), dict = cosDict({ Type: cosName("XObject"), Subtype: cosName("Form"), BBox: cosArray([0, 0, 12, 12].map((v) => cosNumber(v))) });
63859
+ const name2 = await onValue(field3.location), dict = cosDict({ Type: cosName("XObject"), Subtype: cosName("Form"), BBox: cosArray([0, 0, 12, 12].map((v) => cosNumber(v))) });
63853
63860
  const on = await stream(dict, [new TextEncoder().encode("q 0 0 0 rg 2 2 8 8 re f Q\n")]);
63854
63861
  const off = await stream(dict, [new TextEncoder().encode("q Q\n")]);
63855
- dictSet(field2.value, "AP", cosDict({ N: cosDict({ [name2]: on, Off: off }) }));
63862
+ dictSet(field3.value, "AP", cosDict({ N: cosDict({ [name2]: on, Off: off }) }));
63856
63863
  }
63857
- await store.set(field2.owner);
63864
+ await store.set(field3.owner);
63858
63865
  continue;
63859
63866
  }
63860
63867
  let text = value.kind === "string" ? decodePdfString(value) : value.kind === "name" ? value.decoded : "";
63861
63868
  if (inherited.ft === "Ch") {
63862
- const choices = await resolve2(dictGet(field2.value, "Opt"));
63869
+ const choices = await resolve2(dictGet(field3.value, "Opt"));
63863
63870
  if (choices?.kind === "array") for (const choice of choices.items) {
63864
63871
  await checkpoint();
63865
63872
  const pair = await resolve2(choice);
@@ -63872,7 +63879,7 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
63872
63879
  }
63873
63880
  }
63874
63881
  }
63875
- await synthesize(field2.location, text, inherited);
63882
+ await synthesize(field3.location, text, inherited);
63876
63883
  if (kids?.value.kind === "array") for (let i = 0; i < kids.value.items.length; i++) {
63877
63884
  await checkpoint();
63878
63885
  const kid = await locate(itemLocation(kids.location, i, kids.value.items[i]));
@@ -63883,8 +63890,8 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
63883
63890
  const fields3 = await locate(child(formLocation, "Fields"));
63884
63891
  if (fields3?.value.kind === "array") {
63885
63892
  const value = update.value;
63886
- const field2 = typeof value === "boolean" ? cosDict({ FT: cosName("Btn"), T: cosString(update.name), V: cosName(value ? "Yes" : "Off"), AS: cosName(value ? "Yes" : "Off") }) : cosDict({ FT: cosName("Tx"), T: cosString(update.name), V: cosString(value) });
63887
- fields3.value.items.push(await store.allocate(field2));
63893
+ const field3 = typeof value === "boolean" ? cosDict({ FT: cosName("Btn"), T: cosString(update.name), V: cosName(value ? "Yes" : "Off"), AS: cosName(value ? "Yes" : "Off") }) : cosDict({ FT: cosName("Tx"), T: cosString(update.name), V: cosString(value) });
63894
+ fields3.value.items.push(await store.allocate(field3));
63888
63895
  await store.set(fields3.owner);
63889
63896
  }
63890
63897
  }
@@ -66729,7 +66736,7 @@ async function* parseRetainedFormData(source, storage, options = {}) {
66729
66736
  const prefix = await text.prefix();
66730
66737
  if (prefix === "%FDF-" || await text.indexOf("/FDF") >= 0 && await text.indexOf("/Fields") >= 0) await parseRetainedFdf(source, storage, set, signal);
66731
66738
  else if (prefix === "<?xml" || prefix === "<xfdf" || await text.indexOf("<fields") >= 0) {
66732
- let position = 0, head = -1, field2 = "";
66739
+ let position = 0, head = -1, field3 = "";
66733
66740
  while (position < text.length) {
66734
66741
  await checkpoint();
66735
66742
  const lt = await text.indexOf("<", position);
@@ -66742,7 +66749,7 @@ async function* parseRetainedFormData(source, storage, options = {}) {
66742
66749
  if (raw.startsWith("/")) {
66743
66750
  if (raw.slice(1).trim().toLowerCase() === "field" && head !== -1) {
66744
66751
  const row = (await readStoredRecord(state, head, signal)).value;
66745
- field2 = row.field;
66752
+ field3 = row.field;
66746
66753
  head = row.previous;
66747
66754
  }
66748
66755
  continue;
@@ -66759,14 +66766,14 @@ async function* parseRetainedFormData(source, storage, options = {}) {
66759
66766
  }
66760
66767
  }
66761
66768
  if (!selfClosing) {
66762
- head = await appendStoredRecord(state, { field: field2, previous: head }, -1, signal);
66763
- field2 = field2 && part ? `${field2}.${part}` : field2 || part;
66769
+ head = await appendStoredRecord(state, { field: field3, previous: head }, -1, signal);
66770
+ field3 = field3 && part ? `${field3}.${part}` : field3 || part;
66764
66771
  }
66765
66772
  } else if (name === "value" && !selfClosing && head !== -1) {
66766
66773
  const close = await text.indexOf("</value>", position);
66767
66774
  if (close >= 0) {
66768
66775
  const value = decodeFormDataEntities(await text.read(position, close));
66769
- if (field2) await set(field2, value === "Off" ? false : value === "Yes" || value === "On" ? true : value, true);
66776
+ if (field3) await set(field3, value === "Off" ? false : value === "Yes" || value === "On" ? true : value, true);
66770
66777
  position = close + 8;
66771
66778
  }
66772
66779
  }