@poe-platform/safe-bash 0.1.758 → 0.1.759

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 (26) hide show
  1. package/dist/image-ast/index.browser.js +15 -5
  2. package/dist/image-ast/index.js +15 -5
  3. package/dist/pdf-ast/index.js +15 -5
  4. package/dist/safe-bash/chunks/{chunk-WNWIBBJZ.js → chunk-AYPUGSOV.js} +7 -1
  5. package/dist/safe-bash/command-chunks/{chunk-XYCWDGOG.js → chunk-7JA44PVV.js} +1 -1
  6. package/dist/safe-bash/command-chunks/{chunk-TCAGGM44.js → chunk-BAUGDXLZ.js} +15 -6
  7. package/dist/safe-bash/command-chunks/{chunk-L2C5TIII.js → chunk-HVEAK3OS.js} +2 -2
  8. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  9. package/dist/safe-bash/commands/python/shell-capability.js +10 -2
  10. package/dist/safe-bash/core.browser.js +1 -1
  11. package/dist/safe-bash-command-ffmpeg/index.js +618 -613
  12. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  13. package/dist/safe-bash-command-pandoc/command.js +3 -3
  14. package/dist/safe-bash-command-pandoc/index.js +3 -3
  15. package/dist/safe-bash-command-pdfimages/index.js +15 -5
  16. package/dist/safe-bash-command-pdfinfo/index.js +15 -5
  17. package/dist/safe-bash-command-pdftk/index.js +15 -5
  18. package/dist/safe-bash-command-pdftoppm/index.js +15 -5
  19. package/dist/safe-bash-command-pdftotext/index.js +15 -5
  20. package/dist/safe-bash-command-qpdf/index.js +15 -5
  21. package/dist/safe-bash-command-sips/index.js +2 -2
  22. package/dist/safe-bash-command-soffice/index.js +1 -1
  23. package/dist/safe-bash-command-ssconvert/index.js +37 -27
  24. package/dist/safe-bash-command-wkhtmltopdf/index.js +16 -5
  25. package/package.json +2 -2
  26. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +14 -0
@@ -28,8 +28,8 @@ import {
28
28
  thresholdImage,
29
29
  tintImage,
30
30
  trimImage
31
- } from "../safe-bash/command-chunks/chunk-XYCWDGOG.js";
32
- import "../safe-bash/command-chunks/chunk-TCAGGM44.js";
31
+ } from "../safe-bash/command-chunks/chunk-7JA44PVV.js";
32
+ import "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
33
33
  import {
34
34
  init_buffer
35
35
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -2,11 +2,11 @@ import {
2
2
  createPandocCommand,
3
3
  createPandocCommands,
4
4
  pandocCommands
5
- } from "../safe-bash/command-chunks/chunk-L2C5TIII.js";
5
+ } from "../safe-bash/command-chunks/chunk-HVEAK3OS.js";
6
6
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
7
7
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
8
- import "../safe-bash/command-chunks/chunk-XYCWDGOG.js";
9
- import "../safe-bash/command-chunks/chunk-TCAGGM44.js";
8
+ import "../safe-bash/command-chunks/chunk-7JA44PVV.js";
9
+ import "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
10
10
  import "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
11
11
  import "../safe-bash/command-chunks/chunk-YGYOVXTO.js";
12
12
  import "../safe-bash/command-chunks/chunk-I5GLTNVH.js";
@@ -21,11 +21,11 @@ import {
21
21
  readDocument,
22
22
  resolveConversionArgs,
23
23
  writeDocument
24
- } from "../safe-bash/command-chunks/chunk-L2C5TIII.js";
24
+ } from "../safe-bash/command-chunks/chunk-HVEAK3OS.js";
25
25
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
26
26
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
27
- import "../safe-bash/command-chunks/chunk-XYCWDGOG.js";
28
- import "../safe-bash/command-chunks/chunk-TCAGGM44.js";
27
+ import "../safe-bash/command-chunks/chunk-7JA44PVV.js";
28
+ import "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
29
29
  import {
30
30
  createLuaFilterCapability
31
31
  } from "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
@@ -656,6 +656,7 @@ var messages_default = {
656
656
  "-5": "buffer error",
657
657
  "-6": "incompatible version"
658
658
  };
659
+ var Z_BUF_ERROR = -5;
659
660
  var MAX_MEM_LEVEL = 9;
660
661
  var HEAP_SIZE = 573;
661
662
  var MIN_MATCH = 3;
@@ -22547,22 +22548,31 @@ function decodeFlate(bytes, parms, maxDecodedBytes = DEFAULT_MAX_DECODED_BYTES)
22547
22548
  inflated = new BoundedFlateStream(bytes, maxDecodedBytes).getBytes();
