kordoc 4.0.6 → 4.0.8

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 (86) hide show
  1. package/README.md +823 -806
  2. package/dist/{-NDU7YGSS.js → -LE4RLXVA.js} +8 -8
  3. package/dist/{chunk-5SOZXPQY.js → chunk-2DZQF6YJ.js} +3 -3
  4. package/dist/chunk-2DZQF6YJ.js.map +1 -0
  5. package/dist/{chunk-6GBLFQMA.js → chunk-5RPYBC2Q.js} +1 -1
  6. package/dist/chunk-5RPYBC2Q.js.map +1 -0
  7. package/dist/{chunk-DQJTNXVS.cjs → chunk-6XAAYAWL.cjs} +142 -3
  8. package/dist/chunk-6XAAYAWL.cjs.map +1 -0
  9. package/dist/{chunk-HC2SEH6I.js → chunk-7S3M4N4E.js} +939 -946
  10. package/dist/chunk-7S3M4N4E.js.map +1 -0
  11. package/dist/{chunk-4C7SBZNW.js → chunk-BNU5QGIZ.js} +2 -2
  12. package/dist/chunk-BNU5QGIZ.js.map +1 -0
  13. package/dist/{chunk-63ASYC4N.js → chunk-D35VBACN.js} +3 -3
  14. package/dist/chunk-D35VBACN.js.map +1 -0
  15. package/dist/chunk-DCZVOIEO.cjs.map +1 -1
  16. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  17. package/dist/{chunk-L3I4TIRP.js → chunk-HMUEU7D7.js} +2 -2
  18. package/dist/chunk-HMUEU7D7.js.map +1 -0
  19. package/dist/{chunk-5CJGKKMZ.js → chunk-MEPHGCPQ.js} +1 -1
  20. package/dist/chunk-MEPHGCPQ.js.map +1 -0
  21. package/dist/chunk-MOL7MDBG.js +0 -0
  22. package/dist/{chunk-HOGJ5ALY.js → chunk-OQPILS7B.js} +142 -3
  23. package/dist/chunk-OQPILS7B.js.map +1 -0
  24. package/dist/{chunk-KA4FEBS2.js → chunk-RROH5WHO.js} +2 -2
  25. package/dist/chunk-RROH5WHO.js.map +1 -0
  26. package/dist/{chunk-UVSOSFER.js → chunk-UEIYETCQ.js} +142 -3
  27. package/dist/chunk-UEIYETCQ.js.map +1 -0
  28. package/dist/cli.js +15 -15
  29. package/dist/cli.js.map +1 -1
  30. package/dist/{detect-PJZMUL2Z.js → detect-RI2MQ33K.js} +2 -2
  31. package/dist/formula-5NKVS2LR.cjs.map +1 -1
  32. package/dist/formula-JCNF43NE.js +0 -0
  33. package/dist/index.cjs +1248 -1255
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +1 -1
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.js +925 -932
  38. package/dist/index.js.map +1 -1
  39. package/dist/mcp.js +13 -13
  40. package/dist/mcp.js.map +1 -1
  41. package/dist/page-range-737B4EZW.js +0 -0
  42. package/dist/page-range-P7SDW6LR.cjs.map +1 -1
  43. package/dist/{parser-VEY4B5CJ.cjs → parser-ITMU2WN5.cjs} +231 -37
  44. package/dist/parser-ITMU2WN5.cjs.map +1 -0
  45. package/dist/{parser-DMKHIV4E.js → parser-KMMUS73Q.js} +200 -6
  46. package/dist/parser-KMMUS73Q.js.map +1 -0
  47. package/dist/{parser-C636QIOB.js → parser-TCTCSBYZ.js} +202 -8
  48. package/dist/parser-TCTCSBYZ.js.map +1 -0
  49. package/dist/{profile-io-JYGCC6XQ.js → profile-io-SLN4P76T.js} +3 -3
  50. package/dist/{provider-H4WWSPOV.js → provider-4ZJKV3DC.js} +1 -1
  51. package/dist/provider-4ZJKV3DC.js.map +1 -0
  52. package/dist/{provider-7H4CPZYS.js → provider-AKROB7WQ.js} +1 -1
  53. package/dist/provider-AKROB7WQ.js.map +1 -0
  54. package/dist/{provider-5K7O3Z2O.cjs → provider-G4C2V2PD.cjs} +1 -1
  55. package/dist/provider-G4C2V2PD.cjs.map +1 -0
  56. package/dist/render-25BT623I.js +10 -0
  57. package/dist/seal-R4TETA4C.js +10 -0
  58. package/dist/setup-57FB3LSP.js +0 -0
  59. package/dist/{watch-ZQUFJBFR.js → watch-OHQWSVPE.js} +8 -8
  60. package/dist/watch-OHQWSVPE.js.map +1 -0
  61. package/package.json +97 -97
  62. package/dist/chunk-4C7SBZNW.js.map +0 -1
  63. package/dist/chunk-5CJGKKMZ.js.map +0 -1
  64. package/dist/chunk-5SOZXPQY.js.map +0 -1
  65. package/dist/chunk-63ASYC4N.js.map +0 -1
  66. package/dist/chunk-6GBLFQMA.js.map +0 -1
  67. package/dist/chunk-DQJTNXVS.cjs.map +0 -1
  68. package/dist/chunk-HC2SEH6I.js.map +0 -1
  69. package/dist/chunk-HOGJ5ALY.js.map +0 -1
  70. package/dist/chunk-KA4FEBS2.js.map +0 -1
  71. package/dist/chunk-L3I4TIRP.js.map +0 -1
  72. package/dist/chunk-UVSOSFER.js.map +0 -1
  73. package/dist/parser-C636QIOB.js.map +0 -1
  74. package/dist/parser-DMKHIV4E.js.map +0 -1
  75. package/dist/parser-VEY4B5CJ.cjs.map +0 -1
  76. package/dist/provider-5K7O3Z2O.cjs.map +0 -1
  77. package/dist/provider-7H4CPZYS.js.map +0 -1
  78. package/dist/provider-H4WWSPOV.js.map +0 -1
  79. package/dist/render-ISOEOMTM.js +0 -10
  80. package/dist/seal-676ZIAZZ.js +0 -10
  81. package/dist/watch-ZQUFJBFR.js.map +0 -1
  82. /package/dist/{-NDU7YGSS.js.map → -LE4RLXVA.js.map} +0 -0
  83. /package/dist/{detect-PJZMUL2Z.js.map → detect-RI2MQ33K.js.map} +0 -0
  84. /package/dist/{profile-io-JYGCC6XQ.js.map → profile-io-SLN4P76T.js.map} +0 -0
  85. /package/dist/{render-ISOEOMTM.js.map → render-25BT623I.js.map} +0 -0
  86. /package/dist/{seal-676ZIAZZ.js.map → seal-R4TETA4C.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -20,7 +20,8 @@
20
20
 
21
21
 
22
22
 
23
- var _chunkDQJTNXVScjs = require('./chunk-DQJTNXVS.cjs');
23
+
24
+ var _chunk6XAAYAWLcjs = require('./chunk-6XAAYAWL.cjs');
24
25
 
25
26
 
26
27
  var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
@@ -406,7 +407,7 @@ function createSectionShared() {
406
407
  function createXmlParser(warnings) {
407
408
  return new (0, _xmldom.DOMParser)({
408
409
  onError(level, msg2) {
409
- if (level === "fatalError") throw new (0, _chunkDQJTNXVScjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
410
+ if (level === "fatalError") throw new (0, _chunk6XAAYAWLcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
410
411
  _optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
411
412
  }
412
413
  });
@@ -462,10 +463,10 @@ async function extractHwpxStyles(zip, decompressed) {
462
463
  const xml = await file.async("text");
463
464
  if (decompressed) {
464
465
  decompressed.total += xml.length * 2;
465
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
466
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
466
467
  }
467
468
  const parser = createXmlParser();
468
- const doc = parser.parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, xml), "text/xml");
469
+ const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
469
470
  if (!doc.documentElement) continue;
470
471
  const domDoc = doc;
471
472
  parseCharProperties(domDoc, result.charProperties);
@@ -648,9 +649,9 @@ function detectHwpxHeadings(blocks, styleMap) {
648
649
  let level = 0;
649
650
  if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
650
651
  const ratio = block.style.fontSize / baseFontSize;
651
- if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H1) level = 1;
652
- else if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H2) level = 2;
653
- else if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H3) level = 3;
652
+ if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H1) level = 1;
653
+ else if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H2) level = 2;
654
+ else if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H3) level = 3;
654
655
  }
655
656
  const compactText = text.replace(/\s+/g, "");
656
657
  if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
@@ -1575,7 +1576,7 @@ function needsGaejosikAssets(gongmun) {
1575
1576
  }
1576
1577
  function assertFiniteRange(name, value, min, max) {
1577
1578
  if (!Number.isFinite(value) || value < min || value > max) {
1578
- throw new (0, _chunkDQJTNXVScjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
1579
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
1579
1580
  }
1580
1581
  }
1581
1582
  function validateGongmunOptions(opts) {
@@ -1590,10 +1591,10 @@ function validateGongmunOptions(opts) {
1590
1591
  assertFiniteRange(`margins.${side}`, value, 0, 200);
1591
1592
  }
1592
1593
  if (opts.margins.left + opts.margins.right >= 210) {
1593
- throw new (0, _chunkDQJTNXVScjs.KordocError)("margins.left + margins.right must be less than 210");
1594
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("margins.left + margins.right must be less than 210");
1594
1595
  }
1595
1596
  if (opts.margins.top + opts.margins.bottom >= 297) {
1596
- throw new (0, _chunkDQJTNXVScjs.KordocError)("margins.top + margins.bottom must be less than 297");
1597
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("margins.top + margins.bottom must be less than 297");
1597
1598
  }
1598
1599
  }
1599
1600
  if (opts.sizes) {
@@ -1602,7 +1603,7 @@ function validateGongmunOptions(opts) {
1602
1603
  }
1603
1604
  }
1604
1605
  if (opts.approval && opts.approval.length > 6) {
1605
- throw new (0, _chunkDQJTNXVScjs.KordocError)("approval must contain at most 6 labels");
1606
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("approval must contain at most 6 labels");
1606
1607
  }
1607
1608
  }
1608
1609
  function incompatibleGongmunWarnings(opts) {
@@ -1866,7 +1867,7 @@ function resolveParaHeading(paraEl, ctx) {
1866
1867
 
1867
1868
  // src/hwpx/table-build.ts
1868
1869
  function buildTableWithCellMeta(state) {
1869
- const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, state.rows);
1870
+ const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, state.rows);
1870
1871
  if (state.caption) table2.caption = state.caption;
1871
1872
  const anchors = [];
1872
1873
  {
@@ -1936,7 +1937,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1936
1937
  const cell2 = parentTable.cell;
1937
1938
  (cell2.blocks ??= []).push(block);
1938
1939
  cell2.hasStructure = true;
1939
- let flat = _chunkDQJTNXVScjs.convertTableToText.call(void 0, newTable.rows);
1940
+ let flat = _chunk6XAAYAWLcjs.convertTableToText.call(void 0, newTable.rows);
1940
1941
  if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
1941
1942
  if (flat) cell2.text += (cell2.text ? "\n" : "") + flat;
1942
1943
  } else {
@@ -1948,7 +1949,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1948
1949
  // src/hwpx/section-walker.ts
1949
1950
  function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
1950
1951
  const parser = createXmlParser(warnings);
1951
- const doc = parser.parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, xml), "text/xml");
1952
+ const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
1952
1953
  if (!doc.documentElement) return [];
1953
1954
  const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
1954
1955
  ctx.shared.track.deleteDepth = 0;
@@ -2053,8 +2054,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2053
2054
  const cs = isNaN(rawCs) ? 1 : rawCs;
2054
2055
  const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
2055
2056
  const rs = isNaN(rawRs) ? 1 : rawRs;
2056
- tableCtx.cell.colSpan = clampSpan(cs, _chunkDQJTNXVScjs.MAX_COLS);
2057
- tableCtx.cell.rowSpan = clampSpan(rs, _chunkDQJTNXVScjs.MAX_ROWS);
2057
+ tableCtx.cell.colSpan = clampSpan(cs, _chunk6XAAYAWLcjs.MAX_COLS);
2058
+ tableCtx.cell.rowSpan = clampSpan(rs, _chunk6XAAYAWLcjs.MAX_ROWS);
2058
2059
  }
2059
2060
  break;
2060
2061
  case "p": {
@@ -2252,7 +2253,7 @@ function flattenSubListTable(el, ctx, depth) {
2252
2253
  const sink = [];
2253
2254
  const st = { rows: [], currentRow: [], cell: null };
2254
2255
  walkSection(el, sink, st, [], ctx, depth + 1);
2255
- let flat = _chunkDQJTNXVScjs.convertTableToText.call(void 0, st.rows);
2256
+ let flat = _chunk6XAAYAWLcjs.convertTableToText.call(void 0, st.rows);
2256
2257
  if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
2257
2258
  return flat;
2258
2259
  }
@@ -2385,7 +2386,7 @@ function extractHyperlinkHref(fieldBegin) {
2385
2386
  let url = (ch.textContent || "").trim();
2386
2387
  if (!url) continue;
2387
2388
  url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
2388
- const safe = _chunkDQJTNXVScjs.sanitizeHref.call(void 0, url);
2389
+ const safe = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, url);
2389
2390
  if (safe) return safe;
2390
2391
  }
2391
2392
  return void 0;
@@ -2523,7 +2524,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2523
2524
  case "hyperlink": {
2524
2525
  const url = child.getAttribute("url") || child.getAttribute("href") || "";
2525
2526
  if (url) {
2526
- const safe = _chunkDQJTNXVScjs.sanitizeHref.call(void 0, url);
2527
+ const safe = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, url);
2527
2528
  if (safe) href = safe;
2528
2529
  }
2529
2530
  walk(child);
@@ -2714,628 +2715,807 @@ function gongmunDepthFromIndent(para2, left, ctx) {
2714
2715
  return depth >= 1 && depth < 8 ? depth : null;
2715
2716
  }
2716
2717
 
