kordoc 4.18.3 → 4.18.4

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 (145) hide show
  1. package/dist/{-WOKB25R2.js → -DDAVBMHD.js} +11 -11
  2. package/dist/{chunk-BGOR5GCF.js → chunk-274ZPMHK.js} +2 -2
  3. package/dist/{chunk-2ZBLQVAS.cjs → chunk-3WLZOJIE.cjs} +6 -6
  4. package/dist/chunk-3WLZOJIE.cjs.map +1 -0
  5. package/dist/{chunk-SHRRD2TD.cjs → chunk-3XSP7V5P.cjs} +2 -2
  6. package/dist/chunk-3XSP7V5P.cjs.map +1 -0
  7. package/dist/{chunk-6GLTGOP6.js → chunk-4IBY5LTJ.js} +2 -2
  8. package/dist/chunk-6H25SXDI.js +11 -0
  9. package/dist/chunk-6H25SXDI.js.map +1 -0
  10. package/dist/{chunk-CAN5P6N6.js → chunk-7GR2GCJF.js} +2 -2
  11. package/dist/{chunk-HZV52V2X.cjs → chunk-AVIZ55NQ.cjs} +3 -3
  12. package/dist/chunk-AVIZ55NQ.cjs.map +1 -0
  13. package/dist/chunk-DC6CTQTK.js +9 -0
  14. package/dist/chunk-DC6CTQTK.js.map +1 -0
  15. package/dist/{chunk-NES5U4JK.js → chunk-DUV7Y6IQ.js} +3 -3
  16. package/dist/{chunk-WN5YLP7H.cjs → chunk-E2644XCO.cjs} +693 -187
  17. package/dist/chunk-E2644XCO.cjs.map +1 -0
  18. package/dist/{chunk-3FZGL3IL.js → chunk-ELOPDQES.js} +2 -2
  19. package/dist/{chunk-2I2RTJJ5.js → chunk-F2GDLA45.js} +25 -35
  20. package/dist/chunk-F2GDLA45.js.map +1 -0
  21. package/dist/{chunk-VGDTONTB.js → chunk-F5YVCJVF.js} +2 -2
  22. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  23. package/dist/{chunk-RDBTOE5X.js → chunk-HRJJDNRD.js} +2 -2
  24. package/dist/{chunk-KSJ7GKNQ.js → chunk-IAXGGQGD.js} +2 -2
  25. package/dist/{chunk-IXX3WHIE.js → chunk-IBQCK4F3.js} +7 -3
  26. package/dist/chunk-IBQCK4F3.js.map +1 -0
  27. package/dist/chunk-J55UQC5H.cjs.map +1 -1
  28. package/dist/{chunk-J2A46VCA.js → chunk-KUUSP6OS.js} +576 -70
  29. package/dist/chunk-KUUSP6OS.js.map +1 -0
  30. package/dist/{chunk-RSDUH4XF.js → chunk-LGF2IO66.js} +2 -2
  31. package/dist/{chunk-BJ6RYYXV.js → chunk-MXA6YW2W.js} +577 -71
  32. package/dist/chunk-MXA6YW2W.js.map +1 -0
  33. package/dist/{chunk-ZD5WNQNC.cjs → chunk-OIUSF2VA.cjs} +16 -12
  34. package/dist/chunk-OIUSF2VA.cjs.map +1 -0
  35. package/dist/{chunk-AZQWESRH.js → chunk-QVCHFCT2.js} +2 -2
  36. package/dist/{chunk-W7P4GPOV.js → chunk-RCI7LY4N.js} +8 -4
  37. package/dist/chunk-RCI7LY4N.js.map +1 -0
  38. package/dist/{chunk-V4BKT65D.cjs → chunk-SVNBZEL6.cjs} +3 -3
  39. package/dist/chunk-SVNBZEL6.cjs.map +1 -0
  40. package/dist/{chunk-OOX2GZZ4.js → chunk-T2BJPT6D.js} +3 -3
  41. package/dist/{chunk-OOX2GZZ4.js.map → chunk-T2BJPT6D.js.map} +1 -1
  42. package/dist/chunk-TK3FDAEE.cjs +9 -0
  43. package/dist/chunk-TK3FDAEE.cjs.map +1 -0
  44. package/dist/{chunk-UVUKT3IQ.js → chunk-TMJVD6FW.js} +2 -2
  45. package/dist/{chunk-ZN3LHNJG.js → chunk-V5X4LLVM.js} +28 -27
  46. package/dist/chunk-V5X4LLVM.js.map +1 -0
  47. package/dist/{chunk-W3RADOLO.js → chunk-VTVK2JMI.js} +2 -2
  48. package/dist/{chunk-PSJLB3SZ.js → chunk-XG4SYOZL.js} +2 -2
  49. package/dist/{chunk-RRURZDEK.js → chunk-YCY2R4FM.js} +2 -2
  50. package/dist/{chunk-5X7XWYR2.js → chunk-Z2PPDQK2.js} +2 -2
  51. package/dist/chunks-5QTTAT5T.js +10 -0
  52. package/dist/cli.js +154 -115
  53. package/dist/cli.js.map +1 -1
  54. package/dist/{formula-QZAOKPBX.js → formula-7ZOZ5QJ6.js} +8 -4
  55. package/dist/{formula-QZAOKPBX.js.map → formula-7ZOZ5QJ6.js.map} +1 -1
  56. package/dist/{formula-GPCOJJXN.js → formula-HQFZEXFF.js} +7 -3
  57. package/dist/{formula-GPCOJJXN.js.map → formula-HQFZEXFF.js.map} +1 -1
  58. package/dist/{formula-BQ5RW5XD.cjs → formula-YYJQBKEN.cjs} +13 -9
  59. package/dist/formula-YYJQBKEN.cjs.map +1 -0
  60. package/dist/{image-ocr-POCME5I4.js → image-ocr-4BGX2EJJ.js} +7 -6
  61. package/dist/{image-ocr-POCME5I4.js.map → image-ocr-4BGX2EJJ.js.map} +1 -1
  62. package/dist/{image-ocr-VKIUBLBX.cjs → image-ocr-CC26Q5KG.cjs} +16 -15
  63. package/dist/image-ocr-CC26Q5KG.cjs.map +1 -0
  64. package/dist/{image-ocr-TWNNVTZS.js → image-ocr-RK3HJVCI.js} +10 -9
  65. package/dist/{image-ocr-TWNNVTZS.js.map → image-ocr-RK3HJVCI.js.map} +1 -1
  66. package/dist/index.cjs +338 -347
  67. package/dist/index.cjs.map +1 -1
  68. package/dist/index.js +42 -51
  69. package/dist/index.js.map +1 -1
  70. package/dist/mcp.js +22 -22
  71. package/dist/{model-bundle-THYUL7GG.js → model-bundle-VHRXG63R.js} +5 -5
  72. package/dist/{models-U22N4RXX.js → models-G3WA24SY.js} +5 -5
  73. package/dist/page-range-QHHFTL7X.cjs.map +1 -1
  74. package/dist/{parser-JOMFOZLH.cjs → parser-BGORCLIU.cjs} +449 -244
  75. package/dist/parser-BGORCLIU.cjs.map +1 -0
  76. package/dist/{parser-SCXRLOW7.js → parser-GFDGAVLV.js} +242 -37
  77. package/dist/parser-GFDGAVLV.js.map +1 -0
  78. package/dist/{parser-NKP2NCSV.js → parser-SOWTUOMK.js} +245 -40
  79. package/dist/parser-SOWTUOMK.js.map +1 -0
  80. package/dist/pdf-ocr-7IOOVR2I.js +20 -0
  81. package/dist/pdf-ocr-EJ2HNZN6.cjs +17 -0
  82. package/dist/pdf-ocr-EJ2HNZN6.cjs.map +1 -0
  83. package/dist/pdf-ocr-RACAZU3N.js +16 -0
  84. package/dist/{profile-io-UI3TZBYH.js → profile-io-Q2T47RVH.js} +3 -3
  85. package/dist/{rasterize-XMBV5H2I.js → rasterize-OAVMUTE6.js} +3 -3
  86. package/dist/{redact-doc-7ZZMHDBO.js → redact-doc-ECFOVR4X.js} +11 -11
  87. package/dist/{render-SWRTUDAV.js → render-NSKWZVTD.js} +7 -7
  88. package/dist/seal-A4MG7MPQ.js +10 -0
  89. package/dist/{setup-43JJEEU7.js → setup-REH2KZP2.js} +3 -3
  90. package/dist/visual-B56WQAGW.js +20 -0
  91. package/dist/{watch-NRATQ472.js → watch-JXDUZYBY.js} +12 -12
  92. package/package.json +1 -1
  93. package/dist/chunk-2I2RTJJ5.js.map +0 -1
  94. package/dist/chunk-2ZBLQVAS.cjs.map +0 -1
  95. package/dist/chunk-BJ6RYYXV.js.map +0 -1
  96. package/dist/chunk-HZV52V2X.cjs.map +0 -1
  97. package/dist/chunk-IXX3WHIE.js.map +0 -1
  98. package/dist/chunk-J2A46VCA.js.map +0 -1
  99. package/dist/chunk-SHRRD2TD.cjs.map +0 -1
  100. package/dist/chunk-V4BKT65D.cjs.map +0 -1
  101. package/dist/chunk-W7P4GPOV.js.map +0 -1
  102. package/dist/chunk-WN5YLP7H.cjs.map +0 -1
  103. package/dist/chunk-ZD5WNQNC.cjs.map +0 -1
  104. package/dist/chunk-ZN3LHNJG.js.map +0 -1
  105. package/dist/chunks-OQDRDICD.js +0 -10
  106. package/dist/formula-BQ5RW5XD.cjs.map +0 -1
  107. package/dist/image-ocr-VKIUBLBX.cjs.map +0 -1
  108. package/dist/parser-JOMFOZLH.cjs.map +0 -1
  109. package/dist/parser-NKP2NCSV.js.map +0 -1
  110. package/dist/parser-SCXRLOW7.js.map +0 -1
  111. package/dist/pdf-ocr-NF4AY5MI.cjs +0 -16
  112. package/dist/pdf-ocr-NF4AY5MI.cjs.map +0 -1
  113. package/dist/pdf-ocr-OLII3WAG.js +0 -15
  114. package/dist/pdf-ocr-VJL7ON2Q.js +0 -19
  115. package/dist/seal-UKKJZHKE.js +0 -10
  116. package/dist/visual-D2563HCJ.js +0 -20
  117. /package/dist/{-WOKB25R2.js.map → -DDAVBMHD.js.map} +0 -0
  118. /package/dist/{chunk-BGOR5GCF.js.map → chunk-274ZPMHK.js.map} +0 -0
  119. /package/dist/{chunk-6GLTGOP6.js.map → chunk-4IBY5LTJ.js.map} +0 -0
  120. /package/dist/{chunk-CAN5P6N6.js.map → chunk-7GR2GCJF.js.map} +0 -0
  121. /package/dist/{chunk-NES5U4JK.js.map → chunk-DUV7Y6IQ.js.map} +0 -0
  122. /package/dist/{chunk-3FZGL3IL.js.map → chunk-ELOPDQES.js.map} +0 -0
  123. /package/dist/{chunk-VGDTONTB.js.map → chunk-F5YVCJVF.js.map} +0 -0
  124. /package/dist/{chunk-RDBTOE5X.js.map → chunk-HRJJDNRD.js.map} +0 -0
  125. /package/dist/{chunk-KSJ7GKNQ.js.map → chunk-IAXGGQGD.js.map} +0 -0
  126. /package/dist/{chunk-RSDUH4XF.js.map → chunk-LGF2IO66.js.map} +0 -0
  127. /package/dist/{chunk-AZQWESRH.js.map → chunk-QVCHFCT2.js.map} +0 -0
  128. /package/dist/{chunk-UVUKT3IQ.js.map → chunk-TMJVD6FW.js.map} +0 -0
  129. /package/dist/{chunk-W3RADOLO.js.map → chunk-VTVK2JMI.js.map} +0 -0
  130. /package/dist/{chunk-PSJLB3SZ.js.map → chunk-XG4SYOZL.js.map} +0 -0
  131. /package/dist/{chunk-RRURZDEK.js.map → chunk-YCY2R4FM.js.map} +0 -0
  132. /package/dist/{chunk-5X7XWYR2.js.map → chunk-Z2PPDQK2.js.map} +0 -0
  133. /package/dist/{chunks-OQDRDICD.js.map → chunks-5QTTAT5T.js.map} +0 -0
  134. /package/dist/{model-bundle-THYUL7GG.js.map → model-bundle-VHRXG63R.js.map} +0 -0
  135. /package/dist/{models-U22N4RXX.js.map → models-G3WA24SY.js.map} +0 -0
  136. /package/dist/{pdf-ocr-OLII3WAG.js.map → pdf-ocr-7IOOVR2I.js.map} +0 -0
  137. /package/dist/{pdf-ocr-VJL7ON2Q.js.map → pdf-ocr-RACAZU3N.js.map} +0 -0
  138. /package/dist/{profile-io-UI3TZBYH.js.map → profile-io-Q2T47RVH.js.map} +0 -0
  139. /package/dist/{rasterize-XMBV5H2I.js.map → rasterize-OAVMUTE6.js.map} +0 -0
  140. /package/dist/{redact-doc-7ZZMHDBO.js.map → redact-doc-ECFOVR4X.js.map} +0 -0
  141. /package/dist/{render-SWRTUDAV.js.map → render-NSKWZVTD.js.map} +0 -0
  142. /package/dist/{seal-UKKJZHKE.js.map → seal-A4MG7MPQ.js.map} +0 -0
  143. /package/dist/{setup-43JJEEU7.js.map → setup-REH2KZP2.js.map} +0 -0
  144. /package/dist/{visual-D2563HCJ.js.map → visual-B56WQAGW.js.map} +0 -0
  145. /package/dist/{watch-NRATQ472.js.map → watch-JXDUZYBY.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
2
 
3
3
 
4
- var _chunkV4BKT65Dcjs = require('./chunk-V4BKT65D.cjs');
4
+ var _chunkSVNBZEL6cjs = require('./chunk-SVNBZEL6.cjs');
5
5
 
6
6
 
7
7
 
@@ -48,7 +48,6 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
48
48
 
49
49
 
50
50
 
51
- var _chunkWN5YLP7Hcjs = require('./chunk-WN5YLP7H.cjs');
52
51
 
53
52
 
54
53
 
@@ -58,12 +57,22 @@ var _chunkWN5YLP7Hcjs = require('./chunk-WN5YLP7H.cjs');
58
57
 
59
58
 
60
59
 
61
- var _chunk2ZBLQVAScjs = require('./chunk-2ZBLQVAS.cjs');
62
- require('./chunk-HZV52V2X.cjs');
60
+ var _chunkE2644XCOcjs = require('./chunk-E2644XCO.cjs');
63
61
 
64
62
 
65
63
 
66
- var _chunkSHRRD2TDcjs = require('./chunk-SHRRD2TD.cjs');
64
+
65
+
66
+
67
+
68
+
69
+
70
+ var _chunk3WLZOJIEcjs = require('./chunk-3WLZOJIE.cjs');
71
+ require('./chunk-AVIZ55NQ.cjs');
72
+
73
+
74
+
75
+ var _chunk3XSP7V5Pcjs = require('./chunk-3XSP7V5P.cjs');
67
76
 
68
77
 
69
78
  var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
@@ -79,41 +88,103 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
79
88
  const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
80
89
  return overlapW * overlapH >= b.width * b.height * 0.8;
81
90
  });
91
+ const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _2 => _2.text, 'optionalAccess', _3 => _3.match, 'call', _4 => _4(/[\p{L}\p{N}]/gu), 'optionalAccess', _5 => _5.length]), () => ( 0))) >= 2);
92
+ const axisFragments = rotatedAxisFragments(candidates);
82
93
  const accepted = candidates.filter((b) => {
83
- if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _2 => _2.text, 'optionalAccess', _3 => _3.match, 'call', _4 => _4(/[\p{L}\p{N}]/gu), 'optionalAccess', _5 => _5.length]), () => ( 0))) >= 2;
94
+ if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _6 => _6.text, 'optionalAccess', _7 => _7.match, 'call', _8 => _8(/[\p{L}\p{N}]/gu), 'optionalAccess', _9 => _9.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && supportedDiagramLabel(b, labels, region);
84
95
  const t = b.table;
85
96
  if (b.type !== "table" || !t) return false;
