kordoc 4.0.8 → 4.2.0

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 (122) hide show
  1. package/README.md +50 -16
  2. package/dist/{-LE4RLXVA.js → -SXQIZHYA.js} +24 -10
  3. package/dist/{parser-TCTCSBYZ.js → chunk-26AJJCFF.js} +1427 -2027
  4. package/dist/chunk-26AJJCFF.js.map +1 -0
  5. package/dist/{parser-KMMUS73Q.js → chunk-4JPPLIIV.js} +1425 -2025
  6. package/dist/chunk-4JPPLIIV.js.map +1 -0
  7. package/dist/chunk-4VNLZ2GZ.js +13 -0
  8. package/dist/chunk-4VNLZ2GZ.js.map +1 -0
  9. package/dist/{chunk-2DZQF6YJ.js → chunk-6SHO3BNV.js} +24 -15
  10. package/dist/chunk-6SHO3BNV.js.map +1 -0
  11. package/dist/chunk-7FCNOKOR.js +144 -0
  12. package/dist/chunk-7FCNOKOR.js.map +1 -0
  13. package/dist/{chunk-6XAAYAWL.cjs → chunk-CMN3SYZ3.js} +62 -304
  14. package/dist/chunk-CMN3SYZ3.js.map +1 -0
  15. package/dist/chunk-DZIXKL7E.js +145 -0
  16. package/dist/chunk-DZIXKL7E.js.map +1 -0
  17. package/dist/chunk-ELOV2GIJ.js +82 -0
  18. package/dist/chunk-ELOV2GIJ.js.map +1 -0
  19. package/dist/chunk-F2HYH62H.cjs +130 -0
  20. package/dist/chunk-F2HYH62H.cjs.map +1 -0
  21. package/dist/{chunk-HMUEU7D7.js → chunk-FSXLSHCW.js} +3 -3
  22. package/dist/{chunk-HMUEU7D7.js.map → chunk-FSXLSHCW.js.map} +1 -1
  23. package/dist/chunk-GEPINOL6.js +83 -0
  24. package/dist/chunk-GEPINOL6.js.map +1 -0
  25. package/dist/chunk-H7OWEYH2.cjs +243 -0
  26. package/dist/chunk-H7OWEYH2.cjs.map +1 -0
  27. package/dist/{chunk-7S3M4N4E.js → chunk-IGGRLWT5.js} +683 -226
  28. package/dist/chunk-IGGRLWT5.js.map +1 -0
  29. package/dist/chunk-J2RZ444H.js +243 -0
  30. package/dist/chunk-J2RZ444H.js.map +1 -0
  31. package/dist/chunk-JP5YH3Z4.js +130 -0
  32. package/dist/chunk-JP5YH3Z4.js.map +1 -0
  33. package/dist/{parser-ITMU2WN5.cjs → chunk-LHROM2BO.cjs} +1409 -2012
  34. package/dist/chunk-LHROM2BO.cjs.map +1 -0
  35. package/dist/chunk-NNDVFNMJ.js +246 -0
  36. package/dist/chunk-NNDVFNMJ.js.map +1 -0
  37. package/dist/{chunk-RROH5WHO.js → chunk-PLIY23LY.js} +2 -2
  38. package/dist/{chunk-BNU5QGIZ.js → chunk-V6U6YS5B.js} +12 -4
  39. package/dist/chunk-V6U6YS5B.js.map +1 -0
  40. package/dist/{chunk-UEIYETCQ.js → chunk-WF2E5P2G.js} +40 -35
  41. package/dist/chunk-WF2E5P2G.js.map +1 -0
  42. package/dist/{chunk-D35VBACN.js → chunk-WQLHPOMJ.js} +7 -4
  43. package/dist/chunk-WQLHPOMJ.js.map +1 -0
  44. package/dist/{chunk-OQPILS7B.js → chunk-XTCT6KQ5.cjs} +79 -183
  45. package/dist/chunk-XTCT6KQ5.cjs.map +1 -0
  46. package/dist/{chunk-MEPHGCPQ.js → chunk-YOO6ET6M.js} +7 -3
  47. package/dist/chunk-YOO6ET6M.js.map +1 -0
  48. package/dist/chunks-ZQEFAZNC.js +10 -0
  49. package/dist/cli.js +228 -36
  50. package/dist/cli.js.map +1 -1
  51. package/dist/{detect-RI2MQ33K.js → detect-YEZX2XCF.js} +2 -2
  52. package/dist/{formula-RXVSQPXI.js → formula-KSNAEBZ2.js} +23 -232
  53. package/dist/formula-KSNAEBZ2.js.map +1 -0
  54. package/dist/{formula-5NKVS2LR.cjs → formula-SB3NHDUM.cjs} +30 -240
  55. package/dist/formula-SB3NHDUM.cjs.map +1 -0
  56. package/dist/{formula-JCNF43NE.js → formula-SXC6LRRC.js} +23 -233
  57. package/dist/formula-SXC6LRRC.js.map +1 -0
  58. package/dist/index.cjs +1280 -589
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +112 -4
  61. package/dist/index.d.ts +112 -4
  62. package/dist/index.js +929 -238
  63. package/dist/index.js.map +1 -1
  64. package/dist/mcp.js +278 -68
  65. package/dist/mcp.js.map +1 -1
  66. package/dist/models-KA4GLQK5.js +25 -0
  67. package/dist/parser-ND2YGQZR.js +800 -0
  68. package/dist/parser-ND2YGQZR.js.map +1 -0
  69. package/dist/parser-RBZHA6SY.js +804 -0
  70. package/dist/parser-RBZHA6SY.js.map +1 -0
  71. package/dist/parser-WDZOMDG4.cjs +803 -0
  72. package/dist/parser-WDZOMDG4.cjs.map +1 -0
  73. package/dist/pdf-ocr-2Z7VZIFI.cjs +439 -0
  74. package/dist/pdf-ocr-2Z7VZIFI.cjs.map +1 -0
  75. package/dist/pdf-ocr-FJFXFADQ.js +438 -0
  76. package/dist/pdf-ocr-FJFXFADQ.js.map +1 -0
  77. package/dist/pdf-ocr-VYE4DHD4.js +386 -0
  78. package/dist/pdf-ocr-VYE4DHD4.js.map +1 -0
  79. package/dist/{profile-io-SLN4P76T.js → profile-io-TWHDIVPL.js} +3 -3
  80. package/dist/rasterize-W2NEZUSW.js +40 -0
  81. package/dist/rasterize-W2NEZUSW.js.map +1 -0
  82. package/dist/redact-7ILEAUTS.js +12 -0
  83. package/dist/redact-7ILEAUTS.js.map +1 -0
  84. package/dist/render-4MG5QUDG.js +10 -0
  85. package/dist/render-4MG5QUDG.js.map +1 -0
  86. package/dist/seal-D2QNXJVO.js +10 -0
  87. package/dist/seal-D2QNXJVO.js.map +1 -0
  88. package/dist/{setup-57FB3LSP.js → setup-Q2PRE7UA.js} +5 -3
  89. package/dist/setup-Q2PRE7UA.js.map +1 -0
  90. package/dist/{watch-OHQWSVPE.js → watch-VWXJZT2R.js} +78 -23
  91. package/dist/watch-VWXJZT2R.js.map +1 -0
  92. package/package.json +2 -1
  93. package/dist/chunk-2DZQF6YJ.js.map +0 -1
  94. package/dist/chunk-6XAAYAWL.cjs.map +0 -1
  95. package/dist/chunk-7S3M4N4E.js.map +0 -1
  96. package/dist/chunk-BNU5QGIZ.js.map +0 -1
  97. package/dist/chunk-D35VBACN.js.map +0 -1
  98. package/dist/chunk-MEPHGCPQ.js.map +0 -1
  99. package/dist/chunk-OQPILS7B.js.map +0 -1
  100. package/dist/chunk-UEIYETCQ.js.map +0 -1
  101. package/dist/formula-5NKVS2LR.cjs.map +0 -1
  102. package/dist/formula-JCNF43NE.js.map +0 -1
  103. package/dist/formula-RXVSQPXI.js.map +0 -1
  104. package/dist/parser-ITMU2WN5.cjs.map +0 -1
  105. package/dist/parser-KMMUS73Q.js.map +0 -1
  106. package/dist/parser-TCTCSBYZ.js.map +0 -1
  107. package/dist/provider-4ZJKV3DC.js +0 -37
  108. package/dist/provider-4ZJKV3DC.js.map +0 -1
  109. package/dist/provider-AKROB7WQ.js +0 -39
  110. package/dist/provider-AKROB7WQ.js.map +0 -1
  111. package/dist/provider-G4C2V2PD.cjs +0 -39
  112. package/dist/provider-G4C2V2PD.cjs.map +0 -1
  113. package/dist/render-25BT623I.js +0 -10
  114. package/dist/seal-R4TETA4C.js +0 -10
  115. package/dist/setup-57FB3LSP.js.map +0 -1
  116. package/dist/watch-OHQWSVPE.js.map +0 -1
  117. /package/dist/{-LE4RLXVA.js.map → -SXQIZHYA.js.map} +0 -0
  118. /package/dist/{chunk-RROH5WHO.js.map → chunk-PLIY23LY.js.map} +0 -0
  119. /package/dist/{detect-RI2MQ33K.js.map → chunks-ZQEFAZNC.js.map} +0 -0
  120. /package/dist/{profile-io-SLN4P76T.js.map → detect-YEZX2XCF.js.map} +0 -0
  121. /package/dist/{render-25BT623I.js.map → models-KA4GLQK5.js.map} +0 -0
  122. /package/dist/{seal-R4TETA4C.js.map → profile-io-TWHDIVPL.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -8,8 +8,10 @@
8
8
 
9
9
 
10
10
 
11
+ var _chunkXTCT6KQ5cjs = require('./chunk-XTCT6KQ5.cjs');
11
12
 
12
13
 
14
+ var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
13
15
 
14
16
 
15
17
 
@@ -21,10 +23,11 @@
21
23
 
22
24
 
23
25
 
24
- var _chunk6XAAYAWLcjs = require('./chunk-6XAAYAWL.cjs');
25
26
 
26
27
 
27
- var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
28
+
29
+
30
+ var _chunkF2HYH62Hcjs = require('./chunk-F2HYH62H.cjs');
28
31
 
29
32
 
30
33
  var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
@@ -51,8 +54,11 @@ function parseLenientCfb(data) {
51
54
  const miniSectorSizeShift = data.readUInt16LE(32);
52
55
  if (miniSectorSizeShift > 16) throw new Error("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 \uBBF8\uB2C8 \uC139\uD130 \uD06C\uAE30 \uC2DC\uD504\uD2B8: " + miniSectorSizeShift);
53
56
  const miniSectorSize = 1 << miniSectorSizeShift;
54
- const fatSectorCount = data.readUInt32LE(44);
55
- if (fatSectorCount > 1e4) throw new Error("FAT \uC139\uD130 \uC218\uAC00 \uB108\uBB34 \uB9CE\uC2B5\uB2C8\uB2E4: " + fatSectorCount);
57
+ const headerFatSectorCount = data.readUInt32LE(44);
58
+ if (headerFatSectorCount > 1e4) throw new Error("FAT \uC139\uD130 \uC218\uAC00 \uB108\uBB34 \uB9CE\uC2B5\uB2C8\uB2E4: " + headerFatSectorCount);
59
+ const maxRealSectors = Math.ceil(Math.max(0, data.length - 512) / sectorSize);
60
+ const maxFatSectors = Math.max(1, Math.ceil(maxRealSectors / (sectorSize / 4)));
61
+ const fatSectorCount = Math.min(headerFatSectorCount, maxFatSectors);
56
62
  const firstDirSector = data.readUInt32LE(48);
57
63
  const miniStreamCutoff = data.readUInt32LE(56);
58
64
  const firstMiniFatSector = data.readUInt32LE(60);
@@ -79,6 +85,7 @@ function parseLenientCfb(data) {
79
85
  if (visitedDifat.has(difatSector)) break;
80
86
  visitedDifat.add(difatSector);
81
87
  const buf = readSectorData(difatSector);
88
+ if (buf.length < sectorSize) break;
82
89
  const entriesPerSector = sectorSize / 4 - 1;
83
90
  for (let i = 0; i < entriesPerSector && fatSectors.length < fatSectorCount; i++) {
84
91
  const sid = buf.readUInt32LE(i * 4);
@@ -397,6 +404,12 @@ function comResultToParseResult(pages, pageCount, warnings) {
397
404
  var _xmldom = require('@xmldom/xmldom');
398
405
  var MAX_DECOMPRESS_SIZE = 100 * 1024 * 1024;
399
406
  var MAX_ZIP_ENTRIES = 500;
407
+ var ZipBombError = class extends _chunkF2HYH62Hcjs.KordocError {
408
+ constructor(message) {
409
+ super(message);
410
+ this.name = "ZipBombError";
411
+ }
412
+ };
400
413
  function clampSpan(val, max) {
401
414
  return Math.max(1, Math.min(val, max));
402
415
  }
@@ -407,7 +420,7 @@ function createSectionShared() {
407
420
  function createXmlParser(warnings) {
408
421
  return new (0, _xmldom.DOMParser)({
409
422
  onError(level, msg2) {
410
- if (level === "fatalError") throw new (0, _chunk6XAAYAWLcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
423
+ if (level === "fatalError") throw new (0, _chunkF2HYH62Hcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
411
424
  _optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
412
425
  }
413
426
  });
@@ -432,14 +445,15 @@ function findChildByLocalName(parent, name) {
432
445
  }
433
446
  return null;
434
447
  }
435
- function extractTextFromNode(node) {
448
+ function extractTextFromNode(node, depth = 0) {
436
449
  let result = "";
450
+ if (depth > MAX_XML_DEPTH) return result;
437
451
  const children = node.childNodes;
438
452
  if (!children) return result;
439
453
  for (let i = 0; i < children.length; i++) {
440
454
  const child = children[i];
441
455
  if (child.nodeType === 3) result += child.textContent || "";
442
- else if (child.nodeType === 1) result += extractTextFromNode(child);
456
+ else if (child.nodeType === 1) result += extractTextFromNode(child, depth + 1);
443
457
  }
444
458
  return result.trim();
445
459
  }
@@ -463,10 +477,10 @@ async function extractHwpxStyles(zip, decompressed) {
463
477
  const xml = await file.async("text");
464
478
  if (decompressed) {
465
479
  decompressed.total += xml.length * 2;
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)");
480
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
467
481
  }
468
482
  const parser = createXmlParser();
469
- const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
483
+ const doc = parser.parseFromString(_chunkF2HYH62Hcjs.stripDtd.call(void 0, xml), "text/xml");
470
484
  if (!doc.documentElement) continue;
471
485
  const domDoc = doc;
472
486
  parseCharProperties(domDoc, result.charProperties);
@@ -649,9 +663,9 @@ function detectHwpxHeadings(blocks, styleMap) {
649
663
  let level = 0;
650
664
  if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
651
665
  const ratio = block.style.fontSize / baseFontSize;
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;
666
+ if (ratio >= _chunkF2HYH62Hcjs.HEADING_RATIO_H1) level = 1;
667
+ else if (ratio >= _chunkF2HYH62Hcjs.HEADING_RATIO_H2) level = 2;
668
+ else if (ratio >= _chunkF2HYH62Hcjs.HEADING_RATIO_H3) level = 3;
655
669
  }
656
670
  const compactText = text.replace(/\s+/g, "");
657
671
  if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
@@ -1323,7 +1337,7 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
1323
1337
  for (const ch of text.slice(from, to)) w += charW2(ch);
1324
1338
  return w;
1325
1339
  };
1326
- const units = _nullishCoalesce(text.match(mode === "keep" ? / +|[^ ]+/g : / +|[^ ]/g), () => ( []));
1340
+ const units = _nullishCoalesce(text.match(mode === "keep" ? / +|[^ ]+/gu : / +|[^ ]/gu), () => ( []));
1327
1341
  const starts = [0];
1328
1342
  let lineW = 0;
1329
1343
  let avail = firstWidth;
@@ -1576,7 +1590,7 @@ function needsGaejosikAssets(gongmun) {
1576
1590
  }
1577
1591
  function assertFiniteRange(name, value, min, max) {
1578
1592
  if (!Number.isFinite(value) || value < min || value > max) {
1579
- throw new (0, _chunk6XAAYAWLcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
1593
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
1580
1594
  }
1581
1595
  }
1582
1596
  function validateGongmunOptions(opts) {
@@ -1591,10 +1605,10 @@ function validateGongmunOptions(opts) {
1591
1605
  assertFiniteRange(`margins.${side}`, value, 0, 200);
1592
1606
  }
1593
1607
  if (opts.margins.left + opts.margins.right >= 210) {
1594
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("margins.left + margins.right must be less than 210");
1608
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("margins.left + margins.right must be less than 210");
1595
1609
  }
1596
1610
  if (opts.margins.top + opts.margins.bottom >= 297) {
1597
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("margins.top + margins.bottom must be less than 297");
1611
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("margins.top + margins.bottom must be less than 297");
1598
1612
  }
1599
1613
  }
1600
1614
  if (opts.sizes) {
@@ -1603,7 +1617,7 @@ function validateGongmunOptions(opts) {
1603
1617
  }
1604
1618
  }
1605
1619
  if (opts.approval && opts.approval.length > 6) {
1606
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("approval must contain at most 6 labels");
1620
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("approval must contain at most 6 labels");
1607
1621
  }
1608
1622
  }
1609
1623
  function incompatibleGongmunWarnings(opts) {
@@ -1792,6 +1806,7 @@ function toRoman(n) {
1792
1806
  return out;
1793
1807
  }
1794
1808
  function formatHeadNumber(n, numFormat) {
1809
+ if (n === 0 && numFormat === "DIGIT") return "0";
1795
1810
  if (n <= 0) n = 1;
1796
1811
  switch (numFormat) {
1797
1812
  case "DIGIT":
@@ -1849,25 +1864,25 @@ function resolveParaHeading(paraEl, ctx) {
1849
1864
  if (!numDef) return headingLevel ? { headingLevel } : null;
1850
1865
  let counters = ctx.shared.numState.get(numId);
1851
1866
  if (!counters) {
1852
- counters = new Array(11).fill(0);
1867
+ counters = new Array(11).fill(-1);
1853
1868
  ctx.shared.numState.set(numId, counters);
1854
1869
  }
1855
1870
  const head = numDef.heads.get(level);
1856
- counters[level] = counters[level] === 0 ? _nullishCoalesce(_optionalChain([head, 'optionalAccess', _22 => _22.start]), () => ( 1)) : counters[level] + 1;
1857
- for (let l = level + 1; l <= 10; l++) counters[l] = 0;
1871
+ counters[level] = counters[level] < 0 ? _nullishCoalesce(_optionalChain([head, 'optionalAccess', _22 => _22.start]), () => ( 1)) : counters[level] + 1;
1872
+ for (let l = level + 1; l <= 10; l++) counters[l] = -1;
1858
1873
  const fmtText = head ? head.text.trim() : `^${level}.`;
1859
1874
  const prefix = fmtText.replace(/\^(10|[1-9])/g, (_, d) => {
1860
1875
  const lv = parseInt(d, 10);
1861
1876
  const refHead = numDef.heads.get(lv);
1862
- const n = counters[lv] || _optionalChain([refHead, 'optionalAccess', _23 => _23.start]) || 1;
1877
+ const n = counters[lv] >= 0 ? counters[lv] : _nullishCoalesce(_optionalChain([refHead, 'optionalAccess', _23 => _23.start]), () => ( 1));
1863
1878
  return formatHeadNumber(n, _optionalChain([refHead, 'optionalAccess', _24 => _24.numFormat]) || "DIGIT");
1864
1879
  });
1865
1880
  return { prefix: prefix || void 0, headingLevel };
1866
1881
  }
1867
1882
 
1868
1883
  // src/hwpx/table-build.ts
1869
- function buildTableWithCellMeta(state) {
1870
- const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, state.rows);
1884
+ function buildTableWithCellMeta(state, keepAnchoredEmptyCols) {
1885
+ const table2 = _chunkXTCT6KQ5cjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols });
1871
1886
  if (state.caption) table2.caption = state.caption;
1872
1887
  const anchors = [];
1873
1888
  {
@@ -1931,13 +1946,13 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1931
1946
  if (newTable.caption) blocks.push({ type: "paragraph", text: newTable.caption, pageNumber: ctx.sectionNum });
1932
1947
  return parentTable;
1933
1948
  }
1934
- const ir = buildTableWithCellMeta(newTable);
1949
+ const ir = buildTableWithCellMeta(newTable, ctx.shared.keepTrailingEmptyCols);
1935
1950
  const block = { type: "table", table: ir, pageNumber: ctx.sectionNum };
1936
1951
  if (_optionalChain([parentTable, 'optionalAccess', _31 => _31.cell])) {
1937
1952
  const cell2 = parentTable.cell;
1938
1953
  (cell2.blocks ??= []).push(block);
1939
1954
  cell2.hasStructure = true;
1940
- let flat = _chunk6XAAYAWLcjs.convertTableToText.call(void 0, newTable.rows);
1955
+ let flat = _chunkXTCT6KQ5cjs.convertTableToText.call(void 0, newTable.rows);
1941
1956
  if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
1942
1957
  if (flat) cell2.text += (cell2.text ? "\n" : "") + flat;
1943
1958
  } else {
@@ -1949,7 +1964,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1949
1964
  // src/hwpx/section-walker.ts
1950
1965
  function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
1951
1966
  const parser = createXmlParser(warnings);
1952
- const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
1967
+ const doc = parser.parseFromString(_chunkF2HYH62Hcjs.stripDtd.call(void 0, xml), "text/xml");
1953
1968
  if (!doc.documentElement) return [];
1954
1969
  const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
1955
1970
  ctx.shared.track.deleteDepth = 0;
@@ -1965,7 +1980,8 @@ function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
1965
1980
  walkSection(doc.documentElement, blocks, null, [], ctx);
1966
1981
  return blocks;
1967
1982
  }
1968
- function extractImageRef(el) {
1983
+ function extractImageRef(el, depth = 0) {
1984
+ if (depth > MAX_XML_DEPTH) return null;
1969
1985
  const children = el.childNodes;
1970
1986
  if (!children) return null;
1971
1987
  for (let i = 0; i < children.length; i++) {
@@ -1976,7 +1992,7 @@ function extractImageRef(el) {
1976
1992
  const ref = child.getAttribute("binaryItemIDRef") || child.getAttribute("href") || "";
1977
1993
  if (ref) return ref;
1978
1994
  }
1979
- const nested = extractImageRef(child);
1995
+ const nested = extractImageRef(child, depth + 1);
1980
1996
  if (nested) return nested;
1981
1997
  }
1982
1998
  const directRef = el.getAttribute("binaryItemIDRef") || "";
@@ -2054,8 +2070,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2054
2070
  const cs = isNaN(rawCs) ? 1 : rawCs;
2055
2071
  const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
2056
2072
  const rs = isNaN(rawRs) ? 1 : rawRs;
2057
- tableCtx.cell.colSpan = clampSpan(cs, _chunk6XAAYAWLcjs.MAX_COLS);
2058
- tableCtx.cell.rowSpan = clampSpan(rs, _chunk6XAAYAWLcjs.MAX_ROWS);
2073
+ tableCtx.cell.colSpan = clampSpan(cs, _chunkXTCT6KQ5cjs.MAX_COLS);
2074
+ tableCtx.cell.rowSpan = clampSpan(rs, _chunkXTCT6KQ5cjs.MAX_ROWS);
2059
2075
  }
2060
2076
  break;
2061
2077
  case "p": {
@@ -2083,7 +2099,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2083
2099
  ;
2084
2100
  (cell2.blocks ??= []).push(cellBlock);
2085
2101
  } else if (!tableCtx) {
2086
- if (/^─{10,}$/.test(text)) {
2102
+ if (ctx.shared.kordocLayout && /^─{10,}$/.test(text)) {
2087
2103
  blocks.push({ type: "separator", pageNumber: ctx.sectionNum });
2088
2104
  tableCtx = walkParagraphChildren(el, blocks, tableCtx, tableStack, ctx, depth + 1);
2089
2105
  break;
@@ -2221,6 +2237,19 @@ function findKordocMarkedCell(el, depth) {
2221
2237
  }
2222
2238
  return null;
2223
2239
  }
2240
+ function hasPageAutoNum(el, depth = 0) {
2241
+ if (depth > 10) return false;
2242
+ const children = el.childNodes;
2243
+ if (!children) return false;
2244
+ for (let i = 0; i < children.length; i++) {
2245
+ const ch = children[i];
2246
+ if (ch.nodeType !== 1) continue;
2247
+ const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
2248
+ if (tag === "autoNum" && _optionalChain([ch, 'access', _44 => _44.getAttribute, 'optionalCall', _45 => _45("numType")]) === "PAGE") return true;
2249
+ if (hasPageAutoNum(ch, depth + 1)) return true;
2250
+ }
2251
+ return false;
2252
+ }
2224
2253
  function collectSubListText(el, ctx, depth = 0) {
2225
2254
  if (depth > 10) return "";
2226
2255
  const parts = [];
@@ -2253,7 +2282,7 @@ function flattenSubListTable(el, ctx, depth) {
2253
2282
  const sink = [];
2254
2283
  const st = { rows: [], currentRow: [], cell: null };
2255
2284
  walkSection(el, sink, st, [], ctx, depth + 1);
2256
- let flat = _chunk6XAAYAWLcjs.convertTableToText.call(void 0, st.rows);
2285
+ let flat = _chunkXTCT6KQ5cjs.convertTableToText.call(void 0, st.rows);
2257
2286
  if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
2258
2287
  return flat;
2259
2288
  }
@@ -2302,12 +2331,12 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
2302
2331
  } else if (localTag === "caption" && !inShape) {
2303
2332
  const capText = collectSubListText(el, ctx);
2304
2333
  if (capText) {
2305
- if (_optionalChain([tableCtx, 'optionalAccess', _44 => _44.cell])) mergeBlocksIntoCell(tableCtx.cell, [{ type: "paragraph", text: capText, pageNumber: ctx.sectionNum }]);
2334
+ if (_optionalChain([tableCtx, 'optionalAccess', _46 => _46.cell])) mergeBlocksIntoCell(tableCtx.cell, [{ type: "paragraph", text: capText, pageNumber: ctx.sectionNum }]);
2306
2335
  else if (tableCtx) tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + capText;
2307
2336
  else blocks.push({ type: "paragraph", text: capText, pageNumber: ctx.sectionNum });
2308
2337
  }
2309
2338
  } else if (localTag === "pic" || localTag === "shape" || localTag === "drawingObject") {
2310
- if (_optionalChain([tableCtx, 'optionalAccess', _45 => _45.cell])) {
2339
+ if (_optionalChain([tableCtx, 'optionalAccess', _47 => _47.cell])) {
2311
2340
  const sink = [];
2312
2341
  handleShape(el, sink, ctx);
2313
2342
  mergeBlocksIntoCell(tableCtx.cell, sink);
@@ -2315,7 +2344,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
2315
2344
  handleShape(el, blocks, ctx);
2316
2345
  }
2317
2346
  } else if (localTag === "drawText") {
2318
- if (_optionalChain([tableCtx, 'optionalAccess', _46 => _46.cell])) {
2347
+ if (_optionalChain([tableCtx, 'optionalAccess', _48 => _48.cell])) {
2319
2348
  const sink = [];
2320
2349
  extractDrawTextBlocks(el, sink, ctx);
2321
2350
  mergeBlocksIntoCell(tableCtx.cell, sink);
@@ -2359,9 +2388,9 @@ function extractDrawTextBlocks(drawTextNode, blocks, ctx) {
2359
2388
  } else {
2360
2389
  const info = extractParagraphInfo(child, ctx.styleMap, ctx);
2361
2390
  let text = info.text.trim();
2391
+ const ph = resolveParaHeading(child, ctx);
2362
2392
  if (text) {
2363
- const ph = resolveParaHeading(child, ctx);
2364
- if (_optionalChain([ph, 'optionalAccess', _47 => _47.prefix])) text = ph.prefix + " " + text;
2393
+ if (_optionalChain([ph, 'optionalAccess', _49 => _49.prefix])) text = ph.prefix + " " + text;
2365
2394
  const block = { type: "paragraph", text, style: _nullishCoalesce(info.style, () => ( void 0)), pageNumber: ctx.sectionNum };
2366
2395
  if (info.href) block.href = info.href;
2367
2396
  if (info.footnote) block.footnoteText = info.footnote;
@@ -2386,19 +2415,35 @@ function extractHyperlinkHref(fieldBegin) {
2386
2415
  let url = (ch.textContent || "").trim();
2387
2416
  if (!url) continue;
2388
2417
  url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
2389
- const safe = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, url);
2418
+ const safe = _chunkF2HYH62Hcjs.sanitizeHref.call(void 0, url);
2390
2419
  if (safe) return safe;
2391
2420
  }
2392
2421
  return void 0;
2393
2422
  }
2394
2423
  function isInDeletedRange(ctx) {
2395
- return (_nullishCoalesce(_optionalChain([ctx, 'optionalAccess', _48 => _48.shared, 'access', _49 => _49.track, 'access', _50 => _50.deleteDepth]), () => ( 0))) > 0;
2424
+ return (_nullishCoalesce(_optionalChain([ctx, 'optionalAccess', _50 => _50.shared, 'access', _51 => _51.track, 'access', _52 => _52.deleteDepth]), () => ( 0))) > 0;
2396
2425
  }
2397
2426
  function extractParagraphInfo(para2, styleMap, ctx) {
2398
2427
  let text = "";
2399
2428
  let href;
2400
2429
  let footnote;
2401
2430
  let charPrId;
2431
+ const linkRanges = [];
2432
+ const openFields = [];
2433
+ const onFieldBegin = (el) => {
2434
+ const url = extractHyperlinkHref(el);
2435
+ if (url) {
2436
+ linkRanges.push({ url, start: text.length });
2437
+ openFields.push({ rangeIdx: linkRanges.length - 1 });
2438
+ if (!href) href = url;
2439
+ } else {
2440
+ openFields.push({});
2441
+ }
2442
+ };
2443
+ const onFieldEnd = () => {
2444
+ const open = openFields.pop();
2445
+ if (_optionalChain([open, 'optionalAccess', _53 => _53.rangeIdx]) !== void 0) linkRanges[open.rangeIdx].end = text.length;
2446
+ };
2402
2447
  const handleCtrl = (ctrlEl) => {
2403
2448
  const kids2 = ctrlEl.childNodes;
2404
2449
  if (!kids2) return;
@@ -2408,10 +2453,13 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2408
2453
  const ktag = (k.tagName || k.localName || "").replace(/^[^:]+:/, "");
2409
2454
  switch (ktag) {
2410
2455
  // 머리말/꼬리말 — 문서당 1회 수집, 본문 앞/뒤 배치
2456
+ // 페이지 번호 크롬(autoNum PAGE + 문자 없는 잔여 텍스트, 예: "- 1 -")은 본문 정보가
2457
+ // 아니므로 방출하지 않는다
2411
2458
  case "header":
2412
2459
  case "footer": {
2413
2460
  if (!ctx) break;
2414
2461
  const t = collectSubListText(k, ctx);
2462
+ if (t && hasPageAutoNum(k) && !/\p{L}/u.test(t)) break;
2415
2463
  if (t) {
2416
2464
  const bucket = ktag === "header" ? ctx.shared.pageText.headers : ctx.shared.pageText.footers;
2417
2465
  if (!bucket.includes(t)) bucket.push(t);
@@ -2425,13 +2473,12 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2425
2473
  if (noteText) footnote = (footnote ? footnote + "; " : "") + noteText;
2426
2474
  break;
2427
2475
  }
2428
- // 하이퍼링크 — fieldBegin type=HYPERLINK의 Path 파라미터
2429
- case "fieldBegin": {
2430
- const url = extractHyperlinkHref(k);
2431
- if (url && !href) href = url;
2476
+ // 하이퍼링크 — fieldBegin type=HYPERLINK의 Path 파라미터 (extent 오프셋 추적)
2477
+ case "fieldBegin":
2478
+ onFieldBegin(k);
2432
2479
  break;
2433
- }
2434
2480
  case "fieldEnd":
2481
+ onFieldEnd();
2435
2482
  break;
2436
2483
  // 변경추적 — 삭제 구간(deleteBegin~End)의 텍스트는 출력 제외 (최종본 상태 재현)
2437
2484
  case "deleteBegin":
@@ -2446,7 +2493,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2446
2493
  // 삽입분은 최종본에 포함
2447
2494
  // 숨은 설명 — 본문 혼입 차단
2448
2495
  case "hiddenComment": {
2449
- if (_optionalChain([ctx, 'optionalAccess', _51 => _51.warnings]) && extractTextFromNode(k)) {
2496
+ if (_optionalChain([ctx, 'optionalAccess', _54 => _54.warnings]) && extractTextFromNode(k)) {
2450
2497
  ctx.warnings.push({ page: ctx.sectionNum, message: "\uC228\uC740 \uC124\uBA85 \uD14D\uC2A4\uD2B8 \uC81C\uC678: hiddenComment", code: "HIDDEN_TEXT_FILTERED" });
2451
2498
  }
2452
2499
  break;
@@ -2466,14 +2513,15 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2466
2513
  break;
2467
2514
  // 미지원 요소 — 텍스트를 가졌으면 무음 손실 대신 경고
2468
2515
  default: {
2469
- if (_optionalChain([ctx, 'optionalAccess', _52 => _52.warnings]) && extractTextFromNode(k)) {
2516
+ if (_optionalChain([ctx, 'optionalAccess', _55 => _55.warnings]) && extractTextFromNode(k)) {
2470
2517
  ctx.warnings.push({ page: ctx.sectionNum, message: `\uBBF8\uC9C0\uC6D0 \uC81C\uC5B4 \uC694\uC18C\uC758 \uD14D\uC2A4\uD2B8 \uC190\uC2E4: ${ktag}`, code: "UNSUPPORTED_ELEMENT" });
2471
2518
  }
2472
2519
  }
2473
2520
  }
2474
2521
  }
2475
2522
  };
2476
- const walk = (node) => {
2523
+ const walk = (node, depth = 0) => {
2524
+ if (depth > MAX_XML_DEPTH) return;
2477
2525
  const children = node.childNodes;
2478
2526
  if (!children) return;
2479
2527
  for (let i = 0; i < children.length; i++) {
@@ -2483,7 +2531,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2483
2531
  if (isInDeletedRange(ctx)) {
2484
2532
  if (t && ctx && !ctx.shared.track.warned) {
2485
2533
  ctx.shared.track.warned = true;
2486
- _optionalChain([ctx, 'access', _53 => _53.warnings, 'optionalAccess', _54 => _54.push, 'call', _55 => _55({ page: ctx.sectionNum, message: "\uBCC0\uACBD\uCD94\uC801 \uC0AD\uC81C \uD14D\uC2A4\uD2B8 \uCD9C\uB825 \uC81C\uC678", code: "HIDDEN_TEXT_FILTERED" })]);
2534
+ _optionalChain([ctx, 'access', _56 => _56.warnings, 'optionalAccess', _57 => _57.push, 'call', _58 => _58({ page: ctx.sectionNum, message: "\uBCC0\uACBD\uCD94\uC801 \uC0AD\uC81C \uD14D\uC2A4\uD2B8 \uCD9C\uB825 \uC81C\uC678", code: "HIDDEN_TEXT_FILTERED" })]);
2487
2535
  }
2488
2536
  } else {
2489
2537
  text += t;
@@ -2494,7 +2542,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2494
2542
  const tag = (child.tagName || child.localName || "").replace(/^[^:]+:/, "");
2495
2543
  switch (tag) {
2496
2544
  case "t":
2497
- walk(child);
2545
+ walk(child, depth + 1);
2498
2546
  break;
2499
2547
  // 자식 순회 (tab 등 하위 요소 처리)
2500
2548
  case "tab": {
@@ -2524,10 +2572,10 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2524
2572
  case "hyperlink": {
2525
2573
  const url = child.getAttribute("url") || child.getAttribute("href") || "";
2526
2574
  if (url) {
2527
- const safe = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, url);
2575
+ const safe = _chunkF2HYH62Hcjs.sanitizeHref.call(void 0, url);
2528
2576
  if (safe) href = safe;
2529
2577
  }
2530
- walk(child);
2578
+ walk(child, depth + 1);
2531
2579
  break;
2532
2580
  }
2533
2581
  // 각주/미주
@@ -2543,12 +2591,10 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2543
2591
  case "ctrl":
2544
2592
  handleCtrl(child);
2545
2593
  break;
2546
- // run 직계 fieldBegin (비표준 경로) — 하이퍼링크 URL 추출
2547
- case "fieldBegin": {
2548
- const url = extractHyperlinkHref(child);
2549
- if (url && !href) href = url;
2594
+ // run 직계 fieldBegin (비표준 경로) — 하이퍼링크 URL·extent 추적
2595
+ case "fieldBegin":
2596
+ onFieldBegin(child);
2550
2597
  break;
2551
- }
2552
2598
  // run 직계 변경추적 마커 (비표준 경로)
2553
2599
  case "deleteBegin":
2554
2600
  if (ctx) ctx.shared.track.deleteDepth++;
@@ -2560,6 +2606,8 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2560
2606
  case "insertEnd":
2561
2607
  break;
2562
2608
  case "fieldEnd":
2609
+ onFieldEnd();
2610
+ break;
2563
2611
  case "parameters":
2564
2612
  case "stringParam":
2565
2613
  case "integerParam":
@@ -2598,22 +2646,34 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2598
2646
  case "r": {
2599
2647
  const runCharPr = child.getAttribute("charPrIDRef");
2600
2648
  if (runCharPr && !charPrId) charPrId = runCharPr;
2601
- walk(child);
2649
+ walk(child, depth + 1);
2602
2650
  break;
2603
2651
  }
2604
2652
  default:
2605
- walk(child);
2653
+ walk(child, depth + 1);
2606
2654
  break;
2607
2655
  }
2608
2656
  }
2609
2657
  };
2610
2658
  walk(para2);
2659
+ {
2660
+ const applied = [];
2661
+ const closed = linkRanges.filter((r) => r.end !== void 0 && r.end > r.start).sort((a, b) => b.start - a.start);
2662
+ for (const r of closed) {
2663
+ if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
2664
+ const anchor = text.slice(r.start, r.end);
2665
+ if (!anchor.trim() || /[\n\x1F\[\]]/.test(anchor)) continue;
2666
+ text = text.slice(0, r.start) + `[${anchor}](${r.url})` + text.slice(r.end);
2667
+ applied.push([r.start, r.end]);
2668
+ }
2669
+ if (applied.length) href = void 0;
2670
+ }
2611
2671
  const leaderIdx = text.indexOf("");
2612
2672
  if (leaderIdx >= 0) text = text.substring(0, leaderIdx);
2613
2673
  let cleanText = text.replace(/[ \t]+/g, " ").trim();
2614
2674
  if (/^그림입니다\.?\s*원본\s*그림의\s*(이름|크기)/.test(cleanText)) cleanText = "";
2615
2675
  cleanText = cleanText.replace(/그림입니다\.?\s*원본\s*그림의\s*(이름|크기)[^\n]*(\n[^\n]*원본\s*그림의\s*(이름|크기)[^\n]*)*/g, "").trim();
2616
- cleanText = cleanText.replace(/(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|선|직선|곡선|화살표|오각형|육각형|팔각형|별|십자|구름|마름모|도넛|평행사변형|사다리꼴|개체|그리기\s?개체|묶음\s?개체|글상자|표|그림|OLE\s?개체)\s?입니다\.?/g, "").trim();
2676
+ cleanText = cleanText.replace(/^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|선|직선|곡선|화살표|오각형|육각형|팔각형|별|십자|구름|마름모|도넛|평행사변형|사다리꼴|개체|그리기\s?개체|묶음\s?개체|글상자|표|그림|OLE\s?개체)\s?입니다\.?$/gm, "").trim();
2617
2677
  let style;
2618
2678
  if (styleMap && charPrId) {
2619
2679
  const charProp = styleMap.charProperties.get(charPrId);
@@ -2651,13 +2711,13 @@ function extractRunSpans(para2, ctx, mode, requireMixed) {
2651
2711
  if (tag !== "run" && tag !== "r") return null;
2652
2712
  let text = "";
2653
2713
  const rkids = child.childNodes;
2654
- for (let j = 0; j < (_nullishCoalesce(_optionalChain([rkids, 'optionalAccess', _56 => _56.length]), () => ( 0))); j++) {
2714
+ for (let j = 0; j < (_nullishCoalesce(_optionalChain([rkids, 'optionalAccess', _59 => _59.length]), () => ( 0))); j++) {
2655
2715
  const rc = rkids[j];
2656
2716
  if (rc.nodeType !== 1) continue;
2657
2717
  const rtag = (rc.tagName || rc.localName || "").replace(/^[^:]+:/, "");
2658
2718
  if (rtag === "t") {
2659
2719
  const tkids = rc.childNodes;
2660
- for (let k = 0; k < (_nullishCoalesce(_optionalChain([tkids, 'optionalAccess', _57 => _57.length]), () => ( 0))); k++) {
2720
+ for (let k = 0; k < (_nullishCoalesce(_optionalChain([tkids, 'optionalAccess', _60 => _60.length]), () => ( 0))); k++) {
2661
2721
  const tk = tkids[k];
2662
2722
  if (tk.nodeType === 3) text += tk.textContent || "";
2663
2723
  else if (tk.nodeType === 1) return null;
@@ -2675,8 +2735,8 @@ function extractRunSpans(para2, ctx, mode, requireMixed) {
2675
2735
  const span = { text };
2676
2736
  if (mode !== "foreign" && prId === KORDOC_CHAR_CODE) span.code = true;
2677
2737
  else {
2678
- if (_optionalChain([cp, 'optionalAccess', _58 => _58.bold])) span.bold = true;
2679
- if (_optionalChain([cp, 'optionalAccess', _59 => _59.italic])) span.italic = true;
2738
+ if (_optionalChain([cp, 'optionalAccess', _61 => _61.bold])) span.bold = true;
2739
+ if (_optionalChain([cp, 'optionalAccess', _62 => _62.italic])) span.italic = true;
2680
2740
  }
2681
2741
  if (span.bold || span.italic || span.code) styled = true;
2682
2742
  spans.push(span);
@@ -2699,12 +2759,12 @@ function gongmunDepthFromIndent(para2, left, ctx) {
2699
2759
  if (!styleMap) return null;
2700
2760
  let unit = 0;
2701
2761
  const kids2 = para2.childNodes;
2702
- for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids2, 'optionalAccess', _60 => _60.length]), () => ( 0))); i++) {
2762
+ for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids2, 'optionalAccess', _63 => _63.length]), () => ( 0))); i++) {
2703
2763
  const child = kids2[i];
2704
2764
  if (child.nodeType !== 1) continue;
2705
2765
  const tag = (child.tagName || child.localName || "").replace(/^[^:]+:/, "");
2706
2766
  if (tag !== "run" && tag !== "r") continue;
2707
- const size = _optionalChain([styleMap, 'access', _61 => _61.charProperties, 'access', _62 => _62.get, 'call', _63 => _63(_nullishCoalesce(child.getAttribute("charPrIDRef"), () => ( ""))), 'optionalAccess', _64 => _64.fontSize]);
2767
+ const size = _optionalChain([styleMap, 'access', _64 => _64.charProperties, 'access', _65 => _65.get, 'call', _66 => _66(_nullishCoalesce(child.getAttribute("charPrIDRef"), () => ( ""))), 'optionalAccess', _67 => _67.fontSize]);
2708
2768
  if (size) unit = size * 100;
2709
2769
  break;
2710
2770
  }
@@ -2737,10 +2797,9 @@ var CHAR_LINE = 0;
2737
2797
  var CHAR_SECTION_BREAK = 10;
2738
2798
  var CHAR_PARA = 13;
2739
2799
  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;
2800
+ var CHAR_HYPHEN = 24;
2801
+ var CHAR_NBSP = 30;
2802
+ var CHAR_FIXED_WIDTH = 31;
2744
2803
  var FLAG_COMPRESSED = 1 << 0;
2745
2804
  var FLAG_ENCRYPTED = 1 << 1;
2746
2805
  var FLAG_DISTRIBUTION = 1 << 2;
@@ -2778,7 +2837,7 @@ function decompressStream(data) {
2778
2837
  return _zlib.inflateRawSync.call(void 0, data, opts);
2779
2838
  }
2780
2839
  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)");
2840
+ if (data.length < 40) throw new (0, _chunkF2HYH62Hcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2782
2841
  const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
2783
2842
  return {
2784
2843
  signature: sig,
@@ -2911,7 +2970,7 @@ function appendParaText(state, data, resolveControl) {
2911
2970
  const resolveAt = (byteOffset, extended) => {
2912
2971
  const ctrlId = data.readUInt32LE(byteOffset);
2913
2972
  const idx = extended ? state.ctrlIdx : -1;
2914
- const replacement = _optionalChain([resolveControl, 'optionalCall', _65 => _65(idx, ctrlId)]);
2973
+ const replacement = _optionalChain([resolveControl, 'optionalCall', _68 => _68(idx, ctrlId)]);
2915
2974
  if (replacement) result += replacement;
2916
2975
  if (extended) state.ctrlIdx++;
2917
2976
  };
@@ -2939,9 +2998,6 @@ function appendParaText(state, data, resolveControl) {
2939
2998
  result += "-";
2940
2999
  break;
2941
3000
  case CHAR_NBSP:
2942
- result += " ";
2943
- break;
2944
- case CHAR_FIXED_NBSP:
2945
3001
  result += "\xA0";
2946
3002
  break;
2947
3003
  // 진짜 NBSP
@@ -3116,7 +3172,7 @@ function extractHwp5Images(fileIndex, blocks, warnings, sweepUnreferenced) {
3116
3172
  const binDataMap = /* @__PURE__ */ new Map();
3117
3173
  if (fileIndex) {
3118
3174
  for (const entry of fileIndex) {
3119
- if (!_optionalChain([entry, 'optionalAccess', _66 => _66.name]) || !entry.content) continue;
3175
+ if (!_optionalChain([entry, 'optionalAccess', _69 => _69.name]) || !entry.content) continue;
3120
3176
  const match = entry.name.match(BIN_ENTRY_RE);
3121
3177
  if (!match) continue;
3122
3178
  const idx = parseInt(match[1], 16);
@@ -3192,7 +3248,7 @@ function collectImageBlocks2(blocks, out, ownerCell, depth = 0) {
3192
3248
  } else if (block.type === "table" && block.table) {
3193
3249
  for (const row of block.table.cells) {
3194
3250
  for (const cell2 of row) {
3195
- if (_optionalChain([cell2, 'access', _67 => _67.blocks, 'optionalAccess', _68 => _68.length])) collectImageBlocks2(cell2.blocks, out, cell2, depth + 1);
3251
+ if (_optionalChain([cell2, 'access', _70 => _70.blocks, 'optionalAccess', _71 => _71.length])) collectImageBlocks2(cell2.blocks, out, cell2, depth + 1);
3196
3252
  }
3197
3253
  }
3198
3254
  }
@@ -3230,46 +3286,47 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
3230
3286
  }
3231
3287
  const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
3232
3288
  for (const path of allCandidates) {
3233
- if (_chunk6XAAYAWLcjs.isPathTraversal.call(void 0, path)) continue;
3289
+ if (_chunkF2HYH62Hcjs.isPathTraversal.call(void 0, path)) continue;
3234
3290
  const file = zip.file(path);
3235
3291
  if (!file) continue;
3236
3292
  try {
3237
3293
  const data = await file.async("uint8array");
3238
3294
  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)");
3295
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3240
3296
  const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
3241
3297
  const mimeType = imageExtToMime(ext);
3242
3298
  imageIndex++;
3243
- const filename = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
3244
- img = { filename, data, mimeType };
3299
+ const filename2 = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
3300
+ img = { filename: filename2, data, mimeType };
3245
3301
  images.push(img);
3246
3302
  usedPaths.add(path);
3247
3303
  break;
3248
3304
  } catch (err) {
3249
- if (err instanceof _chunk6XAAYAWLcjs.KordocError) throw err;
3305
+ if (err instanceof _chunkF2HYH62Hcjs.KordocError) throw err;
3250
3306
  }
3251
3307
  }
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" })]);
3308
+ if (!img) _optionalChain([warnings, 'optionalAccess', _72 => _72.push, 'call', _73 => _73({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
3253
3309
  resolved.set(ref, img);
3254
3310
  }
3255
3311
  if (!img) {
3256
3312
  block.type = "paragraph";
3257
3313
  block.text = `[\uC774\uBBF8\uC9C0: ${ref}]`;
3258
- if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, `[\uC774\uBBF8\uC9C0: ${ref}]`);
3314
+ if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, () => `[\uC774\uBBF8\uC9C0: ${ref}]`);
3259
3315
  continue;
3260
3316
  }
3261
- block.text = img.filename;
3317
+ const filename = img.filename;
3318
+ block.text = filename;
3262
3319
  block.imageData = { data: img.data, mimeType: img.mimeType, filename: ref };
3263
- if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, `![image](${img.filename})`);
3320
+ if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, () => `![image](${filename})`);
3264
3321
  }
3265
3322
  if (sweepUnreferenced) {
3266
3323
  const binEntries = zip.file(/(?:^|\/)BinData\//i);
3267
3324
  for (const file of binEntries) {
3268
- if (file.dir || usedPaths.has(file.name) || _chunk6XAAYAWLcjs.isPathTraversal.call(void 0, file.name)) continue;
3325
+ if (file.dir || usedPaths.has(file.name) || _chunkF2HYH62Hcjs.isPathTraversal.call(void 0, file.name)) continue;
3269
3326
  try {
3270
3327
  const data = await file.async("uint8array");
3271
3328
  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)");
3329
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3273
3330
  const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
3274
3331
  let mimeType = imageExtToMime(ext);
3275
3332
  if (mimeType === "application/octet-stream") {
@@ -3283,8 +3340,8 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
3283
3340
  images.push(img);
3284
3341
  blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
3285
3342
  } 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" })]);
3343
+ if (err instanceof _chunkF2HYH62Hcjs.KordocError) throw err;
3344
+ _optionalChain([warnings, 'optionalAccess', _74 => _74.push, 'call', _75 => _75({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
3288
3345
  }
3289
3346
  }
3290
3347
  }
@@ -3334,7 +3391,7 @@ function extractFromBrokenZip(buffer) {
3334
3391
  }
3335
3392
  const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
3336
3393
  const name = new TextDecoder().decode(nameBytes);
3337
- if (_chunk6XAAYAWLcjs.isPathTraversal.call(void 0, name)) {
3394
+ if (_chunkF2HYH62Hcjs.isPathTraversal.call(void 0, name)) {
3338
3395
  pos = fileStart + compSize;
3339
3396
  continue;
3340
3397
  }
@@ -3352,16 +3409,16 @@ function extractFromBrokenZip(buffer) {
3352
3409
  continue;
3353
3410
  }
3354
3411
  totalDecompressed += content.length * 2;
3355
- if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
3412
+ if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
3356
3413
  sectionNum++;
3357
3414
  blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
3358
3415
  } catch (e16) {
3359
3416
  continue;
3360
3417
  }
3361
3418
  }
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");
3419
+ if (blocks.length === 0) throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3363
3420
  applyPageText(blocks, shared);
3364
- const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
3421
+ const markdown = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, blocks);
3365
3422
  return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
3366
3423
  }
3367
3424
  async function readKordocLayout(zip) {
@@ -3370,7 +3427,7 @@ async function readKordocLayout(zip) {
3370
3427
  try {
3371
3428
  const xml = await file.async("text");
3372
3429
  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));
3430
+ return _nullishCoalesce(_optionalChain([xml, 'access', _76 => _76.match, 'call', _77 => _77(/<opf:meta\b[^>]*name="kordoc-layout"[^>]*content="([^"]*)"/), 'optionalAccess', _78 => _78[1]]), () => ( null));
3374
3431
  } catch (e17) {
3375
3432
  return null;
3376
3433
  }
@@ -3386,18 +3443,18 @@ async function resolveSectionPaths(zip) {
3386
3443
  if (paths.length > 0) return paths;
3387
3444
  }
3388
3445
  const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
3389
- return sectionFiles.map((f) => f.name).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
3446
+ return sectionFiles.map((f) => f.name).sort(_chunkF2HYH62Hcjs.compareSectionPaths);
3390
3447
  }
3391
3448
  function parseSectionPathsFromManifest(xml) {
3392
3449
  const parser = createXmlParser();
3393
- const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
3450
+ const doc = parser.parseFromString(_chunkF2HYH62Hcjs.stripDtd.call(void 0, xml), "text/xml");
3394
3451
  const items = doc.getElementsByTagName("opf:item");
3395
3452
  const spine = doc.getElementsByTagName("opf:itemref");
3396
3453
  const idToHref = /* @__PURE__ */ new Map();
3397
3454
  for (let i = 0; i < items.length; i++) {
3398
3455
  const item = items[i];
3399
3456
  const id = item.getAttribute("id") || "";
3400
- const href = _chunk6XAAYAWLcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
3457
+ const href = _chunkF2HYH62Hcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
3401
3458
  if (id && href) idToHref.set(id, href);
3402
3459
  }
3403
3460
  if (spine.length > 0) {
@@ -3408,7 +3465,7 @@ function parseSectionPathsFromManifest(xml) {
3408
3465
  }
3409
3466
  if (ordered.length > 0) return ordered;
3410
3467
  }
3411
- return Array.from(idToHref.values()).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
3468
+ return Array.from(idToHref.values()).sort(_chunkF2HYH62Hcjs.compareSectionPaths);
3412
3469
  }
3413
3470
 
3414
3471
  // src/hwpx/metadata.ts
@@ -3421,7 +3478,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
3421
3478
  const xml = await file.async("text");
3422
3479
  if (decompressed) {
3423
3480
  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)");
3481
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3425
3482
  }
3426
3483
  parseDublinCoreMetadata(xml, metadata);
3427
3484
  if (metadata.title || metadata.author) return;
@@ -3431,13 +3488,13 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
3431
3488
  }
3432
3489
  function parseDublinCoreMetadata(xml, metadata) {
3433
3490
  const parser = createXmlParser();
3434
- const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
3491
+ const doc = parser.parseFromString(_chunkF2HYH62Hcjs.stripDtd.call(void 0, xml), "text/xml");
3435
3492
  if (!doc.documentElement) return;
3436
3493
  const getText = (tagNames) => {
3437
3494
  for (const tag of tagNames) {
3438
3495
  const els = doc.getElementsByTagName(tag);
3439
3496
  if (els.length > 0) {
3440
- const text = _optionalChain([els, 'access', _76 => _76[0], 'access', _77 => _77.textContent, 'optionalAccess', _78 => _78.trim, 'call', _79 => _79()]);
3497
+ const text = _optionalChain([els, 'access', _79 => _79[0], 'access', _80 => _80.textContent, 'optionalAccess', _81 => _81.trim, 'call', _82 => _82()]);
3441
3498
  if (text) return text;
3442
3499
  }
3443
3500
  }
@@ -3456,7 +3513,7 @@ function parseDublinCoreMetadata(xml, metadata) {
3456
3513
 
3457
3514
  // src/hwpx/parser.ts
3458
3515
  async function parseHwpxDocument(buffer, options) {
3459
- _chunk6XAAYAWLcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
3516
+ _chunkF2HYH62Hcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
3460
3517
  let zip;
3461
3518
  try {
3462
3519
  zip = await _jszip2.default.loadAsync(buffer);
@@ -3465,19 +3522,19 @@ async function parseHwpxDocument(buffer, options) {
3465
3522
  }
3466
3523
  const actualEntryCount = Object.keys(zip.files).length;
3467
3524
  if (actualEntryCount > MAX_ZIP_ENTRIES) {
3468
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3525
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3469
3526
  }
3470
3527
  const manifestFile = zip.file("META-INF/manifest.xml");
3471
3528
  if (manifestFile) {
3472
3529
  const manifestXml = await manifestFile.async("text");
3473
3530
  if (isEncryptedHwpx(manifestXml)) {
3474
- if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _80 => _80.filePath])) {
3531
+ if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _83 => _83.filePath])) {
3475
3532
  const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
3476
3533
  if (pages.some((p) => p && p.trim().length > 0)) {
3477
3534
  return comResultToParseResult(pages, pageCount, warnings2);
3478
3535
  }
3479
3536
  }
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.");
3537
+ throw new (0, _chunkF2HYH62Hcjs.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
3538
  }
3482
3539
  }
3483
3540
  const decompressed = { total: 0 };
@@ -3486,13 +3543,14 @@ async function parseHwpxDocument(buffer, options) {
3486
3543
  const styleMap = await extractHwpxStyles(zip, decompressed);
3487
3544
  const warnings = [];
3488
3545
  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");
3546
+ if (sectionPaths.length === 0) throw new (0, _chunkF2HYH62Hcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3490
3547
  metadata.pageCount = sectionPaths.length;
3491
- const pageFilter = _optionalChain([options, 'optionalAccess', _81 => _81.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
3548
+ const pageFilter = _optionalChain([options, 'optionalAccess', _84 => _84.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
3492
3549
  const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
3493
3550
  const blocks = [];
3494
3551
  const shared = createSectionShared();
3495
3552
  shared.kordocLayout = await readKordocLayout(zip);
3553
+ shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _85 => _85.keepTrailingEmptyCols]);
3496
3554
  let parsedSections = 0;
3497
3555
  for (let si = 0; si < sectionPaths.length; si++) {
3498
3556
  if (pageFilter && !pageFilter.has(si + 1)) continue;
@@ -3501,12 +3559,12 @@ async function parseHwpxDocument(buffer, options) {
3501
3559
  try {
3502
3560
  const xml = await file.async("text");
3503
3561
  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)");
3562
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new ZipBombError("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
3505
3563
  blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
3506
3564
  parsedSections++;
3507
- _optionalChain([options, 'optionalAccess', _82 => _82.onProgress, 'optionalCall', _83 => _83(parsedSections, totalTarget)]);
3565
+ _optionalChain([options, 'optionalAccess', _86 => _86.onProgress, 'optionalCall', _87 => _87(parsedSections, totalTarget)]);
3508
3566
  } catch (secErr) {
3509
- if (secErr instanceof _chunk6XAAYAWLcjs.KordocError) throw secErr;
3567
+ if (secErr instanceof ZipBombError) throw secErr;
3510
3568
  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" });
3511
3569
  }
3512
3570
  }
@@ -3514,7 +3572,7 @@ async function parseHwpxDocument(buffer, options) {
3514
3572
  const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
3515
3573
  detectHwpxHeadings(blocks, styleMap);
3516
3574
  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);
3575
+ const markdown = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, blocks);
3518
3576
  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 };
3519
3577
  }
3520
3578
 
@@ -4693,22 +4751,22 @@ function parseHwp5Document(buffer, options) {
4693
4751
  lenientCfb = parseLenientCfb(buffer);
4694
4752
  warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
4695
4753
  } catch (e22) {
4696
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
4754
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
4697
4755
  }
4698
4756
  }
4699
4757
  const findStream = (path) => {
4700
4758
  if (cfb) {
4701
4759
  const entry = CFB.find(cfb, path);
4702
- return _optionalChain([entry, 'optionalAccess', _84 => _84.content]) ? Buffer.from(entry.content) : null;
4760
+ return _optionalChain([entry, 'optionalAccess', _88 => _88.content]) ? Buffer.from(entry.content) : null;
4703
4761
  }
4704
4762
  return lenientCfb.findStream(path);
4705
4763
  };
4706
4764
  const headerData = findStream("/FileHeader");
4707
- if (!headerData) throw new (0, _chunk6XAAYAWLcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
4765
+ if (!headerData) throw new (0, _chunkF2HYH62Hcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
4708
4766
  const header = parseFileHeader(headerData);
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");
4767
+ if (header.signature !== "HWP Document File") throw new (0, _chunkF2HYH62Hcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
4768
+ if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
4769
+ if (header.flags & FLAG_DRM) throw new (0, _chunkF2HYH62Hcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
4712
4770
  const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
4713
4771
  const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
4714
4772
  const metadata = {
@@ -4717,12 +4775,13 @@ function parseHwp5Document(buffer, options) {
4717
4775
  if (cfb) extractHwp5Metadata(cfb, metadata);
4718
4776
  const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
4719
4777
  const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
4720
- if (sections.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
4778
+ if (sections.length === 0) throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
4721
4779
  metadata.pageCount = sections.length;
4722
- const pageFilter = _optionalChain([options, 'optionalAccess', _85 => _85.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
4780
+ const pageFilter = _optionalChain([options, 'optionalAccess', _89 => _89.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
4723
4781
  const totalTarget = pageFilter ? pageFilter.size : sections.length;
4724
4782
  const bodyBlocks = [];
4725
4783
  const doc = createHwp5DocState();
4784
+ doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _90 => _90.keepTrailingEmptyCols]);
4726
4785
  let totalDecompressed = 0;
4727
4786
  let parsedSections = 0;
4728
4787
  for (let si = 0; si < sections.length; si++) {
@@ -4731,22 +4790,22 @@ function parseHwp5Document(buffer, options) {
4731
4790
  const sectionData = sections[si];
4732
4791
  const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
4733
4792
  totalDecompressed += data.length;
4734
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4793
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4735
4794
  const records = readRecords(data);
4736
4795
  const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
4737
4796
  bodyBlocks.push(...sectionBlocks);
4738
4797
  parsedSections++;
4739
- _optionalChain([options, 'optionalAccess', _86 => _86.onProgress, 'optionalCall', _87 => _87(parsedSections, totalTarget)]);
4798
+ _optionalChain([options, 'optionalAccess', _91 => _91.onProgress, 'optionalCall', _92 => _92(parsedSections, totalTarget)]);
4740
4799
  } catch (secErr) {
4741
- if (secErr instanceof _chunk6XAAYAWLcjs.KordocError) throw secErr;
4800
+ if (secErr instanceof _chunkF2HYH62Hcjs.KordocError) throw secErr;
4742
4801
  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" });
4743
4802
  }
4744
4803
  }
4745
4804
  const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
4746
4805
  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);
4806
+ let flatBlocks = _chunkXTCT6KQ5cjs.flattenLayoutTables.call(void 0, blocks);
4807
+ if (_optionalChain([options, 'optionalAccess', _93 => _93.dedupeRunningHeaders])) {
4808
+ const deduped = _chunkXTCT6KQ5cjs.dedupeRunningHeaders.call(void 0, flatBlocks);
4750
4809
  const removed = flatBlocks.length - deduped.length;
4751
4810
  if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
4752
4811
  flatBlocks = deduped;
@@ -4755,10 +4814,10 @@ function parseHwp5Document(buffer, options) {
4755
4814
  detectHwp5Headings(flatBlocks, docInfo);
4756
4815
  }
4757
4816
  const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
4758
- let markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, flatBlocks);
4759
- if (_optionalChain([options, 'optionalAccess', _89 => _89.inlineImages]) && images.length > 0) {
4817
+ let markdown = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, flatBlocks);
4818
+ if (_optionalChain([options, 'optionalAccess', _94 => _94.inlineImages]) && images.length > 0) {
4760
4819
  try {
4761
- markdown = _chunk6XAAYAWLcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
4820
+ markdown = _chunkXTCT6KQ5cjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
4762
4821
  } catch (inlineErr) {
4763
4822
  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" });
4764
4823
  }
@@ -4768,7 +4827,7 @@ function parseHwp5Document(buffer, options) {
4768
4827
  function parseDocInfoStream(cfb, compressed) {
4769
4828
  try {
4770
4829
  const entry = CFB.find(cfb, "/DocInfo");
4771
- if (!_optionalChain([entry, 'optionalAccess', _90 => _90.content])) return null;
4830
+ if (!_optionalChain([entry, 'optionalAccess', _95 => _95.content])) return null;
4772
4831
  const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
4773
4832
  const records = readRecords(data);
4774
4833
  return parseDocInfo(records);
@@ -4789,7 +4848,7 @@ function detectHwp5Headings(blocks, docInfo) {
4789
4848
  let baseFontSize = 0;
4790
4849
  const sizeFreq = /* @__PURE__ */ new Map();
4791
4850
  for (const b of blocks) {
4792
- if (_optionalChain([b, 'access', _91 => _91.style, 'optionalAccess', _92 => _92.fontSize]) && b.text) {
4851
+ if (_optionalChain([b, 'access', _96 => _96.style, 'optionalAccess', _97 => _97.fontSize]) && b.text) {
4793
4852
  sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
4794
4853
  }
4795
4854
  }
@@ -4805,7 +4864,7 @@ function detectHwp5Headings(blocks, docInfo) {
4805
4864
  const name = (style.nameKo || style.name).toLowerCase();
4806
4865
  if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
4807
4866
  const cs = docInfo.charShapes[style.charShapeId];
4808
- if (_optionalChain([cs, 'optionalAccess', _93 => _93.fontSize]) > 0) {
4867
+ if (_optionalChain([cs, 'optionalAccess', _98 => _98.fontSize]) > 0) {
4809
4868
  baseFontSize = cs.fontSize / 10;
4810
4869
  break;
4811
4870
  }
@@ -4820,11 +4879,11 @@ function detectHwp5Headings(blocks, docInfo) {
4820
4879
  if (text.length === 0 || text.length > 200) continue;
4821
4880
  if (/^\d+$/.test(text)) continue;
4822
4881
  let level = 0;
4823
- if (_optionalChain([block, 'access', _94 => _94.style, 'optionalAccess', _95 => _95.fontSize]) && baseFontSize > 0) {
4882
+ if (_optionalChain([block, 'access', _99 => _99.style, 'optionalAccess', _100 => _100.fontSize]) && baseFontSize > 0) {
4824
4883
  const ratio = block.style.fontSize / baseFontSize;
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;
4884
+ if (ratio >= _chunkF2HYH62Hcjs.HEADING_RATIO_H1) level = 1;
4885
+ else if (ratio >= _chunkF2HYH62Hcjs.HEADING_RATIO_H2) level = 2;
4886
+ else if (ratio >= _chunkF2HYH62Hcjs.HEADING_RATIO_H3) level = 3;
4828
4887
  }
4829
4888
  if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
4830
4889
  if (level === 0) level = 2;
@@ -4840,7 +4899,7 @@ function detectHwp5Headings(blocks, docInfo) {
4840
4899
  function extractHwp5Metadata(cfb, metadata) {
4841
4900
  try {
4842
4901
  const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
4843
- if (!_optionalChain([summaryEntry, 'optionalAccess', _96 => _96.content])) return;
4902
+ if (!_optionalChain([summaryEntry, 'optionalAccess', _101 => _101.content])) return;
4844
4903
  const data = Buffer.from(summaryEntry.content);
4845
4904
  if (data.length < 48) return;
4846
4905
  const numSets = data.readUInt32LE(24);
@@ -4873,7 +4932,7 @@ function findViewTextSections(cfb, compressed) {
4873
4932
  const sections = [];
4874
4933
  for (let i = 0; i < MAX_SECTIONS; i++) {
4875
4934
  const entry = CFB.find(cfb, `/ViewText/Section${i}`);
4876
- if (!_optionalChain([entry, 'optionalAccess', _97 => _97.content])) break;
4935
+ if (!_optionalChain([entry, 'optionalAccess', _102 => _102.content])) break;
4877
4936
  try {
4878
4937
  const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
4879
4938
  sections.push({ idx: i, content: decrypted });
@@ -4887,13 +4946,13 @@ function findSections(cfb) {
4887
4946
  const sections = [];
4888
4947
  for (let i = 0; i < MAX_SECTIONS; i++) {
4889
4948
  const entry = CFB.find(cfb, `/BodyText/Section${i}`);
4890
- if (!_optionalChain([entry, 'optionalAccess', _98 => _98.content])) break;
4949
+ if (!_optionalChain([entry, 'optionalAccess', _103 => _103.content])) break;
4891
4950
  sections.push({ idx: i, content: Buffer.from(entry.content) });
4892
4951
  }
4893
4952
  if (sections.length === 0 && cfb.FileIndex) {
4894
4953
  for (const entry of cfb.FileIndex) {
4895
4954
  if (sections.length >= MAX_SECTIONS) break;
4896
- if (_optionalChain([entry, 'access', _99 => _99.name, 'optionalAccess', _100 => _100.startsWith, 'call', _101 => _101("Section")]) && entry.content) {
4955
+ if (_optionalChain([entry, 'access', _104 => _104.name, 'optionalAccess', _105 => _105.startsWith, 'call', _106 => _106("Section")]) && entry.content) {
4897
4956
  const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
4898
4957
  sections.push({ idx, content: Buffer.from(entry.content) });
4899
4958
  }
@@ -4909,7 +4968,7 @@ function findSectionsLenient(lcfb, compressed) {
4909
4968
  if (!raw) break;
4910
4969
  const content = compressed ? decompressStream(raw) : raw;
4911
4970
  totalDecompressed += content.length;
4912
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4971
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4913
4972
  sections.push({ idx: i, content });
4914
4973
  }
4915
4974
  if (sections.length === 0) {
@@ -4921,7 +4980,7 @@ function findSectionsLenient(lcfb, compressed) {
4921
4980
  if (raw) {
4922
4981
  const content = compressed ? decompressStream(raw) : raw;
4923
4982
  totalDecompressed += content.length;
4924
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4983
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4925
4984
  sections.push({ idx, content });
4926
4985
  }
4927
4986
  }
@@ -4938,7 +4997,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
4938
4997
  try {
4939
4998
  const content = decryptViewText(raw, compressed);
4940
4999
  totalDecompressed += content.length;
4941
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
5000
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
4942
5001
  sections.push({ idx: i, content });
4943
5002
  } catch (e27) {
4944
5003
  break;
@@ -5039,9 +5098,9 @@ function parseParagraph(records, start, end, ctx) {
5039
5098
  const applied = [];
5040
5099
  for (const r of ranges) {
5041
5100
  const ctrl = ctrls[r.ctrlIdx];
5042
- if (!_optionalChain([ctrl, 'optionalAccess', _102 => _102.href]) || r.end <= r.start) continue;
5101
+ if (!_optionalChain([ctrl, 'optionalAccess', _107 => _107.href]) || r.end <= r.start) continue;
5043
5102
  if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
5044
- const href = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, ctrl.href);
5103
+ const href = _chunkF2HYH62Hcjs.sanitizeHref.call(void 0, ctrl.href);
5045
5104
  if (!href) continue;
5046
5105
  const anchor = text.slice(r.start, r.end);
5047
5106
  if (!anchor.trim()) continue;
@@ -5059,7 +5118,7 @@ function parseParagraph(records, start, end, ctx) {
5059
5118
  }
5060
5119
  if (ps.headType === 1 || ps.headType === 2) {
5061
5120
  const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
5062
- const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _103 => _103.docInfo, 'optionalAccess', _104 => _104.numberings, 'access', _105 => _105[nid - 1]]) : void 0;
5121
+ const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _108 => _108.docInfo, 'optionalAccess', _109 => _109.numberings, 'access', _110 => _110[nid - 1]]) : void 0;
5063
5122
  if (numbering) {
5064
5123
  const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
5065
5124
  const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
@@ -5069,7 +5128,7 @@ function parseParagraph(records, start, end, ctx) {
5069
5128
  }
5070
5129
  }
5071
5130
  } else if (ps.headType === 3) {
5072
- const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _106 => _106.docInfo, 'optionalAccess', _107 => _107.bullets, 'access', _108 => _108[ps.numberingId - 1]]) : void 0;
5131
+ const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _111 => _111.docInfo, 'optionalAccess', _112 => _112.bullets, 'access', _113 => _113[ps.numberingId - 1]]) : void 0;
5073
5132
  if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
5074
5133
  }
5075
5134
  }
@@ -5274,8 +5333,8 @@ function parseTableControl(ctrl, records, ctx) {
5274
5333
  let tableIdx = -1;
5275
5334
  for (let i2 = childStart; i2 < childEnd; i2++) {
5276
5335
  if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
5277
- rows = Math.min(records[i2].data.readUInt16LE(4), _chunk6XAAYAWLcjs.MAX_ROWS);
5278
- cols = Math.min(records[i2].data.readUInt16LE(6), _chunk6XAAYAWLcjs.MAX_COLS);
5336
+ rows = Math.min(records[i2].data.readUInt16LE(4), _chunkXTCT6KQ5cjs.MAX_ROWS);
5337
+ cols = Math.min(records[i2].data.readUInt16LE(6), _chunkXTCT6KQ5cjs.MAX_COLS);
5279
5338
  tableIdx = i2;
5280
5339
  break;
5281
5340
  }
@@ -5315,7 +5374,7 @@ function parseTableControl(ctrl, records, ctx) {
5315
5374
  const cellRows2 = arrangeCells(rows, cols, cells);
5316
5375
  const irCells = cellRows2.map((row) => row.map((c) => {
5317
5376
  const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
5318
- if (_optionalChain([c, 'access', _109 => _109.blocks, 'optionalAccess', _110 => _110.length])) ir.blocks = c.blocks;
5377
+ if (_optionalChain([c, 'access', _114 => _114.blocks, 'optionalAccess', _115 => _115.length])) ir.blocks = c.blocks;
5319
5378
  if (c.isHeader) ir.isHeader = true;
5320
5379
  return ir;
5321
5380
  }));
@@ -5324,7 +5383,7 @@ function parseTableControl(ctrl, records, ctx) {
5324
5383
  return table3;
5325
5384
  }
5326
5385
  const cellRows = arrangeCells(rows, cols, cells);
5327
- const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
5386
+ const table2 = _chunkXTCT6KQ5cjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
5328
5387
  if (caption && table2.rows > 0) table2.caption = caption;
5329
5388
  return table2.rows > 0 ? table2 : null;
5330
5389
  }
@@ -5341,8 +5400,8 @@ function parseCell(records, lhIdx, end, ctx) {
5341
5400
  rowAddr = rec.data.readUInt16LE(10);
5342
5401
  const cs = rec.data.readUInt16LE(12);
5343
5402
  const rs = rec.data.readUInt16LE(14);
5344
- if (cs > 0) colSpan = Math.min(cs, _chunk6XAAYAWLcjs.MAX_COLS);
5345
- if (rs > 0) rowSpan = Math.min(rs, _chunk6XAAYAWLcjs.MAX_ROWS);
5403
+ if (cs > 0) colSpan = Math.min(cs, _chunkXTCT6KQ5cjs.MAX_COLS);
5404
+ if (rs > 0) rowSpan = Math.min(rs, _chunkXTCT6KQ5cjs.MAX_ROWS);
5346
5405
  }
5347
5406
  const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
5348
5407
  const parts = [];
@@ -5352,7 +5411,7 @@ function parseCell(records, lhIdx, end, ctx) {
5352
5411
  parts.push(`![image](hwp5bin:${b.text})`);
5353
5412
  hasStructure = true;
5354
5413
  } else if (b.type === "table" && b.table) {
5355
- const flat = _chunk6XAAYAWLcjs.convertTableToText.call(void 0, b.table.cells);
5414
+ const flat = _chunkXTCT6KQ5cjs.convertTableToText.call(void 0, b.table.cells);
5356
5415
  if (flat) parts.push(flat);
5357
5416
  hasStructure = true;
5358
5417
  } else if (b.text) {
@@ -5449,8 +5508,8 @@ function pictureToImageBlock(data, ctx) {
5449
5508
  if (data.length < 73) return null;
5450
5509
  const binDataId = data.readUInt16LE(71);
5451
5510
  if (binDataId === 0) return null;
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") {
5511
+ const item = _optionalChain([ctx, 'access', _116 => _116.docInfo, 'optionalAccess', _117 => _117.binData, 'access', _118 => _118[binDataId - 1]]);
5512
+ if (_optionalChain([item, 'optionalAccess', _119 => _119.kind]) === "link") {
5454
5513
  ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
5455
5514
  return null;
5456
5515
  }
@@ -17402,8 +17461,50 @@ function decodeJohab(ch) {
17402
17461
  }
17403
17462
  const hit = lookupSymbol(ch);
17404
17463
  if (hit !== null) return hit;
17464
+ return JOHAB_UNMAPPED;
17465
+ }
17466
+ return decodeHwp3Extra(ch);
17467
+ }
17468
+ function decodeHwp3Extra(ch) {
17469
+ if (ch >= 13712 && ch <= 13721) return 8544 + (ch - 13712);
17470
+ if (ch >= 14055 && ch <= 14064) return 9312 + (ch - 14055);
17471
+ switch (ch) {
17472
+ case 129:
17473
+ return 8220;
17474
+ // 왼쪽 큰따옴표
17475
+ case 130:
17476
+ return 8221;
17477
+ // 오른쪽 큰따옴표
17478
+ case 12316:
17479
+ return 9473;
17480
+ // ━ 굵은 가로선 (rhwp: U+F080F, 표시값 직행)
17481
+ case 12349:
17482
+ return 9632;
17483
+ // ■ (rhwp: U+F0827, 표시값 직행)
17484
+ case 13158:
17485
+ return 9633;
17486
+ // □ 글머리 (rhwp: U+F03C5, 한컴 표시값 직행)
17487
+ case 13316:
17488
+ return 8228;
17489
+ // 한 점 리더
17490
+ case 13377:
17491
+ return 9632;
17492
+ // ■
17493
+ case 13382:
17494
+ return 8594;
17495
+ // → 오른쪽 화살표
17496
+ case 13793:
17497
+ return 9472;
17498
+ // ─ 상자 그리기 가로선
17499
+ case 13433:
17500
+ return 9655;
17501
+ // ▷
17502
+ case 13434:
17503
+ return 9654;
17504
+ // ▶
17505
+ default:
17506
+ return JOHAB_UNMAPPED;
17405
17507
  }
17406
- return JOHAB_UNMAPPED;
17407
17508
  }
17408
17509
  function decodeHcharString(bytes) {
17409
17510
  let out = "";
@@ -17518,11 +17619,12 @@ function readHeader(reader) {
17518
17619
  }
17519
17620
 
17520
17621
  // src/hwp3/parser.ts
17622
+ var MAX_DECOMPRESS_SIZE3 = 100 * 1024 * 1024;
17521
17623
  var PARA_SHAPE_SIZE = 187;
17522
17624
  var LINE_INFO_SIZE = 14;
17523
17625
  var INLINE_CHAR_SHAPE_SIZE = 31;
17524
17626
  var SIMPLE_CTRL = /* @__PURE__ */ new Map([
17525
- [9, { extraBytes: 0, extraHchar: 0, emit: " " }],
17627
+ [9, { extraBytes: 6, extraHchar: 3, emit: " " }],
17526
17628
  [7, { extraBytes: 6, extraHchar: 3, emit: "\uFFFC" }],
17527
17629
  [8, { extraBytes: 6, extraHchar: 3, emit: "\uFFFC" }],
17528
17630
  [18, { extraBytes: 6, extraHchar: 3, emit: " " }],
@@ -17553,8 +17655,11 @@ function parseHwp3Document(buffer, _options) {
17553
17655
  const warnings = [];
17554
17656
  if (header.compressed !== 0) {
17555
17657
  try {
17556
- body = _zlib.inflateRawSync.call(void 0, tail);
17658
+ body = _zlib.inflateRawSync.call(void 0, tail, { maxOutputLength: MAX_DECOMPRESS_SIZE3 });
17557
17659
  } catch (err) {
17660
+ if (_optionalChain([err, 'optionalAccess', _120 => _120.code]) === "ERR_BUFFER_TOO_LARGE") {
17661
+ throw new Error(`HWP3 \uC555\uCD95 \uD574\uC81C \uACB0\uACFC\uAC00 \uCD5C\uB300 \uD5C8\uC6A9 \uD06C\uAE30(${MAX_DECOMPRESS_SIZE3 / 1024 / 1024}MB)\uB97C \uCD08\uACFC\uD588\uC2B5\uB2C8\uB2E4`);
17662
+ }
17558
17663
  const msg2 = err instanceof Error ? err.message : String(err);
17559
17664
  throw new Error(`HWP3 \uC555\uCD95 \uD574\uC81C \uC2E4\uD328: ${msg2}`);
17560
17665
  }
@@ -17695,6 +17800,12 @@ function parseCharStream(reader, charCount, ctx) {
17695
17800
  parseParagraphList2(reader, ctx);
17696
17801
  break;
17697
17802
  }
17803
+ case 5:
17804
+ if (headerVal1 > 0 && headerVal1 < 1e6) reader.skip(headerVal1);
17805
+ break;
17806
+ case 6:
17807
+ reader.skip(34);
17808
+ break;
17698
17809
  case 29:
17699
17810
  if (headerVal1 < 1e6) reader.skip(headerVal1);
17700
17811
  break;
@@ -17751,7 +17862,7 @@ function isDistributionSentinel(markdown) {
17751
17862
 
17752
17863
 
17753
17864
  var MAX_SHEETS = 100;
17754
- var MAX_DECOMPRESS_SIZE3 = 100 * 1024 * 1024;
17865
+ var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
17755
17866
  var MAX_ROWS2 = 1e4;
17756
17867
  var MAX_COLS2 = 200;
17757
17868
  function cleanNumericValue(raw) {
@@ -17781,26 +17892,97 @@ function getElements(parent, tagName) {
17781
17892
  const result = [];
17782
17893
  for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
17783
17894
  if (result.length > 0) return result;
17784
- const nsNodes = _optionalChain([parent, 'access', _115 => _115.getElementsByTagNameNS, 'optionalCall', _116 => _116("*", tagName)]);
17895
+ const nsNodes = _optionalChain([parent, 'access', _121 => _121.getElementsByTagNameNS, 'optionalCall', _122 => _122("*", tagName)]);
17785
17896
  if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
17786
17897
  return result;
17787
17898
  }
17788
17899
  function getTextContent(el) {
17789
- return _nullishCoalesce(_optionalChain([el, 'access', _117 => _117.textContent, 'optionalAccess', _118 => _118.trim, 'call', _119 => _119()]), () => ( ""));
17900
+ return _nullishCoalesce(_optionalChain([el, 'access', _123 => _123.textContent, 'optionalAccess', _124 => _124.trim, 'call', _125 => _125()]), () => ( ""));
17790
17901
  }
17791
17902
  function parseXml(text) {
17792
- return new (0, _xmldom.DOMParser)().parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, text), "text/xml");
17903
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkF2HYH62Hcjs.stripDtd.call(void 0, text), "text/xml");
17904
+ }
17905
+ function collectRichText(root) {
17906
+ let out = "";
17907
+ const walk = (node) => {
17908
+ const children = node.childNodes;
17909
+ for (let i = 0; i < children.length; i++) {
17910
+ if (children[i].nodeType !== 1) continue;
17911
+ const el = children[i];
17912
+ const local = el.localName || _optionalChain([el, 'access', _126 => _126.tagName, 'optionalAccess', _127 => _127.replace, 'call', _128 => _128(/^[^:]+:/, "")]) || "";
17913
+ if (local === "rPh") continue;
17914
+ if (local === "t") out += _nullishCoalesce(el.textContent, () => ( ""));
17915
+ else walk(el);
17916
+ }
17917
+ };
17918
+ walk(root);
17919
+ return out;
17793
17920
  }
17794
17921
  function parseSharedStrings(xml) {
17795
17922
  const doc = parseXml(xml);
17796
17923
  const strings = [];
17797
17924
  const siList = getElements(doc.documentElement, "si");
17798
17925
  for (const si of siList) {
17799
- const tElements = getElements(si, "t");
17800
- strings.push(tElements.map((t) => _nullishCoalesce(t.textContent, () => ( ""))).join(""));
17926
+ strings.push(collectRichText(si));
17801
17927
  }
17802
17928
  return strings;
17803
17929
  }
17930
+ var BUILTIN_DATE_FMT = /* @__PURE__ */ new Map([
17931
+ [14, "date"],
17932
+ [15, "date"],
17933
+ [16, "date"],
17934
+ [17, "date"],
17935
+ [18, "datetime"],
17936
+ [19, "datetime"],
17937
+ [20, "datetime"],
17938
+ [21, "datetime"],
17939
+ [22, "datetime"],
17940
+ [45, "datetime"],
17941
+ [46, "datetime"],
17942
+ [47, "datetime"]
17943
+ ]);
17944
+ function classifyDateFormat(code) {
17945
+ const stripped = code.replace(/"[^"]*"/g, "").replace(/\[[^\]]*\]/g, "").replace(/\\./g, "");
17946
+ if (!/[ymdh]/i.test(stripped)) return null;
17947
+ return /[hs]/i.test(stripped) ? "datetime" : "date";
17948
+ }
17949
+ function dateKindOfFmt(fmtId, customFormats) {
17950
+ const builtin = BUILTIN_DATE_FMT.get(fmtId);
17951
+ if (builtin) return builtin;
17952
+ const code = customFormats.get(fmtId);
17953
+ return code !== void 0 ? classifyDateFormat(code) : null;
17954
+ }
17955
+ function dateSerialToIso(serial, date1904, kind) {
17956
+ if (!isFinite(serial) || serial < 0) return null;
17957
+ let days = serial;
17958
+ if (date1904) days += 1462;
17959
+ else if (days < 60) days += 1;
17960
+ const ms = Math.round((days - 25569) * 864e5);
17961
+ const d = new Date(ms);
17962
+ if (isNaN(d.getTime()) || d.getUTCFullYear() > 9999) return null;
17963
+ const iso = d.toISOString();
17964
+ return kind === "datetime" ? iso.slice(0, 19) : iso.slice(0, 10);
17965
+ }
17966
+ function parseStyleDateXfs(xml) {
17967
+ const doc = parseXml(xml);
17968
+ const customFormats = /* @__PURE__ */ new Map();
17969
+ for (const el of getElements(doc.documentElement, "numFmt")) {
17970
+ const id = parseInt(_nullishCoalesce(el.getAttribute("numFmtId"), () => ( "")), 10);
17971
+ if (isNaN(id)) continue;
17972
+ customFormats.set(id, _nullishCoalesce(el.getAttribute("formatCode"), () => ( "")));
17973
+ }
17974
+ const dateXfs = /* @__PURE__ */ new Map();
17975
+ const cellXfsEls = getElements(doc.documentElement, "cellXfs");
17976
+ if (cellXfsEls.length === 0) return dateXfs;
17977
+ const xfs = getElements(cellXfsEls[0], "xf");
17978
+ for (let i = 0; i < xfs.length; i++) {
17979
+ const fmtId = parseInt(_nullishCoalesce(xfs[i].getAttribute("numFmtId"), () => ( "")), 10);
17980
+ if (isNaN(fmtId)) continue;
17981
+ const kind = dateKindOfFmt(fmtId, customFormats);
17982
+ if (kind) dateXfs.set(i, kind);
17983
+ }
17984
+ return dateXfs;
17985
+ }
17804
17986
  function parseWorkbook(xml) {
17805
17987
  const doc = parseXml(xml);
17806
17988
  const sheets = [];
@@ -17812,7 +17994,9 @@ function parseWorkbook(xml) {
17812
17994
  rId: _nullishCoalesce(el.getAttribute("r:id"), () => ( ""))
17813
17995
  });
17814
17996
  }
17815
- return sheets;
17997
+ const prEls = getElements(doc.documentElement, "workbookPr");
17998
+ const d1904 = prEls.length > 0 ? prEls[0].getAttribute("date1904") : null;
17999
+ return { sheets, date1904: d1904 === "1" || d1904 === "true" };
17816
18000
  }
17817
18001
  function parseRels(xml) {
17818
18002
  const doc = parseXml(xml);
@@ -17825,21 +18009,25 @@ function parseRels(xml) {
17825
18009
  }
17826
18010
  return map;
17827
18011
  }
17828
- function parseWorksheet(xml, sharedStrings) {
18012
+ function parseWorksheet(xml, sharedStrings, dateXfs, date1904) {
17829
18013
  const doc = parseXml(xml);
17830
18014
  const grid = [];
17831
18015
  let maxRow = 0;
17832
18016
  let maxCol = 0;
17833
18017
  const rows = getElements(doc.documentElement, "row");
18018
+ let prevRow = -1;
17834
18019
  for (const rowEl of rows) {
17835
- const rowNum = parseInt(_nullishCoalesce(rowEl.getAttribute("r"), () => ( "0")), 10) - 1;
18020
+ const rAttr = rowEl.getAttribute("r");
18021
+ const rowNum = rAttr !== null ? parseInt(rAttr, 10) - 1 : prevRow + 1;
17836
18022
  if (rowNum < 0 || rowNum >= MAX_ROWS2) continue;
18023
+ if (Number.isFinite(rowNum)) prevRow = rowNum;
17837
18024
  const cells = getElements(rowEl, "c");
18025
+ let prevCol = -1;
17838
18026
  for (const cellEl of cells) {
17839
18027
  const ref = cellEl.getAttribute("r");
17840
- if (!ref) continue;
17841
- const pos = parseCellRef(ref);
17842
- if (!pos || pos.col >= MAX_COLS2) continue;
18028
+ const pos = ref !== null ? parseCellRef(ref) : { col: prevCol + 1, row: rowNum };
18029
+ if (!pos || !Number.isFinite(pos.row) || pos.row < 0 || pos.row >= MAX_ROWS2 || pos.col >= MAX_COLS2) continue;
18030
+ prevCol = pos.col;
17843
18031
  const type = cellEl.getAttribute("t");
17844
18032
  const vElements = getElements(cellEl, "v");
17845
18033
  const fElements = getElements(cellEl, "f");
@@ -17853,12 +18041,19 @@ function parseWorksheet(xml, sharedStrings) {
17853
18041
  value = raw === "1" ? "TRUE" : "FALSE";
17854
18042
  } else {
17855
18043
  value = cleanNumericValue(raw);
18044
+ if (type === null || type === "n") {
18045
+ const sAttr = cellEl.getAttribute("s");
18046
+ const kind = sAttr !== null ? dateXfs.get(parseInt(sAttr, 10)) : void 0;
18047
+ if (kind) {
18048
+ const iso = dateSerialToIso(parseFloat(raw), date1904, kind);
18049
+ if (iso) value = iso;
18050
+ }
18051
+ }
17856
18052
  }
17857
18053
  } else if (type === "inlineStr") {
17858
18054
  const isEl = getElements(cellEl, "is");
17859
18055
  if (isEl.length > 0) {
17860
- const tElements = getElements(isEl[0], "t");
17861
- value = tElements.map((t) => _nullishCoalesce(t.textContent, () => ( ""))).join("");
18056
+ value = collectRichText(isEl[0]);
17862
18057
  }
17863
18058
  }
17864
18059
  if (!value && fElements.length > 0) {
@@ -17877,11 +18072,18 @@ function parseWorksheet(xml, sharedStrings) {
17877
18072
  const ref = el.getAttribute("ref");
17878
18073
  if (!ref) continue;
17879
18074
  const m = parseMergeRef(ref);
17880
- if (m) merges.push(m);
18075
+ if (m) {
18076
+ merges.push({
18077
+ startCol: Math.min(m.startCol, MAX_COLS2 - 1),
18078
+ startRow: Math.min(m.startRow, MAX_ROWS2 - 1),
18079
+ endCol: Math.min(m.endCol, MAX_COLS2 - 1),
18080
+ endRow: Math.min(m.endRow, MAX_ROWS2 - 1)
18081
+ });
18082
+ }
17881
18083
  }
17882
18084
  return { grid, merges, maxRow, maxCol };
17883
18085
  }
17884
- function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
18086
+ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keepAnchoredEmptyCols) {
17885
18087
  const blocks = [];
17886
18088
  if (sheetName) {
17887
18089
  blocks.push({
@@ -17926,14 +18128,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
17926
18128
  const merge = mergeMap.get(key);
17927
18129
  row.push({
17928
18130
  text,
17929
- colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _120 => _120.colSpan]), () => ( 1)),
17930
- rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _121 => _121.rowSpan]), () => ( 1))
18131
+ colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _129 => _129.colSpan]), () => ( 1)),
18132
+ rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _130 => _130.rowSpan]), () => ( 1))
17931
18133
  });
17932
18134
  }
17933
18135
  cellRows.push(row);
17934
18136
  }
17935
18137
  if (cellRows.length > 0) {
17936
- const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
18138
+ const table2 = _chunkXTCT6KQ5cjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
17937
18139
  if (table2.rows > 0) {
17938
18140
  blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
17939
18141
  }
@@ -17941,21 +18143,29 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
17941
18143
  return blocks;
17942
18144
  }
17943
18145
  async function parseXlsxDocument(buffer, options) {
17944
- _chunk6XAAYAWLcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
18146
+ _chunkF2HYH62Hcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
17945
18147
  const zip = await _jszip2.default.loadAsync(buffer);
17946
18148
  const warnings = [];
17947
18149
  const workbookFile = zip.file("xl/workbook.xml");
17948
18150
  if (!workbookFile) {
17949
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18151
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
17950
18152
  }
17951
18153
  let sharedStrings = [];
17952
18154
  const ssFile = zip.file("xl/sharedStrings.xml");
17953
18155
  if (ssFile) {
17954
18156
  sharedStrings = parseSharedStrings(await ssFile.async("text"));
17955
18157
  }
17956
- const sheets = parseWorkbook(await workbookFile.async("text"));
18158
+ const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
17957
18159
  if (sheets.length === 0) {
17958
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
18160
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
18161
+ }
18162
+ let dateXfs = /* @__PURE__ */ new Map();
18163
+ const stylesFile = zip.file("xl/styles.xml");
18164
+ if (stylesFile) {
18165
+ try {
18166
+ dateXfs = parseStyleDateXfs(await stylesFile.async("text"));
18167
+ } catch (e28) {
18168
+ }
17959
18169
  }
17960
18170
  let relsMap = /* @__PURE__ */ new Map();
17961
18171
  const relsFile = zip.file("xl/_rels/workbook.xml.rels");
@@ -17963,7 +18173,7 @@ async function parseXlsxDocument(buffer, options) {
17963
18173
  relsMap = parseRels(await relsFile.async("text"));
17964
18174
  }
17965
18175
  let pageFilter = null;
17966
- if (_optionalChain([options, 'optionalAccess', _122 => _122.pages])) {
18176
+ if (_optionalChain([options, 'optionalAccess', _131 => _131.pages])) {
17967
18177
  const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
17968
18178
  pageFilter = parsePageRange2(options.pages, sheets.length);
17969
18179
  }
@@ -17972,7 +18182,7 @@ async function parseXlsxDocument(buffer, options) {
17972
18182
  for (let i = 0; i < processedSheets; i++) {
17973
18183
  if (pageFilter && !pageFilter.has(i + 1)) continue;
17974
18184
  const sheet = sheets[i];
17975
- _optionalChain([options, 'optionalAccess', _123 => _123.onProgress, 'optionalCall', _124 => _124(i + 1, processedSheets)]);
18185
+ _optionalChain([options, 'optionalAccess', _132 => _132.onProgress, 'optionalCall', _133 => _133(i + 1, processedSheets)]);
17976
18186
  let sheetPath = relsMap.get(sheet.rId);
17977
18187
  if (sheetPath) {
17978
18188
  if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
@@ -17994,8 +18204,8 @@ async function parseXlsxDocument(buffer, options) {
17994
18204
  }
17995
18205
  try {
17996
18206
  const sheetXml = await sheetFile.async("text");
17997
- const { grid, merges, maxRow, maxCol } = parseWorksheet(sheetXml, sharedStrings);
17998
- const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i);
18207
+ const { grid, merges, maxRow, maxCol } = parseWorksheet(sheetXml, sharedStrings, dateXfs, date1904);
18208
+ const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i, _optionalChain([options, 'optionalAccess', _134 => _134.keepTrailingEmptyCols]));
17999
18209
  blocks.push(...sheetBlocks);
18000
18210
  } catch (err) {
18001
18211
  warnings.push({
@@ -18024,10 +18234,10 @@ async function parseXlsxDocument(buffer, options) {
18024
18234
  if (created) metadata.createdAt = created;
18025
18235
  const modified = getFirst("dcterms:modified");
18026
18236
  if (modified) metadata.modifiedAt = modified;
18027
- } catch (e28) {
18237
+ } catch (e29) {
18028
18238
  }
18029
18239
  }
18030
- const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
18240
+ const markdown = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, blocks);
18031
18241
  return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
18032
18242
  }
18033
18243
 
@@ -18038,7 +18248,10 @@ var OP_CONTINUE = 60;
18038
18248
  var OP_BOUNDSHEET8 = 133;
18039
18249
  var OP_SST = 252;
18040
18250
  var OP_CODEPAGE = 66;
18251
+ var OP_DATE1904 = 34;
18041
18252
  var OP_FILEPASS = 47;
18253
+ var OP_FORMAT = 1054;
18254
+ var OP_XF = 224;
18042
18255
  var OP_NUMBER = 515;
18043
18256
  var OP_RK = 638;
18044
18257
  var OP_MULRK = 189;
@@ -18050,6 +18263,8 @@ var OP_BOOLERR = 517;
18050
18263
  var OP_BLANK = 513;
18051
18264
  var OP_MULBLANK = 190;
18052
18265
  var OP_MERGECELLS = 229;
18266
+ var OP_SHRFMLA = 1212;
18267
+ var OP_ARRAY = 545;
18053
18268
  var DT_GLOBALS = 5;
18054
18269
  var DT_WORKSHEET = 16;
18055
18270
  var MAX_RECORDS2 = 1e6;
@@ -18145,7 +18360,7 @@ function decodeUtf16Le(buf) {
18145
18360
  }
18146
18361
 
18147
18362
  // src/xls/sst.ts
18148
- function parseString(buf, offset, segments) {
18363
+ function parseString(buf, offset, segments, segCursor) {
18149
18364
  if (offset + 3 > buf.length) return null;
18150
18365
  const cch = buf.readUInt16LE(offset);
18151
18366
  let flags = buf.readUInt8(offset + 2);
@@ -18168,7 +18383,15 @@ function parseString(buf, offset, segments) {
18168
18383
  const charBytes = [];
18169
18384
  let charsRead = 0;
18170
18385
  while (charsRead < cch) {
18171
- const nextBoundary = _nullishCoalesce(segments.find((s) => s > off), () => ( buf.length));
18386
+ while (segCursor.idx < segments.length && segments[segCursor.idx] < off) segCursor.idx++;
18387
+ if (segCursor.idx < segments.length && segments[segCursor.idx] === off) {
18388
+ if (off >= buf.length) return null;
18389
+ flags = buf.readUInt8(off);
18390
+ highByte = (flags & 1) !== 0;
18391
+ off += 1;
18392
+ segCursor.idx++;
18393
+ }
18394
+ const nextBoundary = segCursor.idx < segments.length ? segments[segCursor.idx] : buf.length;
18172
18395
  const remainChars = cch - charsRead;
18173
18396
  const bytesPerChar = highByte ? 2 : 1;
18174
18397
  const bytesAvail = nextBoundary - off;
@@ -18179,12 +18402,10 @@ function parseString(buf, offset, segments) {
18179
18402
  charBytes.push(highByte ? slice : padToUtf16(slice));
18180
18403
  off += bytesToRead;
18181
18404
  charsRead += charsInThisRun;
18182
- }
18183
- if (charsRead < cch) {
18184
- if (off >= buf.length) return null;
18185
- flags = buf.readUInt8(off);
18186
- highByte = (flags & 1) !== 0;
18187
- off += 1;
18405
+ } else if (nextBoundary < buf.length) {
18406
+ off = nextBoundary;
18407
+ } else {
18408
+ return null;
18188
18409
  }
18189
18410
  }
18190
18411
  const text = decodeUtf16Le(Buffer.concat(charBytes));
@@ -18209,8 +18430,9 @@ function decodeSST(records) {
18209
18430
  const cstUnique = combined.readUInt32LE(4);
18210
18431
  const strings = [];
18211
18432
  let off = 8;
18433
+ const segCursor = { idx: 0 };
18212
18434
  for (let i = 0; i < cstUnique && off < combined.length; i++) {
18213
- const r = parseString(combined, off, segments);
18435
+ const r = parseString(combined, off, segments, segCursor);
18214
18436
  if (!r) break;
18215
18437
  strings.push(r.text);
18216
18438
  off += r.consumed;
@@ -18285,7 +18507,7 @@ function decodeFormulaStringRecord(data) {
18285
18507
  return decodeUtf16Le(padded);
18286
18508
  }
18287
18509
  }
18288
- function extractSheetCells(records, bofIndex, sst) {
18510
+ function extractSheetCells(records, bofIndex, sst, convertNum) {
18289
18511
  const cells = [];
18290
18512
  const merges = [];
18291
18513
  const bofOffset = records[bofIndex].offset;
@@ -18303,14 +18525,16 @@ function extractSheetCells(records, bofIndex, sst) {
18303
18525
  case OP_NUMBER: {
18304
18526
  const h = readCellHeader(rec.data);
18305
18527
  if (h && rec.data.length >= 14) {
18306
- cells.push({ row: h.row, col: h.col, value: rec.data.readDoubleLE(6) });
18528
+ const n = rec.data.readDoubleLE(6);
18529
+ cells.push({ row: h.row, col: h.col, value: convertNum ? convertNum(n, h.ixfe) : n });
18307
18530
  }
18308
18531
  break;
18309
18532
  }
18310
18533
  case OP_RK: {
18311
18534
  const h = readCellHeader(rec.data);
18312
18535
  if (h && rec.data.length >= 10) {
18313
- cells.push({ row: h.row, col: h.col, value: decodeRk(rec.data.readInt32LE(6)) });
18536
+ const n = decodeRk(rec.data.readInt32LE(6));
18537
+ cells.push({ row: h.row, col: h.col, value: convertNum ? convertNum(n, h.ixfe) : n });
18314
18538
  }
18315
18539
  break;
18316
18540
  }
@@ -18318,7 +18542,7 @@ function extractSheetCells(records, bofIndex, sst) {
18318
18542
  const m = decodeMulRk(rec.data);
18319
18543
  if (m) {
18320
18544
  for (const c of m.cells) {
18321
- cells.push({ row: m.row, col: c.col, value: c.value });
18545
+ cells.push({ row: m.row, col: c.col, value: convertNum ? convertNum(c.value, c.ixfe) : c.value });
18322
18546
  }
18323
18547
  }
18324
18548
  break;
@@ -18343,19 +18567,26 @@ function extractSheetCells(records, bofIndex, sst) {
18343
18567
  if (h && rec.data.length >= 14) {
18344
18568
  const result = decodeFormulaResult(rec.data.subarray(6, 14));
18345
18569
  if (result.kind === "stringRef") {
18346
- const next = records[i + 1];
18570
+ let j = i + 1;
18571
+ while (j < records.length && (records[j].opcode === OP_SHRFMLA || records[j].opcode === OP_ARRAY)) j++;
18572
+ const next = records[j];
18347
18573
  if (next && next.opcode === OP_STRING) {
18348
18574
  cells.push({
18349
18575
  row: h.row,
18350
18576
  col: h.col,
18351
18577
  value: decodeFormulaStringRecord(next.data)
18352
18578
  });
18353
- i++;
18579
+ i = j;
18354
18580
  } else {
18355
18581
  cells.push({ row: h.row, col: h.col, value: "" });
18356
18582
  }
18357
18583
  } else {
18358
- cells.push({ row: h.row, col: h.col, value: result.value });
18584
+ const v = result.value;
18585
+ cells.push({
18586
+ row: h.row,
18587
+ col: h.col,
18588
+ value: convertNum && typeof v === "number" ? convertNum(v, h.ixfe) : v
18589
+ });
18359
18590
  }
18360
18591
  }
18361
18592
  break;
@@ -18405,7 +18636,7 @@ function extractSheetCells(records, bofIndex, sst) {
18405
18636
 
18406
18637
  // src/xls/parser.ts
18407
18638
  var MAX_SHEETS2 = 100;
18408
- var MAX_ROWS3 = 1e5;
18639
+ var MAX_ROWS3 = 65536;
18409
18640
  var MAX_COLS3 = 1e3;
18410
18641
  function decodeBoundSheet(data) {
18411
18642
  if (data.length < 8) return null;
@@ -18428,17 +18659,40 @@ function decodeBoundSheet(data) {
18428
18659
  }
18429
18660
  return { name, lbPlyPos, dt };
18430
18661
  }
18662
+ function decodeFormatRecord(data) {
18663
+ if (data.length < 5) return null;
18664
+ const ifmt = data.readUInt16LE(0);
18665
+ const cch = data.readUInt16LE(2);
18666
+ const flags = data.readUInt8(4);
18667
+ const highByte = (flags & 1) !== 0;
18668
+ const start = 5;
18669
+ let code;
18670
+ if (highByte) {
18671
+ const end = Math.min(start + cch * 2, data.length);
18672
+ code = decodeUtf16Le(data.subarray(start, end));
18673
+ } else {
18674
+ const end = Math.min(start + cch, data.length);
18675
+ const slice = data.subarray(start, end);
18676
+ const padded = Buffer.alloc(slice.length * 2);
18677
+ for (let i = 0; i < slice.length; i++) padded[i * 2] = slice[i];
18678
+ code = decodeUtf16Le(padded);
18679
+ }
18680
+ return { ifmt, code };
18681
+ }
18431
18682
  function processGlobals(records) {
18432
18683
  const sheets = [];
18433
18684
  let codePage = 1200;
18434
18685
  let encrypted = false;
18686
+ let date1904 = false;
18687
+ const customFormats = /* @__PURE__ */ new Map();
18688
+ const xfFmtIds = [];
18435
18689
  const firstBof = records[0];
18436
18690
  if (!firstBof || firstBof.opcode !== OP_BOF) {
18437
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
18691
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
18438
18692
  }
18439
18693
  const bof = decodeBof(firstBof.data);
18440
18694
  if (!bof || bof.dt !== DT_GLOBALS) {
18441
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
18695
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
18442
18696
  }
18443
18697
  let i = 1;
18444
18698
  while (i < records.length) {
@@ -18454,21 +18708,41 @@ function processGlobals(records) {
18454
18708
  codePage = r.data.readUInt16LE(0);
18455
18709
  } else if (r.opcode === OP_FILEPASS) {
18456
18710
  encrypted = true;
18711
+ } else if (r.opcode === OP_DATE1904 && r.data.length >= 2) {
18712
+ date1904 = r.data.readUInt16LE(0) === 1;
18713
+ } else if (r.opcode === OP_FORMAT) {
18714
+ const f = decodeFormatRecord(r.data);
18715
+ if (f) customFormats.set(f.ifmt, f.code);
18716
+ } else if (r.opcode === OP_XF && r.data.length >= 4) {
18717
+ xfFmtIds.push(r.data.readUInt16LE(2));
18457
18718
  }
18458
18719
  i++;
18459
18720
  }
18721
+ const dateXfs = /* @__PURE__ */ new Map();
18722
+ for (let k = 0; k < xfFmtIds.length; k++) {
18723
+ const kind = dateKindOfFmt(xfFmtIds[k], customFormats);
18724
+ if (kind) dateXfs.set(k, kind);
18725
+ }
18460
18726
  const globalsRecords = records.slice(0, i);
18461
18727
  const sst = decodeSST(globalsRecords);
18462
- return { sheets, sst, codePage, encrypted, endIndex: i };
18728
+ return { sheets, sst, codePage, encrypted, dateXfs, date1904, endIndex: i };
18463
18729
  }
18464
18730
  function findSheetBofIndex(records, lbPlyPos) {
18465
18731
  const exact = records.findIndex(
18466
18732
  (r) => r.opcode === OP_BOF && r.offset === lbPlyPos
18467
18733
  );
18468
18734
  if (exact >= 0) return exact;
18469
- const bofIndices = records.map((r, idx) => r.opcode === OP_BOF ? idx : -1).filter((idx) => idx >= 0);
18470
- if (bofIndices.length === 0) return -1;
18471
- return bofIndices.length > 1 ? bofIndices[1] : -1;
18735
+ let best = -1;
18736
+ let bestOffset = Infinity;
18737
+ for (let idx = 1; idx < records.length; idx++) {
18738
+ const r = records[idx];
18739
+ if (r.opcode !== OP_BOF) continue;
18740
+ if (r.offset >= lbPlyPos && r.offset < bestOffset) {
18741
+ best = idx;
18742
+ bestOffset = r.offset;
18743
+ }
18744
+ }
18745
+ return best;
18472
18746
  }
18473
18747
  function cellValueToText(v) {
18474
18748
  if (v === null || v === void 0) return "";
@@ -18480,7 +18754,7 @@ function cellValueToText(v) {
18480
18754
  if (typeof v === "boolean") return v ? "TRUE" : "FALSE";
18481
18755
  return v;
18482
18756
  }
18483
- function sheetToBlocks2(sheetName, sheet, sheetIndex) {
18757
+ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
18484
18758
  const blocks = [];
18485
18759
  if (sheetName) {
18486
18760
  blocks.push({
@@ -18546,14 +18820,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
18546
18820
  const merge = mergeMap.get(key);
18547
18821
  row.push({
18548
18822
  text: grid[r][c],
18549
- colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _125 => _125.colSpan]), () => ( 1)),
18550
- rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _126 => _126.rowSpan]), () => ( 1))
18823
+ colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _135 => _135.colSpan]), () => ( 1)),
18824
+ rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _136 => _136.rowSpan]), () => ( 1))
18551
18825
  });
18552
18826
  }
18553
18827
  cellRows.push(row);
18554
18828
  }
18555
18829
  if (cellRows.length > 0) {
18556
- const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
18830
+ const table2 = _chunkXTCT6KQ5cjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
18557
18831
  if (table2.rows > 0) {
18558
18832
  blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
18559
18833
  }
@@ -18566,21 +18840,21 @@ async function parseXlsDocument(buffer, options) {
18566
18840
  try {
18567
18841
  cfb = parseLenientCfb(buf);
18568
18842
  } catch (e) {
18569
- throw new (0, _chunk6XAAYAWLcjs.KordocError)(
18843
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)(
18570
18844
  `XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
18571
18845
  );
18572
18846
  }
18573
18847
  const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
18574
18848
  if (!wb) {
18575
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
18849
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
18576
18850
  }
18577
18851
  const records = readRecords2(wb);
18578
18852
  if (records.length === 0) {
18579
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
18853
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
18580
18854
  }
18581
18855
  const firstBof = decodeBof(records[0].data);
18582
18856
  if (firstBof && firstBof.vers !== 1536) {
18583
- throw new (0, _chunk6XAAYAWLcjs.KordocError)(
18857
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)(
18584
18858
  `XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
18585
18859
  );
18586
18860
  }
@@ -18599,9 +18873,17 @@ async function parseXlsDocument(buffer, options) {
18599
18873
  ]
18600
18874
  };
18601
18875
  }
18876
+ const convertNum = globals.dateXfs.size > 0 ? (n, ixfe) => {
18877
+ const kind = globals.dateXfs.get(ixfe);
18878
+ if (kind) {
18879
+ const iso = dateSerialToIso(n, globals.date1904, kind);
18880
+ if (iso) return iso;
18881
+ }
18882
+ return n;
18883
+ } : void 0;
18602
18884
  const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
18603
18885
  let pageFilter = null;
18604
- if (_optionalChain([options, 'optionalAccess', _127 => _127.pages])) {
18886
+ if (_optionalChain([options, 'optionalAccess', _137 => _137.pages])) {
18605
18887
  const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
18606
18888
  pageFilter = parsePageRange2(options.pages, totalSheets);
18607
18889
  }
@@ -18610,7 +18892,7 @@ async function parseXlsDocument(buffer, options) {
18610
18892
  if (pageFilter && !pageFilter.has(i + 1)) continue;
18611
18893
  const meta = globals.sheets[i];
18612
18894
  if (meta.dt !== 0) continue;
18613
- _optionalChain([options, 'optionalAccess', _128 => _128.onProgress, 'optionalCall', _129 => _129(i + 1, totalSheets)]);
18895
+ _optionalChain([options, 'optionalAccess', _138 => _138.onProgress, 'optionalCall', _139 => _139(i + 1, totalSheets)]);
18614
18896
  const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
18615
18897
  if (bofIdx < 0) {
18616
18898
  warnings.push({
@@ -18625,8 +18907,8 @@ async function parseXlsDocument(buffer, options) {
18625
18907
  continue;
18626
18908
  }
18627
18909
  try {
18628
- const { sheet } = extractSheetCells(records, bofIdx, globals.sst);
18629
- const blocks = sheetToBlocks2(meta.name, sheet, i);
18910
+ const { sheet } = extractSheetCells(records, bofIdx, globals.sst, convertNum);
18911
+ const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess', _140 => _140.keepTrailingEmptyCols]));
18630
18912
  allBlocks.push(...blocks);
18631
18913
  } catch (e) {
18632
18914
  warnings.push({
@@ -18640,7 +18922,7 @@ async function parseXlsDocument(buffer, options) {
18640
18922
  pageCount: totalSheets
18641
18923
  };
18642
18924
  return {
18643
- markdown: _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, allBlocks),
18925
+ markdown: _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, allBlocks),
18644
18926
  blocks: allBlocks,
18645
18927
  metadata,
18646
18928
  warnings: warnings.length > 0 ? warnings : void 0
@@ -18653,7 +18935,7 @@ async function parseXlsDocument(buffer, options) {
18653
18935
 
18654
18936
  // src/docx/equation.ts
18655
18937
  function lname(el) {
18656
- return el.localName || _optionalChain([el, 'access', _130 => _130.tagName, 'optionalAccess', _131 => _131.replace, 'call', _132 => _132(/^[^:]+:/, "")]) || "";
18938
+ return el.localName || _optionalChain([el, 'access', _141 => _141.tagName, 'optionalAccess', _142 => _142.replace, 'call', _143 => _143(/^[^:]+:/, "")]) || "";
18657
18939
  }
18658
18940
  function kids(parent, name) {
18659
18941
  const out = [];
@@ -18753,6 +19035,9 @@ var NARY_MAP = {
18753
19035
  "\u2A02": "\\bigotimes",
18754
19036
  "\u2A00": "\\bigodot"
18755
19037
  };
19038
+ function onOffVal(v) {
19039
+ return v !== "0" && v !== "false" && v !== "off";
19040
+ }
18756
19041
  function mapDelim(ch, isLeft) {
18757
19042
  const l = {
18758
19043
  "(": "(",
@@ -18779,10 +19064,23 @@ function mapDelim(ch, isLeft) {
18779
19064
  const map = isLeft ? l : r;
18780
19065
  return _nullishCoalesce(map[ch], () => ( ch));
18781
19066
  }
19067
+ function isBalancedWrap(s) {
19068
+ let depth = 0;
19069
+ for (let i = 0; i < s.length; i++) {
19070
+ const ch = s[i];
19071
+ if (ch === "{" && s[i - 1] !== "\\") depth++;
19072
+ else if (ch === "}" && s[i - 1] !== "\\") {
19073
+ depth--;
19074
+ if (depth === 0) return i === s.length - 1;
19075
+ if (depth < 0) return false;
19076
+ }
19077
+ }
19078
+ return false;
19079
+ }
18782
19080
  function grp(body) {
18783
19081
  const s = body.trim();
18784
19082
  if (s.length === 0) return "{}";
18785
- if (s.startsWith("{") && s.endsWith("}")) return s;
19083
+ if (s.startsWith("{") && s.endsWith("}") && isBalancedWrap(s)) return s;
18786
19084
  return "{" + s + "}";
18787
19085
  }
18788
19086
  function childrenToLatex(parent) {
@@ -18876,8 +19174,8 @@ function nodeToLatex(el) {
18876
19174
  }
18877
19175
  const sh = firstKid(naryPr, "subHide");
18878
19176
  const ph = firstKid(naryPr, "supHide");
18879
- if (sh) subHide = (_nullishCoalesce(sh.getAttribute("m:val"), () => ( sh.getAttribute("val")))) !== "0";
18880
- if (ph) supHide = (_nullishCoalesce(ph.getAttribute("m:val"), () => ( ph.getAttribute("val")))) !== "0";
19177
+ if (sh) subHide = onOffVal(_nullishCoalesce(sh.getAttribute("m:val"), () => ( sh.getAttribute("val"))));
19178
+ if (ph) supHide = onOffVal(_nullishCoalesce(ph.getAttribute("m:val"), () => ( ph.getAttribute("val"))));
18881
19179
  const ll = firstKid(naryPr, "limLoc");
18882
19180
  if (ll) limLoc = _nullishCoalesce(_nullishCoalesce(ll.getAttribute("m:val"), () => ( ll.getAttribute("val"))), () => ( ""));
18883
19181
  }
@@ -19024,9 +19322,9 @@ function isDisplayMath(el) {
19024
19322
  }
19025
19323
 
19026
19324
  // src/docx/parser.ts
19027
- var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
19325
+ var MAX_DECOMPRESS_SIZE5 = 100 * 1024 * 1024;
19028
19326
  function matchesLocal(el, localName2) {
19029
- return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _133 => _133.tagName, 'optionalAccess', _134 => _134.endsWith, 'call', _135 => _135(`:${localName2}`)]), () => ( false)));
19327
+ return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _144 => _144.tagName, 'optionalAccess', _145 => _145.endsWith, 'call', _146 => _146(`:${localName2}`)]), () => ( false)));
19030
19328
  }
19031
19329
  function effectiveChildElements(parent) {
19032
19330
  const result = [];
@@ -19042,6 +19340,8 @@ function effectiveChildElements(parent) {
19042
19340
  result.push(...effectiveChildElements(c));
19043
19341
  }
19044
19342
  }
19343
+ } else if (matchesLocal(el, "ins") || matchesLocal(el, "smartTag")) {
19344
+ result.push(...effectiveChildElements(el));
19045
19345
  } else {
19046
19346
  result.push(el);
19047
19347
  }
@@ -19059,7 +19359,7 @@ function findElements(parent, localName2) {
19059
19359
  const child = children[i];
19060
19360
  if (child.nodeType === 1) {
19061
19361
  const el = child;
19062
- if (el.localName === localName2 || _optionalChain([el, 'access', _136 => _136.tagName, 'optionalAccess', _137 => _137.endsWith, 'call', _138 => _138(`:${localName2}`)])) {
19362
+ if (el.localName === localName2 || _optionalChain([el, 'access', _147 => _147.tagName, 'optionalAccess', _148 => _148.endsWith, 'call', _149 => _149(`:${localName2}`)])) {
19063
19363
  result.push(el);
19064
19364
  }
19065
19365
  walk(el);
@@ -19078,7 +19378,7 @@ function getAttr(el, localName2) {
19078
19378
  return null;
19079
19379
  }
19080
19380
  function parseXml2(text) {
19081
- return new (0, _xmldom.DOMParser)().parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, text), "text/xml");
19381
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkF2HYH62Hcjs.stripDtd.call(void 0, text), "text/xml");
19082
19382
  }
19083
19383
  function parseStyles(xml) {
19084
19384
  const doc = parseXml2(xml);
@@ -19106,6 +19406,21 @@ function parseStyles(xml) {
19106
19406
  }
19107
19407
  styles.set(styleId, { name, basedOn, outlineLevel });
19108
19408
  }
19409
+ for (const [styleId, info] of styles) {
19410
+ if (info.outlineLevel !== void 0) continue;
19411
+ const seen = /* @__PURE__ */ new Set([styleId]);
19412
+ let cur = info.basedOn;
19413
+ while (cur && !seen.has(cur)) {
19414
+ seen.add(cur);
19415
+ const parent = styles.get(cur);
19416
+ if (!parent) break;
19417
+ if (parent.outlineLevel !== void 0) {
19418
+ info.outlineLevel = parent.outlineLevel;
19419
+ break;
19420
+ }
19421
+ cur = parent.basedOn;
19422
+ }
19423
+ }
19109
19424
  return styles;
19110
19425
  }
19111
19426
  function parseNumbering(xml) {
@@ -19180,7 +19495,7 @@ function collectOmmlRoots(p) {
19180
19495
  const child = children[i];
19181
19496
  if (child.nodeType !== 1) continue;
19182
19497
  const el = child;
19183
- const tag = el.localName || _optionalChain([el, 'access', _139 => _139.tagName, 'optionalAccess', _140 => _140.replace, 'call', _141 => _141(/^[^:]+:/, "")]) || "";
19498
+ const tag = el.localName || _optionalChain([el, 'access', _150 => _150.tagName, 'optionalAccess', _151 => _151.replace, 'call', _152 => _152(/^[^:]+:/, "")]) || "";
19184
19499
  if (tag === "oMath" || tag === "oMathPara") {
19185
19500
  out.push(el);
19186
19501
  } else if (tag === "txbxContent" || tag === "Fallback") {
@@ -19193,8 +19508,12 @@ function collectOmmlRoots(p) {
19193
19508
  return out;
19194
19509
  }
19195
19510
  function extractRun(r) {
19196
- const tElements = getChildElements(r, "t");
19197
- const text = tElements.map((t) => _nullishCoalesce(t.textContent, () => ( ""))).join("");
19511
+ let text = "";
19512
+ for (const el of effectiveChildElements(r)) {
19513
+ if (matchesLocal(el, "t")) text += _nullishCoalesce(el.textContent, () => ( ""));
19514
+ else if (matchesLocal(el, "br") || matchesLocal(el, "cr")) text += "\n";
19515
+ else if (matchesLocal(el, "tab")) text += " ";
19516
+ }
19198
19517
  let bold = false;
19199
19518
  let italic = false;
19200
19519
  const rPrEls = getChildElements(r, "rPr");
@@ -19217,7 +19536,7 @@ function fieldUrlFromInstr(instr) {
19217
19536
  function makeLink(text, rawHref) {
19218
19537
  if (!text) return "";
19219
19538
  if (!rawHref) return text;
19220
- const href = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, rawHref);
19539
+ const href = _chunkF2HYH62Hcjs.sanitizeHref.call(void 0, rawHref);
19221
19540
  return href ? `[${text}](${href})` : text;
19222
19541
  }
19223
19542
  function collectInline(p, footnotes, rels) {
@@ -19319,7 +19638,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
19319
19638
  const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
19320
19639
  if (!text) return null;
19321
19640
  const style = styles.get(styleId);
19322
- if (_optionalChain([style, 'optionalAccess', _142 => _142.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
19641
+ if (_optionalChain([style, 'optionalAccess', _153 => _153.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
19323
19642
  return {
19324
19643
  type: "heading",
19325
19644
  text,
@@ -19328,8 +19647,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
19328
19647
  }
19329
19648
  if (numId && numId !== "0") {
19330
19649
  const numDef = numbering.get(numId);
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";
19650
+ const levelInfo = _optionalChain([numDef, 'optionalAccess', _154 => _154.get, 'call', _155 => _155(ilvl)]);
19651
+ const listType = _optionalChain([levelInfo, 'optionalAccess', _156 => _156.numFmt]) === "bullet" ? "unordered" : "ordered";
19333
19652
  return { type: "list", text, listType };
19334
19653
  }
19335
19654
  const block = { type: "paragraph", text };
@@ -19349,7 +19668,7 @@ function collectTextboxParagraphs(node, inTxbx = false, out = [], depth = 0) {
19349
19668
  }
19350
19669
  return out;
19351
19670
  }
19352
- function parseTable(tbl2, styles, numbering, footnotes, rels) {
19671
+ function parseTable(tbl2, styles, numbering, footnotes, rels, keepEmptyCols) {
19353
19672
  const trElements = getChildElements(tbl2, "tr");
19354
19673
  if (trElements.length === 0) return null;
19355
19674
  const rawRows = [];
@@ -19411,7 +19730,7 @@ ${cell2.text}` : cell2.text;
19411
19730
  return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
19412
19731
  })
19413
19732
  );
19414
- const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
19733
+ const table2 = _chunkXTCT6KQ5cjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
19415
19734
  if (table2.rows === 0 || table2.cols === 0) return null;
19416
19735
  return { type: "table", table: table2 };
19417
19736
  }
@@ -19421,10 +19740,10 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
19421
19740
  for (const el of effectiveChildElements(tc2)) {
19422
19741
  if (matchesLocal(el, "p")) {
19423
19742
  const block = parseParagraph2(el, styles, numbering, footnotes, rels);
19424
- if (_optionalChain([block, 'optionalAccess', _146 => _146.text])) parts.push(block.text);
19743
+ if (_optionalChain([block, 'optionalAccess', _157 => _157.text])) parts.push(block.text);
19425
19744
  for (const tp of collectTextboxParagraphs(el)) {
19426
19745
  const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
19427
- if (_optionalChain([tb, 'optionalAccess', _147 => _147.text])) parts.push(tb.text);
19746
+ if (_optionalChain([tb, 'optionalAccess', _158 => _158.text])) parts.push(tb.text);
19428
19747
  }
19429
19748
  } else if (matchesLocal(el, "tbl")) {
19430
19749
  for (const tr of getChildElements(el, "tr")) {
@@ -19459,7 +19778,7 @@ async function buildImageMap(zip, rels, doc, warnings) {
19459
19778
  try {
19460
19779
  const data = await imgFile.async("uint8array");
19461
19780
  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"));
19781
+ const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _159 => _159.split, 'call', _160 => _160("."), 'access', _161 => _161.pop, 'call', _162 => _162(), 'optionalAccess', _163 => _163.toLowerCase, 'call', _164 => _164()]), () => ( "png"));
19463
19782
  const mimeMap = {
19464
19783
  png: "image/png",
19465
19784
  jpg: "image/jpeg",
@@ -19513,12 +19832,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
19513
19832
  }
19514
19833
  }
19515
19834
  async function parseDocxDocument(buffer, options) {
19516
- _chunk6XAAYAWLcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
19835
+ _chunkF2HYH62Hcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
19517
19836
  const zip = await _jszip2.default.loadAsync(buffer);
19518
19837
  const warnings = [];
19519
19838
  const docFile = zip.file("word/document.xml");
19520
19839
  if (!docFile) {
19521
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
19840
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
19522
19841
  }
19523
19842
  let rels = /* @__PURE__ */ new Map();
19524
19843
  const relsFile = zip.file("word/_rels/document.xml.rels");
@@ -19565,7 +19884,7 @@ async function parseDocxDocument(buffer, options) {
19565
19884
  const doc = parseXml2(docXml);
19566
19885
  const body = findElements(doc, "body");
19567
19886
  if (body.length === 0) {
19568
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19887
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19569
19888
  }
19570
19889
  const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
19571
19890
  const linkedImages = /* @__PURE__ */ new Set();
@@ -19573,7 +19892,7 @@ async function parseDocxDocument(buffer, options) {
19573
19892
  const bodyEl = body[0];
19574
19893
  const topLevel = effectiveChildElements(bodyEl);
19575
19894
  for (const el of topLevel) {
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()])));
19895
+ const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _165 => _165.tagName, 'optionalAccess', _166 => _166.split, 'call', _167 => _167(":"), 'access', _168 => _168.pop, 'call', _169 => _169()])));
19577
19896
  if (localName2 === "p") {
19578
19897
  const block = parseParagraph2(el, styles, numbering, footnotes, rels);
19579
19898
  if (block) blocks.push(block);
@@ -19584,7 +19903,7 @@ async function parseDocxDocument(buffer, options) {
19584
19903
  if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
19585
19904
  }
19586
19905
  } else if (localName2 === "tbl") {
19587
- const block = parseTable(el, styles, numbering, footnotes, rels);
19906
+ const block = parseTable(el, styles, numbering, footnotes, rels, _optionalChain([options, 'optionalAccess', _170 => _170.keepTrailingEmptyCols]));
19588
19907
  if (block) blocks.push(block);
19589
19908
  }
19590
19909
  }
@@ -19616,7 +19935,7 @@ async function parseDocxDocument(buffer, options) {
19616
19935
  }
19617
19936
  }
19618
19937
  const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
19619
- const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
19938
+ const markdown = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, blocks);
19620
19939
  return {
19621
19940
  markdown,
19622
19941
  blocks,
@@ -19639,7 +19958,7 @@ function parseHwpmlDocument(buffer, options) {
19639
19958
  }
19640
19959
  const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
19641
19960
  const normalized = text.replace(/&nbsp;/g, "&#160;");
19642
- const xml = _chunk6XAAYAWLcjs.stripDtd.call(void 0, normalized);
19961
+ const xml = _chunkF2HYH62Hcjs.stripDtd.call(void 0, normalized);
19643
19962
  const warnings = [];
19644
19963
  const parser = new (0, _xmldom.DOMParser)({
19645
19964
  onError: (_level, msg2) => {
@@ -19667,7 +19986,7 @@ function parseHwpmlDocument(buffer, options) {
19667
19986
  return { markdown: "", blocks: [], metadata, warnings };
19668
19987
  }
19669
19988
  const blocks = [];
19670
- const pageFilter = _optionalChain([options, 'optionalAccess', _159 => _159.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
19989
+ const pageFilter = _optionalChain([options, 'optionalAccess', _171 => _171.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
19671
19990
  let sectionIdx = 0;
19672
19991
  const children = body.childNodes;
19673
19992
  for (let i = 0; i < children.length; i++) {
@@ -19676,10 +19995,10 @@ function parseHwpmlDocument(buffer, options) {
19676
19995
  if (localName(el) !== "SECTION") continue;
19677
19996
  sectionIdx++;
19678
19997
  if (pageFilter && !pageFilter.has(sectionIdx)) continue;
19679
- parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
19998
+ parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _172 => _172.keepTrailingEmptyCols]), () => ( false)));
19680
19999
  }
19681
20000
  const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
19682
- const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
20001
+ const markdown = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, blocks);
19683
20002
  return {
19684
20003
  markdown,
19685
20004
  blocks,
@@ -19712,10 +20031,10 @@ function buildParaShapeMap(root) {
19712
20031
  }
19713
20032
  return map;
19714
20033
  }
19715
- function parseSection2(section, blocks, paraShapeMap, sectionNum, warnings) {
19716
- walkContent(section, blocks, paraShapeMap, sectionNum, warnings, false);
20034
+ function parseSection2(section, blocks, paraShapeMap, sectionNum, warnings, keep) {
20035
+ walkContent(section, blocks, paraShapeMap, sectionNum, warnings, false, keep);
19717
20036
  }
19718
- function walkContent(node, blocks, paraShapeMap, sectionNum, warnings, inHeaderFooter, depth = 0) {
20037
+ function walkContent(node, blocks, paraShapeMap, sectionNum, warnings, inHeaderFooter, keep, depth = 0) {
19719
20038
  if (depth > MAX_XML_DEPTH2) return;
19720
20039
  const children = node.childNodes;
19721
20040
  for (let i = 0; i < children.length; i++) {
@@ -19728,24 +20047,24 @@ function walkContent(node, blocks, paraShapeMap, sectionNum, warnings, inHeaderF
19728
20047
  if (tag === "P") {
19729
20048
  if (!inHeaderFooter) {
19730
20049
  parseParagraph3(el, blocks, paraShapeMap, sectionNum);
19731
- walkTablesInP(el, blocks, paraShapeMap, sectionNum, warnings);
20050
+ walkTablesInP(el, blocks, paraShapeMap, sectionNum, warnings, keep);
19732
20051
  }
19733
20052
  continue;
19734
20053
  }
19735
20054
  if (tag === "TABLE") {
19736
20055
  if (!inHeaderFooter) {
19737
- parseTable2(el, blocks, paraShapeMap, sectionNum, warnings);
20056
+ parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep);
19738
20057
  }
19739
20058
  continue;
19740
20059
  }
19741
20060
  if (tag === "PARALIST" || tag === "SECTION" || tag === "COLDEF") {
19742
- walkContent(el, blocks, paraShapeMap, sectionNum, warnings, inHeaderFooter, depth + 1);
20061
+ walkContent(el, blocks, paraShapeMap, sectionNum, warnings, inHeaderFooter, keep, depth + 1);
19743
20062
  continue;
19744
20063
  }
19745
- walkContent(el, blocks, paraShapeMap, sectionNum, warnings, inHeaderFooter, depth + 1);
20064
+ walkContent(el, blocks, paraShapeMap, sectionNum, warnings, inHeaderFooter, keep, depth + 1);
19746
20065
  }
19747
20066
  }
19748
- function walkTablesInP(node, blocks, paraShapeMap, sectionNum, warnings, depth = 0) {
20067
+ function walkTablesInP(node, blocks, paraShapeMap, sectionNum, warnings, keep, depth = 0) {
19749
20068
  if (depth > MAX_XML_DEPTH2) return;
19750
20069
  const children = node.childNodes;
19751
20070
  for (let i = 0; i < children.length; i++) {
@@ -19753,11 +20072,11 @@ function walkTablesInP(node, blocks, paraShapeMap, sectionNum, warnings, depth =
19753
20072
  if (el.nodeType !== 1) continue;
19754
20073
  const tag = localName(el);
19755
20074
  if (tag === "TABLE") {
19756
- parseTable2(el, blocks, paraShapeMap, sectionNum, warnings);
20075
+ parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep);
19757
20076
  continue;
19758
20077
  }
19759
20078
  if (tag === "FOOTNOTE" || tag === "ENDNOTE" || tag === "HEADER" || tag === "FOOTER") continue;
19760
- walkTablesInP(el, blocks, paraShapeMap, sectionNum, warnings, depth + 1);
20079
+ walkTablesInP(el, blocks, paraShapeMap, sectionNum, warnings, keep, depth + 1);
19761
20080
  }
19762
20081
  }
19763
20082
  function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
@@ -19765,7 +20084,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
19765
20084
  const shapeInfo = paraShapeMap.get(paraShapeId);
19766
20085
  const text = extractParagraphText(el);
19767
20086
  if (!text) return;
19768
- if (_optionalChain([shapeInfo, 'optionalAccess', _160 => _160.headingLevel]) != null) {
20087
+ if (_optionalChain([shapeInfo, 'optionalAccess', _173 => _173.headingLevel]) != null) {
19769
20088
  blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
19770
20089
  } else {
19771
20090
  blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
@@ -19793,7 +20112,7 @@ function collectCharText(node, parts, depth = 0) {
19793
20112
  }
19794
20113
  }
19795
20114
  }
19796
- function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
20115
+ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
19797
20116
  const cells = [];
19798
20117
  const rowCount = parseInt(_nullishCoalesce(el.getAttribute("RowCount"), () => ( "0")), 10);
19799
20118
  const colCount = parseInt(_nullishCoalesce(el.getAttribute("ColCount"), () => ( "0")), 10);
@@ -19810,8 +20129,8 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
19810
20129
  for (let j = 0; j < rowCells.length; j++) {
19811
20130
  const cellEl = rowCells[j];
19812
20131
  if (cellEl.nodeType !== 1 || localName(cellEl) !== "CELL") continue;
19813
- const colAddr = parseInt(_nullishCoalesce(cellEl.getAttribute("ColAddr"), () => ( "0")), 10);
19814
- const rowAddr = parseInt(_nullishCoalesce(cellEl.getAttribute("RowAddr"), () => ( "0")), 10);
20132
+ const colAddr = parseInt(_nullishCoalesce(cellEl.getAttribute("ColAddr"), () => ( "0")), 10) || 0;
20133
+ const rowAddr = parseInt(_nullishCoalesce(cellEl.getAttribute("RowAddr"), () => ( "0")), 10) || 0;
19815
20134
  const colSpan = Math.min(Math.max(1, parseInt(_nullishCoalesce(cellEl.getAttribute("ColSpan"), () => ( "1")), 10) || 1), MAX_TABLE_COLS);
19816
20135
  const rowSpan = Math.min(Math.max(1, parseInt(_nullishCoalesce(cellEl.getAttribute("RowSpan"), () => ( "1")), 10) || 1), MAX_TABLE_ROWS);
19817
20136
  const cellText = extractCellText(cellEl);
@@ -19819,25 +20138,12 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
19819
20138
  }
19820
20139
  }
19821
20140
  if (cells.length === 0) return;
19822
- const grid = Array.from({ length: rowCount }, () => Array(colCount).fill(null));
20141
+ const cellRows = Array.from({ length: rowCount }, () => []);
19823
20142
  for (const cell2 of cells) {
19824
- const r = _nullishCoalesce(cell2.rowAddr, () => ( 0));
19825
- const c = _nullishCoalesce(cell2.colAddr, () => ( 0));
19826
- if (isNaN(r) || isNaN(c) || r >= rowCount || c >= colCount) continue;
19827
- grid[r][c] = cell2;
19828
- for (let dr = 0; dr < cell2.rowSpan; dr++) {
19829
- for (let dc = 0; dc < cell2.colSpan; dc++) {
19830
- if (dr === 0 && dc === 0) continue;
19831
- if (r + dr < rowCount && c + dc < colCount) {
19832
- grid[r + dr][c + dc] = { text: "", colSpan: 1, rowSpan: 1 };
19833
- }
19834
- }
19835
- }
20143
+ const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
20144
+ cellRows[r].push(cell2);
19836
20145
  }
19837
- const cellRows = grid.map(
19838
- (row) => row.map((cell2) => _nullishCoalesce(cell2, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
19839
- );
19840
- const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
20146
+ const table2 = _chunkXTCT6KQ5cjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
19841
20147
  const caption = extractShapeCaption(el);
19842
20148
  if (caption.text && caption.before) {
19843
20149
  blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
@@ -20073,7 +20379,7 @@ function findMatchingKey(cellLabel, values) {
20073
20379
  bestKey = key;
20074
20380
  }
20075
20381
  } else if (key.startsWith(cellLabel)) {
20076
- if (cellLabel.length >= key.length * 0.6 && cellLabel.length > bestLen) {
20382
+ if (cellLabel.length >= key.length * 0.75 && cellLabel.length > bestLen) {
20077
20383
  bestLen = cellLabel.length;
20078
20384
  bestKey = key;
20079
20385
  }
@@ -20097,7 +20403,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
20097
20403
  (match, prefix, suffix) => {
20098
20404
  const label = prefix + suffix;
20099
20405
  const normalizedLabel = normalizeLabel(label);
20100
- if (_optionalChain([blockedLabels, 'optionalAccess', _161 => _161.has, 'call', _162 => _162(normalizedLabel)])) return match;
20406
+ if (_optionalChain([blockedLabels, 'optionalAccess', _174 => _174.has, 'call', _175 => _175(normalizedLabel)])) return match;
20101
20407
  const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
20102
20408
  if (matchKey === void 0) return match;
20103
20409
  const newValue = values.consume(matchKey);
@@ -20113,7 +20419,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
20113
20419
  const matchKey = values.available(normalizedKw) ? normalizedKw : void 0;
20114
20420
  if (matchKey === void 0) return match;
20115
20421
  const val = values.peek(matchKey);
20116
- const isTruthy = ["\u2611", "\u2713", "\u2714", "v", "V", "true", "1", "yes", "o", "O"].includes(val.trim()) || val.trim() === "";
20422
+ const isTruthy = ["\u2611", "\u2713", "\u2714", "v", "V", "true", "1", "yes", "o", "O"].includes(val.trim());
20117
20423
  if (!isTruthy) return match;
20118
20424
  values.consume(matchKey);
20119
20425
  matchedLabels.add(matchKey);
@@ -20135,14 +20441,20 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
20135
20441
  );
20136
20442
  return matches.length > 0 ? { text, matches } : null;
20137
20443
  }
20138
- var INLINE_LABEL_RE = /([가-힣A-Za-z]{2,10})\s*[::]/g;
20444
+ var INLINE_LABEL_RE = /((?:[가-힣A-Za-z]{1,10} )?)([가-힣A-Za-z]{2,10})\s*[::]/g;
20139
20445
  function scanInlineSegments(text) {
20140
20446
  const labels = [];
20141
20447
  INLINE_LABEL_RE.lastIndex = 0;
20142
20448
  let m;
20143
20449
  while ((m = INLINE_LABEL_RE.exec(text)) !== null) {
20144
20450
  if (text[INLINE_LABEL_RE.lastIndex] === "/") continue;
20145
- labels.push({ label: m[1], start: m.index, end: INLINE_LABEL_RE.lastIndex });
20451
+ labels.push({
20452
+ label: m[2],
20453
+ ext: m[1] ? m[1] + m[2] : void 0,
20454
+ extStart: m[1] ? m.index : void 0,
20455
+ start: m.index + m[1].length,
20456
+ end: INLINE_LABEL_RE.lastIndex
20457
+ });
20146
20458
  }
20147
20459
  const segments = [];
20148
20460
  for (let i = 0; i < labels.length; i++) {
@@ -20160,21 +20472,44 @@ function scanInlineSegments(text) {
20160
20472
  labelStart: cur.start,
20161
20473
  valueStart: vs,
20162
20474
  valueEnd: ve,
20163
- value: text.slice(vs, ve)
20475
+ value: text.slice(vs, ve),
20476
+ ...cur.ext !== void 0 ? { extLabel: cur.ext, extStart: cur.extStart } : {}
20164
20477
  });
20165
20478
  }
20166
20479
  return segments;
20167
20480
  }
20481
+ function matchInlineSegment(seg, values, blockedLabels) {
20482
+ const nlabel = normalizeLabel(seg.label);
20483
+ if (seg.extLabel !== void 0) {
20484
+ const nExt = normalizeLabel(seg.extLabel);
20485
+ if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess', _176 => _176.has, 'call', _177 => _177(nExt)]) && values.has(nExt)) {
20486
+ return { key: nExt, label: seg.extLabel, viaExt: true };
20487
+ }
20488
+ }
20489
+ if (_optionalChain([blockedLabels, 'optionalAccess', _178 => _178.has, 'call', _179 => _179(nlabel)])) return void 0;
20490
+ const key = findMatchingKey(nlabel, values);
20491
+ return key !== void 0 ? { key, label: seg.label, viaExt: false } : void 0;
20492
+ }
20493
+ function clampSegmentEnd(text, seg, next, nextViaExt) {
20494
+ let ve = seg.valueEnd;
20495
+ if (nextViaExt && _optionalChain([next, 'optionalAccess', _180 => _180.extStart]) !== void 0 && next.extStart < ve) ve = next.extStart;
20496
+ while (ve > seg.valueStart && /\s/.test(text[ve - 1])) ve--;
20497
+ return ve;
20498
+ }
20168
20499
  function padInsertion(text, pos, value) {
20169
20500
  const lead = pos > 0 && !/\s/.test(text[pos - 1]) ? " " : "";
20170
20501
  const trail = pos < text.length && !/\s/.test(text[pos]) ? " " : "";
20171
20502
  return lead + value + trail;
20172
20503
  }
20173
- function normalizeValues(values) {
20504
+ function normalizeValues(values, warnings) {
20174
20505
  const map = /* @__PURE__ */ new Map();
20175
20506
  for (const [label, raw] of Object.entries(values)) {
20176
20507
  const { value, format } = typeof raw === "object" && !Array.isArray(raw) ? raw : { value: raw, format: void 0 };
20177
- map.set(normalizeLabel(label), Array.isArray(value) ? value.map((v) => formatFillValue(v, format)) : formatFillValue(value, format));
20508
+ const key = normalizeLabel(label);
20509
+ if (map.has(key)) {
20510
+ _optionalChain([warnings, 'optionalAccess', _181 => _181.push, 'call', _182 => _182(`\uC785\uB825 \uB77C\uBCA8 "${label}"\uC774 \uC815\uADDC\uD654 \uD0A4 "${key}"\uC5D0\uC11C \uB2E4\uB978 \uB77C\uBCA8\uACFC \uCDA9\uB3CC \u2014 \uB4A4 \uAC12\uC73C\uB85C \uB36E\uC5B4\uC500`)]);
20511
+ }
20512
+ map.set(key, Array.isArray(value) ? value.map((v) => formatFillValue(v, format)) : formatFillValue(value, format));
20178
20513
  }
20179
20514
  return map;
20180
20515
  }
@@ -20347,8 +20682,8 @@ function extractFromTable(table2) {
20347
20682
  if (table2.cols >= 2) {
20348
20683
  for (let r = 0; r < table2.rows; r++) {
20349
20684
  for (let c = 0; c < table2.cols - 1; c++) {
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]]);
20685
+ const labelCell = _optionalChain([table2, 'access', _183 => _183.cells, 'access', _184 => _184[r], 'optionalAccess', _185 => _185[c]]);
20686
+ const valueCell = _optionalChain([table2, 'access', _186 => _186.cells, 'access', _187 => _187[r], 'optionalAccess', _188 => _188[c + 1]]);
20352
20687
  if (!labelCell || !valueCell) continue;
20353
20688
  if (isLabelCell(labelCell.text)) {
20354
20689
  fields.push({
@@ -20363,15 +20698,15 @@ function extractFromTable(table2) {
20363
20698
  }
20364
20699
  if (fields.length === 0 && table2.rows >= 2 && table2.cols >= 2) {
20365
20700
  const headerRow = table2.cells[0];
20366
- const allLabels = headerRow.every((cell2) => {
20367
- const t = cell2.text.trim();
20701
+ const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess', _189 => _189.every, 'call', _190 => _190((cell2) => {
20702
+ const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _191 => _191.text, 'access', _192 => _192.trim, 'call', _193 => _193()]), () => ( ""));
20368
20703
  return t.length > 0 && t.length <= 20;
20369
- });
20704
+ })]), () => ( false));
20370
20705
  if (allLabels) {
20371
20706
  for (let r = 1; r < table2.rows; r++) {
20372
20707
  for (let c = 0; c < table2.cols; c++) {
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()]), () => ( ""));
20708
+ const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _194 => _194[c], 'optionalAccess', _195 => _195.text, 'access', _196 => _196.trim, 'call', _197 => _197()]), () => ( ""));
20709
+ const value = _nullishCoalesce(_optionalChain([table2, 'access', _198 => _198.cells, 'access', _199 => _199[r], 'optionalAccess', _200 => _200[c], 'optionalAccess', _201 => _201.text, 'access', _202 => _202.trim, 'call', _203 => _203()]), () => ( ""));
20375
20710
  if (label && value) {
20376
20711
  fields.push({ label, value, row: r, col: c });
20377
20712
  }
@@ -20457,14 +20792,15 @@ function fillFormFields(blocks, values, blockedLabels) {
20457
20792
  const cloned = structuredClone(blocks);
20458
20793
  const filled = [];
20459
20794
  const matchedLabels = /* @__PURE__ */ new Set();
20460
- const normalizedValues = normalizeValues(values);
20795
+ const warnings = [];
20796
+ const normalizedValues = normalizeValues(values, warnings);
20461
20797
  const cursor = new ValueCursor(normalizedValues);
20462
20798
  const allTables = collectIRTables(cloned, 0);
20463
20799
  const patternFilledCells = /* @__PURE__ */ new Set();
20464
20800
  for (const table2 of allTables) {
20465
20801
  for (let r = 0; r < table2.rows; r++) {
20466
20802
  for (let c = 0; c < table2.cols; c++) {
20467
- const cell2 = _optionalChain([table2, 'access', _179 => _179.cells, 'access', _180 => _180[r], 'optionalAccess', _181 => _181[c]]);
20803
+ const cell2 = _optionalChain([table2, 'access', _204 => _204.cells, 'access', _205 => _205[r], 'optionalAccess', _206 => _206[c]]);
20468
20804
  if (!cell2) continue;
20469
20805
  const result = fillInCellPatterns(cell2.text, cursor, matchedLabels, blockedLabels);
20470
20806
  if (result) {
@@ -20486,7 +20822,7 @@ function fillFormFields(blocks, values, blockedLabels) {
20486
20822
  if (newText !== block.text) block.text = newText;
20487
20823
  }
20488
20824
  const unmatched = resolveUnmatched(normalizedValues, matchedLabels, values);
20489
- return { blocks: cloned, filled, unmatched };
20825
+ return { blocks: cloned, filled, unmatched, ...warnings.length > 0 ? { warnings } : {} };
20490
20826
  }
20491
20827
  function collectIRTables(blocks, depth) {
20492
20828
  if (depth > 16) return [];
@@ -20496,7 +20832,7 @@ function collectIRTables(blocks, depth) {
20496
20832
  out.push(block.table);
20497
20833
  for (const row of block.table.cells) {
20498
20834
  for (const cell2 of row) {
20499
- if (_optionalChain([cell2, 'optionalAccess', _182 => _182.blocks, 'optionalAccess', _183 => _183.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
20835
+ if (_optionalChain([cell2, 'optionalAccess', _207 => _207.blocks, 'optionalAccess', _208 => _208.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
20500
20836
  }
20501
20837
  }
20502
20838
  }
@@ -20507,7 +20843,7 @@ function coveredPositions(table2) {
20507
20843
  for (let r = 0; r < table2.rows; r++) {
20508
20844
  for (let c = 0; c < table2.cols; c++) {
20509
20845
  if (covered.has(`${r},${c}`)) continue;
20510
- const cell2 = _optionalChain([table2, 'access', _184 => _184.cells, 'access', _185 => _185[r], 'optionalAccess', _186 => _186[c]]);
20846
+ const cell2 = _optionalChain([table2, 'access', _209 => _209.cells, 'access', _210 => _210[r], 'optionalAccess', _211 => _211[c]]);
20511
20847
  if (!cell2) continue;
20512
20848
  for (let dr = 0; dr < cell2.rowSpan; dr++) {
20513
20849
  for (let dc = 0; dc < cell2.colSpan; dc++) {
@@ -20520,13 +20856,31 @@ function coveredPositions(table2) {
20520
20856
  }
20521
20857
  return covered;
20522
20858
  }
20859
+ function isHeaderDataTable(table2, covered) {
20860
+ if (table2.rows < 2) return false;
20861
+ const headerRow = table2.cells[0];
20862
+ if (!_optionalChain([headerRow, 'optionalAccess', _212 => _212.length])) return false;
20863
+ const allLabels = headerRow.every((cell2) => {
20864
+ const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _213 => _213.text, 'access', _214 => _214.trim, 'call', _215 => _215()]), () => ( ""));
20865
+ return t.length > 0 && t.length <= 20 && isLabelCell(t);
20866
+ });
20867
+ if (!allLabels) return false;
20868
+ for (let c = 0; c < table2.cols; c++) {
20869
+ if (covered.has(`1,${c}`)) continue;
20870
+ const cell2 = _optionalChain([table2, 'access', _216 => _216.cells, 'access', _217 => _217[1], 'optionalAccess', _218 => _218[c]]);
20871
+ if (!cell2) break;
20872
+ return !isLabelCell(cell2.text);
20873
+ }
20874
+ return true;
20875
+ }
20523
20876
  function fillTable(table2, values, filled, matchedLabels, patternFilledCells, blockedLabels) {
20524
20877
  if (table2.cols < 2) return;
20525
20878
  const covered = coveredPositions(table2);
20526
- for (let r = 0; r < table2.rows; r++) {
20879
+ const skipHeaderRow = isHeaderDataTable(table2, covered);
20880
+ for (let r = skipHeaderRow ? 1 : 0; r < table2.rows; r++) {
20527
20881
  for (let c = 0; c < table2.cols; c++) {
20528
20882
  if (covered.has(`${r},${c}`)) continue;
20529
- const labelCell = table2.cells[r][c];
20883
+ const labelCell = _optionalChain([table2, 'access', _219 => _219.cells, 'access', _220 => _220[r], 'optionalAccess', _221 => _221[c]]);
20530
20884
  if (!labelCell) continue;
20531
20885
  if (!isLabelCell(labelCell.text)) continue;
20532
20886
  let vc = c + labelCell.colSpan;
@@ -20537,12 +20891,12 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
20537
20891
  if (isKeywordLabel(valueCell.text)) continue;
20538
20892
  const normalizedCellLabel = normalizeLabel(labelCell.text);
20539
20893
  if (!normalizedCellLabel) continue;
20540
- if (_optionalChain([blockedLabels, 'optionalAccess', _187 => _187.has, 'call', _188 => _188(normalizedCellLabel)])) continue;
20894
+ if (_optionalChain([blockedLabels, 'optionalAccess', _222 => _222.has, 'call', _223 => _223(normalizedCellLabel)])) continue;
20541
20895
  const matchKey = findMatchingKey(normalizedCellLabel, values);
20542
20896
  if (matchKey === void 0) continue;
20543
20897
  const newValue = values.consume(matchKey);
20544
20898
  if (newValue === void 0) continue;
20545
- if (_optionalChain([patternFilledCells, 'optionalAccess', _189 => _189.has, 'call', _190 => _190(valueCell)])) {
20899
+ if (_optionalChain([patternFilledCells, 'optionalAccess', _224 => _224.has, 'call', _225 => _225(valueCell)])) {
20546
20900
  valueCell.text = newValue + " " + valueCell.text;
20547
20901
  } else {
20548
20902
  valueCell.text = newValue;
@@ -20559,25 +20913,29 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
20559
20913
  }
20560
20914
  if (table2.rows >= 2 && table2.cols >= 2) {
20561
20915
  const headerRow = table2.cells[0];
20562
- const allLabels = headerRow.every((cell2) => {
20563
- const t = cell2.text.trim();
20916
+ const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess', _226 => _226.every, 'call', _227 => _227((cell2) => {
20917
+ const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _228 => _228.text, 'access', _229 => _229.trim, 'call', _230 => _230()]), () => ( ""));
20564
20918
  return t.length > 0 && t.length <= 20 && isLabelCell(t);
20565
- });
20919
+ })]), () => ( false));
20566
20920
  if (!allLabels) return;
20567
20921
  for (let r = 1; r < table2.rows; r++) {
20568
20922
  for (let c = 0; c < table2.cols; c++) {
20569
20923
  if (covered.has(`${r},${c}`)) continue;
20570
20924
  const headerCell = headerRow[c];
20571
- const valueCell = _optionalChain([table2, 'access', _191 => _191.cells, 'access', _192 => _192[r], 'optionalAccess', _193 => _193[c]]);
20925
+ const valueCell = _optionalChain([table2, 'access', _231 => _231.cells, 'access', _232 => _232[r], 'optionalAccess', _233 => _233[c]]);
20572
20926
  if (!headerCell || !valueCell) continue;
20573
20927
  const headerLabel = normalizeLabel(headerCell.text);
20574
- if (_optionalChain([blockedLabels, 'optionalAccess', _194 => _194.has, 'call', _195 => _195(headerLabel)])) continue;
20928
+ if (_optionalChain([blockedLabels, 'optionalAccess', _234 => _234.has, 'call', _235 => _235(headerLabel)])) continue;
20575
20929
  const matchKey = findMatchingKey(headerLabel, values);
20576
20930
  if (matchKey === void 0) continue;
20577
20931
  if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
20578
20932
  const newValue = values.consume(matchKey);
20579
20933
  if (newValue === void 0) continue;
20580
- valueCell.text = newValue;
20934
+ if (_optionalChain([patternFilledCells, 'optionalAccess', _236 => _236.has, 'call', _237 => _237(valueCell)])) {
20935
+ valueCell.text = newValue + " " + valueCell.text;
20936
+ } else {
20937
+ valueCell.text = newValue;
20938
+ }
20581
20939
  matchedLabels.add(matchKey);
20582
20940
  filled.push({
20583
20941
  label: headerCell.text.trim(),
@@ -20593,20 +20951,22 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
20593
20951
  function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
20594
20952
  const segments = scanInlineSegments(text);
20595
20953
  if (segments.length === 0) return text;
20954
+ const matches = segments.map((seg) => matchInlineSegment(seg, values, blockedLabels));
20596
20955
  let out = "";
20597
20956
  let pos = 0;
20598
- for (const seg of segments) {
20599
- const nlabel = normalizeLabel(seg.label);
20600
- if (_optionalChain([blockedLabels, 'optionalAccess', _196 => _196.has, 'call', _197 => _197(nlabel)])) continue;
20601
- const matchKey = findMatchingKey(nlabel, values);
20602
- if (matchKey === void 0) continue;
20957
+ for (let i = 0; i < segments.length; i++) {
20958
+ const seg = segments[i];
20959
+ const matched = matches[i];
20960
+ if (matched === void 0) continue;
20961
+ const matchKey = matched.key;
20603
20962
  const newValue = values.consume(matchKey);
20604
20963
  if (newValue === void 0) continue;
20605
20964
  matchedLabels.add(matchKey);
20606
- filled.push({ label: seg.label.trim(), value: newValue, row: -1, col: -1, key: matchKey });
20965
+ filled.push({ label: matched.label.trim(), value: newValue, row: -1, col: -1, key: matchKey });
20966
+ const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access', _238 => _238[i + 1], 'optionalAccess', _239 => _239.viaExt]), () => ( false)));
20607
20967
  out += text.slice(pos, seg.valueStart);
20608
- out += seg.valueStart === seg.valueEnd ? padInsertion(text, seg.valueStart, newValue) : newValue;
20609
- pos = seg.valueEnd;
20968
+ out += seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
20969
+ pos = ve;
20610
20970
  }
20611
20971
  out += text.slice(pos);
20612
20972
  return out;
@@ -20617,7 +20977,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
20617
20977
 
20618
20978
  // src/roundtrip/source-map.ts
20619
20979
  function escapeXmlText(text) {
20620
- return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
20980
+ return text.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
20621
20981
  }
20622
20982
  function decodeXmlEntities(text) {
20623
20983
  return text.replace(/&(lt|gt|amp|quot|apos|#x?[0-9a-fA-F]+);/g, (m, ent) => {
@@ -20636,7 +20996,7 @@ function decodeXmlEntities(text) {
20636
20996
  try {
20637
20997
  const code = ent[1] === "x" || ent[1] === "X" ? parseInt(ent.slice(2), 16) : parseInt(ent.slice(1), 10);
20638
20998
  if (!isNaN(code) && code >= 0 && code <= 1114111) return String.fromCodePoint(code);
20639
- } catch (e29) {
20999
+ } catch (e30) {
20640
21000
  }
20641
21001
  return m;
20642
21002
  });
@@ -21165,19 +21525,19 @@ function parseCentralDirectory(buf) {
21165
21525
  }
21166
21526
  }
21167
21527
  }
21168
- if (eocdOffset < 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
21528
+ if (eocdOffset < 0) throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
21169
21529
  const totalEntries = view.getUint16(eocdOffset + 10, true);
21170
21530
  const cdSize = view.getUint32(eocdOffset + 12, true);
21171
21531
  const cdOffset = view.getUint32(eocdOffset + 16, true);
21172
- if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21532
+ if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21173
21533
  if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
21174
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21534
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21175
21535
  }
21176
21536
  const decoder = new TextDecoder("utf-8");
21177
21537
  const entries = [];
21178
21538
  let pos = cdOffset;
21179
21539
  for (let i = 0; i < totalEntries; i++) {
21180
- if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
21540
+ if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
21181
21541
  const flags = view.getUint16(pos + 8, true);
21182
21542
  const method = view.getUint16(pos + 10, true);
21183
21543
  const crc = view.getUint32(pos + 16, true);
@@ -21188,7 +21548,7 @@ function parseCentralDirectory(buf) {
21188
21548
  const commentLen = view.getUint16(pos + 32, true);
21189
21549
  const localOffset = view.getUint32(pos + 42, true);
21190
21550
  if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
21191
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21551
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
21192
21552
  }
21193
21553
  const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
21194
21554
  const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
@@ -21217,11 +21577,11 @@ function patchZipEntries(original, replacements, additions) {
21217
21577
  const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
21218
21578
  const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
21219
21579
  for (const name of replacements.keys()) {
21220
- if (!entries.some((e) => e.name === name)) throw new (0, _chunk6XAAYAWLcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
21580
+ if (!entries.some((e) => e.name === name)) throw new (0, _chunkF2HYH62Hcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
21221
21581
  }
21222
21582
  if (additions) {
21223
21583
  for (const name of additions.keys()) {
21224
- if (entries.some((e) => e.name === name)) throw new (0, _chunk6XAAYAWLcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
21584
+ if (entries.some((e) => e.name === name)) throw new (0, _chunkF2HYH62Hcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
21225
21585
  }
21226
21586
  }
21227
21587
  const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
@@ -21240,13 +21600,16 @@ function patchZipEntries(original, replacements, additions) {
21240
21600
  offset += seg.length;
21241
21601
  continue;
21242
21602
  }
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");
21603
+ if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkF2HYH62Hcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
21244
21604
  const nameLen = view.getUint16(e.localOffset + 26, true);
21245
21605
  const extraLen = view.getUint16(e.localOffset + 28, true);
21246
21606
  const headerLen = 30 + nameLen + extraLen;
21247
21607
  const header = copyBytes(original, e.localOffset, e.localOffset + headerLen);
21248
21608
  const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
21249
21609
  const method = e.method;
21610
+ if (method !== 0 && method !== 8) {
21611
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 ZIP \uC555\uCD95 \uBC29\uC2DD(method=${method}): ${e.name} \u2014 STORE(0)/DEFLATE(8)\uB9CC \uAD50\uCCB4 \uAC00\uB2A5`);
21612
+ }
21250
21613
  const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
21251
21614
  const crc = crc32(newData);
21252
21615
  const flags = e.flags & ~8;
@@ -21346,9 +21709,10 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21346
21709
  const zip = await _jszip2.default.loadAsync(hwpxBuffer);
21347
21710
  const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
21348
21711
  if (sectionPaths.length === 0) {
21349
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
21712
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
21350
21713
  }
21351
- const normalizedValues = normalizeValues(values);
21714
+ const warnings = [];
21715
+ const normalizedValues = normalizeValues(values, warnings);
21352
21716
  const cursor = new ValueCursor(normalizedValues);
21353
21717
  const matchedLabels = /* @__PURE__ */ new Set();
21354
21718
  const filled = [];
@@ -21410,7 +21774,17 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21410
21774
  }
21411
21775
  }
21412
21776
  for (const table2 of allTables) {
21413
- for (let rowIdx = 0; rowIdx < table2.rows.length; rowIdx++) {
21777
+ const skipHeaderRow = table2.rows.length >= 2 && (() => {
21778
+ const first = table2.rows[0];
21779
+ const allLabels = first.length > 0 && first.every((cell2) => {
21780
+ const t = cellLabelText(cell2).trim();
21781
+ return t.length > 0 && t.length <= 20 && isLabelCell(t);
21782
+ });
21783
+ if (!allLabels) return false;
21784
+ const d0 = table2.rows[1][0];
21785
+ return d0 === void 0 || !isLabelCell(cellLabelText(d0));
21786
+ })();
21787
+ for (let rowIdx = skipHeaderRow ? 1 : 0; rowIdx < table2.rows.length; rowIdx++) {
21414
21788
  const cells = table2.rows[rowIdx];
21415
21789
  for (let colIdx = 0; colIdx < cells.length - 1; colIdx++) {
21416
21790
  const labelText = cellLabelText(cells[colIdx]);
@@ -21419,7 +21793,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21419
21793
  if (isKeywordLabel(cellLabelText(valueCell))) continue;
21420
21794
  const normalizedCellLabel = normalizeLabel(labelText);
21421
21795
  if (!normalizedCellLabel) continue;
21422
- if (_optionalChain([blockedLabels, 'optionalAccess', _198 => _198.has, 'call', _199 => _199(normalizedCellLabel)])) continue;
21796
+ if (_optionalChain([blockedLabels, 'optionalAccess', _240 => _240.has, 'call', _241 => _241(normalizedCellLabel)])) continue;
21423
21797
  const matchKey = findMatchingKey(normalizedCellLabel, cursor);
21424
21798
  if (matchKey === void 0) continue;
21425
21799
  if (patternApplied.has(valueCell)) {
@@ -21477,13 +21851,34 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21477
21851
  const dataCells = table2.rows[rowIdx];
21478
21852
  for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
21479
21853
  const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
21480
- if (_optionalChain([blockedLabels, 'optionalAccess', _200 => _200.has, 'call', _201 => _201(headerLabel)])) continue;
21854
+ if (_optionalChain([blockedLabels, 'optionalAccess', _242 => _242.has, 'call', _243 => _243(headerLabel)])) continue;
21481
21855
  const matchKey = findMatchingKey(headerLabel, cursor);
21482
21856
  if (matchKey === void 0) continue;
21483
21857
  if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
21858
+ const dataCell = dataCells[colIdx];
21859
+ if (patternApplied.has(dataCell)) {
21860
+ const target = _nullishCoalesce(dataCell.paragraphs.find((p) => p.tRanges.length > 0), () => ( dataCell.paragraphs[0]));
21861
+ if (!target) continue;
21862
+ const l = led(target);
21863
+ if (l.fullText !== void 0) continue;
21864
+ const newValue2 = cursor.consume(matchKey);
21865
+ if (newValue2 === void 0) continue;
21866
+ l.ranges.push({ start: 0, end: 0, replacement: newValue2 + " " });
21867
+ l.filledIdx.push(filled.length);
21868
+ l.matchKeys.push(matchKey);
21869
+ matchedLabels.add(matchKey);
21870
+ filled.push({
21871
+ label: cellLabelText(headerCells[colIdx]).trim(),
21872
+ value: newValue2,
21873
+ row: rowIdx,
21874
+ col: colIdx,
21875
+ key: matchKey
21876
+ });
21877
+ continue;
21878
+ }
21484
21879
  const newValue = cursor.consume(matchKey);
21485
21880
  if (newValue === void 0) continue;
21486
- const paras = dataCells[colIdx].paragraphs;
21881
+ const paras = dataCell.paragraphs;
21487
21882
  if (paras.length === 0) continue;
21488
21883
  const l0 = led(paras[0]);
21489
21884
  l0.fullText = newValue;
@@ -21510,22 +21905,25 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21510
21905
  }
21511
21906
  for (const para2 of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
21512
21907
  const existing = ledger.get(para2);
21513
- if (_optionalChain([existing, 'optionalAccess', _202 => _202.fullText]) !== void 0) continue;
21908
+ if (_optionalChain([existing, 'optionalAccess', _244 => _244.fullText]) !== void 0) continue;
21514
21909
  const text = matchText(para2);
21515
- for (const seg of scanInlineSegments(text)) {
21516
- const nlabel = normalizeLabel(seg.label);
21517
- if (_optionalChain([blockedLabels, 'optionalAccess', _203 => _203.has, 'call', _204 => _204(nlabel)])) continue;
21518
- const matchKey = findMatchingKey(nlabel, cursor);
21519
- if (matchKey === void 0) continue;
21910
+ const segments = scanInlineSegments(text);
21911
+ const matches = segments.map((seg) => matchInlineSegment(seg, cursor, blockedLabels));
21912
+ for (let i = 0; i < segments.length; i++) {
21913
+ const seg = segments[i];
21914
+ const matched = matches[i];
21915
+ if (matched === void 0) continue;
21916
+ const matchKey = matched.key;
21520
21917
  const newValue = cursor.consume(matchKey);
21521
21918
  if (newValue === void 0) continue;
21522
- const replacement = seg.valueStart === seg.valueEnd ? padInsertion(text, seg.valueStart, newValue) : newValue;
21919
+ const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access', _245 => _245[i + 1], 'optionalAccess', _246 => _246.viaExt]), () => ( false)));
21920
+ const replacement = seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
21523
21921
  const l = led(para2);
21524
- l.ranges.push({ start: seg.valueStart, end: seg.valueEnd, replacement });
21922
+ l.ranges.push({ start: seg.valueStart, end: ve, replacement });
21525
21923
  matchedLabels.add(matchKey);
21526
21924
  l.filledIdx.push(filled.length);
21527
21925
  l.matchKeys.push(matchKey);
21528
- filled.push({ label: seg.label.trim(), value: newValue, row: -1, col: -1, key: matchKey });
21926
+ filled.push({ label: matched.label.trim(), value: newValue, row: -1, col: -1, key: matchKey });
21529
21927
  }
21530
21928
  }
21531
21929
  const splices = [];
@@ -21578,7 +21976,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21578
21976
  }
21579
21977
  }
21580
21978
  for (const k of failedKeys) {
21581
- if (!succeededKeys.has(k)) matchedLabels.delete(k);
21979
+ if (!succeededKeys.has(k) || cursor.isArray(k)) matchedLabels.delete(k);
21582
21980
  }
21583
21981
  const cleanFilled = filled.filter((f) => f !== null);
21584
21982
  const unmatched = resolveUnmatched(normalizedValues, matchedLabels, values);
@@ -21586,7 +21984,8 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
21586
21984
  return {
21587
21985
  buffer: out.buffer.slice(out.byteOffset, out.byteOffset + out.byteLength),
21588
21986
  filled: cleanFilled,
21589
- unmatched
21987
+ unmatched,
21988
+ ...warnings.length > 0 ? { warnings } : {}
21590
21989
  };
21591
21990
  }
21592
21991
 
@@ -21623,16 +22022,16 @@ var PARA_LIST = 7;
21623
22022
  var DEFAULT_TEXT_COLOR = "#000000";
21624
22023
  function resolveTheme(theme) {
21625
22024
  return {
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)),
22025
+ h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _247 => _247.headingColors, 'optionalAccess', _248 => _248[1]]), () => ( DEFAULT_TEXT_COLOR)),
22026
+ h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _249 => _249.headingColors, 'optionalAccess', _250 => _250[2]]), () => ( DEFAULT_TEXT_COLOR)),
22027
+ h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _251 => _251.headingColors, 'optionalAccess', _252 => _252[3]]), () => ( DEFAULT_TEXT_COLOR)),
22028
+ h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _253 => _253.headingColors, 'optionalAccess', _254 => _254[4]]), () => ( _optionalChain([theme, 'optionalAccess', _255 => _255.headingColors, 'optionalAccess', _256 => _256[3]]))), () => ( DEFAULT_TEXT_COLOR)),
22029
+ body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _257 => _257.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
22030
+ quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _258 => _258.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
21632
22031
  /** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
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])
22032
+ hasQuoteOption: _optionalChain([theme, 'optionalAccess', _259 => _259.quoteColor]) !== void 0,
22033
+ tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _260 => _260.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _261 => _261.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
22034
+ tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _262 => _262.tableHeaderBold])
21636
22035
  };
21637
22036
  }
21638
22037
  function escapeXml(text) {
@@ -21863,27 +22262,39 @@ function parseMarkdownToBlocks(md2) {
21863
22262
  if (/^<table[\s>]/i.test(line.trimStart())) {
21864
22263
  const htmlLines = [];
21865
22264
  let depth = 0;
21866
- while (i < lines.length) {
21867
- const l = lines[i];
22265
+ let closed = false;
22266
+ let j = i;
22267
+ while (j < lines.length) {
22268
+ const l = lines[j];
21868
22269
  htmlLines.push(l);
21869
22270
  depth += (_nullishCoalesce(l.match(/<table[\s>]/gi), () => ( []))).length;
21870
22271
  depth -= (_nullishCoalesce(l.match(/<\/table>/gi), () => ( []))).length;
21871
- i++;
21872
- if (depth <= 0) break;
22272
+ j++;
22273
+ if (depth <= 0) {
22274
+ closed = true;
22275
+ break;
22276
+ }
22277
+ }
22278
+ if (closed) {
22279
+ blocks.push({ type: "html_table", text: htmlLines.join("\n") });
22280
+ i = j;
22281
+ continue;
21873
22282
  }
21874
- blocks.push({ type: "html_table", text: htmlLines.join("\n") });
21875
- continue;
21876
22283
  }
21877
22284
  if (line.trimStart().startsWith("|")) {
21878
22285
  const tableRows = [];
22286
+ let sepSeen = false;
21879
22287
  while (i < lines.length && lines[i].trimStart().startsWith("|")) {
21880
22288
  const row = lines[i];
21881
- const sepCells = row.trim().replace(/^\|/, "").replace(/\|$/, "").split("|");
21882
- if (sepCells.every((c) => /^\s*:?-+:?\s*$/.test(c))) {
21883
- i++;
21884
- continue;
22289
+ if (tableRows.length === 1 && !sepSeen) {
22290
+ const sepCells = row.trim().replace(/^\|/, "").replace(/\|$/, "").split("|");
22291
+ if (sepCells.every((c) => /^\s*:?-+:?\s*$/.test(c))) {
22292
+ sepSeen = true;
22293
+ i++;
22294
+ continue;
22295
+ }
21885
22296
  }
21886
- const cells = row.split("|").slice(1, -1).map((c) => c.trim());
22297
+ const cells = row.split(/(?<!\\)\|/).slice(1, -1).map((c) => c.trim().replace(/\\\|/g, "|"));
21887
22298
  if (cells.length > 0) tableRows.push(cells);
21888
22299
  i++;
21889
22300
  }
@@ -22035,7 +22446,7 @@ function assertSequentialIds(rows, label, startId) {
22035
22446
  const m = rows[i].match(/\bid="(\d+)"/);
22036
22447
  const got = m ? Number(m[1]) : NaN;
22037
22448
  if (got !== startId + i) {
22038
- throw new (0, _chunk6XAAYAWLcjs.KordocError)(
22449
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)(
22039
22450
  `\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)`
22040
22451
  );
22041
22452
  }
@@ -22119,7 +22530,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
22119
22530
  }
22120
22531
  const expectedBase = charVariantBase(richAssets, !!gongmun);
22121
22532
  if (rows.length !== expectedBase) {
22122
- throw new (0, _chunk6XAAYAWLcjs.KordocError)(
22533
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)(
22123
22534
  `\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`
22124
22535
  );
22125
22536
  }
@@ -22346,7 +22757,7 @@ function buildStyles(gongmun) {
22346
22757
  </hh:styles>`;
22347
22758
  }
22348
22759
  function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = [], listIndentVariants = [], extraFonts = []) {
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")));
22760
+ const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _263 => _263.fonts, 'access', _264 => _264.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _265 => _265.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
22350
22761
  const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
22351
22762
  const paraPropsXml = buildParaProperties(gongmun, gongmun ? listIndentVariants : []);
22352
22763
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
@@ -22475,8 +22886,8 @@ function parseChartFence(text) {
22475
22886
  const spec = chartSpec(type);
22476
22887
  let finalSeries = spec.pie ? [series[0]] : series;
22477
22888
  finalSeries = finalSeries.map((s) => ({ ...s }));
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}`)));
22889
+ const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _266 => _266.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
22890
+ const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _267 => _267[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
22480
22891
  if (!spec.scatter) {
22481
22892
  finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
22482
22893
  }
@@ -22518,7 +22929,7 @@ function serSpPr(color, stroke) {
22518
22929
  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>`;
22519
22930
  }
22520
22931
  function dPtXml(pointColors, pie) {
22521
- if (!_optionalChain([pointColors, 'optionalAccess', _226 => _226.length])) return "";
22932
+ if (!_optionalChain([pointColors, 'optionalAccess', _268 => _268.length])) return "";
22522
22933
  return pointColors.map((col, i) => {
22523
22934
  const f = chartColorFill(col);
22524
22935
  if (!f) return "";
@@ -22757,8 +23168,8 @@ function buildGaejosikCover(title, gongmun, bodyWidth = GAEJOSIK_BASE_WIDTH) {
22757
23168
  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 });
22758
23169
  const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3, 1, bodyWidth);
22759
23170
  const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
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]), () => ( ""));
23171
+ const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _269 => _269.cover, 'optionalAccess', _270 => _270.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
23172
+ const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _271 => _271.cover, 'optionalAccess', _272 => _272.org]), () => ( ""));
22762
23173
  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>`;
22763
23174
  const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
22764
23175
  return [
@@ -22832,13 +23243,26 @@ function normalize(s) {
22832
23243
  return s.replace(/\s+/g, " ").trim();
22833
23244
  }
22834
23245
  var MAX_LEVENSHTEIN_LEN = 1e4;
23246
+ function approxDistance(a, b) {
23247
+ const bigramCounts = (s) => {
23248
+ const m = /* @__PURE__ */ new Map();
23249
+ for (let i = 0; i < s.length - 1; i++) {
23250
+ const g = s.slice(i, i + 2);
23251
+ m.set(g, (_nullishCoalesce(m.get(g), () => ( 0))) + 1);
23252
+ }
23253
+ return m;
23254
+ };
23255
+ const ca = bigramCounts(a);
23256
+ const cb = bigramCounts(b);
23257
+ let inter = 0;
23258
+ for (const [g, n] of ca) inter += Math.min(n, _nullishCoalesce(cb.get(g), () => ( 0)));
23259
+ const total = Math.max(a.length - 1, 0) + Math.max(b.length - 1, 0);
23260
+ const dice = total > 0 ? 2 * inter / total : 1;
23261
+ return Math.round(Math.max(a.length, b.length) * (1 - dice));
23262
+ }
22835
23263
  function levenshtein(a, b) {
22836
23264
  if (a.length + b.length > MAX_LEVENSHTEIN_LEN) {
22837
- const sampleLen = Math.min(500, a.length, b.length);
22838
- let diffs = 0;
22839
- for (let i = 0; i < sampleLen; i++) if (a[i] !== b[i]) diffs++;
22840
- const sampleRate = sampleLen > 0 ? diffs / sampleLen : 1;
22841
- return Math.abs(a.length - b.length) + Math.round(Math.min(a.length, b.length) * sampleRate);
23265
+ return approxDistance(a, b);
22842
23266
  }
22843
23267
  if (a.length > b.length) [a, b] = [b, a];
22844
23268
  const m = a.length;
@@ -22990,11 +23414,18 @@ function bestSimInRange(arr, from, to, target) {
22990
23414
  return best;
22991
23415
  }
22992
23416
  function escapeGfm(text) {
22993
- return text.replace(/([~*])/g, "\\$1");
23417
+ const NUL = String.fromCharCode(0);
23418
+ const spans = [];
23419
+ const masked = text.replace(/!\[[^\]]*\]\([^)\n]*\)|\]\((?:https?:|mailto:|tel:|#)[^)\n]*\)/gi, (m) => {
23420
+ spans.push(m);
23421
+ return NUL + (spans.length - 1) + NUL;
23422
+ });
23423
+ const escaped = masked.replace(/([~*_`])/g, "\\$1");
23424
+ return escaped.replace(new RegExp(NUL + "(\\d+)" + NUL, "g"), (_, n) => spans[Number(n)]);
22994
23425
  }
22995
- var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
23426
+ var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
22996
23427
  function sanitizeText(text) {
22997
- let result = _chunk6XAAYAWLcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
23428
+ let result = _chunkXTCT6KQ5cjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
22998
23429
  if (result.length <= 30 && result.includes(" ")) {
22999
23430
  const tokens = result.split(" ");
23000
23431
  const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-힯ㄱ-ㆎ]/.test(t)).length;
@@ -23008,7 +23439,7 @@ function normForMatch(text) {
23008
23439
  return sanitizeText(text).replace(/\s+/g, " ").trim();
23009
23440
  }
23010
23441
  function unescapeGfm(text) {
23011
- return text.replace(/\\([~*])/g, "$1");
23442
+ return text.replace(/\\([~*_`])/g, "$1");
23012
23443
  }
23013
23444
  function summarize(text) {
23014
23445
  const t = text.replace(/\s+/g, " ").trim();
@@ -23024,7 +23455,7 @@ function replicateGfmTable(table2) {
23024
23455
  for (let r = 0; r < numRows; r++) {
23025
23456
  for (let c = 0; c < numCols; c++) {
23026
23457
  if (skip.has(`${r},${c}`)) continue;
23027
- const cell2 = _optionalChain([cells, 'access', _231 => _231[r], 'optionalAccess', _232 => _232[c]]);
23458
+ const cell2 = _optionalChain([cells, 'access', _273 => _273[r], 'optionalAccess', _274 => _274[c]]);
23028
23459
  if (!cell2) continue;
23029
23460
  display[r][c] = {
23030
23461
  text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
@@ -23075,10 +23506,10 @@ function parseGfmTable(lines) {
23075
23506
  return rows;
23076
23507
  }
23077
23508
  function unescapeGfmCell(text) {
23078
- return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
23509
+ return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*_`])/g, "$1");
23079
23510
  }
23080
23511
  function replicateCellInnerHtml(cell2) {
23081
- if (_optionalChain([cell2, 'access', _233 => _233.blocks, 'optionalAccess', _234 => _234.length])) {
23512
+ if (_optionalChain([cell2, 'access', _275 => _275.blocks, 'optionalAccess', _276 => _276.length])) {
23082
23513
  return cell2.blocks.map((b) => {
23083
23514
  if (b.type === "table" && b.table) {
23084
23515
  const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
@@ -23117,7 +23548,7 @@ function replicateHtmlTable(table2) {
23117
23548
  const rowCells = [];
23118
23549
  for (let c = 0; c < numCols; c++) {
23119
23550
  if (skip.has(`${r},${c}`)) continue;
23120
- const cell2 = _optionalChain([cells, 'access', _235 => _235[r], 'optionalAccess', _236 => _236[c]]);
23551
+ const cell2 = _optionalChain([cells, 'access', _277 => _277[r], 'optionalAccess', _278 => _278[c]]);
23121
23552
  if (!cell2) continue;
23122
23553
  for (let dr = 0; dr < cell2.rowSpan; dr++) {
23123
23554
  for (let dc = 0; dc < cell2.colSpan; dc++) {
@@ -23163,10 +23594,10 @@ function parseHtmlTable(raw) {
23163
23594
  }
23164
23595
  } else {
23165
23596
  if (!isClose) {
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);
23597
+ const cs = parseInt(_optionalChain([attrs, 'access', _279 => _279.match, 'call', _280 => _280(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _281 => _281[1]]) || "1", 10);
23598
+ const rs = parseInt(_optionalChain([attrs, 'access', _282 => _282.match, 'call', _283 => _283(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _284 => _284[1]]) || "1", 10);
23168
23599
  cellStart = m.index + m[0].length;
23169
- cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
23600
+ cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunkXTCT6KQ5cjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunkXTCT6KQ5cjs.MAX_ROWS) };
23170
23601
  } else if (cellStart >= 0 && cellInfo && currentRow) {
23171
23602
  currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
23172
23603
  cellStart = -1;
@@ -23190,7 +23621,7 @@ function htmlCellInnerToLines(inner) {
23190
23621
  hadNonText = true;
23191
23622
  work = work.replace(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi, (tag) => {
23192
23623
  const m = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(tag);
23193
- const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _243 => _243[1]]), () => ( _optionalChain([m, 'optionalAccess', _244 => _244[2]])));
23624
+ const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _285 => _285[1]]), () => ( _optionalChain([m, 'optionalAccess', _286 => _286[2]])));
23194
23625
  if (src) imgSrcs.push(src);
23195
23626
  return "";
23196
23627
  });
@@ -23321,7 +23752,7 @@ function edgeXml(tag, d) {
23321
23752
  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"/>`;
23322
23753
  }
23323
23754
  function borderFillDefToXml(id, def) {
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>` : "";
23755
+ const fill = _optionalChain([def, 'access', _287 => _287.fill, 'optionalAccess', _288 => _288.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${escapeXml(def.fill.faceColor)}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
23325
23756
  return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
23326
23757
  <hh:slash type="NONE" Crooked="0" isCounter="0"/>
23327
23758
  <hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
@@ -23726,11 +24157,11 @@ function estimateRowHeight(cells, widths, charHeight) {
23726
24157
  function generateTable(rows, theme, style = null, remap = null, seq = 0, images = null) {
23727
24158
  const rowCnt = rows.length;
23728
24159
  const colCnt = Math.max(...rows.map((r) => r.length), 1);
23729
- const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _247 => _247.bfRegistry]), () => ( null));
24160
+ const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _289 => _289.bfRegistry]), () => ( null));
23730
24161
  const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
23731
- const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _248 => _248.charHeight]), () => ( 1e3));
24162
+ const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _290 => _290.charHeight]), () => ( 1e3));
23732
24163
  const rowAnchor = normalizeRowAnchor((_nullishCoalesce(rows[0], () => ( []))).map((c) => c.replace(/!\[[^\]]*\]\([^)]*\)/g, "")));
23733
- const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _249 => _249[0], 'optionalAccess', _250 => _250[0]]), () => ( ""))), seq, rowAnchor);
24164
+ const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _291 => _291[0], 'optionalAccess', _292 => _292[0]]), () => ( ""))), seq, rowAnchor);
23734
24165
  const colMax = Array(colCnt).fill(0);
23735
24166
  const colMaxBody = Array(colCnt).fill(0);
23736
24167
  const colMinWord = Array(colCnt).fill(0);
@@ -23758,7 +24189,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
23758
24189
  const k = `${rowIdx},${colIdx}`;
23759
24190
  const isLabelCell2 = labelCol0 && colIdx === 0;
23760
24191
  const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
23761
- const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _251 => _251.cellChar, 'access', _252 => _252.get, 'call', _253 => _253(k)]), () => ( defaultCharPr));
24192
+ const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _293 => _293.cellChar, 'access', _294 => _294.get, 'call', _295 => _295(k)]), () => ( defaultCharPr));
23762
24193
  const centered = isHeaderRow || colCentered[colIdx];
23763
24194
  const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
23764
24195
  const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
@@ -23776,11 +24207,11 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
23776
24207
  }
23777
24208
  }
23778
24209
  }
23779
- const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _254 => _254.cellChar, 'access', _255 => _255.has, 'call', _256 => _256(k)]) ? void 0 : mapId);
24210
+ const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _296 => _296.cellChar, 'access', _297 => _297.has, 'call', _298 => _298(k)]) ? void 0 : mapId);
23780
24211
  const body = (runs || (picRuns ? "" : `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`)) + picRuns;
23781
24212
  return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${body}</hp:p>`;
23782
24213
  }).join("");
23783
- const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _257 => _257.cellBf, 'access', _258 => _258.get, 'call', _259 => _259(k)]), () => ( (reg ? reg.get(dataCellSpec({
24214
+ const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _299 => _299.cellBf, 'access', _300 => _300.get, 'call', _301 => _301(k)]), () => ( (reg ? reg.get(dataCellSpec({
23784
24215
  row: rowIdx,
23785
24216
  rowEnd: rowIdx,
23786
24217
  col: colIdx,
@@ -23790,7 +24221,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
23790
24221
  headerRows: 1,
23791
24222
  fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
23792
24223
  })) : style && isHeaderRow ? style.headerBf : 2)));
23793
- const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _260 => _260.cellH, 'access', _261 => _261.get, 'call', _262 => _262(k)]), () => ( cellH));
24224
+ const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _302 => _302.cellH, 'access', _303 => _303.get, 'call', _304 => _304(k)]), () => ( cellH));
23794
24225
  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>`;
23795
24226
  }).join("");
23796
24227
  return `<hp:tr>${tdElements}</hp:tr>`;
@@ -23799,7 +24230,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
23799
24230
  const tblH = rowHeights.reduce((a, b) => a + b, 0);
23800
24231
  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;
23801
24232
  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>`;
23802
- const hostPr = reg && _optionalChain([style, 'optionalAccess', _263 => _263.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
24233
+ const hostPr = reg && _optionalChain([style, 'optionalAccess', _305 => _305.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
23803
24234
  return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
23804
24235
  }
23805
24236
  function layoutHtmlRows(rows) {
@@ -23810,8 +24241,8 @@ function layoutHtmlRows(rows) {
23810
24241
  let c = 0;
23811
24242
  for (const cell2 of rows[r].cells) {
23812
24243
  while (occupied.has(`${r},${c}`)) c++;
23813
- const colSpan = Math.max(1, cell2.colSpan);
23814
- const rowSpan = Math.max(1, cell2.rowSpan);
24244
+ const colSpan = clampSpan(cell2.colSpan, _chunkXTCT6KQ5cjs.MAX_COLS);
24245
+ const rowSpan = clampSpan(cell2.rowSpan, _chunkXTCT6KQ5cjs.MAX_ROWS);
23815
24246
  placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
23816
24247
  for (let dr = 0; dr < rowSpan; dr++) {
23817
24248
  for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
@@ -23839,7 +24270,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23839
24270
  if (!rows || rows.length === 0) return null;
23840
24271
  const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
23841
24272
  if (rowCnt === 0 || colCnt === 0) return null;
23842
- const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _264 => _264.charHeight]), () => ( 1e3));
24273
+ const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _306 => _306.charHeight]), () => ( 1e3));
23843
24274
  const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
23844
24275
  const row0 = Array.from({ length: colCnt }, () => "");
23845
24276
  for (const cell2 of placed) {
@@ -23868,7 +24299,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23868
24299
  const tblId = nextTableId();
23869
24300
  const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
23870
24301
  const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
23871
- const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _265 => _265.bfRegistry]), () => ( null));
24302
+ const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _307 => _307.bfRegistry]), () => ( null));
23872
24303
  let htmlHeaderRows = 0;
23873
24304
  while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
23874
24305
  const tableRowHeights = Array(rowCnt).fill(cellH);
@@ -23883,7 +24314,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23883
24314
  const nestedXml = generateHtmlTableXml(nested, theme, nestedW, style ? { ...style, totalWidth: nestedW } : null);
23884
24315
  if (nestedXml) {
23885
24316
  nestedXmls.push(nestedXml);
23886
- const szH = _optionalChain([nestedXml, 'access', _266 => _266.match, 'call', _267 => _267(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _268 => _268[1]]);
24317
+ const szH = _optionalChain([nestedXml, 'access', _308 => _308.match, 'call', _309 => _309(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _310 => _310[1]]);
23887
24318
  nestedH += (szH ? Number(szH) : (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH) + 300;
23888
24319
  }
23889
24320
  }
@@ -23892,7 +24323,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23892
24323
  for (const line of lines) wrapLines += Math.max(1, Math.ceil(measureTextWidth(unescapeHtml(line).trim(), measureH, 100) / usable));
23893
24324
  const lineH = style ? Math.round(measureH * 1.6) : 800;
23894
24325
  const contentH = Math.max(cellH * rowSpan, Math.max(wrapLines, 1) * lineH + nestedH);
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);
24326
+ const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _311 => _311.cellH, 'access', _312 => _312.get, 'call', _313 => _313(`${cell2.r},${cell2.c}`)]), () => ( 0)), contentH);
23896
24327
  const perRow = Math.ceil(cellHeight / rowSpan);
23897
24328
  for (let r = cell2.r; r < cell2.r + rowSpan; r++) tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
23898
24329
  return { cell: cell2, rowSpan, lines, nestedXmls, imgSrcs: cellParsed[i].imgSrcs };
@@ -23903,7 +24334,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23903
24334
  const baseCharPr = style ? style.charPr : CHAR_NORMAL;
23904
24335
  const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
23905
24336
  const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
23906
- const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _272 => _272.cellChar, 'access', _273 => _273.get, 'call', _274 => _274(k)]), () => ( defaultCharPr));
24337
+ const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _314 => _314.cellChar, 'access', _315 => _315.get, 'call', _316 => _316(k)]), () => ( defaultCharPr));
23907
24338
  const centered = isHeader || colCentered[cell2.c];
23908
24339
  const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
23909
24340
  const picUrls = images ? [...imgSrcs] : [];
@@ -23939,7 +24370,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
23939
24370
  let cellHeight = 0;
23940
24371
  for (let r = cell2.r; r < cell2.r + rowSpan; r++) cellHeight += tableRowHeights[r];
23941
24372
  const rowEnd = cell2.r + rowSpan - 1;
23942
- const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _275 => _275.cellBf, 'access', _276 => _276.get, 'call', _277 => _277(k)]), () => ( (reg ? reg.get(dataCellSpec({
24373
+ const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _317 => _317.cellBf, 'access', _318 => _318.get, 'call', _319 => _319(k)]), () => ( (reg ? reg.get(dataCellSpec({
23943
24374
  row: cell2.r,
23944
24375
  rowEnd,
23945
24376
  col: cell2.c,
@@ -24109,7 +24540,7 @@ function buildPressHead(g, ids, bodyWidth, reg) {
24109
24540
  return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
24110
24541
  }
24111
24542
  function buildPressContact(g, ids, bodyWidth, reg) {
24112
- const c = _optionalChain([g, 'access', _278 => _278.press, 'optionalAccess', _279 => _279.contact]);
24543
+ const c = _optionalChain([g, 'access', _320 => _320.press, 'optionalAccess', _321 => _321.contact]);
24113
24544
  if (!c || !c.dept && !c.manager && !c.phone) return [];
24114
24545
  const w = bodyWidth - 280;
24115
24546
  const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
@@ -24490,7 +24921,7 @@ function generateSecPr(gongmun) {
24490
24921
  }
24491
24922
  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>`;
24492
24923
  const colPr = `<hp:ctrl><hp:colPr id="" type="NEWSPAPER" layout="LEFT" colCount="1" sameSz="1" sameGap="0"/></hp:ctrl>`;
24493
- return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _280 => _280.pageNumbers]) ? pageNumCtrl() : "");
24924
+ return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _322 => _322.pageNumbers]) ? pageNumCtrl() : "");
24494
24925
  }
24495
24926
  var SectionOpener = (_class6 = class {
24496
24927
  constructor(gongmun) {;_class6.prototype.__init12.call(this);
@@ -24529,19 +24960,19 @@ function buildPreamble(blocks, ctx) {
24529
24960
  const { gongmun, dfIds, bfReg, tableStyle, richAssets, gjBodyW } = ctx;
24530
24961
  const preamble = [];
24531
24962
  let hasFrontPages = false;
24532
- if (_optionalChain([gongmun, 'optionalAccess', _281 => _281.reportInfo]) && dfIds) {
24963
+ if (_optionalChain([gongmun, 'optionalAccess', _323 => _323.reportInfo]) && dfIds) {
24533
24964
  preamble.push(buildReportInfo(gongmun, dfIds));
24534
24965
  }
24535
- if (_optionalChain([gongmun, 'optionalAccess', _282 => _282.approval]) && bfReg) {
24966
+ if (_optionalChain([gongmun, 'optionalAccess', _324 => _324.approval]) && bfReg) {
24536
24967
  preamble.push(buildApprovalTable(gongmun.approval, bfReg, richAssets ? GJ_CHAR_APPROVAL : GONGMUN_APPROVAL_CHAR));
24537
24968
  }
24538
- if (_optionalChain([gongmun, 'optionalAccess', _283 => _283.docHead]) && dfIds) {
24969
+ if (_optionalChain([gongmun, 'optionalAccess', _325 => _325.docHead]) && dfIds) {
24539
24970
  preamble.push(...buildDocHead(gongmun, dfIds));
24540
24971
  }
24541
- if (_optionalChain([gongmun, 'optionalAccess', _284 => _284.noticeHead]) && dfIds) {
24972
+ if (_optionalChain([gongmun, 'optionalAccess', _326 => _326.noticeHead]) && dfIds) {
24542
24973
  preamble.push(...buildNoticeHead(gongmun));
24543
24974
  }
24544
- if (_optionalChain([gongmun, 'optionalAccess', _285 => _285.press]) && dfIds && bfReg && tableStyle) {
24975
+ if (_optionalChain([gongmun, 'optionalAccess', _327 => _327.press]) && dfIds && bfReg && tableStyle) {
24545
24976
  preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
24546
24977
  }
24547
24978
  if (gongmun && (gongmun.cover || gongmun.toc)) {
@@ -24570,7 +25001,7 @@ function buildPreamble(blocks, ctx) {
24570
25001
  }
24571
25002
  if (gongmun && !ctx.gaejosik && ctx.coverH1Idx < 0 && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
24572
25003
  ctx.titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
24573
- } else if (_optionalChain([gongmun, 'optionalAccess', _286 => _286.press]) && ctx.coverH1Idx < 0 && dfIds) {
25004
+ } else if (_optionalChain([gongmun, 'optionalAccess', _328 => _328.press]) && ctx.coverH1Idx < 0 && dfIds) {
24574
25005
  ctx.pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
24575
25006
  }
24576
25007
  if (preamble.length > 0) {
@@ -24585,7 +25016,7 @@ function renderHeading(block, blockIdx, ctx) {
24585
25016
  if (gongmun && blockIdx === ctx.coverH1Idx) return "";
24586
25017
  if (gongmun && blockIdx === ctx.pressH1Idx && dfIds) {
24587
25018
  const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
24588
- for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _287 => _287.press, 'optionalAccess', _288 => _288.sub]), () => ( []))) {
25019
+ for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _329 => _329.press, 'optionalAccess', _330 => _330.sub]), () => ( []))) {
24589
25020
  parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
24590
25021
  }
24591
25022
  return parts.join("\n ");
@@ -24679,8 +25110,8 @@ function renderListItem(block, blockIdx, ctx) {
24679
25110
  const { gongmun, gongmunList, measured, fit, vBase, dfIds } = ctx;
24680
25111
  if (gongmun && gongmunList) {
24681
25112
  const info = gongmunList.items.get(blockIdx);
24682
- const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _289 => _289.depth]), () => ( 0));
24683
- const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _290 => _290.marker]), () => ( ""));
25113
+ const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _331 => _331.depth]), () => ( 0));
25114
+ const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _332 => _332.marker]), () => ( ""));
24684
25115
  const content = block.text || "";
24685
25116
  if (measured && content.trimStart().startsWith("\u203B")) {
24686
25117
  return generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
@@ -24689,7 +25120,7 @@ function renderListItem(block, blockIdx, ctx) {
24689
25120
  return generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
24690
25121
  }
24691
25122
  const text = marker2 ? `${marker2} ${content}` : content;
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;
25123
+ const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess', _333 => _333.indentVariant]) !== void 0 ? GONGMUN_LIST_VARIANT_BASE + info.indentVariant : GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
24693
25124
  let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
24694
25125
  let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
24695
25126
  if (measured && depth === 0 && gongmun.numbering !== "standard") {
@@ -24748,18 +25179,18 @@ function renderHtmlTable(block, ctx) {
24748
25179
  }
24749
25180
  function appendPostamble(blocks, ctx) {
24750
25181
  const { gongmun, dfIds, bfReg, tableStyle, paraXmls } = ctx;
24751
- if (_optionalChain([gongmun, 'optionalAccess', _292 => _292.noticeHead]) && dfIds) {
25182
+ if (_optionalChain([gongmun, 'optionalAccess', _334 => _334.noticeHead]) && dfIds) {
24752
25183
  paraXmls.push(...buildNoticeFoot(gongmun));
24753
25184
  }
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]));
25185
+ if (_optionalChain([gongmun, 'optionalAccess', _335 => _335.endMark]) && paraXmls.length > 0) {
25186
+ const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access', _336 => _336.rows, 'optionalAccess', _337 => _337.length]));
24756
25187
  const lastText = lastBlock && (lastBlock.type === "paragraph" || lastBlock.type === "list_item") ? lastBlock.text || "" : "";
24757
25188
  if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
24758
25189
  }
24759
- if (_optionalChain([gongmun, 'optionalAccess', _296 => _296.docFoot]) && dfIds) {
25190
+ if (_optionalChain([gongmun, 'optionalAccess', _338 => _338.docFoot]) && dfIds) {
24760
25191
  paraXmls.push(...buildDocFoot(gongmun, dfIds));
24761
25192
  }
24762
- if (_optionalChain([gongmun, 'optionalAccess', _297 => _297.press]) && dfIds && bfReg && tableStyle) {
25193
+ if (_optionalChain([gongmun, 'optionalAccess', _339 => _339.press]) && dfIds && bfReg && tableStyle) {
24763
25194
  paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
24764
25195
  }
24765
25196
  }
@@ -24779,7 +25210,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
24779
25210
  remap,
24780
25211
  dfIds,
24781
25212
  images,
24782
- gaejosik: _optionalChain([gongmun, 'optionalAccess', _298 => _298.preset]) === "gaejosik",
25213
+ gaejosik: _optionalChain([gongmun, 'optionalAccess', _340 => _340.preset]) === "gaejosik",
24783
25214
  measured,
24784
25215
  richAssets,
24785
25216
  vBase: charVariantBase(richAssets, !!gongmun),
@@ -24885,18 +25316,18 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
24885
25316
 
24886
25317
  // src/hwpx/generator.ts
24887
25318
  async function markdownToHwpx(markdown, options) {
24888
- const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _299 => _299.theme]));
24889
- const gongmun = _optionalChain([options, 'optionalAccess', _300 => _300.gongmun]) ? resolveGongmun(options.gongmun) : null;
25319
+ const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _341 => _341.theme]));
25320
+ const gongmun = _optionalChain([options, 'optionalAccess', _342 => _342.gongmun]) ? resolveGongmun(options.gongmun) : null;
24890
25321
  const measured = !!gongmun && usesReportFonts(gongmun.preset);
24891
25322
  const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
24892
25323
  const blocks = parseMarkdownToBlocks(markdown);
24893
25324
  const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
24894
25325
  const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
24895
25326
  const staticBfEnd = staticBorderFillNext(gongmun);
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;
25327
+ const remap = _optionalChain([options, 'optionalAccess', _343 => _343.profile]) ? buildProfileRemap(options.profile, charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _344 => _344.variants, 'optionalAccess', _345 => _345.length]), () => ( 0))) * 4, staticBfEnd, staticFontNext(gongmun)) : null;
25328
+ const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _346 => _346.borderFillXmls, 'access', _347 => _347.length]), () => ( 0)))) : null;
24898
25329
  const dfActive = !!gongmun && docframeActive(gongmun);
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)));
25330
+ const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _348 => _348.variants, 'optionalAccess', _349 => _349.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _350 => _350.charPrXmls, 'access', _351 => _351.length]), () => ( 0)));
24900
25331
  const dfIds = dfActive ? docframeIds(dfBase) : null;
24901
25332
  const chartParts = [];
24902
25333
  const images = new ImageRegistry();
@@ -24907,7 +25338,7 @@ async function markdownToHwpx(markdown, options) {
24907
25338
  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)`);
24908
25339
  }
24909
25340
  }
24910
- const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _310 => _310.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _311 => _311.emit, 'call', _312 => _312()]), () => ( []))];
25341
+ const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _352 => _352.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _353 => _353.emit, 'call', _354 => _354()]), () => ( []))];
24911
25342
  const zip = new (0, _jszip2.default)();
24912
25343
  zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
24913
25344
  zip.file("META-INF/container.xml", generateContainerXml());
@@ -24916,11 +25347,11 @@ async function markdownToHwpx(markdown, options) {
24916
25347
  zip.file("Contents/header.xml", generateHeaderXml(
24917
25348
  theme,
24918
25349
  gongmun,
24919
- _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _313 => _313.variants]), () => ( [])),
25350
+ _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _355 => _355.variants]), () => ( [])),
24920
25351
  extraBorderFills,
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]), () => ( []))
25352
+ [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _356 => _356.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, richAssets) : []],
25353
+ _nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess', _357 => _357.indentVariants]), () => ( [])),
25354
+ _nullishCoalesce(_optionalChain([remap, 'optionalAccess', _358 => _358.fontFaces]), () => ( []))
24924
25355
  ));
24925
25356
  zip.file("Contents/section0.xml", sectionXml);
24926
25357
  for (const part of chartParts) zip.file(part.name, part.xml);
@@ -24970,12 +25401,20 @@ function diffBlocks(blocksA, blocksB) {
24970
25401
  function alignBlocks(a, b) {
24971
25402
  const m = a.length, n = b.length;
24972
25403
  if (m * n > 1e7) return fallbackAlign(a, b);
25404
+ const lenOf = (blk) => {
25405
+ const t = blk.text !== void 0 ? blk.text : blk.type === "table" && blk.table ? blk.table.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _359 => _359.text]), () => ( ""))).join(" ") : "";
25406
+ return t.replace(/\s+/g, " ").trim().length;
25407
+ };
25408
+ const aLen = a.map(lenOf);
25409
+ const bLen = b.map(lenOf);
24973
25410
  const simCache = /* @__PURE__ */ new Map();
24974
25411
  const getSim = (i2, j2) => {
24975
25412
  const key = `${i2},${j2}`;
24976
25413
  let v = simCache.get(key);
24977
25414
  if (v === void 0) {
24978
- v = blockSimilarity(a[i2], b[j2]);
25415
+ const mx = Math.max(aLen[i2], bLen[j2]);
25416
+ const cut = a[i2].type === "table" || b[j2].type === "table" ? 6 / 7 : 1 - SIMILARITY_THRESHOLD;
25417
+ v = mx > 0 && (mx - Math.min(aLen[i2], bLen[j2])) / mx > cut ? 0 : blockSimilarity(a[i2], b[j2]);
24979
25418
  simCache.set(key, v);
24980
25419
  }
24981
25420
  return v;
@@ -25036,8 +25475,8 @@ function blockSimilarity(a, b) {
25036
25475
  }
25037
25476
  function tableSimilarity(a, b) {
25038
25477
  const dimSim = 1 - Math.abs(a.rows * a.cols - b.rows * b.cols) / Math.max(a.rows * a.cols, b.rows * b.cols, 1);
25039
- const textsA = a.cells.flat().map((c) => c.text).join(" ");
25040
- const textsB = b.cells.flat().map((c) => c.text).join(" ");
25478
+ const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _360 => _360.text]), () => ( ""))).join(" ");
25479
+ const textsB = b.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _361 => _361.text]), () => ( ""))).join(" ");
25041
25480
  const contentSim = normalizedSimilarity(textsA, textsB);
25042
25481
  return dimSim * 0.3 + contentSim * 0.7;
25043
25482
  }
@@ -25048,8 +25487,8 @@ function diffTableCells(a, b) {
25048
25487
  for (let r = 0; r < maxRows; r++) {
25049
25488
  const row = [];
25050
25489
  for (let c = 0; c < maxCols; c++) {
25051
- const cellA = r < a.rows && c < a.cols ? a.cells[r][c].text : void 0;
25052
- const cellB = r < b.rows && c < b.cols ? b.cells[r][c].text : void 0;
25490
+ const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access', _362 => _362.cells, 'access', _363 => _363[r], 'optionalAccess', _364 => _364[c], 'optionalAccess', _365 => _365.text]) : void 0;
25491
+ const cellB = r < b.rows && c < b.cols ? _optionalChain([b, 'access', _366 => _366.cells, 'access', _367 => _367[r], 'optionalAccess', _368 => _368[c], 'optionalAccess', _369 => _369.text]) : void 0;
25053
25492
  let type;
25054
25493
  if (cellA === void 0) type = "added";
25055
25494
  else if (cellB === void 0) type = "removed";
@@ -25215,7 +25654,7 @@ function parseRenderStyles(headXml) {
25215
25654
  const underlineEl = findChildByLocalName(el, "underline");
25216
25655
  const textColor = el.getAttribute("textColor");
25217
25656
  const fontRef = findChildByLocalName(el, "fontRef");
25218
- const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _317 => _317.getAttribute, 'call', _318 => _318("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _319 => _319.getAttribute, 'call', _320 => _320("latin")])));
25657
+ const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _370 => _370.getAttribute, 'call', _371 => _371("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _372 => _372.getAttribute, 'call', _373 => _373("latin")])));
25219
25658
  const face = fontId != null ? hangulFonts.get(fontId) : void 0;
25220
25659
  styles.charPr.set(id, {
25221
25660
  height: Number(el.getAttribute("height")) || 1e3,
@@ -25223,8 +25662,8 @@ function parseRenderStyles(headXml) {
25223
25662
  italic: findChildByLocalName(el, "italic") != null,
25224
25663
  underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
25225
25664
  color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 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,
25665
+ ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _374 => _374.getAttribute, 'call', _375 => _375("hangul")])) || 100,
25666
+ spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _376 => _376.getAttribute, 'call', _377 => _377("hangul")])) || 0,
25228
25667
  fontFamily: face ? hwpFaceToCssStack(face) : void 0,
25229
25668
  face
25230
25669
  });
@@ -25233,7 +25672,7 @@ function parseRenderStyles(headXml) {
25233
25672
  const id = el.getAttribute("id");
25234
25673
  if (id != null) {
25235
25674
  const align = findChildByLocalName(el, "align");
25236
- styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _325 => _325.getAttribute, 'call', _326 => _326("horizontal")]) || "JUSTIFY");
25675
+ styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _378 => _378.getAttribute, 'call', _379 => _379("horizontal")]) || "JUSTIFY");
25237
25676
  styles.paraGeom.set(id, parseParaGeom(el));
25238
25677
  }
25239
25678
  } else if (tag === "borderFill") {
@@ -25247,7 +25686,7 @@ function parseRenderStyles(headXml) {
25247
25686
  };
25248
25687
  const fillBrush = findChildByLocalName(el, "fillBrush");
25249
25688
  const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
25250
- const face = _optionalChain([winBrush, 'optionalAccess', _327 => _327.getAttribute, 'call', _328 => _328("faceColor")]);
25689
+ const face = _optionalChain([winBrush, 'optionalAccess', _380 => _380.getAttribute, 'call', _381 => _381("faceColor")]);
25251
25690
  if (face && face.toLowerCase() !== "none") bf.fill = face;
25252
25691
  styles.borderFill.set(id, bf);
25253
25692
  }