2717
- // src/hwpx/images.ts
2718
- function imageExtToMime(ext) {
2719
- switch (ext.toLowerCase()) {
2720
- case "jpg":
2721
- case "jpeg":
2722
- return "image/jpeg";
2723
- case "png":
2724
- return "image/png";
2725
- case "gif":
2726
- return "image/gif";
2727
- case "bmp":
2728
- return "image/bmp";
2729
- case "tif":
2730
- case "tiff":
2731
- return "image/tiff";
2732
- case "wmf":
2733
- return "image/wmf";
2734
- case "emf":
2735
- return "image/emf";
2736
- case "svg":
2737
- return "image/svg+xml";
2738
- default:
2739
- return "application/octet-stream";
2718
+ // src/hwp5/record.ts
2719
+ var _zlib = require('zlib');
2720
+ var TAG_PARA_HEADER = 66;
2721
+ var TAG_PARA_TEXT = 67;
2722
+ var TAG_CHAR_SHAPE = 68;
2723
+ var TAG_CTRL_HEADER = 71;
2724
+ var TAG_LIST_HEADER = 72;
2725
+ var TAG_TABLE = 77;
2726
+ var TAG_SHAPE_COMPONENT = 76;
2727
+ var TAG_SHAPE_COMPONENT_PICTURE = 85;
2728
+ var TAG_SHAPE_COMPONENT_CONTAINER = 86;
2729
+ var TAG_EQEDIT = 88;
2730
+ var TAG_BIN_DATA = 18;
2731
+ var TAG_DOC_CHAR_SHAPE = 21;
2732
+ var TAG_NUMBERING = 23;
2733
+ var TAG_BULLET = 24;
2734
+ var TAG_DOC_PARA_SHAPE = 25;
2735
+ var TAG_DOC_STYLE = 26;
2736
+ var CHAR_LINE = 0;
2737
+ var CHAR_SECTION_BREAK = 10;
2738
+ var CHAR_PARA = 13;
2739
+ var CHAR_TAB = 9;
2740
+ var CHAR_HYPHEN = 30;
2741
+ var CHAR_NBSP = 31;
2742
+ var CHAR_FIXED_NBSP = 24;
2743
+ var CHAR_FIXED_WIDTH = 25;
2744
+ var FLAG_COMPRESSED = 1 << 0;
2745
+ var FLAG_ENCRYPTED = 1 << 1;
2746
+ var FLAG_DISTRIBUTION = 1 << 2;
2747
+ var FLAG_DRM = 1 << 4;
2748
+ var MAX_RECORDS = 5e5;
2749
+ function readRecords(data) {
2750
+ const records = [];
2751
+ let offset = 0;
2752
+ while (offset + 4 <= data.length && records.length < MAX_RECORDS) {
2753
+ const header = data.readUInt32LE(offset);
2754
+ offset += 4;
2755
+ const tagId = header & 1023;
2756
+ const level = header >> 10 & 1023;
2757
+ let size = header >> 20 & 4095;
2758
+ if (size === 4095) {
2759
+ if (offset + 4 > data.length) break;
2760
+ size = data.readUInt32LE(offset);
2761
+ offset += 4;
2762
+ }
2763
+ if (offset + size > data.length) break;
2764
+ records.push({ tagId, level, size, data: data.subarray(offset, offset + size) });
2765
+ offset += size;
2740
2766
  }
2767
+ return records;
2741
2768
  }
2742
- function mimeToExt(mime) {
2743
- if (mime.includes("jpeg")) return "jpg";
2744
- if (mime.includes("png")) return "png";
2745
- if (mime.includes("gif")) return "gif";
2746
- if (mime.includes("bmp")) return "bmp";
2747
- if (mime.includes("tiff")) return "tif";
2748
- if (mime.includes("wmf")) return "wmf";
2749
- if (mime.includes("emf")) return "emf";
2750
- if (mime.includes("svg")) return "svg";
2751
- return "bin";
2752
- }
2753
- function collectImageBlocks(blocks, out, ownerCell, depth = 0) {
2754
- if (depth > MAX_XML_DEPTH) return;
2755
- for (const block of blocks) {
2756
- if (block.type === "image") {
2757
- out.push({ block, ownerCell });
2758
- } else if (block.type === "table" && block.table) {
2759
- for (const row of block.table.cells) {
2760
- for (const cell2 of row) {
2761
- if (_optionalChain([cell2, 'access', _65 => _65.blocks, 'optionalAccess', _66 => _66.length])) collectImageBlocks(cell2.blocks, out, cell2, depth + 1);
2762
- }
2763
- }
2769
+ var MAX_DECOMPRESS_SIZE2 = 100 * 1024 * 1024;
2770
+ function decompressStream(data) {
2771
+ const opts = { maxOutputLength: MAX_DECOMPRESS_SIZE2 };
2772
+ if (data.length >= 2 && data[0] === 120) {
2773
+ try {
2774
+ return _zlib.inflateSync.call(void 0, data, opts);
2775
+ } catch (e13) {
2764
2776
  }
2765
2777
  }
2778
+ return _zlib.inflateRawSync.call(void 0, data, opts);
2766
2779
  }
2767
- async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
2768
- const images = [];
2769
- let imageIndex = 0;
2770
- const imageBlocks = [];
2771
- collectImageBlocks(blocks, imageBlocks);
2772
- const resolved = /* @__PURE__ */ new Map();
2773
- for (const { block, ownerCell } of imageBlocks) {
2774
- if (block.type !== "image" || !block.text) continue;
2775
- const ref = block.text;
2776
- let img = resolved.get(ref);
2777
- if (img === void 0) {
2778
- img = null;
2779
- const candidates = [
2780
- `BinData/${ref}`,
2781
- `Contents/BinData/${ref}`,
2782
- ref
2783
- // 절대 경로일 수도 있음
2784
- ];
2785
- let resolvedPath = null;
2786
- if (!ref.includes(".")) {
2787
- const prefixes = [`BinData/${ref}`, `Contents/BinData/${ref}`];
2788
- for (const prefix of prefixes) {
2789
- const match = zip.file(new RegExp(`^${prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\.[a-zA-Z0-9]+$`));
2790
- if (match.length > 0) {
2791
- resolvedPath = match[0].name;
2792
- break;
2793
- }
2780
+ function parseFileHeader(data) {
2781
+ if (data.length < 40) throw new (0, _chunk6XAAYAWLcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2782
+ const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
2783
+ return {
2784
+ signature: sig,
2785
+ versionMajor: data[35],
2786
+ flags: data.readUInt32LE(36)
2787
+ };
2788
+ }
2789
+ function readHwpString(data, offset) {
2790
+ if (offset + 2 > data.length) return { value: "", next: data.length };
2791
+ const len = data.readUInt16LE(offset);
2792
+ const start = offset + 2;
2793
+ const end = start + len * 2;
2794
+ if (len === 0 || end > data.length) return { value: "", next: start };
2795
+ return { value: data.subarray(start, end).toString("utf16le"), next: end };
2796
+ }
2797
+ function parseDocInfo(records) {
2798
+ const charShapes = [];
2799
+ const paraShapes = [];
2800
+ const styles = [];
2801
+ const binData = [];
2802
+ const numberings = [];
2803
+ const bullets = [];
2804
+ for (const rec of records) {
2805
+ if (rec.tagId === TAG_DOC_PARA_SHAPE && rec.data.length >= 4) {
2806
+ const attr1 = rec.data.readUInt32LE(0);
2807
+ const headType = attr1 >>> 23 & 3;
2808
+ const paraLevel = attr1 >>> 25 & 7;
2809
+ const numberingId = rec.data.length >= 32 ? rec.data.readUInt16LE(30) : 0;
2810
+ paraShapes.push({ headType, paraLevel, numberingId });
2811
+ }
2812
+ if (rec.tagId === TAG_BIN_DATA && rec.data.length >= 2) {
2813
+ const attr = rec.data.readUInt16LE(0);
2814
+ const typeBits = attr & 15;
2815
+ if (typeBits === 0) {
2816
+ binData.push({ kind: "link", storageId: 0, extension: "" });
2817
+ } else {
2818
+ const storageId = rec.data.length >= 4 ? rec.data.readUInt16LE(2) : 0;
2819
+ const { value: extension } = readHwpString(rec.data, 4);
2820
+ binData.push({ kind: typeBits === 2 ? "storage" : "embed", storageId, extension });
2821
+ }
2822
+ }
2823
+ if (rec.tagId === TAG_NUMBERING && rec.data.length >= 14) {
2824
+ const levelFormats = [];
2825
+ const numberFormats = [];
2826
+ const startNumbers = [1, 1, 1, 1, 1, 1, 1];
2827
+ let offset = 0;
2828
+ for (let level = 0; level < 7; level++) {
2829
+ if (offset + 12 > rec.data.length) {
2830
+ levelFormats.push("");
2831
+ numberFormats.push(0);
2832
+ continue;
2794
2833
  }
2834
+ const attr = rec.data.readUInt32LE(offset);
2835
+ numberFormats.push(attr >>> 5 & 15);
2836
+ offset += 12;
2837
+ const { value, next } = readHwpString(rec.data, offset);
2838
+ levelFormats.push(value);
2839
+ offset = next;
2795
2840
  }
2796
- const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
2797
- for (const path of allCandidates) {
2798
- if (_chunkDQJTNXVScjs.isPathTraversal.call(void 0, path)) continue;
2799
- const file = zip.file(path);
2800
- if (!file) continue;
2801
- try {
2802
- const data = await file.async("uint8array");
2803
- decompressed.total += data.length;
2804
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2805
- const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
2806
- const mimeType = imageExtToMime(ext);
2807
- imageIndex++;
2808
- const filename = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
2809
- img = { filename, data, mimeType };
2810
- images.push(img);
2811
- break;
2812
- } catch (err) {
2813
- if (err instanceof _chunkDQJTNXVScjs.KordocError) throw err;
2841
+ let baseStart = 1;
2842
+ if (offset + 2 <= rec.data.length) {
2843
+ baseStart = rec.data.readUInt16LE(offset) || 1;
2844
+ offset += 2;
2845
+ }
2846
+ for (let level = 0; level < 7; level++) {
2847
+ if (offset + 4 <= rec.data.length) {
2848
+ startNumbers[level] = rec.data.readUInt32LE(offset) || 1;
2849
+ offset += 4;
2850
+ } else {
2851
+ startNumbers[level] = baseStart;
2814
2852
  }
2815
2853
  }
2816
- if (!img) _optionalChain([warnings, 'optionalAccess', _67 => _67.push, 'call', _68 => _68({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
2817
- resolved.set(ref, img);
2818
- }
2819
- if (!img) {
2820
- block.type = "paragraph";
2821
- block.text = `[\uC774\uBBF8\uC9C0: ${ref}]`;
2822
- if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, `[\uC774\uBBF8\uC9C0: ${ref}]`);
2823
- continue;
2854
+ numberings.push({ levelFormats, numberFormats, startNumbers });
2824
2855
  }
2825
- block.text = img.filename;
2826
- block.imageData = { data: img.data, mimeType: img.mimeType, filename: ref };
2827
- if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, `![image](${img.filename})`);
2828
- }
2829
- return images;
2830
- }
2831
-
2832
- // src/hwpx/metadata.ts
2833
-
2834
-
2835
- // src/hwpx/zip-sections.ts
2836
- var _zlib = require('zlib');
2837
- function extractFromBrokenZip(buffer) {
2838
- const data = new Uint8Array(buffer);
2839
- const view = new DataView(buffer);
2840
- let pos = 0;
2841
- const blocks = [];
2842
- const warnings = [
2843
- { code: "BROKEN_ZIP_RECOVERY", message: "\uC190\uC0C1\uB41C ZIP \uAD6C\uC870 \u2014 Local File Header \uAE30\uBC18 \uBCF5\uAD6C \uBAA8\uB4DC" }
2844
- ];
2845
- let totalDecompressed = 0;
2846
- let entryCount = 0;
2847
- let sectionNum = 0;
2848
- const shared = createSectionShared();
2849
- while (pos < data.length - 30) {
2850
- if (data[pos] !== 80 || data[pos + 1] !== 75 || data[pos + 2] !== 3 || data[pos + 3] !== 4) {
2851
- pos++;
2852
- while (pos < data.length - 30) {
2853
- if (data[pos] === 80 && data[pos + 1] === 75 && data[pos + 2] === 3 && data[pos + 3] === 4) break;
2854
- pos++;
2855
- }
2856
- continue;
2856
+ if (rec.tagId === TAG_BULLET && rec.data.length >= 14) {
2857
+ const code = rec.data.readUInt16LE(12);
2858
+ bullets.push({ char: code > 0 ? String.fromCharCode(code) : "\u2022" });
2857
2859
  }
2858
- if (++entryCount > MAX_ZIP_ENTRIES) break;
2859
- const method = view.getUint16(pos + 8, true);
2860
- const compSize = view.getUint32(pos + 18, true);
2861
- const nameLen = view.getUint16(pos + 26, true);
2862
- const extraLen = view.getUint16(pos + 28, true);
2863
- if (nameLen > 1024 || extraLen > 65535) {
2864
- pos += 30 + nameLen + extraLen;
2865
- continue;
2866
- }
2867
- const fileStart = pos + 30 + nameLen + extraLen;
2868
- if (fileStart + compSize > data.length) break;
2869
- if (compSize === 0 && method !== 0) {
2870
- pos = fileStart;
2871
- continue;
2872
- }
2873
- const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
2874
- const name = new TextDecoder().decode(nameBytes);
2875
- if (_chunkDQJTNXVScjs.isPathTraversal.call(void 0, name)) {
2876
- pos = fileStart + compSize;
2877
- continue;
2878
- }
2879
- const fileData = data.slice(fileStart, fileStart + compSize);
2880
- pos = fileStart + compSize;
2881
- if (!name.toLowerCase().includes("section") || !name.endsWith(".xml")) continue;
2882
- try {
2883
- let content;
2884
- if (method === 0) {
2885
- content = new TextDecoder().decode(fileData);
2886
- } else if (method === 8) {
2887
- const decompressed = _zlib.inflateRawSync.call(void 0, Buffer.from(fileData), { maxOutputLength: MAX_DECOMPRESS_SIZE });
2888
- content = new TextDecoder().decode(decompressed);
2860
+ if (rec.tagId === TAG_DOC_CHAR_SHAPE && rec.data.length >= 18) {
2861
+ if (rec.data.length >= 50) {
2862
+ const fontSize = rec.data.readUInt32LE(42);
2863
+ const attrFlags = rec.data.readUInt32LE(46);
2864
+ charShapes.push({ fontSize, attrFlags });
2889
2865
  } else {
2890
- continue;
2866
+ charShapes.push({ fontSize: 0, attrFlags: 0 });
2867
+ }
2868
+ }
2869
+ if (rec.tagId === TAG_DOC_STYLE && rec.data.length >= 8) {
2870
+ try {
2871
+ let offset = 0;
2872
+ const nameLen = rec.data.readUInt16LE(offset);
2873
+ offset += 2;
2874
+ const nameBytes = nameLen * 2;
2875
+ const name = nameBytes > 0 && offset + nameBytes <= rec.data.length ? rec.data.subarray(offset, offset + nameBytes).toString("utf16le") : "";
2876
+ offset += nameBytes;
2877
+ let nameKo = "";
2878
+ if (offset + 2 <= rec.data.length) {
2879
+ const nameKoLen = rec.data.readUInt16LE(offset);
2880
+ offset += 2;
2881
+ const nameKoBytes = nameKoLen * 2;
2882
+ if (nameKoBytes > 0 && offset + nameKoBytes <= rec.data.length) {
2883
+ nameKo = rec.data.subarray(offset, offset + nameKoBytes).toString("utf16le");
2884
+ }
2885
+ offset += nameKoBytes;
2886
+ }
2887
+ const type = offset < rec.data.length ? rec.data.readUInt8(offset) : 0;
2888
+ offset += 1;
2889
+ offset += 1;
2890
+ offset += 2;
2891
+ const paraShapeId = offset + 2 <= rec.data.length ? rec.data.readUInt16LE(offset) : 0;
2892
+ offset += 2;
2893
+ const charShapeId = offset + 2 <= rec.data.length ? rec.data.readUInt16LE(offset) : 0;
2894
+ styles.push({ name, nameKo, charShapeId, paraShapeId, type });
2895
+ } catch (e14) {
2891
2896
  }
2892
- totalDecompressed += content.length * 2;
2893
- if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
2894
- sectionNum++;
2895
- blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
2896
- } catch (e13) {
2897
- continue;
2898
2897
  }
2899
2898
  }
2900
- if (blocks.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2901
- applyPageText(blocks, shared);
2902
- const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
2903
- return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
2899
+ return { charShapes, paraShapes, styles, binData, numberings, bullets };
2904
2900
  }
2905
- async function readKordocLayout(zip) {
2906
- const file = _nullishCoalesce(zip.file("Contents/content.hpf"), () => ( zip.file("content.hpf")));
2907
- if (!file) return null;
2908
- try {
2909
- const xml = await file.async("text");
2910
- if (!/<opf:meta\b[^>]*name="generator"[^>]*content="kordoc"/.test(xml)) return null;
2911
- return _nullishCoalesce(_optionalChain([xml, 'access', _69 => _69.match, 'call', _70 => _70(/<opf:meta\b[^>]*name="kordoc-layout"[^>]*content="([^"]*)"/), 'optionalAccess', _71 => _71[1]]), () => ( null));
2912
- } catch (e14) {
2913
- return null;
2914
- }
2901
+ function createParaTextState() {
2902
+ return { text: "", ctrlIdx: 0, fieldStack: [], fieldRanges: [] };
2915
2903
  }
2916
- async function resolveSectionPaths(zip) {
2917
- const manifestPaths = ["Contents/content.hpf", "content.hpf"];
2918
- for (const mp of manifestPaths) {
2919
- const mpLower = mp.toLowerCase();
2920
- const file = zip.file(mp) || Object.values(zip.files).find((f) => f.name.toLowerCase() === mpLower) || null;
2921
- if (!file) continue;
2922
- const xml = await file.async("text");
2923
- const paths = parseSectionPathsFromManifest(xml);
2924
- if (paths.length > 0) return paths;
2925
- }
2926
- const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
2927
- return sectionFiles.map((f) => f.name).sort(_chunkDQJTNXVScjs.compareSectionPaths);
2904
+ function isExtendedOnlyCtrlChar(ch) {
2905
+ return ch >= 1 && ch <= 3 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 18 || ch >= 21 && ch <= 23;
2928
2906
  }
2929
- function parseSectionPathsFromManifest(xml) {
2930
- const parser = createXmlParser();
2931
- const doc = parser.parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, xml), "text/xml");
2932
- const items = doc.getElementsByTagName("opf:item");
2933
- const spine = doc.getElementsByTagName("opf:itemref");
2934
- const idToHref = /* @__PURE__ */ new Map();
2935
- for (let i = 0; i < items.length; i++) {
2936
- const item = items[i];
2937
- const id = item.getAttribute("id") || "";
2938
- const href = _chunkDQJTNXVScjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
2939
- if (id && href) idToHref.set(id, href);
2940
- }
2941
- if (spine.length > 0) {
2942
- const ordered = [];
2943
- for (let i = 0; i < spine.length; i++) {
2944
- const href = idToHref.get(spine[i].getAttribute("idref") || "");
2945
- if (href) ordered.push(href);
2907
+ function appendParaText(state, data, resolveControl) {
2908
+ let result = "";
2909
+ let i = 0;
2910
+ const base = state.text.length;
2911
+ const resolveAt = (byteOffset, extended) => {
2912
+ const ctrlId = data.readUInt32LE(byteOffset);
2913
+ const idx = extended ? state.ctrlIdx : -1;
2914
+ const replacement = _optionalChain([resolveControl, 'optionalCall', _65 => _65(idx, ctrlId)]);
2915
+ if (replacement) result += replacement;
2916
+ if (extended) state.ctrlIdx++;
2917
+ };
2918
+ while (i + 1 < data.length) {
2919
+ const ch = data.readUInt16LE(i);
2920
+ i += 2;
2921
+ switch (ch) {
2922
+ // ── char 타입 (2바이트만, 확장 데이터 없음) ──
2923
+ case CHAR_LINE:
2924
+ result += "\n";
2925
+ break;
2926
+ case CHAR_SECTION_BREAK: {
2927
+ if (i + 16 <= data.length && data.readUInt16LE(i) === 11) {
2928
+ resolveAt(i + 2, true);
2929
+ i += 16;
2930
+ break;
2931
+ }
2932
+ result += "\n";
2933
+ break;
2934
+ }
2935
+ case CHAR_PARA:
2936
+ break;
2937
+ // 문단 끝
2938
+ case CHAR_HYPHEN:
2939
+ result += "-";
2940
+ break;
2941
+ case CHAR_NBSP:
2942
+ result += " ";
2943
+ break;
2944
+ case CHAR_FIXED_NBSP:
2945
+ result += "\xA0";
2946
+ break;
2947
+ // 진짜 NBSP
2948
+ case CHAR_FIXED_WIDTH:
2949
+ result += " ";
2950
+ break;
2951
+ // 고정폭 공백
2952
+ // ── inline 타입 (2바이트 + 14바이트 확장) ──
2953
+ case CHAR_TAB:
2954
+ result += " ";
2955
+ if (i + 14 <= data.length) i += 14;
2956
+ break;
2957
+ default:
2958
+ if (ch >= 1 && ch <= 31) {
2959
+ const isExtended = isExtendedOnlyCtrlChar(ch);
2960
+ const isInline = ch >= 4 && ch <= 9 || ch >= 19 && ch <= 20;
2961
+ if ((isExtended || isInline) && i + 14 <= data.length) {
2962
+ if (ch === 3) {
2963
+ state.fieldStack.push({ start: base + result.length, ctrlIdx: state.ctrlIdx });
2964
+ } else if (ch === 4) {
2965
+ const open = state.fieldStack.pop();
2966
+ if (open) {
2967
+ state.fieldRanges.push({ start: open.start, end: base + result.length, ctrlIdx: open.ctrlIdx });
2968
+ }
2969
+ }
2970
+ resolveAt(i, isExtended);
2971
+ i += 14;
2972
+ }
2973
+ } else if (ch >= 32) {
2974
+ if (ch >= 55296 && ch <= 56319 && i + 1 < data.length) {
2975
+ const lo = data.readUInt16LE(i);
2976
+ if (lo >= 56320 && lo <= 57343) {
2977
+ i += 2;
2978
+ const codePoint = (ch - 55296 << 10) + (lo - 56320) + 65536;
2979
+ result += String.fromCodePoint(codePoint);
2980
+ break;
2981
+ }
2982
+ }
2983
+ result += String.fromCharCode(ch);
2984
+ }
2985
+ break;
2946
2986
  }
2947
- if (ordered.length > 0) return ordered;
2948
2987
  }
2949
- return Array.from(idToHref.values()).sort(_chunkDQJTNXVScjs.compareSectionPaths);
2988
+ state.text += result;
2989
+ }
2990
+ function extractEquationText(data) {
2991
+ if (data.length < 6) return null;
2992
+ const scriptLength = data.readUInt16LE(4);
2993
+ const scriptStart = 6;
2994
+ const scriptEnd = scriptStart + scriptLength * 2;
2995
+ if (scriptLength <= 0 || scriptEnd > data.length) return null;
2996
+ const equation = data.subarray(scriptStart, scriptEnd).toString("utf16le").replace(/\0+/g, "").trim();
2997
+ return equation || null;
2950
2998
  }
2951
2999
 
2952
- // src/hwpx/metadata.ts
2953
- async function extractHwpxMetadata(zip, metadata, decompressed) {
3000
+ // src/hwp5/images.ts
3001
+ function detectImageMime(data) {
3002
+ if (data.length < 4) return null;
3003
+ if (data[0] === 137 && data[1] === 80 && data[2] === 78 && data[3] === 71) return "image/png";
3004
+ if (data[0] === 255 && data[1] === 216 && data[2] === 255) return "image/jpeg";
3005
+ if (data[0] === 71 && data[1] === 73 && data[2] === 70) return "image/gif";
3006
+ if (data[0] === 66 && data[1] === 77) return "image/bmp";
3007
+ if (data[0] === 215 && data[1] === 205 && data[2] === 198 && data[3] === 154) return "image/wmf";
3008
+ if (data[0] === 1 && data[1] === 0 && data[2] === 0 && data[3] === 0) return "image/emf";
3009
+ return null;
3010
+ }
3011
+ function normalizeBinPayload(data) {
3012
+ if (detectImageMime(data)) return data;
2954
3013
  try {
2955
- const metaPaths = ["meta.xml", "META-INF/meta.xml", "docProps/core.xml"];
2956
- for (const mp of metaPaths) {
2957
- const file = zip.file(mp) || Object.values(zip.files).find((f) => f.name.toLowerCase() === mp.toLowerCase()) || null;
2958
- if (!file) continue;
2959
- const xml = await file.async("text");
2960
- if (decompressed) {
2961
- decompressed.total += xml.length * 2;
2962
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2963
- }
2964
- parseDublinCoreMetadata(xml, metadata);
2965
- if (metadata.title || metadata.author) return;
2966
- }
3014
+ const inflated = decompressStream(data);
3015
+ if (inflated.length > 0) return inflated;
2967
3016
  } catch (e15) {
2968
3017
  }
3018
+ return data;
2969
3019
  }
2970
- function parseDublinCoreMetadata(xml, metadata) {
2971
- const parser = createXmlParser();
2972
- const doc = parser.parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, xml), "text/xml");
2973
- if (!doc.documentElement) return;
2974
- const getText = (tagNames) => {
2975
- for (const tag of tagNames) {
2976
- const els = doc.getElementsByTagName(tag);
2977
- if (els.length > 0) {
2978
- const text = _optionalChain([els, 'access', _72 => _72[0], 'access', _73 => _73.textContent, 'optionalAccess', _74 => _74.trim, 'call', _75 => _75()]);
2979
- if (text) return text;
3020
+ var BIN_ENTRY_RE = /(?:^|\/)BIN([0-9A-Fa-f]{4,8})(?:\.[^./\\]*)?$/;
3021
+ function collectImageBlocks(blocks, out) {
3022
+ for (const b of blocks) {
3023
+ if (b.type === "image") out.push(b);
3024
+ if (b.table) {
3025
+ for (const row of b.table.cells) {
3026
+ for (const cell2 of row) {
3027
+ if (cell2.blocks) collectImageBlocks(cell2.blocks, out);
3028
+ }
2980
3029
  }
2981
3030
  }
2982
- return void 0;
2983
- };
2984
- metadata.title = metadata.title || getText(["dc:title", "title"]);
2985
- metadata.author = metadata.author || getText(["dc:creator", "creator", "cp:lastModifiedBy"]);
2986
- metadata.description = metadata.description || getText(["dc:description", "description", "dc:subject", "subject"]);
2987
- metadata.createdAt = metadata.createdAt || getText(["dcterms:created", "meta:creation-date"]);
2988
- metadata.modifiedAt = metadata.modifiedAt || getText(["dcterms:modified", "meta:date"]);
2989
- const keywords = getText(["dc:keyword", "cp:keywords", "meta:keyword"]);
2990
- if (keywords && !metadata.keywords) {
2991
- metadata.keywords = keywords.split(/[,;]/).map((k) => k.trim()).filter(Boolean);
3031
+ if (b.children) collectImageBlocks(b.children, out);
2992
3032
  }
2993
3033
  }
2994
-
2995
- // src/hwpx/parser.ts
2996
- async function parseHwpxDocument(buffer, options) {
2997
- _chunkDQJTNXVScjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
2998
- let zip;
2999
- try {
3000
- zip = await _jszip2.default.loadAsync(buffer);
3001
- } catch (e16) {
3002
- return extractFromBrokenZip(buffer);
3003
- }
3004
- const actualEntryCount = Object.keys(zip.files).length;
3005
- if (actualEntryCount > MAX_ZIP_ENTRIES) {
3006
- throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3034
+ function forEachTableCell(blocks, fn) {
3035
+ for (const b of blocks) {
3036
+ if (b.table) {
3037
+ for (const row of b.table.cells) {
3038
+ for (const cell2 of row) {
3039
+ fn(cell2);
3040
+ if (cell2.blocks) forEachTableCell(cell2.blocks, fn);
3041
+ }
3042
+ }
3043
+ }
3044
+ if (b.children) forEachTableCell(b.children, fn);
3007
3045
  }
3008
- const manifestFile = zip.file("META-INF/manifest.xml");
3009
- if (manifestFile) {
3010
- const manifestXml = await manifestFile.async("text");
3011
- if (isEncryptedHwpx(manifestXml)) {
3012
- if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _76 => _76.filePath])) {
3013
- const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
3014
- if (pages.some((p) => p && p.trim().length > 0)) {
3015
- return comResultToParseResult(pages, pageCount, warnings2);
3046
+ }
3047
+ var CELL_IMAGE_SENTINEL_RE = /!\[image\]\(hwp5bin:(\d+)\)/g;
3048
+ function resolveCellImageSentinels(blocks, renamed) {
3049
+ forEachTableCell(blocks, (cell2) => {
3050
+ if (!cell2.text.includes("hwp5bin:")) return;
3051
+ cell2.text = cell2.text.replace(CELL_IMAGE_SENTINEL_RE, (_m, idStr) => {
3052
+ const filename = renamed.get(Number(idStr));
3053
+ return filename ? `![image](${filename})` : "[\uC774\uBBF8\uC9C0]";
3054
+ });
3055
+ });
3056
+ }
3057
+ function resolveImageBlocks(binDataMap, blocks, warnings, sweepUnreferenced) {
3058
+ const imageBlocks = [];
3059
+ collectImageBlocks(blocks, imageBlocks);
3060
+ const images = [];
3061
+ const renamed = /* @__PURE__ */ new Map();
3062
+ const resolved = /* @__PURE__ */ new Map();
3063
+ let imageIndex = 0;
3064
+ for (const block of imageBlocks) {
3065
+ if (!block.text) continue;
3066
+ const storageId = parseInt(block.text, 10);
3067
+ if (isNaN(storageId)) continue;
3068
+ let img = resolved.get(storageId);
3069
+ if (img === void 0) {
3070
+ const bin = binDataMap.get(storageId);
3071
+ if (!bin) {
3072
+ warnings.push({ page: block.pageNumber, message: `BinData ${storageId} \uC5C6\uC74C`, code: "SKIPPED_IMAGE" });
3073
+ resolved.set(storageId, null);
3074
+ } else {
3075
+ const mime = detectImageMime(bin.data);
3076
+ if (!mime) {
3077
+ warnings.push({ page: block.pageNumber, message: `BinData ${storageId}: \uC54C \uC218 \uC5C6\uB294 \uC774\uBBF8\uC9C0 \uD615\uC2DD`, code: "SKIPPED_IMAGE" });
3078
+ resolved.set(storageId, null);
3079
+ } else {
3080
+ imageIndex++;
3081
+ const ext = mime.includes("jpeg") ? "jpg" : mime.includes("png") ? "png" : mime.includes("gif") ? "gif" : mime.includes("bmp") ? "bmp" : "bin";
3082
+ img = { filename: `image_${String(imageIndex).padStart(3, "0")}.${ext}`, data: new Uint8Array(bin.data), mime };
3083
+ resolved.set(storageId, img);
3084
+ images.push({ filename: img.filename, data: img.data, mimeType: img.mime });
3085
+ renamed.set(storageId, img.filename);
3016
3086
  }
3017
3087
  }
3018
- throw new (0, _chunkDQJTNXVScjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
3088
+ img = resolved.get(storageId);
3019
3089
  }
3090
+ if (!img) {
3091
+ const bin = binDataMap.get(storageId);
3092
+ block.type = "paragraph";
3093
+ block.text = bin ? `[\uC774\uBBF8\uC9C0: ${bin.name}]` : `[\uC774\uBBF8\uC9C0: BinData ${storageId}]`;
3094
+ continue;
3095
+ }
3096
+ block.text = img.filename;
3097
+ block.imageData = { data: img.data, mimeType: img.mime, filename: binDataMap.get(storageId).name };
3020
3098
  }
3021
- const decompressed = { total: 0 };
3022
- const metadata = {};
3023
- await extractHwpxMetadata(zip, metadata, decompressed);
3024
- const styleMap = await extractHwpxStyles(zip, decompressed);
3025
- const warnings = [];
3026
- const sectionPaths = await resolveSectionPaths(zip);
3027
- if (sectionPaths.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3028
- metadata.pageCount = sectionPaths.length;
3029
- const pageFilter = _optionalChain([options, 'optionalAccess', _77 => _77.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
3030
- const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
3031
- const blocks = [];
3032
- const shared = createSectionShared();
3033
- shared.kordocLayout = await readKordocLayout(zip);
3034
- let parsedSections = 0;
3035
- for (let si = 0; si < sectionPaths.length; si++) {
3036
- if (pageFilter && !pageFilter.has(si + 1)) continue;
3037
- const file = zip.file(sectionPaths[si]);
3038
- if (!file) continue;
3039
- try {
3040
- const xml = await file.async("text");
3041
- decompressed.total += xml.length * 2;
3042
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3043
- blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
3044
- parsedSections++;
3045
- _optionalChain([options, 'optionalAccess', _78 => _78.onProgress, 'optionalCall', _79 => _79(parsedSections, totalTarget)]);
3046
- } catch (secErr) {
3047
- if (secErr instanceof _chunkDQJTNXVScjs.KordocError) throw secErr;
3048
- warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
3099
+ if (sweepUnreferenced) {
3100
+ for (const [storageId, bin] of [...binDataMap.entries()].sort((a, b) => a[0] - b[0])) {
3101
+ if (resolved.has(storageId)) continue;
3102
+ const mime = detectImageMime(bin.data);
3103
+ if (!mime) continue;
3104
+ imageIndex++;
3105
+ const ext = mime.includes("jpeg") ? "jpg" : mime.includes("png") ? "png" : mime.includes("gif") ? "gif" : mime.includes("bmp") ? "bmp" : "bin";
3106
+ const filename = `image_${String(imageIndex).padStart(3, "0")}.${ext}`;
3107
+ const data = new Uint8Array(bin.data);
3108
+ images.push({ filename, data, mimeType: mime });
3109
+ blocks.push({ type: "image", text: filename, imageData: { data, mimeType: mime, filename: bin.name } });
3049
3110
  }
3050
3111
  }
3051
- applyPageText(blocks, shared);
3052
- const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
3053
- detectHwpxHeadings(blocks, styleMap);
3054
- const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
3055
- const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
3056
- return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
3112
+ resolveCellImageSentinels(blocks, renamed);
3113
+ return images;
3057
3114
  }
3058
-
3059
- // src/hwp5/record.ts
3060
-
3061
- var TAG_PARA_HEADER = 66;
3062
- var TAG_PARA_TEXT = 67;
3063
- var TAG_CHAR_SHAPE = 68;
3064
- var TAG_CTRL_HEADER = 71;
3065
- var TAG_LIST_HEADER = 72;
3066
- var TAG_TABLE = 77;
3067
- var TAG_SHAPE_COMPONENT = 76;
3068
- var TAG_SHAPE_COMPONENT_PICTURE = 85;
3069
- var TAG_SHAPE_COMPONENT_CONTAINER = 86;
3070
- var TAG_EQEDIT = 88;
3071
- var TAG_BIN_DATA = 18;
3072
- var TAG_DOC_CHAR_SHAPE = 21;
3073
- var TAG_NUMBERING = 23;
3074
- var TAG_BULLET = 24;
3075
- var TAG_DOC_PARA_SHAPE = 25;
3076
- var TAG_DOC_STYLE = 26;
3077
- var CHAR_LINE = 0;
3078
- var CHAR_SECTION_BREAK = 10;
3079
- var CHAR_PARA = 13;
3080
- var CHAR_TAB = 9;
3081
- var CHAR_HYPHEN = 30;
3082
- var CHAR_NBSP = 31;
3083
- var CHAR_FIXED_NBSP = 24;
3084
- var CHAR_FIXED_WIDTH = 25;
3085
- var FLAG_COMPRESSED = 1 << 0;
3086
- var FLAG_ENCRYPTED = 1 << 1;
3087
- var FLAG_DISTRIBUTION = 1 << 2;
3088
- var FLAG_DRM = 1 << 4;
3089
- var MAX_RECORDS = 5e5;
3090
- function readRecords(data) {
3091
- const records = [];
3092
- let offset = 0;
3093
- while (offset + 4 <= data.length && records.length < MAX_RECORDS) {
3094
- const header = data.readUInt32LE(offset);
3095
- offset += 4;
3096
- const tagId = header & 1023;
3097
- const level = header >> 10 & 1023;
3098
- let size = header >> 20 & 4095;
3099
- if (size === 4095) {
3100
- if (offset + 4 > data.length) break;
3101
- size = data.readUInt32LE(offset);
3102
- offset += 4;
3115
+ function extractHwp5Images(fileIndex, blocks, warnings, sweepUnreferenced) {
3116
+ const binDataMap = /* @__PURE__ */ new Map();
3117
+ if (fileIndex) {
3118
+ for (const entry of fileIndex) {
3119
+ if (!_optionalChain([entry, 'optionalAccess', _66 => _66.name]) || !entry.content) continue;
3120
+ const match = entry.name.match(BIN_ENTRY_RE);
3121
+ if (!match) continue;
3122
+ const idx = parseInt(match[1], 16);
3123
+ const data = normalizeBinPayload(Buffer.from(entry.content));
3124
+ binDataMap.set(idx, { data, name: entry.name });
3103
3125
  }
3104
- if (offset + size > data.length) break;
3105
- records.push({ tagId, level, size, data: data.subarray(offset, offset + size) });
3106
- offset += size;
3107
3126
  }
3108
- return records;
3127
+ if (binDataMap.size === 0) {
3128
+ resolveCellImageSentinels(blocks, /* @__PURE__ */ new Map());
3129
+ return [];
3130
+ }
3131
+ return resolveImageBlocks(binDataMap, blocks, warnings, sweepUnreferenced);
3109
3132
  }
3110
- var MAX_DECOMPRESS_SIZE2 = 100 * 1024 * 1024;
3111
- function decompressStream(data) {
3112
- const opts = { maxOutputLength: MAX_DECOMPRESS_SIZE2 };
3113
- if (data.length >= 2 && data[0] === 120) {
3114
- try {
3115
- return _zlib.inflateSync.call(void 0, data, opts);
3116
- } catch (e17) {
3117
- }
3133
+ function extractHwp5ImagesLenient(lcfb, blocks, warnings, sweepUnreferenced) {
3134
+ const binDataMap = /* @__PURE__ */ new Map();
3135
+ const binRe = /^BIN([0-9A-Fa-f]{4,8})(?:\.|$)/;
3136
+ for (const e of lcfb.entries()) {
3137
+ const match = e.name.match(binRe);
3138
+ if (!match) continue;
3139
+ const idx = parseInt(match[1], 16);
3140
+ const raw = lcfb.findStream(e.name);
3141
+ if (!raw) continue;
3142
+ binDataMap.set(idx, { data: normalizeBinPayload(raw), name: e.name });
3118
3143
  }
3119
- return _zlib.inflateRawSync.call(void 0, data, opts);
3144
+ if (binDataMap.size === 0) {
3145
+ resolveCellImageSentinels(blocks, /* @__PURE__ */ new Map());
3146
+ return [];
3147
+ }
3148
+ return resolveImageBlocks(binDataMap, blocks, warnings, sweepUnreferenced);
3120
3149
  }
3121
- function parseFileHeader(data) {
3122
- if (data.length < 40) throw new (0, _chunkDQJTNXVScjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
3123
- const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
3124
- return {
3125
- signature: sig,
3126
- versionMajor: data[35],
3127
- flags: data.readUInt32LE(36)
3128
- };
3150
+
3151
+ // src/hwpx/images.ts
3152
+ function imageExtToMime(ext) {
3153
+ switch (ext.toLowerCase()) {
3154
+ case "jpg":
3155
+ case "jpeg":
3156
+ return "image/jpeg";
3157
+ case "png":
3158
+ return "image/png";
3159
+ case "gif":
3160
+ return "image/gif";
3161
+ case "bmp":
3162
+ return "image/bmp";
3163
+ case "tif":
3164
+ case "tiff":
3165
+ return "image/tiff";
3166
+ case "wmf":
3167
+ return "image/wmf";
3168
+ case "emf":
3169
+ return "image/emf";
3170
+ case "svg":
3171
+ return "image/svg+xml";
3172
+ default:
3173
+ return "application/octet-stream";
3174
+ }
3129
3175
  }
3130
- function readHwpString(data, offset) {
3131
- if (offset + 2 > data.length) return { value: "", next: data.length };
3132
- const len = data.readUInt16LE(offset);
3133
- const start = offset + 2;
3134
- const end = start + len * 2;
3135
- if (len === 0 || end > data.length) return { value: "", next: start };
3136
- return { value: data.subarray(start, end).toString("utf16le"), next: end };
3176
+ function mimeToExt(mime) {
3177
+ if (mime.includes("jpeg")) return "jpg";
3178
+ if (mime.includes("png")) return "png";
3179
+ if (mime.includes("gif")) return "gif";
3180
+ if (mime.includes("bmp")) return "bmp";
3181
+ if (mime.includes("tiff")) return "tif";
3182
+ if (mime.includes("wmf")) return "wmf";
3183
+ if (mime.includes("emf")) return "emf";
3184
+ if (mime.includes("svg")) return "svg";
3185
+ return "bin";
3137
3186
  }
3138
- function parseDocInfo(records) {
3139
- const charShapes = [];
3140
- const paraShapes = [];
3141
- const styles = [];
3142
- const binData = [];
3143
- const numberings = [];
3144
- const bullets = [];
3145
- for (const rec of records) {
3146
- if (rec.tagId === TAG_DOC_PARA_SHAPE && rec.data.length >= 4) {
3147
- const attr1 = rec.data.readUInt32LE(0);
3148
- const headType = attr1 >>> 23 & 3;
3149
- const paraLevel = attr1 >>> 25 & 7;
3150
- const numberingId = rec.data.length >= 32 ? rec.data.readUInt16LE(30) : 0;
3151
- paraShapes.push({ headType, paraLevel, numberingId });
3187
+ function collectImageBlocks2(blocks, out, ownerCell, depth = 0) {
3188
+ if (depth > MAX_XML_DEPTH) return;
3189
+ for (const block of blocks) {
3190
+ if (block.type === "image") {
3191
+ out.push({ block, ownerCell });
3192
+ } else if (block.type === "table" && block.table) {
3193
+ for (const row of block.table.cells) {
3194
+ for (const cell2 of row) {
3195
+ if (_optionalChain([cell2, 'access', _67 => _67.blocks, 'optionalAccess', _68 => _68.length])) collectImageBlocks2(cell2.blocks, out, cell2, depth + 1);
3196
+ }
3197
+ }
3152
3198
  }
3153
- if (rec.tagId === TAG_BIN_DATA && rec.data.length >= 2) {
3154
- const attr = rec.data.readUInt16LE(0);
3155
- const typeBits = attr & 15;
3156
- if (typeBits === 0) {
3157
- binData.push({ kind: "link", storageId: 0, extension: "" });
3158
- } else {
3159
- const storageId = rec.data.length >= 4 ? rec.data.readUInt16LE(2) : 0;
3160
- const { value: extension } = readHwpString(rec.data, 4);
3161
- binData.push({ kind: typeBits === 2 ? "storage" : "embed", storageId, extension });
3162
- }
3163
- }
3164
- if (rec.tagId === TAG_NUMBERING && rec.data.length >= 14) {
3165
- const levelFormats = [];
3166
- const numberFormats = [];
3167
- const startNumbers = [1, 1, 1, 1, 1, 1, 1];
3168
- let offset = 0;
3169
- for (let level = 0; level < 7; level++) {
3170
- if (offset + 12 > rec.data.length) {
3171
- levelFormats.push("");
3172
- numberFormats.push(0);
3173
- continue;
3199
+ }
3200
+ }
3201
+ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUnreferenced) {
3202
+ const images = [];
3203
+ let imageIndex = 0;
3204
+ const usedPaths = /* @__PURE__ */ new Set();
3205
+ const imageBlocks = [];
3206
+ collectImageBlocks2(blocks, imageBlocks);
3207
+ const resolved = /* @__PURE__ */ new Map();
3208
+ for (const { block, ownerCell } of imageBlocks) {
3209
+ if (block.type !== "image" || !block.text) continue;
3210
+ const ref = block.text;
3211
+ let img = resolved.get(ref);
3212
+ if (img === void 0) {
3213
+ img = null;
3214
+ const candidates = [
3215
+ `BinData/${ref}`,
3216
+ `Contents/BinData/${ref}`,
3217
+ ref
3218
+ // 절대 경로일 수도 있음
3219
+ ];
3220
+ let resolvedPath = null;
3221
+ if (!ref.includes(".")) {
3222
+ const prefixes = [`BinData/${ref}`, `Contents/BinData/${ref}`];
3223
+ for (const prefix of prefixes) {
3224
+ const match = zip.file(new RegExp(`^${prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\.[a-zA-Z0-9]+$`));
3225
+ if (match.length > 0) {
3226
+ resolvedPath = match[0].name;
3227
+ break;
3228
+ }
3174
3229
  }
3175
- const attr = rec.data.readUInt32LE(offset);
3176
- numberFormats.push(attr >>> 5 & 15);
3177
- offset += 12;
3178
- const { value, next } = readHwpString(rec.data, offset);
3179
- levelFormats.push(value);
3180
- offset = next;
3181
- }
3182
- let baseStart = 1;
3183
- if (offset + 2 <= rec.data.length) {
3184
- baseStart = rec.data.readUInt16LE(offset) || 1;
3185
- offset += 2;
3186
3230
  }
3187
- for (let level = 0; level < 7; level++) {
3188
- if (offset + 4 <= rec.data.length) {
3189
- startNumbers[level] = rec.data.readUInt32LE(offset) || 1;
3190
- offset += 4;
3191
- } else {
3192
- startNumbers[level] = baseStart;
3231
+ const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
3232
+ for (const path of allCandidates) {
3233
+ if (_chunk6XAAYAWLcjs.isPathTraversal.call(void 0, path)) continue;
3234
+ const file = zip.file(path);
3235
+ if (!file) continue;
3236
+ try {
3237
+ const data = await file.async("uint8array");
3238
+ decompressed.total += data.length;
3239
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3240
+ const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
3241
+ const mimeType = imageExtToMime(ext);
3242
+ imageIndex++;
3243
+ const filename = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
3244
+ img = { filename, data, mimeType };
3245
+ images.push(img);
3246
+ usedPaths.add(path);
3247
+ break;
3248
+ } catch (err) {
3249
+ if (err instanceof _chunk6XAAYAWLcjs.KordocError) throw err;
3193
3250
  }
3194
3251
  }
3195
- numberings.push({ levelFormats, numberFormats, startNumbers });
3196
- }
3197
- if (rec.tagId === TAG_BULLET && rec.data.length >= 14) {
3198
- const code = rec.data.readUInt16LE(12);
3199
- bullets.push({ char: code > 0 ? String.fromCharCode(code) : "\u2022" });
3252
+ if (!img) _optionalChain([warnings, 'optionalAccess', _69 => _69.push, 'call', _70 => _70({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
3253
+ resolved.set(ref, img);
3200
3254
  }
3201
- if (rec.tagId === TAG_DOC_CHAR_SHAPE && rec.data.length >= 18) {
3202
- if (rec.data.length >= 50) {
3203
- const fontSize = rec.data.readUInt32LE(42);
3204
- const attrFlags = rec.data.readUInt32LE(46);
3205
- charShapes.push({ fontSize, attrFlags });
3206
- } else {
3207
- charShapes.push({ fontSize: 0, attrFlags: 0 });
3208
- }
3255
+ if (!img) {
3256
+ block.type = "paragraph";
3257
+ block.text = `[\uC774\uBBF8\uC9C0: ${ref}]`;
3258
+ if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, `[\uC774\uBBF8\uC9C0: ${ref}]`);
3259
+ continue;
3209
3260
  }
3210
- if (rec.tagId === TAG_DOC_STYLE && rec.data.length >= 8) {
3261
+ block.text = img.filename;
3262
+ block.imageData = { data: img.data, mimeType: img.mimeType, filename: ref };
3263
+ if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, `![image](${img.filename})`);
3264
+ }
3265
+ if (sweepUnreferenced) {
3266
+ const binEntries = zip.file(/(?:^|\/)BinData\//i);
3267
+ for (const file of binEntries) {
3268
+ if (file.dir || usedPaths.has(file.name) || _chunk6XAAYAWLcjs.isPathTraversal.call(void 0, file.name)) continue;
3211
3269
  try {
3212
- let offset = 0;
3213
- const nameLen = rec.data.readUInt16LE(offset);
3214
- offset += 2;
3215
- const nameBytes = nameLen * 2;
3216
- const name = nameBytes > 0 && offset + nameBytes <= rec.data.length ? rec.data.subarray(offset, offset + nameBytes).toString("utf16le") : "";
3217
- offset += nameBytes;
3218
- let nameKo = "";
3219
- if (offset + 2 <= rec.data.length) {
3220
- const nameKoLen = rec.data.readUInt16LE(offset);
3221
- offset += 2;
3222
- const nameKoBytes = nameKoLen * 2;
3223
- if (nameKoBytes > 0 && offset + nameKoBytes <= rec.data.length) {
3224
- nameKo = rec.data.subarray(offset, offset + nameKoBytes).toString("utf16le");
3225
- }
3226
- offset += nameKoBytes;
3270
+ const data = await file.async("uint8array");
3271
+ decompressed.total += data.length;
3272
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3273
+ const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
3274
+ let mimeType = imageExtToMime(ext);
3275
+ if (mimeType === "application/octet-stream") {
3276
+ const sniffed = detectImageMime(data);
3277
+ if (!sniffed) continue;
3278
+ mimeType = sniffed;
3227
3279
  }
3228
- const type = offset < rec.data.length ? rec.data.readUInt8(offset) : 0;
3229
- offset += 1;
3230
- offset += 1;
3231
- offset += 2;
3232
- const paraShapeId = offset + 2 <= rec.data.length ? rec.data.readUInt16LE(offset) : 0;
3233
- offset += 2;
3234
- const charShapeId = offset + 2 <= rec.data.length ? rec.data.readUInt16LE(offset) : 0;
3235
- styles.push({ name, nameKo, charShapeId, paraShapeId, type });
3236
- } catch (e18) {
3280
+ imageIndex++;
3281
+ const filename = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
3282
+ const img = { filename, data, mimeType };
3283
+ images.push(img);
3284
+ blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
3285
+ } catch (err) {
3286
+ if (err instanceof _chunk6XAAYAWLcjs.KordocError) throw err;
3287
+ _optionalChain([warnings, 'optionalAccess', _71 => _71.push, 'call', _72 => _72({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
3237
3288
  }
3238
3289
  }
3239
3290
  }
3240
- return { charShapes, paraShapes, styles, binData, numberings, bullets };
3291
+ return images;
3241
3292
  }
3242
- function createParaTextState() {
3243
- return { text: "", ctrlIdx: 0, fieldStack: [], fieldRanges: [] };
3293
+
3294
+ // src/hwpx/metadata.ts
3295
+
3296
+
3297
+ // src/hwpx/zip-sections.ts
3298
+
3299
+ function extractFromBrokenZip(buffer) {
3300
+ const data = new Uint8Array(buffer);
3301
+ const view = new DataView(buffer);
3302
+ let pos = 0;
3303
+ const blocks = [];
3304
+ const warnings = [
3305
+ { code: "BROKEN_ZIP_RECOVERY", message: "\uC190\uC0C1\uB41C ZIP \uAD6C\uC870 \u2014 Local File Header \uAE30\uBC18 \uBCF5\uAD6C \uBAA8\uB4DC" }
3306
+ ];
3307
+ let totalDecompressed = 0;
3308
+ let entryCount = 0;
3309
+ let sectionNum = 0;
3310
+ const shared = createSectionShared();
3311
+ while (pos < data.length - 30) {
3312
+ if (data[pos] !== 80 || data[pos + 1] !== 75 || data[pos + 2] !== 3 || data[pos + 3] !== 4) {
3313
+ pos++;
3314
+ while (pos < data.length - 30) {
3315
+ if (data[pos] === 80 && data[pos + 1] === 75 && data[pos + 2] === 3 && data[pos + 3] === 4) break;
3316
+ pos++;
3317
+ }
3318
+ continue;
3319
+ }
3320
+ if (++entryCount > MAX_ZIP_ENTRIES) break;
3321
+ const method = view.getUint16(pos + 8, true);
3322
+ const compSize = view.getUint32(pos + 18, true);
3323
+ const nameLen = view.getUint16(pos + 26, true);
3324
+ const extraLen = view.getUint16(pos + 28, true);
3325
+ if (nameLen > 1024 || extraLen > 65535) {
3326
+ pos += 30 + nameLen + extraLen;
3327
+ continue;
3328
+ }
3329
+ const fileStart = pos + 30 + nameLen + extraLen;
3330
+ if (fileStart + compSize > data.length) break;
3331
+ if (compSize === 0 && method !== 0) {
3332
+ pos = fileStart;
3333
+ continue;
3334
+ }
3335
+ const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
3336
+ const name = new TextDecoder().decode(nameBytes);
3337
+ if (_chunk6XAAYAWLcjs.isPathTraversal.call(void 0, name)) {
3338
+ pos = fileStart + compSize;
3339
+ continue;
3340
+ }
3341
+ const fileData = data.slice(fileStart, fileStart + compSize);
3342
+ pos = fileStart + compSize;
3343
+ if (!name.toLowerCase().includes("section") || !name.endsWith(".xml")) continue;
3344
+ try {
3345
+ let content;
3346
+ if (method === 0) {
3347
+ content = new TextDecoder().decode(fileData);
3348
+ } else if (method === 8) {
3349
+ const decompressed = _zlib.inflateRawSync.call(void 0, Buffer.from(fileData), { maxOutputLength: MAX_DECOMPRESS_SIZE });
3350
+ content = new TextDecoder().decode(decompressed);
3351
+ } else {
3352
+ continue;
3353
+ }
3354
+ totalDecompressed += content.length * 2;
3355
+ if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
3356
+ sectionNum++;
3357
+ blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
3358
+ } catch (e16) {
3359
+ continue;
3360
+ }
3361
+ }
3362
+ if (blocks.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3363
+ applyPageText(blocks, shared);
3364
+ const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
3365
+ return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
3244
3366
  }
3245
- function isExtendedOnlyCtrlChar(ch) {
3246
- return ch >= 1 && ch <= 3 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 18 || ch >= 21 && ch <= 23;
3367
+ async function readKordocLayout(zip) {
3368
+ const file = _nullishCoalesce(zip.file("Contents/content.hpf"), () => ( zip.file("content.hpf")));
3369
+ if (!file) return null;
3370
+ try {
3371
+ const xml = await file.async("text");
3372
+ if (!/<opf:meta\b[^>]*name="generator"[^>]*content="kordoc"/.test(xml)) return null;
3373
+ return _nullishCoalesce(_optionalChain([xml, 'access', _73 => _73.match, 'call', _74 => _74(/<opf:meta\b[^>]*name="kordoc-layout"[^>]*content="([^"]*)"/), 'optionalAccess', _75 => _75[1]]), () => ( null));
3374
+ } catch (e17) {
3375
+ return null;
3376
+ }
3247
3377
  }
3248
- function appendParaText(state, data, resolveControl) {
3249
- let result = "";
3250
- let i = 0;
3251
- const base = state.text.length;
3252
- const resolveAt = (byteOffset, extended) => {
3253
- const ctrlId = data.readUInt32LE(byteOffset);
3254
- const idx = extended ? state.ctrlIdx : -1;
3255
- const replacement = _optionalChain([resolveControl, 'optionalCall', _80 => _80(idx, ctrlId)]);
3256
- if (replacement) result += replacement;
3257
- if (extended) state.ctrlIdx++;
3378
+ async function resolveSectionPaths(zip) {
3379
+ const manifestPaths = ["Contents/content.hpf", "content.hpf"];
3380
+ for (const mp of manifestPaths) {
3381
+ const mpLower = mp.toLowerCase();
3382
+ const file = zip.file(mp) || Object.values(zip.files).find((f) => f.name.toLowerCase() === mpLower) || null;
3383
+ if (!file) continue;
3384
+ const xml = await file.async("text");
3385
+ const paths = parseSectionPathsFromManifest(xml);
3386
+ if (paths.length > 0) return paths;
3387
+ }
3388
+ const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
3389
+ return sectionFiles.map((f) => f.name).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
3390
+ }
3391
+ function parseSectionPathsFromManifest(xml) {
3392
+ const parser = createXmlParser();
3393
+ const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
3394
+ const items = doc.getElementsByTagName("opf:item");
3395
+ const spine = doc.getElementsByTagName("opf:itemref");
3396
+ const idToHref = /* @__PURE__ */ new Map();
3397
+ for (let i = 0; i < items.length; i++) {
3398
+ const item = items[i];
3399
+ const id = item.getAttribute("id") || "";
3400
+ const href = _chunk6XAAYAWLcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
3401
+ if (id && href) idToHref.set(id, href);
3402
+ }
3403
+ if (spine.length > 0) {
3404
+ const ordered = [];
3405
+ for (let i = 0; i < spine.length; i++) {
3406
+ const href = idToHref.get(spine[i].getAttribute("idref") || "");
3407
+ if (href) ordered.push(href);
3408
+ }
3409
+ if (ordered.length > 0) return ordered;
3410
+ }
3411
+ return Array.from(idToHref.values()).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
3412
+ }
3413
+
3414
+ // src/hwpx/metadata.ts
3415
+ async function extractHwpxMetadata(zip, metadata, decompressed) {
3416
+ try {
3417
+ const metaPaths = ["meta.xml", "META-INF/meta.xml", "docProps/core.xml"];
3418
+ for (const mp of metaPaths) {
3419
+ const file = zip.file(mp) || Object.values(zip.files).find((f) => f.name.toLowerCase() === mp.toLowerCase()) || null;
3420
+ if (!file) continue;
3421
+ const xml = await file.async("text");
3422
+ if (decompressed) {
3423
+ decompressed.total += xml.length * 2;
3424
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3425
+ }
3426
+ parseDublinCoreMetadata(xml, metadata);
3427
+ if (metadata.title || metadata.author) return;
3428
+ }
3429
+ } catch (e18) {
3430
+ }
3431
+ }
3432
+ function parseDublinCoreMetadata(xml, metadata) {
3433
+ const parser = createXmlParser();
3434
+ const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
3435
+ if (!doc.documentElement) return;
3436
+ const getText = (tagNames) => {
3437
+ for (const tag of tagNames) {
3438
+ const els = doc.getElementsByTagName(tag);
3439
+ if (els.length > 0) {
3440
+ const text = _optionalChain([els, 'access', _76 => _76[0], 'access', _77 => _77.textContent, 'optionalAccess', _78 => _78.trim, 'call', _79 => _79()]);
3441
+ if (text) return text;
3442
+ }
3443
+ }
3444
+ return void 0;
3258
3445
  };
3259
- while (i + 1 < data.length) {
3260
- const ch = data.readUInt16LE(i);
3261
- i += 2;
3262
- switch (ch) {
3263
- // ── char 타입 (2바이트만, 확장 데이터 없음) ──
3264
- case CHAR_LINE:
3265
- result += "\n";
3266
- break;
3267
- case CHAR_SECTION_BREAK: {
3268
- if (i + 16 <= data.length && data.readUInt16LE(i) === 11) {
3269
- resolveAt(i + 2, true);
3270
- i += 16;
3271
- break;
3446
+ metadata.title = metadata.title || getText(["dc:title", "title"]);
3447
+ metadata.author = metadata.author || getText(["dc:creator", "creator", "cp:lastModifiedBy"]);
3448
+ metadata.description = metadata.description || getText(["dc:description", "description", "dc:subject", "subject"]);
3449
+ metadata.createdAt = metadata.createdAt || getText(["dcterms:created", "meta:creation-date"]);
3450
+ metadata.modifiedAt = metadata.modifiedAt || getText(["dcterms:modified", "meta:date"]);
3451
+ const keywords = getText(["dc:keyword", "cp:keywords", "meta:keyword"]);
3452
+ if (keywords && !metadata.keywords) {
3453
+ metadata.keywords = keywords.split(/[,;]/).map((k) => k.trim()).filter(Boolean);
3454
+ }
3455
+ }
3456
+
3457
+ // src/hwpx/parser.ts
3458
+ async function parseHwpxDocument(buffer, options) {
3459
+ _chunk6XAAYAWLcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
3460
+ let zip;
3461
+ try {
3462
+ zip = await _jszip2.default.loadAsync(buffer);
3463
+ } catch (e19) {
3464
+ return extractFromBrokenZip(buffer);
3465
+ }
3466
+ const actualEntryCount = Object.keys(zip.files).length;
3467
+ if (actualEntryCount > MAX_ZIP_ENTRIES) {
3468
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3469
+ }
3470
+ const manifestFile = zip.file("META-INF/manifest.xml");
3471
+ if (manifestFile) {
3472
+ const manifestXml = await manifestFile.async("text");
3473
+ if (isEncryptedHwpx(manifestXml)) {
3474
+ if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _80 => _80.filePath])) {
3475
+ const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
3476
+ if (pages.some((p) => p && p.trim().length > 0)) {
3477
+ return comResultToParseResult(pages, pageCount, warnings2);
3272
3478
  }
3273
- result += "\n";
3274
- break;
3275
3479
  }
3276
- case CHAR_PARA:
3277
- break;
3278
- // 문단 끝
3279
- case CHAR_HYPHEN:
3280
- result += "-";
3281
- break;
3282
- case CHAR_NBSP:
3283
- result += " ";
3284
- break;
3285
- case CHAR_FIXED_NBSP:
3286
- result += "\xA0";
3287
- break;
3288
- // 진짜 NBSP
3289
- case CHAR_FIXED_WIDTH:
3290
- result += " ";
3291
- break;
3292
- // 고정폭 공백
3293
- // ── inline 타입 (2바이트 + 14바이트 확장) ──
3294
- case CHAR_TAB:
3295
- result += " ";
3296
- if (i + 14 <= data.length) i += 14;
3297
- break;
3298
- default:
3299
- if (ch >= 1 && ch <= 31) {
3300
- const isExtended = isExtendedOnlyCtrlChar(ch);
3301
- const isInline = ch >= 4 && ch <= 9 || ch >= 19 && ch <= 20;
3302
- if ((isExtended || isInline) && i + 14 <= data.length) {
3303
- if (ch === 3) {
3304
- state.fieldStack.push({ start: base + result.length, ctrlIdx: state.ctrlIdx });
3305
- } else if (ch === 4) {
3306
- const open = state.fieldStack.pop();
3307
- if (open) {
3308
- state.fieldRanges.push({ start: open.start, end: base + result.length, ctrlIdx: open.ctrlIdx });
3309
- }
3310
- }
3311
- resolveAt(i, isExtended);
3312
- i += 14;
3313
- }
3314
- } else if (ch >= 32) {
3315
- if (ch >= 55296 && ch <= 56319 && i + 1 < data.length) {
3316
- const lo = data.readUInt16LE(i);
3317
- if (lo >= 56320 && lo <= 57343) {
3318
- i += 2;
3319
- const codePoint = (ch - 55296 << 10) + (lo - 56320) + 65536;
3320
- result += String.fromCodePoint(codePoint);
3321
- break;
3322
- }
3323
- }
3324
- result += String.fromCharCode(ch);
3325
- }
3326
- break;
3480
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
3481
+ }
3482
+ }
3483
+ const decompressed = { total: 0 };
3484
+ const metadata = {};
3485
+ await extractHwpxMetadata(zip, metadata, decompressed);
3486
+ const styleMap = await extractHwpxStyles(zip, decompressed);
3487
+ const warnings = [];
3488
+ const sectionPaths = await resolveSectionPaths(zip);
3489
+ if (sectionPaths.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3490
+ metadata.pageCount = sectionPaths.length;
3491
+ const pageFilter = _optionalChain([options, 'optionalAccess', _81 => _81.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
3492
+ const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
3493
+ const blocks = [];
3494
+ const shared = createSectionShared();
3495
+ shared.kordocLayout = await readKordocLayout(zip);
3496
+ let parsedSections = 0;
3497
+ for (let si = 0; si < sectionPaths.length; si++) {
3498
+ if (pageFilter && !pageFilter.has(si + 1)) continue;
3499
+ const file = zip.file(sectionPaths[si]);
3500
+ if (!file) continue;
3501
+ try {
3502
+ const xml = await file.async("text");
3503
+ decompressed.total += xml.length * 2;
3504
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3505
+ blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
3506
+ parsedSections++;
3507
+ _optionalChain([options, 'optionalAccess', _82 => _82.onProgress, 'optionalCall', _83 => _83(parsedSections, totalTarget)]);
3508
+ } catch (secErr) {
3509
+ if (secErr instanceof _chunk6XAAYAWLcjs.KordocError) throw secErr;
3510
+ warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
3327
3511
  }
3328
3512
  }
3329
- state.text += result;
3330
- }
3331
- function extractEquationText(data) {
3332
- if (data.length < 6) return null;
3333
- const scriptLength = data.readUInt16LE(4);
3334
- const scriptStart = 6;
3335
- const scriptEnd = scriptStart + scriptLength * 2;
3336
- if (scriptLength <= 0 || scriptEnd > data.length) return null;
3337
- const equation = data.subarray(scriptStart, scriptEnd).toString("utf16le").replace(/\0+/g, "").trim();
3338
- return equation || null;
3513
+ applyPageText(blocks, shared);
3514
+ const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
3515
+ detectHwpxHeadings(blocks, styleMap);
3516
+ const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
3517
+ const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
3518
+ return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
3339
3519
  }
3340
3520
 
3341
3521
  // src/hwp5/numbering.ts
@@ -3516,282 +3696,6 @@ function expandNumberingFormat(formatStr, counters, numbering) {
3516
3696
  return result;
3517
3697
  }
3518
3698
 
3519
- // src/hwp5/images.ts
3520
- function detectImageMime(data) {
3521
- if (data.length < 4) return null;
3522
- if (data[0] === 137 && data[1] === 80 && data[2] === 78 && data[3] === 71) return "image/png";
3523
- if (data[0] === 255 && data[1] === 216 && data[2] === 255) return "image/jpeg";
3524
- if (data[0] === 71 && data[1] === 73 && data[2] === 70) return "image/gif";
3525
- if (data[0] === 66 && data[1] === 77) return "image/bmp";
3526
- if (data[0] === 215 && data[1] === 205 && data[2] === 198 && data[3] === 154) return "image/wmf";
3527
- if (data[0] === 1 && data[1] === 0 && data[2] === 0 && data[3] === 0) return "image/emf";
3528
- return null;
3529
- }
3530
- function normalizeBinPayload(data) {
3531
- if (detectImageMime(data)) return data;
3532
- try {
3533
- const inflated = decompressStream(data);
3534
- if (inflated.length > 0) return inflated;
3535
- } catch (e19) {
3536
- }
3537
- return data;
3538
- }
3539
- var BIN_ENTRY_RE = /(?:^|\/)BIN([0-9A-Fa-f]{4,8})(?:\.[^./\\]*)?$/;
3540
- function collectImageBlocks2(blocks, out) {
3541
- for (const b of blocks) {
3542
- if (b.type === "image") out.push(b);
3543
- if (b.table) {
3544
- for (const row of b.table.cells) {
3545
- for (const cell2 of row) {
3546
- if (cell2.blocks) collectImageBlocks2(cell2.blocks, out);
3547
- }
3548
- }
3549
- }
3550
- if (b.children) collectImageBlocks2(b.children, out);
3551
- }
3552
- }
3553
- function forEachTableCell(blocks, fn) {
3554
- for (const b of blocks) {
3555
- if (b.table) {
3556
- for (const row of b.table.cells) {
3557
- for (const cell2 of row) {
3558
- fn(cell2);
3559
- if (cell2.blocks) forEachTableCell(cell2.blocks, fn);
3560
- }
3561
- }
3562
- }
3563
- if (b.children) forEachTableCell(b.children, fn);
3564
- }
3565
- }
3566
- var CELL_IMAGE_SENTINEL_RE = /!\[image\]\(hwp5bin:(\d+)\)/g;
3567
- function resolveCellImageSentinels(blocks, renamed) {
3568
- forEachTableCell(blocks, (cell2) => {
3569
- if (!cell2.text.includes("hwp5bin:")) return;
3570
- cell2.text = cell2.text.replace(CELL_IMAGE_SENTINEL_RE, (_m, idStr) => {
3571
- const filename = renamed.get(Number(idStr));
3572
- return filename ? `![image](${filename})` : "[\uC774\uBBF8\uC9C0]";
3573
- });
3574
- });
3575
- }
3576
- function resolveImageBlocks(binDataMap, blocks, warnings) {
3577
- const imageBlocks = [];
3578
- collectImageBlocks2(blocks, imageBlocks);
3579
- if (imageBlocks.length === 0) return [];
3580
- const images = [];
3581
- const renamed = /* @__PURE__ */ new Map();
3582
- const resolved = /* @__PURE__ */ new Map();
3583
- let imageIndex = 0;
3584
- for (const block of imageBlocks) {
3585
- if (!block.text) continue;
3586
- const storageId = parseInt(block.text, 10);
3587
- if (isNaN(storageId)) continue;
3588
- let img = resolved.get(storageId);
3589
- if (img === void 0) {
3590
- const bin = binDataMap.get(storageId);
3591
- if (!bin) {
3592
- warnings.push({ page: block.pageNumber, message: `BinData ${storageId} \uC5C6\uC74C`, code: "SKIPPED_IMAGE" });
3593
- resolved.set(storageId, null);
3594
- } else {
3595
- const mime = detectImageMime(bin.data);
3596
- if (!mime) {
3597
- warnings.push({ page: block.pageNumber, message: `BinData ${storageId}: \uC54C \uC218 \uC5C6\uB294 \uC774\uBBF8\uC9C0 \uD615\uC2DD`, code: "SKIPPED_IMAGE" });
3598
- resolved.set(storageId, null);
3599
- } else {
3600
- imageIndex++;
3601
- const ext = mime.includes("jpeg") ? "jpg" : mime.includes("png") ? "png" : mime.includes("gif") ? "gif" : mime.includes("bmp") ? "bmp" : "bin";
3602
- img = { filename: `image_${String(imageIndex).padStart(3, "0")}.${ext}`, data: new Uint8Array(bin.data), mime };
3603
- resolved.set(storageId, img);
3604
- images.push({ filename: img.filename, data: img.data, mimeType: img.mime });
3605
- renamed.set(storageId, img.filename);
3606
- }
3607
- }
3608
- img = resolved.get(storageId);
3609
- }
3610
- if (!img) {
3611
- const bin = binDataMap.get(storageId);
3612
- block.type = "paragraph";
3613
- block.text = bin ? `[\uC774\uBBF8\uC9C0: ${bin.name}]` : `[\uC774\uBBF8\uC9C0: BinData ${storageId}]`;
3614
- continue;
3615
- }
3616
- block.text = img.filename;
3617
- block.imageData = { data: img.data, mimeType: img.mime, filename: binDataMap.get(storageId).name };
3618
- }
3619
- resolveCellImageSentinels(blocks, renamed);
3620
- return images;
3621
- }
3622
- function extractHwp5Images(fileIndex, blocks, warnings) {
3623
- const binDataMap = /* @__PURE__ */ new Map();
3624
- if (fileIndex) {
3625
- for (const entry of fileIndex) {
3626
- if (!_optionalChain([entry, 'optionalAccess', _81 => _81.name]) || !entry.content) continue;
3627
- const match = entry.name.match(BIN_ENTRY_RE);
3628
- if (!match) continue;
3629
- const idx = parseInt(match[1], 16);
3630
- const data = normalizeBinPayload(Buffer.from(entry.content));
3631
- binDataMap.set(idx, { data, name: entry.name });
3632
- }
3633
- }
3634
- if (binDataMap.size === 0) {
3635
- resolveCellImageSentinels(blocks, /* @__PURE__ */ new Map());
3636
- return [];
3637
- }
3638
- return resolveImageBlocks(binDataMap, blocks, warnings);
3639
- }
3640
- function extractHwp5ImagesLenient(lcfb, blocks, warnings) {
3641
- const binDataMap = /* @__PURE__ */ new Map();
3642
- const binRe = /^BIN([0-9A-Fa-f]{4,8})(?:\.|$)/;
3643
- for (const e of lcfb.entries()) {
3644
- const match = e.name.match(binRe);
3645
- if (!match) continue;
3646
- const idx = parseInt(match[1], 16);
3647
- const raw = lcfb.findStream(e.name);
3648
- if (!raw) continue;
3649
- binDataMap.set(idx, { data: normalizeBinPayload(raw), name: e.name });
3650
- }
3651
- if (binDataMap.size === 0) {
3652
- resolveCellImageSentinels(blocks, /* @__PURE__ */ new Map());
3653
- return [];
3654
- }
3655
- return resolveImageBlocks(binDataMap, blocks, warnings);
3656
- }
3657
-
3658
- // src/image/transcode.ts
3659
-
3660
- var CRC_TABLE = (() => {
3661
- const table2 = new Uint32Array(256);
3662
- for (let n = 0; n < 256; n++) {
3663
- let c = n;
3664
- for (let k = 0; k < 8; k++) {
3665
- c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
3666
- }
3667
- table2[n] = c >>> 0;
3668
- }
3669
- return table2;
3670
- })();
3671
- function crc32(bytes) {
3672
- let c = 4294967295;
3673
- for (let i = 0; i < bytes.length; i++) {
3674
- c = CRC_TABLE[(c ^ bytes[i]) & 255] ^ c >>> 8;
3675
- }
3676
- return (c ^ 4294967295) >>> 0;
3677
- }
3678
- var BI_RGB = 0;
3679
- var MAX_DIM = 32767;
3680
- var MAX_PIXELS = 36e6;
3681
- function bmpToPng(bmp) {
3682
- if (bmp.length < 54) return null;
3683
- if (bmp[0] !== 66 || bmp[1] !== 77) return null;
3684
- const dv = new DataView(bmp.buffer, bmp.byteOffset, bmp.byteLength);
3685
- const dataOffset = dv.getUint32(10, true);
3686
- const headerSize = dv.getUint32(14, true);
3687
- if (headerSize < 40) return null;
3688
- const width = dv.getInt32(18, true);
3689
- const rawHeight = dv.getInt32(22, true);
3690
- const bitCount = dv.getUint16(28, true);
3691
- const compression = dv.getUint32(30, true);
3692
- if (compression !== BI_RGB) return null;
3693
- if (bitCount !== 24 && bitCount !== 32) return null;
3694
- if (width <= 0 || rawHeight === 0) return null;
3695
- if (width > MAX_DIM || Math.abs(rawHeight) > MAX_DIM) return null;
3696
- const topDown = rawHeight < 0;
3697
- const height = Math.abs(rawHeight);
3698
- if (width * height > MAX_PIXELS) return null;
3699
- const bytesPerPixel = bitCount >> 3;
3700
- const rowStride = width * bytesPerPixel + 3 & ~3;
3701
- if (dataOffset + rowStride * height > bmp.length) return null;
3702
- const rgba = new Uint8Array(width * height * 4);
3703
- let anyAlpha = 0;
3704
- for (let y = 0; y < height; y++) {
3705
- const srcRow = topDown ? y : height - 1 - y;
3706
- let src = dataOffset + srcRow * rowStride;
3707
- let dst = y * width * 4;
3708
- for (let x = 0; x < width; x++) {
3709
- rgba[dst] = bmp[src + 2];
3710
- rgba[dst + 1] = bmp[src + 1];
3711
- rgba[dst + 2] = bmp[src];
3712
- const a = bitCount === 32 ? bmp[src + 3] : 255;
3713
- rgba[dst + 3] = a;
3714
- anyAlpha |= a;
3715
- src += bytesPerPixel;
3716
- dst += 4;
3717
- }
3718
- }
3719
- if (bitCount === 32 && anyAlpha === 0) {
3720
- for (let i = 3; i < rgba.length; i += 4) rgba[i] = 255;
3721
- }
3722
- return encodePng(width, height, rgba);
3723
- }
3724
- var PNG_SIGNATURE = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10);
3725
- function chunk(type, data) {
3726
- const body = new Uint8Array(4 + data.length);
3727
- body[0] = type.charCodeAt(0);
3728
- body[1] = type.charCodeAt(1);
3729
- body[2] = type.charCodeAt(2);
3730
- body[3] = type.charCodeAt(3);
3731
- body.set(data, 4);
3732
- const out = new Uint8Array(8 + data.length + 4);
3733
- const dv = new DataView(out.buffer);
3734
- dv.setUint32(0, data.length, false);
3735
- out.set(body, 4);
3736
- dv.setUint32(8 + data.length, crc32(body), false);
3737
- return out;
3738
- }
3739
- function encodePng(width, height, rgba) {
3740
- const ihdr = new Uint8Array(13);
3741
- const iv = new DataView(ihdr.buffer);
3742
- iv.setUint32(0, width, false);
3743
- iv.setUint32(4, height, false);
3744
- ihdr[8] = 8;
3745
- ihdr[9] = 6;
3746
- const stride = width * 4;
3747
- const raw = new Uint8Array((stride + 1) * height);
3748
- for (let y = 0; y < height; y++) {
3749
- const rowStart = y * (stride + 1);
3750
- raw[rowStart] = 0;
3751
- raw.set(rgba.subarray(y * stride, y * stride + stride), rowStart + 1);
3752
- }
3753
- const idat = _zlib.deflateSync.call(void 0, raw);
3754
- const ihdrChunk = chunk("IHDR", ihdr);
3755
- const idatChunk = chunk("IDAT", idat);
3756
- const iendChunk = chunk("IEND", new Uint8Array(0));
3757
- const out = new Uint8Array(PNG_SIGNATURE.length + ihdrChunk.length + idatChunk.length + iendChunk.length);
3758
- let o = 0;
3759
- out.set(PNG_SIGNATURE, o);
3760
- o += PNG_SIGNATURE.length;
3761
- out.set(ihdrChunk, o);
3762
- o += ihdrChunk.length;
3763
- out.set(idatChunk, o);
3764
- o += idatChunk.length;
3765
- out.set(iendChunk, o);
3766
- return out;
3767
- }
3768
- function escapeRegExp(s) {
3769
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3770
- }
3771
- function inlineImagesIntoMarkdown(markdown, images, opts) {
3772
- const compress = _optionalChain([opts, 'optionalAccess', _82 => _82.compress]) !== false;
3773
- let out = markdown;
3774
- for (const img of images) {
3775
- let bytes = img.data;
3776
- let mime = img.mimeType;
3777
- if (compress && mime === "image/bmp") {
3778
- const png = bmpToPng(img.data);
3779
- if (png) {
3780
- bytes = png;
3781
- mime = "image/png";
3782
- }
3783
- }
3784
- const base64 = Buffer.from(bytes).toString("base64");
3785
- const dataUri = `data:${mime};base64,${base64}`;
3786
- const name = escapeRegExp(img.filename);
3787
- const mdRe = new RegExp(`!\\[image\\]\\((?:images/)?${name}\\)`, "g");
3788
- out = out.replace(mdRe, () => `![image](${dataUri})`);
3789
- const imgTagRe = new RegExp(`(<img\\b[^>]*\\bsrc=")(?:images/)?${name}(")`, "g");
3790
- out = out.replace(imgTagRe, (_m, pre, post) => `${pre}${dataUri}${post}`);
3791
- }
3792
- return out;
3793
- }
3794
-
3795
3699
  // src/hwp5/aes.ts
3796
3700
  var S_BOX = new Uint8Array([
3797
3701
  99,
@@ -4789,22 +4693,22 @@ function parseHwp5Document(buffer, options) {
4789
4693
  lenientCfb = parseLenientCfb(buffer);
4790
4694
  warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
4791
4695
  } catch (e22) {
4792
- throw new (0, _chunkDQJTNXVScjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
4696
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
4793
4697
  }
4794
4698
  }
4795
4699
  const findStream = (path) => {
4796
4700
  if (cfb) {
4797
4701
  const entry = CFB.find(cfb, path);
4798
- return _optionalChain([entry, 'optionalAccess', _83 => _83.content]) ? Buffer.from(entry.content) : null;
4702
+ return _optionalChain([entry, 'optionalAccess', _84 => _84.content]) ? Buffer.from(entry.content) : null;
4799
4703
  }
4800
4704
  return lenientCfb.findStream(path);
4801
4705
  };
4802
4706
  const headerData = findStream("/FileHeader");
4803
- if (!headerData) throw new (0, _chunkDQJTNXVScjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
4707
+ if (!headerData) throw new (0, _chunk6XAAYAWLcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
4804
4708
  const header = parseFileHeader(headerData);
4805
- if (header.signature !== "HWP Document File") throw new (0, _chunkDQJTNXVScjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
4806
- if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
4807
- if (header.flags & FLAG_DRM) throw new (0, _chunkDQJTNXVScjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
4709
+ if (header.signature !== "HWP Document File") throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
4710
+ if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
4711
+ if (header.flags & FLAG_DRM) throw new (0, _chunk6XAAYAWLcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
4808
4712
  const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
4809
4713
  const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
4810
4714
  const metadata = {
@@ -4813,9 +4717,9 @@ function parseHwp5Document(buffer, options) {
4813
4717
  if (cfb) extractHwp5Metadata(cfb, metadata);
4814
4718
  const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
4815
4719
  const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
4816
- if (sections.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
4720
+ if (sections.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
4817
4721
  metadata.pageCount = sections.length;
4818
- const pageFilter = _optionalChain([options, 'optionalAccess', _84 => _84.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
4722
+ const pageFilter = _optionalChain([options, 'optionalAccess', _85 => _85.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
4819
4723
  const totalTarget = pageFilter ? pageFilter.size : sections.length;
4820
4724
  const bodyBlocks = [];
4821
4725
  const doc = createHwp5DocState();
@@ -4827,22 +4731,22 @@ function parseHwp5Document(buffer, options) {
4827
4731
  const sectionData = sections[si];
4828
4732
  const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
4829
4733
  totalDecompressed += data.length;
4830
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4734
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4831
4735
  const records = readRecords(data);
4832
4736
  const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
4833
4737
  bodyBlocks.push(...sectionBlocks);
4834
4738
  parsedSections++;
4835
- _optionalChain([options, 'optionalAccess', _85 => _85.onProgress, 'optionalCall', _86 => _86(parsedSections, totalTarget)]);
4739
+ _optionalChain([options, 'optionalAccess', _86 => _86.onProgress, 'optionalCall', _87 => _87(parsedSections, totalTarget)]);
4836
4740
  } catch (secErr) {
4837
- if (secErr instanceof _chunkDQJTNXVScjs.KordocError) throw secErr;
4741
+ if (secErr instanceof _chunk6XAAYAWLcjs.KordocError) throw secErr;
4838
4742
  warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
4839
4743
  }
4840
4744
  }
4841
4745
  const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
4842
- const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
4843
- let flatBlocks = _chunkDQJTNXVScjs.flattenLayoutTables.call(void 0, blocks);
4844
- if (_optionalChain([options, 'optionalAccess', _87 => _87.dedupeRunningHeaders])) {
4845
- const deduped = _chunkDQJTNXVScjs.dedupeRunningHeaders.call(void 0, flatBlocks);
4746
+ const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
4747
+ let flatBlocks = _chunk6XAAYAWLcjs.flattenLayoutTables.call(void 0, blocks);
4748
+ if (_optionalChain([options, 'optionalAccess', _88 => _88.dedupeRunningHeaders])) {
4749
+ const deduped = _chunk6XAAYAWLcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
4846
4750
  const removed = flatBlocks.length - deduped.length;
4847
4751
  if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
4848
4752
  flatBlocks = deduped;
@@ -4851,10 +4755,10 @@ function parseHwp5Document(buffer, options) {
4851
4755
  detectHwp5Headings(flatBlocks, docInfo);
4852
4756
  }
4853
4757
  const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
4854
- let markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, flatBlocks);
4855
- if (_optionalChain([options, 'optionalAccess', _88 => _88.inlineImages]) && images.length > 0) {
4758
+ let markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, flatBlocks);
4759
+ if (_optionalChain([options, 'optionalAccess', _89 => _89.inlineImages]) && images.length > 0) {
4856
4760
  try {
4857
- markdown = inlineImagesIntoMarkdown(markdown, images, { compress: true });
4761
+ markdown = _chunk6XAAYAWLcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
4858
4762
  } catch (inlineErr) {
4859
4763
  warnings.push({ message: `\uC774\uBBF8\uC9C0 \uC778\uB77C\uC778 \uC2E4\uD328 \u2014 \uC6D0\uBCF8 \uD30C\uC77C \uCC38\uC870\uB85C \uD3F4\uBC31: ${inlineErr instanceof Error ? inlineErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "SKIPPED_IMAGE" });
4860
4764
  }
@@ -4864,7 +4768,7 @@ function parseHwp5Document(buffer, options) {
4864
4768
  function parseDocInfoStream(cfb, compressed) {
4865
4769
  try {
4866
4770
  const entry = CFB.find(cfb, "/DocInfo");
4867
- if (!_optionalChain([entry, 'optionalAccess', _89 => _89.content])) return null;
4771
+ if (!_optionalChain([entry, 'optionalAccess', _90 => _90.content])) return null;
4868
4772
  const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
4869
4773
  const records = readRecords(data);
4870
4774
  return parseDocInfo(records);
@@ -4885,7 +4789,7 @@ function detectHwp5Headings(blocks, docInfo) {
4885
4789
  let baseFontSize = 0;
4886
4790
  const sizeFreq = /* @__PURE__ */ new Map();
4887
4791
  for (const b of blocks) {
4888
- if (_optionalChain([b, 'access', _90 => _90.style, 'optionalAccess', _91 => _91.fontSize]) && b.text) {
4792
+ if (_optionalChain([b, 'access', _91 => _91.style, 'optionalAccess', _92 => _92.fontSize]) && b.text) {
4889
4793
  sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
4890
4794
  }
4891
4795
  }
@@ -4901,7 +4805,7 @@ function detectHwp5Headings(blocks, docInfo) {
4901
4805
  const name = (style.nameKo || style.name).toLowerCase();
4902
4806
  if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
4903
4807
  const cs = docInfo.charShapes[style.charShapeId];
4904
- if (_optionalChain([cs, 'optionalAccess', _92 => _92.fontSize]) > 0) {
4808
+ if (_optionalChain([cs, 'optionalAccess', _93 => _93.fontSize]) > 0) {
4905
4809
  baseFontSize = cs.fontSize / 10;
4906
4810
  break;
4907
4811
  }
@@ -4916,11 +4820,11 @@ function detectHwp5Headings(blocks, docInfo) {
4916
4820
  if (text.length === 0 || text.length > 200) continue;
4917
4821
  if (/^\d+$/.test(text)) continue;
4918
4822
  let level = 0;
4919
- if (_optionalChain([block, 'access', _93 => _93.style, 'optionalAccess', _94 => _94.fontSize]) && baseFontSize > 0) {
4823
+ if (_optionalChain([block, 'access', _94 => _94.style, 'optionalAccess', _95 => _95.fontSize]) && baseFontSize > 0) {
4920
4824
  const ratio = block.style.fontSize / baseFontSize;
4921
- if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H1) level = 1;
4922
- else if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H2) level = 2;
4923
- else if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H3) level = 3;
4825
+ if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H1) level = 1;
4826
+ else if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H2) level = 2;
4827
+ else if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H3) level = 3;
4924
4828
  }
4925
4829
  if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
4926
4830
  if (level === 0) level = 2;
@@ -4936,7 +4840,7 @@ function detectHwp5Headings(blocks, docInfo) {
4936
4840
  function extractHwp5Metadata(cfb, metadata) {
4937
4841
  try {
4938
4842
  const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
4939
- if (!_optionalChain([summaryEntry, 'optionalAccess', _95 => _95.content])) return;
4843
+ if (!_optionalChain([summaryEntry, 'optionalAccess', _96 => _96.content])) return;
4940
4844
  const data = Buffer.from(summaryEntry.content);
4941
4845
  if (data.length < 48) return;
4942
4846
  const numSets = data.readUInt32LE(24);
@@ -4969,7 +4873,7 @@ function findViewTextSections(cfb, compressed) {
4969
4873
  const sections = [];
4970
4874
  for (let i = 0; i < MAX_SECTIONS; i++) {
4971
4875
  const entry = CFB.find(cfb, `/ViewText/Section${i}`);
4972
- if (!_optionalChain([entry, 'optionalAccess', _96 => _96.content])) break;
4876
+ if (!_optionalChain([entry, 'optionalAccess', _97 => _97.content])) break;
4973
4877
  try {
4974
4878
  const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
4975
4879
  sections.push({ idx: i, content: decrypted });
@@ -4983,13 +4887,13 @@ function findSections(cfb) {
4983
4887
  const sections = [];
4984
4888
  for (let i = 0; i < MAX_SECTIONS; i++) {
4985
4889
  const entry = CFB.find(cfb, `/BodyText/Section${i}`);
4986
- if (!_optionalChain([entry, 'optionalAccess', _97 => _97.content])) break;
4890
+ if (!_optionalChain([entry, 'optionalAccess', _98 => _98.content])) break;
4987
4891
  sections.push({ idx: i, content: Buffer.from(entry.content) });
4988
4892
  }
4989
4893
  if (sections.length === 0 && cfb.FileIndex) {
4990
4894
  for (const entry of cfb.FileIndex) {
4991
4895
  if (sections.length >= MAX_SECTIONS) break;
4992
- if (_optionalChain([entry, 'access', _98 => _98.name, 'optionalAccess', _99 => _99.startsWith, 'call', _100 => _100("Section")]) && entry.content) {
4896
+ if (_optionalChain([entry, 'access', _99 => _99.name, 'optionalAccess', _100 => _100.startsWith, 'call', _101 => _101("Section")]) && entry.content) {
4993
4897
  const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
4994
4898
  sections.push({ idx, content: Buffer.from(entry.content) });
4995
4899
  }
@@ -5005,7 +4909,7 @@ function findSectionsLenient(lcfb, compressed) {
5005
4909
  if (!raw) break;
5006
4910
  const content = compressed ? decompressStream(raw) : raw;
5007
4911
  totalDecompressed += content.length;
5008
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4912
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
5009
4913
  sections.push({ idx: i, content });
5010
4914
  }
5011
4915
  if (sections.length === 0) {
@@ -5017,7 +4921,7 @@ function findSectionsLenient(lcfb, compressed) {
5017
4921
  if (raw) {
5018
4922
  const content = compressed ? decompressStream(raw) : raw;
5019
4923
  totalDecompressed += content.length;
5020
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4924
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
5021
4925
  sections.push({ idx, content });
5022
4926
  }
5023
4927
  }
@@ -5034,7 +4938,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
5034
4938
  try {
5035
4939
  const content = decryptViewText(raw, compressed);
5036
4940
  totalDecompressed += content.length;
5037
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4941
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
5038
4942
  sections.push({ idx: i, content });
5039
4943
  } catch (e27) {
5040
4944
  break;
@@ -5135,9 +5039,9 @@ function parseParagraph(records, start, end, ctx) {
5135
5039
  const applied = [];
5136
5040
  for (const r of ranges) {
5137
5041
  const ctrl = ctrls[r.ctrlIdx];
5138
- if (!_optionalChain([ctrl, 'optionalAccess', _101 => _101.href]) || r.end <= r.start) continue;
5042
+ if (!_optionalChain([ctrl, 'optionalAccess', _102 => _102.href]) || r.end <= r.start) continue;
5139
5043
  if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
5140
- const href = _chunkDQJTNXVScjs.sanitizeHref.call(void 0, ctrl.href);
5044
+ const href = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, ctrl.href);
5141
5045
  if (!href) continue;
5142
5046
  const anchor = text.slice(r.start, r.end);
5143
5047
  if (!anchor.trim()) continue;
@@ -5155,7 +5059,7 @@ function parseParagraph(records, start, end, ctx) {
5155
5059
  }
5156
5060
  if (ps.headType === 1 || ps.headType === 2) {
5157
5061
  const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
5158
- const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _102 => _102.docInfo, 'optionalAccess', _103 => _103.numberings, 'access', _104 => _104[nid - 1]]) : void 0;
5062
+ const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _103 => _103.docInfo, 'optionalAccess', _104 => _104.numberings, 'access', _105 => _105[nid - 1]]) : void 0;
5159
5063
  if (numbering) {
5160
5064
  const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
5161
5065
  const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
@@ -5165,7 +5069,7 @@ function parseParagraph(records, start, end, ctx) {
5165
5069
  }
5166
5070
  }
5167
5071
  } else if (ps.headType === 3) {
5168
- const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _105 => _105.docInfo, 'optionalAccess', _106 => _106.bullets, 'access', _107 => _107[ps.numberingId - 1]]) : void 0;
5072
+ const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _106 => _106.docInfo, 'optionalAccess', _107 => _107.bullets, 'access', _108 => _108[ps.numberingId - 1]]) : void 0;
5169
5073
  if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
5170
5074
  }
5171
5075
  }
@@ -5370,8 +5274,8 @@ function parseTableControl(ctrl, records, ctx) {
5370
5274
  let tableIdx = -1;
5371
5275
  for (let i2 = childStart; i2 < childEnd; i2++) {
5372
5276
  if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
5373
- rows = Math.min(records[i2].data.readUInt16LE(4), _chunkDQJTNXVScjs.MAX_ROWS);
5374
- cols = Math.min(records[i2].data.readUInt16LE(6), _chunkDQJTNXVScjs.MAX_COLS);
5277
+ rows = Math.min(records[i2].data.readUInt16LE(4), _chunk6XAAYAWLcjs.MAX_ROWS);
5278
+ cols = Math.min(records[i2].data.readUInt16LE(6), _chunk6XAAYAWLcjs.MAX_COLS);
5375
5279
  tableIdx = i2;
5376
5280
  break;
5377
5281
  }
@@ -5411,7 +5315,7 @@ function parseTableControl(ctrl, records, ctx) {
5411
5315
  const cellRows2 = arrangeCells(rows, cols, cells);
5412
5316
  const irCells = cellRows2.map((row) => row.map((c) => {
5413
5317
  const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
5414
- if (_optionalChain([c, 'access', _108 => _108.blocks, 'optionalAccess', _109 => _109.length])) ir.blocks = c.blocks;
5318
+ if (_optionalChain([c, 'access', _109 => _109.blocks, 'optionalAccess', _110 => _110.length])) ir.blocks = c.blocks;
5415
5319
  if (c.isHeader) ir.isHeader = true;
5416
5320
  return ir;
5417
5321
  }));
@@ -5420,7 +5324,7 @@ function parseTableControl(ctrl, records, ctx) {
5420
5324
  return table3;
5421
5325
  }
5422
5326
  const cellRows = arrangeCells(rows, cols, cells);
5423
- const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, cellRows);
5327
+ const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
5424
5328
  if (caption && table2.rows > 0) table2.caption = caption;
5425
5329
  return table2.rows > 0 ? table2 : null;
5426
5330
  }
@@ -5437,8 +5341,8 @@ function parseCell(records, lhIdx, end, ctx) {
5437
5341
  rowAddr = rec.data.readUInt16LE(10);
5438
5342
  const cs = rec.data.readUInt16LE(12);
5439
5343
  const rs = rec.data.readUInt16LE(14);
5440
- if (cs > 0) colSpan = Math.min(cs, _chunkDQJTNXVScjs.MAX_COLS);
5441
- if (rs > 0) rowSpan = Math.min(rs, _chunkDQJTNXVScjs.MAX_ROWS);
5344
+ if (cs > 0) colSpan = Math.min(cs, _chunk6XAAYAWLcjs.MAX_COLS);
5345
+ if (rs > 0) rowSpan = Math.min(rs, _chunk6XAAYAWLcjs.MAX_ROWS);
5442
5346
  }
5443
5347
  const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
5444
5348
  const parts = [];
@@ -5448,7 +5352,7 @@ function parseCell(records, lhIdx, end, ctx) {
5448
5352
  parts.push(`![image](hwp5bin:${b.text})`);
5449
5353
  hasStructure = true;
5450
5354
  } else if (b.type === "table" && b.table) {
5451
- const flat = _chunkDQJTNXVScjs.convertTableToText.call(void 0, b.table.cells);
5355
+ const flat = _chunk6XAAYAWLcjs.convertTableToText.call(void 0, b.table.cells);
5452
5356
  if (flat) parts.push(flat);
5453
5357
  hasStructure = true;
5454
5358
  } else if (b.text) {
@@ -5545,8 +5449,8 @@ function pictureToImageBlock(data, ctx) {
5545
5449
  if (data.length < 73) return null;
5546
5450
  const binDataId = data.readUInt16LE(71);
5547
5451
  if (binDataId === 0) return null;
5548
- const item = _optionalChain([ctx, 'access', _110 => _110.docInfo, 'optionalAccess', _111 => _111.binData, 'access', _112 => _112[binDataId - 1]]);
5549
- if (_optionalChain([item, 'optionalAccess', _113 => _113.kind]) === "link") {
5452
+ const item = _optionalChain([ctx, 'access', _111 => _111.docInfo, 'optionalAccess', _112 => _112.binData, 'access', _113 => _113[binDataId - 1]]);
5453
+ if (_optionalChain([item, 'optionalAccess', _114 => _114.kind]) === "link") {
5550
5454
  ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
5551
5455
  return null;
5552
5456
  }
@@ -17877,15 +17781,15 @@ function getElements(parent, tagName) {
17877
17781
  const result = [];
17878
17782
  for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
17879
17783
  if (result.length > 0) return result;
17880
- const nsNodes = _optionalChain([parent, 'access', _114 => _114.getElementsByTagNameNS, 'optionalCall', _115 => _115("*", tagName)]);
17784
+ const nsNodes = _optionalChain([parent, 'access', _115 => _115.getElementsByTagNameNS, 'optionalCall', _116 => _116("*", tagName)]);
17881
17785
  if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
17882
17786
  return result;
17883
17787
  }
17884
17788
  function getTextContent(el) {
17885
- return _nullishCoalesce(_optionalChain([el, 'access', _116 => _116.textContent, 'optionalAccess', _117 => _117.trim, 'call', _118 => _118()]), () => ( ""));
17789
+ return _nullishCoalesce(_optionalChain([el, 'access', _117 => _117.textContent, 'optionalAccess', _118 => _118.trim, 'call', _119 => _119()]), () => ( ""));
17886
17790
  }
17887
17791
  function parseXml(text) {
17888
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, text), "text/xml");
17792
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, text), "text/xml");
17889
17793
  }
17890
17794
  function parseSharedStrings(xml) {
17891
17795
  const doc = parseXml(xml);
@@ -18022,14 +17926,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
18022
17926
  const merge = mergeMap.get(key);
18023
17927
  row.push({
18024
17928
  text,
18025
- colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _119 => _119.colSpan]), () => ( 1)),
18026
- rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _120 => _120.rowSpan]), () => ( 1))
17929
+ colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _120 => _120.colSpan]), () => ( 1)),
17930
+ rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _121 => _121.rowSpan]), () => ( 1))
18027
17931
  });
18028
17932
  }
18029
17933
  cellRows.push(row);
18030
17934
  }
18031
17935
  if (cellRows.length > 0) {
18032
- const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, cellRows);
17936
+ const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
18033
17937
  if (table2.rows > 0) {
18034
17938
  blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
18035
17939
  }
@@ -18037,12 +17941,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
18037
17941
  return blocks;
18038
17942
  }
18039
17943
  async function parseXlsxDocument(buffer, options) {
18040
- _chunkDQJTNXVScjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
17944
+ _chunk6XAAYAWLcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
18041
17945
  const zip = await _jszip2.default.loadAsync(buffer);
18042
17946
  const warnings = [];
18043
17947
  const workbookFile = zip.file("xl/workbook.xml");
18044
17948
  if (!workbookFile) {
18045
- throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
17949
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18046
17950
  }
18047
17951
  let sharedStrings = [];
18048
17952
  const ssFile = zip.file("xl/sharedStrings.xml");
@@ -18051,7 +17955,7 @@ async function parseXlsxDocument(buffer, options) {
18051
17955
  }
18052
17956
  const sheets = parseWorkbook(await workbookFile.async("text"));
18053
17957
  if (sheets.length === 0) {
18054
- throw new (0, _chunkDQJTNXVScjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
17958
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
18055
17959
  }
18056
17960
  let relsMap = /* @__PURE__ */ new Map();
18057
17961
  const relsFile = zip.file("xl/_rels/workbook.xml.rels");
@@ -18059,7 +17963,7 @@ async function parseXlsxDocument(buffer, options) {
18059
17963
  relsMap = parseRels(await relsFile.async("text"));
18060
17964
  }
18061
17965
  let pageFilter = null;
18062
- if (_optionalChain([options, 'optionalAccess', _121 => _121.pages])) {
17966
+ if (_optionalChain([options, 'optionalAccess', _122 => _122.pages])) {
18063
17967
  const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
18064
17968
  pageFilter = parsePageRange2(options.pages, sheets.length);
18065
17969
  }
@@ -18068,7 +17972,7 @@ async function parseXlsxDocument(buffer, options) {
18068
17972
  for (let i = 0; i < processedSheets; i++) {
18069
17973
  if (pageFilter && !pageFilter.has(i + 1)) continue;
18070
17974
  const sheet = sheets[i];
18071
- _optionalChain([options, 'optionalAccess', _122 => _122.onProgress, 'optionalCall', _123 => _123(i + 1, processedSheets)]);
17975
+ _optionalChain([options, 'optionalAccess', _123 => _123.onProgress, 'optionalCall', _124 => _124(i + 1, processedSheets)]);
18072
17976
  let sheetPath = relsMap.get(sheet.rId);
18073
17977
  if (sheetPath) {
18074
17978
  if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
@@ -18123,7 +18027,7 @@ async function parseXlsxDocument(buffer, options) {
18123
18027
  } catch (e28) {
18124
18028
  }
18125
18029
  }
18126
- const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
18030
+ const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
18127
18031
  return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
18128
18032
  }
18129
18033
 
@@ -18530,11 +18434,11 @@ function processGlobals(records) {
18530
18434
  let encrypted = false;
18531
18435
  const firstBof = records[0];
18532
18436
  if (!firstBof || firstBof.opcode !== OP_BOF) {
18533
- throw new (0, _chunkDQJTNXVScjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
18437
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
18534
18438
  }
18535
18439
  const bof = decodeBof(firstBof.data);
18536
18440
  if (!bof || bof.dt !== DT_GLOBALS) {
18537
- throw new (0, _chunkDQJTNXVScjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
18441
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
18538
18442
  }
18539
18443
  let i = 1;
18540
18444
  while (i < records.length) {
@@ -18642,14 +18546,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
18642
18546
  const merge = mergeMap.get(key);
18643
18547
  row.push({
18644
18548
  text: grid[r][c],
18645
- colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _124 => _124.colSpan]), () => ( 1)),
18646
- rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _125 => _125.rowSpan]), () => ( 1))
18549
+ colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _125 => _125.colSpan]), () => ( 1)),
18550
+ rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _126 => _126.rowSpan]), () => ( 1))
18647
18551
  });
18648
18552
  }
18649
18553
  cellRows.push(row);
18650
18554
  }
18651
18555
  if (cellRows.length > 0) {
18652
- const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, cellRows);
18556
+ const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
18653
18557
  if (table2.rows > 0) {
18654
18558
  blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
18655
18559
  }
@@ -18662,21 +18566,21 @@ async function parseXlsDocument(buffer, options) {
18662
18566
  try {
18663
18567
  cfb = parseLenientCfb(buf);
18664
18568
  } catch (e) {
18665
- throw new (0, _chunkDQJTNXVScjs.KordocError)(
18569
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)(
18666
18570
  `XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
18667
18571
  );
18668
18572
  }
18669
18573
  const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
18670
18574
  if (!wb) {
18671
- throw new (0, _chunkDQJTNXVScjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
18575
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
18672
18576
  }
18673
18577
  const records = readRecords2(wb);
18674
18578
  if (records.length === 0) {
18675
- throw new (0, _chunkDQJTNXVScjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
18579
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
18676
18580
  }
18677
18581
  const firstBof = decodeBof(records[0].data);
18678
18582
  if (firstBof && firstBof.vers !== 1536) {
18679
- throw new (0, _chunkDQJTNXVScjs.KordocError)(
18583
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)(
18680
18584
  `XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
18681
18585
  );
18682
18586
  }
@@ -18697,7 +18601,7 @@ async function parseXlsDocument(buffer, options) {
18697
18601
  }
18698
18602
  const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
18699
18603
  let pageFilter = null;
18700
- if (_optionalChain([options, 'optionalAccess', _126 => _126.pages])) {
18604
+ if (_optionalChain([options, 'optionalAccess', _127 => _127.pages])) {
18701
18605
  const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
18702
18606
  pageFilter = parsePageRange2(options.pages, totalSheets);
18703
18607
  }
@@ -18706,7 +18610,7 @@ async function parseXlsDocument(buffer, options) {
18706
18610
  if (pageFilter && !pageFilter.has(i + 1)) continue;
18707
18611
  const meta = globals.sheets[i];
18708
18612
  if (meta.dt !== 0) continue;
18709
- _optionalChain([options, 'optionalAccess', _127 => _127.onProgress, 'optionalCall', _128 => _128(i + 1, totalSheets)]);
18613
+ _optionalChain([options, 'optionalAccess', _128 => _128.onProgress, 'optionalCall', _129 => _129(i + 1, totalSheets)]);
18710
18614
  const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
18711
18615
  if (bofIdx < 0) {
18712
18616
  warnings.push({
@@ -18736,7 +18640,7 @@ async function parseXlsDocument(buffer, options) {
18736
18640
  pageCount: totalSheets
18737
18641
  };
18738
18642
  return {
18739
- markdown: _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, allBlocks),
18643
+ markdown: _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, allBlocks),
18740
18644
  blocks: allBlocks,
18741
18645
  metadata,
18742
18646
  warnings: warnings.length > 0 ? warnings : void 0
@@ -18749,7 +18653,7 @@ async function parseXlsDocument(buffer, options) {
18749
18653
 
18750
18654
  // src/docx/equation.ts
18751
18655
  function lname(el) {
18752
- return el.localName || _optionalChain([el, 'access', _129 => _129.tagName, 'optionalAccess', _130 => _130.replace, 'call', _131 => _131(/^[^:]+:/, "")]) || "";
18656
+ return el.localName || _optionalChain([el, 'access', _130 => _130.tagName, 'optionalAccess', _131 => _131.replace, 'call', _132 => _132(/^[^:]+:/, "")]) || "";
18753
18657
  }
18754
18658
  function kids(parent, name) {
18755
18659
  const out = [];
@@ -19122,7 +19026,7 @@ function isDisplayMath(el) {
19122
19026
  // src/docx/parser.ts
19123
19027
  var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
19124
19028
  function matchesLocal(el, localName2) {
19125
- return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _132 => _132.tagName, 'optionalAccess', _133 => _133.endsWith, 'call', _134 => _134(`:${localName2}`)]), () => ( false)));
19029
+ return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _133 => _133.tagName, 'optionalAccess', _134 => _134.endsWith, 'call', _135 => _135(`:${localName2}`)]), () => ( false)));
19126
19030
  }
19127
19031
  function effectiveChildElements(parent) {
19128
19032
  const result = [];
@@ -19155,7 +19059,7 @@ function findElements(parent, localName2) {
19155
19059
  const child = children[i];
19156
19060
  if (child.nodeType === 1) {
19157
19061
  const el = child;
19158
- if (el.localName === localName2 || _optionalChain([el, 'access', _135 => _135.tagName, 'optionalAccess', _136 => _136.endsWith, 'call', _137 => _137(`:${localName2}`)])) {
19062
+ if (el.localName === localName2 || _optionalChain([el, 'access', _136 => _136.tagName, 'optionalAccess', _137 => _137.endsWith, 'call', _138 => _138(`:${localName2}`)])) {
19159
19063
  result.push(el);
19160
19064
  }
19161
19065
  walk(el);
@@ -19174,7 +19078,7 @@ function getAttr(el, localName2) {
19174
19078
  return null;
19175
19079
  }
19176
19080
  function parseXml2(text) {
19177
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, text), "text/xml");
19081
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, text), "text/xml");
19178
19082
  }
19179
19083
  function parseStyles(xml) {
19180
19084
  const doc = parseXml2(xml);
@@ -19276,7 +19180,7 @@ function collectOmmlRoots(p) {
19276
19180
  const child = children[i];
19277
19181
  if (child.nodeType !== 1) continue;
19278
19182
  const el = child;
19279
- const tag = el.localName || _optionalChain([el, 'access', _138 => _138.tagName, 'optionalAccess', _139 => _139.replace, 'call', _140 => _140(/^[^:]+:/, "")]) || "";
19183
+ const tag = el.localName || _optionalChain([el, 'access', _139 => _139.tagName, 'optionalAccess', _140 => _140.replace, 'call', _141 => _141(/^[^:]+:/, "")]) || "";
19280
19184
  if (tag === "oMath" || tag === "oMathPara") {
19281
19185
  out.push(el);
19282
19186
  } else if (tag === "txbxContent" || tag === "Fallback") {
@@ -19300,6 +19204,102 @@ function extractRun(r) {
19300
19204
  }
19301
19205
  return { text, bold, italic };
19302
19206
  }
19207
+ function fieldUrlFromInstr(instr) {
19208
+ if (!/HYPERLINK\b/i.test(instr)) return null;
19209
+ const urlM = instr.match(/HYPERLINK\s+"([^"]*)"/i);
19210
+ const anchorM = instr.match(/\\l\s+"([^"]*)"/i);
19211
+ if (urlM && urlM[1]) {
19212
+ return anchorM && anchorM[1] ? `${urlM[1]}#${anchorM[1]}` : urlM[1];
19213
+ }
19214
+ if (anchorM && anchorM[1]) return `#${anchorM[1]}`;
19215
+ return null;
19216
+ }
19217
+ function makeLink(text, rawHref) {
19218
+ if (!text) return "";
19219
+ if (!rawHref) return text;
19220
+ const href = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, rawHref);
19221
+ return href ? `[${text}](${href})` : text;
19222
+ }
19223
+ function collectInline(p, footnotes, rels) {
19224
+ const parts = [];
19225
+ let bold = false;
19226
+ let italic = false;
19227
+ let footnoteText;
19228
+ let fieldActive = false;
19229
+ let fieldStage = "instr";
19230
+ let fieldInstr = "";
19231
+ let fieldDisplay = "";
19232
+ const flushField = () => {
19233
+ if (!fieldActive) return;
19234
+ if (fieldDisplay) {
19235
+ const url = fieldUrlFromInstr(fieldInstr);
19236
+ parts.push(url ? makeLink(fieldDisplay, url) : fieldDisplay);
19237
+ }
19238
+ fieldActive = false;
19239
+ fieldStage = "instr";
19240
+ fieldInstr = "";
19241
+ fieldDisplay = "";
19242
+ };
19243
+ for (const el of effectiveChildElements(p)) {
19244
+ if (matchesLocal(el, "hyperlink")) {
19245
+ const rId = getAttr(el, "id");
19246
+ const anchor = getAttr(el, "anchor");
19247
+ const t = findElements(el, "r").map((r) => extractRun(r).text).join("");
19248
+ if (!t) continue;
19249
+ let raw = null;
19250
+ if (rId && rels.has(rId)) raw = rels.get(rId);
19251
+ else if (anchor) raw = `#${anchor}`;
19252
+ if (fieldActive && fieldStage === "display") fieldDisplay += t;
19253
+ else parts.push(makeLink(t, raw));
19254
+ continue;
19255
+ }
19256
+ if (matchesLocal(el, "fldSimple")) {
19257
+ const t = findElements(el, "r").map((r) => extractRun(r).text).join("");
19258
+ if (!t) continue;
19259
+ const url = fieldUrlFromInstr(_nullishCoalesce(getAttr(el, "instr"), () => ( "")));
19260
+ parts.push(url ? makeLink(t, url) : t);
19261
+ continue;
19262
+ }
19263
+ if (matchesLocal(el, "r")) {
19264
+ for (const fc of getChildElements(el, "fldChar")) {
19265
+ const ty = getAttr(fc, "fldCharType");
19266
+ if (ty === "begin") {
19267
+ flushField();
19268
+ fieldActive = true;
19269
+ fieldStage = "instr";
19270
+ } else if (ty === "separate") {
19271
+ if (fieldActive) fieldStage = "display";
19272
+ } else if (ty === "end") flushField();
19273
+ }
19274
+ if (fieldActive && fieldStage === "instr") {
19275
+ for (const it of getChildElements(el, "instrText")) fieldInstr += _nullishCoalesce(it.textContent, () => ( ""));
19276
+ }
19277
+ const rr = extractRun(el);
19278
+ if (rr.bold) bold = true;
19279
+ if (rr.italic) italic = true;
19280
+ const fnRefEls = getChildElements(el, "footnoteReference");
19281
+ if (fnRefEls.length > 0) {
19282
+ const fnId = getAttr(fnRefEls[0], "id");
19283
+ if (fnId && footnotes.has(fnId)) footnoteText = footnotes.get(fnId);
19284
+ }
19285
+ if (rr.text) {
19286
+ if (fieldActive && fieldStage === "display") fieldDisplay += rr.text;
19287
+ else if (fieldActive && fieldStage === "instr") {
19288
+ } else parts.push(rr.text);
19289
+ }
19290
+ continue;
19291
+ }
19292
+ }
19293
+ flushField();
19294
+ for (const om of collectOmmlRoots(p)) {
19295
+ const latex = ommlElementToLatex(om);
19296
+ if (!latex) continue;
19297
+ if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
19298
+ else parts.push(" $" + latex + "$ ");
19299
+ }
19300
+ const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
19301
+ return { text, bold, italic, footnoteText };
19302
+ }
19303
19303
  function parseParagraph2(p, styles, numbering, footnotes, rels) {
19304
19304
  const pPrEls = getChildElements(p, "pPr");
19305
19305
  let styleId = "";
@@ -19316,57 +19316,10 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
19316
19316
  ilvl = ilvlEls.length > 0 ? parseInt(_nullishCoalesce(getAttr(ilvlEls[0], "val"), () => ( "0")), 10) : 0;
19317
19317
  }
19318
19318
  }
19319
- const parts = [];
19320
- let hasBold = false;
19321
- let hasItalic = false;
19322
- let href;
19323
- let footnoteText;
19324
- const hyperlinks = getChildElements(p, "hyperlink");
19325
- const hyperlinkTexts = /* @__PURE__ */ new Set();
19326
- for (const hl of hyperlinks) {
19327
- const rId = getAttr(hl, "id");
19328
- const hlText = [];
19329
- const runs2 = findElements(hl, "r");
19330
- for (const r of runs2) {
19331
- const result = extractRun(r);
19332
- hlText.push(result.text);
19333
- }
19334
- const text2 = hlText.join("");
19335
- if (text2) {
19336
- hyperlinkTexts.add(text2);
19337
- if (rId && rels.has(rId)) {
19338
- href = rels.get(rId);
19339
- parts.push(text2);
19340
- } else {
19341
- parts.push(text2);
19342
- }
19343
- }
19344
- }
19345
- const runs = getChildElements(p, "r");
19346
- for (const r of runs) {
19347
- if (r.parentNode && r.parentNode.localName === "hyperlink") continue;
19348
- const result = extractRun(r);
19349
- if (result.bold) hasBold = true;
19350
- if (result.italic) hasItalic = true;
19351
- const fnRefEls = getChildElements(r, "footnoteReference");
19352
- if (fnRefEls.length > 0) {
19353
- const fnId = getAttr(fnRefEls[0], "id");
19354
- if (fnId && footnotes.has(fnId)) {
19355
- footnoteText = footnotes.get(fnId);
19356
- }
19357
- }
19358
- if (result.text) parts.push(result.text);
19359
- }
19360
- for (const om of collectOmmlRoots(p)) {
19361
- const latex = ommlElementToLatex(om);
19362
- if (!latex) continue;
19363
- if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
19364
- else parts.push(" $" + latex + "$ ");
19365
- }
19366
- const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
19319
+ const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
19367
19320
  if (!text) return null;
19368
19321
  const style = styles.get(styleId);
19369
- if (_optionalChain([style, 'optionalAccess', _141 => _141.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
19322
+ if (_optionalChain([style, 'optionalAccess', _142 => _142.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
19370
19323
  return {
19371
19324
  type: "heading",
19372
19325
  text,
@@ -19375,15 +19328,14 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
19375
19328
  }
19376
19329
  if (numId && numId !== "0") {
19377
19330
  const numDef = numbering.get(numId);
19378
- const levelInfo = _optionalChain([numDef, 'optionalAccess', _142 => _142.get, 'call', _143 => _143(ilvl)]);
19379
- const listType = _optionalChain([levelInfo, 'optionalAccess', _144 => _144.numFmt]) === "bullet" ? "unordered" : "ordered";
19331
+ const levelInfo = _optionalChain([numDef, 'optionalAccess', _143 => _143.get, 'call', _144 => _144(ilvl)]);
19332
+ const listType = _optionalChain([levelInfo, 'optionalAccess', _145 => _145.numFmt]) === "bullet" ? "unordered" : "ordered";
19380
19333
  return { type: "list", text, listType };
19381
19334
  }
19382
19335
  const block = { type: "paragraph", text };
19383
19336
  if (hasBold || hasItalic) {
19384
19337
  block.style = { bold: hasBold || void 0, italic: hasItalic || void 0 };
19385
19338
  }
19386
- if (href) block.href = href;
19387
19339
  if (footnoteText) block.footnoteText = footnoteText;
19388
19340
  return block;
19389
19341
  }
@@ -19459,7 +19411,7 @@ ${cell2.text}` : cell2.text;
19459
19411
  return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
19460
19412
  })
19461
19413
  );
19462
- const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, cellRows);
19414
+ const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
19463
19415
  if (table2.rows === 0 || table2.cols === 0) return null;
19464
19416
  return { type: "table", table: table2 };
19465
19417
  }
@@ -19469,10 +19421,10 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
19469
19421
  for (const el of effectiveChildElements(tc2)) {
19470
19422
  if (matchesLocal(el, "p")) {
19471
19423
  const block = parseParagraph2(el, styles, numbering, footnotes, rels);
19472
- if (_optionalChain([block, 'optionalAccess', _145 => _145.text])) parts.push(block.text);
19424
+ if (_optionalChain([block, 'optionalAccess', _146 => _146.text])) parts.push(block.text);
19473
19425
  for (const tp of collectTextboxParagraphs(el)) {
19474
19426
  const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
19475
- if (_optionalChain([tb, 'optionalAccess', _146 => _146.text])) parts.push(tb.text);
19427
+ if (_optionalChain([tb, 'optionalAccess', _147 => _147.text])) parts.push(tb.text);
19476
19428
  }
19477
19429
  } else if (matchesLocal(el, "tbl")) {
19478
19430
  for (const tr of getChildElements(el, "tr")) {
@@ -19484,54 +19436,89 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
19484
19436
  }
19485
19437
  return parts;
19486
19438
  }
19487
- async function extractImages(zip, rels, doc, warnings) {
19488
- const blocks = [];
19439
+ async function buildImageMap(zip, rels, doc, warnings) {
19440
+ const imageMap = /* @__PURE__ */ new Map();
19489
19441
  const images = [];
19490
- const drawingElements = findElements(doc.documentElement, "drawing");
19491
19442
  let imgIdx = 0;
19492
- for (const drawing of drawingElements) {
19493
- const blips = findElements(drawing, "blip");
19494
- for (const blip of blips) {
19495
- const embedId = getAttr(blip, "embed");
19496
- if (!embedId) continue;
19497
- const target = rels.get(embedId);
19498
- if (!target) continue;
19499
- const imgPath = target.startsWith("/") ? target.slice(1) : target.startsWith("word/") ? target : `word/${target}`;
19500
- const imgFile = zip.file(imgPath);
19501
- if (!imgFile) continue;
19502
- try {
19503
- const data = await imgFile.async("uint8array");
19504
- imgIdx++;
19505
- const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _147 => _147.split, 'call', _148 => _148("."), 'access', _149 => _149.pop, 'call', _150 => _150(), 'optionalAccess', _151 => _151.toLowerCase, 'call', _152 => _152()]), () => ( "png"));
19506
- const mimeMap = {
19507
- png: "image/png",
19508
- jpg: "image/jpeg",
19509
- jpeg: "image/jpeg",
19510
- gif: "image/gif",
19511
- bmp: "image/bmp",
19512
- wmf: "image/wmf",
19513
- emf: "image/emf"
19514
- };
19515
- const filename = `image_${String(imgIdx).padStart(3, "0")}.${ext}`;
19516
- images.push({ filename, data, mimeType: _nullishCoalesce(mimeMap[ext], () => ( "image/png")) });
19517
- blocks.push({ type: "image", text: filename });
19518
- } catch (err) {
19519
- warnings.push({
19520
- code: "SKIPPED_IMAGE",
19521
- message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
19522
- });
19523
- }
19443
+ const imageRefs = [];
19444
+ for (const blip of findElements(doc.documentElement, "blip")) {
19445
+ const embedId = getAttr(blip, "embed");
19446
+ if (embedId) imageRefs.push(embedId);
19447
+ }
19448
+ for (const imagedata of collectNonFallbackImagedata(doc.documentElement)) {
19449
+ const embedId = getAttr(imagedata, "id");
19450
+ if (embedId) imageRefs.push(embedId);
19451
+ }
19452
+ for (const embedId of imageRefs) {
19453
+ if (imageMap.has(embedId)) continue;
19454
+ const target = rels.get(embedId);
19455
+ if (!target) continue;
19456
+ const imgPath = target.startsWith("/") ? target.slice(1) : target.startsWith("word/") ? target : `word/${target}`;
19457
+ const imgFile = zip.file(imgPath);
19458
+ if (!imgFile) continue;
19459
+ try {
19460
+ const data = await imgFile.async("uint8array");
19461
+ imgIdx++;
19462
+ const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _148 => _148.split, 'call', _149 => _149("."), 'access', _150 => _150.pop, 'call', _151 => _151(), 'optionalAccess', _152 => _152.toLowerCase, 'call', _153 => _153()]), () => ( "png"));
19463
+ const mimeMap = {
19464
+ png: "image/png",
19465
+ jpg: "image/jpeg",
19466
+ jpeg: "image/jpeg",
19467
+ gif: "image/gif",
19468
+ bmp: "image/bmp",
19469
+ wmf: "image/wmf",
19470
+ emf: "image/emf"
19471
+ };
19472
+ const filename = `image_${String(imgIdx).padStart(3, "0")}.${ext}`;
19473
+ images.push({ filename, data, mimeType: _nullishCoalesce(mimeMap[ext], () => ( "image/png")) });
19474
+ imageMap.set(embedId, filename);
19475
+ } catch (err) {
19476
+ warnings.push({
19477
+ code: "SKIPPED_IMAGE",
19478
+ message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
19479
+ });
19524
19480
  }
19525
19481
  }
19526
- return { blocks, images };
19482
+ return { imageMap, images };
19483
+ }
19484
+ function collectParagraphBlips(node, out = [], depth = 0) {
19485
+ if (depth > 40) return out;
19486
+ for (const el of effectiveChildElements(node)) {
19487
+ if (matchesLocal(el, "txbxContent") || matchesLocal(el, "Fallback")) continue;
19488
+ if (matchesLocal(el, "blip") || matchesLocal(el, "imagedata")) out.push(el);
19489
+ else collectParagraphBlips(el, out, depth + 1);
19490
+ }
19491
+ return out;
19492
+ }
19493
+ function collectNonFallbackImagedata(node, out = [], depth = 0) {
19494
+ if (depth > 60) return out;
19495
+ const children = node.childNodes;
19496
+ for (let i = 0; i < children.length; i++) {
19497
+ if (children[i].nodeType !== 1) continue;
19498
+ const el = children[i];
19499
+ if (matchesLocal(el, "Fallback")) continue;
19500
+ if (matchesLocal(el, "imagedata")) out.push(el);
19501
+ else collectNonFallbackImagedata(el, out, depth + 1);
19502
+ }
19503
+ return out;
19504
+ }
19505
+ function emitParagraphImages(p, imageMap, linked, out) {
19506
+ for (const blip of collectParagraphBlips(p)) {
19507
+ const embedId = _nullishCoalesce(getAttr(blip, "embed"), () => ( getAttr(blip, "id")));
19508
+ if (!embedId) continue;
19509
+ const filename = imageMap.get(embedId);
19510
+ if (!filename) continue;
19511
+ linked.add(embedId);
19512
+ out.push({ type: "image", text: filename });
19513
+ }
19527
19514
  }
19528
19515
  async function parseDocxDocument(buffer, options) {
19529
- _chunkDQJTNXVScjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
19516
+ _chunk6XAAYAWLcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
19530
19517
  const zip = await _jszip2.default.loadAsync(buffer);
19531
19518
  const warnings = [];
19532
19519
  const docFile = zip.file("word/document.xml");
19533
19520
  if (!docFile) {
19534
- throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
19521
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
19535
19522
  }
19536
19523
  let rels = /* @__PURE__ */ new Map();
19537
19524
  const relsFile = zip.file("word/_rels/document.xml.rels");
@@ -19578,26 +19565,32 @@ async function parseDocxDocument(buffer, options) {
19578
19565
  const doc = parseXml2(docXml);
19579
19566
  const body = findElements(doc, "body");
19580
19567
  if (body.length === 0) {
19581
- throw new (0, _chunkDQJTNXVScjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19568
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19582
19569
  }
19570
+ const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
19571
+ const linkedImages = /* @__PURE__ */ new Set();
19583
19572
  const blocks = [];
19584
19573
  const bodyEl = body[0];
19585
19574
  const topLevel = effectiveChildElements(bodyEl);
19586
19575
  for (const el of topLevel) {
19587
- const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _153 => _153.tagName, 'optionalAccess', _154 => _154.split, 'call', _155 => _155(":"), 'access', _156 => _156.pop, 'call', _157 => _157()])));
19576
+ const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _154 => _154.tagName, 'optionalAccess', _155 => _155.split, 'call', _156 => _156(":"), 'access', _157 => _157.pop, 'call', _158 => _158()])));
19588
19577
  if (localName2 === "p") {
19589
19578
  const block = parseParagraph2(el, styles, numbering, footnotes, rels);
19590
19579
  if (block) blocks.push(block);
19580
+ if (imageMap.size > 0) emitParagraphImages(el, imageMap, linkedImages, blocks);
19591
19581
  for (const tp of collectTextboxParagraphs(el)) {
19592
19582
  const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
19593
19583
  if (tb) blocks.push(tb);
19584
+ if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
19594
19585
  }
19595
19586
  } else if (localName2 === "tbl") {
19596
19587
  const block = parseTable(el, styles, numbering, footnotes, rels);
19597
19588
  if (block) blocks.push(block);
19598
19589
  }
19599
19590
  }
19600
- const { blocks: imgBlocks, images } = await extractImages(zip, rels, doc, warnings);
19591
+ for (const [embedId, filename] of imageMap) {
19592
+ if (!linkedImages.has(embedId)) blocks.push({ type: "image", text: filename });
19593
+ }
19601
19594
  const metadata = {};
19602
19595
  const coreFile = zip.file("docProps/core.xml");
19603
19596
  if (coreFile) {
@@ -19623,7 +19616,7 @@ async function parseDocxDocument(buffer, options) {
19623
19616
  }
19624
19617
  }
19625
19618
  const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
19626
- const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
19619
+ const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
19627
19620
  return {
19628
19621
  markdown,
19629
19622
  blocks,
@@ -19646,7 +19639,7 @@ function parseHwpmlDocument(buffer, options) {
19646
19639
  }
19647
19640
  const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
19648
19641
  const normalized = text.replace(/&nbsp;/g, "&#160;");
19649
- const xml = _chunkDQJTNXVScjs.stripDtd.call(void 0, normalized);
19642
+ const xml = _chunk6XAAYAWLcjs.stripDtd.call(void 0, normalized);
19650
19643
  const warnings = [];
19651
19644
  const parser = new (0, _xmldom.DOMParser)({
19652
19645
  onError: (_level, msg2) => {
@@ -19674,7 +19667,7 @@ function parseHwpmlDocument(buffer, options) {
19674
19667
  return { markdown: "", blocks: [], metadata, warnings };
19675
19668
  }
19676
19669
  const blocks = [];
19677
- const pageFilter = _optionalChain([options, 'optionalAccess', _158 => _158.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
19670
+ const pageFilter = _optionalChain([options, 'optionalAccess', _159 => _159.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
19678
19671
  let sectionIdx = 0;
19679
19672
  const children = body.childNodes;
19680
19673
  for (let i = 0; i < children.length; i++) {
@@ -19686,7 +19679,7 @@ function parseHwpmlDocument(buffer, options) {
19686
19679
  parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
19687
19680
  }
19688
19681
  const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
19689
- const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
19682
+ const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
19690
19683
  return {
19691
19684
  markdown,
19692
19685
  blocks,
@@ -19772,7 +19765,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
19772
19765
  const shapeInfo = paraShapeMap.get(paraShapeId);
19773
19766
  const text = extractParagraphText(el);
19774
19767
  if (!text) return;
19775
- if (_optionalChain([shapeInfo, 'optionalAccess', _159 => _159.headingLevel]) != null) {
19768
+ if (_optionalChain([shapeInfo, 'optionalAccess', _160 => _160.headingLevel]) != null) {
19776
19769
  blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
19777
19770
  } else {
19778
19771
  blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
@@ -19844,7 +19837,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
19844
19837
  const cellRows = grid.map(
19845
19838
  (row) => row.map((cell2) => _nullishCoalesce(cell2, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
19846
19839
  );
19847
- const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, cellRows);
19840
+ const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
19848
19841
  const caption = extractShapeCaption(el);
19849
19842
  if (caption.text && caption.before) {
19850
19843
  blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
@@ -20104,7 +20097,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
20104
20097
  (match, prefix, suffix) => {
20105
20098
  const label = prefix + suffix;
20106
20099
  const normalizedLabel = normalizeLabel(label);
20107
- if (_optionalChain([blockedLabels, 'optionalAccess', _160 => _160.has, 'call', _161 => _161(normalizedLabel)])) return match;
20100
+ if (_optionalChain([blockedLabels, 'optionalAccess', _161 => _161.has, 'call', _162 => _162(normalizedLabel)])) return match;
20108
20101
  const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
20109
20102
  if (matchKey === void 0) return match;
20110
20103
  const newValue = values.consume(matchKey);
@@ -20354,8 +20347,8 @@ function extractFromTable(table2) {
20354
20347
  if (table2.cols >= 2) {
20355
20348
  for (let r = 0; r < table2.rows; r++) {
20356
20349
  for (let c = 0; c < table2.cols - 1; c++) {
20357
- const labelCell = _optionalChain([table2, 'access', _162 => _162.cells, 'access', _163 => _163[r], 'optionalAccess', _164 => _164[c]]);
20358
- const valueCell = _optionalChain([table2, 'access', _165 => _165.cells, 'access', _166 => _166[r], 'optionalAccess', _167 => _167[c + 1]]);
20350
+ const labelCell = _optionalChain([table2, 'access', _163 => _163.cells, 'access', _164 => _164[r], 'optionalAccess', _165 => _165[c]]);
20351
+ const valueCell = _optionalChain([table2, 'access', _166 => _166.cells, 'access', _167 => _167[r], 'optionalAccess', _168 => _168[c + 1]]);
20359
20352
  if (!labelCell || !valueCell) continue;
20360
20353
  if (isLabelCell(labelCell.text)) {
20361
20354
  fields.push({
@@ -20377,8 +20370,8 @@ function extractFromTable(table2) {
20377
20370
  if (allLabels) {
20378
20371
  for (let r = 1; r < table2.rows; r++) {
20379
20372
  for (let c = 0; c < table2.cols; c++) {
20380
- const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _168 => _168[c], 'optionalAccess', _169 => _169.text, 'access', _170 => _170.trim, 'call', _171 => _171()]), () => ( ""));
20381
- const value = _nullishCoalesce(_optionalChain([table2, 'access', _172 => _172.cells, 'access', _173 => _173[r], 'optionalAccess', _174 => _174[c], 'optionalAccess', _175 => _175.text, 'access', _176 => _176.trim, 'call', _177 => _177()]), () => ( ""));
20373
+ const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _169 => _169[c], 'optionalAccess', _170 => _170.text, 'access', _171 => _171.trim, 'call', _172 => _172()]), () => ( ""));
20374
+ const value = _nullishCoalesce(_optionalChain([table2, 'access', _173 => _173.cells, 'access', _174 => _174[r], 'optionalAccess', _175 => _175[c], 'optionalAccess', _176 => _176.text, 'access', _177 => _177.trim, 'call', _178 => _178()]), () => ( ""));
20382
20375
  if (label && value) {
20383
20376
  fields.push({ label, value, row: r, col: c });
20384
20377
  }
@@ -20471,7 +20464,7 @@ function fillFormFields(blocks, values, blockedLabels) {
20471
20464
  for (const table2 of allTables) {
20472
20465
  for (let r = 0; r < table2.rows; r++) {
20473
20466
  for (let c = 0; c < table2.cols; c++) {
20474
- const cell2 = _optionalChain([table2, 'access', _178 => _178.cells, 'access', _179 => _179[r], 'optionalAccess', _180 => _180[c]]);
20467
+ const cell2 = _optionalChain([table2, 'access', _179 => _179.cells, 'access', _180 => _180[r], 'optionalAccess', _181 => _181[c]]);
20475
20468
  if (!cell2) continue;
20476
20469
  const result = fillInCellPatterns(cell2.text, cursor, matchedLabels, blockedLabels);
20477
20470
  if (result) {
@@ -20503,7 +20496,7 @@ function collectIRTables(blocks, depth) {
20503
20496
  out.push(block.table);
20504
20497
  for (const row of block.table.cells) {
20505
20498
  for (const cell2 of row) {
20506
- if (_optionalChain([cell2, 'optionalAccess', _181 => _181.blocks, 'optionalAccess', _182 => _182.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
20499
+ if (_optionalChain([cell2, 'optionalAccess', _182 => _182.blocks, 'optionalAccess', _183 => _183.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
20507
20500
  }
20508
20501
  }
20509
20502
  }
@@ -20514,7 +20507,7 @@ function coveredPositions(table2) {
20514
20507
  for (let r = 0; r < table2.rows; r++) {
20515
20508
  for (let c = 0; c < table2.cols; c++) {
20516
20509
  if (covered.has(`${r},${c}`)) continue;
20517
- const cell2 = _optionalChain([table2, 'access', _183 => _183.cells, 'access', _184 => _184[r], 'optionalAccess', _185 => _185[c]]);
20510
+ const cell2 = _optionalChain([table2, 'access', _184 => _184.cells, 'access', _185 => _185[r], 'optionalAccess', _186 => _186[c]]);
20518
20511
  if (!cell2) continue;
20519
20512
  for (let dr = 0; dr < cell2.rowSpan; dr++) {
20520
20513
  for (let dc = 0; dc < cell2.colSpan; dc++) {
@@ -20544,12 +20537,12 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
20544
20537
  if (isKeywordLabel(valueCell.text)) continue;
20545
20538
  const normalizedCellLabel = normalizeLabel(labelCell.text);
20546
20539
  if (!normalizedCellLabel) continue;
20547
- if (_optionalChain([blockedLabels, 'optionalAccess', _186 => _186.has, 'call', _187 => _187(normalizedCellLabel)])) continue;
20540
+ if (_optionalChain([blockedLabels, 'optionalAccess', _187 => _187.has, 'call', _188 => _188(normalizedCellLabel)])) continue;
20548
20541
  const matchKey = findMatchingKey(normalizedCellLabel, values);
20549
20542
  if (matchKey === void 0) continue;
20550
20543
  const newValue = values.consume(matchKey);
20551
20544
  if (newValue === void 0) continue;
20552
- if (_optionalChain([patternFilledCells, 'optionalAccess', _188 => _188.has, 'call', _189 => _189(valueCell)])) {
20545
+ if (_optionalChain([patternFilledCells, 'optionalAccess', _189 => _189.has, 'call', _190 => _190(valueCell)])) {
20553
20546
  valueCell.text = newValue + " " + valueCell.text;
20554
20547
  } else {
20555
20548
  valueCell.text = newValue;
@@ -20575,10 +20568,10 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
20575
20568
  for (let c = 0; c < table2.cols; c++) {
20576
20569
  if (covered.has(`${r},${c}`)) continue;
20577
20570
  const headerCell = headerRow[c];
20578
- const valueCell = _optionalChain([table2, 'access', _190 => _190.cells, 'access', _191 => _191[r], 'optionalAccess', _192 => _192[c]]);
20571
+ const valueCell = _optionalChain([table2, 'access', _191 => _191.cells, 'access', _192 => _192[r], 'optionalAccess', _193 => _193[c]]);
20579
20572
  if (!headerCell || !valueCell) continue;
20580
20573
  const headerLabel = normalizeLabel(headerCell.text);
20581
- if (_optionalChain([blockedLabels, 'optionalAccess', _193 => _193.has, 'call', _194 => _194(headerLabel)])) continue;
20574
+ if (_optionalChain([blockedLabels, 'optionalAccess', _194 => _194.has, 'call', _195 => _195(headerLabel)])) continue;
20582
20575
  const matchKey = findMatchingKey(headerLabel, values);
20583
20576
  if (matchKey === void 0) continue;
20584
20577
  if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
@@ -20604,7 +20597,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
20604
20597
  let pos = 0;
20605
20598
  for (const seg of segments) {
20606
20599
  const nlabel = normalizeLabel(seg.label);
20607
- if (_optionalChain([blockedLabels, 'optionalAccess', _195 => _195.has, 'call', _196 => _196(nlabel)])) continue;
20600
+ if (_optionalChain([blockedLabels, 'optionalAccess', _196 => _196.has, 'call', _197 => _197(nlabel)])) continue;
20608
20601
  const matchKey = findMatchingKey(nlabel, values);
20609
20602
  if (matchKey === void 0) continue;
20610
20603
  const newValue = values.consume(matchKey);
@@ -21172,19 +21165,19 @@ function parseCentralDirectory(buf) {
21172
21165
  }
21173
21166
  }
21174
21167
  }
21175
- if (eocdOffset < 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
21168
+ if (eocdOffset < 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
21176
21169
  const totalEntries = view.getUint16(eocdOffset + 10, true);
21177
21170
  const cdSize = view.getUint32(eocdOffset + 12, true);
21178
21171
  const cdOffset = view.getUint32(eocdOffset + 16, true);
21179
- if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21172
+ if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21180
21173
  if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
21181
- throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21174
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21182
21175
  }
21183
21176
  const decoder = new TextDecoder("utf-8");
21184
21177
  const entries = [];
21185
21178
  let pos = cdOffset;
21186
21179
  for (let i = 0; i < totalEntries; i++) {
21187
- if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
21180
+ if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
21188
21181
  const flags = view.getUint16(pos + 8, true);
21189
21182
  const method = view.getUint16(pos + 10, true);
21190
21183
  const crc = view.getUint32(pos + 16, true);
@@ -21195,7 +21188,7 @@ function parseCentralDirectory(buf) {
21195
21188
  const commentLen = view.getUint16(pos + 32, true);
21196
21189
  const localOffset = view.getUint32(pos + 42, true);
21197
21190
  if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
21198
- throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21191
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21199
21192
  }
21200
21193
  const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
21201
21194
  const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
@@ -21204,7 +21197,7 @@ function parseCentralDirectory(buf) {
21204
21197
  }
21205
21198
  return { entries, cdOffset, cdSize, eocdOffset };
21206
21199
  }
21207
- var CRC_TABLE2 = (() => {
21200
+ var CRC_TABLE = (() => {
21208
21201
  const table2 = new Uint32Array(256);
21209
21202
  for (let n = 0; n < 256; n++) {
21210
21203
  let c = n;
@@ -21213,10 +21206,10 @@ var CRC_TABLE2 = (() => {
21213
21206
  }
21214
21207
  return table2;
21215
21208
  })();
21216
- function crc322(data) {
21209
+ function crc32(data) {
21217
21210
  let crc = 4294967295;
21218
21211
  for (let i = 0; i < data.length; i++) {
21219
- crc = CRC_TABLE2[(crc ^ data[i]) & 255] ^ crc >>> 8;
21212
+ crc = CRC_TABLE[(crc ^ data[i]) & 255] ^ crc >>> 8;
21220
21213
  }
21221
21214
  return (crc ^ 4294967295) >>> 0;
21222
21215
  }
@@ -21224,11 +21217,11 @@ function patchZipEntries(original, replacements, additions) {
21224
21217
  const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
21225
21218
  const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
21226
21219
  for (const name of replacements.keys()) {
21227
- if (!entries.some((e) => e.name === name)) throw new (0, _chunkDQJTNXVScjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
21220
+ if (!entries.some((e) => e.name === name)) throw new (0, _chunk6XAAYAWLcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
21228
21221
  }
21229
21222
  if (additions) {
21230
21223
  for (const name of additions.keys()) {
21231
- if (entries.some((e) => e.name === name)) throw new (0, _chunkDQJTNXVScjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
21224
+ if (entries.some((e) => e.name === name)) throw new (0, _chunk6XAAYAWLcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
21232
21225
  }
21233
21226
  }
21234
21227
  const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
@@ -21247,7 +21240,7 @@ function patchZipEntries(original, replacements, additions) {
21247
21240
  offset += seg.length;
21248
21241
  continue;
21249
21242
  }
21250
- if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
21243
+ if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
21251
21244
  const nameLen = view.getUint16(e.localOffset + 26, true);
21252
21245
  const extraLen = view.getUint16(e.localOffset + 28, true);
21253
21246
  const headerLen = 30 + nameLen + extraLen;
@@ -21255,7 +21248,7 @@ function patchZipEntries(original, replacements, additions) {
21255
21248
  const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
21256
21249
  const method = e.method;
21257
21250
  const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
21258
- const crc = crc322(newData);
21251
+ const crc = crc32(newData);
21259
21252
  const flags = e.flags & ~8;
21260
21253
  hview.setUint16(6, flags, true);
21261
21254
  hview.setUint32(14, crc, true);
@@ -21273,7 +21266,7 @@ function patchZipEntries(original, replacements, additions) {
21273
21266
  const deflated = new Uint8Array(_zlib.deflateRawSync.call(void 0, data));
21274
21267
  const method = deflated.length < data.length ? 8 : 0;
21275
21268
  const compData = method === 8 ? deflated : data;
21276
- const crc = crc322(data);
21269
+ const crc = crc32(data);
21277
21270
  const header = new Uint8Array(30 + nameBytes.length);
21278
21271
  const hv = new DataView(header.buffer);
21279
21272
  hv.setUint32(0, LOCAL_SIG, true);
@@ -21353,7 +21346,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21353
21346
  const zip = await _jszip2.default.loadAsync(hwpxBuffer);
21354
21347
  const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
21355
21348
  if (sectionPaths.length === 0) {
21356
- throw new (0, _chunkDQJTNXVScjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
21349
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
21357
21350
  }
21358
21351
  const normalizedValues = normalizeValues(values);
21359
21352
  const cursor = new ValueCursor(normalizedValues);
@@ -21426,7 +21419,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21426
21419
  if (isKeywordLabel(cellLabelText(valueCell))) continue;
21427
21420
  const normalizedCellLabel = normalizeLabel(labelText);
21428
21421
  if (!normalizedCellLabel) continue;
21429
- if (_optionalChain([blockedLabels, 'optionalAccess', _197 => _197.has, 'call', _198 => _198(normalizedCellLabel)])) continue;
21422
+ if (_optionalChain([blockedLabels, 'optionalAccess', _198 => _198.has, 'call', _199 => _199(normalizedCellLabel)])) continue;
21430
21423
  const matchKey = findMatchingKey(normalizedCellLabel, cursor);
21431
21424
  if (matchKey === void 0) continue;
21432
21425
  if (patternApplied.has(valueCell)) {
@@ -21484,7 +21477,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21484
21477
  const dataCells = table2.rows[rowIdx];
21485
21478
  for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
21486
21479
  const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
21487
- if (_optionalChain([blockedLabels, 'optionalAccess', _199 => _199.has, 'call', _200 => _200(headerLabel)])) continue;
21480
+ if (_optionalChain([blockedLabels, 'optionalAccess', _200 => _200.has, 'call', _201 => _201(headerLabel)])) continue;
21488
21481
  const matchKey = findMatchingKey(headerLabel, cursor);
21489
21482
  if (matchKey === void 0) continue;
21490
21483
  if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
@@ -21517,11 +21510,11 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21517
21510
  }
21518
21511
  for (const para2 of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
21519
21512
  const existing = ledger.get(para2);
21520
- if (_optionalChain([existing, 'optionalAccess', _201 => _201.fullText]) !== void 0) continue;
21513
+ if (_optionalChain([existing, 'optionalAccess', _202 => _202.fullText]) !== void 0) continue;
21521
21514
  const text = matchText(para2);
21522
21515
  for (const seg of scanInlineSegments(text)) {
21523
21516
  const nlabel = normalizeLabel(seg.label);
21524
- if (_optionalChain([blockedLabels, 'optionalAccess', _202 => _202.has, 'call', _203 => _203(nlabel)])) continue;
21517
+ if (_optionalChain([blockedLabels, 'optionalAccess', _203 => _203.has, 'call', _204 => _204(nlabel)])) continue;
21525
21518
  const matchKey = findMatchingKey(nlabel, cursor);
21526
21519
  if (matchKey === void 0) continue;
21527
21520
  const newValue = cursor.consume(matchKey);
@@ -21630,16 +21623,16 @@ var PARA_LIST = 7;
21630
21623
  var DEFAULT_TEXT_COLOR = "#000000";
21631
21624
  function resolveTheme(theme) {
21632
21625
  return {
21633
- h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _204 => _204.headingColors, 'optionalAccess', _205 => _205[1]]), () => ( DEFAULT_TEXT_COLOR)),
21634
- h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _206 => _206.headingColors, 'optionalAccess', _207 => _207[2]]), () => ( DEFAULT_TEXT_COLOR)),
21635
- h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _208 => _208.headingColors, 'optionalAccess', _209 => _209[3]]), () => ( DEFAULT_TEXT_COLOR)),
21636
- h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _210 => _210.headingColors, 'optionalAccess', _211 => _211[4]]), () => ( _optionalChain([theme, 'optionalAccess', _212 => _212.headingColors, 'optionalAccess', _213 => _213[3]]))), () => ( DEFAULT_TEXT_COLOR)),
21637
- body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _214 => _214.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
21638
- quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _215 => _215.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
21626
+ h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _205 => _205.headingColors, 'optionalAccess', _206 => _206[1]]), () => ( DEFAULT_TEXT_COLOR)),
21627
+ h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _207 => _207.headingColors, 'optionalAccess', _208 => _208[2]]), () => ( DEFAULT_TEXT_COLOR)),
21628
+ h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _209 => _209.headingColors, 'optionalAccess', _210 => _210[3]]), () => ( DEFAULT_TEXT_COLOR)),
21629
+ h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _211 => _211.headingColors, 'optionalAccess', _212 => _212[4]]), () => ( _optionalChain([theme, 'optionalAccess', _213 => _213.headingColors, 'optionalAccess', _214 => _214[3]]))), () => ( DEFAULT_TEXT_COLOR)),
21630
+ body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _215 => _215.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
21631
+ quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _216 => _216.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
21639
21632
  /** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
21640
- hasQuoteOption: _optionalChain([theme, 'optionalAccess', _216 => _216.quoteColor]) !== void 0,
21641
- tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _217 => _217.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _218 => _218.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
21642
- tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _219 => _219.tableHeaderBold])
21633
+ hasQuoteOption: _optionalChain([theme, 'optionalAccess', _217 => _217.quoteColor]) !== void 0,
21634
+ tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _218 => _218.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _219 => _219.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
21635
+ tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _220 => _220.tableHeaderBold])
21643
21636
  };
21644
21637
  }
21645
21638
  function escapeXml(text) {
@@ -22042,7 +22035,7 @@ function assertSequentialIds(rows, label, startId) {
22042
22035
  const m = rows[i].match(/\bid="(\d+)"/);
22043
22036
  const got = m ? Number(m[1]) : NaN;
22044
22037
  if (got !== startId + i) {
22045
- throw new (0, _chunkDQJTNXVScjs.KordocError)(
22038
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)(
22046
22039
  `\uB0B4\uBD80 \uC624\uB958: ${label} id \uD30C\uD2F0\uC158 \uB4DC\uB9AC\uD504\uD2B8 \u2014 ${startId + i} \uC704\uCE58\uC5D0 id=${m ? m[1] : "?"} \uBC29\uCD9C. id \uC0C1\uC218(gen-ids)\uC640 \uC2E4\uC81C \uBC29\uCD9C \uC218\uAC00 \uC5B4\uAE0B\uB0AC\uB2E4 (GJ_CHAR_COUNT\uB958 \uCE74\uC6B4\uD2B8\xB7base \uC0B0\uC220 \uD655\uC778)`
22047
22040
  );
22048
22041
  }
@@ -22126,7 +22119,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
22126
22119
  }
22127
22120
  const expectedBase = charVariantBase(richAssets, !!gongmun);
22128
22121
  if (rows.length !== expectedBase) {
22129
- throw new (0, _chunkDQJTNXVScjs.KordocError)(
22122
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)(
22130
22123
  `\uB0B4\uBD80 \uC624\uB958: charPr \uAE30\uBCF8 \uBE14\uB85D \uBC29\uCD9C \uC218(${rows.length}) \u2260 charVariantBase(${expectedBase}) \u2014 gen-header \uBC29\uCD9C \uD589\uACFC gen-ids \uCE74\uC6B4\uD2B8 \uC0C1\uC218\uAC00 \uC5B4\uAE0B\uB0AC\uB2E4`
22131
22124
  );
22132
22125
  }
@@ -22353,7 +22346,7 @@ function buildStyles(gongmun) {
22353
22346
  </hh:styles>`;
22354
22347
  }
22355
22348
  function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = [], listIndentVariants = [], extraFonts = []) {
22356
- const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _220 => _220.fonts, 'access', _221 => _221.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _222 => _222.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
22349
+ const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _221 => _221.fonts, 'access', _222 => _222.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _223 => _223.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
22357
22350
  const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
22358
22351
  const paraPropsXml = buildParaProperties(gongmun, gongmun ? listIndentVariants : []);
22359
22352
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
@@ -22482,8 +22475,8 @@ function parseChartFence(text) {
22482
22475
  const spec = chartSpec(type);
22483
22476
  let finalSeries = spec.pie ? [series[0]] : series;
22484
22477
  finalSeries = finalSeries.map((s) => ({ ...s }));
22485
- const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _223 => _223.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
22486
- const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _224 => _224[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
22478
+ const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _224 => _224.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
22479
+ const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _225 => _225[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
22487
22480
  if (!spec.scatter) {
22488
22481
  finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
22489
22482
  }
@@ -22525,7 +22518,7 @@ function serSpPr(color, stroke) {
22525
22518
  return stroke ? `<c:spPr><a:ln w="28575" cap="flat" cmpd="sng" algn="ctr">${f}<a:prstDash val="solid"/><a:round/></a:ln></c:spPr>` : `<c:spPr>${f}</c:spPr>`;
22526
22519
  }
22527
22520
  function dPtXml(pointColors, pie) {
22528
- if (!_optionalChain([pointColors, 'optionalAccess', _225 => _225.length])) return "";
22521
+ if (!_optionalChain([pointColors, 'optionalAccess', _226 => _226.length])) return "";
22529
22522
  return pointColors.map((col, i) => {
22530
22523
  const f = chartColorFill(col);
22531
22524
  if (!f) return "";
@@ -22764,8 +22757,8 @@ function buildGaejosikCover(title, gongmun, bodyWidth = GAEJOSIK_BASE_WIDTH) {
22764
22757
  const botRow = cell({ bf: GJ_BF_BAR_DARK, col: 0, row: 2, w: g.botDarkW, h: g.botBarH, paras: barEmpty }) + cell({ bf: GJ_BF_BAR_LIGHT, col: 1, colSpan: 2, row: 2, w: g.botLightW, h: g.botBarH, paras: barEmpty });
22765
22758
  const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3, 1, bodyWidth);
22766
22759
  const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
22767
- const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _226 => _226.cover, 'optionalAccess', _227 => _227.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
22768
- const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _228 => _228.cover, 'optionalAccess', _229 => _229.org]), () => ( ""));
22760
+ const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _227 => _227.cover, 'optionalAccess', _228 => _228.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
22761
+ const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _229 => _229.cover, 'optionalAccess', _230 => _230.org]), () => ( ""));
22769
22762
  const sub = (t) => `<hp:p paraPrIDRef="${GJ_PARA_COVER}" styleIDRef="0"><hp:run charPrIDRef="${GJ_CHAR_COVER_SUB}"><hp:t>${escapeXml(t)}</hp:t></hp:run></hp:p>`;
22770
22763
  const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
22771
22764
  return [
@@ -23001,7 +22994,7 @@ function escapeGfm(text) {
23001
22994
  }
23002
22995
  var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
23003
22996
  function sanitizeText(text) {
23004
- let result = _chunkDQJTNXVScjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
22997
+ let result = _chunk6XAAYAWLcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
23005
22998
  if (result.length <= 30 && result.includes(" ")) {
23006
22999
  const tokens = result.split(" ");
23007
23000
  const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-힯ㄱ-ㆎ]/.test(t)).length;
@@ -23031,7 +23024,7 @@ function replicateGfmTable(table2) {
23031
23024
  for (let r = 0; r < numRows; r++) {
23032
23025
  for (let c = 0; c < numCols; c++) {
23033
23026
  if (skip.has(`${r},${c}`)) continue;
23034
- const cell2 = _optionalChain([cells, 'access', _230 => _230[r], 'optionalAccess', _231 => _231[c]]);
23027
+ const cell2 = _optionalChain([cells, 'access', _231 => _231[r], 'optionalAccess', _232 => _232[c]]);
23035
23028
  if (!cell2) continue;
23036
23029
  display[r][c] = {
23037
23030
  text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
@@ -23085,7 +23078,7 @@ function unescapeGfmCell(text) {
23085
23078
  return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
23086
23079
  }
23087
23080
  function replicateCellInnerHtml(cell2) {
23088
- if (_optionalChain([cell2, 'access', _232 => _232.blocks, 'optionalAccess', _233 => _233.length])) {
23081
+ if (_optionalChain([cell2, 'access', _233 => _233.blocks, 'optionalAccess', _234 => _234.length])) {
23089
23082
  return cell2.blocks.map((b) => {
23090
23083
  if (b.type === "table" && b.table) {
23091
23084
  const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
@@ -23124,7 +23117,7 @@ function replicateHtmlTable(table2) {
23124
23117
  const rowCells = [];
23125
23118
  for (let c = 0; c < numCols; c++) {
23126
23119
  if (skip.has(`${r},${c}`)) continue;
23127
- const cell2 = _optionalChain([cells, 'access', _234 => _234[r], 'optionalAccess', _235 => _235[c]]);
23120
+ const cell2 = _optionalChain([cells, 'access', _235 => _235[r], 'optionalAccess', _236 => _236[c]]);
23128
23121
  if (!cell2) continue;
23129
23122
  for (let dr = 0; dr < cell2.rowSpan; dr++) {
23130
23123
  for (let dc = 0; dc < cell2.colSpan; dc++) {
@@ -23170,8 +23163,8 @@ function parseHtmlTable(raw) {
23170
23163
  }
23171
23164
  } else {
23172
23165
  if (!isClose) {
23173
- const cs = parseInt(_optionalChain([attrs, 'access', _236 => _236.match, 'call', _237 => _237(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _238 => _238[1]]) || "1", 10);
23174
- const rs = parseInt(_optionalChain([attrs, 'access', _239 => _239.match, 'call', _240 => _240(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _241 => _241[1]]) || "1", 10);
23166
+ const cs = parseInt(_optionalChain([attrs, 'access', _237 => _237.match, 'call', _238 => _238(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _239 => _239[1]]) || "1", 10);
23167
+ const rs = parseInt(_optionalChain([attrs, 'access', _240 => _240.match, 'call', _241 => _241(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _242 => _242[1]]) || "1", 10);
23175
23168
  cellStart = m.index + m[0].length;
23176
23169
  cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
23177
23170
  } else if (cellStart >= 0 && cellInfo && currentRow) {
@@ -23197,7 +23190,7 @@ function htmlCellInnerToLines(inner) {
23197
23190
  hadNonText = true;
23198
23191
  work = work.replace(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi, (tag) => {
23199
23192
  const m = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(tag);
23200
- const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _242 => _242[1]]), () => ( _optionalChain([m, 'optionalAccess', _243 => _243[2]])));
23193
+ const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _243 => _243[1]]), () => ( _optionalChain([m, 'optionalAccess', _244 => _244[2]])));
23201
23194
  if (src) imgSrcs.push(src);
23202
23195
  return "";
23203
23196
  });
@@ -23328,7 +23321,7 @@ function edgeXml(tag, d) {
23328
23321
  return d ? `<hh:${tag} type="${escapeXml(d.type)}" width="${escapeXml(d.width)}" color="${escapeXml(d.color)}"/>` : `<hh:${tag} type="NONE" width="0.1 mm" color="#000000"/>`;
23329
23322
  }
23330
23323
  function borderFillDefToXml(id, def) {
23331
- const fill = _optionalChain([def, 'access', _244 => _244.fill, 'optionalAccess', _245 => _245.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${escapeXml(def.fill.faceColor)}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
23324
+ const fill = _optionalChain([def, 'access', _245 => _245.fill, 'optionalAccess', _246 => _246.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${escapeXml(def.fill.faceColor)}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
23332
23325
  return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
23333
23326
  <hh:slash type="NONE" Crooked="0" isCounter="0"/>
23334
23327
  <hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
@@ -23733,11 +23726,11 @@ function estimateRowHeight(cells, widths, charHeight) {
23733
23726
  function generateTable(rows, theme, style = null, remap = null, seq = 0, images = null) {
23734
23727
  const rowCnt = rows.length;
23735
23728
  const colCnt = Math.max(...rows.map((r) => r.length), 1);
23736
- const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _246 => _246.bfRegistry]), () => ( null));
23729
+ const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _247 => _247.bfRegistry]), () => ( null));
23737
23730
  const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
23738
- const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _247 => _247.charHeight]), () => ( 1e3));
23731
+ const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _248 => _248.charHeight]), () => ( 1e3));
23739
23732
  const rowAnchor = normalizeRowAnchor((_nullishCoalesce(rows[0], () => ( []))).map((c) => c.replace(/!\[[^\]]*\]\([^)]*\)/g, "")));
23740
- const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _248 => _248[0], 'optionalAccess', _249 => _249[0]]), () => ( ""))), seq, rowAnchor);
23733
+ const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _249 => _249[0], 'optionalAccess', _250 => _250[0]]), () => ( ""))), seq, rowAnchor);
23741
23734
  const colMax = Array(colCnt).fill(0);
23742
23735
  const colMaxBody = Array(colCnt).fill(0);
23743
23736
  const colMinWord = Array(colCnt).fill(0);
@@ -23765,7 +23758,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
23765
23758
  const k = `${rowIdx},${colIdx}`;
23766
23759
  const isLabelCell2 = labelCol0 && colIdx === 0;
23767
23760
  const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
23768
- const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _250 => _250.cellChar, 'access', _251 => _251.get, 'call', _252 => _252(k)]), () => ( defaultCharPr));
23761
+ const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _251 => _251.cellChar, 'access', _252 => _252.get, 'call', _253 => _253(k)]), () => ( defaultCharPr));
23769
23762
  const centered = isHeaderRow || colCentered[colIdx];
23770
23763
  const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
23771
23764
  const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
@@ -23783,11 +23776,11 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
23783
23776
  }
23784
23777
  }
23785
23778
  }
23786
- const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _253 => _253.cellChar, 'access', _254 => _254.has, 'call', _255 => _255(k)]) ? void 0 : mapId);
23779
+ const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _254 => _254.cellChar, 'access', _255 => _255.has, 'call', _256 => _256(k)]) ? void 0 : mapId);
23787
23780
  const body = (runs || (picRuns ? "" : `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`)) + picRuns;
23788
23781
  return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${body}</hp:p>`;
23789
23782
  }).join("");
23790
- const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _256 => _256.cellBf, 'access', _257 => _257.get, 'call', _258 => _258(k)]), () => ( (reg ? reg.get(dataCellSpec({
23783
+ const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _257 => _257.cellBf, 'access', _258 => _258.get, 'call', _259 => _259(k)]), () => ( (reg ? reg.get(dataCellSpec({
23791
23784
  row: rowIdx,
23792
23785
  rowEnd: rowIdx,
23793
23786
  col: colIdx,
@@ -23797,7 +23790,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
23797
23790
  headerRows: 1,
23798
23791
  fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
23799
23792
  })) : style && isHeaderRow ? style.headerBf : 2)));
23800
- const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _259 => _259.cellH, 'access', _260 => _260.get, 'call', _261 => _261(k)]), () => ( cellH));
23793
+ const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _260 => _260.cellH, 'access', _261 => _261.get, 'call', _262 => _262(k)]), () => ( cellH));
23801
23794
  return `<hp:tc name="" header="${isHeaderRow ? 1 : 0}" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="${bf}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="${style ? "CENTER" : "TOP"}" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${p}</hp:subList><hp:cellAddr colAddr="${colIdx}" rowAddr="${rowIdx}"/><hp:cellSpan colSpan="1" rowSpan="1"/><hp:cellSz width="${colWidths[colIdx]}" height="${h}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
23802
23795
  }).join("");
23803
23796
  return `<hp:tr>${tdElements}</hp:tr>`;
@@ -23806,7 +23799,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
23806
23799
  const tblH = rowHeights.reduce((a, b) => a + b, 0);
23807
23800
  const tblInner = `<hp:sz width="${tblW}" widthRelTo="ABSOLUTE" height="${tblH}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="0" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:inMargin left="510" right="510" top="141" bottom="141"/>` + trElements;
23808
23801
  const tbl2 = `<hp:tbl id="${tblId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="${style ? 1 : 0}" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="2" noShading="0">${tblInner}</hp:tbl>`;
23809
- const hostPr = reg && _optionalChain([style, 'optionalAccess', _262 => _262.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
23802
+ const hostPr = reg && _optionalChain([style, 'optionalAccess', _263 => _263.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
23810
23803
  return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
23811
23804
  }
23812
23805
  function layoutHtmlRows(rows) {
@@ -23846,7 +23839,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23846
23839
  if (!rows || rows.length === 0) return null;
23847
23840
  const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
23848
23841
  if (rowCnt === 0 || colCnt === 0) return null;
23849
- const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _263 => _263.charHeight]), () => ( 1e3));
23842
+ const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _264 => _264.charHeight]), () => ( 1e3));
23850
23843
  const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
23851
23844
  const row0 = Array.from({ length: colCnt }, () => "");
23852
23845
  for (const cell2 of placed) {
@@ -23875,7 +23868,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23875
23868
  const tblId = nextTableId();
23876
23869
  const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
23877
23870
  const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
23878
- const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _264 => _264.bfRegistry]), () => ( null));
23871
+ const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _265 => _265.bfRegistry]), () => ( null));
23879
23872
  let htmlHeaderRows = 0;
23880
23873
  while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
23881
23874
  const tableRowHeights = Array(rowCnt).fill(cellH);
@@ -23890,7 +23883,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23890
23883
  const nestedXml = generateHtmlTableXml(nested, theme, nestedW, style ? { ...style, totalWidth: nestedW } : null);
23891
23884
  if (nestedXml) {
23892
23885
  nestedXmls.push(nestedXml);
23893
- const szH = _optionalChain([nestedXml, 'access', _265 => _265.match, 'call', _266 => _266(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _267 => _267[1]]);
23886
+ const szH = _optionalChain([nestedXml, 'access', _266 => _266.match, 'call', _267 => _267(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _268 => _268[1]]);
23894
23887
  nestedH += (szH ? Number(szH) : (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH) + 300;
23895
23888
  }
23896
23889
  }
@@ -23899,7 +23892,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23899
23892
  for (const line of lines) wrapLines += Math.max(1, Math.ceil(measureTextWidth(unescapeHtml(line).trim(), measureH, 100) / usable));
23900
23893
  const lineH = style ? Math.round(measureH * 1.6) : 800;
23901
23894
  const contentH = Math.max(cellH * rowSpan, Math.max(wrapLines, 1) * lineH + nestedH);
23902
- const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _268 => _268.cellH, 'access', _269 => _269.get, 'call', _270 => _270(`${cell2.r},${cell2.c}`)]), () => ( 0)), contentH);
23895
+ const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _269 => _269.cellH, 'access', _270 => _270.get, 'call', _271 => _271(`${cell2.r},${cell2.c}`)]), () => ( 0)), contentH);
23903
23896
  const perRow = Math.ceil(cellHeight / rowSpan);
23904
23897
  for (let r = cell2.r; r < cell2.r + rowSpan; r++) tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
23905
23898
  return { cell: cell2, rowSpan, lines, nestedXmls, imgSrcs: cellParsed[i].imgSrcs };
@@ -23910,7 +23903,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23910
23903
  const baseCharPr = style ? style.charPr : CHAR_NORMAL;
23911
23904
  const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
23912
23905
  const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
23913
- const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _271 => _271.cellChar, 'access', _272 => _272.get, 'call', _273 => _273(k)]), () => ( defaultCharPr));
23906
+ const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _272 => _272.cellChar, 'access', _273 => _273.get, 'call', _274 => _274(k)]), () => ( defaultCharPr));
23914
23907
  const centered = isHeader || colCentered[cell2.c];
23915
23908
  const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
23916
23909
  const picUrls = images ? [...imgSrcs] : [];
@@ -23946,7 +23939,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23946
23939
  let cellHeight = 0;
23947
23940
  for (let r = cell2.r; r < cell2.r + rowSpan; r++) cellHeight += tableRowHeights[r];
23948
23941
  const rowEnd = cell2.r + rowSpan - 1;
23949
- const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _274 => _274.cellBf, 'access', _275 => _275.get, 'call', _276 => _276(k)]), () => ( (reg ? reg.get(dataCellSpec({
23942
+ const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _275 => _275.cellBf, 'access', _276 => _276.get, 'call', _277 => _277(k)]), () => ( (reg ? reg.get(dataCellSpec({
23950
23943
  row: cell2.r,
23951
23944
  rowEnd,
23952
23945
  col: cell2.c,
@@ -24116,7 +24109,7 @@ function buildPressHead(g, ids, bodyWidth, reg) {
24116
24109
  return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
24117
24110
  }
24118
24111
  function buildPressContact(g, ids, bodyWidth, reg) {
24119
- const c = _optionalChain([g, 'access', _277 => _277.press, 'optionalAccess', _278 => _278.contact]);
24112
+ const c = _optionalChain([g, 'access', _278 => _278.press, 'optionalAccess', _279 => _279.contact]);
24120
24113
  if (!c || !c.dept && !c.manager && !c.phone) return [];
24121
24114
  const w = bodyWidth - 280;
24122
24115
  const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
@@ -24497,7 +24490,7 @@ function generateSecPr(gongmun) {
24497
24490
  }
24498
24491
  const secPr = `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="1" memoShapeIDRef="0" textVerticalWidthHead="0" masterPageCnt="0"><hp:grid lineGrid="0" charGrid="0" wonggojiFormat="0"/><hp:startNum pageStartsOn="BOTH" page="0" pic="0" tbl="0" equation="0"/><hp:visibility hideFirstHeader="0" hideFirstFooter="0" hideFirstMasterPage="0" border="SHOW_ALL" fill="SHOW_ALL" hideFirstPageNum="0" hideFirstEmptyLine="0" showLineNumber="0"/><hp:pagePr landscape="WIDELY" width="${A4_W_HU}" height="${A4_H_HU}" gutterType="LEFT_ONLY"><hp:margin header="${m.header}" footer="${m.footer}" gutter="0" left="${m.left}" right="${m.right}" top="${m.top}" bottom="${m.bottom}"/></hp:pagePr><hp:footNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="-1" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="283" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="EACH_COLUMN" beneathText="0"/></hp:footNotePr><hp:endNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="14692344" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="0" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="END_OF_DOCUMENT" beneathText="0"/></hp:endNotePr></hp:secPr>`;
24499
24492
  const colPr = `<hp:ctrl><hp:colPr id="" type="NEWSPAPER" layout="LEFT" colCount="1" sameSz="1" sameGap="0"/></hp:ctrl>`;
24500
- return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _279 => _279.pageNumbers]) ? pageNumCtrl() : "");
24493
+ return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _280 => _280.pageNumbers]) ? pageNumCtrl() : "");
24501
24494
  }
24502
24495
  var SectionOpener = (_class6 = class {
24503
24496
  constructor(gongmun) {;_class6.prototype.__init12.call(this);
@@ -24536,19 +24529,19 @@ function buildPreamble(blocks, ctx) {
24536
24529
  const { gongmun, dfIds, bfReg, tableStyle, richAssets, gjBodyW } = ctx;
24537
24530
  const preamble = [];
24538
24531
  let hasFrontPages = false;
24539
- if (_optionalChain([gongmun, 'optionalAccess', _280 => _280.reportInfo]) && dfIds) {
24532
+ if (_optionalChain([gongmun, 'optionalAccess', _281 => _281.reportInfo]) && dfIds) {
24540
24533
  preamble.push(buildReportInfo(gongmun, dfIds));
24541
24534
  }
24542
- if (_optionalChain([gongmun, 'optionalAccess', _281 => _281.approval]) && bfReg) {
24535
+ if (_optionalChain([gongmun, 'optionalAccess', _282 => _282.approval]) && bfReg) {
24543
24536
  preamble.push(buildApprovalTable(gongmun.approval, bfReg, richAssets ? GJ_CHAR_APPROVAL : GONGMUN_APPROVAL_CHAR));
24544
24537
  }
24545
- if (_optionalChain([gongmun, 'optionalAccess', _282 => _282.docHead]) && dfIds) {
24538
+ if (_optionalChain([gongmun, 'optionalAccess', _283 => _283.docHead]) && dfIds) {
24546
24539
  preamble.push(...buildDocHead(gongmun, dfIds));
24547
24540
  }
24548
- if (_optionalChain([gongmun, 'optionalAccess', _283 => _283.noticeHead]) && dfIds) {
24541
+ if (_optionalChain([gongmun, 'optionalAccess', _284 => _284.noticeHead]) && dfIds) {
24549
24542
  preamble.push(...buildNoticeHead(gongmun));
24550
24543
  }
24551
- if (_optionalChain([gongmun, 'optionalAccess', _284 => _284.press]) && dfIds && bfReg && tableStyle) {
24544
+ if (_optionalChain([gongmun, 'optionalAccess', _285 => _285.press]) && dfIds && bfReg && tableStyle) {
24552
24545
  preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
24553
24546
  }
24554
24547
  if (gongmun && (gongmun.cover || gongmun.toc)) {
@@ -24577,7 +24570,7 @@ function buildPreamble(blocks, ctx) {
24577
24570
  }
24578
24571
  if (gongmun && !ctx.gaejosik && ctx.coverH1Idx < 0 && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
24579
24572
  ctx.titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
24580
- } else if (_optionalChain([gongmun, 'optionalAccess', _285 => _285.press]) && ctx.coverH1Idx < 0 && dfIds) {
24573
+ } else if (_optionalChain([gongmun, 'optionalAccess', _286 => _286.press]) && ctx.coverH1Idx < 0 && dfIds) {
24581
24574
  ctx.pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
24582
24575
  }
24583
24576
  if (preamble.length > 0) {
@@ -24592,7 +24585,7 @@ function renderHeading(block, blockIdx, ctx) {
24592
24585
  if (gongmun && blockIdx === ctx.coverH1Idx) return "";
24593
24586
  if (gongmun && blockIdx === ctx.pressH1Idx && dfIds) {
24594
24587
  const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
24595
- for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _286 => _286.press, 'optionalAccess', _287 => _287.sub]), () => ( []))) {
24588
+ for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _287 => _287.press, 'optionalAccess', _288 => _288.sub]), () => ( []))) {
24596
24589
  parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
24597
24590
  }
24598
24591
  return parts.join("\n ");
@@ -24686,8 +24679,8 @@ function renderListItem(block, blockIdx, ctx) {
24686
24679
  const { gongmun, gongmunList, measured, fit, vBase, dfIds } = ctx;
24687
24680
  if (gongmun && gongmunList) {
24688
24681
  const info = gongmunList.items.get(blockIdx);
24689
- const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _288 => _288.depth]), () => ( 0));
24690
- const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _289 => _289.marker]), () => ( ""));
24682
+ const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _289 => _289.depth]), () => ( 0));
24683
+ const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _290 => _290.marker]), () => ( ""));
24691
24684
  const content = block.text || "";
24692
24685
  if (measured && content.trimStart().startsWith("\u203B")) {
24693
24686
  return generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
@@ -24696,7 +24689,7 @@ function renderListItem(block, blockIdx, ctx) {
24696
24689
  return generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
24697
24690
  }
24698
24691
  const text = marker2 ? `${marker2} ${content}` : content;
24699
- const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess', _290 => _290.indentVariant]) !== void 0 ? GONGMUN_LIST_VARIANT_BASE + info.indentVariant : GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
24692
+ const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess', _291 => _291.indentVariant]) !== void 0 ? GONGMUN_LIST_VARIANT_BASE + info.indentVariant : GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
24700
24693
  let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
24701
24694
  let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
24702
24695
  if (measured && depth === 0 && gongmun.numbering !== "standard") {
@@ -24755,18 +24748,18 @@ function renderHtmlTable(block, ctx) {
24755
24748
  }
24756
24749
  function appendPostamble(blocks, ctx) {
24757
24750
  const { gongmun, dfIds, bfReg, tableStyle, paraXmls } = ctx;
24758
- if (_optionalChain([gongmun, 'optionalAccess', _291 => _291.noticeHead]) && dfIds) {
24751
+ if (_optionalChain([gongmun, 'optionalAccess', _292 => _292.noticeHead]) && dfIds) {
24759
24752
  paraXmls.push(...buildNoticeFoot(gongmun));
24760
24753
  }
24761
- if (_optionalChain([gongmun, 'optionalAccess', _292 => _292.endMark]) && paraXmls.length > 0) {
24762
- const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access', _293 => _293.rows, 'optionalAccess', _294 => _294.length]));
24754
+ if (_optionalChain([gongmun, 'optionalAccess', _293 => _293.endMark]) && paraXmls.length > 0) {
24755
+ const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access', _294 => _294.rows, 'optionalAccess', _295 => _295.length]));
24763
24756
  const lastText = lastBlock && (lastBlock.type === "paragraph" || lastBlock.type === "list_item") ? lastBlock.text || "" : "";
24764
24757
  if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
24765
24758
  }
24766
- if (_optionalChain([gongmun, 'optionalAccess', _295 => _295.docFoot]) && dfIds) {
24759
+ if (_optionalChain([gongmun, 'optionalAccess', _296 => _296.docFoot]) && dfIds) {
24767
24760
  paraXmls.push(...buildDocFoot(gongmun, dfIds));
24768
24761
  }
24769
- if (_optionalChain([gongmun, 'optionalAccess', _296 => _296.press]) && dfIds && bfReg && tableStyle) {
24762
+ if (_optionalChain([gongmun, 'optionalAccess', _297 => _297.press]) && dfIds && bfReg && tableStyle) {
24770
24763
  paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
24771
24764
  }
24772
24765
  }
@@ -24786,7 +24779,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
24786
24779
  remap,
24787
24780
  dfIds,
24788
24781
  images,
24789
- gaejosik: _optionalChain([gongmun, 'optionalAccess', _297 => _297.preset]) === "gaejosik",
24782
+ gaejosik: _optionalChain([gongmun, 'optionalAccess', _298 => _298.preset]) === "gaejosik",
24790
24783
  measured,
24791
24784
  richAssets,
24792
24785
  vBase: charVariantBase(richAssets, !!gongmun),
@@ -24892,18 +24885,18 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
24892
24885
 
24893
24886
  // src/hwpx/generator.ts
24894
24887
  async function markdownToHwpx(markdown, options) {
24895
- const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _298 => _298.theme]));
24896
- const gongmun = _optionalChain([options, 'optionalAccess', _299 => _299.gongmun]) ? resolveGongmun(options.gongmun) : null;
24888
+ const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _299 => _299.theme]));
24889
+ const gongmun = _optionalChain([options, 'optionalAccess', _300 => _300.gongmun]) ? resolveGongmun(options.gongmun) : null;
24897
24890
  const measured = !!gongmun && usesReportFonts(gongmun.preset);
24898
24891
  const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
24899
24892
  const blocks = parseMarkdownToBlocks(markdown);
24900
24893
  const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
24901
24894
  const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
24902
24895
  const staticBfEnd = staticBorderFillNext(gongmun);
24903
- const remap = _optionalChain([options, 'optionalAccess', _300 => _300.profile]) ? buildProfileRemap(options.profile, charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _301 => _301.variants, 'optionalAccess', _302 => _302.length]), () => ( 0))) * 4, staticBfEnd, staticFontNext(gongmun)) : null;
24904
- const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _303 => _303.borderFillXmls, 'access', _304 => _304.length]), () => ( 0)))) : null;
24896
+ const remap = _optionalChain([options, 'optionalAccess', _301 => _301.profile]) ? buildProfileRemap(options.profile, charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _302 => _302.variants, 'optionalAccess', _303 => _303.length]), () => ( 0))) * 4, staticBfEnd, staticFontNext(gongmun)) : null;
24897
+ const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _304 => _304.borderFillXmls, 'access', _305 => _305.length]), () => ( 0)))) : null;
24905
24898
  const dfActive = !!gongmun && docframeActive(gongmun);
24906
- const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _305 => _305.variants, 'optionalAccess', _306 => _306.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _307 => _307.charPrXmls, 'access', _308 => _308.length]), () => ( 0)));
24899
+ const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _306 => _306.variants, 'optionalAccess', _307 => _307.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _308 => _308.charPrXmls, 'access', _309 => _309.length]), () => ( 0)));
24907
24900
  const dfIds = dfActive ? docframeIds(dfBase) : null;
24908
24901
  const chartParts = [];
24909
24902
  const images = new ImageRegistry();
@@ -24914,7 +24907,7 @@ async function markdownToHwpx(markdown, options) {
24914
24907
  console.warn(`[kordoc] format profile: \uD504\uB85C\uD544 \uD45C ${unused}\uAC1C\uAC00 \uBB38\uC11C \uD45C\uC640 \uB9E4\uCE6D\uB418\uC9C0 \uC54A\uC544 \uBBF8\uC801\uC6A9 (\uD589\xB7\uC5F4/\uCCAB \uC140 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)`);
24915
24908
  }
24916
24909
  }
24917
- const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _309 => _309.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _310 => _310.emit, 'call', _311 => _311()]), () => ( []))];
24910
+ const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _310 => _310.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _311 => _311.emit, 'call', _312 => _312()]), () => ( []))];
24918
24911
  const zip = new (0, _jszip2.default)();
24919
24912
  zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
24920
24913
  zip.file("META-INF/container.xml", generateContainerXml());
@@ -24923,11 +24916,11 @@ async function markdownToHwpx(markdown, options) {
24923
24916
  zip.file("Contents/header.xml", generateHeaderXml(
24924
24917
  theme,
24925
24918
  gongmun,
24926
- _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _312 => _312.variants]), () => ( [])),
24919
+ _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _313 => _313.variants]), () => ( [])),
24927
24920
  extraBorderFills,
24928
- [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _313 => _313.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, richAssets) : []],
24929
- _nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess', _314 => _314.indentVariants]), () => ( [])),
24930
- _nullishCoalesce(_optionalChain([remap, 'optionalAccess', _315 => _315.fontFaces]), () => ( []))
24921
+ [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _314 => _314.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, richAssets) : []],
24922
+ _nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess', _315 => _315.indentVariants]), () => ( [])),
24923
+ _nullishCoalesce(_optionalChain([remap, 'optionalAccess', _316 => _316.fontFaces]), () => ( []))
24931
24924
  ));
24932
24925
  zip.file("Contents/section0.xml", sectionXml);
24933
24926
  for (const part of chartParts) zip.file(part.name, part.xml);
@@ -25222,7 +25215,7 @@ function parseRenderStyles(headXml) {
25222
25215
  const underlineEl = findChildByLocalName(el, "underline");
25223
25216
  const textColor = el.getAttribute("textColor");
25224
25217
  const fontRef = findChildByLocalName(el, "fontRef");
25225
- const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _316 => _316.getAttribute, 'call', _317 => _317("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _318 => _318.getAttribute, 'call', _319 => _319("latin")])));
25218
+ const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _317 => _317.getAttribute, 'call', _318 => _318("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _319 => _319.getAttribute, 'call', _320 => _320("latin")])));
25226
25219
  const face = fontId != null ? hangulFonts.get(fontId) : void 0;
25227
25220
  styles.charPr.set(id, {
25228
25221
  height: Number(el.getAttribute("height")) || 1e3,
@@ -25230,8 +25223,8 @@ function parseRenderStyles(headXml) {
25230
25223
  italic: findChildByLocalName(el, "italic") != null,
25231
25224
  underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
25232
25225
  color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
25233
- ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _320 => _320.getAttribute, 'call', _321 => _321("hangul")])) || 100,
25234
- spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _322 => _322.getAttribute, 'call', _323 => _323("hangul")])) || 0,
25226
+ ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _321 => _321.getAttribute, 'call', _322 => _322("hangul")])) || 100,
25227
+ spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _323 => _323.getAttribute, 'call', _324 => _324("hangul")])) || 0,
25235
25228
  fontFamily: face ? hwpFaceToCssStack(face) : void 0,
25236
25229
  face
25237
25230
  });