86
97
  if (t.rows === 1 && t.cols === 1) {
87
- const text = _nullishCoalesce(_optionalChain([t, 'access', _6 => _6.cells, 'access', _7 => _7[0], 'optionalAccess', _8 => _8[0], 'optionalAccess', _9 => _9.text]), () => ( ""));
88
- return (_nullishCoalesce(_optionalChain([text, 'access', _10 => _10.match, 'call', _11 => _11(/\n/g), 'optionalAccess', _12 => _12.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _13 => _13.match, 'call', _14 => _14(/\d/g), 'optionalAccess', _15 => _15.length]), () => ( 0))) >= text.length * 0.25;
98
+ const text = _nullishCoalesce(_optionalChain([t, 'access', _10 => _10.cells, 'access', _11 => _11[0], 'optionalAccess', _12 => _12[0], 'optionalAccess', _13 => _13.text]), () => ( ""));
99
+ return (_nullishCoalesce(_optionalChain([text, 'access', _14 => _14.match, 'call', _15 => _15(/\n/g), 'optionalAccess', _16 => _16.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _17 => _17.match, 'call', _18 => _18(/\d/g), 'optionalAccess', _19 => _19.length]), () => ( 0))) >= text.length * 0.25;
89
100
  }
90
- const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _16 => _16.cells, 'access', _17 => _17[0], 'optionalAccess', _18 => _18.filter, 'call', _19 => _19((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _20 => _20.length]), () => ( 0));
101
+ const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _20 => _20.cells, 'access', _21 => _21[0], 'optionalAccess', _22 => _22.filter, 'call', _23 => _23((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _24 => _24.length]), () => ( 0));
91
102
  return t.rows >= 2 && t.cols >= 2 && headerLabels >= t.cols * 0.75 && t.cells.slice(1).some((row) => row.filter((c) => c.text.trim()).length >= 2);
92
103
  });
93
104
  const selected = candidates.flatMap((b) => accepted.includes(b) ? [b] : b.type === "table" && b.table ? rowParagraphs(b).filter((p) => /[\p{L}\p{N}]{2}/u.test(_nullishCoalesce(p.text, () => ( "")))) : []);
94
- for (const block of selected) {
105
+ const hasOriginal = (block) => blocks.some((existing) => {
95
106
  const b = block.bbox;
96
- const hasOriginal = blocks.some((existing) => {
97
- if (existing.pageNumber !== page || !existing.bbox || existing.type === "image") return false;
98
- const e = existing.bbox;
99
- const x = Math.max(0, Math.min(e.x + e.width, b.x + b.width) - Math.max(e.x, b.x));
100
- const y = Math.max(0, Math.min(e.y + e.height, b.y + b.height) - Math.max(e.y, b.y));
101
- return x * y > b.width * b.height * 0.2;
102
- });
103
- if (hasOriginal) continue;
104
- const index = blocks.findIndex((existing) => {
105
- const e = existing.bbox;
106
- if (existing.pageNumber !== page || !e) return false;
107
- const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
108
- return e.y < b.y || beside;
109
- });
110
- const placed = block.type === "paragraph" ? { ...block, style: void 0 } : block;
111
- blocks.splice(index < 0 ? blocks.length : index, 0, placed);
112
- added++;
107
+ if (existing.pageNumber !== page || !existing.bbox || existing.type === "image") return false;
108
+ const e = existing.bbox;
109
+ const x = Math.max(0, Math.min(e.x + e.width, b.x + b.width) - Math.max(e.x, b.x));
110
+ const y = Math.max(0, Math.min(e.y + e.height, b.y + b.height) - Math.max(e.y, b.y));
111
+ return x * y > b.width * b.height * 0.2;
112
+ });
113
+ const selectedSet = new Set(selected), seen = /* @__PURE__ */ new Set();
114
+ for (const block of selected) {
115
+ if (seen.has(block)) continue;
116
+ const frame = _chunkE2644XCOcjs.FRAME_READING_UNITS.get(block);
117
+ const source = _optionalChain([frame, 'optionalAccess', _25 => _25.blocks, 'access', _26 => _26.every, 'call', _27 => _27((member) => selectedSet.has(member))]) ? frame.blocks : [block];
118
+ source.forEach((member) => seen.add(member));
119
+ const available = source.filter((member) => !hasOriginal(member));
120
+ const units = frame && available.length === source.length && source === frame.blocks ? [{ blocks: available, bbox: frame.bbox, atomic: true }] : available.map((member) => ({ blocks: [member], bbox: member.bbox, atomic: false }));
121
+ for (const unit of units) {
122
+ const b = unit.bbox;
123
+ const index = blocks.findIndex((existing) => {
124
+ const e = _nullishCoalesce(_optionalChain([_chunkE2644XCOcjs.FRAME_READING_UNITS, 'access', _28 => _28.get, 'call', _29 => _29(existing), 'optionalAccess', _30 => _30.bbox]), () => ( existing.bbox));
125
+ if (existing.pageNumber !== page || !e) return false;
126
+ const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
127
+ return e.y < b.y || beside;
128
+ });
129
+ const placed = unit.blocks.map((member) => member.type === "paragraph" ? { ...member, style: void 0 } : member);
130
+ if (unit.atomic) _chunkE2644XCOcjs.recordFrameReadingUnit.call(void 0, placed, unit.bbox);
131
+ blocks.splice(index < 0 ? blocks.length : index, 0, ...placed);
132
+ added += placed.length;
133
+ }
113
134
  }
114
135
  }
115
136
  return added;
116
137
  }
138
+ function supportedDiagramLabel(block, labels, region) {
139
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _31 => _31.text, 'optionalAccess', _32 => _32.trim, 'call', _33 => _33()]), () => ( ""));
140
+ if (!b || !/^[\p{L}\p{N}]$/u.test(text) || b.height < 4 || b.width < 1 || b.width > b.height * 2 || b.x < region.x1 || b.y < region.y1 || b.x + b.width > region.x2 || b.y + b.height > region.y2 || b.width * b.height > (region.x2 - region.x1) * (region.y2 - region.y1) * 5e-3 || labels.length < 3 || !labels.some((l) => /\p{L}{3}/u.test(_nullishCoalesce(l.text, () => ( "")))) || labels.filter((l) => !/\p{L}/u.test(_nullishCoalesce(l.text, () => ( ""))) && (_nullishCoalesce(_optionalChain([l, 'access', _34 => _34.text, 'optionalAccess', _35 => _35.match, 'call', _36 => _36(/\p{N}/gu), 'optionalAccess', _37 => _37.length]), () => ( 0))) >= 2).length < 2) return false;
141
+ let above = false, below = false;
142
+ for (const label of labels) {
143
+ const a = label.bbox, em = Math.max(b.height, a.height);
144
+ if (b.x + b.width < a.x - em * 2 || b.x > a.x + a.width + em * 2) continue;
145
+ const upperGap = a.y - (b.y + b.height), lowerGap = b.y - (a.y + a.height);
146
+ if (upperGap >= 0 && upperGap <= em * 4) above = true;
147
+ if (lowerGap >= 0 && lowerGap <= em * 4) below = true;
148
+ }
149
+ return above && below;
150
+ }
151
+ function rotatedAxisFragments(candidates) {
152
+ const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
153
+ const axes = [];
154
+ for (const block of paragraphs) {
155
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _38 => _38.text, 'optionalAccess', _39 => _39.trim, 'call', _40 => _40()]), () => ( ""));
156
+ if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
157
+ const axis = axes.find((a) => Math.abs(a[0].bbox.x + a[0].bbox.width - b.x - b.width) <= Math.max(a[0].bbox.height, b.height) * 0.5);
158
+ if (axis) axis.push(block);
159
+ else axes.push([block]);
160
+ }
161
+ const fragments = /* @__PURE__ */ new Set();
162
+ const aligned = (a, b) => {
163
+ const x = a.bbox, y = b.bbox, tolerance = Math.max(x.height, y.height) * 0.5;
164
+ return Math.abs(x.x - y.x) <= tolerance || Math.abs(x.x + x.width - y.x - y.width) <= tolerance;
165
+ };
166
+ for (const axis of axes) {
167
+ if (axis.length < 3) continue;
168
+ const bottom = Math.min(...axis.map((a) => a.bbox.y)), top = Math.max(...axis.map((a) => a.bbox.y + a.bbox.height));
169
+ const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
170
+ if (top - bottom < em * 6) continue;
171
+ const left = paragraphs.filter((block) => {
172
+ const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _41 => _41.text, 'optionalAccess', _42 => _42.trim, 'call', _43 => _43()]), () => ( ""));
173
+ return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _44 => _44.match, 'call', _45 => _45(/[\p{L}\p{N}]/gu), 'optionalAccess', _46 => _46.length]), () => ( 0))) <= 3 && b.width <= b.height * 3 && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && b.y >= bottom && b.y + b.height <= top;
174
+ });
175
+ const stack = left.filter((a) => left.some((b) => {
176
+ if (a === b || !aligned(a, b)) return false;
177
+ const x = a.bbox, y = b.bbox, gap = Math.max(x.y, y.y) - Math.min(x.y + x.height, y.y + y.height);
178
+ return gap >= -Math.min(x.height, y.height) * 0.5 && gap <= Math.max(x.height, y.height);
179
+ }));
180
+ if (stack.length < 2) continue;
181
+ for (const block of paragraphs) {
182
+ const b = block.bbox;
183
+ if (b.y >= bottom && b.y + b.height <= top && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && /^[\p{L}\p{N}]$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _47 => _47.text, 'optionalAccess', _48 => _48.trim, 'call', _49 => _49()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
184
+ }
185
+ }
186
+ return fragments;
187
+ }
117
188
  function rowParagraphs(block) {
118
189
  const t = block.table, b = block.bbox;
119
190
  const h = b.height / t.rows;
@@ -218,7 +289,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
218
289
  let imgData = null;
219
290
  let dedupeId = null;
220
291
  if (op === _pdfmjs.OPS.paintImageXObject || op === _pdfmjs.OPS.paintImageXObjectRepeat) {
221
- const objId = _optionalChain([argsArray, 'access', _21 => _21[i], 'optionalAccess', _22 => _22[0]]);
292
+ const objId = _optionalChain([argsArray, 'access', _50 => _50[i], 'optionalAccess', _51 => _51[0]]);
222
293
  if (typeof objId !== "string" || pageSeenIds.has(objId)) continue;
223
294
  pageSeenIds.add(objId);
224
295
  dedupeId = objId;
@@ -235,16 +306,16 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
235
306
  if (dedupeId) {
236
307
  imgData = await resolveImgData(page, dedupeId);
237
308
  } else {
238
- imgData = _optionalChain([argsArray, 'access', _23 => _23[i], 'optionalAccess', _24 => _24[0]]);
309
+ imgData = _optionalChain([argsArray, 'access', _52 => _52[i], 'optionalAccess', _53 => _53[0]]);
239
310
  }
240
- if (!_optionalChain([imgData, 'optionalAccess', _25 => _25.data]) || !imgData.width || !imgData.height) continue;
311
+ if (!_optionalChain([imgData, 'optionalAccess', _54 => _54.data]) || !imgData.width || !imgData.height) continue;
241
312
  const { width: w, height: h } = imgData;
242
313
  if (w < MIN_DIM || h < MIN_DIM) continue;
243
314
  if (w * h > MAX_PIXELS) {
244
315
  warnings.push({ page: pageNumber, message: `\uC774\uBBF8\uC9C0 \uD06C\uAE30 \uCD08\uACFC\uB85C \uCD94\uCD9C \uC0DD\uB7B5 (${w}\xD7${h})`, code: "SKIPPED_IMAGE" });
245
316
  continue;
246
317
  }
247
- const globalId = _optionalChain([dedupeId, 'optionalAccess', _26 => _26.startsWith, 'call', _27 => _27("g_")]) ? dedupeId : void 0;
318
+ const globalId = _optionalChain([dedupeId, 'optionalAccess', _55 => _55.startsWith, 'call', _56 => _56("g_")]) ? dedupeId : void 0;
248
319
  let hash = globalId ? state.globalKeys.get(globalId) : void 0;
249
320
  if (hash === void 0) {
250
321
  hash = `${w}x${h}k${_nullishCoalesce(imgData.kind, () => ( "?"))}h${contentHash(imgData.data)}${dedupeId ? "" : "inline"}`;
@@ -257,7 +328,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
257
328
  const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
258
329
  state.seen.set(hash, filename);
259
330
  if (withBytes) {
260
- const png = _chunkV4BKT65Dcjs.encodePng.call(void 0, w, h, rgba);
331
+ const png = _chunkSVNBZEL6cjs.encodePng.call(void 0, w, h, rgba);
261
332
  state.totalBytes += png.length;
262
333
  images.push({ filename, data: png, mimeType: "image/png" });
263
334
  }
@@ -695,7 +766,7 @@ function anchorsOf(table) {
695
766
  for (let r = 0; r < table.rows; r++) {
696
767
  for (let c = 0; c < table.cols; c++) {
697
768
  if (covered.has(r * 1e5 + c)) continue;
698
- const cell = _optionalChain([table, 'access', _28 => _28.cells, 'access', _29 => _29[r], 'optionalAccess', _30 => _30[c]]);
769
+ const cell = _optionalChain([table, 'access', _57 => _57.cells, 'access', _58 => _58[r], 'optionalAccess', _59 => _59[c]]);
699
770
  if (!cell) continue;
700
771
  out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
701
772
  for (let dr = 0; dr < cell.rowSpan; dr++) {
@@ -772,24 +843,24 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
772
843
  if (r + dr < rows) owner[r + dr][dc] = placed;
773
844
  }
774
845
  grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
775
- const lines = _chunkWN5YLP7Hcjs.CELL_LINES.get(a.cell);
776
- if (lines) _chunkWN5YLP7Hcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
777
- if (_chunkWN5YLP7Hcjs.IMAGE_CELLS.has(a.cell)) _chunkWN5YLP7Hcjs.IMAGE_CELLS.add(grid[r][c1]);
778
- const edges = _chunk2ZBLQVAScjs.CELL_EDGES.get(a.cell);
846
+ const lines = _chunkE2644XCOcjs.CELL_LINES.get(a.cell);
847
+ if (lines) _chunkE2644XCOcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
848
+ if (_chunkE2644XCOcjs.IMAGE_CELLS.has(a.cell)) _chunkE2644XCOcjs.IMAGE_CELLS.add(grid[r][c1]);
849
+ const edges = _chunk3WLZOJIEcjs.CELL_EDGES.get(a.cell);
779
850
  if (edges) {
780
- _chunk2ZBLQVAScjs.CELL_EDGES.set(grid[r][c1], edges);
851
+ _chunk3WLZOJIEcjs.CELL_EDGES.set(grid[r][c1], edges);
781
852
  edged = true;
782
853
  }
783
854
  return true;
784
855
  };
785
- for (const a of pa) if (!_chunkWN5YLP7Hcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
856
+ for (const a of pa) if (!_chunkE2644XCOcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
786
857
  for (const a of ca) {
787
- if (a.r < skip || _chunkWN5YLP7Hcjs.FILLER_CELLS.has(a.cell)) continue;
858
+ if (a.r < skip || _chunkE2644XCOcjs.FILLER_CELLS.has(a.cell)) continue;
788
859
  if (!place(a, cxU, prev.rows - skip, dx)) return null;
789
860
  }
790
861
  const first = prev.rows;
791
862
  for (let c = 0; c < cols; c++) {
792
- const above = _optionalChain([owner, 'access', _31 => _31[first - 1], 'optionalAccess', _32 => _32[c]]);
863
+ const above = _optionalChain([owner, 'access', _60 => _60[first - 1], 'optionalAccess', _61 => _61[c]]);
793
864
  if (!above) continue;
794
865
  let r = first;
795
866
  while (r < rows && owner[r][c] === null) r++;
@@ -808,9 +879,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
808
879
  const grown = { ...above, rs: newRs };
809
880
  for (let rr = above.r; rr < above.r + newRs; rr++) for (let dc = above.c; dc < above.c + above.cs; dc++) owner[rr][dc] = grown;
810
881
  }
811
- for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkWN5YLP7Hcjs.FILLER_CELLS.add(grid[r][c]);
882
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkE2644XCOcjs.FILLER_CELLS.add(grid[r][c]);
812
883
  if (edged) {
813
- for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunk2ZBLQVAScjs.CELL_EDGES.set(grid[r][c], _chunkWN5YLP7Hcjs.NO_EDGES);
884
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunk3WLZOJIEcjs.CELL_EDGES.set(grid[r][c], _chunkE2644XCOcjs.NO_EDGES);
814
885
  }
815
886
  for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
816
887
  let r = prev.rows;
@@ -819,7 +890,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
819
890
  for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
820
891
  }
821
892
  const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
822
- const pr = _chunkWN5YLP7Hcjs.ROW_RULES.get(prev), cr = _chunkWN5YLP7Hcjs.ROW_RULES.get(curr);
893
+ const pr = _chunkE2644XCOcjs.ROW_RULES.get(prev), cr = _chunkE2644XCOcjs.ROW_RULES.get(curr);
823
894
  const shifted = dx !== 0;
824
895
  const cut = {
825
896
  open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
@@ -830,7 +901,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
830
901
  if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U)) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
831
902
  if (pr && cr) {
832
903
  const cutRuled = pr.bottom || cr.top;
833
- _chunkWN5YLP7Hcjs.ROW_RULES.set(table, { top: pr.top, bottom: cr.bottom, innerRuled: pr.innerRuled + cr.innerRuled + (!split && cutRuled ? 1 : 0), innerOpen: pr.innerOpen + cr.innerOpen + (!split && !cutRuled ? 1 : 0) });
904
+ _chunkE2644XCOcjs.ROW_RULES.set(table, { top: pr.top, bottom: cr.bottom, innerRuled: pr.innerRuled + cr.innerRuled + (!split && cutRuled ? 1 : 0), innerOpen: pr.innerOpen + cr.innerOpen + (!split && !cutRuled ? 1 : 0) });
834
905
  }
835
906
  return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
836
907
  }
@@ -884,8 +955,8 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
884
955
  if (!crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
885
956
  if (!straddles && !midWord) continue;
886
957
  if (u.r >= last && d.rs < 2) continue;
887
- const U = _chunkWN5YLP7Hcjs.CELL_LINES.get(a);
888
- if (!_optionalChain([U, 'optionalAccess', _33 => _33.length]) || !hasContent(b)) continue;
958
+ const U = _chunkE2644XCOcjs.CELL_LINES.get(a);
959
+ if (!_optionalChain([U, 'optionalAccess', _62 => _62.length]) || !hasContent(b)) continue;
889
960
  if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
890
961
  if (U.length > STRADDLE_MAX_LINES) continue;
891
962
  const lu = U[U.length - 1];
@@ -931,8 +1002,8 @@ function nextItemHead(prev, next) {
931
1002
  return false;
932
1003
  }
933
1004
  function continuesAcross(u, d, x1, x2) {
934
- const U = _chunkWN5YLP7Hcjs.CELL_LINES.get(u), D = _chunkWN5YLP7Hcjs.CELL_LINES.get(d);
935
- if (!_optionalChain([U, 'optionalAccess', _34 => _34.length]) || !_optionalChain([D, 'optionalAccess', _35 => _35.length])) return false;
1005
+ const U = _chunkE2644XCOcjs.CELL_LINES.get(u), D = _chunkE2644XCOcjs.CELL_LINES.get(d);
1006
+ if (!_optionalChain([U, 'optionalAccess', _63 => _63.length]) || !_optionalChain([D, 'optionalAccess', _64 => _64.length])) return false;
936
1007
  const last = U[U.length - 1];
937
1008
  const fs = last.h || 10;
938
1009
  let minL = Infinity, maxR = -Infinity;
@@ -949,7 +1020,7 @@ function continuesAcross(u, d, x1, x2) {
949
1020
  if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
950
1021
  const indented = last.l - minL >= HANGING_MIN * fs;
951
1022
  if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
952
- const newItem = _chunkWN5YLP7Hcjs.startsNewItem.call(void 0, u.text, d.text);
1023
+ const newItem = _chunkE2644XCOcjs.startsNewItem.call(void 0, u.text, d.text);
953
1024
  const all = D.length ? U.concat(D) : U;
954
1025
  const leftAligned = (l) => maxR - l.r > SHORT_LINE_GAP * fs && (l.l - minL <= fs || !newItem && all.some((o) => o !== l && Math.abs(o.l - l.l) <= HANGING_TOL && Math.abs(o.r - l.r) >= HANGING_MIN * fs));
955
1026
  const hanging = U.length >= 2 && U.every((l) => maxR - l.r <= FULL_LINE_TOL * fs) && indented && Math.abs(D[0].l - last.l) <= HANGING_TOL;
@@ -966,12 +1037,12 @@ function outlineContinues(u, d) {
966
1037
  return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
967
1038
  }
968
1039
  function lineEnded(c, x1, x2, next) {
969
- const L = _chunkWN5YLP7Hcjs.CELL_LINES.get(c);
1040
+ const L = _chunkE2644XCOcjs.CELL_LINES.get(c);
970
1041
  if (!L || L.length !== 1) return false;
971
1042
  const l = L[0], h = l.h || 10;
972
- const d0 = next ? _optionalChain([_chunkWN5YLP7Hcjs.CELL_LINES, 'access', _36 => _36.get, 'call', _37 => _37(next), 'optionalAccess', _38 => _38[0]]) : void 0;
1043
+ const d0 = next ? _optionalChain([_chunkE2644XCOcjs.CELL_LINES, 'access', _65 => _65.get, 'call', _66 => _66(next), 'optionalAccess', _67 => _67[0]]) : void 0;
973
1044
  if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
974
- return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _39 => _39.text]), () => ( "")))) * h;
1045
+ return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _68 => _68.text]), () => ( "")))) * h;
975
1046
  }
