kordoc 4.18.13 → 4.19.1

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 (131) hide show
  1. package/README.md +3 -1
  2. package/dist/{-DC2OO5KO.js → -LYUUVVQF.js} +11 -11
  3. package/dist/{chunk-ISC2TH24.js → chunk-4WTJS6ES.js} +2 -2
  4. package/dist/{chunk-SVIOP7PE.js → chunk-5AZQEMMG.js} +7 -7
  5. package/dist/{chunk-SVIOP7PE.js.map → chunk-5AZQEMMG.js.map} +1 -1
  6. package/dist/{chunk-GUH6HYSZ.js → chunk-6KOQPPLX.js} +25 -22
  7. package/dist/chunk-6KOQPPLX.js.map +1 -0
  8. package/dist/{chunk-PN5WWW56.js → chunk-7L5GY54Q.js} +2 -2
  9. package/dist/{chunk-PN5WWW56.js.map → chunk-7L5GY54Q.js.map} +1 -1
  10. package/dist/{chunk-PHMWSWHJ.js → chunk-7XRI4FL4.js} +2 -2
  11. package/dist/{chunk-32ZUIHSY.js → chunk-ADBES5QJ.js} +3 -3
  12. package/dist/{chunk-JWTZ3OVZ.js → chunk-BDTWXJNM.js} +2 -2
  13. package/dist/{chunk-INESPVEV.js → chunk-CL3CJ7X5.js} +3 -3
  14. package/dist/{chunk-VDEENOPW.js → chunk-DQHDI567.js} +2 -2
  15. package/dist/{chunk-ZNY5BRV6.js → chunk-FEGRQA3Q.js} +4 -4
  16. package/dist/{chunk-3FGHQWJP.cjs → chunk-FNX3ZAYB.cjs} +22 -22
  17. package/dist/{chunk-3FGHQWJP.cjs.map → chunk-FNX3ZAYB.cjs.map} +1 -1
  18. package/dist/{chunk-GGMIPTM5.cjs → chunk-GPNPYBXJ.cjs} +12 -12
  19. package/dist/{chunk-GGMIPTM5.cjs.map → chunk-GPNPYBXJ.cjs.map} +1 -1
  20. package/dist/{chunk-6CQZMVXW.cjs → chunk-HMJXB7ZE.cjs} +3 -3
  21. package/dist/{chunk-6CQZMVXW.cjs.map → chunk-HMJXB7ZE.cjs.map} +1 -1
  22. package/dist/{chunk-IRN5SDY2.js → chunk-JA5B4NPF.js} +2 -2
  23. package/dist/{chunk-GSW7W7AL.js → chunk-JNIJPP4B.js} +7 -4
  24. package/dist/chunk-JNIJPP4B.js.map +1 -0
  25. package/dist/{chunk-EZSWBHHI.js → chunk-KYFP5LDC.js} +2 -2
  26. package/dist/{chunk-XVB3PUPJ.js → chunk-L5N5UQBP.js} +10 -4
  27. package/dist/chunk-L5N5UQBP.js.map +1 -0
  28. package/dist/{chunk-6AYTYTFY.js → chunk-MSUGYK6A.js} +3 -3
  29. package/dist/{chunk-K6WSMTVU.cjs → chunk-RHMIEEAZ.cjs} +2 -2
  30. package/dist/{chunk-K6WSMTVU.cjs.map → chunk-RHMIEEAZ.cjs.map} +1 -1
  31. package/dist/{chunk-JKHU7HID.js → chunk-TRUR4RUJ.js} +95 -11
  32. package/dist/chunk-TRUR4RUJ.js.map +1 -0
  33. package/dist/{chunk-DHEUQXXR.js → chunk-UAAYIEIK.js} +2 -2
  34. package/dist/{chunk-RQEDNI4P.cjs → chunk-UOXOYZU4.cjs} +3 -3
  35. package/dist/{chunk-RQEDNI4P.cjs.map → chunk-UOXOYZU4.cjs.map} +1 -1
  36. package/dist/{chunk-6FW3AZWN.cjs → chunk-W5NXOMCD.cjs} +125 -35
  37. package/dist/chunk-W5NXOMCD.cjs.map +1 -0
  38. package/dist/{chunk-V7LKQNC4.js → chunk-X6ME7YYS.js} +2 -2
  39. package/dist/{chunk-LKA7Z2NH.js → chunk-XFZMRCGJ.js} +2 -2
  40. package/dist/{chunk-JPSLMPFI.js → chunk-YLST4S4P.js} +103 -13
  41. package/dist/chunk-YLST4S4P.js.map +1 -0
  42. package/dist/{chunk-EBXJ45VZ.js → chunk-Z2WI3E4N.js} +2 -2
  43. package/dist/{chunk-EBXJ45VZ.js.map → chunk-Z2WI3E4N.js.map} +1 -1
  44. package/dist/{chunk-7LOD4IGO.js → chunk-ZTGTFO52.js} +4 -4
  45. package/dist/chunks-T67OQGPJ.js +10 -0
  46. package/dist/cli.js +39 -28
  47. package/dist/cli.js.map +1 -1
  48. package/dist/{formula-DAMFHLQO.js → formula-G4YA7SNQ.js} +3 -3
  49. package/dist/{formula-HJNQGPRC.cjs → formula-J3UUIPCX.cjs} +9 -9
  50. package/dist/{formula-HJNQGPRC.cjs.map → formula-J3UUIPCX.cjs.map} +1 -1
  51. package/dist/{formula-YCAO5IVW.js → formula-QSZRYZ44.js} +4 -4
  52. package/dist/{image-ocr-AZ25IOC7.cjs → image-ocr-467KLV3F.cjs} +15 -15
  53. package/dist/{image-ocr-AZ25IOC7.cjs.map → image-ocr-467KLV3F.cjs.map} +1 -1
  54. package/dist/{image-ocr-VH54SDZ7.js → image-ocr-I52GBXRE.js} +6 -6
  55. package/dist/{image-ocr-PAF76DAW.js → image-ocr-ZP3F4MUY.js} +9 -9
  56. package/dist/index.cjs +669 -663
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.d.cts +15 -2
  59. package/dist/index.d.ts +15 -2
  60. package/dist/index.js +26 -20
  61. package/dist/index.js.map +1 -1
  62. package/dist/mcp.js +25 -23
  63. package/dist/mcp.js.map +1 -1
  64. package/dist/{model-bundle-53CHDYCG.js → model-bundle-FEUM7XXS.js} +5 -5
  65. package/dist/{models-UVLAKK3M.js → models-6QCNX5YR.js} +5 -5
  66. package/dist/{parser-I4D3TRGU.js → parser-6EIBURDE.js} +179 -13
  67. package/dist/parser-6EIBURDE.js.map +1 -0
  68. package/dist/{parser-HWAOPQYK.cjs → parser-BIJBX2D5.cjs} +393 -227
  69. package/dist/parser-BIJBX2D5.cjs.map +1 -0
  70. package/dist/{parser-Z6PHB54O.js → parser-YX4LGKIK.js} +176 -10
  71. package/dist/parser-YX4LGKIK.js.map +1 -0
  72. package/dist/pdf-ocr-DXQIMO77.cjs +17 -0
  73. package/dist/{pdf-ocr-HR6CXGTX.cjs.map → pdf-ocr-DXQIMO77.cjs.map} +1 -1
  74. package/dist/pdf-ocr-MESGGING.js +20 -0
  75. package/dist/pdf-ocr-YSRBRIPR.js +16 -0
  76. package/dist/{profile-io-WHCWCOPW.js → profile-io-ATHFEUAP.js} +3 -3
  77. package/dist/{rasterize-5DZ3DHGH.js → rasterize-SG3CLXMQ.js} +3 -3
  78. package/dist/{redact-doc-RNJVMFGQ.js → redact-doc-K3S4HFHU.js} +11 -11
  79. package/dist/{render-NZ6RA6SW.js → render-6CQJM7VE.js} +7 -7
  80. package/dist/seal-SMO4544N.js +10 -0
  81. package/dist/{setup-U3EQNK4Z.js → setup-CZ5KHGPI.js} +3 -3
  82. package/dist/visual-UWYGQLOU.js +20 -0
  83. package/dist/{watch-GB2M7XU6.js → watch-RQRIGLFF.js} +12 -12
  84. package/package.json +3 -2
  85. package/dist/chunk-6FW3AZWN.cjs.map +0 -1
  86. package/dist/chunk-GSW7W7AL.js.map +0 -1
  87. package/dist/chunk-GUH6HYSZ.js.map +0 -1
  88. package/dist/chunk-JKHU7HID.js.map +0 -1
  89. package/dist/chunk-JPSLMPFI.js.map +0 -1
  90. package/dist/chunk-XVB3PUPJ.js.map +0 -1
  91. package/dist/chunks-JZW2TXIZ.js +0 -10
  92. package/dist/parser-HWAOPQYK.cjs.map +0 -1
  93. package/dist/parser-I4D3TRGU.js.map +0 -1
  94. package/dist/parser-Z6PHB54O.js.map +0 -1
  95. package/dist/pdf-ocr-F4ICXO7W.js +0 -20
  96. package/dist/pdf-ocr-HR6CXGTX.cjs +0 -17
  97. package/dist/pdf-ocr-JI3K7JIN.js +0 -16
  98. package/dist/seal-WHJ6O5HT.js +0 -10
  99. package/dist/visual-JDAS4R43.js +0 -20
  100. /package/dist/{-DC2OO5KO.js.map → -LYUUVVQF.js.map} +0 -0
  101. /package/dist/{chunk-ISC2TH24.js.map → chunk-4WTJS6ES.js.map} +0 -0
  102. /package/dist/{chunk-PHMWSWHJ.js.map → chunk-7XRI4FL4.js.map} +0 -0
  103. /package/dist/{chunk-32ZUIHSY.js.map → chunk-ADBES5QJ.js.map} +0 -0
  104. /package/dist/{chunk-JWTZ3OVZ.js.map → chunk-BDTWXJNM.js.map} +0 -0
  105. /package/dist/{chunk-INESPVEV.js.map → chunk-CL3CJ7X5.js.map} +0 -0
  106. /package/dist/{chunk-VDEENOPW.js.map → chunk-DQHDI567.js.map} +0 -0
  107. /package/dist/{chunk-ZNY5BRV6.js.map → chunk-FEGRQA3Q.js.map} +0 -0
  108. /package/dist/{chunk-IRN5SDY2.js.map → chunk-JA5B4NPF.js.map} +0 -0
  109. /package/dist/{chunk-EZSWBHHI.js.map → chunk-KYFP5LDC.js.map} +0 -0
  110. /package/dist/{chunk-6AYTYTFY.js.map → chunk-MSUGYK6A.js.map} +0 -0
  111. /package/dist/{chunk-DHEUQXXR.js.map → chunk-UAAYIEIK.js.map} +0 -0
  112. /package/dist/{chunk-V7LKQNC4.js.map → chunk-X6ME7YYS.js.map} +0 -0
  113. /package/dist/{chunk-LKA7Z2NH.js.map → chunk-XFZMRCGJ.js.map} +0 -0
  114. /package/dist/{chunk-7LOD4IGO.js.map → chunk-ZTGTFO52.js.map} +0 -0
  115. /package/dist/{chunks-JZW2TXIZ.js.map → chunks-T67OQGPJ.js.map} +0 -0
  116. /package/dist/{formula-DAMFHLQO.js.map → formula-G4YA7SNQ.js.map} +0 -0
  117. /package/dist/{formula-YCAO5IVW.js.map → formula-QSZRYZ44.js.map} +0 -0
  118. /package/dist/{image-ocr-VH54SDZ7.js.map → image-ocr-I52GBXRE.js.map} +0 -0
  119. /package/dist/{image-ocr-PAF76DAW.js.map → image-ocr-ZP3F4MUY.js.map} +0 -0
  120. /package/dist/{model-bundle-53CHDYCG.js.map → model-bundle-FEUM7XXS.js.map} +0 -0
  121. /package/dist/{models-UVLAKK3M.js.map → models-6QCNX5YR.js.map} +0 -0
  122. /package/dist/{pdf-ocr-F4ICXO7W.js.map → pdf-ocr-MESGGING.js.map} +0 -0
  123. /package/dist/{pdf-ocr-JI3K7JIN.js.map → pdf-ocr-YSRBRIPR.js.map} +0 -0
  124. /package/dist/{profile-io-WHCWCOPW.js.map → profile-io-ATHFEUAP.js.map} +0 -0
  125. /package/dist/{rasterize-5DZ3DHGH.js.map → rasterize-SG3CLXMQ.js.map} +0 -0
  126. /package/dist/{redact-doc-RNJVMFGQ.js.map → redact-doc-K3S4HFHU.js.map} +0 -0
  127. /package/dist/{render-NZ6RA6SW.js.map → render-6CQJM7VE.js.map} +0 -0
  128. /package/dist/{seal-WHJ6O5HT.js.map → seal-SMO4544N.js.map} +0 -0
  129. /package/dist/{setup-U3EQNK4Z.js.map → setup-CZ5KHGPI.js.map} +0 -0
  130. /package/dist/{visual-JDAS4R43.js.map → visual-UWYGQLOU.js.map} +0 -0
  131. /package/dist/{watch-GB2M7XU6.js.map → watch-RQRIGLFF.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 _chunkRQEDNI4Pcjs = require('./chunk-RQEDNI4P.cjs');
4
+ var _chunkUOXOYZU4cjs = require('./chunk-UOXOYZU4.cjs');
5
5
 
6
6
 
7
7
 
@@ -58,7 +58,7 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
58
58
 
59
59
 
60
60
 
61
- var _chunk3FGHQWJPcjs = require('./chunk-3FGHQWJP.cjs');
61
+ var _chunkFNX3ZAYBcjs = require('./chunk-FNX3ZAYB.cjs');
62
62
 
63
63
 
64
64
 
@@ -68,12 +68,14 @@ var _chunk3FGHQWJPcjs = require('./chunk-3FGHQWJP.cjs');
68
68
 
69
69
 
70
70
 
71
- var _chunk6FW3AZWNcjs = require('./chunk-6FW3AZWN.cjs');
72
- require('./chunk-6CQZMVXW.cjs');
73
71
 
74
72
 
73
+ var _chunkW5NXOMCDcjs = require('./chunk-W5NXOMCD.cjs');
74
+ require('./chunk-HMJXB7ZE.cjs');
75
75
 
76
- var _chunkK6WSMTVUcjs = require('./chunk-K6WSMTVU.cjs');
76
+
77
+
78
+ var _chunkRHMIEEAZcjs = require('./chunk-RHMIEEAZ.cjs');
77
79
 
78
80
 
79
81
  var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
@@ -114,7 +116,7 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
114
116
  const selectedSet = new Set(selected), seen = /* @__PURE__ */ new Set();
115
117
  for (const block of selected) {
116
118
  if (seen.has(block)) continue;
117
- const frame = _chunk3FGHQWJPcjs.FRAME_READING_UNITS.get(block);
119
+ const frame = _chunkFNX3ZAYBcjs.FRAME_READING_UNITS.get(block);
118
120
  const source = _optionalChain([frame, 'optionalAccess', _25 => _25.blocks, 'access', _26 => _26.every, 'call', _27 => _27((member) => selectedSet.has(member))]) ? frame.blocks : [block];
119
121
  source.forEach((member) => seen.add(member));
120
122
  const available = source.filter((member) => !hasOriginal(member));
@@ -122,13 +124,13 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
122
124
  for (const unit of units) {
123
125
  const b = unit.bbox;
124
126
  const index = blocks.findIndex((existing) => {
125
- const e = _nullishCoalesce(_optionalChain([_chunk3FGHQWJPcjs.FRAME_READING_UNITS, 'access', _28 => _28.get, 'call', _29 => _29(existing), 'optionalAccess', _30 => _30.bbox]), () => ( existing.bbox));
127
+ const e = _nullishCoalesce(_optionalChain([_chunkFNX3ZAYBcjs.FRAME_READING_UNITS, 'access', _28 => _28.get, 'call', _29 => _29(existing), 'optionalAccess', _30 => _30.bbox]), () => ( existing.bbox));
126
128
  if (existing.pageNumber !== page || !e) return false;
127
129
  const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
128
130
  return e.y < b.y || beside;
129
131
  });
130
132
  const placed = unit.blocks.map((member) => member.type === "paragraph" ? { ...member, style: void 0 } : member);
131
- if (unit.atomic) _chunk3FGHQWJPcjs.recordFrameReadingUnit.call(void 0, placed, unit.bbox);
133
+ if (unit.atomic) _chunkFNX3ZAYBcjs.recordFrameReadingUnit.call(void 0, placed, unit.bbox);
132
134
  blocks.splice(index < 0 ? blocks.length : index, 0, ...placed);
133
135
  added += placed.length;
134
136
  }
@@ -329,7 +331,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
329
331
  const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
330
332
  state.seen.set(hash, filename);
331
333
  if (withBytes) {
332
- const png = _chunkRQEDNI4Pcjs.encodePng.call(void 0, w, h, rgba);
334
+ const png = _chunkUOXOYZU4cjs.encodePng.call(void 0, w, h, rgba);
333
335
  state.totalBytes += png.length;
334
336
  images.push({ filename, data: png, mimeType: "image/png" });
335
337
  }
@@ -757,6 +759,167 @@ function splitContactTables(blocks) {
757
759
  }
758
760
  }
759
761
 
762
+ // src/pdf/table-pages.ts
763
+ var CELL_SPLITS = /* @__PURE__ */ new WeakMap();
764
+ function relocate(src, dst, from = 0) {
765
+ const out = [];
766
+ for (const s of _nullishCoalesce(CELL_SPLITS.get(src), () => ( []))) {
767
+ const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access', _57 => _57.at, 'call', _58 => _58(-1), 'optionalAccess', _59 => _59.at]), () => ( 0))));
768
+ if (at >= 0) out.push({ at, page: s.page });
769
+ }
770
+ return out;
771
+ }
772
+ var setSplits = (cell, splits) => {
773
+ if (splits.length) CELL_SPLITS.set(cell, splits.sort((a, b) => a.at - b.at));
774
+ };
775
+ function markContinuedText(cell, add, page) {
776
+ if (!add.text.trim()) return;
777
+ const base = cell.text.trim() ? cell.text.length + 1 : 0;
778
+ setSplits(cell, [
779
+ ..._nullishCoalesce(CELL_SPLITS.get(cell), () => ( [])),
780
+ { at: base, page },
781
+ ...(_nullishCoalesce(CELL_SPLITS.get(add), () => ( []))).map((s) => ({ at: base + s.at, page: s.page }))
782
+ ]);
783
+ }
784
+ function rowStarts(t) {
785
+ const covered = /* @__PURE__ */ new Set();
786
+ const rows = [];
787
+ for (let r = 0; r < t.rows; r++) {
788
+ const starts = [];
789
+ for (let c = 0; c < t.cols; c++) {
790
+ if (covered.has(r * 1e5 + c)) continue;
791
+ const cell = _optionalChain([t, 'access', _60 => _60.cells, 'access', _61 => _61[r], 'optionalAccess', _62 => _62[c]]);
792
+ if (!cell) continue;
793
+ for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) if (dr || dc) covered.add((r + dr) * 1e5 + c + dc);
794
+ starts.push({ cell, c });
795
+ }
796
+ rows.push(starts);
797
+ }
798
+ return rows;
799
+ }
800
+ var covering = (t, r) => rowStarts(t).slice(0, r + 1).flatMap((starts, rr) => starts.filter((s) => rr + s.cell.rowSpan > r).map((s) => s.cell));
801
+ function cellPage(cell) {
802
+ const p = _chunkW5NXOMCDcjs.CELL_PAGES.get(cell);
803
+ if (p !== void 0 || !_optionalChain([cell, 'access', _63 => _63.blocks, 'optionalAccess', _64 => _64.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
804
+ return Math.min(...cell.blocks.map((b) => b.pageNumber));
805
+ }
806
+ function tableRowPages(t, pageNumber) {
807
+ const pages = [];
808
+ let prev = pageNumber;
809
+ for (const starts of rowStarts(t)) {
810
+ let mark, text = false;
811
+ for (const { cell } of starts) {
812
+ const p = cellPage(cell);
813
+ if (p !== void 0) mark = Math.max(_nullishCoalesce(mark, () => ( p)), p);
814
+ else if (cell.text.trim() || _optionalChain([cell, 'access', _65 => _65.blocks, 'optionalAccess', _66 => _66.length])) text = true;
815
+ }
816
+ const page = _nullishCoalesce(mark, () => ( (text ? pageNumber : prev)));
817
+ prev = page !== void 0 && prev !== void 0 ? Math.max(prev, page) : _nullishCoalesce(page, () => ( prev));
818
+ pages.push(prev);
819
+ }
820
+ return pages;
821
+ }
822
+ function markJoinedPages(table, prev, curr) {
823
+ const pt = prev.table, ct = curr.table;
824
+ if (!curr.pageNumber || table.rows < pt.rows) return;
825
+ const pp = tableRowPages(pt, prev.pageNumber), cp = tableRowPages(ct, curr.pageNumber);
826
+ const off = table.rows - ct.rows;
827
+ const rows = rowStarts(table), ptRows = rowStarts(pt), ctRows = rowStarts(ct);
828
+ rows.forEach((starts, r) => {
829
+ const page2 = r < pt.rows ? pp[r] : cp[r - off];
830
+ for (const { cell } of starts) {
831
+ if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkW5NXOMCDcjs.CELL_PAGES.set(cell, page2);
832
+ const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _67 => _67.find, 'call', _68 => _68((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
833
+ if (src) setSplits(cell, relocate(src.cell, cell));
834
+ }
835
+ });
836
+ const cr = pt.rows - 1 - off, page = cp[cr];
837
+ if (cr < 0 || page === void 0 || page === prev.pageNumber) return;
838
+ const tails = ctRows[cr].filter((s) => s.cell.text.trim());
839
+ for (const { cell } of ctRows[cr]) for (const b of _nullishCoalesce(cell.blocks, () => ( []))) b.pageNumber ??= page;
840
+ const heads = covering(pt, pt.rows - 1);
841
+ for (const cell of covering(table, pt.rows - 1)) {
842
+ if (_optionalChain([cell, 'access', _69 => _69.blocks, 'optionalAccess', _70 => _70.length])) continue;
843
+ const head = heads.filter((h) => h.text.trim() && cell.text.startsWith(h.text.trimEnd()) && cell.text.trim().length > h.text.trim().length).sort((a, b) => b.text.length - a.text.length)[0];
844
+ if (!head) continue;
845
+ const from = head.text.trimEnd().length;
846
+ const hit = tails.map((t) => ({ t: t.cell, at: cell.text.indexOf(t.cell.text.trim().slice(0, 20), from) })).filter((h) => h.at >= from).sort((a, b) => a.at - b.at)[0];
847
+ if (!hit) continue;
848
+ setSplits(cell, [...relocate(head, cell), { at: hit.at, page }, ...relocate(hit.t, cell, hit.at)]);
849
+ }
850
+ }
851
+ function splitCell(cell, page) {
852
+ if (page === void 0) return null;
853
+ if (_optionalChain([cell, 'access', _71 => _71.blocks, 'optionalAccess', _72 => _72.length])) {
854
+ const k2 = cell.blocks.findIndex((b) => (_nullishCoalesce(b.pageNumber, () => ( page))) > page);
855
+ if (k2 <= 0) return null;
856
+ const head = cell.blocks.slice(0, k2), tail = cell.blocks.slice(k2);
857
+ const text = (bs) => bs.map((b) => _nullishCoalesce(b.text, () => ( ""))).filter(Boolean).join("\n");
858
+ return { head: { text: text(head), blocks: head }, tail: { text: text(tail), blocks: tail }, page: tail[0].pageNumber, rest: [] };
859
+ }
860
+ const splits = _nullishCoalesce(CELL_SPLITS.get(cell), () => ( []));
861
+ const k = splits.findIndex((s2) => s2.page > page && s2.at < cell.text.length);
862
+ if (k < 0) return null;
863
+ const s = splits[k];
864
+ const rest = cell.text.slice(s.at), lead = rest.length - rest.trimStart().length;
865
+ return {
866
+ head: { text: cell.text.slice(0, s.at).trimEnd() },
867
+ tail: { text: rest.trim() },
868
+ page: s.page,
869
+ rest: splits.slice(k + 1).map((x) => ({ at: x.at - s.at - lead, page: x.page })).filter((x) => x.at > 0)
870
+ };
871
+ }
872
+ function splitCrossPageRows(t, pageNumber) {
873
+ const pages = tableRowPages(t, pageNumber);
874
+ const rows = rowStarts(t);
875
+ for (let r = 0; r < t.rows; r++) {
876
+ const splits = rows[r].map((s) => ({ ...s, split: splitCell(s.cell, pages[r]) })).filter((s) => s.split);
877
+ if (!splits.length) continue;
878
+ const clone = (cell, patch) => {
879
+ const out = { ...cell, ...patch };
880
+ const p = _chunkW5NXOMCDcjs.CELL_PAGES.get(cell);
881
+ if (p !== void 0) _chunkW5NXOMCDcjs.CELL_PAGES.set(out, p);
882
+ if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
883
+ return out;
884
+ };
885
+ const e = Math.max(...splits.map((s) => r + s.cell.rowSpan - 1));
886
+ const cells = t.cells.map((row2) => row2.slice());
887
+ const row = Array.from({ length: t.cols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }));
888
+ for (const { cell, c, split } of splits) {
889
+ cells[r][c] = clone(cell, split.head);
890
+ const tail = { ...cell, ...split.tail, rowSpan: 1 };
891
+ _chunkW5NXOMCDcjs.CELL_PAGES.set(tail, split.page);
892
+ setSplits(tail, split.rest);
893
+ row[c] = tail;
894
+ }
895
+ rows.forEach((starts, rr) => {
896
+ for (const { cell, c } of starts) {
897
+ if (splits.some((s) => s.cell === cell) || rr > e || rr + cell.rowSpan - 1 <= e) continue;
898
+ cells[rr][c] = clone(cells[rr][c], { rowSpan: cell.rowSpan + 1 });
899
+ }
900
+ });
901
+ cells.splice(e + 1, 0, row);
902
+ return splitCrossPageRows({ ...t, rows: t.rows + 1, cells }, pageNumber);
903
+ }
904
+ return t;
905
+ }
906
+ function splitPageTables(blocks) {
907
+ return blocks.flatMap((b) => {
908
+ if (b.type !== "table" || !b.table) return [b];
909
+ const t = splitCrossPageRows(b.table, b.pageNumber);
910
+ const pages = tableRowPages(t, b.pageNumber);
911
+ const cuts = [0];
912
+ for (let r = 1; r < t.rows; r++) if (pages[r] !== pages[r - 1]) cuts.push(r);
913
+ if (cuts.length === 1) return t === b.table ? [b] : [{ ...b, table: t }];
914
+ return cuts.map((from, k) => {
915
+ const end = _nullishCoalesce(cuts[k + 1], () => ( t.rows));
916
+ const cells = t.cells.slice(from, end).map((row, dr) => row.map((cell) => cell && from + dr + cell.rowSpan > end ? { ...cell, rowSpan: end - from - dr } : cell));
917
+ const table = { ...t, rows: end - from, cells, ...k ? { caption: void 0, captionBlocks: void 0 } : {} };
918
+ return { ...b, table, pageNumber: pages[from] };
919
+ });
920
+ });
921
+ }
922
+
760
923
  // src/pdf/table-parts.ts
761
924
  var flowText = (text) => text.replace(/<\/?u>|~~/g, "");
762
925
  var PART_COL_TOL = 1;
@@ -767,7 +930,7 @@ function anchorsOf(table) {
767
930
  for (let r = 0; r < table.rows; r++) {
768
931
  for (let c = 0; c < table.cols; c++) {
769
932
  if (covered.has(r * 1e5 + c)) continue;
770
- const cell = _optionalChain([table, 'access', _57 => _57.cells, 'access', _58 => _58[r], 'optionalAccess', _59 => _59[c]]);
933
+ const cell = _optionalChain([table, 'access', _73 => _73.cells, 'access', _74 => _74[r], 'optionalAccess', _75 => _75[c]]);
771
934
  if (!cell) continue;
772
935
  out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
773
936
  for (let dr = 0; dr < cell.rowSpan; dr++) {
@@ -844,24 +1007,24 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
844
1007
  if (r + dr < rows) owner[r + dr][dc] = placed;
845
1008
  }
846
1009
  grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
847
- const lines = _chunk3FGHQWJPcjs.CELL_LINES.get(a.cell);
848
- if (lines) _chunk3FGHQWJPcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
849
- if (_chunk3FGHQWJPcjs.IMAGE_CELLS.has(a.cell)) _chunk3FGHQWJPcjs.IMAGE_CELLS.add(grid[r][c1]);
850
- const edges = _chunk6FW3AZWNcjs.CELL_EDGES.get(a.cell);
1010
+ const lines = _chunkFNX3ZAYBcjs.CELL_LINES.get(a.cell);
1011
+ if (lines) _chunkFNX3ZAYBcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
1012
+ if (_chunkFNX3ZAYBcjs.IMAGE_CELLS.has(a.cell)) _chunkFNX3ZAYBcjs.IMAGE_CELLS.add(grid[r][c1]);
1013
+ const edges = _chunkW5NXOMCDcjs.CELL_EDGES.get(a.cell);
851
1014
  if (edges) {
852
- _chunk6FW3AZWNcjs.CELL_EDGES.set(grid[r][c1], edges);
1015
+ _chunkW5NXOMCDcjs.CELL_EDGES.set(grid[r][c1], edges);
853
1016
  edged = true;
854
1017
  }
855
1018
  return true;
856
1019
  };
857
- for (const a of pa) if (!_chunk3FGHQWJPcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
1020
+ for (const a of pa) if (!_chunkFNX3ZAYBcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
858
1021
  for (const a of ca) {
859
- if (a.r < skip || _chunk3FGHQWJPcjs.FILLER_CELLS.has(a.cell)) continue;
1022
+ if (a.r < skip || _chunkFNX3ZAYBcjs.FILLER_CELLS.has(a.cell)) continue;
860
1023
  if (!place(a, cxU, prev.rows - skip, dx)) return null;
861
1024
  }
862
1025
  const first = prev.rows;
863
1026
  for (let c = 0; c < cols; c++) {
864
- const above = _optionalChain([owner, 'access', _60 => _60[first - 1], 'optionalAccess', _61 => _61[c]]);
1027
+ const above = _optionalChain([owner, 'access', _76 => _76[first - 1], 'optionalAccess', _77 => _77[c]]);
865
1028
  if (!above) continue;
866
1029
  let r = first;
867
1030
  while (r < rows && owner[r][c] === null) r++;
@@ -880,9 +1043,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
880
1043
  const grown = { ...above, rs: newRs };
881
1044
  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;
882
1045
  }
883
- for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunk3FGHQWJPcjs.FILLER_CELLS.add(grid[r][c]);
1046
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkFNX3ZAYBcjs.FILLER_CELLS.add(grid[r][c]);
884
1047
  if (edged) {
885
- for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunk6FW3AZWNcjs.CELL_EDGES.set(grid[r][c], _chunk3FGHQWJPcjs.NO_EDGES);
1048
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkW5NXOMCDcjs.CELL_EDGES.set(grid[r][c], _chunkFNX3ZAYBcjs.NO_EDGES);
886
1049
  }
887
1050
  for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
888
1051
  let r = prev.rows;
@@ -891,7 +1054,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
891
1054
  for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
892
1055
  }
893
1056
  const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
894
- const pr = _chunk3FGHQWJPcjs.ROW_RULES.get(prev), cr = _chunk3FGHQWJPcjs.ROW_RULES.get(curr);
1057
+ const pr = _chunkFNX3ZAYBcjs.ROW_RULES.get(prev), cr = _chunkFNX3ZAYBcjs.ROW_RULES.get(curr);
895
1058
  const shifted = dx !== 0;
896
1059
  const cut = {
897
1060
  open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
@@ -902,7 +1065,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
902
1065
  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 });
903
1066
  if (pr && cr) {
904
1067
  const cutRuled = pr.bottom || cr.top;
905
- _chunk3FGHQWJPcjs.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) });
1068
+ _chunkFNX3ZAYBcjs.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) });
906
1069
  }