@@ -25240,7 +25233,7 @@ function parseRenderStyles(headXml) {
25240
25233
  const id = el.getAttribute("id");
25241
25234
  if (id != null) {
25242
25235
  const align = findChildByLocalName(el, "align");
25243
- styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _324 => _324.getAttribute, 'call', _325 => _325("horizontal")]) || "JUSTIFY");
25236
+ styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _325 => _325.getAttribute, 'call', _326 => _326("horizontal")]) || "JUSTIFY");
25244
25237
  styles.paraGeom.set(id, parseParaGeom(el));
25245
25238
  }
25246
25239
  } else if (tag === "borderFill") {
@@ -25254,7 +25247,7 @@ function parseRenderStyles(headXml) {
25254
25247
  };
25255
25248
  const fillBrush = findChildByLocalName(el, "fillBrush");
25256
25249
  const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
25257
- const face = _optionalChain([winBrush, 'optionalAccess', _326 => _326.getAttribute, 'call', _327 => _327("faceColor")]);
25250
+ const face = _optionalChain([winBrush, 'optionalAccess', _327 => _327.getAttribute, 'call', _328 => _328("faceColor")]);
25258
25251
  if (face && face.toLowerCase() !== "none") bf.fill = face;
25259
25252
  styles.borderFill.set(id, bf);
25260
25253
  }