976
1047
  function firstWordUnits(text) {
977
1048
  const word = _nullishCoalesce(flowText(text).trim().replace(/^([(\[「『<〈])\s+/, "$1").split(/\s+/)[0], () => ( ""));
@@ -980,14 +1051,14 @@ function firstWordUnits(text) {
980
1051
  return units;
981
1052
  }
982
1053
  function appendCell(a, b) {
983
- if (_optionalChain([a, 'access', _40 => _40.blocks, 'optionalAccess', _41 => _41.length]) || _optionalChain([b, 'access', _42 => _42.blocks, 'optionalAccess', _43 => _43.length])) {
984
- const asBlocks = (c) => _optionalChain([c, 'access', _44 => _44.blocks, 'optionalAccess', _45 => _45.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
1054
+ if (_optionalChain([a, 'access', _69 => _69.blocks, 'optionalAccess', _70 => _70.length]) || _optionalChain([b, 'access', _71 => _71.blocks, 'optionalAccess', _72 => _72.length])) {
1055
+ const asBlocks = (c) => _optionalChain([c, 'access', _73 => _73.blocks, 'optionalAccess', _74 => _74.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
985
1056
  a.blocks = [...asBlocks(a), ...asBlocks(b)];
986
1057
  }
987
1058
  if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
988
- _chunkWN5YLP7Hcjs.joinCellEdges.call(void 0, a, b);
1059
+ _chunkE2644XCOcjs.joinCellEdges.call(void 0, a, b);
989
1060
  }
990
- var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _46 => _46.blocks, 'optionalAccess', _47 => _47.length]) || _chunkWN5YLP7Hcjs.IMAGE_CELLS.has(cell);
1061
+ var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _75 => _75.blocks, 'optionalAccess', _76 => _76.length]) || _chunkE2644XCOcjs.IMAGE_CELLS.has(cell);
991
1062
  var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
992
1063
  var batchim = (ch) => {
993
1064
  const k = ch.charCodeAt(0) - 44032;
@@ -995,13 +1066,13 @@ var batchim = (ch) => {
995
1066
  };
996
1067
  function clauseContinues(u, d) {
997
1068
  const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
998
- if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkWN5YLP7Hcjs.startsNewItem.call(void 0, u.text, head)) return false;
1069
+ if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkE2644XCOcjs.startsNewItem.call(void 0, u.text, head)) return false;
999
1070
  const last = tail[tail.length - 1], before = tail[tail.length - 2];
1000
1071
  return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
1001
1072
  }
1002
1073
  function wordOverflows(u, d, x1, x2) {
1003
- const U = _chunkWN5YLP7Hcjs.CELL_LINES.get(u);
1004
- if (!_optionalChain([U, 'optionalAccess', _48 => _48.length]) || _chunkWN5YLP7Hcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
1074
+ const U = _chunkE2644XCOcjs.CELL_LINES.get(u);
1075
+ if (!_optionalChain([U, 'optionalAccess', _77 => _77.length]) || _chunkE2644XCOcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
1005
1076
  const last = U[U.length - 1], units = firstWordUnits(d.text);
1006
1077
  return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
1007
1078
  }
@@ -1023,7 +1094,7 @@ function listContinues(u, d, multi = false) {
1023
1094
  const marks = u.text.split("\n").map((l) => itemMark(l.trim()));
1024
1095
  let last = -1, count = 0;
1025
1096
  marks.forEach((m, i) => {
1026
- if (_optionalChain([m, 'optionalAccess', _49 => _49.style]) === head.style) {
1097
+ if (_optionalChain([m, 'optionalAccess', _78 => _78.style]) === head.style) {
1027
1098
  last = i;
1028
1099
  count++;
1029
1100
  }
@@ -1061,7 +1132,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
1061
1132
  if (!carriedSplit) {
1062
1133
  const norm = (c) => flowText(c.text).replace(/\s+/g, "");
1063
1134
  if (pairs.some(([u, d]) => hasContent(d.cell) && norm(cell(d)) !== norm(cell(u)) && lineEnded(cell(u), colXs[u.c], colXs[u.c + u.cs], cell(d)))) return false;
1064
- const oneLine = (c) => _optionalChain([_chunkWN5YLP7Hcjs.CELL_LINES, 'access', _50 => _50.get, 'call', _51 => _51(c), 'optionalAccess', _52 => _52.length]) === 1;
1135
+ const oneLine = (c) => _optionalChain([_chunkE2644XCOcjs.CELL_LINES, 'access', _79 => _79.get, 'call', _80 => _80(c), 'optionalAccess', _81 => _81.length]) === 1;
1065
1136
  if (pairs.some(([u, d]) => nextItemHead(cell(u).text, cell(d).text)) && pairs.some(([u, d]) => hasContent(u.cell) && hasContent(d.cell) && oneLine(cell(u)) && oneLine(cell(d)) && norm(cell(u)) !== norm(cell(d)))) return false;
1066
1137
  const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d));
1067
1138
  if (!(cut.open && !newCell)) {
@@ -1092,8 +1163,8 @@ function besideOwn(b, p, c) {
1092
1163
  }
1093
1164
  var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
1094
1165
  function pageNumberBetween(b, p, c, pageHeights) {
1095
- if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _53 => _53.text, 'optionalAccess', _54 => _54.trim, 'call', _55 => _55()]), () => ( "")))) return false;
1096
- const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _56 => _56.get, 'call', _57 => _57(b.pageNumber)]) : void 0;
1166
+ if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _82 => _82.text, 'optionalAccess', _83 => _83.trim, 'call', _84 => _84()]), () => ( "")))) return false;
1167
+ const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _85 => _85.get, 'call', _86 => _86(b.pageNumber)]) : void 0;
1097
1168
  if (!h) return false;
1098
1169
  if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
1099
1170
  if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
@@ -1116,14 +1187,14 @@ function insideTable(b, t) {
1116
1187
  return b.bbox.x >= o.x - 1 && b.bbox.x + b.bbox.width <= o.x + o.width + 1 && b.bbox.y >= o.y - 1 && b.bbox.y + b.bbox.height <= o.y + o.height + 1;
1117
1188
  }
1118
1189
  function startsWithUnitRow(table) {
1119
- return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _58 => _58.cells, 'access', _59 => _59[0], 'optionalAccess', _60 => _60[0], 'optionalAccess', _61 => _61.text]), () => ( ""))) && _optionalChain([table, 'access', _62 => _62.cells, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.slice, 'call', _65 => _65(1), 'access', _66 => _66.every, 'call', _67 => _67((c) => !c.text.trim())]);
1190
+ return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _87 => _87.cells, 'access', _88 => _88[0], 'optionalAccess', _89 => _89[0], 'optionalAccess', _90 => _90.text]), () => ( ""))) && _optionalChain([table, 'access', _91 => _91.cells, 'access', _92 => _92[0], 'optionalAccess', _93 => _93.slice, 'call', _94 => _94(1), 'access', _95 => _95.every, 'call', _96 => _96((c) => !c.text.trim())]);
1120
1191
  }
1121
1192
  function sameHeadShape(a, b) {
1122
1193
  if (!a || !b || a.length !== b.length) return false;
1123
1194
  let tall = false;
1124
1195
  for (let c = 0; c < a.length; c++) {
1125
1196
  if (a[c].colSpan !== b[c].colSpan || a[c].rowSpan !== b[c].rowSpan) return false;
1126
- if (a[c].rowSpan >= 2 && a[c].text.trim()) tall = true;
1197
+ if (a[c].rowSpan >= 2 && a[c].text.trim() && b[c].text.trim()) tall = true;
1127
1198
  }
1128
1199
  return tall;
1129
1200
  }
@@ -1136,7 +1207,7 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1136
1207
  const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
1137
1208
  while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
1138
1209
  const curr = blocks[j];
1139
- const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _68 => _68.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
1210
+ const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _97 => _97.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
1140
1211
  if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
1141
1212
  if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
1142
1213
  if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
@@ -1145,38 +1216,39 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1145
1216
  placeJoined(blocks, i, j, joined);
1146
1217
  continue;
1147
1218
  }
1148
- if (_chunkWN5YLP7Hcjs.EMPTY_PARTS.has(curr.table)) {
1219
+ if (_chunkE2644XCOcjs.EMPTY_PARTS.has(curr.table)) {
1149
1220
  blocks.splice(j, 1);
1150
1221
  i++;
1151
1222
  continue;
1152
1223
  }
1153
1224
  if (joined === null) continue;
1154
- if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkWN5YLP7Hcjs.EMPTY_PARTS.has(prev.table)) continue;
1225
+ if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkE2644XCOcjs.EMPTY_PARTS.has(prev.table)) continue;
1155
1226
  const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
1156
1227
  const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
1157
1228
  const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
1158
1229
  if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
1159
- const px = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(prev.table), cx = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(curr.table);
1160
- if (px && cx && !shiftedSame(px, cx, !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(prev.table) && !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(curr.table))) continue;
1230
+ const px = _chunkE2644XCOcjs.TABLE_COLXS.get(prev.table), cx = _chunkE2644XCOcjs.TABLE_COLXS.get(curr.table);
1231
+ if (px && cx && !shiftedSame(px, cx, !_chunkE2644XCOcjs.CLIP_TABLES.has(prev.table) && !_chunkE2644XCOcjs.CLIP_TABLES.has(curr.table))) continue;
1161
1232
  if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
1162
1233
  let currCells = curr.table.cells;
1163
- if (currCells.length > 1 && prev.table.cells.length > 0 && rowTextsEqual(prev.table.cells[0], currCells[0])) {
1164
- currCells = currCells.slice(1);
1165
- }
1234
+ const headRows = repeatedHeaderRows(prev.table, curr.table);
1235
+ if (headRows < 0) continue;
1236
+ if (headRows) currCells = currCells.slice(headRows);
1237
+ if (currCells.length) continueRowSpans(prev.table.cells, currCells);
1166
1238
  if (currCells.length === 0) {
1167
1239
  blocks.splice(j, 1);
1168
1240
  continue;
1169
1241
  }