22548
22549
  } catch (error) {
22549
22550
  if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
22551
+ const wrapped = bytes[0] === 31 && bytes[1] === 139 || bytes.length >= 2 && (bytes[0] & 15) === 8 && bytes[0] >>> 4 <= 7 && (bytes[0] << 8 | bytes[1]) % 31 === 0;
22550
22552
  const decoder = new Inflate({
22551
- raw: !(bytes[0] === 31 && bytes[1] === 139),
22553
+ raw: !wrapped,
22552
22554
  chunkSize: Math.max(1, Math.min(64 * 1024, maxDecodedBytes + 1))
22553
22555
  });
22556
+ const chunks = [];
22554
22557
  let length = 0;
22555
22558
  decoder.onData = (chunk) => {
22556
22559
  length += chunk.length;
22557
22560
  if (length > maxDecodedBytes) {
22558
22561
  throw new PdfError("E_LIMIT", "FlateDecode output exceeds maximum decoded byte budget");
22559
22562
  }
22560
- decoder.chunks.push(chunk);
22563
+ chunks.push(chunk);
22561
22564
  };
22562
- if (!decoder.push(bytes, true) || decoder.err || !decoder.ended) {
22565
+ const complete = decoder.push(bytes, true);
22566
+ const truncated = wrapped && decoder.err === Z_BUF_ERROR && length > 0;
22567
+ if ((!complete || decoder.err || !decoder.ended) && !truncated) {
22563
22568
  throw new PdfError("E_CAPABILITY", "Invalid FlateDecode compressed stream");
22564
22569
  }
22565
- inflated = decoder.result;
22570
+ inflated = new Uint8Array(length);
22571
+ let offset = 0;
22572
+ for (const chunk of chunks) {
22573
+ inflated.set(chunk, offset);
22574
+ offset += chunk.length;
22575
+ }
22566
22576
  }
22567
22577
  return applyPredictor(inflated, parms);
22568
22578
  }
@@ -34796,7 +34806,7 @@ function resolvePageFonts(doc, resourcesDict) {
34796
34806
  const glyphNames = buildFontEncodingGlyphNamesMap(encNode);
34797
34807
  const widths = /* @__PURE__ */ new Map();
34798
34808
  let defaultWidth = 556;
34799
- const isTwoByteCid = subtype === "Type0" || Boolean(cmap?.isTwoByte);
34809
+ const isTwoByteCid = subtype === "Type0";
34800
34810
  let fontMatrix;
34801
34811
  let charProcs;
34802
34812
  let fontResources;
@@ -656,6 +656,7 @@ var messages_default = {
656
656
  "-5": "buffer error",
657
657
  "-6": "incompatible version"
658
658
  };
659
+ var Z_BUF_ERROR = -5;
659
660
  var MAX_MEM_LEVEL = 9;
660
661
  var HEAP_SIZE = 573;
661
662
  var MIN_MATCH = 3;
@@ -22741,22 +22742,31 @@ function decodeFlate(bytes, parms, maxDecodedBytes = DEFAULT_MAX_DECODED_BYTES)
22741
22742
  inflated = new BoundedFlateStream(bytes, maxDecodedBytes).getBytes();
22742
22743
  } catch (error) {
22743
22744
  if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
22745
+ const wrapped = bytes[0] === 31 && bytes[1] === 139 || bytes.length >= 2 && (bytes[0] & 15) === 8 && bytes[0] >>> 4 <= 7 && (bytes[0] << 8 | bytes[1]) % 31 === 0;
22744
22746
  const decoder = new Inflate({
22745
- raw: !(bytes[0] === 31 && bytes[1] === 139),
22747
+ raw: !wrapped,
22746
22748
  chunkSize: Math.max(1, Math.min(64 * 1024, maxDecodedBytes + 1))
22747
22749
  });
22750
+ const chunks = [];
22748
22751
  let length = 0;
22749
22752
  decoder.onData = (chunk) => {
22750
22753
  length += chunk.length;
22751
22754
  if (length > maxDecodedBytes) {
22752
22755
  throw new PdfError("E_LIMIT", "FlateDecode output exceeds maximum decoded byte budget");
22753
22756
  }
22754
- decoder.chunks.push(chunk);
22757
+ chunks.push(chunk);
22755
22758
  };
22756
- if (!decoder.push(bytes, true) || decoder.err || !decoder.ended) {
22759
+ const complete = decoder.push(bytes, true);
22760
+ const truncated = wrapped && decoder.err === Z_BUF_ERROR && length > 0;
22761
+ if ((!complete || decoder.err || !decoder.ended) && !truncated) {
22757
22762
  throw new PdfError("E_CAPABILITY", "Invalid FlateDecode compressed stream");
22758
22763
  }
22759
- inflated = decoder.result;
22764
+ inflated = new Uint8Array(length);
22765
+ let offset = 0;
22766
+ for (const chunk of chunks) {
22767
+ inflated.set(chunk, offset);
22768
+ offset += chunk.length;
22769
+ }
22760
22770
  }
22761
22771
  return applyPredictor(inflated, parms);
22762
22772
  }