@@ -25326,7 +25319,7 @@ function collectSites(scan) {
25326
25319
  }
25327
25320
  function attrOf(openTag, name) {
25328
25321
  const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
25329
- return _optionalChain([m, 'optionalAccess', _328 => _328[1]]);
25322
+ return _optionalChain([m, 'optionalAccess', _329 => _329[1]]);
25330
25323
  }
25331
25324
  function paraOpenTag(xml, para2) {
25332
25325
  const end = xml.indexOf(">", para2.start);
@@ -25341,7 +25334,7 @@ function anchorRunInfo(xml, para2, anchor) {
25341
25334
  if (!tr) return null;
25342
25335
  const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
25343
25336
  const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
25344
- const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _329 => _329[1]]), () => ( tr.prefix)), () => ( "hp"));
25337
+ const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _330 => _330[1]]), () => ( tr.prefix)), () => ( "hp"));
25345
25338
  const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
25346
25339
  const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
25347
25340
  if (close === -1) return null;
@@ -25368,7 +25361,7 @@ function cellContentWidthMm(xml, cell2) {
25368
25361
  if (width === null) return null;
25369
25362
  let content = width;
25370
25363
  const win = cellAddrWindow(xml, cell2);
25371
- const mg = _optionalChain([win, 'optionalAccess', _330 => _330.match, 'call', _331 => _331(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
25364
+ const mg = _optionalChain([win, 'optionalAccess', _331 => _331.match, 'call', _332 => _332(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
25372
25365
  if (mg) {
25373
25366
  content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
25374
25367
  }
@@ -25402,11 +25395,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
25402
25395
  return `<hp:pic xmlns:hc="http://www.hancom.co.kr/hwpml/2011/core" id="${ids.id}" zOrder="0" numberingType="PICTURE" textWrap="IN_FRONT_OF_TEXT" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" href="" groupLevel="0" instid="${ids.instid}" reverse="0"><hp:offset x="0" y="0"/><hp:orgSz width="${w}" height="${h}"/><hp:curSz width="${w}" height="${h}"/><hp:flip horizontal="0" vertical="0"/><hp:rotationInfo angle="0" centerX="${Math.round(w / 2)}" centerY="${Math.round(h / 2)}" rotateimage="1"/><hp:renderingInfo><hc:transMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:scaMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:rotMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/></hp:renderingInfo><hp:imgRect><hc:pt0 x="0" y="0"/><hc:pt1 x="${w}" y="0"/><hc:pt2 x="${w}" y="${h}"/><hc:pt3 x="0" y="${h}"/></hp:imgRect><hp:imgClip left="0" right="${w}" top="0" bottom="${h}"/><hp:inMargin left="0" right="0" top="0" bottom="0"/><hp:imgDim dimwidth="${w}" dimheight="${h}"/><hc:img binaryItemIDRef="${itemId}" bright="0" contrast="0" effect="REAL_PIC" alpha="0"/><hp:effects/><hp:sz width="${w}" widthRelTo="ABSOLUTE" height="${h}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="0" affectLSpacing="0" flowWithText="0" allowOverlap="1" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="COLUMN" vertAlign="TOP" horzAlign="LEFT" vertOffset="${posYHu}" horzOffset="${posXHu}"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:shapeComment>kordoc seal</hp:shapeComment></hp:pic>`;
25403
25396
  }
25404
25397
  async function placeSealHwpx(hwpxBuffer, ops) {
25405
- if (ops.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
25398
+ if (ops.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
25406
25399
  const u8 = new Uint8Array(hwpxBuffer);
25407
25400
  const zip = await _jszip2.default.loadAsync(hwpxBuffer);
25408
- const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _332 => _332.match, 'call', _333 => _333(/(\d+)\.xml$/i), 'optionalAccess', _334 => _334[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _335 => _335.match, 'call', _336 => _336(/(\d+)\.xml$/i), 'optionalAccess', _337 => _337[1]]), () => ( 0))));
25409
- if (sectionPaths.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
25401
+ const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _333 => _333.match, 'call', _334 => _334(/(\d+)\.xml$/i), 'optionalAccess', _335 => _335[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _336 => _336.match, 'call', _337 => _337(/(\d+)\.xml$/i), 'optionalAccess', _338 => _338[1]]), () => ( 0))));
25402
+ if (sectionPaths.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
25410
25403
  const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
25411
25404
  const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
25412
25405
  const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
@@ -25447,11 +25440,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
25447
25440
  const manifestItems = [];
25448
25441
  const placed = [];
25449
25442
  for (const op of ops) {
25450
- if (!op.anchor) throw new (0, _chunkDQJTNXVScjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
25451
- if (!op.image || op.image.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
25443
+ if (!op.anchor) throw new (0, _chunk6XAAYAWLcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
25444
+ if (!op.image || op.image.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
25452
25445
  const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
25453
- if (!MIME[ext]) throw new (0, _chunkDQJTNXVScjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
25454
- if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkDQJTNXVScjs.KordocError)(`place_seal: \uC774\uBBF8\uC9C0 \uB0B4\uC6A9\uC774 .${ext} \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 (\uB9E4\uC9C1\uBC14\uC774\uD2B8 \uBD88\uC77C\uCE58)`);
25446
+ if (!MIME[ext]) throw new (0, _chunk6XAAYAWLcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
25447
+ if (!imageMagicMatches(op.image, ext)) throw new (0, _chunk6XAAYAWLcjs.KordocError)(`place_seal: \uC774\uBBF8\uC9C0 \uB0B4\uC6A9\uC774 .${ext} \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 (\uB9E4\uC9C1\uBC14\uC774\uD2B8 \uBD88\uC77C\uCE58)`);
25455
25448
  const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
25456
25449
  let found = null;
25457
25450
  let total = 0;
@@ -25484,7 +25477,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
25484
25477
  }
25485
25478
  }
25486
25479
  }
25487
- throw new (0, _chunkDQJTNXVScjs.KordocError)(
25480
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)(
25488
25481
  `place_seal: \uC575\uCEE4 "${op.anchor}" ${wantOcc}\uBC88\uC9F8 \uB4F1\uC7A5\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (\uBCF8\uBB38 \uB0B4 ${total}\uD68C \uB4F1\uC7A5 \u2014 occurrence 0..${Math.max(0, total - 1)})`
25489
25482
  );
25490
25483
  }
@@ -25492,9 +25485,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
25492
25485
  const xml = sectionXmls[si];
25493
25486
  const run = anchorRunInfo(xml, site.para, op.anchor);
25494
25487
  if (!run) {
25495
- throw new (0, _chunkDQJTNXVScjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
25488
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
25496
25489
  }
25497
- const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _338 => _338.charPr, 'access', _339 => _339.get, 'call', _340 => _340(run.charPr), 'optionalAccess', _341 => _341.height]), () => ( 1e3));
25490
+ const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _339 => _339.charPr, 'access', _340 => _340.get, 'call', _341 => _341(run.charPr), 'optionalAccess', _342 => _342.height]), () => ( 1e3));
25498
25491
  const fontPt = charPrHeight / 100;