@@ -25319,7 +25758,7 @@ function collectSites(scan) {
25319
25758
  }
25320
25759
  function attrOf(openTag, name) {
25321
25760
  const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
25322
- return _optionalChain([m, 'optionalAccess', _329 => _329[1]]);
25761
+ return _optionalChain([m, 'optionalAccess', _382 => _382[1]]);
25323
25762
  }
25324
25763
  function paraOpenTag(xml, para2) {
25325
25764
  const end = xml.indexOf(">", para2.start);
@@ -25334,7 +25773,7 @@ function anchorRunInfo(xml, para2, anchor) {
25334
25773
  if (!tr) return null;
25335
25774
  const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
25336
25775
  const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
25337
- const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _330 => _330[1]]), () => ( tr.prefix)), () => ( "hp"));
25776
+ const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _383 => _383[1]]), () => ( tr.prefix)), () => ( "hp"));
25338
25777
  const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
25339
25778
  const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
25340
25779
  if (close === -1) return null;
@@ -25361,7 +25800,7 @@ function cellContentWidthMm(xml, cell2) {
25361
25800
  if (width === null) return null;
25362
25801
  let content = width;
25363
25802
  const win = cellAddrWindow(xml, cell2);
25364
- const mg = _optionalChain([win, 'optionalAccess', _331 => _331.match, 'call', _332 => _332(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
25803
+ const mg = _optionalChain([win, 'optionalAccess', _384 => _384.match, 'call', _385 => _385(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
25365
25804
  if (mg) {
25366
25805
  content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
25367
25806
  }
@@ -25395,11 +25834,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
25395
25834
  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>`;
25396
25835
  }
25397
25836
  async function placeSealHwpx(hwpxBuffer, ops) {
25398
- if (ops.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
25837
+ if (ops.length === 0) throw new (0, _chunkF2HYH62Hcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
25399
25838
  const u8 = new Uint8Array(hwpxBuffer);
25400
25839
  const zip = await _jszip2.default.loadAsync(hwpxBuffer);
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");
25840
+ const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _386 => _386.match, 'call', _387 => _387(/(\d+)\.xml$/i), 'optionalAccess', _388 => _388[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _389 => _389.match, 'call', _390 => _390(/(\d+)\.xml$/i), 'optionalAccess', _391 => _391[1]]), () => ( 0))));
25841
+ if (sectionPaths.length === 0) throw new (0, _chunkF2HYH62Hcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
25403
25842
  const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
25404
25843
  const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
25405
25844
  const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
@@ -25440,11 +25879,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
25440
25879
  const manifestItems = [];
25441
25880
  const placed = [];
25442
25881
  for (const op of ops) {
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");
25882
+ if (!op.anchor) throw new (0, _chunkF2HYH62Hcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
25883
+ if (!op.image || op.image.length === 0) throw new (0, _chunkF2HYH62Hcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
25445
25884
  const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
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)`);
25885
+ if (!MIME[ext]) throw new (0, _chunkF2HYH62Hcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
25886
+ if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkF2HYH62Hcjs.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)`);
25448
25887
  const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
25449
25888
  let found = null;
25450
25889
  let total = 0;
@@ -25477,7 +25916,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
25477
25916
  }
25478
25917
  }
25479
25918
  }
25480
- throw new (0, _chunk6XAAYAWLcjs.KordocError)(
25919
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)(
25481
25920
  `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)})`
25482
25921
  );
25483
25922
  }
@@ -25485,9 +25924,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
25485
25924
  const xml = sectionXmls[si];
25486
25925
  const run = anchorRunInfo(xml, site.para, op.anchor);
25487
25926
  if (!run) {
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`);
25927
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
25489
25928
  }
25490
- const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _339 => _339.charPr, 'access', _340 => _340.get, 'call', _341 => _341(run.charPr), 'optionalAccess', _342 => _342.height]), () => ( 1e3));
25929
+ const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _392 => _392.charPr, 'access', _393 => _393.get, 'call', _394 => _394(run.charPr), 'optionalAccess', _395 => _395.height]), () => ( 1e3));
25491
25930
  const fontPt = charPrHeight / 100;