@@ -34990,7 +35000,7 @@ function resolvePageFonts(doc, resourcesDict) {
34990
35000
  const glyphNames = buildFontEncodingGlyphNamesMap(encNode);
34991
35001
  const widths = /* @__PURE__ */ new Map();
34992
35002
  let defaultWidth = 556;
34993
- const isTwoByteCid = subtype === "Type0" || Boolean(cmap?.isTwoByte);
35003
+ const isTwoByteCid = subtype === "Type0";
34994
35004
  let fontMatrix;
34995
35005
  let charProcs;
34996
35006
  let fontResources;
@@ -656,6 +656,7 @@ var messages_default = {
656
656
  "-5": "buffer error",
657
657
  "-6": "incompatible version"
658
658
  };
659
+ var Z_BUF_ERROR = -5;
659
660
  var MAX_MEM_LEVEL = 9;
660
661
  var HEAP_SIZE = 573;
661
662
  var MIN_MATCH = 3;
@@ -22547,22 +22548,31 @@ function decodeFlate(bytes, parms, maxDecodedBytes = DEFAULT_MAX_DECODED_BYTES)
22547
22548
  inflated = new BoundedFlateStream(bytes, maxDecodedBytes).getBytes();
22548
22549
  } catch (error) {
22549
22550
  if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
22551
+ const wrapped = bytes[0] === 31 && bytes[1] === 139 || bytes.length >= 2 && (bytes[0] & 15) === 8 && bytes[0] >>> 4 <= 7 && (bytes[0] << 8 | bytes[1]) % 31 === 0;
22550
22552
  const decoder = new Inflate({
22551
- raw: !(bytes[0] === 31 && bytes[1] === 139),
22553
+ raw: !wrapped,
22552
22554
  chunkSize: Math.max(1, Math.min(64 * 1024, maxDecodedBytes + 1))
22553
22555
  });
22556
+ const chunks = [];
22554
22557
  let length = 0;
22555
22558
  decoder.onData = (chunk) => {
22556
22559
  length += chunk.length;
22557
22560
  if (length > maxDecodedBytes) {
22558
22561
  throw new PdfError("E_LIMIT", "FlateDecode output exceeds maximum decoded byte budget");
22559
22562
  }
22560
- decoder.chunks.push(chunk);
22563
+ chunks.push(chunk);
22561
22564
  };
22562
- if (!decoder.push(bytes, true) || decoder.err || !decoder.ended) {
22565
+ const complete = decoder.push(bytes, true);
22566
+ const truncated = wrapped && decoder.err === Z_BUF_ERROR && length > 0;
22567
+ if ((!complete || decoder.err || !decoder.ended) && !truncated) {
22563
22568
  throw new PdfError("E_CAPABILITY", "Invalid FlateDecode compressed stream");
22564
22569
  }
22565
- inflated = decoder.result;
22570
+ inflated = new Uint8Array(length);
22571
+ let offset = 0;
22572
+ for (const chunk of chunks) {
22573
+ inflated.set(chunk, offset);
22574
+ offset += chunk.length;
22575
+ }
22566
22576
  }
22567
22577
  return applyPredictor(inflated, parms);
22568
22578
  }