25499
25492
  const emMm = fontPt * 25.4 / 72;
25500
25493
  const lineHMm = emMm;
@@ -25503,7 +25496,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
25503
25496
  const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
25504
25497
  const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
25505
25498
  const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
25506
- const align = _optionalChain([styles, 'optionalAccess', _342 => _342.paraAlign, 'access', _343 => _343.get, 'call', _344 => _344(paraPrId)]);
25499
+ const align = _optionalChain([styles, 'optionalAccess', _343 => _343.paraAlign, 'access', _344 => _344.get, 'call', _345 => _345(paraPrId)]);
25507
25500
  let alignShiftMm = 0;
25508
25501
  if (align === "CENTER" || align === "RIGHT") {
25509
25502
  const paraWMm = measureMm(site.para.text, emMm);
@@ -25599,7 +25592,7 @@ function parseBorderFills(headerDoc) {
25599
25592
  };
25600
25593
  const fillBrush = findChildByLocalName(bf, "fillBrush");
25601
25594
  const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
25602
- const face = _optionalChain([winBrush, 'optionalAccess', _345 => _345.getAttribute, 'call', _346 => _346("faceColor")]);
25595
+ const face = _optionalChain([winBrush, 'optionalAccess', _346 => _346.getAttribute, 'call', _347 => _347("faceColor")]);
25603
25596
  if (face && face !== "none") def.fill = { faceColor: face };
25604
25597
  map.set(id, def);
25605
25598
  }