1170
- if (px && cx && !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(prev.table) && !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(curr.table) && currCells.length < curr.table.cells.length && curr.table.cells[0].filter((c) => c.text.trim()).length >= 2 && prev.table.cells.at(-1).concat(currCells[0]).every((c) => c.rowSpan === 1 && c.colSpan === 1 && _chunkWN5YLP7Hcjs.CELL_LINES.has(c))) {
1242
+ if (px && cx && !_chunkE2644XCOcjs.CLIP_TABLES.has(prev.table) && !_chunkE2644XCOcjs.CLIP_TABLES.has(curr.table) && currCells.length < curr.table.cells.length && curr.table.cells[0].filter((c) => c.text.trim()).length >= 2 && prev.table.cells.at(-1).concat(currCells[0]).every((c) => c.rowSpan === 1 && c.colSpan === 1 && _chunkE2644XCOcjs.CELL_LINES.has(c))) {
1171
1243
  const dx = px[0] - cx[0];
1172
1244
  const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
1173
- if (_optionalChain([part, 'optionalAccess', _69 => _69.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
1245
+ if (_optionalChain([part, 'optionalAccess', _98 => _98.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
1174
1246
  const last = prev.table.rows - 1;
1175
1247
  for (let c = 0; c < part.table.cols; c++) {
1176
- const U = _chunkWN5YLP7Hcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkWN5YLP7Hcjs.CELL_LINES.get(currCells[0][c]);
1177
- _chunkWN5YLP7Hcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
1248
+ const U = _chunkE2644XCOcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkE2644XCOcjs.CELL_LINES.get(currCells[0][c]);
1249
+ _chunkE2644XCOcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
1178
1250
  }
1179
- _chunkWN5YLP7Hcjs.TABLE_COLXS.set(part.table, part.colXs);
1251
+ _chunkE2644XCOcjs.TABLE_COLXS.set(part.table, part.colXs);
1180
1252
  placeJoined(blocks, i, j, part.table);
1181
1253
  continue;
1182
1254
  }
@@ -1189,20 +1261,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1189
1261
  caption: prev.table.caption,
1190
1262
  ...prev.table.renderAsTable ? { renderAsTable: true } : {}
1191
1263
  };
1192
- if (_nullishCoalesce(px, () => ( cx))) _chunkWN5YLP7Hcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
1193
- if (_chunkWN5YLP7Hcjs.CLIP_TABLES.has(prev.table) || _chunkWN5YLP7Hcjs.CLIP_TABLES.has(curr.table)) _chunkWN5YLP7Hcjs.CLIP_TABLES.add(merged);
1264
+ if (_nullishCoalesce(px, () => ( cx))) _chunkE2644XCOcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
1265
+ if (_chunkE2644XCOcjs.CLIP_TABLES.has(prev.table) || _chunkE2644XCOcjs.CLIP_TABLES.has(curr.table)) _chunkE2644XCOcjs.CLIP_TABLES.add(merged);
1194
1266
  placeJoined(blocks, i, j, merged);
1195
1267
  }
1196
1268
  for (let i = blocks.length - 1; i >= 0; i--) {
1197
1269
  const t = blocks[i].table;
1198
- if (blocks[i].type === "table" && t && _chunkWN5YLP7Hcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
1270
+ if (blocks[i].type === "table" && t && _chunkE2644XCOcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
1199
1271
  }
1200
1272
  }
1201
1273
  function mergeColumnFlow(blocks, pageHeights, lex) {
1202
1274
  if (!pageHeights) return;
1203
1275
  for (let i = 0; i < blocks.length; i++) {
1204
1276
  const L = blocks[i];
1205
- if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(L.table) || _chunkWN5YLP7Hcjs.EMPTY_PARTS.has(L.table)) continue;
1277
+ if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkE2644XCOcjs.CLIP_TABLES.has(L.table) || _chunkE2644XCOcjs.EMPTY_PARTS.has(L.table)) continue;
1206
1278
  const ph = pageHeights.get(L.pageNumber);
1207
1279
  if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
1208
1280
  let s0 = i, s1 = i;
@@ -1231,12 +1303,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
1231
1303
  }
1232
1304
  function joinClipParts(prev, curr, pageHeights, lex) {
1233
1305
  const pt = prev.table, ct = curr.table;
1234
- if (!_chunkWN5YLP7Hcjs.CLIP_TABLES.has(pt) || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(ct)) return null;
1235
- const px = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(pt), cx = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(ct);
1306
+ if (!_chunkE2644XCOcjs.CLIP_TABLES.has(pt) || !_chunkE2644XCOcjs.CLIP_TABLES.has(ct)) return null;
1307
+ const px = _chunkE2644XCOcjs.TABLE_COLXS.get(pt), cx = _chunkE2644XCOcjs.TABLE_COLXS.get(ct);
1236
1308
  if (!px || !cx) return null;
1237
1309
  let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
1238
1310
  if (!shiftedSame(px, cx, false)) {
1239
- if (!_optionalChain([pageHeights, 'optionalAccess', _70 => _70.get, 'call', _71 => _71(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _72 => _72.get, 'call', _73 => _73(curr.pageNumber)])) return null;
1311
+ if (!_optionalChain([pageHeights, 'optionalAccess', _99 => _99.get, 'call', _100 => _100(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _101 => _101.get, 'call', _102 => _102(curr.pageNumber)])) return null;
1240
1312
  dx = px[px.length - 1] - cx[cx.length - 1];
1241
1313
  within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
1242
1314
  if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
@@ -1248,19 +1320,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
1248
1320
  const inner = b.slice(1, -1).map((x) => x + dx);
1249
1321
  return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
1250
1322
  };
1251
- foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkWN5YLP7Hcjs.PART_COLXS.get(ct), () => ( cx))) && (headingRow(_nullishCoalesce(ct.cells[0], () => ( []))) || px.length > FOREIGN_FIRST_ROW_CELLS && anchorsOf(ct).filter((a) => a.r === 0).length >= FOREIGN_FIRST_ROW_CELLS);
1323
+ foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkE2644XCOcjs.PART_COLXS.get(ct), () => ( cx))) && (headingRow(_nullishCoalesce(ct.cells[0], () => ( []))) || px.length > FOREIGN_FIRST_ROW_CELLS && anchorsOf(ct).filter((a) => a.r === 0).length >= FOREIGN_FIRST_ROW_CELLS);
1252
1324
  }
1253
- const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _74 => _74.bbox, 'optionalAccess', _75 => _75.y]), lex);
1325
+ const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _103 => _103.bbox, 'optionalAccess', _104 => _104.y]), lex);
1254
1326
  if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
1255
- _chunkWN5YLP7Hcjs.TABLE_COLXS.set(res.table, res.colXs);
1256
- const ys = _chunkWN5YLP7Hcjs.TABLE_ROWYS.get(pt);
1257
- if (ys) _chunkWN5YLP7Hcjs.TABLE_ROWYS.set(res.table, ys);
1258
- _chunkWN5YLP7Hcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkWN5YLP7Hcjs.PART_COLXS.get(pt), () => ( px)));
1259
- _chunkWN5YLP7Hcjs.CLIP_TABLES.add(res.table);
1327
+ _chunkE2644XCOcjs.TABLE_COLXS.set(res.table, res.colXs);
1328
+ const ys = _chunkE2644XCOcjs.TABLE_ROWYS.get(pt);
1329
+ if (ys) _chunkE2644XCOcjs.TABLE_ROWYS.set(res.table, ys);
1330
+ _chunkE2644XCOcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkE2644XCOcjs.PART_COLXS.get(pt), () => ( px)));
1331
+ _chunkE2644XCOcjs.CLIP_TABLES.add(res.table);
1260
1332
  return res.table;
1261
1333
  }
1262
1334
  function prevLacksLeftCols(prev, px, xs, pageHeights) {
1263
- const ph = _optionalChain([pageHeights, 'optionalAccess', _76 => _76.get, 'call', _77 => _77(prev.pageNumber)]);
1335
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _105 => _105.get, 'call', _106 => _106(prev.pageNumber)]);
1264
1336
  if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
1265
1337
  return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
1266
1338
  }
@@ -1271,21 +1343,21 @@ function headingRow(row) {
1271
1343
  }
1272
1344
  var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
1273
1345
  function looksContinued(prev, curr, pageHeights) {
1274
- const ph = _optionalChain([pageHeights, 'optionalAccess', _78 => _78.get, 'call', _79 => _79(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _80 => _80.get, 'call', _81 => _81(curr.pageNumber)]);
1346
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _107 => _107.get, 'call', _108 => _108(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _109 => _109.get, 'call', _110 => _110(curr.pageNumber)]);
1275
1347
  if (ph && ch && (prev.bbox.y > ph * PAGE_EDGE_BAND && !pushedLead(prev, curr) || curr.bbox.y + curr.bbox.height < ch * (1 - PAGE_EDGE_BAND))) return false;
1276
1348
  const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
1277
- const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _82 => _82.find, 'call', _83 => _83((c) => c.text.trim()), 'optionalAccess', _84 => _84.text]), () => ( ""));
1349
+ const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _111 => _111.find, 'call', _112 => _112((c) => c.text.trim()), 'optionalAccess', _113 => _113.text]), () => ( ""));
1278
1350
  if (!ANNEX_HEAD_RE.test(firstText)) return true;
1279
1351
  const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
1280
1352
  return filled.length >= 2 && filled.every((t) => t === filled[0]);
1281
1353
  }
1282
1354
  function pushedLead(prev, curr) {
1283
- if (!_chunkWN5YLP7Hcjs.CLIP_TABLES.has(prev.table) || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(curr.table)) return false;
1355
+ if (!_chunkE2644XCOcjs.CLIP_TABLES.has(prev.table) || !_chunkE2644XCOcjs.CLIP_TABLES.has(curr.table)) return false;
1284
1356
  const lead = leadRows(curr.table);
1285
1357
  return lead.image && lead.height > prev.bbox.y;
1286
1358
  }
1287
1359
  function leadRows(t) {
1288
- const ys = _chunkWN5YLP7Hcjs.TABLE_ROWYS.get(t);
1360
+ const ys = _chunkE2644XCOcjs.TABLE_ROWYS.get(t);
1289
1361
  if (!ys || ys.length < 2) return { height: 0, image: false };
1290
1362
  const anchors = anchorsOf(t);
1291
1363
  let end = 1, image = false;
@@ -1293,17 +1365,17 @@ function leadRows(t) {
1293
1365
  for (const a of anchors) {
1294
1366
  if (a.r !== r) continue;
1295
1367
  end = Math.max(end, r + a.rs);
1296
- if (_chunkWN5YLP7Hcjs.IMAGE_CELLS.has(a.cell)) image = true;
1368
+ if (_chunkE2644XCOcjs.IMAGE_CELLS.has(a.cell)) image = true;
1297
1369
  }
1298
1370
  }
1299
1371
  return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
1300
1372
  }
1301
1373
  function tailOf(b) {
1302
- const t = b.table && _chunkWN5YLP7Hcjs.TABLE_TAIL.get(b.table);
1374
+ const t = b.table && _chunkE2644XCOcjs.TABLE_TAIL.get(b.table);
1303
1375
  return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
1304
1376
  }
1305
1377
  function firstRowSig(t) {
1306
- const x = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(t);
1378
+ const x = _chunkE2644XCOcjs.TABLE_COLXS.get(t);
1307
1379
  if (!x || x.length !== t.cols + 1) return null;
1308
1380
  return anchorsOf(t).filter((a) => a.r === 0).map((a) => ({ x1: x[a.c], x2: x[a.c + a.cs], t: flowText(a.cell.text).replace(/\s+/g, "") }));
1309
1381
  }
@@ -1328,9 +1400,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
1328
1400
  }
1329
1401
  function restartsTitledForm(head, curr) {
1330
1402
  if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
1331
- const full = (t) => _optionalChain([t, 'access', _85 => _85.cells, 'access', _86 => _86[0], 'access', _87 => _87[0], 'optionalAccess', _88 => _88.colSpan]) === t.cols;
1403
+ const full = (t) => _optionalChain([t, 'access', _114 => _114.cells, 'access', _115 => _115[0], 'access', _116 => _116[0], 'optionalAccess', _117 => _117.colSpan]) === t.cols;
1332
1404
  if (!full(head) || !full(curr)) return false;
1333
- const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _89 => _89.text]), () => ( ""))).replace(/\s+/g, "");
1405
+ const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _118 => _118.text]), () => ( ""))).replace(/\s+/g, "");
1334
1406
  const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
1335
1407
  if (!ht || !ct || ht === ct) return false;
1336
1408
  const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
@@ -1356,7 +1428,7 @@ function chainHead(blocks, i, pageHeights) {
1356
1428
  if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
1357
1429
  if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
1358
1430
  if (!looksContinued(pb, cur, pageHeights)) break;
1359
- const px = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(pb.table), cx = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(cur.table);
1431
+ const px = _chunkE2644XCOcjs.TABLE_COLXS.get(pb.table), cx = _chunkE2644XCOcjs.TABLE_COLXS.get(cur.table);
1360
1432
  if (!px || !cx) break;
1361
1433
  const dx = px[px.length - 1] - cx[cx.length - 1];
1362
1434
  if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
@@ -1364,6 +1436,45 @@ function chainHead(blocks, i, pageHeights) {
1364
1436
  }
1365
1437
  return k;
1366
1438
  }