25492
25931
  const emMm = fontPt * 25.4 / 72;
25493
25932
  const lineHMm = emMm;
@@ -25496,7 +25935,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
25496
25935
  const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
25497
25936
  const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
25498
25937
  const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
25499
- const align = _optionalChain([styles, 'optionalAccess', _343 => _343.paraAlign, 'access', _344 => _344.get, 'call', _345 => _345(paraPrId)]);
25938
+ const align = _optionalChain([styles, 'optionalAccess', _396 => _396.paraAlign, 'access', _397 => _397.get, 'call', _398 => _398(paraPrId)]);
25500
25939
  let alignShiftMm = 0;
25501
25940
  if (align === "CENTER" || align === "RIGHT") {
25502
25941
  const paraWMm = measureMm(site.para.text, emMm);
@@ -25592,7 +26031,7 @@ function parseBorderFills(headerDoc) {
25592
26031
  };
25593
26032
  const fillBrush = findChildByLocalName(bf, "fillBrush");
25594
26033
  const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
25595
- const face = _optionalChain([winBrush, 'optionalAccess', _346 => _346.getAttribute, 'call', _347 => _347("faceColor")]);
26034
+ const face = _optionalChain([winBrush, 'optionalAccess', _399 => _399.getAttribute, 'call', _400 => _400("faceColor")]);
25596
26035
  if (face && face !== "none") def.fill = { faceColor: face };
25597
26036
  map.set(id, def);
25598
26037
  }