@@ -25631,7 +25624,7 @@ function parseCharPrs(headerDoc, hangulFonts) {
25631
25624
  if (cp.getAttribute("italic") === "1") def.italic = true;
25632
25625
  if (findChildByLocalName(cp, "underline")) def.underline = true;
25633
25626
  const fontRef = findChildByLocalName(cp, "fontRef");
25634
- const hangul = _optionalChain([fontRef, 'optionalAccess', _347 => _347.getAttribute, 'call', _348 => _348("hangul")]);
25627
+ const hangul = _optionalChain([fontRef, 'optionalAccess', _348 => _348.getAttribute, 'call', _349 => _349("hangul")]);
25635
25628
  if (hangul) {
25636
25629
  def.fontRef_hangul = hangul;
25637
25630
  const face = hangulFonts.get(hangul);
@@ -25659,7 +25652,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
25659
25652
  const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
25660
25653
  const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
25661
25654
  const sz = findChildByLocalName(tbl2, "sz");
25662
- const width = _optionalChain([sz, 'optionalAccess', _349 => _349.getAttribute, 'call', _350 => _350("width")]) || void 0;
25655
+ const width = _optionalChain([sz, 'optionalAccess', _350 => _350.getAttribute, 'call', _351 => _351("width")]) || void 0;
25663
25656
  const cells = [];
25664
25657
  const usedBf = /* @__PURE__ */ new Set();
25665
25658
  const usedCp = /* @__PURE__ */ new Set();
@@ -25672,17 +25665,17 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
25672
25665
  const addr = findChildByLocalName(tc2, "cellAddr");
25673
25666
  const span = findChildByLocalName(tc2, "cellSpan");
25674
25667
  const csz = findChildByLocalName(tc2, "cellSz");
25675
- const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _351 => _351.getAttribute, 'call', _352 => _352("rowAddr")])), () => ( 0));
25676
- const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _353 => _353.getAttribute, 'call', _354 => _354("colAddr")])), () => ( 0));
25668
+ const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _352 => _352.getAttribute, 'call', _353 => _353("rowAddr")])), () => ( 0));
25669
+ const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _354 => _354.getAttribute, 'call', _355 => _355("colAddr")])), () => ( 0));
25677
25670
  if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