1439
+ var ROW_CONTINUATIONS = /* @__PURE__ */ new WeakMap();
1440
+ function continueRowSpans(prevCells, currCells) {
1441
+ const first = currCells[0];
1442
+ const last = prevCells.length;
1443
+ for (let c = 0; c < first.length; c++) {
1444
+ const cell = first[c];
1445
+ if (hasContent(cell) || (cell.rowSpan || 1) < 2) continue;
1446
+ let anchor;
1447
+ for (let r = last - 1; r >= 0 && !anchor; r--) {
1448
+ const a = _optionalChain([prevCells, 'access', _119 => _119[r], 'optionalAccess', _120 => _120[c]]);
1449
+ if (a && r + (a.rowSpan || 1) === last && (a.colSpan || 1) === (cell.colSpan || 1) && (hasContent(a) || a.rowSpan >= 2)) anchor = a;
1450
+ }
1451
+ if (!anchor) continue;
1452
+ if (!hasContent(anchor)) {
1453
+ ROW_CONTINUATIONS.set(anchor, cell);
1454
+ continue;
1455
+ }
1456
+ for (let part = cell; part; ) {
1457
+ const next = ROW_CONTINUATIONS.get(part);
1458
+ anchor.rowSpan = (anchor.rowSpan || 1) + part.rowSpan;
1459
+ part.rowSpan = 1;
1460
+ part.colSpan = 1;
1461
+ ROW_CONTINUATIONS.delete(part);
1462
+ part = next;
1463
+ }
1464
+ }
1465
+ }
1466
+ function repeatedHeaderRows(prev, curr) {
1467
+ if (!rowTextsEqual(prev.cells[0], curr.cells[0])) return 0;
1468
+ const pa = anchorsOf(prev), ca = anchorsOf(curr);
1469
+ let depth = 1;
1470
+ for (let r = 0; r < depth && r < prev.rows; r++) {
1471
+ for (const a of pa) if (a.r === r) depth = Math.max(depth, r + a.rs);
1472
+ }
1473
+ if (depth >= curr.rows || depth > prev.rows) return -1;
1474
+ const p = pa.filter((a) => a.r < depth), d = ca.filter((a) => a.r < depth);
1475
+ const norm = (text) => flowText(text).replace(/\s+/g, "");
1476
+ return p.length === d.length && p.every((a, i) => a.r === d[i].r && a.c === d[i].c && a.rs === d[i].rs && a.cs === d[i].cs && norm(a.cell.text) === norm(d[i].cell.text)) ? depth : -1;
1477
+ }
1367
1478
  function rowTextsEqual(a, b) {
1368
1479
  if (a.length !== b.length) return false;
1369
1480
  const norm = (t) => flowText(t).replace(/\s+/g, "");
@@ -1388,12 +1499,12 @@ var RESTART_LOOKBACK_PAGES = 5;
1388
1499
  var COL_MATCH_TOL = 0.5;
1389
1500
  var CONTINUED_TABLE_PAGE_BAND = 0.16;
1390
1501
  function lastRowCell(t, x1, x2) {
1391
- const xs = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(t);
1502
+ const xs = _chunkE2644XCOcjs.TABLE_COLXS.get(t);
1392
1503
  const covered = /* @__PURE__ */ new Set();
1393
1504
  for (let r = 0; r < t.rows; r++) {
1394
1505
  for (let c = 0; c < t.cols; c++) {
1395
1506
  if (covered.has(r * 1e5 + c)) continue;
1396
- const cell = _optionalChain([t, 'access', _90 => _90.cells, 'access', _91 => _91[r], 'optionalAccess', _92 => _92[c]]);
1507
+ const cell = _optionalChain([t, 'access', _121 => _121.cells, 'access', _122 => _122[r], 'optionalAccess', _123 => _123[c]]);
1397
1508
  if (!cell) continue;
1398
1509
  for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
1399
1510
  if (r + cell.rowSpan !== t.rows) continue;
@@ -1406,23 +1517,23 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
1406
1517
  function mergeContinuedCells(blocks, pageHeights) {
1407
1518
  for (let j = blocks.length - 1; j > 0; j--) {
1408
1519
  const part = blocks[j];
1409
- const from = part.table ? _chunkWN5YLP7Hcjs.CONT_PARTS.get(part.table) : void 0;
1520
+ const from = part.table ? _chunkE2644XCOcjs.CONT_PARTS.get(part.table) : void 0;
1410
1521
  if (!from || !part.table) continue;
1411
1522
  let i = j - 1;
1412
1523
  while (i >= 0 && blocks[i].type !== "table") i--;
1413
1524
  const prev = blocks[i];
1414
1525
  if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
1415
1526
  const cell = lastRowCell(prev.table, from.x1, from.x2);
1416
- const add = _optionalChain([part, 'access', _93 => _93.table, 'access', _94 => _94.cells, 'access', _95 => _95[0], 'optionalAccess', _96 => _96[0]]);
1527
+ const add = _optionalChain([part, 'access', _124 => _124.table, 'access', _125 => _125.cells, 'access', _126 => _126[0], 'optionalAccess', _127 => _127[0]]);
1417
1528
  if (!cell || !add) continue;
1418
1529
  const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
1419
1530
  if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
1420
1531
  cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
1421
- _chunkWN5YLP7Hcjs.joinCellEdges.call(void 0, cell, add);
1422
- const lines = _chunkWN5YLP7Hcjs.CELL_LINES.get(add);
1423
- if (_optionalChain([lines, 'optionalAccess', _97 => _97.length])) _chunkWN5YLP7Hcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkWN5YLP7Hcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
1424
- if (part.pageNumber && part.bbox) _chunkWN5YLP7Hcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkWN5YLP7Hcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
1425
- if (cell.text.trim() || _optionalChain([cell, 'access', _98 => _98.blocks, 'optionalAccess', _99 => _99.length])) _chunkWN5YLP7Hcjs.EMPTY_PARTS.delete(prev.table);
1532
+ _chunkE2644XCOcjs.joinCellEdges.call(void 0, cell, add);
1533
+ const lines = _chunkE2644XCOcjs.CELL_LINES.get(add);
1534
+ if (_optionalChain([lines, 'optionalAccess', _128 => _128.length])) _chunkE2644XCOcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkE2644XCOcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
1535
+ if (part.pageNumber && part.bbox) _chunkE2644XCOcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkE2644XCOcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
1536
+ if (cell.text.trim() || _optionalChain([cell, 'access', _129 => _129.blocks, 'optionalAccess', _130 => _130.length])) _chunkE2644XCOcjs.EMPTY_PARTS.delete(prev.table);
1426
1537
  blocks.splice(j, 1);
1427
1538
  if (cell.blocks && at > 0) {
1428
1539
  const nextAt = cell.blocks[at];
@@ -1434,30 +1545,58 @@ function mergeContinuedCells(blocks, pageHeights) {
1434
1545
  }
1435
1546
  function unwrapContinuedTable(blocks, at, pageHeights) {
1436
1547
  const prev = blocks[at - 1], frame = blocks[at];
1437
- if (!_optionalChain([prev, 'optionalAccess', _100 => _100.table]) || !_optionalChain([frame, 'optionalAccess', _101 => _101.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(frame.table)) return;
1438
- const inner = _optionalChain([frame, 'access', _102 => _102.table, 'access', _103 => _103.cells, 'access', _104 => _104[0], 'optionalAccess', _105 => _105[0], 'optionalAccess', _106 => _106.blocks]);
1439
- const next = _optionalChain([inner, 'optionalAccess', _107 => _107[0]]);
1440
- if (!inner || !_optionalChain([next, 'optionalAccess', _108 => _108.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(prev.table) || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
1441
- const px = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(prev.table), nx = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(next.table);
1548
+ if (!_optionalChain([prev, 'optionalAccess', _131 => _131.table]) || !_optionalChain([frame, 'optionalAccess', _132 => _132.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkE2644XCOcjs.CLIP_TABLES.has(frame.table)) return;
1549
+ const inner = _optionalChain([frame, 'access', _133 => _133.table, 'access', _134 => _134.cells, 'access', _135 => _135[0], 'optionalAccess', _136 => _136[0], 'optionalAccess', _137 => _137.blocks]);
1550
+ const next = _optionalChain([inner, 'optionalAccess', _138 => _138[0]]);
1551
+ if (!inner || !_optionalChain([next, 'optionalAccess', _139 => _139.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkE2644XCOcjs.CLIP_TABLES.has(prev.table) || !_chunkE2644XCOcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
1552
+ const px = _chunkE2644XCOcjs.TABLE_COLXS.get(prev.table), nx = _chunkE2644XCOcjs.TABLE_COLXS.get(next.table);
1442
1553
  if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
1443
- const ph = _optionalChain([pageHeights, 'optionalAccess', _109 => _109.get, 'call', _110 => _110(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _111 => _111.get, 'call', _112 => _112(next.pageNumber)]);
1554
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _140 => _140.get, 'call', _141 => _141(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _142 => _142.get, 'call', _143 => _143(next.pageNumber)]);
1444
1555
  if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
1445
1556
  blocks.splice(at, 1, ...inner);
1446
1557
  }
1447
1558
  function fillNestedContinuation(blocks, at) {
1448
1559
  const prev = blocks[at - 1], next = blocks[at];
1449
- const t = _optionalChain([prev, 'optionalAccess', _113 => _113.table]), u = _optionalChain([next, 'optionalAccess', _114 => _114.table]);
1450
- if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(t) || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
1451
- const xs = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(u);
1560
+ const t = _optionalChain([prev, 'optionalAccess', _144 => _144.table]), u = _optionalChain([next, 'optionalAccess', _145 => _145.table]);
1561
+ if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkE2644XCOcjs.CLIP_TABLES.has(t) || !_chunkE2644XCOcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
1562
+ const xs = _chunkE2644XCOcjs.TABLE_COLXS.get(u);
1452
1563
  const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
1453
- const add = _optionalChain([u, 'access', _115 => _115.cells, 'access', _116 => _116[0], 'optionalAccess', _117 => _117[0]]);
1454
- if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _118 => _118.blocks, 'optionalAccess', _119 => _119.length])) return;
1564
+ const add = _optionalChain([u, 'access', _146 => _146.cells, 'access', _147 => _147[0], 'optionalAccess', _148 => _148[0]]);
1565
+ if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _149 => _149.blocks, 'optionalAccess', _150 => _150.length])) return;
1455
1566
  cell.text = add.text;
1456
1567
  if (add.blocks) cell.blocks = add.blocks;
1457
- _chunkWN5YLP7Hcjs.joinCellEdges.call(void 0, cell, add);
1568
+ _chunkE2644XCOcjs.joinCellEdges.call(void 0, cell, add);
1458
1569
  blocks.splice(at, 1);
1459
1570
  }
1460
1571
 
1572
+ // src/pdf/selection-context.ts
1573
+ function selectionContextPages(selected, pageCount) {
1574
+ const out = /* @__PURE__ */ new Set();
1575
+ for (const page of selected) {
1576
+ for (let distance = 1; distance <= 4; distance++) {
1577
+ for (const neighbor of [page - distance, page + distance]) {
1578
+ if (neighbor < 1 || neighbor > pageCount || selected.has(neighbor)) continue;
1579
+ out.add(neighbor);
1580
+ }
1581
+ }
1582
+ }
1583
+ return [...out].sort((a, b) => a - b);
1584
+ }
1585
+ function marginContextBlocks(raw, page, view) {
1586
+ const [x1, y1, x2, y2] = view;
1587
+ const width = x2 - x1, height = y2 - y1;
1588
+ const items = _chunkE2644XCOcjs.filterHiddenText.call(void 0, _chunkE2644XCOcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
1589
+ for (const item of items) {
1590
+ item.x -= x1;
1591
+ item.y -= y1;
1592
+ }
1593
+ return _chunkE2644XCOcjs.groupByY.call(void 0, items).flatMap((line) => {
1594
+ const bbox = _chunkE2644XCOcjs.computeBBox.call(void 0, line, page);
1595
+ if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
1596
+ return [{ type: "paragraph", text: _chunkE2644XCOcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkE2644XCOcjs.dominantStyle.call(void 0, line) }];
1597
+ });
1598
+ }
1599
+
1461
1600
  // src/pdf/symbol-fonts.ts
1462
1601
  var WINANSI_REVERSE = {
1463
1602
  8364: 128,
@@ -1490,7 +1629,7 @@ var WINANSI_REVERSE = {
1490
1629
  };
1491
1630
  function symbolFontTable(fontName) {
1492
1631
  if (!fontName) return void 0;
1493
- if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunk2ZBLQVAScjs.WINGDINGS;
1632
+ if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunk3WLZOJIEcjs.WINGDINGS;
1494
1633
  return void 0;
1495
1634
  }
1496
1635
  function remapSymbolText(text, table) {
@@ -1618,7 +1757,7 @@ function layout(toks) {
1618
1757
  const bar = rest.find((t) => t.bar && t.x >= rt.x && t.x <= rt.x + rt.w + 2 && Math.abs(t.y - rt.y) <= size * 1.5);
1619
1758
  if (!bar) continue;
1620
1759
  const inner = rest.filter((t) => !t.bar && t !== rt && t.x + t.w / 2 > bar.x && t.x + t.w / 2 < bar.x + bar.w && bar.y - t.y > 0 && bar.y - t.y <= size * 1.4);
1621
- const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _120 => _120[0], 'optionalAccess', _121 => _121.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
1760
+ const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _151 => _151[0], 'optionalAccess', _152 => _152.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
1622
1761
  rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
1623
1762
  }
1624
1763
  const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
@@ -1720,7 +1859,7 @@ function wrapEquationRuns(items, faceName) {
1720
1859
  for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
1721
1860
  const top = [...ys].sort((p, q) => q[1] - p[1]);
1722
1861
  const bar = cur.find(isBarItem);
1723
- const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _122 => _122[0], 'optionalAccess', _123 => _123[0]]), () => ( cur[0].y));
1862
+ const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _153 => _153[0], 'optionalAccess', _154 => _154[0]]), () => ( cur[0].y));
1724
1863
  const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
1725
1864
  const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
1726
1865
  added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
@@ -1765,6 +1904,9 @@ var NAMED = {
1765
1904
  quotedblright: "\u201D",
1766
1905
  quotesingle: "'",
1767
1906
  quotedbl: '"',
1907
+ bullet: "\u2022",
1908
+ openbullet: "\u25E6",
1909
+ whitebullet: "\u25E6",
1768
1910
  question: "?",
1769
1911
  exclam: "!",
1770
1912
  percent: "%",
@@ -1781,7 +1923,9 @@ function glyphNameText(name) {
1781
1923
  let out = "";
1782
1924
  for (const part of base.split("_")) {
1783
1925
  const uni = _nullishCoalesce(/^uni([0-9A-F]{4})$/.exec(part), () => ( /^u([0-9A-F]{4,6})$/.exec(part)));
1784
- const ch = /^[A-Za-z]$/.test(part) ? part : _nullishCoalesce(NAMED[part], () => ( (uni ? String.fromCodePoint(parseInt(uni[1], 16)) : void 0)));
1926
+ const code = uni ? parseInt(uni[1], 16) : void 0;
1927
+ if (code !== void 0 && (code > 1114111 || code >= 55296 && code <= 57343)) return void 0;
1928
+ const ch = /^[A-Za-z]$/.test(part) ? part : _nullishCoalesce(NAMED[part], () => ( (code !== void 0 ? String.fromCodePoint(code) : void 0)));
1785
1929
  if (ch === void 0) return void 0;
1786
1930
  out += ch;
1787
1931
  }
@@ -2066,7 +2210,7 @@ function joinVerticalColumns(items) {
2066
2210
  const groups = [];
2067
2211
  for (const col of columns) {
2068
2212
  const g2 = groups[groups.length - 1];
2069
- const last = _optionalChain([g2, 'optionalAccess', _124 => _124[g2.length - 1]]);
2213
+ const last = _optionalChain([g2, 'optionalAccess', _155 => _155[g2.length - 1]]);
2070
2214
  const fs = col.items[0].fontSize;
2071
2215
  if (last && last.x - col.x >= fs * 1.2 && last.x - col.x <= fs * 4 && Math.abs(last.items[0].y - col.items[0].y) <= fs * 1.2) g2.push(col);
2072
2216
  else groups.push([col]);
@@ -2252,7 +2396,7 @@ function relocateEndnotes(blocks) {
2252
2396
  }
2253
2397
  const shapes = /* @__PURE__ */ new Map();
2254
2398
  for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
2255
- const main = _optionalChain([[...shapes], 'access', _125 => _125.sort, 'call', _126 => _126((a, b) => b[1] - a[1]), 'access', _127 => _127[0], 'optionalAccess', _128 => _128[0]]);
2399
+ const main = _optionalChain([[...shapes], 'access', _156 => _156.sort, 'call', _157 => _157((a, b) => b[1] - a[1]), 'access', _158 => _158[0], 'optionalAccess', _159 => _159[0]]);
2256
2400
  if (!main || !/#/.test(main)) return blocks;
2257
2401
  const lastRun = (hs) => {
2258
2402
  let run2 = [];
@@ -2390,7 +2534,7 @@ function inlineFootnotes(blocks, pages) {
2390
2534
  open = true;
2391
2535
  continue;
2392
2536
  }
2393
- const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _129 => _129.style, 'optionalAccess', _130 => _130.fontSize]), () => ( _optionalChain([b, 'access', _131 => _131.bbox, 'optionalAccess', _132 => _132.height]))), () => ( 10))) * 1.5;
2537
+ const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _160 => _160.style, 'optionalAccess', _161 => _161.fontSize]), () => ( _optionalChain([b, 'access', _162 => _162.bbox, 'optionalAccess', _163 => _163.height]))), () => ( 10))) * 1.5;
2394
2538
  if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
2395
2539
  notes[notes.length - 1].text += " " + b.text.trim();
2396
2540
  notes[notes.length - 1].blocks.push(b);
@@ -2413,7 +2557,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
2413
2557
  var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
2414
2558
  var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
2415
2559
  function isRunningHead(block, page, pageHeight) {
2416
- const box = block.bbox, text = _optionalChain([block, 'access', _133 => _133.text, 'optionalAccess', _134 => _134.trim, 'call', _135 => _135()]);
2560
+ const box = block.bbox, text = _optionalChain([block, 'access', _164 => _164.text, 'optionalAccess', _165 => _165.trim, 'call', _166 => _166()]);
2417
2561
  if (!box || !text || !pageHeight) return false;
2418
2562
  const top = box.y + box.height >= pageHeight * 0.9;
2419
2563
  const bottom = box.y <= pageHeight * 0.1;
@@ -2421,7 +2565,7 @@ function isRunningHead(block, page, pageHeight) {
2421
2565
  const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
2422
2566
  if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
2423
2567
  if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
2424
- if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _136 => _136.style, 'optionalAccess', _137 => _137.fontSize]), () => ( 0))) * 1.6) return true;
2568
+ if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _167 => _167.style, 'optionalAccess', _168 => _168.fontSize]), () => ( 0))) * 1.6) return true;
2425
2569
  if (!text.includes(" ")) return false;
2426
2570
  const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
2427
2571
  if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
@@ -2430,7 +2574,7 @@ function isRunningHead(block, page, pageHeight) {
2430
2574
  return right > left && box.width >= (right - left) * 0.6;
2431
2575
  }
2432
2576
  function unbalancedClose(text) {
2433
- return (_nullishCoalesce(_optionalChain([text, 'access', _138 => _138.match, 'call', _139 => _139(/\)/g), 'optionalAccess', _140 => _140.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _141 => _141.match, 'call', _142 => _142(/\(/g), 'optionalAccess', _143 => _143.length]), () => ( 0)));
2577
+ return (_nullishCoalesce(_optionalChain([text, 'access', _169 => _169.match, 'call', _170 => _170(/\)/g), 'optionalAccess', _171 => _171.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _172 => _172.match, 'call', _173 => _173(/\(/g), 'optionalAccess', _174 => _174.length]), () => ( 0)));
2434
2578
  }
2435
2579
  function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2436
2580
  const byPage = /* @__PURE__ */ new Map();
@@ -2446,7 +2590,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2446
2590
  const sizes = /* @__PURE__ */ new Map();
2447
2591
  let proseChars = 0;
2448
2592
  for (const b of page) {
2449
- if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _144 => _144.style, 'optionalAccess', _145 => _145.fontName]) || !b.style.fontSize) continue;
2593
+ if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _175 => _175.style, 'optionalAccess', _176 => _176.fontName]) || !b.style.fontSize) continue;
2450
2594
  const key2 = `${b.style.fontName}:${b.style.fontSize}`;
2451
2595
  chars.set(key2, (_nullishCoalesce(chars.get(key2), () => ( 0))) + b.text.length);
2452
2596
  if (b.type === "paragraph" && b.style.fontName === "ocr") {
@@ -2467,54 +2611,83 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2467
2611
  }
2468
2612
  }
2469
2613
  }