@@ -25624,7 +26063,7 @@ function parseCharPrs(headerDoc, hangulFonts) {
25624
26063
  if (cp.getAttribute("italic") === "1") def.italic = true;
25625
26064
  if (findChildByLocalName(cp, "underline")) def.underline = true;
25626
26065
  const fontRef = findChildByLocalName(cp, "fontRef");
25627
- const hangul = _optionalChain([fontRef, 'optionalAccess', _348 => _348.getAttribute, 'call', _349 => _349("hangul")]);
26066
+ const hangul = _optionalChain([fontRef, 'optionalAccess', _401 => _401.getAttribute, 'call', _402 => _402("hangul")]);
25628
26067
  if (hangul) {
25629
26068
  def.fontRef_hangul = hangul;
25630
26069
  const face = hangulFonts.get(hangul);
@@ -25652,7 +26091,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
25652
26091
  const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
25653
26092
  const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
25654
26093
  const sz = findChildByLocalName(tbl2, "sz");
25655
- const width = _optionalChain([sz, 'optionalAccess', _350 => _350.getAttribute, 'call', _351 => _351("width")]) || void 0;
26094
+ const width = _optionalChain([sz, 'optionalAccess', _403 => _403.getAttribute, 'call', _404 => _404("width")]) || void 0;
25656
26095
  const cells = [];
25657
26096
  const usedBf = /* @__PURE__ */ new Set();
25658
26097
  const usedCp = /* @__PURE__ */ new Set();
@@ -25665,17 +26104,17 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
25665
26104
  const addr = findChildByLocalName(tc2, "cellAddr");
25666
26105
  const span = findChildByLocalName(tc2, "cellSpan");
25667
26106
  const csz = findChildByLocalName(tc2, "cellSz");
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));
26107
+ const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _405 => _405.getAttribute, 'call', _406 => _406("rowAddr")])), () => ( 0));
26108
+ const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _407 => _407.getAttribute, 'call', _408 => _408("colAddr")])), () => ( 0));
25670
26109
  if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