@@ -34451,7 +34461,7 @@ function resolvePageFonts(doc, resourcesDict) {
34451
34461
  const glyphNames = buildFontEncodingGlyphNamesMap(encNode);
34452
34462
  const widths = /* @__PURE__ */ new Map();
34453
34463
  let defaultWidth = 556;
34454
- const isTwoByteCid = subtype === "Type0" || Boolean(cmap?.isTwoByte);
34464
+ const isTwoByteCid = subtype === "Type0";
34455
34465
  let fontMatrix;
34456
34466
  let charProcs;
34457
34467
  let fontResources;
@@ -656,6 +656,7 @@ var messages_default = {
656
656
  "-5": "buffer error",
657
657
  "-6": "incompatible version"
658
658
  };
659
+ var Z_BUF_ERROR = -5;
659
660
  var MAX_MEM_LEVEL = 9;
660
661
  var HEAP_SIZE = 573;
661
662
  var MIN_MATCH = 3;
@@ -22741,22 +22742,31 @@ function decodeFlate(bytes, parms, maxDecodedBytes = DEFAULT_MAX_DECODED_BYTES)
22741
22742
  inflated = new BoundedFlateStream(bytes, maxDecodedBytes).getBytes();
22742
22743
  } catch (error) {
22743
22744
  if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
22745
+ const wrapped = bytes[0] === 31 && bytes[1] === 139 || bytes.length >= 2 && (bytes[0] & 15) === 8 && bytes[0] >>> 4 <= 7 && (bytes[0] << 8 | bytes[1]) % 31 === 0;
22744
22746
  const decoder = new Inflate({
22745
- raw: !(bytes[0] === 31 && bytes[1] === 139),
22747
+ raw: !wrapped,
22746
22748
  chunkSize: Math.max(1, Math.min(64 * 1024, maxDecodedBytes + 1))
22747
22749
  });
22750
+ const chunks = [];
22748
22751
  let length = 0;
22749
22752
  decoder.onData = (chunk) => {
22750
22753
  length += chunk.length;
22751
22754
  if (length > maxDecodedBytes) {
22752
22755
  throw new PdfError("E_LIMIT", "FlateDecode output exceeds maximum decoded byte budget");
22753
22756
  }
22754
- decoder.chunks.push(chunk);
22757
+ chunks.push(chunk);
22755
22758
  };
22756
- if (!decoder.push(bytes, true) || decoder.err || !decoder.ended) {
22759
+ const complete = decoder.push(bytes, true);
22760
+ const truncated = wrapped && decoder.err === Z_BUF_ERROR && length > 0;
22761
+ if ((!complete || decoder.err || !decoder.ended) && !truncated) {
22757
22762
  throw new PdfError("E_CAPABILITY", "Invalid FlateDecode compressed stream");
22758
22763
  }
22759
- inflated = decoder.result;
22764
+ inflated = new Uint8Array(length);
22765
+ let offset = 0;
22766
+ for (const chunk of chunks) {
22767
+ inflated.set(chunk, offset);
22768
+ offset += chunk.length;
22769
+ }
22760
22770
  }
22761
22771
  return applyPredictor(inflated, parms);
22762
22772
  }
@@ -34645,7 +34655,7 @@ function resolvePageFonts(doc, resourcesDict) {
34645
34655
  const glyphNames = buildFontEncodingGlyphNamesMap(encNode);
34646
34656
  const widths = /* @__PURE__ */ new Map();
34647
34657
  let defaultWidth = 556;
34648
- const isTwoByteCid = subtype === "Type0" || Boolean(cmap?.isTwoByte);
34658
+ const isTwoByteCid = subtype === "Type0";
34649
34659
  let fontMatrix;
34650
34660
  let charProcs;
34651
34661
  let fontResources;
@@ -656,6 +656,7 @@ var messages_default = {
656
656
  "-5": "buffer error",
657
657
  "-6": "incompatible version"
658
658
  };
659
+ var Z_BUF_ERROR = -5;
659
660
  var MAX_MEM_LEVEL = 9;
660
661
  var HEAP_SIZE = 573;
661
662
  var MIN_MATCH = 3;
@@ -22547,22 +22548,31 @@ function decodeFlate(bytes, parms, maxDecodedBytes = DEFAULT_MAX_DECODED_BYTES)
22547
22548
  inflated = new BoundedFlateStream(bytes, maxDecodedBytes).getBytes();
22548
22549
  } catch (error) {
22549
22550
  if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
22551
+ const wrapped = bytes[0] === 31 && bytes[1] === 139 || bytes.length >= 2 && (bytes[0] & 15) === 8 && bytes[0] >>> 4 <= 7 && (bytes[0] << 8 | bytes[1]) % 31 === 0;
22550
22552
  const decoder = new Inflate({
22551
- raw: !(bytes[0] === 31 && bytes[1] === 139),
22553
+ raw: !wrapped,
22552
22554
  chunkSize: Math.max(1, Math.min(64 * 1024, maxDecodedBytes + 1))
22553
22555
  });
22556
+ const chunks = [];
22554
22557
  let length = 0;
22555
22558
  decoder.onData = (chunk) => {
22556
22559
  length += chunk.length;
22557
22560
  if (length > maxDecodedBytes) {
22558
22561
  throw new PdfError("E_LIMIT", "FlateDecode output exceeds maximum decoded byte budget");
22559
22562
  }
22560
- decoder.chunks.push(chunk);
22563
+ chunks.push(chunk);
22561
22564
  };
22562
- if (!decoder.push(bytes, true) || decoder.err || !decoder.ended) {
22565
+ const complete = decoder.push(bytes, true);
22566
+ const truncated = wrapped && decoder.err === Z_BUF_ERROR && length > 0;
22567
+ if ((!complete || decoder.err || !decoder.ended) && !truncated) {
22563
22568
  throw new PdfError("E_CAPABILITY", "Invalid FlateDecode compressed stream");
22564
22569
  }
22565
- inflated = decoder.result;
22570
+ inflated = new Uint8Array(length);
22571
+ let offset = 0;
22572
+ for (const chunk of chunks) {
22573
+ inflated.set(chunk, offset);
22574
+ offset += chunk.length;
22575
+ }
22566
22576
  }
22567
22577
  return applyPredictor(inflated, parms);
22568
22578
  }