907
1070
  return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
908
1071
  }
@@ -956,8 +1119,8 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
956
1119
  if (!crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
957
1120
  if (!straddles && !midWord) continue;
958
1121
  if (u.r >= last && d.rs < 2) continue;
959
- const U = _chunk3FGHQWJPcjs.CELL_LINES.get(a);
960
- if (!_optionalChain([U, 'optionalAccess', _62 => _62.length]) || !hasContent(b)) continue;
1122
+ const U = _chunkFNX3ZAYBcjs.CELL_LINES.get(a);
1123
+ if (!_optionalChain([U, 'optionalAccess', _78 => _78.length]) || !hasContent(b)) continue;
961
1124
  if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
962
1125
  if (U.length > STRADDLE_MAX_LINES) continue;
963
1126
  const lu = U[U.length - 1];
@@ -1003,8 +1166,8 @@ function nextItemHead(prev, next) {
1003
1166
  return false;
1004
1167
  }
1005
1168
  function continuesAcross(u, d, x1, x2) {
1006
- const U = _chunk3FGHQWJPcjs.CELL_LINES.get(u), D = _chunk3FGHQWJPcjs.CELL_LINES.get(d);
1007
- if (!_optionalChain([U, 'optionalAccess', _63 => _63.length]) || !_optionalChain([D, 'optionalAccess', _64 => _64.length])) return false;
1169
+ const U = _chunkFNX3ZAYBcjs.CELL_LINES.get(u), D = _chunkFNX3ZAYBcjs.CELL_LINES.get(d);
1170
+ if (!_optionalChain([U, 'optionalAccess', _79 => _79.length]) || !_optionalChain([D, 'optionalAccess', _80 => _80.length])) return false;
1008
1171
  const last = U[U.length - 1];
1009
1172
  const fs = last.h || 10;
1010
1173
  let minL = Infinity, maxR = -Infinity;
@@ -1021,7 +1184,7 @@ function continuesAcross(u, d, x1, x2) {
1021
1184
  if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
1022
1185
  const indented = last.l - minL >= HANGING_MIN * fs;
1023
1186
  if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
1024
- const newItem = _chunk3FGHQWJPcjs.startsNewItem.call(void 0, u.text, d.text);
1187
+ const newItem = _chunkFNX3ZAYBcjs.startsNewItem.call(void 0, u.text, d.text);
1025
1188
  const all = D.length ? U.concat(D) : U;
1026
1189
  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));
1027
1190
  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;
@@ -1038,12 +1201,12 @@ function outlineContinues(u, d) {
1038
1201
  return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
1039
1202
  }
1040
1203
  function lineEnded(c, x1, x2, next) {
1041
- const L = _chunk3FGHQWJPcjs.CELL_LINES.get(c);
1204
+ const L = _chunkFNX3ZAYBcjs.CELL_LINES.get(c);
1042
1205
  if (!L || L.length !== 1) return false;
1043
1206
  const l = L[0], h = l.h || 10;
1044
- const d0 = next ? _optionalChain([_chunk3FGHQWJPcjs.CELL_LINES, 'access', _65 => _65.get, 'call', _66 => _66(next), 'optionalAccess', _67 => _67[0]]) : void 0;
1207
+ const d0 = next ? _optionalChain([_chunkFNX3ZAYBcjs.CELL_LINES, 'access', _81 => _81.get, 'call', _82 => _82(next), 'optionalAccess', _83 => _83[0]]) : void 0;
1045
1208
  if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
1046
- return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _68 => _68.text]), () => ( "")))) * h;
1209
+ return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _84 => _84.text]), () => ( "")))) * h;
1047
1210
  }