25678
25671
  if (row === 0) row0Texts.set(col, directCellText(tc2));
25679
- const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _355 => _355.getAttribute, 'call', _356 => _356("colSpan")])), () => ( 1));
25680
- const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _357 => _357.getAttribute, 'call', _358 => _358("rowSpan")])), () => ( 1));
25672
+ const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _356 => _356.getAttribute, 'call', _357 => _357("colSpan")])), () => ( 1));
25673
+ const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _358 => _358.getAttribute, 'call', _359 => _359("rowSpan")])), () => ( 1));
25681
25674
  const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
25682
25675
  const cpId = firstRunCharPr(tc2);
25683
25676
  const cell2 = { row, col, rowSpan, colSpan };
25684
- const w = _optionalChain([csz, 'optionalAccess', _359 => _359.getAttribute, 'call', _360 => _360("width")]);
25685
- const hh = _optionalChain([csz, 'optionalAccess', _361 => _361.getAttribute, 'call', _362 => _362("height")]);
25677
+ const w = _optionalChain([csz, 'optionalAccess', _360 => _360.getAttribute, 'call', _361 => _361("width")]);
25678
+ const hh = _optionalChain([csz, 'optionalAccess', _362 => _362.getAttribute, 'call', _363 => _363("height")]);
25686
25679
  if (w) cell2.width_hwpunit = w;
25687
25680
  if (hh) cell2.height_hwpunit = hh;
25688
25681
  if (bfId) {
@@ -25770,16 +25763,16 @@ function pick(map, keys) {
25770
25763
  return out;
25771
25764
  }
25772
25765
  async function hwpxToProfile(input) {
25773
- const buf = input instanceof ArrayBuffer ? input : _chunkDQJTNXVScjs.toArrayBuffer.call(void 0, input);
25766
+ const buf = input instanceof ArrayBuffer ? input : _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, input);
25774
25767
  const zip = await _jszip2.default.loadAsync(buf);
25775
25768
  const parser = createXmlParser();
25776
- const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _363 => _363.file, 'call', _364 => _364(/[Hh]eader\.xml$/), 'optionalAccess', _365 => _365[0]])));
25769
+ const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _364 => _364.file, 'call', _365 => _365(/[Hh]eader\.xml$/), 'optionalAccess', _366 => _366[0]])));
25777
25770
  let headerXml = "<root/>";
25778
25771
  if (headerFile) headerXml = await headerFile.async("text");
25779
25772
  const headerDoc = parser.parseFromString(headerXml, "text/xml");
25780
25773
  const borderFills = parseBorderFills(headerDoc);
25781
25774
  const charPrs = parseCharPrs(headerDoc, parseHangulFonts(headerDoc));
25782
- const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _366 => _366.name, 'access', _367 => _367.match, 'call', _368 => _368(/(\d+)\.xml$/), 'optionalAccess', _369 => _369[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _370 => _370.name, 'access', _371 => _371.match, 'call', _372 => _372(/(\d+)\.xml$/), 'optionalAccess', _373 => _373[1]]), () => ( null))), () => ( 0))));
25775
+ const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _367 => _367.name, 'access', _368 => _368.match, 'call', _369 => _369(/(\d+)\.xml$/), 'optionalAccess', _370 => _370[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _371 => _371.name, 'access', _372 => _372.match, 'call', _373 => _373(/(\d+)\.xml$/), 'optionalAccess', _374 => _374[1]]), () => ( null))), () => ( 0))));
25783
25776
  const tables = [];
25784
25777
  let tableIndex = 0;
25785
25778
  for (const f of sectionFiles) {
@@ -26093,7 +26086,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
26093
26086
  var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
26094
26087
  function patchTableRows(input) {
26095
26088
  const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
26096
- const xml = _optionalChain([ctx, 'access', _374 => _374.scans, 'access', _375 => _375[scanTable.sectionIndex], 'optionalAccess', _376 => _376.xml]);
26089
+ const xml = _optionalChain([ctx, 'access', _375 => _375.scans, 'access', _376 => _376[scanTable.sectionIndex], 'optionalAccess', _377 => _377.xml]);
26097
26090
  if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
26098
26091
  const numRows = table2.rows;
26099
26092
  if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
@@ -26260,7 +26253,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
26260
26253
  const rr = scanTable.rowRanges[template];
26261
26254
  const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
26262
26255
  const scan = scanSectionXml(wrapped, 0);
26263
- const row = _optionalChain([scan, 'access', _377 => _377.tables, 'access', _378 => _378[0], 'optionalAccess', _379 => _379.rows, 'access', _380 => _380[0]]);
26256
+ const row = _optionalChain([scan, 'access', _378 => _378.tables, 'access', _379 => _379[0], 'optionalAccess', _380 => _380.rows, 'access', _381 => _381[0]]);
26264
26257
  if (!row || row.length !== cells.length) return null;
26265
26258
  const splices = allLinesegRemovalSplices(wrapped);
26266
26259
  for (let i = 0; i < cells.length; i++) {
@@ -26303,7 +26296,7 @@ function rowHeightOf(fragment) {
26303
26296
  }
26304
26297
  function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
26305
26298
  const from = scanTable.start + tblOpenLen;
26306
- const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _381 => _381.rowRanges, 'access', _382 => _382[0], 'optionalAccess', _383 => _383.start]), () => ( from));
26299
+ const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _382 => _382.rowRanges, 'access', _383 => _383[0], 'optionalAccess', _384 => _384.start]), () => ( from));
26307
26300
  const slice = xml.slice(from, to);
26308
26301
  const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
26309
26302
  if (!szM || szM.index === void 0) return null;
@@ -26492,9 +26485,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
26492
26485
  });
26493
26486
  }
26494
26487
  function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
26495
- const irCell = _optionalChain([table2, 'access', _384 => _384.cells, 'access', _385 => _385[oc.gridR], 'optionalAccess', _386 => _386[oc.gridC]]);
26488
+ const irCell = _optionalChain([table2, 'access', _385 => _385.cells, 'access', _386 => _386[oc.gridR], 'optionalAccess', _387 => _387[oc.gridC]]);
26496
26489
  const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
26497
- const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _387 => _387.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
26490
+ const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _388 => _388.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
26498
26491
  if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
26499
26492
  return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
26500
26493
  }
@@ -26562,7 +26555,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
26562
26555
  };
26563
26556
  const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
26564
26557
  if (!cell2) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
26565
- const irCell = _optionalChain([table2, 'access', _388 => _388.cells, 'access', _389 => _389[gridR], 'optionalAccess', _390 => _390[gridC]]);
26558
+ const irCell = _optionalChain([table2, 'access', _389 => _389.cells, 'access', _390 => _390[gridR], 'optionalAccess', _391 => _391[gridC]]);
26566
26559
  const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
26567
26560
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
26568
26561
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -26585,7 +26578,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
26585
26578
  if (newLines.length === 0) return 0;
26586
26579
  const target = cell2.paragraphs[0];
26587
26580
  if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
26588
- const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _391 => _391.scans, 'access', _392 => _392[target.sectionIndex], 'optionalAccess', _393 => _393.xml]));
26581
+ const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _392 => _392.scans, 'access', _393 => _393[target.sectionIndex], 'optionalAccess', _394 => _394.xml]));
26589
26582
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
26590
26583
  splices.push(...sp);
26591
26584
  sectionIndex = target.sectionIndex;
@@ -26608,7 +26601,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
26608
26601
  }
26609
26602
  for (let i = 0; i < nonEmpty.length; i++) {
26610
26603
  if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
26611
- const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _394 => _394.scans, 'access', _395 => _395[nonEmpty[i].sectionIndex], 'optionalAccess', _396 => _396.xml]));
26604
+ const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _395 => _395.scans, 'access', _396 => _396[nonEmpty[i].sectionIndex], 'optionalAccess', _397 => _397.xml]));
26612
26605
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
26613
26606
  splices.push(...sp);
26614
26607
  sectionIndex = nonEmpty[i].sectionIndex;
@@ -26689,7 +26682,7 @@ async function resolveSectionEntryNames(zip) {
26689
26682
  const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
26690
26683
  if (paths.length > 0) return paths;
26691
26684
  }
26692
- return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkDQJTNXVScjs.compareSectionPaths);
26685
+ return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
26693
26686
  }
26694
26687
  function sectionPathsFromManifest(xml) {
26695
26688
  const attr = (tag, name) => {
@@ -26699,7 +26692,7 @@ function sectionPathsFromManifest(xml) {
26699
26692
  const idToHref = /* @__PURE__ */ new Map();
26700
26693
  for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
26701
26694
  const id = attr(m[1], "id");
26702
- const href = _chunkDQJTNXVScjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
26695
+ const href = _chunk6XAAYAWLcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
26703
26696
  if (id && href) idToHref.set(id, href);
26704
26697
  }
26705
26698
  const ordered = [];
@@ -26708,7 +26701,7 @@ function sectionPathsFromManifest(xml) {
26708
26701
  if (href) ordered.push(href);
26709
26702
  }
26710
26703
  if (ordered.length > 0) return ordered;
26711
- return Array.from(idToHref.values()).sort(_chunkDQJTNXVScjs.compareSectionPaths);
26704
+ return Array.from(idToHref.values()).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
26712
26705
  }
26713
26706
 
26714
26707
  // src/roundtrip/patcher.ts
@@ -26800,7 +26793,7 @@ async function patchHwpx(original, editedMarkdown, options) {
26800
26793
  }
26801
26794
  }
26802
26795
  let verification;