@@ -34796,7 +34806,7 @@ function resolvePageFonts(doc, resourcesDict) {
34796
34806
  const glyphNames = buildFontEncodingGlyphNamesMap(encNode);
34797
34807
  const widths = /* @__PURE__ */ new Map();
34798
34808
  let defaultWidth = 556;
34799
- const isTwoByteCid = subtype === "Type0" || Boolean(cmap?.isTwoByte);
34809
+ const isTwoByteCid = subtype === "Type0";
34800
34810
  let fontMatrix;
34801
34811
  let charProcs;
34802
34812
  let fontResources;
@@ -656,6 +656,7 @@ var messages_default = {
656
656
  "-5": "buffer error",
657
657
  "-6": "incompatible version"
658
658
  };
659
+ var Z_BUF_ERROR = -5;
659
660
  var MAX_MEM_LEVEL = 9;
660
661
  var HEAP_SIZE = 573;
661
662
  var MIN_MATCH = 3;
@@ -22547,22 +22548,31 @@ function decodeFlate(bytes, parms, maxDecodedBytes = DEFAULT_MAX_DECODED_BYTES)
22547
22548
  inflated = new BoundedFlateStream(bytes, maxDecodedBytes).getBytes();
22548
22549
  } catch (error) {
22549
22550
  if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
22551
+ const wrapped = bytes[0] === 31 && bytes[1] === 139 || bytes.length >= 2 && (bytes[0] & 15) === 8 && bytes[0] >>> 4 <= 7 && (bytes[0] << 8 | bytes[1]) % 31 === 0;
22550
22552
  const decoder = new Inflate({
22551
- raw: !(bytes[0] === 31 && bytes[1] === 139),
22553
+ raw: !wrapped,
22552
22554
  chunkSize: Math.max(1, Math.min(64 * 1024, maxDecodedBytes + 1))
22553
22555
  });
22556
+ const chunks = [];
22554
22557
  let length = 0;
22555
22558
  decoder.onData = (chunk) => {
22556
22559
  length += chunk.length;
22557
22560
  if (length > maxDecodedBytes) {
22558
22561
  throw new PdfError("E_LIMIT", "FlateDecode output exceeds maximum decoded byte budget");
22559
22562
  }
22560
- decoder.chunks.push(chunk);
22563
+ chunks.push(chunk);
22561
22564
  };
22562
- if (!decoder.push(bytes, true) || decoder.err || !decoder.ended) {
22565
+ const complete = decoder.push(bytes, true);
22566
+ const truncated = wrapped && decoder.err === Z_BUF_ERROR && length > 0;
22567
+ if ((!complete || decoder.err || !decoder.ended) && !truncated) {
22563
22568
  throw new PdfError("E_CAPABILITY", "Invalid FlateDecode compressed stream");
22564
22569
  }
22565
- inflated = decoder.result;
22570
+ inflated = new Uint8Array(length);
22571
+ let offset = 0;
22572
+ for (const chunk of chunks) {
22573
+ inflated.set(chunk, offset);
22574
+ offset += chunk.length;
22575
+ }
22566
22576
  }
22567
22577
  return applyPredictor(inflated, parms);
22568
22578
  }