1048
1211
  function firstWordUnits(text) {
1049
1212
  const word = _nullishCoalesce(flowText(text).trim().replace(/^([(\[「『<〈])\s+/, "$1").split(/\s+/)[0], () => ( ""));
@@ -1052,14 +1215,14 @@ function firstWordUnits(text) {
1052
1215
  return units;
1053
1216
  }
1054
1217
  function appendCell(a, b) {
1055
- if (_optionalChain([a, 'access', _69 => _69.blocks, 'optionalAccess', _70 => _70.length]) || _optionalChain([b, 'access', _71 => _71.blocks, 'optionalAccess', _72 => _72.length])) {
1056
- 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 }));
1218
+ if (_optionalChain([a, 'access', _85 => _85.blocks, 'optionalAccess', _86 => _86.length]) || _optionalChain([b, 'access', _87 => _87.blocks, 'optionalAccess', _88 => _88.length])) {
1219
+ const asBlocks = (c) => _optionalChain([c, 'access', _89 => _89.blocks, 'optionalAccess', _90 => _90.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
1057
1220
  a.blocks = [...asBlocks(a), ...asBlocks(b)];
1058
1221
  }
1059
1222
  if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
1060
- _chunk3FGHQWJPcjs.joinCellEdges.call(void 0, a, b);
1223
+ _chunkFNX3ZAYBcjs.joinCellEdges.call(void 0, a, b);
1061
1224
  }
1062
- var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _75 => _75.blocks, 'optionalAccess', _76 => _76.length]) || _chunk3FGHQWJPcjs.IMAGE_CELLS.has(cell);
1225
+ var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _91 => _91.blocks, 'optionalAccess', _92 => _92.length]) || _chunkFNX3ZAYBcjs.IMAGE_CELLS.has(cell);
1063
1226
  var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
1064
1227
  var batchim = (ch) => {
1065
1228
  const k = ch.charCodeAt(0) - 44032;
@@ -1067,13 +1230,13 @@ var batchim = (ch) => {
1067
1230
  };
1068
1231
  function clauseContinues(u, d) {
1069
1232
  const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
1070
- if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunk3FGHQWJPcjs.startsNewItem.call(void 0, u.text, head)) return false;
1233
+ if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkFNX3ZAYBcjs.startsNewItem.call(void 0, u.text, head)) return false;
1071
1234
  const last = tail[tail.length - 1], before = tail[tail.length - 2];
1072
1235
  return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
1073
1236
  }
1074
1237
  function wordOverflows(u, d, x1, x2) {
1075
- const U = _chunk3FGHQWJPcjs.CELL_LINES.get(u);
1076
- if (!_optionalChain([U, 'optionalAccess', _77 => _77.length]) || _chunk3FGHQWJPcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
1238
+ const U = _chunkFNX3ZAYBcjs.CELL_LINES.get(u);
1239
+ if (!_optionalChain([U, 'optionalAccess', _93 => _93.length]) || _chunkFNX3ZAYBcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
1077
1240
  const last = U[U.length - 1], units = firstWordUnits(d.text);
1078
1241
  return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
1079
1242
  }
@@ -1095,7 +1258,7 @@ function listContinues(u, d, multi = false) {
1095
1258
  const marks = u.text.split("\n").map((l) => itemMark(l.trim()));
1096
1259
  let last = -1, count = 0;
1097
1260
  marks.forEach((m, i) => {
1098
- if (_optionalChain([m, 'optionalAccess', _78 => _78.style]) === head.style) {
1261
+ if (_optionalChain([m, 'optionalAccess', _94 => _94.style]) === head.style) {
1099
1262
  last = i;
1100
1263
  count++;
1101
1264
  }
@@ -1133,7 +1296,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
1133
1296
  if (!carriedSplit) {
1134
1297
  const norm = (c) => flowText(c.text).replace(/\s+/g, "");
1135
1298
  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;
1136
- const oneLine = (c) => _optionalChain([_chunk3FGHQWJPcjs.CELL_LINES, 'access', _79 => _79.get, 'call', _80 => _80(c), 'optionalAccess', _81 => _81.length]) === 1;
1299
+ const oneLine = (c) => _optionalChain([_chunkFNX3ZAYBcjs.CELL_LINES, 'access', _95 => _95.get, 'call', _96 => _96(c), 'optionalAccess', _97 => _97.length]) === 1;
1137
1300
  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;
1138
1301
  const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d));
1139
1302
  if (!(cut.open && !newCell)) {
@@ -1164,8 +1327,8 @@ function besideOwn(b, p, c) {
1164
1327
  }
1165
1328
  var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
1166
1329
  function pageNumberBetween(b, p, c, pageHeights) {
1167
- 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;
1168
- const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _85 => _85.get, 'call', _86 => _86(b.pageNumber)]) : void 0;
1330
+ if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _98 => _98.text, 'optionalAccess', _99 => _99.trim, 'call', _100 => _100()]), () => ( "")))) return false;
1331
+ const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _101 => _101.get, 'call', _102 => _102(b.pageNumber)]) : void 0;
1169
1332
  if (!h) return false;
1170
1333
  if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
1171
1334
  if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
@@ -1176,6 +1339,7 @@ function leftColumnOf(b, t) {
1176
1339
  }
1177
1340
  function placeJoined(blocks, i, j, table) {
1178
1341
  const prev = blocks[i];
1342
+ markJoinedPages(table, prev, blocks[j]);
1179
1343
  blocks[i] = { ...prev, table };
1180
1344
  blocks.splice(j, 1);
1181
1345
  let k = j - 1;
@@ -1188,7 +1352,7 @@ function insideTable(b, t) {
1188
1352
  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;
1189
1353
  }
1190
1354
  function startsWithUnitRow(table) {
1191
- 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())]);
1355
+ return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _103 => _103.cells, 'access', _104 => _104[0], 'optionalAccess', _105 => _105[0], 'optionalAccess', _106 => _106.text]), () => ( ""))) && _optionalChain([table, 'access', _107 => _107.cells, 'access', _108 => _108[0], 'optionalAccess', _109 => _109.slice, 'call', _110 => _110(1), 'access', _111 => _111.every, 'call', _112 => _112((c) => !c.text.trim())]);
1192
1356
  }
1193
1357
  function sameHeadShape(a, b) {
1194
1358
  if (!a || !b || a.length !== b.length) return false;
@@ -1208,7 +1372,7 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1208
1372
  const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
1209
1373
  while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
1210
1374
  const curr = blocks[j];
1211
- const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _97 => _97.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
1375
+ const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _113 => _113.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
1212
1376
  if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
1213
1377
  if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
1214
1378
  if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
@@ -1217,19 +1381,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1217
1381
  placeJoined(blocks, i, j, joined);
1218
1382
  continue;
1219
1383
  }