25671
26110
  if (row === 0) row0Texts.set(col, directCellText(tc2));
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));
26111
+ const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _409 => _409.getAttribute, 'call', _410 => _410("colSpan")])), () => ( 1));
26112
+ const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _411 => _411.getAttribute, 'call', _412 => _412("rowSpan")])), () => ( 1));
25674
26113
  const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
25675
26114
  const cpId = firstRunCharPr(tc2);
25676
26115
  const cell2 = { row, col, rowSpan, colSpan };
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")]);
26116
+ const w = _optionalChain([csz, 'optionalAccess', _413 => _413.getAttribute, 'call', _414 => _414("width")]);
26117
+ const hh = _optionalChain([csz, 'optionalAccess', _415 => _415.getAttribute, 'call', _416 => _416("height")]);
25679
26118
  if (w) cell2.width_hwpunit = w;
25680
26119
  if (hh) cell2.height_hwpunit = hh;
25681
26120
  if (bfId) {
@@ -25763,16 +26202,16 @@ function pick(map, keys) {
25763
26202
  return out;
25764
26203
  }
25765
26204
  async function hwpxToProfile(input) {
25766
- const buf = input instanceof ArrayBuffer ? input : _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, input);
26205
+ const buf = input instanceof ArrayBuffer ? input : _chunkF2HYH62Hcjs.toArrayBuffer.call(void 0, input);
25767
26206
  const zip = await _jszip2.default.loadAsync(buf);
25768
26207
  const parser = createXmlParser();
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]])));
26208
+ const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _417 => _417.file, 'call', _418 => _418(/[Hh]eader\.xml$/), 'optionalAccess', _419 => _419[0]])));
25770
26209
  let headerXml = "<root/>";