2614
+ const citedProse = /* @__PURE__ */ new Set();
2615
+ const numberedProse = /* @__PURE__ */ new Set();
2616
+ for (const page of byPage.values()) {
2617
+ const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access', _177 => _177.text, 'optionalAccess', _178 => _178.trim, 'call', _179 => _179()]), () => ( ""))) && b.bbox && _optionalChain([b, 'access', _180 => _180.style, 'optionalAccess', _181 => _181.fontName]) && b.style.fontSize && !/Bold|Black|Heavy|Semibold/i.test(_nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _182 => _182.get, 'call', _183 => _183(b.style.fontName)]), () => ( ""))));
2618
+ let chain = [];
2619
+ const finish = () => {
2620
+ if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access', _184 => _184.text, 'optionalAccess', _185 => _185.length]), () => ( 0))) >= 40 && b.bbox.height >= b.style.fontSize * 2.4)) return;
2621
+ for (const b of chain) numberedProse.add(b);
2622
+ const first = chain[0], size = first.style.fontSize;
2623
+ for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access', _186 => _186.text, 'optionalAccess', _187 => _187.trim, 'call', _188 => _188()]), () => ( ""))) && _optionalChain([b, 'access', _189 => _189.style, 'optionalAccess', _190 => _190.fontName]) === _optionalChain([first, 'access', _191 => _191.style, 'optionalAccess', _192 => _192.fontName]) && _optionalChain([b, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontSize]) === size && b.bbox && Math.abs(b.bbox.x - first.bbox.x) <= size * 0.5 && (_nullishCoalesce(_optionalChain([b, 'access', _195 => _195.text, 'optionalAccess', _196 => _196.length]), () => ( 0))) >= 15) numberedProse.add(b);
2624
+ };
2625
+ for (const b of numbered) {
2626
+ const prev = chain.at(-1), size = b.style.fontSize;
2627
+ if (!prev || b.text.trim().charCodeAt(0) !== prev.text.trim().charCodeAt(0) + 1 || b.style.fontName !== prev.style.fontName || size !== prev.style.fontSize || Math.abs(b.bbox.x - prev.bbox.x) > size * 0.5 || prev.bbox.y - (b.bbox.y + b.bbox.height) > size * 8) {
2628
+ finish();
2629
+ chain = [];
2630
+ }
2631
+ chain.push(b);
2632
+ }
2633
+ finish();
2634
+ }
2635
+ for (let i = 0; i + 1 < blocks.length; i++) {
2636
+ const prose = blocks[i], reference = blocks[i + 1];
2637
+ const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _197 => _197.style, 'optionalAccess', _198 => _198.fontSize]), () => ( 0));
2638
+ const source = _nullishCoalesce(_optionalChain([reference, 'access', _199 => _199.text, 'optionalAccess', _200 => _200.replace, 'call', _201 => _201(/<[^>]+>/g, ""), 'access', _202 => _202.trim, 'call', _203 => _203()]), () => ( ""));
2639
+ if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access', _204 => _204.text, 'optionalAccess', _205 => _205.length]), () => ( 0))) < 40 || !a || !b || size <= 0 || a.height < size * 2.4 || prose.pageNumber !== reference.pageNumber || _optionalChain([prose, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontName]) !== _optionalChain([reference, 'access', _208 => _208.style, 'optionalAccess', _209 => _209.fontName]) || _optionalChain([prose, 'access', _210 => _210.style, 'optionalAccess', _211 => _211.fontSize]) !== _optionalChain([reference, 'access', _212 => _212.style, 'optionalAccess', _213 => _213.fontSize]) || Math.abs(a.x - b.x) > size && !(/^[○●•◦]\s/.test(_nullishCoalesce(prose.text, () => ( ""))) && b.x >= a.x && b.x - a.x <= size * 2) || a.y - (b.y + b.height) < 0 || a.y - (b.y + b.height) > size || !/^[((].*(?:제\s*\d+\s*조|(?:Article|Section)\s+\d+).*[))]$/i.test(source)) continue;
2640
+ citedProse.add(prose);
2641
+ citedProse.add(reference);
2642
+ }
2470
2643
  for (let i = 0; i < blocks.length; i++) {
2471
2644
  const block = blocks[i];
2472
2645
  if (block.type !== "heading" || !block.text) continue;
2473
2646
  const text = block.text.replace(/<[^>]+>/g, "").trim();
2474
- const fsz = _nullishCoalesce(_optionalChain([block, 'access', _146 => _146.style, 'optionalAccess', _147 => _147.fontSize]), () => ( 0));
2475
- const tocEntry = i > 0 && _chunkWN5YLP7Hcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkWN5YLP7Hcjs.TOC_BLOCKS.has(blocks[i + 1]);
2647
+ const fsz = _nullishCoalesce(_optionalChain([block, 'access', _214 => _214.style, 'optionalAccess', _215 => _215.fontSize]), () => ( 0));
2648
+ const tocEntry = i > 0 && _chunkE2644XCOcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkE2644XCOcjs.TOC_BLOCKS.has(blocks[i + 1]);
2476
2649
  const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
2477
- const proseStyle = _optionalChain([block, 'access', _148 => _148.style, 'optionalAccess', _149 => _149.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
2650
+ const proseStyle = _optionalChain([block, 'access', _216 => _216.style, 'optionalAccess', _217 => _217.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
2478
2651
  const next = blocks[i + 1];
2479
- const nb = _optionalChain([next, 'optionalAccess', _150 => _150.bbox]), bb = block.bbox;
2480
- const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _151 => _151.style, 'optionalAccess', _152 => _152.fontSize]), () => ( 0))) * 1.2 && Math.abs(bb.x - nb.x) > fsz && Math.abs(bb.x + bb.width / 2 - (nb.x + nb.width / 2)) < nb.width * 0.1;
2481
- if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _153 => _153.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
2652
+ const nb = _optionalChain([next, 'optionalAccess', _218 => _218.bbox]), bb = block.bbox;
2653
+ const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _219 => _219.style, 'optionalAccess', _220 => _220.fontSize]), () => ( 0))) * 1.2 && Math.abs(bb.x - nb.x) > fsz && Math.abs(bb.x + bb.width / 2 - (nb.x + nb.width / 2)) < nb.width * 0.1;
2654
+ if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _221 => _221.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
2482
2655
  next.text = `${block.text.trim()} ${next.text.trim()}`;
2483
2656
  blocks.splice(i--, 1);
2484
2657
  continue;
2485
2658
  }
2486
- if ((_optionalChain([next, 'optionalAccess', _154 => _154.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _155 => _155.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _156 => _156.style, 'optionalAccess', _157 => _157.fontName]) === _optionalChain([block, 'access', _158 => _158.style, 'optionalAccess', _159 => _159.fontName]) && _optionalChain([next, 'access', _160 => _160.style, 'optionalAccess', _161 => _161.fontSize]) === _optionalChain([block, 'access', _162 => _162.style, 'optionalAccess', _163 => _163.fontSize]) && fsz > 0 && /^[a-z]/.test(next.text.trim()) && next.text.trim().length <= 40 && !/[.:;!?]$/.test(next.text.trim()) && block.bbox.y - (next.bbox.y + next.bbox.height) < fsz * 1.2 && Math.abs(next.bbox.x - block.bbox.x) < fsz) {
2659
+ if ((_optionalChain([next, 'optionalAccess', _222 => _222.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _223 => _223.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _224 => _224.style, 'optionalAccess', _225 => _225.fontName]) === _optionalChain([block, 'access', _226 => _226.style, 'optionalAccess', _227 => _227.fontName]) && _optionalChain([next, 'access', _228 => _228.style, 'optionalAccess', _229 => _229.fontSize]) === _optionalChain([block, 'access', _230 => _230.style, 'optionalAccess', _231 => _231.fontSize]) && fsz > 0 && /^[a-z]/.test(next.text.trim()) && next.text.trim().length <= 40 && !/[.:;!?]$/.test(next.text.trim()) && block.bbox.y - (next.bbox.y + next.bbox.height) < fsz * 1.2 && Math.abs(next.bbox.x - block.bbox.x) < fsz) {
2487
2660
  block.text = `${block.text.trim()} ${next.text.trim()}`;
2488
2661
  block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
2489
2662
  blocks.splice(i + 1, 1);
2490
2663
  }
2491
2664
  const after = blocks[i + 2];
2492
- if ((_optionalChain([next, 'optionalAccess', _164 => _164.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _165 => _165.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _166 => _166.text, 'optionalAccess', _167 => _167.trim, 'call', _168 => _168()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _169 => _169.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _170 => _170.style, 'optionalAccess', _171 => _171.fontSize]) === _optionalChain([block, 'access', _172 => _172.style, 'optionalAccess', _173 => _173.fontSize])) {
2665
+ if ((_optionalChain([next, 'optionalAccess', _232 => _232.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _233 => _233.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _234 => _234.text, 'optionalAccess', _235 => _235.trim, 'call', _236 => _236()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _237 => _237.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _238 => _238.style, 'optionalAccess', _239 => _239.fontSize]) === _optionalChain([block, 'access', _240 => _240.style, 'optionalAccess', _241 => _241.fontSize])) {
2493
2666
  block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
2494
2667
  blocks.splice(i + 1, 2);
2495
2668
  }
2496
2669
  const tiny = fsz > 0 && fsz < 7.5;
2497
2670
  const prev = blocks[i - 1];
2498
- if (_optionalChain([prev, 'optionalAccess', _174 => _174.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _175 => _175.text, 'optionalAccess', _176 => _176.trim, 'call', _177 => _177()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
2671
+ if (_optionalChain([prev, 'optionalAccess', _242 => _242.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _243 => _243.text, 'optionalAccess', _244 => _244.trim, 'call', _245 => _245()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
2499
2672
  prev.text = `${prev.text.trim()} ${block.text.trim()}`;
2500
2673
  prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
2501
2674
  blocks.splice(i--, 1);
2502
2675
  continue;
2503
2676
  }
2504
- if (_optionalChain([prev, 'optionalAccess', _178 => _178.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _179 => _179.text, 'optionalAccess', _180 => _180.trim, 'call', _181 => _181()]), () => ( ""))) && prev.bbox && block.bbox && fsz > 0 && (Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x && block.bbox.x - (prev.bbox.x + prev.bbox.width) < fsz * 3 || Math.abs(prev.bbox.x - block.bbox.x) < 2 && (_nullishCoalesce(_optionalChain([prev, 'access', _182 => _182.style, 'optionalAccess', _183 => _183.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
2677
+ if (_optionalChain([prev, 'optionalAccess', _246 => _246.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _247 => _247.text, 'optionalAccess', _248 => _248.trim, 'call', _249 => _249()]), () => ( ""))) && prev.bbox && block.bbox && fsz > 0 && (Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x && block.bbox.x - (prev.bbox.x + prev.bbox.width) < fsz * 3 || Math.abs(prev.bbox.x - block.bbox.x) < 2 && (_nullishCoalesce(_optionalChain([prev, 'access', _250 => _250.style, 'optionalAccess', _251 => _251.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
2505
2678
  block.text = `${prev.text.trim()} ${block.text.trim()}`;
2506
2679
  blocks.splice(i - 1, 1);
2507
2680
  i -= 2;
2508
2681
  continue;
2509
2682
  }
2510
- const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _184 => _184.style, 'optionalAccess', _185 => _185.fontSize]), () => ( 0));
2511
- const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _186 => _186.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _187 => _187.style, 'optionalAccess', _188 => _188.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _189 => _189.style, 'optionalAccess', _190 => _190.fontSize]), () => ( 0))) >= size * 1.3 && box.y - (next.bbox.y + next.bbox.height) <= size * 3 && Math.min(box.x + box.width, next.bbox.x + next.bbox.width) - Math.max(box.x, next.bbox.x) >= Math.min(box.width, next.bbox.width) * 0.5 && !page.some((o) => o !== block && o.bbox && o.bbox.y > box.y + box.height && o.type !== "image");
2512
- const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _191 => _191.get, 'call', _192 => _192(_nullishCoalesce(_optionalChain([block, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontName]), () => ( "")))]), () => ( ""));
2683
+ const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _252 => _252.style, 'optionalAccess', _253 => _253.fontSize]), () => ( 0));
2684
+ const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _254 => _254.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _255 => _255.style, 'optionalAccess', _256 => _256.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _257 => _257.style, 'optionalAccess', _258 => _258.fontSize]), () => ( 0))) >= size * 1.3 && box.y - (next.bbox.y + next.bbox.height) <= size * 3 && Math.min(box.x + box.width, next.bbox.x + next.bbox.width) - Math.max(box.x, next.bbox.x) >= Math.min(box.width, next.bbox.width) * 0.5 && !page.some((o) => o !== block && o.bbox && o.bbox.y > box.y + box.height && o.type !== "image");
2685
+ const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _259 => _259.get, 'call', _260 => _260(_nullishCoalesce(_optionalChain([block, 'access', _261 => _261.style, 'optionalAccess', _262 => _262.fontName]), () => ( "")))]), () => ( ""));
2513
2686
  const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
2514
- const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _195 => _195[i - 1], 'optionalAccess', _196 => _196.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
2515
- const ocrFragment = _optionalChain([block, 'access', _197 => _197.style, 'optionalAccess', _198 => _198.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _199 => _199.match, 'call', _200 => _200(/\p{L}/gu), 'optionalAccess', _201 => _201.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
2516
- const crowdedOcr = _optionalChain([block, 'access', _202 => _202.style, 'optionalAccess', _203 => _203.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _204 => _204.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _205 => _205.style, 'optionalAccess', _206 => _206.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _207 => _207.text, 'optionalAccess', _208 => _208.length]), () => ( 0))) >= 15 && Math.abs(o.bbox.x - box.x) <= size * 0.25 && Math.min(o.bbox.y + o.bbox.height, box.y + box.height) - Math.max(o.bbox.y, box.y) >= o.bbox.height * 0.2) && prev.bbox.y > box.y && next.bbox.y < box.y;
2517
- if (ocrFragment || crowdedOcr || tocEntry || proseStyle || kicker || byline || tiny || !/\p{L}/u.test(text) && !chapterNumber || /^[a-z]/.test(text) || CAPTION.test(text) || EQUATION_NUMBER.test(block.text) || DISPLAY_MATH.test(text) || // 닫는 괄호가 여는 괄호보다 많으면 앞 줄에서 이어진 문장 조각이다 ("Fact-checking) and is used …") — "1)"·"가)" 앞머리 번호는 빼고 센다
2687
+ const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _263 => _263[i - 1], 'optionalAccess', _264 => _264.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
2688
+ const ocrFragment = _optionalChain([block, 'access', _265 => _265.style, 'optionalAccess', _266 => _266.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _267 => _267.match, 'call', _268 => _268(/\p{L}/gu), 'optionalAccess', _269 => _269.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
2689
+ const crowdedOcr = _optionalChain([block, 'access', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _272 => _272.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _273 => _273.style, 'optionalAccess', _274 => _274.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _275 => _275.text, 'optionalAccess', _276 => _276.length]), () => ( 0))) >= 15 && Math.abs(o.bbox.x - box.x) <= size * 0.25 && Math.min(o.bbox.y + o.bbox.height, box.y + box.height) - Math.max(o.bbox.y, box.y) >= o.bbox.height * 0.2) && prev.bbox.y > box.y && next.bbox.y < box.y;
2690
+ if (numberedProse.has(block) || citedProse.has(block) || ocrFragment || crowdedOcr || tocEntry || proseStyle || kicker || byline || tiny || !/\p{L}/u.test(text) && !chapterNumber || /^[a-z]/.test(text) || CAPTION.test(text) || EQUATION_NUMBER.test(block.text) || DISPLAY_MATH.test(text) || // 닫는 괄호가 여는 괄호보다 많으면 앞 줄에서 이어진 문장 조각이다 ("Fact-checking) and is used …") — "1)"·"가)" 앞머리 번호는 빼고 센다
2518
2691
  unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
2519
2692
  block.type = "paragraph";
2520
2693
  block.level = void 0;
@@ -2548,28 +2721,37 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
2548
2721
  function captionTableText(t) {
2549
2722
  if (!t || t.rows !== 1 || t.cols !== 2) return null;
2550
2723
  const [label, body] = t.cells[0];
2551
- if (!label || !body || _optionalChain([label, 'access', _209 => _209.blocks, 'optionalAccess', _210 => _210.length]) || _optionalChain([body, 'access', _211 => _211.blocks, 'optionalAccess', _212 => _212.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
2724
+ if (!label || !body || _optionalChain([label, 'access', _277 => _277.blocks, 'optionalAccess', _278 => _278.length]) || _optionalChain([body, 'access', _279 => _279.blocks, 'optionalAccess', _280 => _280.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
2552
2725
  return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
2553
2726
  }
2554
2727
  function splitSingleCellTables(blocks) {
2555
2728
  const out = [];
2556
2729
  for (const b of blocks) {
2557
2730
  const t = b.type === "table" ? b.table : void 0;
2558
- const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _213 => _213.cells, 'access', _214 => _214[0], 'optionalAccess', _215 => _215[0], 'optionalAccess', _216 => _216.blocks, 'optionalAccess', _217 => _217.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
2731
+ const title = t && _chunkE2644XCOcjs.FRAME_TITLE_BLOCKS.get(t);
2732
+ if (title) {
2733
+ out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
2734
+ continue;
2735
+ }
2736
+ const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _281 => _281.cells, 'access', _282 => _282[0], 'optionalAccess', _283 => _283[0], 'optionalAccess', _284 => _284.blocks, 'optionalAccess', _285 => _285.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
2559
2737
  const squash = (s) => s.replace(/\s/g, "");
2560
2738
  const inner = only && (!squash(t.cells[0][0].text) || only.type === "table" && squash(t.cells[0][0].text) === squash(only.table.cells.flat().map((c) => c.text).join(""))) ? only : void 0;
2561
- const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _218 => _218.type]) === "table" ? captionTableText(inner.table) : null)));
2739
+ const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _286 => _286.type]) === "table" ? captionTableText(inner.table) : null)));
2562
2740
  if (caption) {
2563
2741
  out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
2564
2742
  continue;
2565
2743
  }