1220
- if (_chunk3FGHQWJPcjs.EMPTY_PARTS.has(curr.table)) {
1384
+ if (_chunkFNX3ZAYBcjs.EMPTY_PARTS.has(curr.table)) {
1221
1385
  blocks.splice(j, 1);
1222
1386
  i++;
1223
1387
  continue;
1224
1388
  }
1225
1389
  if (joined === null) continue;
1226
- if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunk3FGHQWJPcjs.EMPTY_PARTS.has(prev.table)) continue;
1390
+ if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkFNX3ZAYBcjs.EMPTY_PARTS.has(prev.table)) continue;
1227
1391
  const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
1228
1392
  const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
1229
1393
  const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
1230
1394
  if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
1231
- const px = _chunk3FGHQWJPcjs.TABLE_COLXS.get(prev.table), cx = _chunk3FGHQWJPcjs.TABLE_COLXS.get(curr.table);
1232
- if (px && cx && !shiftedSame(px, cx, !_chunk3FGHQWJPcjs.CLIP_TABLES.has(prev.table) && !_chunk3FGHQWJPcjs.CLIP_TABLES.has(curr.table))) continue;
1395
+ const px = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(prev.table), cx = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(curr.table);
1396
+ if (px && cx && !shiftedSame(px, cx, !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(prev.table) && !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(curr.table))) continue;
1233
1397
  if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
1234
1398
  let currCells = curr.table.cells;
1235
1399
  const headRows = repeatedHeaderRows(prev.table, curr.table);
@@ -1240,16 +1404,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1240
1404
  blocks.splice(j, 1);
1241
1405
  continue;
1242
1406
  }
1243
- if (px && cx && !_chunk3FGHQWJPcjs.CLIP_TABLES.has(prev.table) && !_chunk3FGHQWJPcjs.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 && _chunk3FGHQWJPcjs.CELL_LINES.has(c))) {
1407
+ if (px && cx && !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(prev.table) && !_chunkFNX3ZAYBcjs.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 && _chunkFNX3ZAYBcjs.CELL_LINES.has(c))) {
1244
1408
  const dx = px[0] - cx[0];
1245
1409
  const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
1246
- if (_optionalChain([part, 'optionalAccess', _98 => _98.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
1410
+ if (_optionalChain([part, 'optionalAccess', _114 => _114.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
1247
1411
  const last = prev.table.rows - 1;
1248
1412
  for (let c = 0; c < part.table.cols; c++) {
1249
- const U = _chunk3FGHQWJPcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunk3FGHQWJPcjs.CELL_LINES.get(currCells[0][c]);
1250
- _chunk3FGHQWJPcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
1413
+ const U = _chunkFNX3ZAYBcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkFNX3ZAYBcjs.CELL_LINES.get(currCells[0][c]);
1414
+ _chunkFNX3ZAYBcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
1251
1415
  }
1252
- _chunk3FGHQWJPcjs.TABLE_COLXS.set(part.table, part.colXs);
1416
+ _chunkFNX3ZAYBcjs.TABLE_COLXS.set(part.table, part.colXs);
1253
1417
  placeJoined(blocks, i, j, part.table);
1254
1418
  continue;
1255
1419
  }
@@ -1262,20 +1426,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
1262
1426
  caption: prev.table.caption,
1263
1427
  ...prev.table.renderAsTable ? { renderAsTable: true } : {}
1264
1428
  };
1265
- if (_nullishCoalesce(px, () => ( cx))) _chunk3FGHQWJPcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
1266
- if (_chunk3FGHQWJPcjs.CLIP_TABLES.has(prev.table) || _chunk3FGHQWJPcjs.CLIP_TABLES.has(curr.table)) _chunk3FGHQWJPcjs.CLIP_TABLES.add(merged);
1429
+ if (_nullishCoalesce(px, () => ( cx))) _chunkFNX3ZAYBcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
1430
+ if (_chunkFNX3ZAYBcjs.CLIP_TABLES.has(prev.table) || _chunkFNX3ZAYBcjs.CLIP_TABLES.has(curr.table)) _chunkFNX3ZAYBcjs.CLIP_TABLES.add(merged);
1267
1431
  placeJoined(blocks, i, j, merged);
1268
1432
  }
1269
1433
  for (let i = blocks.length - 1; i >= 0; i--) {
1270
1434
  const t = blocks[i].table;
1271
- if (blocks[i].type === "table" && t && _chunk3FGHQWJPcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
1435
+ if (blocks[i].type === "table" && t && _chunkFNX3ZAYBcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
1272
1436
  }
1273
1437
  }
1274
1438
  function mergeColumnFlow(blocks, pageHeights, lex) {
1275
1439
  if (!pageHeights) return;
1276
1440
  for (let i = 0; i < blocks.length; i++) {
1277
1441
  const L = blocks[i];
1278
- if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(L.table) || _chunk3FGHQWJPcjs.EMPTY_PARTS.has(L.table)) continue;
1442
+ if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(L.table) || _chunkFNX3ZAYBcjs.EMPTY_PARTS.has(L.table)) continue;
1279
1443
  const ph = pageHeights.get(L.pageNumber);
1280
1444
  if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
1281
1445
  let s0 = i, s1 = i;
@@ -1304,12 +1468,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
1304
1468
  }
1305
1469
  function joinClipParts(prev, curr, pageHeights, lex) {
1306
1470
  const pt = prev.table, ct = curr.table;
1307
- if (!_chunk3FGHQWJPcjs.CLIP_TABLES.has(pt) || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(ct)) return null;
1308
- const px = _chunk3FGHQWJPcjs.TABLE_COLXS.get(pt), cx = _chunk3FGHQWJPcjs.TABLE_COLXS.get(ct);
1471
+ if (!_chunkFNX3ZAYBcjs.CLIP_TABLES.has(pt) || !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(ct)) return null;
1472
+ const px = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(pt), cx = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(ct);
1309
1473
  if (!px || !cx) return null;
1310
1474
  let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
1311
1475
  if (!shiftedSame(px, cx, false)) {
1312
- 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;
1476
+ if (!_optionalChain([pageHeights, 'optionalAccess', _115 => _115.get, 'call', _116 => _116(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _117 => _117.get, 'call', _118 => _118(curr.pageNumber)])) return null;
1313
1477
  dx = px[px.length - 1] - cx[cx.length - 1];
1314
1478
  within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
1315
1479
  if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
@@ -1321,19 +1485,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
1321
1485
  const inner = b.slice(1, -1).map((x) => x + dx);
1322
1486
  return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
1323
1487
  };
1324
- foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunk3FGHQWJPcjs.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);
1488
+ foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkFNX3ZAYBcjs.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);
1325
1489
  }
1326
- const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _103 => _103.bbox, 'optionalAccess', _104 => _104.y]), lex);
1490
+ const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _119 => _119.bbox, 'optionalAccess', _120 => _120.y]), lex);
1327
1491
  if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
1328
- _chunk3FGHQWJPcjs.TABLE_COLXS.set(res.table, res.colXs);
1329
- const ys = _chunk3FGHQWJPcjs.TABLE_ROWYS.get(pt);
1330
- if (ys) _chunk3FGHQWJPcjs.TABLE_ROWYS.set(res.table, ys);
1331
- _chunk3FGHQWJPcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunk3FGHQWJPcjs.PART_COLXS.get(pt), () => ( px)));
1332
- _chunk3FGHQWJPcjs.CLIP_TABLES.add(res.table);
1492
+ _chunkFNX3ZAYBcjs.TABLE_COLXS.set(res.table, res.colXs);
1493
+ const ys = _chunkFNX3ZAYBcjs.TABLE_ROWYS.get(pt);
1494
+ if (ys) _chunkFNX3ZAYBcjs.TABLE_ROWYS.set(res.table, ys);
1495
+ _chunkFNX3ZAYBcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkFNX3ZAYBcjs.PART_COLXS.get(pt), () => ( px)));
1496
+ _chunkFNX3ZAYBcjs.CLIP_TABLES.add(res.table);
1333
1497
  return res.table;
1334
1498
  }
1335
1499
  function prevLacksLeftCols(prev, px, xs, pageHeights) {
1336
- const ph = _optionalChain([pageHeights, 'optionalAccess', _105 => _105.get, 'call', _106 => _106(prev.pageNumber)]);
1500
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _121 => _121.get, 'call', _122 => _122(prev.pageNumber)]);
1337
1501
  if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
1338
1502
  return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
1339
1503
  }
@@ -1344,21 +1508,21 @@ function headingRow(row) {
1344
1508
  }
1345
1509
  var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
1346
1510
  function looksContinued(prev, curr, pageHeights) {
1347
- 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)]);
1511
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _123 => _123.get, 'call', _124 => _124(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _125 => _125.get, 'call', _126 => _126(curr.pageNumber)]);
1348
1512
  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;
1349
1513
  const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
1350
- const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _111 => _111.find, 'call', _112 => _112((c) => c.text.trim()), 'optionalAccess', _113 => _113.text]), () => ( ""));
1514
+ const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _127 => _127.find, 'call', _128 => _128((c) => c.text.trim()), 'optionalAccess', _129 => _129.text]), () => ( ""));
1351
1515
  if (!ANNEX_HEAD_RE.test(firstText)) return true;
1352
1516
  const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
1353
1517
  return filled.length >= 2 && filled.every((t) => t === filled[0]);
1354
1518
  }
1355
1519
  function pushedLead(prev, curr) {
1356
- if (!_chunk3FGHQWJPcjs.CLIP_TABLES.has(prev.table) || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(curr.table)) return false;
1520
+ if (!_chunkFNX3ZAYBcjs.CLIP_TABLES.has(prev.table) || !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(curr.table)) return false;
1357
1521
  const lead = leadRows(curr.table);
1358
1522
  return lead.image && lead.height > prev.bbox.y;
1359
1523
  }
1360
1524
  function leadRows(t) {
1361
- const ys = _chunk3FGHQWJPcjs.TABLE_ROWYS.get(t);
1525
+ const ys = _chunkFNX3ZAYBcjs.TABLE_ROWYS.get(t);
1362
1526
  if (!ys || ys.length < 2) return { height: 0, image: false };
1363
1527
  const anchors = anchorsOf(t);
1364
1528
  let end = 1, image = false;
@@ -1366,17 +1530,17 @@ function leadRows(t) {
1366
1530
  for (const a of anchors) {
1367
1531
  if (a.r !== r) continue;
1368
1532
  end = Math.max(end, r + a.rs);
1369
- if (_chunk3FGHQWJPcjs.IMAGE_CELLS.has(a.cell)) image = true;
1533
+ if (_chunkFNX3ZAYBcjs.IMAGE_CELLS.has(a.cell)) image = true;
1370
1534
  }
1371
1535
  }
1372
1536
  return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
1373
1537
  }
1374
1538
  function tailOf(b) {
1375
- const t = b.table && _chunk3FGHQWJPcjs.TABLE_TAIL.get(b.table);
1539
+ const t = b.table && _chunkFNX3ZAYBcjs.TABLE_TAIL.get(b.table);
1376
1540
  return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
1377
1541
  }
1378
1542
  function firstRowSig(t) {
1379
- const x = _chunk3FGHQWJPcjs.TABLE_COLXS.get(t);
1543
+ const x = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(t);
1380
1544
  if (!x || x.length !== t.cols + 1) return null;
1381
1545
  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, "") }));
1382
1546
  }
@@ -1401,9 +1565,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
1401
1565
  }
1402
1566
  function restartsTitledForm(head, curr) {
1403
1567
  if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
1404
- const full = (t) => _optionalChain([t, 'access', _114 => _114.cells, 'access', _115 => _115[0], 'access', _116 => _116[0], 'optionalAccess', _117 => _117.colSpan]) === t.cols;
1568
+ const full = (t) => _optionalChain([t, 'access', _130 => _130.cells, 'access', _131 => _131[0], 'access', _132 => _132[0], 'optionalAccess', _133 => _133.colSpan]) === t.cols;
1405
1569
  if (!full(head) || !full(curr)) return false;
1406
- const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _118 => _118.text]), () => ( ""))).replace(/\s+/g, "");
1570
+ const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _134 => _134.text]), () => ( ""))).replace(/\s+/g, "");
1407
1571
  const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
1408
1572
  if (!ht || !ct || ht === ct) return false;
1409
1573
  const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