25771
26210
  if (headerFile) headerXml = await headerFile.async("text");
25772
26211
  const headerDoc = parser.parseFromString(headerXml, "text/xml");
25773
26212
  const borderFills = parseBorderFills(headerDoc);
25774
26213
  const charPrs = parseCharPrs(headerDoc, parseHangulFonts(headerDoc));
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))));
26214
+ const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _420 => _420.name, 'access', _421 => _421.match, 'call', _422 => _422(/(\d+)\.xml$/), 'optionalAccess', _423 => _423[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _424 => _424.name, 'access', _425 => _425.match, 'call', _426 => _426(/(\d+)\.xml$/), 'optionalAccess', _427 => _427[1]]), () => ( null))), () => ( 0))));
25776
26215
  const tables = [];
25777
26216
  let tableIndex = 0;
25778
26217
  for (const f of sectionFiles) {
@@ -26086,7 +26525,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
26086
26525
  var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
26087
26526
  function patchTableRows(input) {
26088
26527
  const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
26089
- const xml = _optionalChain([ctx, 'access', _375 => _375.scans, 'access', _376 => _376[scanTable.sectionIndex], 'optionalAccess', _377 => _377.xml]);
26528
+ const xml = _optionalChain([ctx, 'access', _428 => _428.scans, 'access', _429 => _429[scanTable.sectionIndex], 'optionalAccess', _430 => _430.xml]);
26090
26529
  if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
26091
26530
  const numRows = table2.rows;
26092
26531
  if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
@@ -26253,7 +26692,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
26253
26692
  const rr = scanTable.rowRanges[template];
26254
26693
  const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
26255
26694
  const scan = scanSectionXml(wrapped, 0);
26256
- const row = _optionalChain([scan, 'access', _378 => _378.tables, 'access', _379 => _379[0], 'optionalAccess', _380 => _380.rows, 'access', _381 => _381[0]]);
26695
+ const row = _optionalChain([scan, 'access', _431 => _431.tables, 'access', _432 => _432[0], 'optionalAccess', _433 => _433.rows, 'access', _434 => _434[0]]);
26257
26696
  if (!row || row.length !== cells.length) return null;
26258
26697
  const splices = allLinesegRemovalSplices(wrapped);
26259
26698
  for (let i = 0; i < cells.length; i++) {
@@ -26296,7 +26735,7 @@ function rowHeightOf(fragment) {
26296
26735
  }
26297
26736
  function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
26298
26737
  const from = scanTable.start + tblOpenLen;
26299
- const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _382 => _382.rowRanges, 'access', _383 => _383[0], 'optionalAccess', _384 => _384.start]), () => ( from));
26738
+ const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _435 => _435.rowRanges, 'access', _436 => _436[0], 'optionalAccess', _437 => _437.start]), () => ( from));
26300
26739
  const slice = xml.slice(from, to);