2566
- const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _219 => _219.cells, 'access', _220 => _220[0], 'optionalAccess', _221 => _221[0]]) : void 0;
2567
- if (!cell || _optionalChain([cell, 'access', _222 => _222.blocks, 'optionalAccess', _223 => _223.some, 'call', _224 => _224((x) => x.type === "table")])) {
2744
+ const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _287 => _287.cells, 'access', _288 => _288[0], 'optionalAccess', _289 => _289[0]]) : void 0;
2745
+ if (!cell) {
2568
2746
  out.push(b);
2569
2747
  continue;
2570
2748
  }
2571
2749
  const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
2572
- if (_optionalChain([t, 'optionalAccess', _225 => _225.caption, 'optionalAccess', _226 => _226.trim, 'call', _227 => _227()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
2750
+ if (_optionalChain([t, 'optionalAccess', _290 => _290.caption, 'optionalAccess', _291 => _291.trim, 'call', _292 => _292()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
2751
+ if (_optionalChain([cell, 'access', _293 => _293.blocks, 'optionalAccess', _294 => _294.length])) {
2752
+ out.push(...splitSingleCellTables(cell.blocks));
2753
+ continue;
2754
+ }
2573
2755
  for (const text of lines) out.push({ type: "paragraph", text, pageNumber: b.pageNumber, bbox: b.bbox });
2574
2756
  }
2575
2757
  return out;
@@ -2582,7 +2764,7 @@ function joinLatinCellWraps(blocks) {
2582
2764
  const lines = cell.text.split("\n");
2583
2765
  const out = [lines[0]];
2584
2766
  for (const line of lines.slice(1)) {
2585
- if (_chunkWN5YLP7Hcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
2767
+ if (_chunkE2644XCOcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
2586
2768
  else out.push(line);
2587
2769
  }
2588
2770
  cell.text = out.join("\n");
@@ -2593,19 +2775,19 @@ function joinLatinCellWraps(blocks) {
2593
2775
  }
2594
2776
  function cleanPdfText(text, opts) {
2595
2777
  let clean = normalizeAraea(stripControlChars(text));
2596
- if (!_optionalChain([opts, 'optionalAccess', _228 => _228.keepLoneNumbers])) {
2778
+ if (!_optionalChain([opts, 'optionalAccess', _295 => _295.keepLoneNumbers])) {
2597
2779
  clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
2598
2780
  }
2599
- if (!_optionalChain([opts, 'optionalAccess', _229 => _229.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
2781
+ if (!_optionalChain([opts, 'optionalAccess', _296 => _296.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
2600
2782
  return mergeKoreanLines(
2601
2783
  clean.replace(/^[\s]*[-–—]\s*[-–—]?\d+[-–—]?[\s]*[-–—]?[\s]*$/gm, "").replace(/^\s*\d+\s*\/\s*\d+\s*$/gm, "").replace(/\.(?: \.){3,}/g, (m) => ".".repeat(m.length + 1 >> 1))
2602
2784
  ).replace(/^(?!\| ---).*$/gm, (line) => {
2603
2785
  if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
2604
2786
  if (line.startsWith("|")) {
2605
- return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkWN5YLP7Hcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
2787
+ return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkE2644XCOcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
2606
2788
  }
2607
- const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _230 => _230.exec, 'call', _231 => _231(line), 'optionalAccess', _232 => _232[0]]), () => ( ""));
2608
- return mark + _chunkWN5YLP7Hcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
2789
+ const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _297 => _297.exec, 'call', _298 => _298(line), 'optionalAccess', _299 => _299[0]]), () => ( ""));
2790
+ return mark + _chunkE2644XCOcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
2609
2791
  }).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
2610
2792
  }
2611
2793
  function startsWithMarker(line) {
@@ -2637,7 +2819,7 @@ function mergeKoreanLines(text) {
2637
2819
  continue;
2638
2820
  }
2639
2821
  if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
2640
- result[result.length - 1] = prev + _chunkWN5YLP7Hcjs.wrapJoiner.call(void 0, prev, curr) + curr;
2822
+ result[result.length - 1] = prev + _chunkE2644XCOcjs.wrapJoiner.call(void 0, prev, curr) + curr;
2641
2823
  } else {
2642
2824
  result.push(curr);
2643
2825
  }
@@ -2653,7 +2835,7 @@ function applyLinkAnnotations(items, annots) {
2653
2835
  const wrapped = /* @__PURE__ */ new Set();
2654
2836
  for (const a of annots) {
2655
2837
  if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
2656
- const url = _chunkSHRRD2TDcjs.sanitizeHref.call(void 0, a.url);
2838
+ const url = _chunk3XSP7V5Pcjs.sanitizeHref.call(void 0, a.url);
2657
2839
  if (!url) continue;
2658
2840
  const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
2659
2841
  const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
@@ -2694,7 +2876,7 @@ function mergeLinkRuns(markdown) {
2694
2876
 
2695
2877
  // src/pdf/formula-ocr.ts
2696
2878
  async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
2697
- const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-BQ5RW5XD.cjs")));
2879
+ const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-YYJQBKEN.cjs")));
2698
2880
  const { FormulaPipeline, ensureFormulaModels } = formulaMod;
2699
2881
  await ensureFormulaModels((p) => {
2700
2882
  if (p.phase === "download" && p.total) {
@@ -2873,13 +3055,13 @@ async function loadPdfWithTimeout(buffer) {
2873
3055
  try {
2874
3056
  return await Promise.race([
2875
3057
  loadingTask.promise.catch((e) => {
2876
- if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkSHRRD2TDcjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C PDF \uD30C\uC77C\uC785\uB2C8\uB2E4 (PDF \uC5F4\uAE30 \uC554\uD638\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4)");
3058
+ if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunk3XSP7V5Pcjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C PDF \uD30C\uC77C\uC785\uB2C8\uB2E4 (PDF \uC5F4\uAE30 \uC554\uD638\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4)");
2877
3059
  throw e;
2878
3060
  }),
2879
3061
  new Promise((_, reject) => {
2880
3062
  timer = setTimeout(() => {
2881
3063
  loadingTask.destroy();
2882
- reject(new (0, _chunkSHRRD2TDcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
3064
+ reject(new (0, _chunk3XSP7V5Pcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
2883
3065
  }, PDF_LOAD_TIMEOUT_MS);
2884
3066
  })
2885
3067
  ]);
@@ -2888,13 +3070,13 @@ async function loadPdfWithTimeout(buffer) {
2888
3070
  }
2889
3071
  }
2890
3072
  async function parsePdfDocument(buffer, options) {
2891
- const formulaBuffer = _optionalChain([options, 'optionalAccess', _233 => _233.formulaOcr]) ? buffer : null;
2892
- const autoOcr = _optionalChain([options, 'optionalAccess', _234 => _234.ocr]) === void 0 && await _chunkWN5YLP7Hcjs.ocrModelsCached.call(void 0, );
2893
- const ocrBuffer = _optionalChain([options, 'optionalAccess', _235 => _235.ocr]) || autoOcr ? buffer : null;
3073
+ const formulaBuffer = _optionalChain([options, 'optionalAccess', _300 => _300.formulaOcr]) ? buffer : null;
3074
+ const autoOcr = _optionalChain([options, 'optionalAccess', _301 => _301.ocr]) === void 0 && await _chunkE2644XCOcjs.ocrModelsCached.call(void 0, );
3075
+ const ocrBuffer = _optionalChain([options, 'optionalAccess', _302 => _302.ocr]) || autoOcr ? buffer : null;
2894
3076
  const doc = await loadPdfWithTimeout(buffer);
2895
3077
  try {
2896
3078
  const pageCount = doc.numPages;
2897
- if (pageCount === 0) throw new (0, _chunkSHRRD2TDcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
3079
+ if (pageCount === 0) throw new (0, _chunk3XSP7V5Pcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
2898
3080
  const metadata = { pageCount, pageMode: "layout" };
2899
3081
  await extractPdfMetadata(doc, metadata);
2900
3082
  const blocks = [];
@@ -2903,8 +3085,8 @@ async function parsePdfDocument(buffer, options) {
2903
3085
  let totalChars = 0;
2904
3086
  let totalTextBytes = 0;
2905
3087
  const effectivePageCount = Math.min(pageCount, MAX_PAGES);
2906
- const pageFilter = _optionalChain([options, 'optionalAccess', _236 => _236.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
2907
- if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _237 => _237.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
3088
+ const pageFilter = _optionalChain([options, 'optionalAccess', _303 => _303.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
3089
+ if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _304 => _304.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
2908
3090
  warnings.push({ message: `${pageCount}\uCABD \uC911 \uC55E ${MAX_PAGES}\uCABD\uB9CC \uD30C\uC2F1\uD588\uC2B5\uB2C8\uB2E4 (\uCABD \uC218 \uC0C1\uD55C)`, code: "PARTIAL_PARSE" });
2909
3091
  }
2910
3092
  const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
@@ -2917,12 +3099,29 @@ async function parsePdfDocument(buffer, options) {
2917
3099
  const uncoveredImageRegions = /* @__PURE__ */ new Map();
2918
3100
  const largeImageRegions = /* @__PURE__ */ new Set();
2919
3101
  const imageState = createPdfImageState();
3102
+ const imageBulletShapes = /* @__PURE__ */ new Map();
3103
+ const imageArrowDirections = /* @__PURE__ */ new Map();
2920
3104
  const extractedImages = [];
2921
3105
  const pageImageBlocks = /* @__PURE__ */ new Map();
2922
3106
  const carry = {};
2923
3107
  const vectorPageOps = /* @__PURE__ */ new Map();
2924
- const wrapLexicon = new (0, _chunkWN5YLP7Hcjs.WrapLexicon)();
3108
+ const wrapLexicon = new (0, _chunkE2644XCOcjs.WrapLexicon)();
2925
3109
  const noteMarks = /* @__PURE__ */ new Map();
3110
+ const headerContext = [];
3111
+ if (pageFilter && _optionalChain([options, 'optionalAccess', _305 => _305.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
3112
+ for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
3113
+ let contextPage;
3114
+ try {
3115
+ contextPage = await doc.getPage(number);
3116
+ const content = await contextPage.getTextContent();
3117
+ pageHeights.set(number, contextPage.view[3] - contextPage.view[1]);
3118
+ headerContext.push(...marginContextBlocks(content.items, number, contextPage.view));
3119
+ } catch (e4) {
3120
+ } finally {
3121
+ _optionalChain([contextPage, 'optionalAccess', _306 => _306.cleanup, 'call', _307 => _307()]);
3122
+ }
3123
+ }
3124
+ }
2926
3125
  let parsedPages = 0;
2927
3126
  for (let i = 1; i <= effectivePageCount; i++) {
2928
3127
  if (pageFilter && !pageFilter.has(i)) continue;
@@ -2940,17 +3139,17 @@ async function parsePdfDocument(buffer, options) {
2940
3139
  const fontObj = (loadedName) => {
2941
3140
  try {
2942
3141
  return page.commonObjs.has(loadedName) ? page.commonObjs.get(loadedName) : void 0;
2943
- } catch (e4) {
3142
+ } catch (e5) {
2944
3143
  return void 0;
2945
3144
  }
2946
3145
  };
2947
- const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _238 => _238(loadedName), 'optionalAccess', _239 => _239.differences]);
2948
- restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _240 => _240(n), 'optionalAccess', _241 => _241.name]));
3146
+ const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _308 => _308(loadedName), 'optionalAccess', _309 => _309.differences]);
3147
+ restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _310 => _310(n), 'optionalAccess', _311 => _311.name]));
2949
3148
  restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
2950
3149
  markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
2951
3150
  const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
2952
- const items = _chunkWN5YLP7Hcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
2953
- const filtered = _chunkWN5YLP7Hcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
3151
+ const items = _chunkE2644XCOcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
3152
+ const filtered = _chunkE2644XCOcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
2954
3153
  const joined = joinVerticalColumns(filtered.visible);
2955
3154
  const visible = dropTabLeaderDots(joined);
2956
3155
  const hiddenCount = filtered.hiddenCount + occluded.size;
@@ -2963,7 +3162,7 @@ async function parsePdfDocument(buffer, options) {
2963
3162
  try {
2964
3163
  const annots = await page.getAnnotations();
2965
3164
  applyLinkAnnotations(visible, annots);
2966
- } catch (e5) {
3165
+ } catch (e6) {
2967
3166
  }
2968
3167
  const shifted = viewX1 !== 0 || viewY1 !== 0;
2969
3168
  if (shifted) for (const item of visible) {
@@ -2974,26 +3173,27 @@ async function parsePdfDocument(buffer, options) {
2974
3173
  fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
2975
3174
  argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
2976
3175
  } : rawOps;
2977
- remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _242 => _242(loadedName), 'optionalAccess', _243 => _243.name]));
3176
+ remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _312 => _312(loadedName), 'optionalAccess', _313 => _313.name]));
2978
3177
  remapControlGlyphs(visible, differencesOf);
3178
+ await _chunkE2644XCOcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
2979
3179
  const faces = /* @__PURE__ */ new Map();
2980
3180
  for (const it of visible) {
2981
3181
  if (!it.fontName) continue;
2982
3182
  let face = faces.get(it.fontName);
2983
3183
  if (face === void 0) {
2984
3184
  const obj = fontObj(it.fontName);
2985
- face = _optionalChain([obj, 'optionalAccess', _244 => _244.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
3185
+ face = _optionalChain([obj, 'optionalAccess', _314 => _314.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
2986
3186
  faces.set(it.fontName, face);
2987
3187
  }
2988
3188
  it.fontName = face;
2989
- if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _245 => _245(face), 'optionalAccess', _246 => _246.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
3189
+ if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _315 => _315(face), 'optionalAccess', _316 => _316.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
2990
3190
  }
2991
- for (const it of visible) if (it.text.includes("$")) it.text = _chunk2ZBLQVAScjs.escapeLiteralDollar.call(void 0, it.text);
2992
- for (const it of visible) if (it.text.includes("<")) it.text = _chunk2ZBLQVAScjs.escapeLiteralTags.call(void 0, it.text);
3191
+ for (const it of visible) if (it.text.includes("$")) it.text = _chunk3WLZOJIEcjs.escapeLiteralDollar.call(void 0, it.text);
3192
+ for (const it of visible) if (it.text.includes("<")) it.text = _chunk3WLZOJIEcjs.escapeLiteralTags.call(void 0, it.text);
2993
3193
  wrapEquationRuns(visible, (face) => faceNames.get(face));
2994
3194
  const pageArea = pageW * pageH;
2995
3195
  if (pageArea > 0) {
2996
- const imageRegions = _chunkWN5YLP7Hcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
3196
+ const imageRegions = _chunkE2644XCOcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
2997
3197
  let uncovered = 0;
2998
3198
  for (const r of imageRegions) {
2999
3199
  const area = (r.x2 - r.x1) * (r.y2 - r.y1);
@@ -3019,17 +3219,18 @@ async function parsePdfDocument(buffer, options) {
3019
3219
  if (uncovered > 0) skippedImagePages.set(i, uncovered);
3020
3220
  }
3021
3221
  const marks = superscriptNoteMarks(visible);
3022
- if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkWN5YLP7Hcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
3222
+ if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkE2644XCOcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
3023
3223
  const stamp = marginStamp(visible);
3024
3224
  const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
3025
- const pageBlocks = orderTwoUpPage(_chunkWN5YLP7Hcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _247 => _247.tables]) !== false, carry, wrapLexicon), pageW, pageH);
3225
+ const rightArrows = _optionalChain([options, 'optionalAccess', _317 => _317.tables]) !== false ? await _chunkE2644XCOcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
3226
+ const pageBlocks = orderTwoUpPage(_chunkE2644XCOcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _318 => _318.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
3026
3227
  if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
3027
3228
  for (const b of pageBlocks) blocks.push(b);
3028
3229
  try {
3029
- const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _248 => _248.images]) !== false);
3230
+ const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _319 => _319.images]) !== false);
3030
3231
  if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
3031
3232
  extractedImages.push(...pageImages);
3032
- } catch (e6) {
3233
+ } catch (e7) {
3033
3234
  }
3034
3235
  let pageText = "";
3035
3236
  for (const b of pageBlocks) {
@@ -3045,27 +3246,27 @@ async function parsePdfDocument(buffer, options) {
3045
3246
  const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
3046
3247
  const quality = computePageQuality(i, pageText, vector.glyphs);
3047
3248
  pageQuality.push(quality);
3048
- if (_optionalChain([options, 'optionalAccess', _249 => _249.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
3249
+ if (_optionalChain([options, 'optionalAccess', _320 => _320.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
3049
3250
  vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
3050
3251
  }
3051
- if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkSHRRD2TDcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
3252
+ if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunk3XSP7V5Pcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
3052
3253
  parsedPages++;
3053
- _optionalChain([options, 'optionalAccess', _250 => _250.onProgress, 'optionalCall', _251 => _251(parsedPages, totalTarget)]);
3254
+ _optionalChain([options, 'optionalAccess', _321 => _321.onProgress, 'optionalCall', _322 => _322(parsedPages, totalTarget)]);
3054
3255
  } catch (pageErr) {
3055
- if (pageErr instanceof _chunkSHRRD2TDcjs.KordocError) throw pageErr;
3256
+ if (pageErr instanceof _chunk3XSP7V5Pcjs.KordocError) throw pageErr;
3056
3257
  warnings.push({ page: i, message: `\uD398\uC774\uC9C0 ${i} \uD30C\uC2F1 \uC2E4\uD328: ${pageErr instanceof Error ? pageErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
3057
3258
  } finally {
3058
- _optionalChain([loadedPage, 'optionalAccess', _252 => _252.cleanup, 'call', _253 => _253()]);
3259
+ _optionalChain([loadedPage, 'optionalAccess', _323 => _323.cleanup, 'call', _324 => _324()]);
3059
3260
  }
3060
3261
  }
3061
3262
  const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
3062
- const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _254 => _254.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
3263
+ const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _325 => _325.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
3063
3264
  const ocrDone = /* @__PURE__ */ new Set();
3064
- const ocrRegions = _optionalChain([options, 'optionalAccess', _255 => _255.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _256 => _256.ocr]) === true) : /* @__PURE__ */ new Map();
3265
+ const ocrRegions = _optionalChain([options, 'optionalAccess', _326 => _326.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _327 => _327.ocr]) === true) : /* @__PURE__ */ new Map();
3065
3266
  if (ocrBuffer) {
3066
3267
  const inScope = (p) => !pageFilter || pageFilter.has(p);
3067
3268
  const targets = /* @__PURE__ */ new Set();
3068
- if (_optionalChain([options, 'optionalAccess', _257 => _257.ocr]) === "force" || isImageBased) {
3269
+ if (_optionalChain([options, 'optionalAccess', _328 => _328.ocr]) === "force" || isImageBased) {
3069
3270
  for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
3070
3271
  } else {
3071
3272
  for (const pq of pageQuality) {
@@ -3078,16 +3279,16 @@ async function parsePdfDocument(buffer, options) {
3078
3279
  }
3079
3280
  if (targets.size > 0) {
3080
3281
  try {
3081
- const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-NF4AY5MI.cjs")));
3082
- const mode = typeof _optionalChain([options, 'optionalAccess', _258 => _258.ocr]) === "function" ? options.ocr : "builtin";
3083
- const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _259 => _259.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _260 => _260.find, 'call', _261 => _261((q) => q.page === p), 'optionalAccess', _262 => _262.needsOcr])));
3084
- const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _263 => _263.onProgress]), _optionalChain([options, 'optionalAccess', _264 => _264.tables]) !== false, vectorPageOps, regionPages);
3085
- for (const obs of ocrPageBlocks.values()) _chunk2ZBLQVAScjs.stripScriptTags.call(void 0, { blocks: obs });
3282
+ const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-EJ2HNZN6.cjs")));
3283
+ const mode = typeof _optionalChain([options, 'optionalAccess', _329 => _329.ocr]) === "function" ? options.ocr : "builtin";
3284
+ const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _330 => _330.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _331 => _331.find, 'call', _332 => _332((q) => q.page === p), 'optionalAccess', _333 => _333.needsOcr])));
3285
+ const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _334 => _334.onProgress]), _optionalChain([options, 'optionalAccess', _335 => _335.tables]) !== false, vectorPageOps, regionPages);
3286
+ for (const obs of ocrPageBlocks.values()) _chunk3WLZOJIEcjs.stripScriptTags.call(void 0, { blocks: obs });
3086
3287
  if (ocrPageBlocks.size > 0) {
3087
3288
  const replacePages = /* @__PURE__ */ new Set();
3088
3289
  for (const [p, obs] of ocrPageBlocks) {
3089
- const needsOcr = _optionalChain([pageQuality, 'access', _265 => _265.find, 'call', _266 => _266((q) => q.page === p), 'optionalAccess', _267 => _267.needsOcr]);
3090
- if (_optionalChain([options, 'optionalAccess', _268 => _268.ocr]) === "force" || isImageBased || needsOcr) {
3290
+ const needsOcr = _optionalChain([pageQuality, 'access', _336 => _336.find, 'call', _337 => _337((q) => q.page === p), 'optionalAccess', _338 => _338.needsOcr]);
3291
+ if (_optionalChain([options, 'optionalAccess', _339 => _339.ocr]) === "force" || isImageBased || needsOcr) {
3091
3292
  replacePages.add(p);
3092
3293
  ocrDone.add(p);
3093
3294
  continue;
@@ -3095,7 +3296,7 @@ async function parsePdfDocument(buffer, options) {
3095
3296
  const regions = ocrRegions.get(p);
3096
3297
  if (!regions || mergeOcrImageRegions(blocks, p, regions, obs) === 0) continue;
3097
3298
  ocrDone.add(p);
3098
- if (_optionalChain([pageImageBlocks, 'access', _269 => _269.get, 'call', _270 => _270(p), 'optionalAccess', _271 => _271.length]) === 1) pageImageBlocks.delete(p);
3299
+ if (_optionalChain([pageImageBlocks, 'access', _340 => _340.get, 'call', _341 => _341(p), 'optionalAccess', _342 => _342.length]) === 1) pageImageBlocks.delete(p);
3099
3300
  }
3100
3301
  if (replacePages.size) {
3101
3302
  const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
@@ -3145,12 +3346,12 @@ async function parsePdfDocument(buffer, options) {
3145
3346
  warnings.push({ page, message: `${count}\uAC1C \uC774\uBBF8\uC9C0 \uC601\uC5ED\uC5D0 \uCD94\uCD9C \uAC00\uB2A5\uD55C \uD14D\uC2A4\uD2B8 \uC5C6\uC74C (\uADF8\uB9BC/\uCC28\uD2B8/\uB3C4\uC7A5 \uB0B4\uC6A9 \uB204\uB77D \uAC00\uB2A5 \u2014 \uADF8\uB9BC \uC18D \uAE00\uC740 ocr: true / CLI --ocr \uB85C \uC77D\uC2B5\uB2C8\uB2E4)`, code: "SKIPPED_IMAGE" });
3146
3347
  }
3147
3348
  }
3148
- if (_optionalChain([options, 'optionalAccess', _272 => _272.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
3149
- const removed = _chunkWN5YLP7Hcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks);
3349
+ if (_optionalChain([options, 'optionalAccess', _343 => _343.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
3350
+ const removed = _chunkE2644XCOcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
3150
3351
  for (let ri = removed.length - 1; ri >= 0; ri--) {
3151
3352
  blocks.splice(removed[ri], 1);
3152
3353
  }
3153
- const kept = _chunkWN5YLP7Hcjs.removeSideTabs.call(void 0, blocks, pageWidths);
3354
+ const kept = _chunkE2644XCOcjs.removeSideTabs.call(void 0, blocks, pageWidths);
3154
3355
  if (kept !== blocks) {
3155
3356
  blocks.length = 0;
3156
3357
  blocks.push(...kept);
@@ -3158,15 +3359,15 @@ async function parsePdfDocument(buffer, options) {
3158
3359
  }
3159
3360
  mergeContinuedCells(blocks, pageHeights);
3160
3361
  mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
3161
- if (_optionalChain([options, 'optionalAccess', _273 => _273.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
3162
- const boxes = _chunkWN5YLP7Hcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
3362
+ if (_optionalChain([options, 'optionalAccess', _344 => _344.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
3363
+ const boxes = _chunkE2644XCOcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
3163
3364
  for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
3164
3365
  }
3165
3366
  splitContactTables(blocks);
3166
- if (!_optionalChain([options, 'optionalAccess', _274 => _274.keepTrailingEmptyCols])) _chunkWN5YLP7Hcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
3167
- _chunkWN5YLP7Hcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
3367
+ if (!_optionalChain([options, 'optionalAccess', _345 => _345.keepTrailingEmptyCols])) _chunkE2644XCOcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
3368
+ _chunkE2644XCOcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
3168
3369
  injectPageImageBlocks(blocks, pageImageBlocks);
3169
- if (_optionalChain([options, 'optionalAccess', _275 => _275.formulaOcr]) && formulaBuffer) {
3370
+ if (_optionalChain([options, 'optionalAccess', _346 => _346.formulaOcr]) && formulaBuffer) {
3170
3371
  try {
3171
3372
  await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
3172
3373
  } catch (e) {
@@ -3176,49 +3377,53 @@ async function parsePdfDocument(buffer, options) {
3176
3377
  });
3177
3378
  }
3178
3379
  }
3179
- const medianFontSize = _chunkWN5YLP7Hcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
3380
+ const medianFontSize = _chunkE2644XCOcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
3180
3381
  if (medianFontSize > 0) {
3181
- _chunkWN5YLP7Hcjs.detectHeadings.call(void 0, blocks, medianFontSize);
3182
- }
3183
- _chunkWN5YLP7Hcjs.detectDocumentStyleHeadings.call(void 0, blocks);
3184
- _chunkWN5YLP7Hcjs.detectTypographyHeadings.call(void 0, blocks);
3185
- _chunkWN5YLP7Hcjs.detectSiblingStyleHeadings.call(void 0, blocks);
3186
- _chunkWN5YLP7Hcjs.detectRepeatedPageLabels.call(void 0, blocks);
3187
- _chunkWN5YLP7Hcjs.detectPageLeadHeadings.call(void 0, blocks);
3188
- _chunkWN5YLP7Hcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
3189
- _chunkWN5YLP7Hcjs.refineDocumentStyleHeadings.call(void 0, blocks);
3190
- _chunkWN5YLP7Hcjs.detectMarkerHeadings.call(void 0, blocks);
3382
+ _chunkE2644XCOcjs.detectHeadings.call(void 0, blocks, medianFontSize);
3383
+ }
3384
+ _chunkE2644XCOcjs.detectDocumentStyleHeadings.call(void 0, blocks);
3385
+ _chunkE2644XCOcjs.detectTypographyHeadings.call(void 0, blocks);
3386
+ _chunkE2644XCOcjs.detectSiblingStyleHeadings.call(void 0, blocks);
3387
+ _chunkE2644XCOcjs.detectRepeatedPageLabels.call(void 0, blocks);
3388
+ _chunkE2644XCOcjs.detectPageLeadHeadings.call(void 0, blocks);
3389
+ _chunkE2644XCOcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
3390
+ _chunkE2644XCOcjs.refineDocumentStyleHeadings.call(void 0, blocks);
3391
+ _chunkE2644XCOcjs.detectMarkerHeadings.call(void 0, blocks);
3191
3392
  demoteNonHeadingRoles(blocks, pageHeights, faceNames);
3192
- _chunkWN5YLP7Hcjs.detectTableCaptions.call(void 0, blocks);
3193
- _chunkWN5YLP7Hcjs.detectKoreanListBlocks.call(void 0, blocks);
3393
+ _chunkE2644XCOcjs.detectTableCaptions.call(void 0, blocks);
3394
+ _chunkE2644XCOcjs.detectKoreanListBlocks.call(void 0, blocks);
3194
3395
  const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
3195
3396
  sanitizeBlockControlChars(blocks);
3196
3397
  let outBlocks = splitSingleCellTables(blocks);
3398
+ if (_optionalChain([options, 'optionalAccess', _347 => _347.layoutTables]) !== "keep") {
3399
+ blocks.length = 0;
3400
+ for (const block of outBlocks) blocks.push(block);
3401
+ }
3197
3402
  outBlocks = inlineFootnotes(outBlocks, noteMarks);
3198
3403
  outBlocks = relocateEndnotes(outBlocks);
3199
- if (_optionalChain([options, 'optionalAccess', _276 => _276.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
3404
+ if (_optionalChain([options, 'optionalAccess', _348 => _348.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
3200
3405
  if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
3201
3406
  const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
3202
3407
  if (!b.bbox || !h) return false;
3203
3408
  return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
3204
3409
  });
3205
3410
  joinLatinCellWraps(outBlocks);
3206
- if (_optionalChain([options, 'optionalAccess', _277 => _277.layoutTables]) !== "keep") {
3411
+ if (_optionalChain([options, 'optionalAccess', _349 => _349.layoutTables]) !== "keep") {
3207
3412
  const hancom = await isHancomPdf(doc);
3208
3413
  const shown = /* @__PURE__ */ new Map();
3209
3414
  const markContent = (bs) => {
3210
3415
  for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
3211
- if (_chunkWN5YLP7Hcjs.IMAGE_CELLS.has(c)) _chunk2ZBLQVAScjs.CONTENT_CELLS.add(c);
3416
+ if (_chunkE2644XCOcjs.IMAGE_CELLS.has(c)) _chunk3WLZOJIEcjs.CONTENT_CELLS.add(c);
3212
3417
  markContent(c.blocks);
3213
3418
  }
3214
3419
  };
3215
3420
  const visual = (bs) => bs.flatMap((b) => {
3216
3421
  if (b.type !== "table") return [b];
3217
- if (!hancom && b.table && _chunkWN5YLP7Hcjs.CLIP_TABLES.has(b.table)) return [b];
3422
+ if (!hancom && b.table && _chunkE2644XCOcjs.CLIP_TABLES.has(b.table)) return [b];
3218
3423
  let v = shown.get(b);
3219
3424
  if (!v) {
3220
3425
  markContent([b]);
3221
- shown.set(b, v = _chunk2ZBLQVAScjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _278 => _278.keepTrailingEmptyCols])));
3426
+ shown.set(b, v = _chunk3WLZOJIEcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _350 => _350.keepTrailingEmptyCols])));
3222
3427
  }
3223
3428
  return v;
3224
3429
  });
@@ -3227,11 +3432,11 @@ async function parsePdfDocument(buffer, options) {
3227
3432
  blocks.length = 0;
3228
3433
  for (const b of kept) blocks.push(b);
3229
3434
  }
3230
- const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunk2ZBLQVAScjs.blocksToMarkdown.call(void 0, bs), { keepLoneNumbers: true }));
3435
+ const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunk3WLZOJIEcjs.blocksToMarkdown.call(void 0, bs), { keepLoneNumbers: true }));
3231
3436
  let markdown = finishMarkdown(outBlocks);
3232
3437
  return {
3233
3438
  markdown,
3234
- pages: _chunkV4BKT65Dcjs.blocksToPages.call(void 0, outBlocks, finishMarkdown),
3439
+ pages: _chunkSVNBZEL6cjs.blocksToPages.call(void 0, outBlocks, finishMarkdown),
3235
3440
  blocks,
3236
3441
  metadata,
3237
3442
  outline: outline.length > 0 ? outline : void 0,
@@ -3249,7 +3454,7 @@ async function parsePdfDocument(buffer, options) {
3249
3454
  async function extractPdfMetadata(doc, metadata) {
3250
3455
  try {
3251
3456
  const result = await doc.getMetadata();
3252
- if (!_optionalChain([result, 'optionalAccess', _279 => _279.info])) return;
3457
+ if (!_optionalChain([result, 'optionalAccess', _351 => _351.info])) return;
3253
3458
  const info = result.info;
3254
3459
  if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
3255
3460
  if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
@@ -3260,14 +3465,14 @@ async function extractPdfMetadata(doc, metadata) {
3260
3465
  }
3261
3466
  if (typeof info.CreationDate === "string") metadata.createdAt = parsePdfDate(info.CreationDate);
3262
3467
  if (typeof info.ModDate === "string") metadata.modifiedAt = parsePdfDate(info.ModDate);
3263
- } catch (e7) {
3468
+ } catch (e8) {
3264
3469
  }
3265
3470
  }
3266
3471
  async function isHancomPdf(doc) {
3267
3472
  try {
3268
- const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _280 => _280.info]);
3269
- return [_optionalChain([info, 'optionalAccess', _281 => _281.Producer]), _optionalChain([info, 'optionalAccess', _282 => _282.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
3270
- } catch (e8) {
3473
+ const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _352 => _352.info]);
3474
+ return [_optionalChain([info, 'optionalAccess', _353 => _353.Producer]), _optionalChain([info, 'optionalAccess', _354 => _354.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
3475
+ } catch (e9) {
3271
3476
  return false;
3272
3477
  }
3273
3478
  }
@@ -3309,5 +3514,5 @@ function marginStamp(items) {
3309
3514
 
3310
3515
 
3311
3516
 
3312
- exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkWN5YLP7Hcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkWN5YLP7Hcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkWN5YLP7Hcjs.removeHeaderFooterBlocks;
3313
- //# sourceMappingURL=parser-JOMFOZLH.cjs.map
3517
+ exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkE2644XCOcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkE2644XCOcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkE2644XCOcjs.removeHeaderFooterBlocks;
3518
+ //# sourceMappingURL=parser-BGORCLIU.cjs.map