@@ -1429,7 +1593,7 @@ function chainHead(blocks, i, pageHeights) {
1429
1593
  if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
1430
1594
  if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
1431
1595
  if (!looksContinued(pb, cur, pageHeights)) break;
1432
- const px = _chunk3FGHQWJPcjs.TABLE_COLXS.get(pb.table), cx = _chunk3FGHQWJPcjs.TABLE_COLXS.get(cur.table);
1596
+ const px = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(pb.table), cx = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(cur.table);
1433
1597
  if (!px || !cx) break;
1434
1598
  const dx = px[px.length - 1] - cx[cx.length - 1];
1435
1599
  if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
@@ -1446,7 +1610,7 @@ function continueRowSpans(prevCells, currCells) {
1446
1610
  if (hasContent(cell) || (cell.rowSpan || 1) < 2) continue;
1447
1611
  let anchor;
1448
1612
  for (let r = last - 1; r >= 0 && !anchor; r--) {
1449
- const a = _optionalChain([prevCells, 'access', _119 => _119[r], 'optionalAccess', _120 => _120[c]]);
1613
+ const a = _optionalChain([prevCells, 'access', _135 => _135[r], 'optionalAccess', _136 => _136[c]]);
1450
1614
  if (a && r + (a.rowSpan || 1) === last && (a.colSpan || 1) === (cell.colSpan || 1) && (hasContent(a) || a.rowSpan >= 2)) anchor = a;
1451
1615
  }
1452
1616
  if (!anchor) continue;
@@ -1500,12 +1664,12 @@ var RESTART_LOOKBACK_PAGES = 5;
1500
1664
  var COL_MATCH_TOL = 0.5;
1501
1665
  var CONTINUED_TABLE_PAGE_BAND = 0.16;
1502
1666
  function lastRowCell(t, x1, x2) {
1503
- const xs = _chunk3FGHQWJPcjs.TABLE_COLXS.get(t);
1667
+ const xs = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(t);
1504
1668
  const covered = /* @__PURE__ */ new Set();
1505
1669
  for (let r = 0; r < t.rows; r++) {
1506
1670
  for (let c = 0; c < t.cols; c++) {
1507
1671
  if (covered.has(r * 1e5 + c)) continue;
1508
- const cell = _optionalChain([t, 'access', _121 => _121.cells, 'access', _122 => _122[r], 'optionalAccess', _123 => _123[c]]);
1672
+ const cell = _optionalChain([t, 'access', _137 => _137.cells, 'access', _138 => _138[r], 'optionalAccess', _139 => _139[c]]);
1509
1673
  if (!cell) continue;
1510
1674
  for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
1511
1675
  if (r + cell.rowSpan !== t.rows) continue;
@@ -1518,23 +1682,24 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
1518
1682
  function mergeContinuedCells(blocks, pageHeights) {
1519
1683
  for (let j = blocks.length - 1; j > 0; j--) {
1520
1684
  const part = blocks[j];
1521
- const from = part.table ? _chunk3FGHQWJPcjs.CONT_PARTS.get(part.table) : void 0;
1685
+ const from = part.table ? _chunkFNX3ZAYBcjs.CONT_PARTS.get(part.table) : void 0;
1522
1686
  if (!from || !part.table) continue;
1523
1687
  let i = j - 1;
1524
1688
  while (i >= 0 && blocks[i].type !== "table") i--;
1525
1689
  const prev = blocks[i];
1526
1690
  if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
1527
1691
  const cell = lastRowCell(prev.table, from.x1, from.x2);
1528
- const add = _optionalChain([part, 'access', _124 => _124.table, 'access', _125 => _125.cells, 'access', _126 => _126[0], 'optionalAccess', _127 => _127[0]]);
1692
+ const add = _optionalChain([part, 'access', _140 => _140.table, 'access', _141 => _141.cells, 'access', _142 => _142[0], 'optionalAccess', _143 => _143[0]]);
1529
1693
  if (!cell || !add) continue;
1530
1694
  const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
1531
1695
  if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
1696
+ else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
1532
1697
  cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
1533
- _chunk3FGHQWJPcjs.joinCellEdges.call(void 0, cell, add);
1534
- const lines = _chunk3FGHQWJPcjs.CELL_LINES.get(add);
1535
- if (_optionalChain([lines, 'optionalAccess', _128 => _128.length])) _chunk3FGHQWJPcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunk3FGHQWJPcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
1536
- if (part.pageNumber && part.bbox) _chunk3FGHQWJPcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunk3FGHQWJPcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
1537
- if (cell.text.trim() || _optionalChain([cell, 'access', _129 => _129.blocks, 'optionalAccess', _130 => _130.length])) _chunk3FGHQWJPcjs.EMPTY_PARTS.delete(prev.table);
1698
+ _chunkFNX3ZAYBcjs.joinCellEdges.call(void 0, cell, add);
1699
+ const lines = _chunkFNX3ZAYBcjs.CELL_LINES.get(add);
1700
+ if (_optionalChain([lines, 'optionalAccess', _144 => _144.length])) _chunkFNX3ZAYBcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkFNX3ZAYBcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
1701
+ if (part.pageNumber && part.bbox) _chunkFNX3ZAYBcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkFNX3ZAYBcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
1702
+ if (cell.text.trim() || _optionalChain([cell, 'access', _145 => _145.blocks, 'optionalAccess', _146 => _146.length])) _chunkFNX3ZAYBcjs.EMPTY_PARTS.delete(prev.table);
1538
1703
  blocks.splice(j, 1);
1539
1704
  if (cell.blocks && at > 0) {
1540
1705
  const nextAt = cell.blocks[at];
@@ -1546,27 +1711,27 @@ function mergeContinuedCells(blocks, pageHeights) {
1546
1711
  }
1547
1712
  function unwrapContinuedTable(blocks, at, pageHeights) {
1548
1713
  const prev = blocks[at - 1], frame = blocks[at];
1549
- if (!_optionalChain([prev, 'optionalAccess', _131 => _131.table]) || !_optionalChain([frame, 'optionalAccess', _132 => _132.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(frame.table)) return;
1550
- const inner = _optionalChain([frame, 'access', _133 => _133.table, 'access', _134 => _134.cells, 'access', _135 => _135[0], 'optionalAccess', _136 => _136[0], 'optionalAccess', _137 => _137.blocks]);
1551
- const next = _optionalChain([inner, 'optionalAccess', _138 => _138[0]]);
1552
- if (!inner || !_optionalChain([next, 'optionalAccess', _139 => _139.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(prev.table) || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
1553
- const px = _chunk3FGHQWJPcjs.TABLE_COLXS.get(prev.table), nx = _chunk3FGHQWJPcjs.TABLE_COLXS.get(next.table);
1714
+ if (!_optionalChain([prev, 'optionalAccess', _147 => _147.table]) || !_optionalChain([frame, 'optionalAccess', _148 => _148.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(frame.table)) return;
1715
+ const inner = _optionalChain([frame, 'access', _149 => _149.table, 'access', _150 => _150.cells, 'access', _151 => _151[0], 'optionalAccess', _152 => _152[0], 'optionalAccess', _153 => _153.blocks]);
1716
+ const next = _optionalChain([inner, 'optionalAccess', _154 => _154[0]]);
1717
+ if (!inner || !_optionalChain([next, 'optionalAccess', _155 => _155.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(prev.table) || !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
1718
+ const px = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(prev.table), nx = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(next.table);
1554
1719
  if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
1555
- 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)]);
1720
+ const ph = _optionalChain([pageHeights, 'optionalAccess', _156 => _156.get, 'call', _157 => _157(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _158 => _158.get, 'call', _159 => _159(next.pageNumber)]);
1556
1721
  if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
1557
1722
  blocks.splice(at, 1, ...inner);
1558
1723
  }
1559
1724
  function fillNestedContinuation(blocks, at) {
1560
1725
  const prev = blocks[at - 1], next = blocks[at];
1561
- const t = _optionalChain([prev, 'optionalAccess', _144 => _144.table]), u = _optionalChain([next, 'optionalAccess', _145 => _145.table]);
1562
- if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(t) || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
1563
- const xs = _chunk3FGHQWJPcjs.TABLE_COLXS.get(u);
1726
+ const t = _optionalChain([prev, 'optionalAccess', _160 => _160.table]), u = _optionalChain([next, 'optionalAccess', _161 => _161.table]);
1727
+ if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(t) || !_chunkFNX3ZAYBcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
1728
+ const xs = _chunkFNX3ZAYBcjs.TABLE_COLXS.get(u);
1564
1729
  const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
1565
- const add = _optionalChain([u, 'access', _146 => _146.cells, 'access', _147 => _147[0], 'optionalAccess', _148 => _148[0]]);
1566
- if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _149 => _149.blocks, 'optionalAccess', _150 => _150.length])) return;
1730
+ const add = _optionalChain([u, 'access', _162 => _162.cells, 'access', _163 => _163[0], 'optionalAccess', _164 => _164[0]]);
1731
+ if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _165 => _165.blocks, 'optionalAccess', _166 => _166.length])) return;
1567
1732
  cell.text = add.text;
1568
1733
  if (add.blocks) cell.blocks = add.blocks;
1569
- _chunk3FGHQWJPcjs.joinCellEdges.call(void 0, cell, add);
1734
+ _chunkFNX3ZAYBcjs.joinCellEdges.call(void 0, cell, add);
1570
1735
  blocks.splice(at, 1);
1571
1736
  }
1572
1737
 
@@ -1586,15 +1751,15 @@ function selectionContextPages(selected, pageCount) {
1586
1751
  function marginContextBlocks(raw, page, view) {
1587
1752
  const [x1, y1, x2, y2] = view;
1588
1753
  const width = x2 - x1, height = y2 - y1;
1589
- const items = _chunk3FGHQWJPcjs.filterHiddenText.call(void 0, _chunk3FGHQWJPcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
1754
+ const items = _chunkFNX3ZAYBcjs.filterHiddenText.call(void 0, _chunkFNX3ZAYBcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
1590
1755
  for (const item of items) {
1591
1756
  item.x -= x1;
1592
1757
  item.y -= y1;
1593
1758
  }
1594
- return _chunk3FGHQWJPcjs.groupByY.call(void 0, items).flatMap((line) => {
1595
- const bbox = _chunk3FGHQWJPcjs.computeBBox.call(void 0, line, page);
1759
+ return _chunkFNX3ZAYBcjs.groupByY.call(void 0, items).flatMap((line) => {
1760
+ const bbox = _chunkFNX3ZAYBcjs.computeBBox.call(void 0, line, page);
1596
1761
  if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
1597
- return [{ type: "paragraph", text: _chunk3FGHQWJPcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunk3FGHQWJPcjs.dominantStyle.call(void 0, line) }];
1762
+ return [{ type: "paragraph", text: _chunkFNX3ZAYBcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkFNX3ZAYBcjs.dominantStyle.call(void 0, line) }];
1598
1763
  });
1599
1764
  }
1600
1765
 
@@ -1630,7 +1795,7 @@ var WINANSI_REVERSE = {
1630
1795
  };
1631
1796
  function symbolFontTable(fontName) {
1632
1797
  if (!fontName) return void 0;
1633
- if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunk6FW3AZWNcjs.WINGDINGS;
1798
+ if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkW5NXOMCDcjs.WINGDINGS;
1634
1799
  return void 0;
1635
1800
  }
1636
1801
  function remapSymbolText(text, table) {
@@ -1758,7 +1923,7 @@ function layout(toks) {
1758
1923
  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);
1759
1924
  if (!bar) continue;
1760
1925
  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);
1761
- 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 };
1926
+ const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _167 => _167[0], 'optionalAccess', _168 => _168.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
1762
1927
  rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
1763
1928
  }
1764
1929
  const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
@@ -1860,7 +2025,7 @@ function wrapEquationRuns(items, faceName) {
1860
2025
  for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
1861
2026
  const top = [...ys].sort((p, q) => q[1] - p[1]);
1862
2027
  const bar = cur.find(isBarItem);
1863
- 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));
2028
+ const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _169 => _169[0], 'optionalAccess', _170 => _170[0]]), () => ( cur[0].y));
1864
2029
  const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
1865
2030
  const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
1866
2031
  added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
@@ -2211,7 +2376,7 @@ function joinVerticalColumns(items) {
2211
2376
  const groups = [];
2212
2377
  for (const col of columns) {
2213
2378
  const g2 = groups[groups.length - 1];
2214
- const last = _optionalChain([g2, 'optionalAccess', _155 => _155[g2.length - 1]]);
2379
+ const last = _optionalChain([g2, 'optionalAccess', _171 => _171[g2.length - 1]]);
2215
2380
  const fs = col.items[0].fontSize;
2216
2381
  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);
2217
2382
  else groups.push([col]);
@@ -2397,7 +2562,7 @@ function relocateEndnotes(blocks) {
2397
2562
  }
2398
2563
  const shapes = /* @__PURE__ */ new Map();
2399
2564
  for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
2400
- 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]]);
2565
+ const main = _optionalChain([[...shapes], 'access', _172 => _172.sort, 'call', _173 => _173((a, b) => b[1] - a[1]), 'access', _174 => _174[0], 'optionalAccess', _175 => _175[0]]);
2401
2566
  if (!main || !/#/.test(main)) return blocks;
2402
2567
  const lastRun = (hs) => {
2403
2568
  let run2 = [];
@@ -2535,7 +2700,7 @@ function inlineFootnotes(blocks, pages) {
2535
2700
  open = true;
2536
2701
  continue;
2537
2702
  }
2538
- 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;
2703
+ const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _176 => _176.style, 'optionalAccess', _177 => _177.fontSize]), () => ( _optionalChain([b, 'access', _178 => _178.bbox, 'optionalAccess', _179 => _179.height]))), () => ( 10))) * 1.5;
2539
2704
  if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
2540
2705
  notes[notes.length - 1].text += " " + b.text.trim();
2541
2706
  notes[notes.length - 1].blocks.push(b);
@@ -2558,7 +2723,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
2558
2723
  var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
2559
2724
  var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
2560
2725
  function isRunningHead(block, page, pageHeight) {
2561
- const box = block.bbox, text = _optionalChain([block, 'access', _164 => _164.text, 'optionalAccess', _165 => _165.trim, 'call', _166 => _166()]);
2726
+ const box = block.bbox, text = _optionalChain([block, 'access', _180 => _180.text, 'optionalAccess', _181 => _181.trim, 'call', _182 => _182()]);
2562
2727
  if (!box || !text || !pageHeight) return false;
2563
2728
  const top = box.y + box.height >= pageHeight * 0.9;
2564
2729
  const bottom = box.y <= pageHeight * 0.1;
@@ -2566,7 +2731,7 @@ function isRunningHead(block, page, pageHeight) {
2566
2731
  const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
2567
2732
  if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
2568
2733
  if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
2569
- if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _167 => _167.style, 'optionalAccess', _168 => _168.fontSize]), () => ( 0))) * 1.6) return true;
2734
+ if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _183 => _183.style, 'optionalAccess', _184 => _184.fontSize]), () => ( 0))) * 1.6) return true;
2570
2735
  if (!text.includes(" ")) return false;
2571
2736
  const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
2572
2737
  if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
@@ -2575,7 +2740,7 @@ function isRunningHead(block, page, pageHeight) {
2575
2740
  return right > left && box.width >= (right - left) * 0.6;
2576
2741
  }
2577
2742
  function unbalancedClose(text) {
2578
- 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)));
2743
+ return (_nullishCoalesce(_optionalChain([text, 'access', _185 => _185.match, 'call', _186 => _186(/\)/g), 'optionalAccess', _187 => _187.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _188 => _188.match, 'call', _189 => _189(/\(/g), 'optionalAccess', _190 => _190.length]), () => ( 0)));
2579
2744
  }
2580
2745
  function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2581
2746
  const byPage = /* @__PURE__ */ new Map();
@@ -2591,7 +2756,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2591
2756
  const sizes = /* @__PURE__ */ new Map();
2592
2757
  let proseChars = 0;