@@ -34451,7 +34461,7 @@ function resolvePageFonts(doc, resourcesDict) {
34451
34461
  const glyphNames = buildFontEncodingGlyphNamesMap(encNode);
34452
34462
  const widths = /* @__PURE__ */ new Map();
34453
34463
  let defaultWidth = 556;
34454
- const isTwoByteCid = subtype === "Type0" || Boolean(cmap?.isTwoByte);
34464
+ const isTwoByteCid = subtype === "Type0";
34455
34465
  let fontMatrix;
34456
34466
  let charProcs;
34457
34467
  let fontResources;
@@ -11,8 +11,8 @@ import {
11
11
  readImageMetadata,
12
12
  resizeImage,
13
13
  rotateImage
14
- } from "../safe-bash/command-chunks/chunk-XYCWDGOG.js";
15
- import "../safe-bash/command-chunks/chunk-TCAGGM44.js";
14
+ } from "../safe-bash/command-chunks/chunk-7JA44PVV.js";
15
+ import "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
16
16
  import {
17
17
  init_buffer
18
18
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -31,7 +31,7 @@ import {
31
31
  PdfDocument,
32
32
  decodeFlate,
33
33
  rgb
34
- } from "../safe-bash/command-chunks/chunk-TCAGGM44.js";
34
+ } from "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
35
35
  import {
36
36
  init_buffer
37
37
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -1778,7 +1778,7 @@ var require_deflate = __commonJS({
1778
1778
  var Z_STREAM_END2 = 1;
1779
1779
  var Z_STREAM_ERROR = -2;
1780
1780
  var Z_DATA_ERROR2 = -3;
1781
- var Z_BUF_ERROR2 = -5;
1781
+ var Z_BUF_ERROR3 = -5;
1782
1782
  var Z_DEFAULT_COMPRESSION = -1;
1783
1783
  var Z_FILTERED = 1;
1784
1784
  var Z_HUFFMAN_ONLY = 2;
@@ -2476,7 +2476,7 @@ var require_deflate = __commonJS({
2476
2476
  }
2477
2477
  s = strm.state;
2478
2478
  if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE3 && flush !== Z_FINISH2) {
2479
- return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR);
2479
+ return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR3 : Z_STREAM_ERROR);
2480
2480
  }
2481
2481
  s.strm = strm;
2482
2482
  old_flush = s.last_flush;
@@ -2658,10 +2658,10 @@ var require_deflate = __commonJS({
2658
2658
  return Z_OK2;
2659
2659
  }
2660
2660
  } else if (strm.avail_in === 0 && rank3(flush) <= rank3(old_flush) && flush !== Z_FINISH2) {
2661
- return err3(strm, Z_BUF_ERROR2);
2661
+ return err3(strm, Z_BUF_ERROR3);
2662
2662
  }
2663
2663
  if (s.status === FINISH_STATE3 && strm.avail_in !== 0) {
2664
- return err3(strm, Z_BUF_ERROR2);
2664
+ return err3(strm, Z_BUF_ERROR3);
2665
2665
  }
2666
2666
  if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE3) {
2667
2667
  var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff3(s, flush) : s.strategy === Z_RLE ? deflate_rle3(s, flush) : configuration_table3[s.level].func(s, flush);
@@ -3688,7 +3688,7 @@ var require_inflate = __commonJS({
3688
3688
  var Z_STREAM_ERROR = -2;
3689
3689
  var Z_DATA_ERROR2 = -3;
3690
3690
  var Z_MEM_ERROR = -4;
3691
- var Z_BUF_ERROR2 = -5;
3691
+ var Z_BUF_ERROR3 = -5;
3692
3692
  var Z_DEFLATED = 8;
3693
3693
  var HEAD3 = 1;
3694
3694
  var FLAGS3 = 2;
@@ -4838,7 +4838,7 @@ var require_inflate = __commonJS({
4838
4838
  }
4839
4839
  strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE3 ? 128 : 0) + (state.mode === LEN_3 || state.mode === COPY_3 ? 256 : 0);
4840
4840
  if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {
4841
- ret = Z_BUF_ERROR2;
4841
+ ret = Z_BUF_ERROR3;
4842
4842
  }
4843
4843
  return ret;
4844
4844
  }
@@ -7049,7 +7049,7 @@ var require_deflate3 = __commonJS({
7049
7049
  var Z_STREAM_END2 = 1;
7050
7050
  var Z_STREAM_ERROR = -2;
7051
7051
  var Z_DATA_ERROR2 = -3;
7052
- var Z_BUF_ERROR2 = -5;
7052
+ var Z_BUF_ERROR3 = -5;
7053
7053
  var Z_DEFAULT_COMPRESSION = -1;
7054
7054
  var Z_FILTERED = 1;
7055
7055
  var Z_HUFFMAN_ONLY = 2;
@@ -7747,7 +7747,7 @@ var require_deflate3 = __commonJS({
7747
7747
  }
7748
7748
  s = strm.state;
7749
7749
  if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE3 && flush !== Z_FINISH2) {
7750
- return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR);
7750
+ return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR3 : Z_STREAM_ERROR);
7751
7751
  }
7752
7752
  s.strm = strm;
7753
7753
  old_flush = s.last_flush;
@@ -7929,10 +7929,10 @@ var require_deflate3 = __commonJS({
7929
7929
  return Z_OK2;
7930
7930
  }
7931
7931
  } else if (strm.avail_in === 0 && rank3(flush) <= rank3(old_flush) && flush !== Z_FINISH2) {
7932
- return err3(strm, Z_BUF_ERROR2);
7932
+ return err3(strm, Z_BUF_ERROR3);
7933
7933
  }
7934
7934
  if (s.status === FINISH_STATE3 && strm.avail_in !== 0) {
7935
- return err3(strm, Z_BUF_ERROR2);
7935
+ return err3(strm, Z_BUF_ERROR3);
7936
7936
  }
7937
7937
  if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE3) {
7938
7938
  var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff3(s, flush) : s.strategy === Z_RLE ? deflate_rle3(s, flush) : configuration_table3[s.level].func(s, flush);
@@ -8959,7 +8959,7 @@ var require_inflate3 = __commonJS({
8959
8959
  var Z_STREAM_ERROR = -2;
8960
8960
  var Z_DATA_ERROR2 = -3;
8961
8961
  var Z_MEM_ERROR = -4;
8962
- var Z_BUF_ERROR2 = -5;
8962
+ var Z_BUF_ERROR3 = -5;
8963
8963
  var Z_DEFLATED = 8;
8964
8964
  var HEAD3 = 1;
8965
8965
  var FLAGS3 = 2;
@@ -10109,7 +10109,7 @@ var require_inflate3 = __commonJS({
10109
10109
  }
10110
10110
  strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE3 ? 128 : 0) + (state.mode === LEN_3 || state.mode === COPY_3 ? 256 : 0);
10111
10111
  if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {
10112
- ret = Z_BUF_ERROR2;
10112
+ ret = Z_BUF_ERROR3;
10113
10113
  }
10114
10114
  return ret;
10115
10115
  }
@@ -14564,7 +14564,7 @@ var require_deflate5 = __commonJS({
14564
14564
  var Z_STREAM_END2 = 1;
14565
14565
  var Z_STREAM_ERROR = -2;
14566
14566
  var Z_DATA_ERROR2 = -3;
14567
- var Z_BUF_ERROR2 = -5;
14567
+ var Z_BUF_ERROR3 = -5;
14568
14568
  var Z_DEFAULT_COMPRESSION = -1;
14569
14569
  var Z_FILTERED = 1;
14570
14570
  var Z_HUFFMAN_ONLY = 2;
@@ -15262,7 +15262,7 @@ var require_deflate5 = __commonJS({
15262
15262
  }
15263
15263
  s = strm.state;
15264
15264
  if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE3 && flush !== Z_FINISH2) {
15265
- return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR);
15265
+ return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR3 : Z_STREAM_ERROR);
15266
15266
  }
15267
15267
  s.strm = strm;
15268
15268
  old_flush = s.last_flush;
@@ -15444,10 +15444,10 @@ var require_deflate5 = __commonJS({
15444
15444
  return Z_OK2;
15445
15445
  }
15446
15446
  } else if (strm.avail_in === 0 && rank3(flush) <= rank3(old_flush) && flush !== Z_FINISH2) {
15447
- return err3(strm, Z_BUF_ERROR2);
15447
+ return err3(strm, Z_BUF_ERROR3);
15448
15448
  }
15449
15449
  if (s.status === FINISH_STATE3 && strm.avail_in !== 0) {
15450
- return err3(strm, Z_BUF_ERROR2);
15450
+ return err3(strm, Z_BUF_ERROR3);
15451
15451
  }
15452
15452
  if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE3) {
15453
15453
  var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff3(s, flush) : s.strategy === Z_RLE ? deflate_rle3(s, flush) : configuration_table3[s.level].func(s, flush);
@@ -16474,7 +16474,7 @@ var require_inflate5 = __commonJS({
16474
16474
  var Z_STREAM_ERROR = -2;
16475
16475
  var Z_DATA_ERROR2 = -3;
16476
16476
  var Z_MEM_ERROR = -4;
16477
- var Z_BUF_ERROR2 = -5;
16477
+ var Z_BUF_ERROR3 = -5;
16478
16478
  var Z_DEFLATED = 8;
16479
16479
  var HEAD3 = 1;
16480
16480
  var FLAGS3 = 2;
@@ -17624,7 +17624,7 @@ var require_inflate5 = __commonJS({
17624
17624
  }
17625
17625
  strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE3 ? 128 : 0) + (state.mode === LEN_3 || state.mode === COPY_3 ? 256 : 0);
17626
17626
  if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {
17627
- ret = Z_BUF_ERROR2;
17627
+ ret = Z_BUF_ERROR3;
17628
17628
  }
17629
17629
  return ret;
17630
17630
  }
@@ -51584,7 +51584,7 @@ var require_fontkit_umd = __commonJS({
51584
51584
  var Z_STREAM_END2 = 1;
51585
51585
  var Z_STREAM_ERROR = -2;
51586
51586
  var Z_DATA_ERROR2 = -3;
51587
- var Z_BUF_ERROR2 = -5;
51587
+ var Z_BUF_ERROR3 = -5;
51588
51588
  var Z_DEFAULT_COMPRESSION = -1;
51589
51589
  var Z_FILTERED = 1;
51590
51590
  var Z_HUFFMAN_ONLY = 2;
@@ -52282,7 +52282,7 @@ var require_fontkit_umd = __commonJS({
52282
52282
  }
52283
52283
  s = strm.state;
52284
52284
  if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE3 && flush !== Z_FINISH2) {
52285
- return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR);
52285
+ return err3(strm, strm.avail_out === 0 ? Z_BUF_ERROR3 : Z_STREAM_ERROR);
52286
52286
  }
52287
52287
  s.strm = strm;
52288
52288
  old_flush = s.last_flush;
@@ -52461,10 +52461,10 @@ var require_fontkit_umd = __commonJS({
52461
52461
  return Z_OK2;
52462
52462
  }
52463
52463
  } else if (strm.avail_in === 0 && rank3(flush) <= rank3(old_flush) && flush !== Z_FINISH2) {
52464
- return err3(strm, Z_BUF_ERROR2);
52464
+ return err3(strm, Z_BUF_ERROR3);
52465
52465
  }
52466
52466
  if (s.status === FINISH_STATE3 && strm.avail_in !== 0) {
52467
- return err3(strm, Z_BUF_ERROR2);
52467
+ return err3(strm, Z_BUF_ERROR3);
52468
52468
  }
52469
52469
  if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE3) {
52470
52470
  var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff3(s, flush) : s.strategy === Z_RLE ? deflate_rle3(s, flush) : configuration_table3[s.level].func(s, flush);
@@ -174163,6 +174163,7 @@ var messages_default22 = {
174163
174163
  "-5": "buffer error",
174164
174164
  "-6": "incompatible version"
174165
174165
  };
174166
+ var Z_BUF_ERROR2 = -5;
174166
174167
  var MAX_MEM_LEVEL22 = 9;
174167
174168
  var HEAP_SIZE22 = 573;
174168
174169
  var MIN_MATCH22 = 3;
@@ -196054,22 +196055,31 @@ function decodeFlate(bytes, parms, maxDecodedBytes = DEFAULT_MAX_DECODED_BYTES)
196054
196055
  inflated = new BoundedFlateStream(bytes, maxDecodedBytes).getBytes();
196055
196056
  } catch (error2) {
196056
196057
  if (error2 instanceof PdfError2 && error2.code === "E_LIMIT") throw error2;
196058
+ const wrapped = bytes[0] === 31 && bytes[1] === 139 || bytes.length >= 2 && (bytes[0] & 15) === 8 && bytes[0] >>> 4 <= 7 && (bytes[0] << 8 | bytes[1]) % 31 === 0;
196057
196059
  const decoder2 = new Inflate22({
196058
- raw: !(bytes[0] === 31 && bytes[1] === 139),
196060
+ raw: !wrapped,
196059
196061
  chunkSize: Math.max(1, Math.min(64 * 1024, maxDecodedBytes + 1))
196060
196062
  });
196063
+ const chunks = [];
196061
196064
  let length = 0;
196062
196065
  decoder2.onData = (chunk) => {
196063
196066
  length += chunk.length;
196064
196067
  if (length > maxDecodedBytes) {
196065
196068
  throw new PdfError2("E_LIMIT", "FlateDecode output exceeds maximum decoded byte budget");
196066
196069
  }
196067
- decoder2.chunks.push(chunk);
196070
+ chunks.push(chunk);
196068
196071
  };
196069
- if (!decoder2.push(bytes, true) || decoder2.err || !decoder2.ended) {
196072
+ const complete2 = decoder2.push(bytes, true);
196073
+ const truncated = wrapped && decoder2.err === Z_BUF_ERROR2 && length > 0;
196074
+ if ((!complete2 || decoder2.err || !decoder2.ended) && !truncated) {
196070
196075
  throw new PdfError2("E_CAPABILITY", "Invalid FlateDecode compressed stream");
196071
196076
  }
196072
- inflated = decoder2.result;
196077
+ inflated = new Uint8Array(length);
196078
+ let offset = 0;
196079
+ for (const chunk of chunks) {
196080
+ inflated.set(chunk, offset);
196081
+ offset += chunk.length;
196082
+ }
196073
196083
  }
196074
196084
  return applyPredictor(inflated, parms);
196075
196085
  }
@@ -207958,7 +207968,7 @@ function resolvePageFonts(doc, resourcesDict) {
207958
207968
  const glyphNames = buildFontEncodingGlyphNamesMap(encNode);
207959
207969
  const widths = /* @__PURE__ */ new Map();
207960
207970
  let defaultWidth = 556;
207961
- const isTwoByteCid = subtype === "Type0" || Boolean(cmap?.isTwoByte);
207971
+ const isTwoByteCid = subtype === "Type0";
207962
207972
  let fontMatrix;
207963
207973
  let charProcs;
207964
207974
  let fontResources;