26803
- if (_optionalChain([options, 'optionalAccess', _397 => _397.verify]) !== false) {
26796
+ if (_optionalChain([options, 'optionalAccess', _398 => _398.verify]) !== false) {
26804
26797
  try {
26805
26798
  const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
26806
26799
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -26815,20 +26808,20 @@ function buildOrigUnits(blocks) {
26815
26808
  for (let i = 0; i < blocks.length; i++) {
26816
26809
  const block = blocks[i];
26817
26810
  let consume = 1;
26818
- let chunk2;
26811
+ let chunk;
26819
26812
  if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
26820
26813
  const next = blocks[i + 1];
26821
- if (_optionalChain([next, 'optionalAccess', _398 => _398.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
26822
- chunk2 = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
26814
+ if (_optionalChain([next, 'optionalAccess', _399 => _399.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
26815
+ chunk = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
26823
26816
  } else {
26824
- chunk2 = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, [block]);
26817
+ chunk = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, [block]);
26825
26818
  }
26826
- if (chunk2) {
26827
- const subUnits = splitMarkdownUnits(chunk2);
26819
+ if (chunk) {
26820
+ const subUnits = splitMarkdownUnits(chunk);
26828
26821
  const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
26829
26822
  for (let s = 0; s < subUnits.length; s++) {
26830
26823
  const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
26831
- if (block.type === "table" && _optionalChain([block, 'access', _399 => _399.table, 'optionalAccess', _400 => _400.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
26824
+ if (block.type === "table" && _optionalChain([block, 'access', _400 => _400.table, 'optionalAccess', _401 => _401.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
26832
26825
  u.role = "caption";
26833
26826
  }
26834
26827
  units.push(u);
@@ -26939,7 +26932,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
26939
26932
  const ti = ctx.tableInsert;
26940
26933
  if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
26941
26934
  const mapping = ctx.paraMap.get(orig.blockIdx);
26942
- if (!_optionalChain([mapping, 'optionalAccess', _401 => _401.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
26935
+ if (!_optionalChain([mapping, 'optionalAccess', _402 => _402.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
26943
26936
  const para2 = mapping.para;
26944
26937
  if (para2.kind !== "body") return skip("\uBCF8\uBB38 \uC678 \uC601\uC5ED(\uD45C \uC140/\uAE00\uC0C1\uC790) \uBB38\uB2E8\uC758 \uD45C \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0");
26945
26938
  const scan = ctx.scans[para2.sectionIndex];
@@ -26967,7 +26960,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
26967
26960
  }
26968
26961
  function patchParagraphUnit(block, orig, edited, ctx, skip) {
26969
26962
  const mapping = ctx.paraMap.get(orig.blockIdx);
26970
- if (!_optionalChain([mapping, 'optionalAccess', _402 => _402.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
26963
+ if (!_optionalChain([mapping, 'optionalAccess', _403 => _403.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
26971
26964
  if (block.text && block.text.includes("\n")) {
26972
26965
  return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
26973
26966
  }
@@ -26998,7 +26991,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
26998
26991
  if (sanitizeText(newPlain) !== newPlain) {
26999
26992
  return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
27000
26993
  }
27001
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _403 => _403.scans, 'access', _404 => _404[mapping.para.sectionIndex], 'optionalAccess', _405 => _405.xml]));
26994
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _404 => _404.scans, 'access', _405 => _405[mapping.para.sectionIndex], 'optionalAccess', _406 => _406.xml]));
27002
26995
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
27003
26996
  ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
27004
26997
  return 1;
@@ -27184,7 +27177,7 @@ var Surgeon = (_class7 = class {
27184
27177
  /** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
27185
27178
  findEntry(path) {
27186
27179
  const parts = path.replace(/^\//, "").split("/");
27187
- let scope = _nullishCoalesce(_optionalChain([this, 'access', _406 => _406.entries, 'access', _407 => _407[0], 'optionalAccess', _408 => _408.child]), () => ( -1));
27180
+ let scope = _nullishCoalesce(_optionalChain([this, 'access', _407 => _407.entries, 'access', _408 => _408[0], 'optionalAccess', _409 => _409.child]), () => ( -1));
27188
27181
  let current;
27189
27182
  for (const part of parts) {
27190
27183
  const search = (idx) => {
@@ -27397,8 +27390,8 @@ function serializeRecords(recs, repl, inserts) {
27397
27390
  parts.push(header, data);
27398
27391
  };
27399
27392
  for (let i = 0; i < recs.length; i++) {
27400
- for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _409 => _409.get, 'call', _410 => _410(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
27401
- push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _411 => _411.get, 'call', _412 => _412(i)]), () => ( recs[i].data)));
27393
+ for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _410 => _410.get, 'call', _411 => _411(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
27394
+ push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _412 => _412.get, 'call', _413 => _413(i)]), () => ( recs[i].data)));
27402
27395
  }
27403
27396
  return Buffer.concat(parts);
27404
27397
  }
@@ -27516,7 +27509,7 @@ async function patchHwp(original, editedMarkdown, options) {
27516
27509
  return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
27517
27510
  }
27518
27511
  const fhEntry = CFB2.find(cfb, "/FileHeader");
27519
- if (!_optionalChain([fhEntry, 'optionalAccess', _413 => _413.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
27512
+ if (!_optionalChain([fhEntry, 'optionalAccess', _414 => _414.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
27520
27513
  let flags;
27521
27514
  try {
27522
27515
  flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
@@ -27538,7 +27531,7 @@ async function patchHwp(original, editedMarkdown, options) {
27538
27531
  const scans = [];
27539
27532
  for (let i = 0; i < sectionPaths.length; i++) {
27540
27533
  const entry = CFB2.find(cfb, sectionPaths[i]);
27541
- if (!_optionalChain([entry, 'optionalAccess', _414 => _414.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
27534
+ if (!_optionalChain([entry, 'optionalAccess', _415 => _415.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
27542
27535
  let stream;
27543
27536
  try {
27544
27537
  stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
@@ -27589,7 +27582,7 @@ async function patchHwp(original, editedMarkdown, options) {
27589
27582
  }
27590
27583
  }
27591
27584
  let verification;
27592
- if (_optionalChain([options, 'optionalAccess', _415 => _415.verify]) !== false) {
27585
+ if (_optionalChain([options, 'optionalAccess', _416 => _416.verify]) !== false) {
27593
27586
  try {
27594
27587
  const reparsed = parseHwp5Document(Buffer.from(data));
27595
27588
  const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
@@ -27679,7 +27672,7 @@ function tableContentScore(irTable, scanTable) {
27679
27672
  for (const [key, scanCell] of scanTable.cells) {
27680
27673
  const comma = key.indexOf(",");
27681
27674
  const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
27682
- const irCell = _optionalChain([irTable, 'access', _416 => _416.cells, 'access', _417 => _417[r], 'optionalAccess', _418 => _418[c]]);
27675
+ const irCell = _optionalChain([irTable, 'access', _417 => _417.cells, 'access', _418 => _418[r], 'optionalAccess', _419 => _419[c]]);
27683
27676
  if (!irCell) continue;
27684
27677
  const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
27685
27678
  const b = normForMatch(stripCellTokens(irCell.text));
@@ -27715,7 +27708,7 @@ function handleModified(orig, edited, ctx) {
27715
27708
  }
27716
27709
  function patchParagraph(block, orig, edited, ctx, skip) {
27717
27710
  const mapping = ctx.paraMap.get(orig.blockIdx);
27718
- if (!_optionalChain([mapping, 'optionalAccess', _419 => _419.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
27711
+ if (!_optionalChain([mapping, 'optionalAccess', _420 => _420.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
27719
27712
  const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
27720
27713
  let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
27721
27714
  if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
@@ -27914,7 +27907,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
27914
27907
  };
27915
27908
  const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
27916
27909
  if (!cell2) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
27917
- const irCell = _optionalChain([table2, 'access', _420 => _420.cells, 'access', _421 => _421[gridR], 'optionalAccess', _422 => _422[gridC]]);
27910
+ const irCell = _optionalChain([table2, 'access', _421 => _421.cells, 'access', _422 => _422[gridR], 'optionalAccess', _423 => _423[gridC]]);
27918
27911
  const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
27919
27912
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
27920
27913
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -28306,7 +28299,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28306
28299
  const block = st.blocks[blockIndex];
28307
28300
  if (!block) return void 0;
28308
28301
  if (block.type === "paragraph" || block.type === "heading") {
28309
- const para2 = _optionalChain([st, 'access', _423 => _423.paraMap, 'access', _424 => _424.get, 'call', _425 => _425(blockIndex), 'optionalAccess', _426 => _426.para]);
28302
+ const para2 = _optionalChain([st, 'access', _424 => _424.paraMap, 'access', _425 => _425.get, 'call', _426 => _426(blockIndex), 'optionalAccess', _427 => _427.para]);
28310
28303
  if (!para2) return void 0;
28311
28304
  return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
28312
28305
  }
@@ -28331,7 +28324,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28331
28324
  if (block.text && block.text.includes("\n")) {
28332
28325
  return { capability: "locked", reason: "\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)" };
28333
28326
  }
28334
- if (!_optionalChain([st, 'access', _427 => _427.paraMap, 'access', _428 => _428.get, 'call', _429 => _429(blockIndex), 'optionalAccess', _430 => _430.para])) {
28327
+ if (!_optionalChain([st, 'access', _428 => _428.paraMap, 'access', _429 => _429.get, 'call', _430 => _430(blockIndex), 'optionalAccess', _431 => _431.para])) {
28335
28328
  return { capability: "locked", reason: "\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)" };
28336
28329
  }
28337
28330
  return { capability: "text" };
@@ -28397,7 +28390,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28397
28390
  continue;
28398
28391
  }
28399
28392
  if (block.type === "table" && block.table) {
28400
- if (!_optionalChain([edit, 'access', _431 => _431.cells, 'optionalAccess', _432 => _432.length])) {
28393
+ if (!_optionalChain([edit, 'access', _432 => _432.cells, 'optionalAccess', _433 => _433.length])) {
28401
28394
  skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
28402
28395
  continue;
28403
28396
  }
@@ -28417,7 +28410,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28417
28410
  skipped.push({ reason: "\uAC19\uC740 \uC140\uC5D0 \uC911\uBCF5 \uD3B8\uC9D1 \u2014 \uBA3C\uC800 \uC801\uC6A9\uB41C \uD3B8\uC9D1 \uC720\uC9C0", after: summarize(cellEdit.text) });
28418
28411
  continue;
28419
28412
  }
28420
- const irCell = _optionalChain([block, 'access', _433 => _433.table, 'access', _434 => _434.cells, 'access', _435 => _435[cellEdit.row], 'optionalAccess', _436 => _436[cellEdit.col]]);
28413
+ const irCell = _optionalChain([block, 'access', _434 => _434.table, 'access', _435 => _435.cells, 'access', _436 => _436[cellEdit.row], 'optionalAccess', _437 => _437[cellEdit.col]]);
28421
28414
  if (!irCell) {
28422
28415
  skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
28423
28416
  continue;
@@ -28473,7 +28466,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28473
28466
  }
28474
28467
  if (replacements.size === 0) {
28475
28468
  let changes2;
28476
- if (_optionalChain([options, 'optionalAccess', _437 => _437.verify]) !== false) {
28469
+ if (_optionalChain([options, 'optionalAccess', _438 => _438.verify]) !== false) {
28477
28470
  const units = splitMarkdownUnits(st.markdown);
28478
28471
  changes2 = diffUnitLists(units, units);
28479
28472
  }
@@ -28494,7 +28487,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28494
28487
  }
28495
28488
  this.state = newState;
28496
28489
  let changes;
28497
- if (_optionalChain([options, 'optionalAccess', _438 => _438.verify]) !== false) {
28490
+ if (_optionalChain([options, 'optionalAccess', _439 => _439.verify]) !== false) {
28498
28491
  changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
28499
28492
  }
28500
28493
  return { success: true, data: new Uint8Array(data), applied, skipped, changes };
@@ -28514,7 +28507,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28514
28507
  return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
28515
28508
  }
28516
28509
  const mapping = st.paraMap.get(blockIndex);
28517
- if (!_optionalChain([mapping, 'optionalAccess', _439 => _439.para])) {
28510
+ if (!_optionalChain([mapping, 'optionalAccess', _440 => _440.para])) {
28518
28511
  return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
28519
28512
  }
28520
28513
  let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
@@ -28534,14 +28527,14 @@ var HwpxSession = (_class8 = class _HwpxSession {
28534
28527
  if (sanitizeText(newPlain) !== newPlain) {
28535
28528
  return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
28536
28529
  }
28537
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _440 => _440.scans, 'access', _441 => _441[mapping.para.sectionIndex], 'optionalAccess', _442 => _442.xml]));
28530
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _441 => _441.scans, 'access', _442 => _442[mapping.para.sectionIndex], 'optionalAccess', _443 => _443.xml]));
28538
28531
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
28539
28532
  sectionSplices[mapping.para.sectionIndex].push(...splices);
28540
28533
  return 1;
28541
28534
  }
28542
28535
  }, _class8);
28543
28536
  function cellStaticCheck(table2, scanTable, r, c) {
28544
- const irCell = _optionalChain([table2, 'access', _443 => _443.cells, 'access', _444 => _444[r], 'optionalAccess', _445 => _445[c]]);
28537
+ const irCell = _optionalChain([table2, 'access', _444 => _444.cells, 'access', _445 => _445[r], 'optionalAccess', _446 => _446[c]]);
28545
28538
  if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
28546
28539
  const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
28547
28540
  if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
@@ -28625,11 +28618,11 @@ var md = new (0, _markdownit2.default)({
28625
28618
  breaks: false
28626
28619
  });
28627
28620
  function renderHtml(markdown, options) {
28628
- const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _446 => _446.preset]), () => ( "default"));
28629
- const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _447 => _447.extraCss]), () => ( "")));
28621
+ const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _447 => _447.preset]), () => ( "default"));
28622
+ const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _448 => _448.extraCss]), () => ( "")));
28630
28623
  const body = md.render(markdown);
28631
- const watermark = _optionalChain([options, 'optionalAccess', _448 => _448.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
28632
- const watermarkCss = _optionalChain([options, 'optionalAccess', _449 => _449.watermark]) ? `
28624
+ const watermark = _optionalChain([options, 'optionalAccess', _449 => _449.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
28625
+ const watermarkCss = _optionalChain([options, 'optionalAccess', _450 => _450.watermark]) ? `
28633
28626
  .watermark {
28634
28627
  position: fixed;
28635
28628
  top: 50%; left: 50%;
@@ -28660,13 +28653,13 @@ async function htmlToPdf(html, options) {
28660
28653
  try {
28661
28654
  puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
28662
28655
  } catch (e31) {
28663
- throw new (0, _chunkDQJTNXVScjs.KordocError)(
28656
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)(
28664
28657
  "PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
28665
28658
  );
28666
28659
  }
28667
28660
  const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
28668
28661
  if (!executablePath) {
28669
- throw new (0, _chunkDQJTNXVScjs.KordocError)(
28662
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)(
28670
28663
  "Chromium \uC2E4\uD589 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. PUPPETEER_EXECUTABLE_PATH \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694."
28671
28664
  );
28672
28665
  }
@@ -28678,10 +28671,10 @@ async function htmlToPdf(html, options) {
28678
28671
  try {
28679
28672
  const page = await browser.newPage();
28680
28673
  await page.setContent(html, { waitUntil: "networkidle0" });
28681
- const margin = _optionalChain([options, 'optionalAccess', _450 => _450.margin]);
28674
+ const margin = _optionalChain([options, 'optionalAccess', _451 => _451.margin]);
28682
28675
  const pdf = await page.pdf({
28683
- format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _451 => _451.pageSize]), () => ( "A4")),
28684
- landscape: _optionalChain([options, 'optionalAccess', _452 => _452.orientation]) === "landscape",
28676
+ format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _452 => _452.pageSize]), () => ( "A4")),
28677
+ landscape: _optionalChain([options, 'optionalAccess', _453 => _453.orientation]) === "landscape",
28685
28678
  printBackground: true,
28686
28679
  margin: margin ? {
28687
28680
  top: toCss(margin.top),
@@ -28689,9 +28682,9 @@ async function htmlToPdf(html, options) {
28689
28682
  bottom: toCss(margin.bottom),
28690
28683
  left: toCss(margin.left)
28691
28684
  } : void 0,
28692
- displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _453 => _453.header]) || _optionalChain([options, 'optionalAccess', _454 => _454.footer])),
28693
- headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _455 => _455.header]), () => ( "<div></div>")),
28694
- footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _456 => _456.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
28685
+ displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _454 => _454.header]) || _optionalChain([options, 'optionalAccess', _455 => _455.footer])),
28686
+ headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _456 => _456.header]), () => ( "<div></div>")),
28687
+ footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _457 => _457.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
28695
28688
  });
28696
28689
  return Buffer.from(pdf);
28697
28690
  } finally {
@@ -28725,7 +28718,7 @@ async function markdownToPdf(markdown, options) {
28725
28718
  return htmlToPdf(html, options);
28726
28719
  }
28727
28720
  async function blocksToPdf(blocks, options) {
28728
- const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
28721
+ const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
28729
28722
  return markdownToPdf(markdown, options);
28730
28723
  }
28731
28724
 
@@ -28904,7 +28897,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode) {
28904
28897
  }
28905
28898
  const wrapAttr = _nullishCoalesce(o.el.getAttribute("textWrap"), () => ( ""));
28906
28899
  if (wrapAttr === "BEHIND_TEXT" || wrapAttr === "IN_FRONT_OF_TEXT") continue;
28907
- const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _457 => _457.getAttribute, 'call', _458 => _458("vertRelTo")]), () => ( "PARA"));
28900
+ const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _458 => _458.getAttribute, 'call', _459 => _459("vertRelTo")]), () => ( "PARA"));
28908
28901
  if (vertRel === "PAGE" || vertRel === "PAPER") continue;
28909
28902
  const vo = Math.max(0, num2(pos, "vertOffset"));
28910
28903
  if (wrapAttr === "TOP_AND_BOTTOM") {
@@ -28965,7 +28958,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
28965
28958
  if (ln(p) !== "p") continue;
28966
28959
  reflowTablesIn(p, doc, styles, mode, counter);
28967
28960
  const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
28968
- const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _459 => _459.spaceBefore]), () => ( 0)));
28961
+ const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _460 => _460.spaceBefore]), () => ( 0)));
28969
28962
  const res = reflowPara(p, doc, styles, areaW, startV, mode);
28970
28963
  if (!res) {
28971
28964
  const lsa = findChildByLocalName(p, "linesegarray");
@@ -28978,7 +28971,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
28978
28971
  }
28979
28972
  if (Number.isFinite(bottom)) {
28980
28973
  cursorV = bottom;
28981
- prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _460 => _460.spaceAfter]), () => ( 0));
28974
+ prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _461 => _461.spaceAfter]), () => ( 0));
28982
28975
  }
28983
28976
  }
28984
28977
  continue;
@@ -29088,7 +29081,7 @@ function buildPara(p) {
29088
29081
  el: ch,
29089
29082
  tag: cn,
29090
29083
  index: chars.length,
29091
- inline: _optionalChain([pos, 'optionalAccess', _461 => _461.getAttribute, 'call', _462 => _462("treatAsChar")]) === "1",
29084
+ inline: _optionalChain([pos, 'optionalAccess', _462 => _462.getAttribute, 'call', _463 => _463("treatAsChar")]) === "1",
29092
29085
  width: w,
29093
29086
  height: h
29094
29087
  });
@@ -29340,15 +29333,15 @@ function drawShape(o, x, y, ctx, depth) {
29340
29333
  const sx = ow > 0 ? w / ow : 1;
29341
29334
  const sy = oh > 0 ? h / oh : 1;
29342
29335
  const lineShape = findChildByLocalName(el, "lineShape");
29343
- const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _463 => _463.getAttribute, 'call', _464 => _464("style")]), () => ( "SOLID"));
29344
- const strokeCol = _optionalChain([lineShape, 'optionalAccess', _465 => _465.getAttribute, 'call', _466 => _466("color")]) || "#000000";
29336
+ const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _464 => _464.getAttribute, 'call', _465 => _465("style")]), () => ( "SOLID"));
29337
+ const strokeCol = _optionalChain([lineShape, 'optionalAccess', _466 => _466.getAttribute, 'call', _467 => _467("color")]) || "#000000";
29345
29338
  const hasStroke = lstyle !== "NONE";
29346
29339
  const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
29347
29340
  const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
29348
29341
  const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
29349
29342
  const fillBrush = findChildByLocalName(el, "fillBrush");
29350
29343
  const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
29351
- const face = _optionalChain([winBrush, 'optionalAccess', _467 => _467.getAttribute, 'call', _468 => _468("faceColor")]);
29344
+ const face = _optionalChain([winBrush, 'optionalAccess', _468 => _468.getAttribute, 'call', _469 => _469("faceColor")]);
29352
29345
  const fill = face && face.toLowerCase() !== "none" ? face : "none";
29353
29346
  const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
29354
29347
  if (o.tag === "rect") {
@@ -29380,7 +29373,7 @@ function cellContentExtent(cell2) {
29380
29373
  if (ln2(p) !== "p") continue;
29381
29374
  const m = buildPara(p);
29382
29375
  for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
29383
- const baseV = _nullishCoalesce(_optionalChain([m, 'access', _469 => _469.segs, 'access', _470 => _470[0], 'optionalAccess', _471 => _471.vertpos]), () => ( 0));
29376
+ const baseV = _nullishCoalesce(_optionalChain([m, 'access', _470 => _470.segs, 'access', _471 => _471[0], 'optionalAccess', _472 => _472.vertpos]), () => ( 0));
29384
29377
  for (const o of m.objs) {
29385
29378
  if (o.inline) {
29386
29379
  const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
@@ -29388,7 +29381,7 @@ function cellContentExtent(cell2) {
29388
29381
  continue;
29389
29382
  }
29390
29383
  const pos = findChildByLocalName(o.el, "pos");
29391
- if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _472 => _472.getAttribute, 'call', _473 => _473("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
29384
+ if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _473 => _473.getAttribute, 'call', _474 => _474("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
29392
29385
  const om = findChildByLocalName(o.el, "outMargin");
29393
29386
  const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
29394
29387
  const anchor = pushed >= -100 ? pushed : baseV;
@@ -29474,7 +29467,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
29474
29467
  }));
29475
29468
  for (const g of geom) {
29476
29469
  const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
29477
- if (_optionalChain([bf, 'optionalAccess', _474 => _474.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
29470
+ if (_optionalChain([bf, 'optionalAccess', _475 => _475.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
29478
29471
  }
29479
29472
  for (const g of geom) {
29480
29473
  const { c } = g;
@@ -29512,7 +29505,7 @@ function drawPic(pic, x, y, ctx) {
29512
29505
  const sz = findChildByLocalName(pic, "sz");
29513
29506
  const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
29514
29507
  const img = findFirst(pic, "img");
29515
- const ref = _optionalChain([img, 'optionalAccess', _475 => _475.getAttribute, 'call', _476 => _476("binaryItemIDRef")]);
29508
+ const ref = _optionalChain([img, 'optionalAccess', _476 => _476.getAttribute, 'call', _477 => _477("binaryItemIDRef")]);
29516
29509
  const loaded = ref != null ? ctx.images.get(ref) : void 0;
29517
29510
  if (!loaded) {
29518
29511
  emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
@@ -29551,7 +29544,7 @@ function readSectionGeom(root) {
29551
29544
  const pagePr = findFirst(root, "pagePr");
29552
29545
  const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
29553
29546
  let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
29554
- if (_optionalChain([pagePr, 'optionalAccess', _477 => _477.getAttribute, 'call', _478 => _478("landscape")]) === "NARROWLY" && PW < PH) {
29547
+ if (_optionalChain([pagePr, 'optionalAccess', _478 => _478.getAttribute, 'call', _479 => _479("landscape")]) === "NARROWLY" && PW < PH) {
29555
29548
  const t = PW;
29556
29549
  PW = PH;
29557
29550
  PH = t;
@@ -29609,17 +29602,17 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
29609
29602
  return { pages: ctx.pages, pageH };
29610
29603
  }
29611
29604
  async function renderHwpxToSvg(input, options) {
29612
- const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _479 => _479.maxImageBytes]), () => ( 40 * 1024 * 1024));
29605
+ const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _480 => _480.maxImageBytes]), () => ( 40 * 1024 * 1024));
29613
29606
  const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
29614
- _chunkDQJTNXVScjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
29607
+ _chunk6XAAYAWLcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
29615
29608
  let zip;
29616
29609
  try {
29617
29610
  zip = await _jszip2.default.loadAsync(input);
29618
29611
  } catch (e32) {
29619
- throw new (0, _chunkDQJTNXVScjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
29612
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
29620
29613
  }
29621
29614
  const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
29622
- if (secFiles.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
29615
+ if (secFiles.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
29623
29616
  const warnings = [];
29624
29617
  const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
29625
29618
  const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
@@ -29627,7 +29620,7 @@ async function renderHwpxToSvg(input, options) {
29627
29620
  const secXmls = [];
29628
29621
  for (const f of secFiles) {
29629
29622
  const xml = await f.async("string");
29630
- if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
29623
+ if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
29631
29624
  secXmls.push(xml);
29632
29625
  }
29633
29626
  const binmap = /* @__PURE__ */ new Map();
@@ -29651,7 +29644,7 @@ async function renderHwpxToSvg(input, options) {
29651
29644
  let href = binmap.get(ref);
29652
29645
  if (!href) {
29653
29646
  const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
29654
- href = _optionalChain([cand, 'optionalAccess', _480 => _480.name]);
29647
+ href = _optionalChain([cand, 'optionalAccess', _481 => _481.name]);
29655
29648
  }
29656
29649
  if (!href) continue;
29657
29650
  const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
@@ -29672,7 +29665,7 @@ async function renderHwpxToSvg(input, options) {
29672
29665
  styles,
29673
29666
  images,
29674
29667
  defs: [],
29675
- highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _481 => _481.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
29668
+ highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _482 => _482.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
29676
29669
  warnings,
29677
29670
  warned: /* @__PURE__ */ new Set(),
29678
29671
  stats: { texts: 0, images: 0, tables: 0 }
@@ -29682,7 +29675,7 @@ async function renderHwpxToSvg(input, options) {
29682
29675
  for (let si = 0; si < secXmls.length; si++) {
29683
29676
  const secXml = secXmls[si];
29684
29677
  const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
29685
- if (!hasCache && !_optionalChain([options, 'optionalAccess', _482 => _482.reflow])) {
29678
+ if (!hasCache && !_optionalChain([options, 'optionalAccess', _483 => _483.reflow])) {
29686
29679
  noCacheSkipped = true;
29687
29680
  warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
29688
29681
  continue;
@@ -29694,14 +29687,14 @@ async function renderHwpxToSvg(input, options) {
29694
29687
  continue;
29695
29688
  }
29696
29689
  const geom = readSectionGeom(root);
29697
- const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess', _483 => _483.reflow]), _nullishCoalesce(_optionalChain([options, 'optionalAccess', _484 => _484.reflowMode]), () => ( "keep")));
29690
+ const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess', _484 => _484.reflow]), _nullishCoalesce(_optionalChain([options, 'optionalAccess', _485 => _485.reflowMode]), () => ( "keep")));
29698
29691
  rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
29699
29692
  }
29700
29693
  if (rendered.length === 0) {
29701
29694
  if (noCacheSkipped) {
29702
- throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
29695
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
29703
29696
  }
29704
- throw new (0, _chunkDQJTNXVScjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
29697
+ throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
29705
29698
  }
29706
29699
  const GAP = 2400;
29707
29700
  const clipDefs = [];
@@ -29733,17 +29726,17 @@ ${groups.join("\n")}
29733
29726
  // src/index.ts
29734
29727
  async function parse(input, options) {
29735
29728
  let buffer;
29736
- const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _485 => _485.filePath]) ? { ...options, filePath: input } : options;
29729
+ const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _486 => _486.filePath]) ? { ...options, filePath: input } : options;
29737
29730
  if (typeof input === "string") {
29738
29731
  try {
29739
29732
  const buf = await _promises.readFile.call(void 0, input);
29740
- buffer = _chunkDQJTNXVScjs.toArrayBuffer.call(void 0, buf);
29733
+ buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, buf);
29741
29734
  } catch (err) {
29742
29735
  const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
29743
29736
  return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
29744
29737
  }
29745
29738
  } else if (Buffer.isBuffer(input)) {
29746
- buffer = _chunkDQJTNXVScjs.toArrayBuffer.call(void 0, input);
29739
+ buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, input);
29747
29740
  } else {
29748
29741
  buffer = input;
29749
29742
  }
@@ -29778,21 +29771,21 @@ async function parseHwp3(buffer, options) {
29778
29771
  const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
29779
29772
  return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
29780
29773
  } catch (err) {
29781
- return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
29774
+ return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
29782
29775
  }
29783
29776
  }
29784
29777
  async function parseHwpx(buffer, options) {
29785
29778
  try {
29786
29779
  const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
29787
- return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _486 => _486.length]) ? images : void 0 };
29780
+ return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _487 => _487.length]) ? images : void 0 };
29788
29781
  } catch (err) {
29789
- return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
29782
+ return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
29790
29783
  }
29791
29784
  }
29792
29785
  async function parseHwp(buffer, options) {
29793
29786
  try {
29794
29787
  const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
29795
- if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _487 => _487.filePath])) {
29788
+ if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _488 => _488.filePath])) {
29796
29789
  try {
29797
29790
  const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
29798
29791
  if (pages.some((p) => p && p.trim().length > 0)) {
@@ -29809,15 +29802,15 @@ async function parseHwp(buffer, options) {
29809
29802
  } catch (e33) {
29810
29803
  }
29811
29804
  }
29812
- return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _488 => _488.length]) ? images : void 0 };
29805
+ return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _489 => _489.length]) ? images : void 0 };
29813
29806
  } catch (err) {
29814
- return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
29807
+ return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
29815
29808
  }
29816
29809
  }
29817
29810
  async function parsePdf(buffer, options) {
29818
29811
  let parsePdfDocument;
29819
29812
  try {
29820
- const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-VEY4B5CJ.cjs")));
29813
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-ITMU2WN5.cjs")));
29821
29814
  parsePdfDocument = mod.parsePdfDocument;
29822
29815
  } catch (e34) {
29823
29816
  return {
@@ -29828,11 +29821,11 @@ async function parsePdf(buffer, options) {
29828
29821
  };
29829
29822
  }
29830
29823
  try {
29831
- const { markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary } = await parsePdfDocument(buffer, options);
29832
- return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
29824
+ const { markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images } = await parsePdfDocument(buffer, options);
29825
+ return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
29833
29826
  } catch (err) {
29834
29827
  const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
29835
- return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err), isImageBased };
29828
+ return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err), isImageBased };
29836
29829
  }
29837
29830
  }
29838
29831
  async function parseXlsx(buffer, options) {
@@ -29840,7 +29833,7 @@ async function parseXlsx(buffer, options) {
29840
29833
  const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
29841
29834
  return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
29842
29835
  } catch (err) {
29843
- return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
29836
+ return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
29844
29837
  }
29845
29838
  }
29846
29839
  async function parseXls(buffer, options) {
@@ -29848,15 +29841,15 @@ async function parseXls(buffer, options) {
29848
29841
  const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
29849
29842
  return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
29850
29843
  } catch (err) {
29851
- return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
29844
+ return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
29852
29845
  }
29853
29846
  }
29854
29847
  async function parseDocx(buffer, options) {
29855
29848
  try {
29856
29849
  const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
29857
- return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _489 => _489.length]) ? images : void 0 };
29850
+ return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _490 => _490.length]) ? images : void 0 };
29858
29851
  } catch (err) {
29859
- return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
29852
+ return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
29860
29853
  }
29861
29854
  }
29862
29855
  async function parseHwpml(buffer, options) {
@@ -29864,16 +29857,16 @@ async function parseHwpml(buffer, options) {
29864
29857
  const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
29865
29858
  return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
29866
29859
  } catch (err) {
29867
- return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
29860
+ return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
29868
29861
  }
29869
29862
  }
29870
29863
  async function fillForm(input, values, outputFormat = "markdown") {
29871
29864
  let buffer;
29872
29865
  if (typeof input === "string") {
29873
29866
  const buf = await _promises.readFile.call(void 0, input);
29874
- buffer = _chunkDQJTNXVScjs.toArrayBuffer.call(void 0, buf);
29867
+ buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, buf);
29875
29868
  } else if (Buffer.isBuffer(input)) {
29876
- buffer = _chunkDQJTNXVScjs.toArrayBuffer.call(void 0, input);
29869
+ buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, input);
29877
29870
  } else {
29878
29871
  buffer = input;
29879
29872
  }
@@ -29899,7 +29892,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
29899
29892
  throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
29900
29893
  }
29901
29894
  const fill = fillFormFields(parsed.blocks, values);
29902
- const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, fill.blocks);
29895
+ const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, fill.blocks);
29903
29896
  if (outputFormat === "hwpx") {
29904
29897
  const hwpxBuffer = await markdownToHwpx(markdown);
29905
29898
  return { output: hwpxBuffer, format: "hwpx", fill };
@@ -29968,5 +29961,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
29968
29961
 
29969
29962
 
29970
29963
 
29971
- exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkDQJTNXVScjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkDQJTNXVScjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.gongmunLintWarnings = gongmunLintWarnings; exports.hwpxToProfile = hwpxToProfile; exports.incompatibleGongmunWarnings = incompatibleGongmunWarnings; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isKnownFont = isKnownFont; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.lintGongmunText = lintGongmunText; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
29964
+ exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunk6XAAYAWLcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunk6XAAYAWLcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.gongmunLintWarnings = gongmunLintWarnings; exports.hwpxToProfile = hwpxToProfile; exports.incompatibleGongmunWarnings = incompatibleGongmunWarnings; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isKnownFont = isKnownFont; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.lintGongmunText = lintGongmunText; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
29972
29965
  //# sourceMappingURL=index.cjs.map