2593
2758
  for (const b of page) {
2594
- if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _175 => _175.style, 'optionalAccess', _176 => _176.fontName]) || !b.style.fontSize) continue;
2759
+ if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _191 => _191.style, 'optionalAccess', _192 => _192.fontName]) || !b.style.fontSize) continue;
2595
2760
  const key2 = `${b.style.fontName}:${b.style.fontSize}`;
2596
2761
  chars.set(key2, (_nullishCoalesce(chars.get(key2), () => ( 0))) + b.text.length);
2597
2762
  if (b.type === "paragraph" && b.style.fontName === "ocr") {
@@ -2615,13 +2780,13 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2615
2780
  const citedProse = /* @__PURE__ */ new Set();
2616
2781
  const numberedProse = /* @__PURE__ */ new Set();
2617
2782
  for (const page of byPage.values()) {
2618
- 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)]), () => ( ""))));
2783
+ const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access', _193 => _193.text, 'optionalAccess', _194 => _194.trim, 'call', _195 => _195()]), () => ( ""))) && b.bbox && _optionalChain([b, 'access', _196 => _196.style, 'optionalAccess', _197 => _197.fontName]) && b.style.fontSize && !/Bold|Black|Heavy|Semibold/i.test(_nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _198 => _198.get, 'call', _199 => _199(b.style.fontName)]), () => ( ""))));
2619
2784
  let chain = [];
2620
2785
  const finish = () => {
2621
- 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;
2786
+ if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access', _200 => _200.text, 'optionalAccess', _201 => _201.length]), () => ( 0))) >= 40 && b.bbox.height >= b.style.fontSize * 2.4)) return;
2622
2787
  for (const b of chain) numberedProse.add(b);
2623
2788
  const first = chain[0], size = first.style.fontSize;
2624
- 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);
2789
+ for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access', _202 => _202.text, 'optionalAccess', _203 => _203.trim, 'call', _204 => _204()]), () => ( ""))) && _optionalChain([b, 'access', _205 => _205.style, 'optionalAccess', _206 => _206.fontName]) === _optionalChain([first, 'access', _207 => _207.style, 'optionalAccess', _208 => _208.fontName]) && _optionalChain([b, 'access', _209 => _209.style, 'optionalAccess', _210 => _210.fontSize]) === size && b.bbox && Math.abs(b.bbox.x - first.bbox.x) <= size * 0.5 && (_nullishCoalesce(_optionalChain([b, 'access', _211 => _211.text, 'optionalAccess', _212 => _212.length]), () => ( 0))) >= 15) numberedProse.add(b);
2625
2790
  };
2626
2791
  for (const b of numbered) {
2627
2792
  const prev = chain.at(-1), size = b.style.fontSize;
@@ -2635,9 +2800,9 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2635
2800
  }
2636
2801
  for (let i = 0; i + 1 < blocks.length; i++) {
2637
2802
  const prose = blocks[i], reference = blocks[i + 1];
2638
- const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _197 => _197.style, 'optionalAccess', _198 => _198.fontSize]), () => ( 0));
2639
- const source = _nullishCoalesce(_optionalChain([reference, 'access', _199 => _199.text, 'optionalAccess', _200 => _200.replace, 'call', _201 => _201(/<[^>]+>/g, ""), 'access', _202 => _202.trim, 'call', _203 => _203()]), () => ( ""));
2640
- 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;
2803
+ const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _213 => _213.style, 'optionalAccess', _214 => _214.fontSize]), () => ( 0));
2804
+ const source = _nullishCoalesce(_optionalChain([reference, 'access', _215 => _215.text, 'optionalAccess', _216 => _216.replace, 'call', _217 => _217(/<[^>]+>/g, ""), 'access', _218 => _218.trim, 'call', _219 => _219()]), () => ( ""));
2805
+ if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access', _220 => _220.text, 'optionalAccess', _221 => _221.length]), () => ( 0))) < 40 || !a || !b || size <= 0 || a.height < size * 2.4 || prose.pageNumber !== reference.pageNumber || _optionalChain([prose, 'access', _222 => _222.style, 'optionalAccess', _223 => _223.fontName]) !== _optionalChain([reference, 'access', _224 => _224.style, 'optionalAccess', _225 => _225.fontName]) || _optionalChain([prose, 'access', _226 => _226.style, 'optionalAccess', _227 => _227.fontSize]) !== _optionalChain([reference, 'access', _228 => _228.style, 'optionalAccess', _229 => _229.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;
2641
2806
  citedProse.add(prose);
2642
2807
  citedProse.add(reference);
2643
2808
  }
@@ -2645,49 +2810,49 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
2645
2810
  const block = blocks[i];
2646
2811
  if (block.type !== "heading" || !block.text) continue;
2647
2812
  const text = block.text.replace(/<[^>]+>/g, "").trim();
2648
- const fsz = _nullishCoalesce(_optionalChain([block, 'access', _214 => _214.style, 'optionalAccess', _215 => _215.fontSize]), () => ( 0));
2649
- const tocEntry = i > 0 && _chunk3FGHQWJPcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunk3FGHQWJPcjs.TOC_BLOCKS.has(blocks[i + 1]);
2813
+ const fsz = _nullishCoalesce(_optionalChain([block, 'access', _230 => _230.style, 'optionalAccess', _231 => _231.fontSize]), () => ( 0));
2814
+ const tocEntry = i > 0 && _chunkFNX3ZAYBcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkFNX3ZAYBcjs.TOC_BLOCKS.has(blocks[i + 1]);
2650
2815
  const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
2651
- 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;
2816
+ const proseStyle = _optionalChain([block, 'access', _232 => _232.style, 'optionalAccess', _233 => _233.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
2652
2817
  const next = blocks[i + 1];
2653
- const nb = _optionalChain([next, 'optionalAccess', _218 => _218.bbox]), bb = block.bbox;
2654
- 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;
2655
- if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _221 => _221.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
2818
+ const nb = _optionalChain([next, 'optionalAccess', _234 => _234.bbox]), bb = block.bbox;
2819
+ const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _235 => _235.style, 'optionalAccess', _236 => _236.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;
2820
+ if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _237 => _237.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
2656
2821
  next.text = `${block.text.trim()} ${next.text.trim()}`;
2657
2822
  blocks.splice(i--, 1);
2658
2823
  continue;
2659
2824
  }
2660
- 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) {
2825
+ if ((_optionalChain([next, 'optionalAccess', _238 => _238.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _239 => _239.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _240 => _240.style, 'optionalAccess', _241 => _241.fontName]) === _optionalChain([block, 'access', _242 => _242.style, 'optionalAccess', _243 => _243.fontName]) && _optionalChain([next, 'access', _244 => _244.style, 'optionalAccess', _245 => _245.fontSize]) === _optionalChain([block, 'access', _246 => _246.style, 'optionalAccess', _247 => _247.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) {
2661
2826
  block.text = `${block.text.trim()} ${next.text.trim()}`;
2662
2827
  block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
2663
2828
  blocks.splice(i + 1, 1);
2664
2829
  }
2665
2830
  const after = blocks[i + 2];
2666
- 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])) {
2831
+ if ((_optionalChain([next, 'optionalAccess', _248 => _248.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _249 => _249.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _250 => _250.text, 'optionalAccess', _251 => _251.trim, 'call', _252 => _252()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _253 => _253.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _254 => _254.style, 'optionalAccess', _255 => _255.fontSize]) === _optionalChain([block, 'access', _256 => _256.style, 'optionalAccess', _257 => _257.fontSize])) {
2667
2832
  block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
2668
2833
  blocks.splice(i + 1, 2);
2669
2834
  }
2670
2835
  const tiny = fsz > 0 && fsz < 7.5;
2671
2836
  const prev = blocks[i - 1];
2672
- 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) {
2837
+ if (_optionalChain([prev, 'optionalAccess', _258 => _258.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _259 => _259.text, 'optionalAccess', _260 => _260.trim, 'call', _261 => _261()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
2673
2838
  prev.text = `${prev.text.trim()} ${block.text.trim()}`;
2674
2839
  prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
2675
2840
  blocks.splice(i--, 1);
2676
2841
  continue;
2677
2842
  }
2678
- 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)) {
2843
+ if (_optionalChain([prev, 'optionalAccess', _262 => _262.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _263 => _263.text, 'optionalAccess', _264 => _264.trim, 'call', _265 => _265()]), () => ( ""))) && 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', _266 => _266.style, 'optionalAccess', _267 => _267.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
2679
2844
  block.text = `${prev.text.trim()} ${block.text.trim()}`;
2680
2845
  blocks.splice(i - 1, 1);
2681
2846
  i -= 2;
2682
2847
  continue;
2683
2848
  }
2684
- const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _252 => _252.style, 'optionalAccess', _253 => _253.fontSize]), () => ( 0));
2685
- 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");
2686
- const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _259 => _259.get, 'call', _260 => _260(_nullishCoalesce(_optionalChain([block, 'access', _261 => _261.style, 'optionalAccess', _262 => _262.fontName]), () => ( "")))]), () => ( ""));
2849
+ const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _268 => _268.style, 'optionalAccess', _269 => _269.fontSize]), () => ( 0));
2850
+ const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _270 => _270.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _271 => _271.style, 'optionalAccess', _272 => _272.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _273 => _273.style, 'optionalAccess', _274 => _274.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");
2851
+ const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _275 => _275.get, 'call', _276 => _276(_nullishCoalesce(_optionalChain([block, 'access', _277 => _277.style, 'optionalAccess', _278 => _278.fontName]), () => ( "")))]), () => ( ""));
2687
2852
  const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
2688
- 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;
2689
- 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);
2690
- 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;
2853
+ const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _279 => _279[i - 1], 'optionalAccess', _280 => _280.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
2854
+ const ocrFragment = _optionalChain([block, 'access', _281 => _281.style, 'optionalAccess', _282 => _282.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _283 => _283.match, 'call', _284 => _284(/\p{L}/gu), 'optionalAccess', _285 => _285.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
2855
+ const crowdedOcr = _optionalChain([block, 'access', _286 => _286.style, 'optionalAccess', _287 => _287.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _288 => _288.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _289 => _289.style, 'optionalAccess', _290 => _290.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _291 => _291.text, 'optionalAccess', _292 => _292.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;
2691
2856
  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)"·"가)" 앞머리 번호는 빼고 센다
2692
2857
  unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
2693
2858
  block.type = "paragraph";
@@ -2722,34 +2887,34 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
2722
2887
  function captionTableText(t) {
2723
2888
  if (!t || t.rows !== 1 || t.cols !== 2) return null;
2724
2889
  const [label, body] = t.cells[0];
2725
- 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;
2890
+ if (!label || !body || _optionalChain([label, 'access', _293 => _293.blocks, 'optionalAccess', _294 => _294.length]) || _optionalChain([body, 'access', _295 => _295.blocks, 'optionalAccess', _296 => _296.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
2726
2891
  return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
2727
2892
  }
2728
2893
  function splitSingleCellTables(blocks) {
2729
2894
  const out = [];
2730
2895
  for (const b of blocks) {
2731
2896
  const t = b.type === "table" ? b.table : void 0;
2732
- const title = t && _chunk3FGHQWJPcjs.FRAME_TITLE_BLOCKS.get(t);
2897
+ const title = t && _chunkFNX3ZAYBcjs.FRAME_TITLE_BLOCKS.get(t);
2733
2898
  if (title) {
2734
2899
  out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
2735
2900
  continue;
2736
2901
  }
2737
- 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;
2902
+ const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _297 => _297.cells, 'access', _298 => _298[0], 'optionalAccess', _299 => _299[0], 'optionalAccess', _300 => _300.blocks, 'optionalAccess', _301 => _301.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
2738
2903
  const squash = (s) => s.replace(/\s/g, "");
2739
2904
  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;
2740
- const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _286 => _286.type]) === "table" ? captionTableText(inner.table) : null)));
2905
+ const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _302 => _302.type]) === "table" ? captionTableText(inner.table) : null)));
2741
2906
  if (caption) {
2742
2907
  out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
2743
2908
  continue;
2744
2909
  }
2745
- 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;
2910
+ const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _303 => _303.cells, 'access', _304 => _304[0], 'optionalAccess', _305 => _305[0]]) : void 0;
2746
2911
  if (!cell) {
2747
2912
  out.push(b);
2748
2913
  continue;
2749
2914
  }
2750
2915
  const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