26301
26740
  const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
26302
26741
  if (!szM || szM.index === void 0) return null;
@@ -26485,9 +26924,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
26485
26924
  });
26486
26925
  }
26487
26926
  function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
26488
- const irCell = _optionalChain([table2, 'access', _385 => _385.cells, 'access', _386 => _386[oc.gridR], 'optionalAccess', _387 => _387[oc.gridC]]);
26927
+ const irCell = _optionalChain([table2, 'access', _438 => _438.cells, 'access', _439 => _439[oc.gridR], 'optionalAccess', _440 => _440[oc.gridC]]);
26489
26928
  const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
26490
- const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _388 => _388.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
26929
+ const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _441 => _441.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
26491
26930
  if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
26492
26931
  return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
26493
26932
  }
@@ -26555,7 +26994,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
26555
26994
  };
26556
26995
  const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
26557
26996
  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)");
26558
- const irCell = _optionalChain([table2, 'access', _389 => _389.cells, 'access', _390 => _390[gridR], 'optionalAccess', _391 => _391[gridC]]);
26997
+ const irCell = _optionalChain([table2, 'access', _442 => _442.cells, 'access', _443 => _443[gridR], 'optionalAccess', _444 => _444[gridC]]);
26559
26998
  const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
26560
26999
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
26561
27000
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -26578,7 +27017,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
26578
27017
  if (newLines.length === 0) return 0;
26579
27018
  const target = cell2.paragraphs[0];
26580
27019
  if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
26581
- const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _392 => _392.scans, 'access', _393 => _393[target.sectionIndex], 'optionalAccess', _394 => _394.xml]));
27020
+ const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _445 => _445.scans, 'access', _446 => _446[target.sectionIndex], 'optionalAccess', _447 => _447.xml]));
26582
27021
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
26583
27022
  splices.push(...sp);
26584
27023
  sectionIndex = target.sectionIndex;
@@ -26601,7 +27040,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
26601
27040
  }
26602
27041
  for (let i = 0; i < nonEmpty.length; i++) {
26603
27042
  if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
26604
- const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _395 => _395.scans, 'access', _396 => _396[nonEmpty[i].sectionIndex], 'optionalAccess', _397 => _397.xml]));
27043
+ const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _448 => _448.scans, 'access', _449 => _449[nonEmpty[i].sectionIndex], 'optionalAccess', _450 => _450.xml]));
26605
27044
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
26606
27045
  splices.push(...sp);
26607
27046
  sectionIndex = nonEmpty[i].sectionIndex;
@@ -26682,7 +27121,7 @@ async function resolveSectionEntryNames(zip) {
26682
27121
  const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
26683
27122
  if (paths.length > 0) return paths;
26684
27123
  }
26685
- return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
27124
+ return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkF2HYH62Hcjs.compareSectionPaths);
26686
27125
  }
26687
27126
  function sectionPathsFromManifest(xml) {
26688
27127
  const attr = (tag, name) => {
@@ -26692,7 +27131,7 @@ function sectionPathsFromManifest(xml) {
26692
27131
  const idToHref = /* @__PURE__ */ new Map();
26693
27132
  for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
26694
27133
  const id = attr(m[1], "id");
26695
- const href = _chunk6XAAYAWLcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
27134
+ const href = _chunkF2HYH62Hcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
26696
27135
  if (id && href) idToHref.set(id, href);
26697
27136
  }
26698
27137
  const ordered = [];
@@ -26701,7 +27140,7 @@ function sectionPathsFromManifest(xml) {
26701
27140
  if (href) ordered.push(href);
26702
27141
  }
26703
27142
  if (ordered.length > 0) return ordered;
26704
- return Array.from(idToHref.values()).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
27143
+ return Array.from(idToHref.values()).sort(_chunkF2HYH62Hcjs.compareSectionPaths);
26705
27144
  }
26706
27145
 
26707
27146
  // src/roundtrip/patcher.ts
@@ -26718,7 +27157,7 @@ async function patchHwpx(original, editedMarkdown, options) {
26718
27157
  let zip;
26719
27158
  try {
26720
27159
  zip = await _jszip2.default.loadAsync(original);
26721
- } catch (e30) {
27160
+ } catch (e31) {
26722
27161
  return { success: false, applied: 0, skipped, error: "ZIP \uB85C\uB4DC \uC2E4\uD328" };
26723
27162
  }
26724
27163
  const sectionPaths = await resolveSectionEntryNames(zip);
@@ -26793,7 +27232,7 @@ async function patchHwpx(original, editedMarkdown, options) {
26793
27232
  }
26794
27233
  }
26795
27234
  let verification;
26796
- if (_optionalChain([options, 'optionalAccess', _398 => _398.verify]) !== false) {
27235
+ if (_optionalChain([options, 'optionalAccess', _451 => _451.verify]) !== false) {
26797
27236
  try {
26798
27237
  const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
26799
27238
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -26811,17 +27250,17 @@ function buildOrigUnits(blocks) {
26811
27250
  let chunk;
26812
27251
  if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
26813
27252
  const next = blocks[i + 1];
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));
27253
+ if (_optionalChain([next, 'optionalAccess', _452 => _452.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
27254
+ chunk = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
26816
27255
  } else {
26817
- chunk = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, [block]);
27256
+ chunk = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, [block]);
26818
27257
  }
26819
27258
  if (chunk) {
26820
27259
  const subUnits = splitMarkdownUnits(chunk);
26821
27260
  const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
26822
27261
  for (let s = 0; s < subUnits.length; s++) {
26823
27262
  const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
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("**")) {
27263
+ if (block.type === "table" && _optionalChain([block, 'access', _453 => _453.table, 'optionalAccess', _454 => _454.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
26825
27264
  u.role = "caption";
26826
27265
  }
26827
27266
  units.push(u);
@@ -26932,7 +27371,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
26932
27371
  const ti = ctx.tableInsert;
26933
27372
  if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
26934
27373
  const mapping = ctx.paraMap.get(orig.blockIdx);
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");
27374
+ if (!_optionalChain([mapping, 'optionalAccess', _455 => _455.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");
26936
27375
  const para2 = mapping.para;
26937
27376
  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");
26938
27377
  const scan = ctx.scans[para2.sectionIndex];
@@ -26960,7 +27399,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
26960
27399
  }
26961
27400
  function patchParagraphUnit(block, orig, edited, ctx, skip) {
26962
27401
  const mapping = ctx.paraMap.get(orig.blockIdx);
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)");
27402
+ if (!_optionalChain([mapping, 'optionalAccess', _456 => _456.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)");
26964
27403
  if (block.text && block.text.includes("\n")) {
26965
27404
  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)");
26966
27405
  }
@@ -26991,7 +27430,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
26991
27430
  if (sanitizeText(newPlain) !== newPlain) {
26992
27431
  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");
26993
27432
  }
26994
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _404 => _404.scans, 'access', _405 => _405[mapping.para.sectionIndex], 'optionalAccess', _406 => _406.xml]));
27433
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _457 => _457.scans, 'access', _458 => _458[mapping.para.sectionIndex], 'optionalAccess', _459 => _459.xml]));
26995
27434
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
26996
27435
  ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
26997
27436
  return 1;
@@ -27084,7 +27523,10 @@ var Surgeon = (_class7 = class {
27084
27523
  __init16() {this.miniFatSectors = []}
27085
27524
  __init17() {this.dirSectors = []}
27086
27525
  __init18() {this.entries = []}
27087
- constructor(file) {;_class7.prototype.__init13.call(this);_class7.prototype.__init14.call(this);_class7.prototype.__init15.call(this);_class7.prototype.__init16.call(this);_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);
27526
+ /** replace() FREESECT로 해제한 섹터 — finish()에서 재할당 안 된 것만 0으로 지움 (데이터 잔존 방지) */
27527
+ __init19() {this.freedSectors = []}
27528
+ __init20() {this.freedMiniSectors = []}
27529
+ constructor(file) {;_class7.prototype.__init13.call(this);_class7.prototype.__init14.call(this);_class7.prototype.__init15.call(this);_class7.prototype.__init16.call(this);_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);
27088
27530
  if (file.length < SECTOR || file.readUInt32LE(0) !== 3759263696) {
27089
27531
  throw new OleSurgeonError("OLE \uC2DC\uADF8\uB2C8\uCC98\uAC00 \uC544\uB2D9\uB2C8\uB2E4");
27090
27532
  }
@@ -27177,7 +27619,7 @@ var Surgeon = (_class7 = class {
27177
27619
  /** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
27178
27620
  findEntry(path) {
27179
27621
  const parts = path.replace(/^\//, "").split("/");
27180
- let scope = _nullishCoalesce(_optionalChain([this, 'access', _407 => _407.entries, 'access', _408 => _408[0], 'optionalAccess', _409 => _409.child]), () => ( -1));
27622
+ let scope = _nullishCoalesce(_optionalChain([this, 'access', _460 => _460.entries, 'access', _461 => _461[0], 'optionalAccess', _462 => _462.child]), () => ( -1));
27181
27623
  let current;
27182
27624
  for (const part of parts) {
27183
27625
  const search = (idx) => {
@@ -27207,6 +27649,8 @@ var Surgeon = (_class7 = class {
27207
27649
  if (this.fat[i] !== FREESECT) continue;
27208
27650
  if (SECTOR + (i + 1) * SECTOR > this.buf.length) continue;
27209
27651
  this.fat[i] = ENDOFCHAIN;
27652
+ const off = this.sectorOffset(i);
27653
+ this.buf.fill(0, off, off + SECTOR);
27210
27654
  out.push(i);
27211
27655
  }
27212
27656
  while (out.length < n) {
@@ -27306,9 +27750,15 @@ var Surgeon = (_class7 = class {
27306
27750
  const entry = this.findEntry(path);
27307
27751
  if (entry.size > 0 && entry.start !== ENDOFCHAIN) {
27308
27752
  if (entry.size < MINI_CUTOFF) {
27309
- for (const s of this.miniChain(entry.start)) this.miniFat[s] = FREESECT;
27753
+ for (const s of this.miniChain(entry.start)) {
27754
+ this.miniFat[s] = FREESECT;
27755
+ this.freedMiniSectors.push(s);
27756
+ }
27310
27757
  } else {
27311
- for (const s of this.chain(entry.start)) this.fat[s] = FREESECT;
27758
+ for (const s of this.chain(entry.start)) {
27759
+ this.fat[s] = FREESECT;
27760
+ this.freedSectors.push(s);
27761
+ }
27312
27762
  }
27313
27763
  }
27314
27764
  if (newData.length < MINI_CUTOFF) {
@@ -27337,9 +27787,27 @@ var Surgeon = (_class7 = class {
27337
27787
  this.writeDirEntry(entry);
27338
27788
  }
27339
27789
  finish() {
27790
+ this.wipeFreedSectors();
27340
27791
  this.flushFat();
27341
27792
  return this.buf;
27342
27793
  }
27794
+ /** 해제 후 재할당되지 않고 남은 FREESECT 섹터의 바이트를 0으로 채움 (데이터 remanence 제거) */
27795
+ wipeFreedSectors() {
27796
+ for (const s of this.freedSectors) {
27797
+ if (this.fat[s] !== FREESECT) continue;
27798
+ const off = this.sectorOffset(s);
27799
+ this.buf.fill(0, off, off + SECTOR);
27800
+ }
27801
+ if (this.freedMiniSectors.length > 0) {
27802
+ const root = this.rootEntry();
27803
+ const rootChain = root.start === ENDOFCHAIN || root.size === 0 ? [] : this.chain(root.start);
27804
+ for (const s of this.freedMiniSectors) {
27805
+ if (this.miniFat[s] !== FREESECT) continue;
27806
+ const off = this.miniOffset(s, rootChain);
27807
+ this.buf.fill(0, off, off + MINI_SECTOR);
27808
+ }
27809
+ }
27810
+ }
27343
27811
  }, _class7);
27344
27812
 
27345
27813
  // src/roundtrip/hwp5-patch.ts
@@ -27390,8 +27858,8 @@ function serializeRecords(recs, repl, inserts) {
27390
27858
  parts.push(header, data);
27391
27859
  };
27392
27860
  for (let i = 0; i < recs.length; i++) {
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)));
27861
+ for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _463 => _463.get, 'call', _464 => _464(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
27862
+ push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _465 => _465.get, 'call', _466 => _466(i)]), () => ( recs[i].data)));
27395
27863
  }
27396
27864
  return Buffer.concat(parts);
27397
27865
  }
@@ -27509,7 +27977,7 @@ async function patchHwp(original, editedMarkdown, options) {
27509
27977
  return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
27510
27978
  }
27511
27979
  const fhEntry = CFB2.find(cfb, "/FileHeader");
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");
27980
+ if (!_optionalChain([fhEntry, 'optionalAccess', _467 => _467.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
27513
27981
  let flags;
27514
27982
  try {
27515
27983
  flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
@@ -27531,7 +27999,7 @@ async function patchHwp(original, editedMarkdown, options) {
27531
27999
  const scans = [];
27532
28000
  for (let i = 0; i < sectionPaths.length; i++) {
27533
28001
  const entry = CFB2.find(cfb, sectionPaths[i]);
27534
- if (!_optionalChain([entry, 'optionalAccess', _415 => _415.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
28002
+ if (!_optionalChain([entry, 'optionalAccess', _468 => _468.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
27535
28003
  let stream;
27536
28004
  try {
27537
28005
  stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
@@ -27582,7 +28050,7 @@ async function patchHwp(original, editedMarkdown, options) {
27582
28050
  }
27583
28051
  }
27584
28052
  let verification;
27585
- if (_optionalChain([options, 'optionalAccess', _416 => _416.verify]) !== false) {
28053
+ if (_optionalChain([options, 'optionalAccess', _469 => _469.verify]) !== false) {
27586
28054
  try {
27587
28055
  const reparsed = parseHwp5Document(Buffer.from(data));
27588
28056
  const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
@@ -27672,7 +28140,7 @@ function tableContentScore(irTable, scanTable) {
27672
28140
  for (const [key, scanCell] of scanTable.cells) {
27673
28141
  const comma = key.indexOf(",");
27674
28142
  const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
27675
- const irCell = _optionalChain([irTable, 'access', _417 => _417.cells, 'access', _418 => _418[r], 'optionalAccess', _419 => _419[c]]);
28143
+ const irCell = _optionalChain([irTable, 'access', _470 => _470.cells, 'access', _471 => _471[r], 'optionalAccess', _472 => _472[c]]);
27676
28144
  if (!irCell) continue;
27677
28145
  const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
27678
28146
  const b = normForMatch(stripCellTokens(irCell.text));
@@ -27708,7 +28176,7 @@ function handleModified(orig, edited, ctx) {
27708
28176
  }
27709
28177
  function patchParagraph(block, orig, edited, ctx, skip) {
27710
28178
  const mapping = ctx.paraMap.get(orig.blockIdx);
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)");
28179
+ if (!_optionalChain([mapping, 'optionalAccess', _473 => _473.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)");
27712
28180
  const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
27713
28181
  let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
27714
28182
  if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
@@ -27907,7 +28375,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
27907
28375
  };
27908
28376
  const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
27909
28377
  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)");
27910
- const irCell = _optionalChain([table2, 'access', _421 => _421.cells, 'access', _422 => _422[gridR], 'optionalAccess', _423 => _423[gridC]]);
28378
+ const irCell = _optionalChain([table2, 'access', _474 => _474.cells, 'access', _475 => _475[gridR], 'optionalAccess', _476 => _476[gridC]]);
27911
28379
  const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
27912
28380
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
27913
28381
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -28224,6 +28692,216 @@ async function validateHwpx(buffer) {
28224
28692
  return { ok: issues.length === 0, issues, entryCount: names.length };
28225
28693
  }
28226
28694
 
28695
+ // src/redact.ts
28696
+ var DEFAULT_REDACT_RULES = [
28697
+ "rrn",
28698
+ "phone",
28699
+ "email",
28700
+ "card",
28701
+ "account"
28702
+ ];
28703
+ var RULE_PRIORITY = [
28704
+ "rrn",
28705
+ "email",
28706
+ "card",
28707
+ "phone",
28708
+ "driver",
28709
+ "account",
28710
+ "passport"
28711
+ ];
28712
+ function luhnValid(digits) {
28713
+ let sum = 0;
28714
+ for (let i = 0; i < digits.length; i++) {
28715
+ let d = digits.charCodeAt(digits.length - 1 - i) - 48;
28716
+ if (i % 2 === 1) {
28717
+ d *= 2;
28718
+ if (d > 9) d -= 9;
28719
+ }
28720
+ sum += d;
28721
+ }
28722
+ return sum % 10 === 0;
28723
+ }
28724
+ function birthdateValid(front6) {
28725
+ const mm = Number(front6.slice(2, 4));
28726
+ const dd = Number(front6.slice(4, 6));
28727
+ return mm >= 1 && mm <= 12 && dd >= 1 && dd <= 31;
28728
+ }
28729
+ var RULES2 = {
28730
+ // 주민/외국인등록번호 — 뒷자리 첫 숫자 1-8 + 생년월일 유효성으로 오탐 축소.
28731
+ // 유니코드 대시 변형(‐ ‑ – —)은 rrn만 허용. 앞 6자리 유지, 뒤 7자리 전부 마스크.
28732
+ rrn: {
28733
+ pattern: /(?<!\d)(\d{6})([-‐‑–—])([1-8]\d{6})(?!\d)/g,
28734
+ validate: (m) => birthdateValid(m[1]),
28735
+ mask: (m, mc) => m[1] + m[2] + mc.repeat(7)
28736
+ },
28737
+ // 이메일 — 로컬파트 첫 글자만 남기고 마스크, 도메인 유지
28738
+ email: {
28739
+ pattern: /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,
28740
+ mask: (m, mc) => {
28741
+ const at = m[0].indexOf("@");
28742
+ return m[0][0] + mc.repeat(at - 1) + m[0].slice(at);
28743
+ }
28744
+ },
28745
+ // 카드번호 — 구분자 필수(무구분 16자리는 오탐 높아 제외), 동일 구분자 강제(\2),
28746
+ // Luhn 체크. 가운데 8자리 마스크.
28747
+ card: {
28748
+ pattern: /(?<!\d)(\d{4})([- ])(\d{4})\2(\d{4})\2(\d{4})(?!\d)/g,
28749
+ validate: (m) => luhnValid(m[1] + m[3] + m[4] + m[5]),
28750
+ mask: (m, mc) => m[1] + m[2] + mc.repeat(4) + m[2] + mc.repeat(4) + m[2] + m[5]
28751
+ },
28752
+ // 전화번호 — 휴대폰(01[016789])·서울(02)·지역(0[3-6]\d)·인터넷(070)은 구분자
28753
+ // -·.·공백 또는 무구분(동일 구분자 강제), 대표번호(15xx/16xx/18xx)는 구분자 필수.
28754
+ // 가운데 자리만 마스크 (대표번호는 뒤 4자리). 선행 [\d-] 금지 — 계좌 부분매치 방지.
28755
+ phone: {
28756
+ pattern: /(?<![\d-])(?:(01[016789]|070|02|0[3-6]\d)([-. ]?)(\d{3,4})\2(\d{4})|(1[568]\d{2})([-. ])(\d{4}))(?!\d)/g,
28757
+ mask: (m, mc) => m[1] !== void 0 ? m[1] + m[2] + mc.repeat(m[3].length) + m[2] + m[4] : m[5] + m[6] + mc.repeat(4)
28758
+ },
28759
+ // 운전면허 (기본 OFF) — 신형 12자리만 (지역명 2글자 선행 구버전은 스킵). 뒷 8자리 마스크.
28760
+ driver: {
28761
+ pattern: /(?<![\d-])(\d{2})-(\d{2})-\d{6}-\d{2}(?!-?\d)/g,
28762
+ mask: (m, mc) => m[1] + "-" + m[2] + "-" + mc.repeat(6) + "-" + mc.repeat(2)
28763
+ },
28764
+ // 계좌번호 — 3~4그룹 + 총 자릿수 10~16. rrn·card·phone과 겹치면 그쪽 우선.
28765
+ // 마지막 그룹 빼고 전부 마스크. 사업자등록번호(3-2-5, 10자리)도 걸린다 — 계약상 의도
28766
+ // (테스트로 명시). 날짜(2026-07-16)는 8자리라 총자릿수 검증에서 탈락.
28767
+ account: {
28768
+ pattern: /(?<!\d)(?<!\d-)\d{2,6}(?:-\d{2,6}){1,2}-\d{2,8}(?!-?\d)/g,
28769
+ validate: (m) => {
28770
+ const digits = m[0].replace(/-/g, "").length;
28771
+ return digits >= 10 && digits <= 16;
28772
+ },
28773
+ mask: (m, mc) => {
28774
+ const parts = m[0].split("-");
28775
+ return parts.map((p, i) => i === parts.length - 1 ? p : mc.repeat(p.length)).join("-");
28776
+ }
28777
+ },
28778
+ // 여권번호 (기본 OFF) — 단어 경계, 첫 글자만 남기고 전부 마스크
28779
+ passport: {
28780
+ pattern: /\b([MSRODG])\d{8}(?![0-9A-Za-z])/g,
28781
+ mask: (m, mc) => m[1] + mc.repeat(8)
28782
+ }
28783
+ };
28784
+ function redactText(text, options) {
28785
+ const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _477 => _477.maskChar]), () => ( "\u25CF"));
28786
+ if (maskChar.length !== 1 || /[0-9A-Za-z]/.test(maskChar)) {
28787
+ throw new Error(`maskChar\uB294 \uC601\uC22B\uC790\uAC00 \uC544\uB2CC 1\uAE00\uC790\uC5EC\uC57C \uD568: ${JSON.stringify(maskChar)}`);
28788
+ }
28789
+ const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _478 => _478.rules]), () => ( DEFAULT_REDACT_RULES));
28790
+ const hits = [];
28791
+ if (text === "" || enabled.length === 0) return { text, hits };
28792
+ const occupied = [];
28793
+ for (const rule of RULE_PRIORITY) {
28794
+ if (!enabled.includes(rule)) continue;
28795
+ const def = RULES2[rule];
28796
+ for (const m of text.matchAll(def.pattern)) {
28797
+ if (def.validate && !def.validate(m)) continue;
28798
+ const start = m.index;
28799
+ const end = start + m[0].length;
28800
+ if (occupied.some((o) => start < o.end && end > o.start)) continue;
28801
+ occupied.push({ start, end });
28802
+ hits.push({ rule, masked: def.mask(m, maskChar), index: start, length: m[0].length });
28803
+ }
28804
+ }
28805
+ hits.sort((a, b) => a.index - b.index);
28806
+ let out = "";
28807
+ let cursor = 0;
28808
+ for (const h of hits) {
28809
+ out += text.slice(cursor, h.index) + h.masked;
28810
+ cursor = h.index + h.length;
28811
+ }
28812
+ out += text.slice(cursor);
28813
+ return { text: out, hits };
28814
+ }
28815
+ function redactMarkdown(markdown, options) {
28816
+ const lines = markdown.split("\n");
28817
+ const hits = [];
28818
+ let offset = 0;
28819
+ const outLines = lines.map((line) => {
28820
+ if (line.includes("data:image/")) {
28821
+ offset += line.length + 1;
28822
+ return line;
28823
+ }
28824
+ const r = redactText(line, options);
28825
+ for (const h of r.hits) hits.push({ ...h, index: h.index + offset });
28826
+ offset += line.length + 1;
28827
+ return r.text;
28828
+ });
28829
+ return { text: outLines.join("\n"), hits };
28830
+ }
28831
+
28832
+ // src/chunks.ts
28833
+ var LIST_MARKER_RE = /^(?:[□■◇◆○◎●◦ㅇ•▪▸▶※-]|\d{1,3}[.)]|[가나다라마바사아자차카타파하][.)]|\([가나다라마바사아자차카타파하0-9]{1,3}\)|[①-⑳㉮-㉻㈎-㈛])\s/;
28834
+ function listDepthOf(block) {
28835
+ if (block.listDepth !== void 0) return block.listDepth;
28836
+ if (block.type === "list") return 0;
28837
+ if (block.type === "paragraph" && block.text && LIST_MARKER_RE.test(block.text.trim())) return 0;
28838
+ return void 0;
28839
+ }
28840
+ function sameBreadcrumb(a, b) {
28841
+ return a.length === b.length && a.every((v, i) => v === b[i]);
28842
+ }
28843
+ function blocksToChunks(blocks, options) {
28844
+ const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _479 => _479.granularity]), () => ( "section"));
28845
+ const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _480 => _480.includeTableCells]), () => ( false));
28846
+ const chunks = [];
28847
+ const headingStack = [];
28848
+ const listStack = [];
28849
+ const crumb = () => [...headingStack.map((h) => h.text), ...listStack.map((l) => l.text)];
28850
+ const push = (type, breadcrumb, text, blockRange, page, table2) => {
28851
+ const chunk = { id: "c" + String(chunks.length + 1).padStart(4, "0"), type, breadcrumb, text, blockRange };
28852
+ if (page !== void 0) chunk.page = page;
28853
+ if (table2) chunk.table = table2;
28854
+ chunks.push(chunk);
28855
+ };
28856
+ let run = null;
28857
+ const flushRun = () => {
28858
+ if (!run) return;
28859
+ push("text", run.breadcrumb, _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
28860
+ run = null;
28861
+ };
28862
+ for (let i = 0; i < blocks.length; i++) {
28863
+ const block = blocks[i];
28864
+ const md2 = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, [block]);
28865
+ if (!md2) continue;
28866
+ if (block.type === "heading") {
28867
+ flushRun();
28868
+ const level = Math.min(block.level || 2, 6);
28869
+ while (headingStack.length && headingStack[headingStack.length - 1].level >= level) headingStack.pop();
28870
+ listStack.length = 0;
28871
+ push("heading", crumb(), md2, [i, i], block.pageNumber);
28872
+ headingStack.push({ level, text: (_nullishCoalesce(block.text, () => ( ""))).trim() });
28873
+ continue;
28874
+ }
28875
+ if (block.type === "table" && block.table) {
28876
+ flushRun();
28877
+ const summary = { rows: block.table.rows, cols: block.table.cols };
28878
+ if (includeCells) summary.cells = block.table.cells.map((row) => row.map((c) => c.text));
28879
+ push("table", crumb(), md2, [i, i], block.pageNumber, summary);
28880
+ continue;
28881
+ }
28882
+ const depth = listDepthOf(block);
28883
+ if (depth !== void 0) {
28884
+ while (listStack.length && listStack[listStack.length - 1].depth >= depth) listStack.pop();
28885
+ }
28886
+ const breadcrumb = crumb();
28887
+ if (depth !== void 0) listStack.push({ depth, text: (_nullishCoalesce(block.text, () => ( ""))).trim() });
28888
+ if (granularity === "block") {
28889
+ push("text", breadcrumb, md2, [i, i], block.pageNumber);
28890
+ continue;
28891
+ }
28892
+ if (run && sameBreadcrumb(run.breadcrumb, breadcrumb)) {
28893
+ run.blocks.push(block);
28894
+ run.end = i;
28895
+ if (run.page === void 0) run.page = block.pageNumber;
28896
+ } else {
28897
+ flushRun();
28898
+ run = { breadcrumb, blocks: [block], start: i, end: i, page: block.pageNumber };
28899
+ }
28900
+ }
28901
+ flushRun();
28902
+ return chunks;
28903
+ }
28904
+
28227
28905
  // src/roundtrip/session.ts
28228
28906
 
28229
28907
  async function buildState(bytes) {
@@ -28273,7 +28951,7 @@ function irCellLines(text) {
28273
28951
  }
28274
28952
  var HwpxSession = (_class8 = class _HwpxSession {
28275
28953
 
28276
- constructor(state) {;_class8.prototype.__init19.call(this);
28954
+ constructor(state) {;_class8.prototype.__init21.call(this);
28277
28955
  this.state = state;
28278
28956
  }
28279
28957
  /** HWPX 바이트로 세션을 연다 (입력은 복사되어 외부 변이와 격리) */
@@ -28299,7 +28977,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28299
28977
  const block = st.blocks[blockIndex];
28300
28978
  if (!block) return void 0;
28301
28979
  if (block.type === "paragraph" || block.type === "heading") {
28302
- const para2 = _optionalChain([st, 'access', _424 => _424.paraMap, 'access', _425 => _425.get, 'call', _426 => _426(blockIndex), 'optionalAccess', _427 => _427.para]);
28980
+ const para2 = _optionalChain([st, 'access', _481 => _481.paraMap, 'access', _482 => _482.get, 'call', _483 => _483(blockIndex), 'optionalAccess', _484 => _484.para]);
28303
28981
  if (!para2) return void 0;
28304
28982
  return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
28305
28983
  }
@@ -28324,7 +29002,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28324
29002
  if (block.text && block.text.includes("\n")) {
28325
29003
  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)" };
28326
29004
  }
28327
- if (!_optionalChain([st, 'access', _428 => _428.paraMap, 'access', _429 => _429.get, 'call', _430 => _430(blockIndex), 'optionalAccess', _431 => _431.para])) {
29005
+ if (!_optionalChain([st, 'access', _485 => _485.paraMap, 'access', _486 => _486.get, 'call', _487 => _487(blockIndex), 'optionalAccess', _488 => _488.para])) {
28328
29006
  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)" };
28329
29007
  }
28330
29008
  return { capability: "text" };
@@ -28373,7 +29051,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28373
29051
  this.opQueue = run.then(() => void 0, () => void 0);
28374
29052
  return run;
28375
29053
  }
28376
- __init19() {this.opQueue = Promise.resolve()}
29054
+ __init21() {this.opQueue = Promise.resolve()}
28377
29055
  async patchBlocksInner(edits, options) {
28378
29056
  const st = this.state;
28379
29057
  const skipped = [];
@@ -28390,7 +29068,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28390
29068
  continue;
28391
29069
  }
28392
29070
  if (block.type === "table" && block.table) {
28393
- if (!_optionalChain([edit, 'access', _432 => _432.cells, 'optionalAccess', _433 => _433.length])) {
29071
+ if (!_optionalChain([edit, 'access', _489 => _489.cells, 'optionalAccess', _490 => _490.length])) {
28394
29072
  skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
28395
29073
  continue;
28396
29074
  }
@@ -28410,7 +29088,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28410
29088
  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) });
28411
29089
  continue;
28412
29090
  }
28413
- const irCell = _optionalChain([block, 'access', _434 => _434.table, 'access', _435 => _435.cells, 'access', _436 => _436[cellEdit.row], 'optionalAccess', _437 => _437[cellEdit.col]]);
29091
+ const irCell = _optionalChain([block, 'access', _491 => _491.table, 'access', _492 => _492.cells, 'access', _493 => _493[cellEdit.row], 'optionalAccess', _494 => _494[cellEdit.col]]);
28414
29092
  if (!irCell) {
28415
29093
  skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
28416
29094
  continue;
@@ -28466,7 +29144,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28466
29144
  }
28467
29145
  if (replacements.size === 0) {
28468
29146
  let changes2;
28469
- if (_optionalChain([options, 'optionalAccess', _438 => _438.verify]) !== false) {
29147
+ if (_optionalChain([options, 'optionalAccess', _495 => _495.verify]) !== false) {
28470
29148
  const units = splitMarkdownUnits(st.markdown);
28471
29149
  changes2 = diffUnitLists(units, units);
28472
29150
  }
@@ -28487,7 +29165,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28487
29165
  }
28488
29166
  this.state = newState;
28489
29167
  let changes;
28490
- if (_optionalChain([options, 'optionalAccess', _439 => _439.verify]) !== false) {
29168
+ if (_optionalChain([options, 'optionalAccess', _496 => _496.verify]) !== false) {
28491
29169
  changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
28492
29170
  }
28493
29171
  return { success: true, data: new Uint8Array(data), applied, skipped, changes };
@@ -28507,7 +29185,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
28507
29185
  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)");
28508
29186
  }
28509
29187
  const mapping = st.paraMap.get(blockIndex);
28510
- if (!_optionalChain([mapping, 'optionalAccess', _440 => _440.para])) {
29188
+ if (!_optionalChain([mapping, 'optionalAccess', _497 => _497.para])) {
28511
29189
  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)");
28512
29190
  }
28513
29191
  let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
@@ -28527,14 +29205,14 @@ var HwpxSession = (_class8 = class _HwpxSession {
28527
29205
  if (sanitizeText(newPlain) !== newPlain) {
28528
29206
  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");
28529
29207
  }
28530
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _441 => _441.scans, 'access', _442 => _442[mapping.para.sectionIndex], 'optionalAccess', _443 => _443.xml]));
29208
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _498 => _498.scans, 'access', _499 => _499[mapping.para.sectionIndex], 'optionalAccess', _500 => _500.xml]));
28531
29209
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
28532
29210
  sectionSplices[mapping.para.sectionIndex].push(...splices);