2751
- 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 });
2752
- if (_optionalChain([cell, 'access', _293 => _293.blocks, 'optionalAccess', _294 => _294.length])) {
2916
+ if (_optionalChain([t, 'optionalAccess', _306 => _306.caption, 'optionalAccess', _307 => _307.trim, 'call', _308 => _308()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
2917
+ if (_optionalChain([cell, 'access', _309 => _309.blocks, 'optionalAccess', _310 => _310.length])) {
2753
2918
  out.push(...splitSingleCellTables(cell.blocks));
2754
2919
  continue;
2755
2920
  }
@@ -2765,7 +2930,7 @@ function joinLatinCellWraps(blocks) {
2765
2930
  const lines = cell.text.split("\n");
2766
2931
  const out = [lines[0]];
2767
2932
  for (const line of lines.slice(1)) {
2768
- if (_chunk3FGHQWJPcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
2933
+ if (_chunkFNX3ZAYBcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
2769
2934
  else out.push(line);
2770
2935
  }
2771
2936
  cell.text = out.join("\n");
@@ -2776,19 +2941,19 @@ function joinLatinCellWraps(blocks) {
2776
2941
  }
2777
2942
  function cleanPdfText(text, opts) {
2778
2943
  let clean = normalizeAraea(stripControlChars(text));
2779
- if (!_optionalChain([opts, 'optionalAccess', _295 => _295.keepLoneNumbers])) {
2944
+ if (!_optionalChain([opts, 'optionalAccess', _311 => _311.keepLoneNumbers])) {
2780
2945
  clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
2781
2946
  }
2782
- if (!_optionalChain([opts, 'optionalAccess', _296 => _296.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
2947
+ if (!_optionalChain([opts, 'optionalAccess', _312 => _312.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
2783
2948
  return mergeKoreanLines(
2784
2949
  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))
2785
2950
  ).replace(/^(?!\| ---).*$/gm, (line) => {
2786
2951
  if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
2787
2952
  if (line.startsWith("|")) {
2788
- return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunk3FGHQWJPcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
2953
+ return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkFNX3ZAYBcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
2789
2954
  }
2790
- const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _297 => _297.exec, 'call', _298 => _298(line), 'optionalAccess', _299 => _299[0]]), () => ( ""));
2791
- return mark + _chunk3FGHQWJPcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
2955
+ const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _313 => _313.exec, 'call', _314 => _314(line), 'optionalAccess', _315 => _315[0]]), () => ( ""));
2956
+ return mark + _chunkFNX3ZAYBcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
2792
2957
  }).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
2793
2958
  }
2794
2959
  function startsWithMarker(line) {
@@ -2820,7 +2985,7 @@ function mergeKoreanLines(text) {
2820
2985
  continue;
2821
2986
  }
2822
2987
  if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
2823
- result[result.length - 1] = prev + _chunk3FGHQWJPcjs.wrapJoiner.call(void 0, prev, curr) + curr;
2988
+ result[result.length - 1] = prev + _chunkFNX3ZAYBcjs.wrapJoiner.call(void 0, prev, curr) + curr;
2824
2989
  } else {
2825
2990
  result.push(curr);
2826
2991
  }
@@ -2836,7 +3001,7 @@ function applyLinkAnnotations(items, annots) {
2836
3001
  const wrapped = /* @__PURE__ */ new Set();
2837
3002
  for (const a of annots) {
2838
3003
  if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
2839
- const url = _chunkK6WSMTVUcjs.sanitizeHref.call(void 0, a.url);
3004
+ const url = _chunkRHMIEEAZcjs.sanitizeHref.call(void 0, a.url);
2840
3005
  if (!url) continue;
2841
3006
  const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
2842
3007
  const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
@@ -2877,7 +3042,7 @@ function mergeLinkRuns(markdown) {
2877
3042
 
2878
3043
  // src/pdf/formula-ocr.ts
2879
3044
  async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
2880
- const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-HJNQGPRC.cjs")));
3045
+ const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-J3UUIPCX.cjs")));
2881
3046
  const { FormulaPipeline, ensureFormulaModels } = formulaMod;
2882
3047
  await ensureFormulaModels((p) => {
2883
3048
  if (p.phase === "download" && p.total) {
@@ -3068,13 +3233,13 @@ async function loadPdfWithTimeout(buffer) {
3068
3233
  try {
3069
3234
  return await Promise.race([
3070
3235
  loadingTask.promise.catch((e) => {
3071
- if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkK6WSMTVUcjs.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)");
3236
+ if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkRHMIEEAZcjs.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)");
3072
3237
  throw e;
3073
3238
  }),
3074
3239
  new Promise((_, reject) => {
3075
3240
  timer = setTimeout(() => {
3076
3241
  loadingTask.destroy();
3077
- reject(new (0, _chunkK6WSMTVUcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
3242
+ reject(new (0, _chunkRHMIEEAZcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
3078
3243
  }, PDF_LOAD_TIMEOUT_MS);
3079
3244
  })
3080
3245
  ]);
@@ -3083,13 +3248,13 @@ async function loadPdfWithTimeout(buffer) {
3083
3248
  }
3084
3249
  }
3085
3250
  async function parsePdfDocument(buffer, options) {
3086
- const formulaBuffer = _optionalChain([options, 'optionalAccess', _300 => _300.formulaOcr]) ? buffer : null;
3087
- const autoOcr = _optionalChain([options, 'optionalAccess', _301 => _301.ocr]) === void 0 && await _chunk3FGHQWJPcjs.ocrModelsCached.call(void 0, );
3088
- const ocrBuffer = _optionalChain([options, 'optionalAccess', _302 => _302.ocr]) || autoOcr ? buffer : null;
3251
+ const formulaBuffer = _optionalChain([options, 'optionalAccess', _316 => _316.formulaOcr]) ? buffer : null;
3252
+ const autoOcr = _optionalChain([options, 'optionalAccess', _317 => _317.ocr]) === void 0 && await _chunkFNX3ZAYBcjs.ocrModelsCached.call(void 0, );
3253
+ const ocrBuffer = _optionalChain([options, 'optionalAccess', _318 => _318.ocr]) || autoOcr ? buffer : null;
3089
3254
  const doc = await loadPdfWithTimeout(buffer);
3090
3255
  try {
3091
3256
  const pageCount = doc.numPages;
3092
- if (pageCount === 0) throw new (0, _chunkK6WSMTVUcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
3257
+ if (pageCount === 0) throw new (0, _chunkRHMIEEAZcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
3093
3258
  const metadata = { pageCount, pageMode: "layout" };
3094
3259
  await extractPdfMetadata(doc, metadata);
3095
3260
  const blocks = [];
@@ -3098,8 +3263,8 @@ async function parsePdfDocument(buffer, options) {
3098
3263
  let totalChars = 0;
3099
3264
  let totalTextBytes = 0;
3100
3265
  const effectivePageCount = Math.min(pageCount, MAX_PAGES);
3101
- const pageFilter = _optionalChain([options, 'optionalAccess', _303 => _303.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
3102
- if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _304 => _304.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
3266
+ const pageFilter = _optionalChain([options, 'optionalAccess', _319 => _319.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
3267
+ if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _320 => _320.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
3103
3268
  warnings.push({ message: `${pageCount}\uCABD \uC911 \uC55E ${MAX_PAGES}\uCABD\uB9CC \uD30C\uC2F1\uD588\uC2B5\uB2C8\uB2E4 (\uCABD \uC218 \uC0C1\uD55C)`, code: "PARTIAL_PARSE" });
3104
3269
  }
3105
3270
  const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
@@ -3118,10 +3283,10 @@ async function parsePdfDocument(buffer, options) {
3118
3283
  const pageImageBlocks = /* @__PURE__ */ new Map();
3119
3284
  const carry = {};
3120
3285
  const vectorPageOps = /* @__PURE__ */ new Map();
3121
- const wrapLexicon = new (0, _chunk3FGHQWJPcjs.WrapLexicon)();
3286
+ const wrapLexicon = new (0, _chunkFNX3ZAYBcjs.WrapLexicon)();
3122
3287
  const noteMarks = /* @__PURE__ */ new Map();
3123
3288
  const headerContext = [];
3124
- if (pageFilter && _optionalChain([options, 'optionalAccess', _305 => _305.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
3289
+ if (pageFilter && _optionalChain([options, 'optionalAccess', _321 => _321.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
3125
3290
  for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
3126
3291
  let contextPage;
3127
3292
  try {
@@ -3131,7 +3296,7 @@ async function parsePdfDocument(buffer, options) {
3131
3296
  headerContext.push(...marginContextBlocks(content.items, number, contextPage.view));
3132
3297
  } catch (e4) {
3133
3298
  } finally {
3134
- _optionalChain([contextPage, 'optionalAccess', _306 => _306.cleanup, 'call', _307 => _307()]);
3299
+ _optionalChain([contextPage, 'optionalAccess', _322 => _322.cleanup, 'call', _323 => _323()]);
3135
3300
  }
3136
3301
  }
3137
3302
  }
@@ -3158,13 +3323,13 @@ async function parsePdfDocument(buffer, options) {
3158
3323
  return void 0;
3159
3324
  }
3160
3325
  };
3161
- const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _308 => _308(loadedName), 'optionalAccess', _309 => _309.differences]);
3162
- restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _310 => _310(n), 'optionalAccess', _311 => _311.name]));
3326
+ const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _324 => _324(loadedName), 'optionalAccess', _325 => _325.differences]);
3327
+ restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _326 => _326(n), 'optionalAccess', _327 => _327.name]));
3163
3328
  restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
3164
3329
  markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
3165
3330
  const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
3166
- const items = _chunk3FGHQWJPcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
3167
- const filtered = _chunk3FGHQWJPcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
3331
+ const items = _chunkFNX3ZAYBcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
3332
+ const filtered = _chunkFNX3ZAYBcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
3168
3333
  const joined = joinVerticalColumns(filtered.visible);
3169
3334
  const visible = dropTabLeaderDots(joined);
3170
3335
  const hiddenCount = filtered.hiddenCount + occluded.size;
@@ -3188,27 +3353,27 @@ async function parsePdfDocument(buffer, options) {
3188
3353
  fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
3189
3354
  argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
3190
3355
  } : rawOps;
3191
- remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _312 => _312(loadedName), 'optionalAccess', _313 => _313.name]));
3356
+ remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _328 => _328(loadedName), 'optionalAccess', _329 => _329.name]));
3192
3357
  remapControlGlyphs(visible, differencesOf);
3193
- await _chunk3FGHQWJPcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
3358
+ await _chunkFNX3ZAYBcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
3194
3359
  const faces = /* @__PURE__ */ new Map();
3195
3360
  for (const it of visible) {
3196
3361
  if (!it.fontName) continue;
3197
3362
  let face = faces.get(it.fontName);
3198
3363
  if (face === void 0) {
3199
3364
  const obj = fontObj(it.fontName);
3200
- face = _optionalChain([obj, 'optionalAccess', _314 => _314.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
3365
+ face = _optionalChain([obj, 'optionalAccess', _330 => _330.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
3201
3366
  faces.set(it.fontName, face);
3202
3367
  }
3203
3368
  it.fontName = face;
3204
- if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _315 => _315(face), 'optionalAccess', _316 => _316.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
3369
+ if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _331 => _331(face), 'optionalAccess', _332 => _332.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
3205
3370
  }
3206
- for (const it of visible) if (it.text.includes("$")) it.text = _chunk6FW3AZWNcjs.escapeLiteralDollar.call(void 0, it.text);
3207
- for (const it of visible) if (it.text.includes("<")) it.text = _chunk6FW3AZWNcjs.escapeLiteralTags.call(void 0, it.text);
3371
+ for (const it of visible) if (it.text.includes("$")) it.text = _chunkW5NXOMCDcjs.escapeLiteralDollar.call(void 0, it.text);
3372
+ for (const it of visible) if (it.text.includes("<")) it.text = _chunkW5NXOMCDcjs.escapeLiteralTags.call(void 0, it.text);
3208
3373
  wrapEquationRuns(visible, (face) => faceNames.get(face));
3209
3374
  const pageArea = pageW * pageH;
3210
3375
  if (pageArea > 0) {
3211
- const imageRegions = _chunk3FGHQWJPcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
3376
+ const imageRegions = _chunkFNX3ZAYBcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
3212
3377
  let uncovered = 0;
3213
3378
  for (const r of imageRegions) {
3214
3379
  const area = (r.x2 - r.x1) * (r.y2 - r.y1);
@@ -3234,15 +3399,15 @@ async function parsePdfDocument(buffer, options) {
3234
3399
  if (uncovered > 0) skippedImagePages.set(i, uncovered);
3235
3400
  }
3236
3401
  const marks = superscriptNoteMarks(visible);
3237
- if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunk3FGHQWJPcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
3402
+ if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkFNX3ZAYBcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
3238
3403
  const stamp = marginStamp(visible);
3239
3404
  const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
3240
- const rightArrows = _optionalChain([options, 'optionalAccess', _317 => _317.tables]) !== false ? await _chunk3FGHQWJPcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
3241
- const pageBlocks = orderTwoUpPage(_chunk3FGHQWJPcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _318 => _318.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
3405
+ const rightArrows = _optionalChain([options, 'optionalAccess', _333 => _333.tables]) !== false ? await _chunkFNX3ZAYBcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
3406
+ const pageBlocks = orderTwoUpPage(_chunkFNX3ZAYBcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _334 => _334.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
3242
3407
  if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
3243
3408
  for (const b of pageBlocks) blocks.push(b);
3244
3409
  try {
3245
- const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _319 => _319.images]) !== false);
3410
+ const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _335 => _335.images]) !== false);
3246
3411
  if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
3247
3412
  extractedImages.push(...pageImages);
3248
3413
  } catch (e7) {
@@ -3261,17 +3426,17 @@ async function parsePdfDocument(buffer, options) {
3261
3426
  const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
3262
3427
  const quality = computePageQuality(i, pageText, vector.glyphs);
3263
3428
  pageQuality.push(quality);
3264
- if (_optionalChain([options, 'optionalAccess', _320 => _320.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
3429
+ if (_optionalChain([options, 'optionalAccess', _336 => _336.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
3265
3430
  vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
3266
3431
  }
3267
- if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkK6WSMTVUcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
3432
+ if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkRHMIEEAZcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
3268
3433
  parsedPages++;
3269
- _optionalChain([options, 'optionalAccess', _321 => _321.onProgress, 'optionalCall', _322 => _322(parsedPages, totalTarget)]);
3434
+ _optionalChain([options, 'optionalAccess', _337 => _337.onProgress, 'optionalCall', _338 => _338(parsedPages, totalTarget)]);
3270
3435
  } catch (pageErr) {
3271
- if (pageErr instanceof _chunkK6WSMTVUcjs.KordocError) throw pageErr;
3436
+ if (pageErr instanceof _chunkRHMIEEAZcjs.KordocError) throw pageErr;
3272
3437
  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" });
3273
3438
  } finally {
3274
- _optionalChain([loadedPage, 'optionalAccess', _323 => _323.cleanup, 'call', _324 => _324()]);
3439
+ _optionalChain([loadedPage, 'optionalAccess', _339 => _339.cleanup, 'call', _340 => _340()]);
3275
3440
  }
3276
3441
  if (loadedFonts.size > FONT_CACHE_LIMIT) {
3277
3442
  await doc.cleanup();
@@ -3279,13 +3444,13 @@ async function parsePdfDocument(buffer, options) {
3279
3444
  }
3280
3445
  }
3281
3446
  const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
3282
- const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _325 => _325.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
3447
+ const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _341 => _341.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
3283
3448
  const ocrDone = /* @__PURE__ */ new Set();
3284
- const ocrRegions = _optionalChain([options, 'optionalAccess', _326 => _326.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _327 => _327.ocr]) === true) : /* @__PURE__ */ new Map();
3449
+ const ocrRegions = _optionalChain([options, 'optionalAccess', _342 => _342.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _343 => _343.ocr]) === true) : /* @__PURE__ */ new Map();
3285
3450
  if (ocrBuffer) {
3286
3451
  const inScope = (p) => !pageFilter || pageFilter.has(p);
3287
3452
  const targets = /* @__PURE__ */ new Set();
3288
- if (_optionalChain([options, 'optionalAccess', _328 => _328.ocr]) === "force" || isImageBased) {
3453
+ if (_optionalChain([options, 'optionalAccess', _344 => _344.ocr]) === "force" || isImageBased) {
3289
3454
  for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
3290
3455
  } else {
3291
3456
  for (const pq of pageQuality) {
@@ -3298,16 +3463,16 @@ async function parsePdfDocument(buffer, options) {
3298
3463
  }
3299
3464
  if (targets.size > 0) {
3300
3465
  try {
3301
- const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-HR6CXGTX.cjs")));
3302
- const mode = typeof _optionalChain([options, 'optionalAccess', _329 => _329.ocr]) === "function" ? options.ocr : "builtin";
3303
- 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])));
3304
- const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _334 => _334.onProgress]), _optionalChain([options, 'optionalAccess', _335 => _335.tables]) !== false, vectorPageOps, regionPages);
3305
- for (const obs of ocrPageBlocks.values()) _chunk6FW3AZWNcjs.stripScriptTags.call(void 0, { blocks: obs });
3466
+ const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-DXQIMO77.cjs")));
3467
+ const mode = typeof _optionalChain([options, 'optionalAccess', _345 => _345.ocr]) === "function" ? options.ocr : "builtin";
3468
+ const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _346 => _346.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _347 => _347.find, 'call', _348 => _348((q) => q.page === p), 'optionalAccess', _349 => _349.needsOcr])));
3469
+ const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _350 => _350.onProgress]), _optionalChain([options, 'optionalAccess', _351 => _351.tables]) !== false, vectorPageOps, regionPages);
3470
+ for (const obs of ocrPageBlocks.values()) _chunkW5NXOMCDcjs.stripScriptTags.call(void 0, { blocks: obs });
3306
3471
  if (ocrPageBlocks.size > 0) {
3307
3472
  const replacePages = /* @__PURE__ */ new Set();
3308
3473
  for (const [p, obs] of ocrPageBlocks) {
3309
- const needsOcr = _optionalChain([pageQuality, 'access', _336 => _336.find, 'call', _337 => _337((q) => q.page === p), 'optionalAccess', _338 => _338.needsOcr]);
3310
- if (_optionalChain([options, 'optionalAccess', _339 => _339.ocr]) === "force" || isImageBased || needsOcr) {
3474
+ const needsOcr = _optionalChain([pageQuality, 'access', _352 => _352.find, 'call', _353 => _353((q) => q.page === p), 'optionalAccess', _354 => _354.needsOcr]);
3475
+ if (_optionalChain([options, 'optionalAccess', _355 => _355.ocr]) === "force" || isImageBased || needsOcr) {
3311
3476
  replacePages.add(p);
3312
3477
  ocrDone.add(p);
3313
3478
  continue;
@@ -3315,7 +3480,7 @@ async function parsePdfDocument(buffer, options) {
3315
3480
  const regions = ocrRegions.get(p);
3316
3481
  if (!regions || mergeOcrImageRegions(blocks, p, regions, obs) === 0) continue;
3317
3482
  ocrDone.add(p);
3318
- if (_optionalChain([pageImageBlocks, 'access', _340 => _340.get, 'call', _341 => _341(p), 'optionalAccess', _342 => _342.length]) === 1) pageImageBlocks.delete(p);
3483
+ if (_optionalChain([pageImageBlocks, 'access', _356 => _356.get, 'call', _357 => _357(p), 'optionalAccess', _358 => _358.length]) === 1) pageImageBlocks.delete(p);
3319
3484
  }
3320
3485
  if (replacePages.size) {
3321
3486
  const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
@@ -3365,12 +3530,12 @@ async function parsePdfDocument(buffer, options) {
3365
3530
  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" });
3366
3531
  }
3367
3532
  }
3368
- if (_optionalChain([options, 'optionalAccess', _343 => _343.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
3369
- const removed = _chunk3FGHQWJPcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
3533
+ if (_optionalChain([options, 'optionalAccess', _359 => _359.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
3534
+ const removed = _chunkFNX3ZAYBcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
3370
3535
  for (let ri = removed.length - 1; ri >= 0; ri--) {
3371
3536
  blocks.splice(removed[ri], 1);
3372
3537
  }
3373
- const kept = _chunk3FGHQWJPcjs.removeSideTabs.call(void 0, blocks, pageWidths);
3538
+ const kept = _chunkFNX3ZAYBcjs.removeSideTabs.call(void 0, blocks, pageWidths);
3374
3539
  if (kept !== blocks) {
3375
3540
  blocks.length = 0;
3376
3541
  blocks.push(...kept);
@@ -3378,15 +3543,15 @@ async function parsePdfDocument(buffer, options) {
3378
3543
  }
3379
3544
  mergeContinuedCells(blocks, pageHeights);
3380
3545
  mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
3381
- if (_optionalChain([options, 'optionalAccess', _344 => _344.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
3382
- const boxes = _chunk3FGHQWJPcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
3546
+ if (_optionalChain([options, 'optionalAccess', _360 => _360.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
3547
+ const boxes = _chunkFNX3ZAYBcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
3383
3548
  for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
3384
3549
  }
3385
3550
  splitContactTables(blocks);
3386
- if (!_optionalChain([options, 'optionalAccess', _345 => _345.keepTrailingEmptyCols])) _chunk3FGHQWJPcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
3387
- _chunk3FGHQWJPcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
3551
+ if (!_optionalChain([options, 'optionalAccess', _361 => _361.keepTrailingEmptyCols])) _chunkFNX3ZAYBcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
3552
+ _chunkFNX3ZAYBcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
3388
3553
  injectPageImageBlocks(blocks, pageImageBlocks);
3389
- if (_optionalChain([options, 'optionalAccess', _346 => _346.formulaOcr]) && formulaBuffer) {
3554
+ if (_optionalChain([options, 'optionalAccess', _362 => _362.formulaOcr]) && formulaBuffer) {
3390
3555
  try {
3391
3556
  await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
3392
3557
  } catch (e) {
@@ -3396,53 +3561,53 @@ async function parsePdfDocument(buffer, options) {
3396
3561
  });
3397
3562
  }
3398
3563
  }
3399
- const medianFontSize = _chunk3FGHQWJPcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
3564
+ const medianFontSize = _chunkFNX3ZAYBcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
3400
3565
  if (medianFontSize > 0) {
3401
- _chunk3FGHQWJPcjs.detectHeadings.call(void 0, blocks, medianFontSize);
3402
- }
3403
- _chunk3FGHQWJPcjs.detectDocumentStyleHeadings.call(void 0, blocks);
3404
- _chunk3FGHQWJPcjs.detectTypographyHeadings.call(void 0, blocks);
3405
- _chunk3FGHQWJPcjs.detectSiblingStyleHeadings.call(void 0, blocks);
3406
- _chunk3FGHQWJPcjs.detectRepeatedPageLabels.call(void 0, blocks);
3407
- _chunk3FGHQWJPcjs.detectPageLeadHeadings.call(void 0, blocks);
3408
- _chunk3FGHQWJPcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
3409
- _chunk3FGHQWJPcjs.refineDocumentStyleHeadings.call(void 0, blocks);
3410
- _chunk3FGHQWJPcjs.detectMarkerHeadings.call(void 0, blocks);
3566
+ _chunkFNX3ZAYBcjs.detectHeadings.call(void 0, blocks, medianFontSize);
3567
+ }
3568
+ _chunkFNX3ZAYBcjs.detectDocumentStyleHeadings.call(void 0, blocks);
3569
+ _chunkFNX3ZAYBcjs.detectTypographyHeadings.call(void 0, blocks);
3570
+ _chunkFNX3ZAYBcjs.detectSiblingStyleHeadings.call(void 0, blocks);
3571
+ _chunkFNX3ZAYBcjs.detectRepeatedPageLabels.call(void 0, blocks);
3572
+ _chunkFNX3ZAYBcjs.detectPageLeadHeadings.call(void 0, blocks);
3573
+ _chunkFNX3ZAYBcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
3574
+ _chunkFNX3ZAYBcjs.refineDocumentStyleHeadings.call(void 0, blocks);
3575
+ _chunkFNX3ZAYBcjs.detectMarkerHeadings.call(void 0, blocks);
3411
3576
  demoteNonHeadingRoles(blocks, pageHeights, faceNames);
3412
- _chunk3FGHQWJPcjs.detectTableCaptions.call(void 0, blocks);
3413
- _chunk3FGHQWJPcjs.detectKoreanListBlocks.call(void 0, blocks);
3577
+ _chunkFNX3ZAYBcjs.detectTableCaptions.call(void 0, blocks);
3578
+ _chunkFNX3ZAYBcjs.detectKoreanListBlocks.call(void 0, blocks);
3414
3579
  const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
3415
3580
  sanitizeBlockControlChars(blocks);
3416
3581
  let outBlocks = splitSingleCellTables(blocks);
3417
- if (_optionalChain([options, 'optionalAccess', _347 => _347.layoutTables]) !== "keep") {
3582
+ if (_optionalChain([options, 'optionalAccess', _363 => _363.layoutTables]) !== "keep") {
3418
3583
  blocks.length = 0;
3419
3584
  for (const block of outBlocks) blocks.push(block);
3420
3585
  }
3421
3586
  outBlocks = inlineFootnotes(outBlocks, noteMarks);
3422
3587
  outBlocks = relocateEndnotes(outBlocks);
3423
- if (_optionalChain([options, 'optionalAccess', _348 => _348.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
3588
+ if (_optionalChain([options, 'optionalAccess', _364 => _364.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
3424
3589
  if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
3425
3590
  const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
3426
3591
  if (!b.bbox || !h) return false;
3427
3592
  return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
3428
3593
  });
3429
3594
  joinLatinCellWraps(outBlocks);
3430
- if (_optionalChain([options, 'optionalAccess', _349 => _349.layoutTables]) !== "keep") {
3595
+ if (_optionalChain([options, 'optionalAccess', _365 => _365.layoutTables]) !== "keep") {
3431
3596
  const hancom = await isHancomPdf(doc);
3432
3597
  const shown = /* @__PURE__ */ new Map();
3433
3598
  const markContent = (bs) => {
3434
3599
  for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
3435
- if (_chunk3FGHQWJPcjs.IMAGE_CELLS.has(c)) _chunk6FW3AZWNcjs.CONTENT_CELLS.add(c);
3600
+ if (_chunkFNX3ZAYBcjs.IMAGE_CELLS.has(c)) _chunkW5NXOMCDcjs.CONTENT_CELLS.add(c);
3436
3601
  markContent(c.blocks);
3437
3602
  }
3438
3603
  };
3439
3604
  const visual = (bs) => bs.flatMap((b) => {
3440
3605
  if (b.type !== "table") return [b];
3441
- if (!hancom && b.table && _chunk3FGHQWJPcjs.CLIP_TABLES.has(b.table)) return [b];
3606
+ if (!hancom && b.table && _chunkFNX3ZAYBcjs.CLIP_TABLES.has(b.table)) return [b];
3442
3607
  let v = shown.get(b);
3443
3608
  if (!v) {
3444
3609
  markContent([b]);
3445
- shown.set(b, v = _chunk6FW3AZWNcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _350 => _350.keepTrailingEmptyCols])));
3610
+ shown.set(b, v = _chunkW5NXOMCDcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _366 => _366.keepTrailingEmptyCols])));
3446
3611
  }
3447
3612
  return v;
3448
3613
  });
@@ -3451,11 +3616,12 @@ async function parsePdfDocument(buffer, options) {
3451
3616
  blocks.length = 0;
3452
3617
  for (const b of kept) blocks.push(b);
3453
3618
  }
3454
- const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunk6FW3AZWNcjs.blocksToMarkdown.call(void 0, bs), { keepLoneNumbers: true }));
3619
+ const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkW5NXOMCDcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _367 => _367.tableFormat]) }), { keepLoneNumbers: true }));
3620
+ if (_optionalChain([options, 'optionalAccess', _368 => _368.tableFormat]) === "gfm") _chunkW5NXOMCDcjs.assignTableIds.call(void 0, blocks);
3455
3621
  let markdown = finishMarkdown(outBlocks);
3456
3622
  return {
3457
3623
  markdown,
3458
- pages: _chunkRQEDNI4Pcjs.blocksToPages.call(void 0, _chunk3FGHQWJPcjs.splitPageBreakWraps.call(void 0, outBlocks), finishMarkdown),
3624
+ pages: _chunkUOXOYZU4cjs.blocksToPages.call(void 0, splitPageTables(_chunkFNX3ZAYBcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
3459
3625
  blocks,
3460
3626
  metadata,
3461
3627
  outline: outline.length > 0 ? outline : void 0,
@@ -3473,7 +3639,7 @@ async function parsePdfDocument(buffer, options) {
3473
3639
  async function extractPdfMetadata(doc, metadata) {
3474
3640
  try {
3475
3641
  const result = await doc.getMetadata();
3476
- if (!_optionalChain([result, 'optionalAccess', _351 => _351.info])) return;
3642
+ if (!_optionalChain([result, 'optionalAccess', _369 => _369.info])) return;
3477
3643
  const info = result.info;
3478
3644
  if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
3479
3645
  if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
@@ -3489,8 +3655,8 @@ async function extractPdfMetadata(doc, metadata) {
3489
3655
  }
3490
3656
  async function isHancomPdf(doc) {
3491
3657
  try {
3492
- const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _352 => _352.info]);
3493
- 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));
3658
+ const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _370 => _370.info]);
3659
+ return [_optionalChain([info, 'optionalAccess', _371 => _371.Producer]), _optionalChain([info, 'optionalAccess', _372 => _372.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
3494
3660
  } catch (e9) {
3495
3661
  return false;
3496
3662
  }
@@ -3534,5 +3700,5 @@ function marginStamp(items) {
3534
3700
 
3535
3701
 
3536
3702
 
3537
- exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunk3FGHQWJPcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunk3FGHQWJPcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunk3FGHQWJPcjs.removeHeaderFooterBlocks;
3538
- //# sourceMappingURL=parser-HWAOPQYK.cjs.map
3703
+ exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkFNX3ZAYBcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkFNX3ZAYBcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkFNX3ZAYBcjs.removeHeaderFooterBlocks;
3704
+ //# sourceMappingURL=parser-BIJBX2D5.cjs.map