28533
29211
  return 1;
28534
29212
  }
28535
29213
  }, _class8);
28536
29214
  function cellStaticCheck(table2, scanTable, r, c) {
28537
- const irCell = _optionalChain([table2, 'access', _444 => _444.cells, 'access', _445 => _445[r], 'optionalAccess', _446 => _446[c]]);
29215
+ const irCell = _optionalChain([table2, 'access', _501 => _501.cells, 'access', _502 => _502[r], 'optionalAccess', _503 => _503[c]]);
28538
29216
  if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
28539
29217
  const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
28540
29218
  if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
@@ -28618,11 +29296,11 @@ var md = new (0, _markdownit2.default)({
28618
29296
  breaks: false
28619
29297
  });
28620
29298
  function renderHtml(markdown, options) {
28621
- const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _447 => _447.preset]), () => ( "default"));
28622
- const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _448 => _448.extraCss]), () => ( "")));
29299
+ const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _504 => _504.preset]), () => ( "default"));
29300
+ const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _505 => _505.extraCss]), () => ( "")));
28623
29301
  const body = md.render(markdown);
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]) ? `
29302
+ const watermark = _optionalChain([options, 'optionalAccess', _506 => _506.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
29303
+ const watermarkCss = _optionalChain([options, 'optionalAccess', _507 => _507.watermark]) ? `
28626
29304
  .watermark {
28627
29305
  position: fixed;
28628
29306
  top: 50%; left: 50%;
@@ -28652,14 +29330,14 @@ async function htmlToPdf(html, options) {
28652
29330
  let puppeteer;
28653
29331
  try {
28654
29332
  puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
28655
- } catch (e31) {
28656
- throw new (0, _chunk6XAAYAWLcjs.KordocError)(
29333
+ } catch (e32) {
29334
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)(
28657
29335
  "PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
28658
29336
  );
28659
29337
  }
28660
29338
  const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
28661
29339
  if (!executablePath) {
28662
- throw new (0, _chunk6XAAYAWLcjs.KordocError)(
29340
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)(
28663
29341
  "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."
28664
29342
  );
28665
29343
  }
@@ -28671,10 +29349,10 @@ async function htmlToPdf(html, options) {
28671
29349
  try {
28672
29350
  const page = await browser.newPage();
28673
29351
  await page.setContent(html, { waitUntil: "networkidle0" });
28674
- const margin = _optionalChain([options, 'optionalAccess', _451 => _451.margin]);
29352
+ const margin = _optionalChain([options, 'optionalAccess', _508 => _508.margin]);
28675
29353
  const pdf = await page.pdf({
28676
- format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _452 => _452.pageSize]), () => ( "A4")),
28677
- landscape: _optionalChain([options, 'optionalAccess', _453 => _453.orientation]) === "landscape",
29354
+ format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _509 => _509.pageSize]), () => ( "A4")),
29355
+ landscape: _optionalChain([options, 'optionalAccess', _510 => _510.orientation]) === "landscape",
28678
29356
  printBackground: true,
28679
29357
  margin: margin ? {
28680
29358
  top: toCss(margin.top),
@@ -28682,9 +29360,9 @@ async function htmlToPdf(html, options) {
28682
29360
  bottom: toCss(margin.bottom),
28683
29361
  left: toCss(margin.left)
28684
29362
  } : void 0,
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>'))
29363
+ displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _511 => _511.header]) || _optionalChain([options, 'optionalAccess', _512 => _512.footer])),
29364
+ headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _513 => _513.header]), () => ( "<div></div>")),
29365
+ footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _514 => _514.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
28688
29366
  });
28689
29367
  return Buffer.from(pdf);
28690
29368
  } finally {
@@ -28718,7 +29396,7 @@ async function markdownToPdf(markdown, options) {
28718
29396
  return htmlToPdf(html, options);
28719
29397
  }
28720
29398
  async function blocksToPdf(blocks, options) {
28721
- const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
29399
+ const markdown = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, blocks);
28722
29400
  return markdownToPdf(markdown, options);
28723
29401
  }
28724
29402
 
@@ -28897,7 +29575,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode) {
28897
29575
  }
28898
29576
  const wrapAttr = _nullishCoalesce(o.el.getAttribute("textWrap"), () => ( ""));
28899
29577
  if (wrapAttr === "BEHIND_TEXT" || wrapAttr === "IN_FRONT_OF_TEXT") continue;
28900
- const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _458 => _458.getAttribute, 'call', _459 => _459("vertRelTo")]), () => ( "PARA"));
29578
+ const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _515 => _515.getAttribute, 'call', _516 => _516("vertRelTo")]), () => ( "PARA"));
28901
29579
  if (vertRel === "PAGE" || vertRel === "PAPER") continue;
28902
29580
  const vo = Math.max(0, num2(pos, "vertOffset"));
28903
29581
  if (wrapAttr === "TOP_AND_BOTTOM") {
@@ -28958,7 +29636,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
28958
29636
  if (ln(p) !== "p") continue;
28959
29637
  reflowTablesIn(p, doc, styles, mode, counter);
28960
29638
  const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
28961
- const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _460 => _460.spaceBefore]), () => ( 0)));
29639
+ const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _517 => _517.spaceBefore]), () => ( 0)));
28962
29640
  const res = reflowPara(p, doc, styles, areaW, startV, mode);
28963
29641
  if (!res) {
28964
29642
  const lsa = findChildByLocalName(p, "linesegarray");
@@ -28971,7 +29649,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
28971
29649
  }
28972
29650
  if (Number.isFinite(bottom)) {
28973
29651
  cursorV = bottom;
28974
- prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _461 => _461.spaceAfter]), () => ( 0));
29652
+ prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _518 => _518.spaceAfter]), () => ( 0));
28975
29653
  }
28976
29654
  }
28977
29655
  continue;
@@ -29081,7 +29759,7 @@ function buildPara(p) {
29081
29759
  el: ch,
29082
29760
  tag: cn,
29083
29761
  index: chars.length,
29084
- inline: _optionalChain([pos, 'optionalAccess', _462 => _462.getAttribute, 'call', _463 => _463("treatAsChar")]) === "1",
29762
+ inline: _optionalChain([pos, 'optionalAccess', _519 => _519.getAttribute, 'call', _520 => _520("treatAsChar")]) === "1",
29085
29763
  width: w,
29086
29764
  height: h
29087
29765
  });
@@ -29199,7 +29877,7 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
29199
29877
  }
29200
29878
  if (text.trim().length > 0) {
29201
29879
  const attrs = [`x="${pt(cx)}"`, `y="${pt(y)}"`, `font-size="${pt(st.height)}"`];
29202
- if (st.fontFamily) attrs.push(`font-family="${st.fontFamily}"`);
29880
+ if (st.fontFamily) attrs.push(`font-family="${escapeXml3(st.fontFamily)}"`);
29203
29881
  if ([...text].length > 1 && sw > 50) {
29204
29882
  attrs.push(`textLength="${pt(sw)}"`, `lengthAdjust="${plan.scale < 1 ? "spacingAndGlyphs" : "spacing"}"`);
29205
29883
  }
@@ -29333,15 +30011,15 @@ function drawShape(o, x, y, ctx, depth) {
29333
30011
  const sx = ow > 0 ? w / ow : 1;
29334
30012
  const sy = oh > 0 ? h / oh : 1;
29335
30013
  const lineShape = findChildByLocalName(el, "lineShape");
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";
30014
+ const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _521 => _521.getAttribute, 'call', _522 => _522("style")]), () => ( "SOLID"));
30015
+ const strokeCol = _optionalChain([lineShape, 'optionalAccess', _523 => _523.getAttribute, 'call', _524 => _524("color")]) || "#000000";
29338
30016
  const hasStroke = lstyle !== "NONE";
29339
30017
  const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
29340
30018
  const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
29341
30019
  const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
29342
30020
  const fillBrush = findChildByLocalName(el, "fillBrush");
29343
30021
  const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
29344
- const face = _optionalChain([winBrush, 'optionalAccess', _468 => _468.getAttribute, 'call', _469 => _469("faceColor")]);
30022
+ const face = _optionalChain([winBrush, 'optionalAccess', _525 => _525.getAttribute, 'call', _526 => _526("faceColor")]);
29345
30023
  const fill = face && face.toLowerCase() !== "none" ? face : "none";
29346
30024
  const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
29347
30025
  if (o.tag === "rect") {
@@ -29366,28 +30044,31 @@ function drawShape(o, x, y, ctx, depth) {
29366
30044
  for (const p of elements2(sub)) if (ln2(p) === "p") drawPara(p, x, y, w, ctx, depth + 1);
29367
30045
  }
29368
30046
  }
29369
- function cellContentExtent(cell2) {
30047
+ function cellContentExtent(cell2, memo) {
29370
30048
  if (!cell2.sub) return 0;
30049
+ const hit = _optionalChain([memo, 'optionalAccess', _527 => _527.cell, 'access', _528 => _528.get, 'call', _529 => _529(cell2.el)]);
30050
+ if (hit !== void 0) return hit;
29371
30051
  let ext = 0;
29372
30052
  for (const p of elements2(cell2.sub)) {
29373
30053
  if (ln2(p) !== "p") continue;
29374
30054
  const m = buildPara(p);
29375
30055
  for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
29376
- const baseV = _nullishCoalesce(_optionalChain([m, 'access', _470 => _470.segs, 'access', _471 => _471[0], 'optionalAccess', _472 => _472.vertpos]), () => ( 0));
30056
+ const baseV = _nullishCoalesce(_optionalChain([m, 'access', _530 => _530.segs, 'access', _531 => _531[0], 'optionalAccess', _532 => _532.vertpos]), () => ( 0));
29377
30057
  for (const o of m.objs) {
29378
30058
  if (o.inline) {
29379
- const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
30059
+ const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, memo)) : o.height;
29380
30060
  ext = Math.max(ext, baseV + h);
29381
30061
  continue;
29382
30062
  }
29383
30063
  const pos = findChildByLocalName(o.el, "pos");
29384
- if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _473 => _473.getAttribute, 'call', _474 => _474("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
30064
+ if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _533 => _533.getAttribute, 'call', _534 => _534("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
29385
30065
  const om = findChildByLocalName(o.el, "outMargin");
29386
30066
  const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
29387
30067
  const anchor = pushed >= -100 ? pushed : baseV;
29388
30068
  ext = Math.max(ext, anchor + num3(om, "top") + num3(pos, "vertOffset") + o.height);
29389
30069
  }
29390
30070
  }
30071
+ _optionalChain([memo, 'optionalAccess', _535 => _535.cell, 'access', _536 => _536.set, 'call', _537 => _537(cell2.el, ext)]);
29391
30072
  return ext;
29392
30073
  }
29393
30074
  function edgeLine(x1, y1, x2, y2, e) {
@@ -29410,8 +30091,9 @@ function collectCells(tbl2) {
29410
30091
  if (!addr || !csz) continue;
29411
30092
  cells.push({
29412
30093
  el: tc2,
29413
- ca: num3(addr, "colAddr"),
29414
- ra: num3(addr, "rowAddr"),
30094
+ // 음수 주소(uint32 역변환·손상 입력) 방어 — colX/rowY 인덱스 이탈로 NaN 좌표 방지
30095
+ ca: Math.max(0, num3(addr, "colAddr")),
30096
+ ra: Math.max(0, num3(addr, "rowAddr")),
29415
30097
  cs: Math.max(1, num3(span, "colSpan", 1)),
29416
30098
  rs: Math.max(1, num3(span, "rowSpan", 1)),
29417
30099
  w: num3(csz, "width"),
@@ -29427,16 +30109,19 @@ function collectCells(tbl2) {
29427
30109
  }
29428
30110
  return cells;
29429
30111
  }
29430
- function measureTableHeight(tbl2) {
30112
+ function measureTableHeight(tbl2, memo) {
30113
+ const hit = _optionalChain([memo, 'optionalAccess', _538 => _538.table, 'access', _539 => _539.get, 'call', _540 => _540(tbl2)]);
30114
+ if (hit !== void 0) return hit;
29431
30115
  const cells = collectCells(tbl2);
29432
30116
  if (cells.length === 0 || cells.length > 4096) return 0;
29433
30117
  const nRows = Math.max(...cells.map((c) => c.ra + c.rs));
29434
30118
  const rowH = solveRowHeights(
29435
- cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c) : void 0 })),
30119
+ cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c, memo) : void 0 })),
29436
30120
  nRows
29437
30121
  );
29438
30122
  let sum = 0;
29439
30123
  for (const h of rowH) sum += h;
30124
+ _optionalChain([memo, 'optionalAccess', _541 => _541.table, 'access', _542 => _542.set, 'call', _543 => _543(tbl2, sum)]);
29440
30125
  return sum;
29441
30126
  }
29442
30127
  function drawTable(tbl2, tx, ty, ctx, depth) {
@@ -29453,7 +30138,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
29453
30138
  const colCons = cells.map((c) => ({ a: c.ca, b: c.ca + c.cs, size: c.w }));
29454
30139
  const colX = solveBoundaries(colCons, nCols, num3(tblSz, "width") || void 0);
29455
30140
  const rowH = solveRowHeights(
29456
- cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c) : void 0 })),
30141
+ cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c, ctx.extentMemo) : void 0 })),
29457
30142
  nRows
29458
30143
  );
29459
30144
  const rowY = [0];
@@ -29467,13 +30152,13 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
29467
30152
  }));
29468
30153
  for (const g of geom) {
29469
30154
  const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
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)}"/>`);
30155
+ if (_optionalChain([bf, 'optionalAccess', _544 => _544.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
29471
30156
  }
29472
30157
  for (const g of geom) {
29473
30158
  const { c } = g;
29474
30159
  if (!c.sub) continue;
29475
30160
  const innerH = g.h - c.marginT - c.marginB;
29476
- const extent = cellContentExtent(c);
30161
+ const extent = cellContentExtent(c, ctx.extentMemo);
29477
30162
  const va = _nullishCoalesce(c.sub.getAttribute("vertAlign"), () => ( "TOP"));
29478
30163
  let yoff = 0;
29479
30164
  if (va === "CENTER") yoff = Math.max(0, (innerH - extent) / 2);
@@ -29505,7 +30190,7 @@ function drawPic(pic, x, y, ctx) {
29505
30190
  const sz = findChildByLocalName(pic, "sz");
29506
30191
  const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
29507
30192
  const img = findFirst(pic, "img");
29508
- const ref = _optionalChain([img, 'optionalAccess', _476 => _476.getAttribute, 'call', _477 => _477("binaryItemIDRef")]);
30193
+ const ref = _optionalChain([img, 'optionalAccess', _545 => _545.getAttribute, 'call', _546 => _546("binaryItemIDRef")]);
29509
30194
  const loaded = ref != null ? ctx.images.get(ref) : void 0;
29510
30195
  if (!loaded) {
29511
30196
  emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
@@ -29536,15 +30221,16 @@ function sniffMime(name, bytes) {
29536
30221
  const lower = name.toLowerCase();
29537
30222
  if (lower.endsWith(".png") || bytes.length > 4 && bytes[0] === 137 && bytes[1] === 80) return "image/png";
29538
30223
  if (lower.endsWith(".bmp") || bytes.length > 2 && bytes[0] === 66 && bytes[1] === 77) return "image/bmp";
29539
- if (lower.endsWith(".gif")) return "image/gif";
30224
+ if (lower.endsWith(".gif") || bytes.length > 3 && bytes[0] === 71 && bytes[1] === 73 && bytes[2] === 70) return "image/gif";
29540
30225
  if (lower.endsWith(".svg")) return "image/svg+xml";
30226
+ if (bytes.length > 3 && bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255) return "image/jpeg";
29541
30227
  return "image/jpeg";
29542
30228
  }
29543
30229
  function readSectionGeom(root) {
29544
30230
  const pagePr = findFirst(root, "pagePr");
29545
30231
  const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
29546
30232
  let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
29547
- if (_optionalChain([pagePr, 'optionalAccess', _478 => _478.getAttribute, 'call', _479 => _479("landscape")]) === "NARROWLY" && PW < PH) {
30233
+ if (_optionalChain([pagePr, 'optionalAccess', _547 => _547.getAttribute, 'call', _548 => _548("landscape")]) === "NARROWLY" && PW < PH) {
29548
30234
  const t = PW;
29549
30235
  PW = PH;
29550
30236
  PH = t;
@@ -29602,17 +30288,17 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
29602
30288
  return { pages: ctx.pages, pageH };
29603
30289
  }
29604
30290
  async function renderHwpxToSvg(input, options) {
29605
- const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _480 => _480.maxImageBytes]), () => ( 40 * 1024 * 1024));
30291
+ const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _549 => _549.maxImageBytes]), () => ( 40 * 1024 * 1024));
29606
30292
  const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
29607
- _chunk6XAAYAWLcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
30293
+ _chunkF2HYH62Hcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
29608
30294
  let zip;
29609
30295
  try {
29610
30296
  zip = await _jszip2.default.loadAsync(input);
29611
- } catch (e32) {
29612
- throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
30297
+ } catch (e33) {
30298
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
29613
30299
  }
29614
30300
  const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
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");
30301
+ if (secFiles.length === 0) throw new (0, _chunkF2HYH62Hcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
29616
30302
  const warnings = [];
29617
30303
  const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
29618
30304
  const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
@@ -29620,7 +30306,7 @@ async function renderHwpxToSvg(input, options) {
29620
30306
  const secXmls = [];
29621
30307
  for (const f of secFiles) {
29622
30308
  const xml = await f.async("string");
29623
- if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
30309
+ if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
29624
30310
  secXmls.push(xml);
29625
30311
  }
29626
30312
  const binmap = /* @__PURE__ */ new Map();
@@ -29644,7 +30330,7 @@ async function renderHwpxToSvg(input, options) {
29644
30330
  let href = binmap.get(ref);
29645
30331
  if (!href) {
29646
30332
  const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
29647
- href = _optionalChain([cand, 'optionalAccess', _481 => _481.name]);
30333
+ href = _optionalChain([cand, 'optionalAccess', _550 => _550.name]);
29648
30334
  }
29649
30335
  if (!href) continue;
29650
30336
  const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
@@ -29665,17 +30351,18 @@ async function renderHwpxToSvg(input, options) {
29665
30351
  styles,
29666
30352
  images,
29667
30353
  defs: [],
29668
- highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _482 => _482.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
30354
+ highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _551 => _551.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
29669
30355
  warnings,
29670
30356
  warned: /* @__PURE__ */ new Set(),
29671
- stats: { texts: 0, images: 0, tables: 0 }
30357
+ stats: { texts: 0, images: 0, tables: 0 },
30358
+ extentMemo: { cell: /* @__PURE__ */ new WeakMap(), table: /* @__PURE__ */ new WeakMap() }
29672
30359
  };
29673
30360
  const rendered = [];
29674
30361
  let noCacheSkipped = false;
29675
30362
  for (let si = 0; si < secXmls.length; si++) {
29676
30363
  const secXml = secXmls[si];
29677
30364
  const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
29678
- if (!hasCache && !_optionalChain([options, 'optionalAccess', _483 => _483.reflow])) {
30365
+ if (!hasCache && !_optionalChain([options, 'optionalAccess', _552 => _552.reflow])) {
29679
30366
  noCacheSkipped = true;
29680
30367
  warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
29681
30368
  continue;
@@ -29687,14 +30374,14 @@ async function renderHwpxToSvg(input, options) {
29687
30374
  continue;
29688
30375
  }
29689
30376
  const geom = readSectionGeom(root);
29690
- const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess', _484 => _484.reflow]), _nullishCoalesce(_optionalChain([options, 'optionalAccess', _485 => _485.reflowMode]), () => ( "keep")));
30377
+ const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess', _553 => _553.reflow]), _nullishCoalesce(_optionalChain([options, 'optionalAccess', _554 => _554.reflowMode]), () => ( "keep")));
29691
30378
  rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
29692
30379
  }
29693
30380
  if (rendered.length === 0) {
29694
30381
  if (noCacheSkipped) {
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)");
30382
+ throw new (0, _chunkF2HYH62Hcjs.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)");
29696
30383
  }
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");
30384
+ throw new (0, _chunkF2HYH62Hcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
29698
30385
  }
29699
30386
  const GAP = 2400;
29700
30387
  const clipDefs = [];
@@ -29726,17 +30413,17 @@ ${groups.join("\n")}
29726
30413
  // src/index.ts
29727
30414
  async function parse(input, options) {
29728
30415
  let buffer;
29729
- const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _486 => _486.filePath]) ? { ...options, filePath: input } : options;
30416
+ const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _555 => _555.filePath]) ? { ...options, filePath: input } : options;
29730
30417
  if (typeof input === "string") {
29731
30418
  try {
29732
30419
  const buf = await _promises.readFile.call(void 0, input);
29733
- buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, buf);
30420
+ buffer = _chunkF2HYH62Hcjs.toArrayBuffer.call(void 0, buf);
29734
30421
  } catch (err) {
29735
30422
  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}`;
29736
30423
  return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
29737
30424
  }
29738
30425
  } else if (Buffer.isBuffer(input)) {
29739
- buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, input);
30426
+ buffer = _chunkF2HYH62Hcjs.toArrayBuffer.call(void 0, input);
29740
30427
  } else {
29741
30428
  buffer = input;
29742
30429
  }
@@ -29771,21 +30458,21 @@ async function parseHwp3(buffer, options) {
29771
30458
  const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
29772
30459
  return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
29773
30460
  } catch (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) };
30461
+ return { success: false, fileType: "hwp3", error: _chunkF2HYH62Hcjs.sanitizeError.call(void 0, err), code: _chunkF2HYH62Hcjs.classifyError.call(void 0, err) };
29775
30462
  }
29776
30463
  }
29777
30464
  async function parseHwpx(buffer, options) {
29778
30465
  try {
29779
30466
  const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
29780
- return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _487 => _487.length]) ? images : void 0 };
30467
+ return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _556 => _556.length]) ? images : void 0 };
29781
30468
  } catch (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) };
30469
+ return { success: false, fileType: "hwpx", error: _chunkF2HYH62Hcjs.sanitizeError.call(void 0, err), code: _chunkF2HYH62Hcjs.classifyError.call(void 0, err) };
29783
30470
  }
29784
30471
  }
29785
30472
  async function parseHwp(buffer, options) {
29786
30473
  try {
29787
30474
  const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
29788
- if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _488 => _488.filePath])) {
30475
+ if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _557 => _557.filePath])) {
29789
30476
  try {
29790
30477
  const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
29791
30478
  if (pages.some((p) => p && p.trim().length > 0)) {
@@ -29799,20 +30486,20 @@ async function parseHwp(buffer, options) {
29799
30486
  warnings: com.warnings
29800
30487
  };
29801
30488
  }
29802
- } catch (e33) {
30489
+ } catch (e34) {
29803
30490
  }
29804
30491
  }
29805
- return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _489 => _489.length]) ? images : void 0 };
30492
+ return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _558 => _558.length]) ? images : void 0 };
29806
30493
  } catch (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) };
30494
+ return { success: false, fileType: "hwp", error: _chunkF2HYH62Hcjs.sanitizeError.call(void 0, err), code: _chunkF2HYH62Hcjs.classifyError.call(void 0, err) };
29808
30495
  }
29809
30496
  }
29810
30497
  async function parsePdf(buffer, options) {
29811
30498
  let parsePdfDocument;
29812
30499
  try {
29813
- const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-ITMU2WN5.cjs")));
30500
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-WDZOMDG4.cjs")));
29814
30501
  parsePdfDocument = mod.parsePdfDocument;
29815
- } catch (e34) {
30502
+ } catch (e35) {
29816
30503
  return {
29817
30504
  success: false,
29818
30505
  fileType: "pdf",
@@ -29825,7 +30512,7 @@ async function parsePdf(buffer, options) {
29825
30512
  return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
29826
30513
  } catch (err) {
29827
30514
  const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
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 };
30515
+ return { success: false, fileType: "pdf", error: _chunkF2HYH62Hcjs.sanitizeError.call(void 0, err), code: _chunkF2HYH62Hcjs.classifyError.call(void 0, err), isImageBased };
29829
30516
  }
29830
30517
  }
29831
30518
  async function parseXlsx(buffer, options) {
@@ -29833,7 +30520,7 @@ async function parseXlsx(buffer, options) {
29833
30520
  const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
29834
30521
  return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
29835
30522
  } catch (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) };
30523
+ return { success: false, fileType: "xlsx", error: _chunkF2HYH62Hcjs.sanitizeError.call(void 0, err), code: _chunkF2HYH62Hcjs.classifyError.call(void 0, err) };
29837
30524
  }
29838
30525
  }
29839
30526
  async function parseXls(buffer, options) {
@@ -29841,15 +30528,15 @@ async function parseXls(buffer, options) {
29841
30528
  const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
29842
30529
  return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
29843
30530
  } catch (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) };
30531
+ return { success: false, fileType: "xls", error: _chunkF2HYH62Hcjs.sanitizeError.call(void 0, err), code: _chunkF2HYH62Hcjs.classifyError.call(void 0, err) };
29845
30532
  }
29846
30533
  }
29847
30534
  async function parseDocx(buffer, options) {
29848
30535
  try {
29849
30536
  const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
29850
- return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _490 => _490.length]) ? images : void 0 };
30537
+ return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _559 => _559.length]) ? images : void 0 };
29851
30538
  } catch (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) };
30539
+ return { success: false, fileType: "docx", error: _chunkF2HYH62Hcjs.sanitizeError.call(void 0, err), code: _chunkF2HYH62Hcjs.classifyError.call(void 0, err) };
29853
30540
  }
29854
30541
  }
29855
30542
  async function parseHwpml(buffer, options) {
@@ -29857,16 +30544,16 @@ async function parseHwpml(buffer, options) {
29857
30544
  const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
29858
30545
  return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
29859
30546
  } catch (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) };
30547
+ return { success: false, fileType: "hwpml", error: _chunkF2HYH62Hcjs.sanitizeError.call(void 0, err), code: _chunkF2HYH62Hcjs.classifyError.call(void 0, err) };
29861
30548
  }
29862
30549
  }
29863
30550
  async function fillForm(input, values, outputFormat = "markdown") {
29864
30551
  let buffer;
29865
30552
  if (typeof input === "string") {
29866
30553
  const buf = await _promises.readFile.call(void 0, input);
29867
- buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, buf);
30554
+ buffer = _chunkF2HYH62Hcjs.toArrayBuffer.call(void 0, buf);
29868
30555
  } else if (Buffer.isBuffer(input)) {
29869
- buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, input);
30556
+ buffer = _chunkF2HYH62Hcjs.toArrayBuffer.call(void 0, input);
29870
30557
  } else {
29871
30558
  buffer = input;
29872
30559
  }
@@ -29892,7 +30579,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
29892
30579
  throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
29893
30580
  }
29894
30581
  const fill = fillFormFields(parsed.blocks, values);
29895
- const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, fill.blocks);
30582
+ const markdown = _chunkXTCT6KQ5cjs.blocksToMarkdown.call(void 0, fill.blocks);
29896
30583
  if (outputFormat === "hwpx") {
29897
30584
  const hwpxBuffer = await markdownToHwpx(markdown);
29898
30585
  return { output: hwpxBuffer, format: "hwpx", fill };
@@ -29961,5 +30648,9 @@ async function fillForm(input, values, outputFormat = "markdown") {
29961
30648
 
29962
30649
 
29963
30650
 
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;
30651
+
30652
+
30653
+
30654
+
30655
+ exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkF2HYH62Hcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunkXTCT6KQ5cjs.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.redactMarkdown = redactMarkdown; exports.redactText = redactText; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
29965
30656
  //# sourceMappingURL=index.cjs.map