kordoc 4.18.0 → 4.18.2

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 (144) hide show
  1. package/README.md +7 -6
  2. package/dist/{-DHSHP3AB.js → -I3CP33G4.js} +13 -11
  3. package/dist/{chunk-JUU2M5WI.js → chunk-4B2EXELH.js} +2 -2
  4. package/dist/{chunk-NYF7AGOX.js → chunk-6OKBTY72.js} +2 -2
  5. package/dist/{chunk-JU4DNVBP.js → chunk-B2E6C2LH.js} +27 -11
  6. package/dist/chunk-B2E6C2LH.js.map +1 -0
  7. package/dist/{chunk-UA7TQ37A.js → chunk-BL7KRE6X.js} +3 -3
  8. package/dist/{chunk-PGZX5JWZ.js → chunk-C2CVOC5K.js} +4 -4
  9. package/dist/{chunk-WSYTO525.js → chunk-CKUIFTXJ.js} +2 -2
  10. package/dist/{chunk-FPU7WPQM.js → chunk-F5HING4Y.js} +25 -9
  11. package/dist/chunk-F5HING4Y.js.map +1 -0
  12. package/dist/{chunk-VVJCQKXV.js → chunk-GM7XIZF2.js} +2 -2
  13. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  14. package/dist/{chunk-DSF64VZN.js → chunk-IA3UKDHA.js} +4 -4
  15. package/dist/chunk-IA3UKDHA.js.map +1 -0
  16. package/dist/chunk-J55UQC5H.cjs.map +1 -1
  17. package/dist/{chunk-ELTPM4HM.cjs → chunk-KDMAYOWH.cjs} +158 -43
  18. package/dist/chunk-KDMAYOWH.cjs.map +1 -0
  19. package/dist/{chunk-Q6SKAFWN.js → chunk-L5RLJPI3.js} +3 -3
  20. package/dist/{chunk-QBTYETIU.js → chunk-L64QRUMK.js} +202 -7
  21. package/dist/chunk-L64QRUMK.js.map +1 -0
  22. package/dist/{chunk-LLD4EY2F.js → chunk-LACO375L.js} +2 -2
  23. package/dist/{chunk-DT57TAEL.js → chunk-LSOD2A6N.js} +2 -2
  24. package/dist/{chunk-OLOMR452.js → chunk-M4P7YS2N.js} +395 -58
  25. package/dist/chunk-M4P7YS2N.js.map +1 -0
  26. package/dist/{chunk-5JFKSCTE.js → chunk-N5DQFA7L.js} +2 -2
  27. package/dist/{chunk-DTPALXTW.js → chunk-NZM2SSI4.js} +2 -2
  28. package/dist/{chunk-GNBQXQDK.js → chunk-O2DI4GHD.js} +2 -2
  29. package/dist/{chunk-32FQLCUJ.js → chunk-OBILAVWC.js} +2 -2
  30. package/dist/{chunk-PQZ4BDXT.js → chunk-OGAYGUJF.js} +122 -87
  31. package/dist/chunk-OGAYGUJF.js.map +1 -0
  32. package/dist/{chunk-2QBZMCRT.cjs → chunk-OI5ZSSIC.cjs} +12 -12
  33. package/dist/chunk-OI5ZSSIC.cjs.map +1 -0
  34. package/dist/{chunk-F4ESJBGU.cjs → chunk-QGFZU3JE.cjs} +31 -15
  35. package/dist/chunk-QGFZU3JE.cjs.map +1 -0
  36. package/dist/{chunk-WDJJ77HP.js → chunk-QP7IXF7R.js} +2 -2
  37. package/dist/{chunk-NKCKN4WW.js → chunk-T4MXCSBP.js} +137 -27
  38. package/dist/chunk-T4MXCSBP.js.map +1 -0
  39. package/dist/{chunk-CKMGVW6S.cjs → chunk-UZGZRGYM.cjs} +2 -2
  40. package/dist/chunk-UZGZRGYM.cjs.map +1 -0
  41. package/dist/{chunk-NIPT5FJO.js → chunk-VSY5PAJ5.js} +2 -2
  42. package/dist/{chunk-GP7BPJTU.cjs → chunk-W2YYBPW5.cjs} +3 -3
  43. package/dist/chunk-W2YYBPW5.cjs.map +1 -0
  44. package/dist/{chunk-RLVALQZI.cjs → chunk-YNLW6EGU.cjs} +3 -3
  45. package/dist/chunk-YNLW6EGU.cjs.map +1 -0
  46. package/dist/chunks-IFFRC5IQ.js +10 -0
  47. package/dist/cli.js +26 -26
  48. package/dist/{formula-6Q2SBBQ5.js → formula-AQZODKZF.js} +3 -3
  49. package/dist/{formula-M6JJBJ3O.js → formula-E3N7KDDG.js} +4 -4
  50. package/dist/{formula-43KHT3B3.cjs → formula-VY4ITOMN.cjs} +9 -9
  51. package/dist/formula-VY4ITOMN.cjs.map +1 -0
  52. package/dist/{image-ocr-22XQ4TMN.cjs → image-ocr-6LYEBMVR.cjs} +15 -15
  53. package/dist/image-ocr-6LYEBMVR.cjs.map +1 -0
  54. package/dist/{image-ocr-2FIFDA7I.js → image-ocr-IMYXOHHV.js} +6 -6
  55. package/dist/{image-ocr-TH2E6E3E.js → image-ocr-LN3GSQPW.js} +9 -9
  56. package/dist/index.cjs +1042 -603
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.d.cts +8 -6
  59. package/dist/index.d.ts +8 -6
  60. package/dist/index.js +529 -90
  61. package/dist/index.js.map +1 -1
  62. package/dist/mcp.js +26 -27
  63. package/dist/mcp.js.map +1 -1
  64. package/dist/{model-bundle-MLEDO25V.js → model-bundle-IHKNDLOT.js} +5 -5
  65. package/dist/{models-MYB5M4XC.js → models-YXITRAMR.js} +5 -5
  66. package/dist/page-range-QHHFTL7X.cjs.map +1 -1
  67. package/dist/{parser-L77S4RZC.cjs → parser-7KECZTTP.cjs} +176 -228
  68. package/dist/parser-7KECZTTP.cjs.map +1 -0
  69. package/dist/{parser-BKTX4GVM.js → parser-KB4BYQBZ.js} +14 -66
  70. package/dist/parser-KB4BYQBZ.js.map +1 -0
  71. package/dist/{parser-WW7NWTUM.js → parser-M3T2EWUN.js} +11 -63
  72. package/dist/parser-M3T2EWUN.js.map +1 -0
  73. package/dist/pdf-ocr-4S2OAHUX.js +15 -0
  74. package/dist/pdf-ocr-IGYCZ7G2.cjs +16 -0
  75. package/dist/pdf-ocr-IGYCZ7G2.cjs.map +1 -0
  76. package/dist/pdf-ocr-YEBFWU2K.js +19 -0
  77. package/dist/{profile-io-XZPNRT4U.js → profile-io-GQWQR7YQ.js} +3 -3
  78. package/dist/{rasterize-4EWPBCOJ.js → rasterize-Y6TVFQ3M.js} +3 -3
  79. package/dist/{redact-doc-YYCWBWGL.js → redact-doc-TRPZ3HNW.js} +11 -11
  80. package/dist/{render-JNMBK4WF.js → render-GHT5HKBO.js} +7 -7
  81. package/dist/seal-3YTXSABW.js +10 -0
  82. package/dist/{setup-NM5ICZ4U.js → setup-AGSCEHDB.js} +3 -3
  83. package/dist/visual-R3E35Q2K.js +20 -0
  84. package/dist/{watch-PTTCHO32.js → watch-ALSEW4GB.js} +13 -13
  85. package/dist/watch-ALSEW4GB.js.map +1 -0
  86. package/package.json +1 -1
  87. package/dist/chunk-2QBZMCRT.cjs.map +0 -1
  88. package/dist/chunk-CKMGVW6S.cjs.map +0 -1
  89. package/dist/chunk-DSF64VZN.js.map +0 -1
  90. package/dist/chunk-ELTPM4HM.cjs.map +0 -1
  91. package/dist/chunk-F4ESJBGU.cjs.map +0 -1
  92. package/dist/chunk-FPU7WPQM.js.map +0 -1
  93. package/dist/chunk-GP7BPJTU.cjs.map +0 -1
  94. package/dist/chunk-JU4DNVBP.js.map +0 -1
  95. package/dist/chunk-NKCKN4WW.js.map +0 -1
  96. package/dist/chunk-OLOMR452.js.map +0 -1
  97. package/dist/chunk-PQZ4BDXT.js.map +0 -1
  98. package/dist/chunk-QBTYETIU.js.map +0 -1
  99. package/dist/chunk-RLVALQZI.cjs.map +0 -1
  100. package/dist/chunks-WTZTE3OL.js +0 -10
  101. package/dist/formula-43KHT3B3.cjs.map +0 -1
  102. package/dist/image-ocr-22XQ4TMN.cjs.map +0 -1
  103. package/dist/parser-BKTX4GVM.js.map +0 -1
  104. package/dist/parser-L77S4RZC.cjs.map +0 -1
  105. package/dist/parser-WW7NWTUM.js.map +0 -1
  106. package/dist/pdf-ocr-IUTBPKOM.js +0 -15
  107. package/dist/pdf-ocr-RQUU3JBR.js +0 -19
  108. package/dist/pdf-ocr-ZWF6ZXLP.cjs +0 -16
  109. package/dist/pdf-ocr-ZWF6ZXLP.cjs.map +0 -1
  110. package/dist/seal-ZIVUVBLM.js +0 -10
  111. package/dist/visual-4W4RBIOA.js +0 -20
  112. package/dist/watch-PTTCHO32.js.map +0 -1
  113. /package/dist/{-DHSHP3AB.js.map → -I3CP33G4.js.map} +0 -0
  114. /package/dist/{chunk-JUU2M5WI.js.map → chunk-4B2EXELH.js.map} +0 -0
  115. /package/dist/{chunk-NYF7AGOX.js.map → chunk-6OKBTY72.js.map} +0 -0
  116. /package/dist/{chunk-UA7TQ37A.js.map → chunk-BL7KRE6X.js.map} +0 -0
  117. /package/dist/{chunk-PGZX5JWZ.js.map → chunk-C2CVOC5K.js.map} +0 -0
  118. /package/dist/{chunk-WSYTO525.js.map → chunk-CKUIFTXJ.js.map} +0 -0
  119. /package/dist/{chunk-VVJCQKXV.js.map → chunk-GM7XIZF2.js.map} +0 -0
  120. /package/dist/{chunk-Q6SKAFWN.js.map → chunk-L5RLJPI3.js.map} +0 -0
  121. /package/dist/{chunk-LLD4EY2F.js.map → chunk-LACO375L.js.map} +0 -0
  122. /package/dist/{chunk-DT57TAEL.js.map → chunk-LSOD2A6N.js.map} +0 -0
  123. /package/dist/{chunk-5JFKSCTE.js.map → chunk-N5DQFA7L.js.map} +0 -0
  124. /package/dist/{chunk-DTPALXTW.js.map → chunk-NZM2SSI4.js.map} +0 -0
  125. /package/dist/{chunk-GNBQXQDK.js.map → chunk-O2DI4GHD.js.map} +0 -0
  126. /package/dist/{chunk-32FQLCUJ.js.map → chunk-OBILAVWC.js.map} +0 -0
  127. /package/dist/{chunk-WDJJ77HP.js.map → chunk-QP7IXF7R.js.map} +0 -0
  128. /package/dist/{chunk-NIPT5FJO.js.map → chunk-VSY5PAJ5.js.map} +0 -0
  129. /package/dist/{chunks-WTZTE3OL.js.map → chunks-IFFRC5IQ.js.map} +0 -0
  130. /package/dist/{formula-6Q2SBBQ5.js.map → formula-AQZODKZF.js.map} +0 -0
  131. /package/dist/{formula-M6JJBJ3O.js.map → formula-E3N7KDDG.js.map} +0 -0
  132. /package/dist/{image-ocr-2FIFDA7I.js.map → image-ocr-IMYXOHHV.js.map} +0 -0
  133. /package/dist/{image-ocr-TH2E6E3E.js.map → image-ocr-LN3GSQPW.js.map} +0 -0
  134. /package/dist/{model-bundle-MLEDO25V.js.map → model-bundle-IHKNDLOT.js.map} +0 -0
  135. /package/dist/{models-MYB5M4XC.js.map → models-YXITRAMR.js.map} +0 -0
  136. /package/dist/{pdf-ocr-IUTBPKOM.js.map → pdf-ocr-4S2OAHUX.js.map} +0 -0
  137. /package/dist/{pdf-ocr-RQUU3JBR.js.map → pdf-ocr-YEBFWU2K.js.map} +0 -0
  138. /package/dist/{profile-io-XZPNRT4U.js.map → profile-io-GQWQR7YQ.js.map} +0 -0
  139. /package/dist/{rasterize-4EWPBCOJ.js.map → rasterize-Y6TVFQ3M.js.map} +0 -0
  140. /package/dist/{redact-doc-YYCWBWGL.js.map → redact-doc-TRPZ3HNW.js.map} +0 -0
  141. /package/dist/{render-JNMBK4WF.js.map → render-GHT5HKBO.js.map} +0 -0
  142. /package/dist/{seal-ZIVUVBLM.js.map → seal-3YTXSABW.js.map} +0 -0
  143. /package/dist/{setup-NM5ICZ4U.js.map → setup-AGSCEHDB.js.map} +0 -0
  144. /package/dist/{visual-4W4RBIOA.js.map → visual-R3E35Q2K.js.map} +0 -0
@@ -4,15 +4,15 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkF4ESJBGUcjs = require('./chunk-F4ESJBGU.cjs');
7
+ var _chunkQGFZU3JEcjs = require('./chunk-QGFZU3JE.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunkRLVALQZIcjs = require('./chunk-RLVALQZI.cjs');
11
+ var _chunkYNLW6EGUcjs = require('./chunk-YNLW6EGU.cjs');
12
12
 
13
13
 
14
14
 
15
- var _chunkCKMGVW6Scjs = require('./chunk-CKMGVW6S.cjs');
15
+ var _chunkUZGZRGYMcjs = require('./chunk-UZGZRGYM.cjs');
16
16
 
17
17
  // src/ocr/models.ts
18
18
  var _path = require('path');
@@ -40,10 +40,10 @@ var OCR_REC_DICT = {
40
40
  };
41
41
  var ALL_OCR_MODELS = [OCR_DET_MODEL, OCR_REC_MODEL, OCR_REC_DICT];
42
42
  function getOcrModelsDir() {
43
- return _chunkRLVALQZIcjs.getModelsDir.call(void 0, "ppocr");
43
+ return _chunkYNLW6EGUcjs.getModelsDir.call(void 0, "ppocr");
44
44
  }
45
45
  async function ensureOcrModels(onProgress) {
46
- return _chunkRLVALQZIcjs.ensureModelsIn.call(void 0, getOcrModelsDir(), ALL_OCR_MODELS, onProgress);
46
+ return _chunkYNLW6EGUcjs.ensureModelsIn.call(void 0, getOcrModelsDir(), ALL_OCR_MODELS, onProgress);
47
47
  }
48
48
  async function ocrModelsCached() {
49
49
  const dir = getOcrModelsDir();
@@ -2090,7 +2090,7 @@ function tagScripts(text, lines) {
2090
2090
  const [s, e, kind] = marks[m];
2091
2091
  out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
2092
2092
  }
2093
- return _chunkF4ESJBGUcjs.tidyScriptTags.call(void 0, out);
2093
+ return _chunkQGFZU3JEcjs.tidyScriptTags.call(void 0, out);
2094
2094
  }
2095
2095
 
2096
2096
  // src/pdf/line-wrap.ts
@@ -3477,7 +3477,9 @@ function findVerticalCutWithOutlierFilter(items, minGap) {
3477
3477
  const filtered = items.filter((i) => i.w >= narrowThreshold);
3478
3478
  if (filtered.length >= 2 && filtered.length < items.length && filtered.length >= items.length * 0.7) {
3479
3479
  const filteredCut = findVerticalCut(filtered);
3480
- if (filteredCut.gap > edgeCut.gap && filteredCut.gap >= minGap) {
3480
+ const sameRow = (a, b) => Math.abs(a.y - b.y) <= Math.max(a.fontSize, b.fontSize) * 0.5;
3481
+ const inLine = items.some((r) => r.w < narrowThreshold && r.x < filteredCut.position && r.x + r.w > filteredCut.position && filtered.some((o) => sameRow(o, r) && o.x + o.w <= r.x + 1) && filtered.some((o) => sameRow(o, r) && o.x >= r.x + r.w - 1));
3482
+ if (filteredCut.gap > edgeCut.gap && filteredCut.gap >= minGap && !inLine) {
3481
3483
  return filteredCut;
3482
3484
  }
3483
3485
  }
@@ -3641,9 +3643,9 @@ function detectHeadings(blocks, medianFontSize) {
3641
3643
  if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
3642
3644
  const ratio = block.style.fontSize / medianFontSize;
3643
3645
  let level = 0;
3644
- if (ratio >= _chunkF4ESJBGUcjs.HEADING_RATIO_H1) level = 1;
3645
- else if (ratio >= _chunkF4ESJBGUcjs.HEADING_RATIO_H2) level = 2;
3646
- else if (ratio >= _chunkF4ESJBGUcjs.HEADING_RATIO_H3) level = 3;
3646
+ if (ratio >= _chunkQGFZU3JEcjs.HEADING_RATIO_H1) level = 1;
3647
+ else if (ratio >= _chunkQGFZU3JEcjs.HEADING_RATIO_H2) level = 2;
3648
+ else if (ratio >= _chunkQGFZU3JEcjs.HEADING_RATIO_H3) level = 3;
3647
3649
  if (level > 0) {
3648
3650
  block.type = "heading";
3649
3651
  block.level = level;
@@ -3656,7 +3658,7 @@ function isChapterNumber(block, next, medianFontSize) {
3656
3658
  const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _94 => _94.style, 'optionalAccess', _95 => _95.fontSize]), () => ( 0));
3657
3659
  const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _96 => _96.text, 'optionalAccess', _97 => _97.trim, 'call', _98 => _98()]), () => ( ""));
3658
3660
  const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _99 => _99.bbox]);
3659
- return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _100 => _100.text, 'optionalAccess', _101 => _101.trim, 'call', _102 => _102()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkF4ESJBGUcjs.HEADING_RATIO_H1 && text.length > 0 && text.length <= 80 && !/^[\d\s.]+$/.test(text) && !!a && !!b && a.y > b.y && a.y - (b.y + b.height) <= size * 2;
3661
+ return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _100 => _100.text, 'optionalAccess', _101 => _101.trim, 'call', _102 => _102()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkQGFZU3JEcjs.HEADING_RATIO_H1 && text.length > 0 && text.length <= 80 && !/^[\d\s.]+$/.test(text) && !!a && !!b && a.y > b.y && a.y - (b.y + b.height) <= size * 2;
3660
3662
  }
3661
3663
  function mergeStackedHeadingLines(blocks, medianFontSize) {
3662
3664
  for (let i = 0; i < blocks.length - 1; ) {
@@ -4197,7 +4199,7 @@ function detectSpecialKoreanTables(blocks) {
4197
4199
  }
4198
4200
  function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables = false) {
4199
4201
  const ZONE_RATIO = 0.12;
4200
- const MIN_REPEAT = 3;
4202
+ const MIN_REPEAT2 = 3;
4201
4203
  const topEntries = [];
4202
4204
  const bottomEntries = [];
4203
4205
  for (let bi = 0; bi < blocks.length; bi++) {
@@ -4234,7 +4236,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
4234
4236
  const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
4235
4237
  const span = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
4236
4238
  const pageNumbered = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _224 => _224.get, 'call', _225 => _225(p), 'optionalAccess', _226 => _226.size]), () => ( 0))) > 1;
4237
- if (count >= MIN_REPEAT && pages.length >= MIN_REPEAT && (pages.length >= span * 0.4 || pageNumbered)) {
4239
+ if (count >= MIN_REPEAT2 && pages.length >= MIN_REPEAT2 && (pages.length >= span * 0.4 || pageNumbered)) {
4238
4240
  repeatedPatterns.add(p);
4239
4241
  }
4240
4242
  }
@@ -4382,6 +4384,78 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
4382
4384
  return merged;
4383
4385
  }
4384
4386
 
4387
+ // src/pdf/side-tabs.ts
4388
+ var BAND = 0.12;
4389
+ var MAX_CHARS = 10;
4390
+ var MIN_REPEAT = 3;
4391
+ var RUN_GAP = 5;
4392
+ var TAB_CELL_CHARS = 24;
4393
+ var TAB_MIN_HEIGHT = 0.3;
4394
+ var SIDE_TAB_TABLES = /* @__PURE__ */ new WeakSet();
4395
+ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
4396
+ if (table.cols !== 1 || box.x2 - box.x1 > pageWidth * BAND || box.y2 - box.y1 < pageHeight * TAB_MIN_HEIGHT) return false;
4397
+ const side = box.x1 >= pageWidth * (1 - BAND) ? "R" : box.x2 <= pageWidth * BAND ? "L" : null;
4398
+ if (!side) return false;
4399
+ const texts = table.cells.flat().map((c) => c.text.replace(/\s+/g, ""));
4400
+ if (!texts.some(Boolean) || texts.some((t) => [...t].length > TAB_CELL_CHARS)) return false;
4401
+ return others.every((it) => it.y < box.y1 || it.y > box.y2 || (side === "R" ? it.x + it.w <= box.x1 + 1 : it.x >= box.x2 - 1));
4402
+ }
4403
+ function removeSideTabs(blocks, pageWidths) {
4404
+ const edges = /* @__PURE__ */ new Map();
4405
+ for (const b of blocks) {
4406
+ if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _250 => _250.text, 'optionalAccess', _251 => _251.trim, 'call', _252 => _252()]), () => ( ""))].length <= MAX_CHARS) continue;
4407
+ const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
4408
+ e.lefts.push(b.bbox.x);
4409
+ e.rights.push(b.bbox.x + b.bbox.width);
4410
+ edges.set(b.pageNumber, e);
4411
+ }
4412
+ const q = (xs, p) => {
4413
+ const v = [...xs].sort((a, b) => a - b);
4414
+ return v[Math.min(v.length - 1, Math.floor(p * v.length))];
4415
+ };
4416
+ const body = /* @__PURE__ */ new Map();
4417
+ for (const [page, e] of edges) body.set(page, { left: q(e.lefts, 0.2), right: q(e.rights, 0.8) });
4418
+ const all = [...body.values()];
4419
+ const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
4420
+ const key = (b) => {
4421
+ const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
4422
+ const text = _optionalChain([b, 'access', _253 => _253.text, 'optionalAccess', _254 => _254.trim, 'call', _255 => _255()]);
4423
+ const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
4424
+ if (b.type === "table") {
4425
+ if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
4426
+ return `${b.bbox.x >= w * (1 - BAND) ? "R" : "L"}${Math.round(b.bbox.x / 8)}`;
4427
+ }
4428
+ if (!w || !area || !b.bbox || !text || [...text].length > MAX_CHARS) return null;
4429
+ const side = b.bbox.x + b.bbox.width <= Math.min(w * BAND, area.left - 1) ? "L" : b.bbox.x >= Math.max(w * (1 - BAND), area.right + 1) ? "R" : null;
4430
+ return side && text.replace(/\s+/g, "");
4431
+ };
4432
+ const pages = /* @__PURE__ */ new Map();
4433
+ for (const b of blocks) {
4434
+ const k = key(b);
4435
+ if (k) pages.set(k, (_nullishCoalesce(pages.get(k), () => ( /* @__PURE__ */ new Set()))).add(b.pageNumber));
4436
+ }
4437
+ const running = /* @__PURE__ */ new Set();
4438
+ for (const [k, ps] of pages) {
4439
+ const list = [...ps].sort((a, b) => a - b);
4440
+ const steps = list.slice(1).map((p, i) => p - list[i]).sort((a, b) => a - b);
4441
+ const gap = Math.max(RUN_GAP, (_nullishCoalesce(steps[steps.length >> 1], () => ( 1))) * 3);
4442
+ let run = [];
4443
+ const flush = () => {
4444
+ if (run.length >= MIN_REPEAT && run.length >= (run[run.length - 1] - run[0] + 1) * 0.4) for (const p of run) running.add(`${p}\0${k}`);
4445
+ run = [];
4446
+ };
4447
+ for (const p of list) {
4448
+ if (run.length && p - run[run.length - 1] > gap) flush();
4449
+ run.push(p);
4450
+ }
4451
+ flush();
4452
+ }
4453
+ return running.size ? blocks.filter((b) => {
4454
+ const k = key(b);
4455
+ return !k || !running.has(`${b.pageNumber}\0${k}`);
4456
+ }) : blocks;
4457
+ }
4458
+
4385
4459
  // src/pdf/table-roles.ts
4386
4460
  var TOC_BLOCKS = /* @__PURE__ */ new WeakSet();
4387
4461
  var PAGE_LABEL = /^(?:\d{1,4}|[ivxlc]{1,7})$/i;
@@ -4432,7 +4506,7 @@ function isProseTable(table) {
4432
4506
  if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
4433
4507
  for (let c = 0; c < table.cols; c++) {
4434
4508
  const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
4435
- if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _250 => _250.match, 'call', _251 => _251(/\p{L}/gu), 'optionalAccess', _252 => _252.length]), () => ( 0))) >= 2)) return false;
4509
+ if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _256 => _256.match, 'call', _257 => _257(/\p{L}/gu), 'optionalAccess', _258 => _258.length]), () => ( 0))) >= 2)) return false;
4436
4510
  }
4437
4511
  return true;
4438
4512
  }
@@ -4459,7 +4533,7 @@ function isChartTable(table) {
4459
4533
  const numeric = texts.filter((text) => NUMERIC_CELL.test(text)).length;
4460
4534
  if (numeric < texts.length * 0.5) return false;
4461
4535
  for (let c = 0; c < table.cols; c++) {
4462
- const ticks = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _253 => _253[c], 'optionalAccess', _254 => _254.text]), () => ( ""))).split(/\s+/)).filter((token) => /^-?[\d,]+(?:\.\d+)?%?$/.test(token)).map((token) => Number(token.replace(/[,%]/g, "")));
4536
+ const ticks = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _259 => _259[c], 'optionalAccess', _260 => _260.text]), () => ( ""))).split(/\s+/)).filter((token) => /^-?[\d,]+(?:\.\d+)?%?$/.test(token)).map((token) => Number(token.replace(/[,%]/g, "")));
4463
4537
  if (hasValueAxis(ticks)) return true;
4464
4538
  }
4465
4539
  const values = texts.filter((text) => text.split(/\s+/).every((token) => /^[-−–]?[\d,]*\.?\d+%?$/.test(token))).length;
@@ -4488,6 +4562,8 @@ var MIN_GAP_FACTOR = 2;
4488
4562
  var MIN_GAP_ABSOLUTE = 20;
4489
4563
  var MIN_COL_FILL_RATIO = 0.4;
4490
4564
  function detectClusterTables(items, pageNum, rejected) {
4565
+ const tab = sideTabGlyphs(items);
4566
+ if (tab.size) items = items.filter((i) => !tab.has(i));
4491
4567
  if (items.length < MIN_ROWS * MIN_COLS) return [];
4492
4568
  const { merged, originMap } = mergeEvenSpacedClusters(items);
4493
4569
  const rows = mergeOverlappingRows(groupByBaseline(merged));
@@ -4547,6 +4623,34 @@ function detectClusterTables(items, pageNum, rejected) {
4547
4623
  return !prose;
4548
4624
  });
4549
4625
  }
4626
+ var SIDE_TAB_MIN = 6;
4627
+ function sideTabGlyphs(items) {
4628
+ const found = /* @__PURE__ */ new Set();
4629
+ const singles = items.filter((i) => i.fontSize > 0 && [...i.text.trim()].length === 1);
4630
+ if (singles.length < SIDE_TAB_MIN) return found;
4631
+ const cols = [];
4632
+ for (const it of [...singles].sort((a, b) => a.x - b.x)) {
4633
+ const c = cols.find((col) => Math.abs(col[0].x - it.x) <= Math.max(1.5, it.fontSize * 0.25));
4634
+ if (c) c.push(it);
4635
+ else cols.push([it]);
4636
+ }
4637
+ for (const col of cols) {
4638
+ if (col.length < SIDE_TAB_MIN) continue;
4639
+ col.sort((a, b) => b.y - a.y);
4640
+ const fs = [...col.map((i) => i.fontSize)].sort((a, b) => a - b)[col.length >> 1];
4641
+ if (col.slice(1).some((it, k) => col[k].y - it.y > fs * 3)) continue;
4642
+ const members = new Set(col);
4643
+ const top = col[0].y + fs, bottom = col[col.length - 1].y - fs;
4644
+ const others = items.filter((i) => !members.has(i) && i.y <= top && i.y >= bottom);
4645
+ const left = Math.min(...col.map((i) => i.x)), right = Math.max(...col.map((i) => i.x + i.w));
4646
+ const outside = others.every((i) => i.x >= right + fs) || others.every((i) => i.x + i.w <= left - fs);
4647
+ if (!outside) continue;
4648
+ const alone = col.filter((g) => !others.some((i) => Math.abs(i.y - g.y) <= Y_TOL)).length;
4649
+ if (alone < col.length * 0.4) continue;
4650
+ for (const g of col) found.add(g);
4651
+ }
4652
+ return found;
4653
+ }
4550
4654
  function detectCompactStatisticalTables(rows, pageNum) {
4551
4655
  const found = [];
4552
4656
  const parts = /* @__PURE__ */ new Map();
@@ -4613,7 +4717,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
4613
4717
  continue;
4614
4718
  }
4615
4719
  const top = rows[i - 1];
4616
- const title = _optionalChain([top, 'optionalAccess', _255 => _255.items, 'access', _256 => _256.length]) === 1 && Math.abs(top.items[0].x - first[0].x) <= 5 && top.items[0].text.length <= 65 && top.y - first[0].y <= Math.max(24, first[0].fontSize * 2.8) ? top : void 0;
4720
+ const title = _optionalChain([top, 'optionalAccess', _261 => _261.items, 'access', _262 => _262.length]) === 1 && Math.abs(top.items[0].x - first[0].x) <= 5 && top.items[0].text.length <= 65 && top.y - first[0].y <= Math.max(24, first[0].fontSize * 2.8) ? top : void 0;
4617
4721
  const tableRows = title ? [title, ...body] : body;
4618
4722
  const cells = tableRows.map((row, idx) => {
4619
4723
  if (title && idx === 0) return [{ text: row.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }];
@@ -4669,12 +4773,12 @@ function isTwoColumnProse(r) {
4669
4773
  if (t.rows < 8) return false;
4670
4774
  const dense = [];
4671
4775
  for (let c = 0; c < t.cols; c++) {
4672
- const filled = t.cells.filter((row) => _optionalChain([row, 'access', _257 => _257[c], 'optionalAccess', _258 => _258.text, 'access', _259 => _259.trim, 'call', _260 => _260()])).length;
4776
+ const filled = t.cells.filter((row) => _optionalChain([row, 'access', _263 => _263[c], 'optionalAccess', _264 => _264.text, 'access', _265 => _265.trim, 'call', _266 => _266()])).length;
4673
4777
  if (filled / t.rows >= 0.3) dense.push(c);
4674
4778
  }
4675
4779
  if (dense.length !== 2) return false;
4676
4780
  for (const c of dense) {
4677
- const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _261 => _261[c], 'optionalAccess', _262 => _262.text, 'access', _263 => _263.replace, 'call', _264 => _264(/\s+/g, ""), 'access', _265 => _265.length]), () => ( 0))).filter((n) => n > 0);
4781
+ const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _267 => _267[c], 'optionalAccess', _268 => _268.text, 'access', _269 => _269.replace, 'call', _270 => _270(/\s+/g, ""), 'access', _271 => _271.length]), () => ( 0))).filter((n) => n > 0);
4678
4782
  const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
4679
4783
  if (avg < 12) return false;
4680
4784
  }
@@ -5070,7 +5174,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
5070
5174
  const runs = [];
5071
5175
  for (const it of sorted) {
5072
5176
  const last = runs[runs.length - 1];
5073
- const prev = _optionalChain([last, 'optionalAccess', _266 => _266[last.length - 1]]);
5177
+ const prev = _optionalChain([last, 'optionalAccess', _272 => _272[last.length - 1]]);
5074
5178
  if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
5075
5179
  else runs.push([it]);
5076
5180
  }
@@ -5144,7 +5248,7 @@ function buildClusterTable(rows, columns, pageNum) {
5144
5248
  () => Array.from({ length: numCols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }))
5145
5249
  );
5146
5250
  const usedItems = /* @__PURE__ */ new Set();
5147
- const headFaces = new Set(_optionalChain([rows, 'access', _267 => _267[0], 'optionalAccess', _268 => _268.items, 'access', _269 => _269.map, 'call', _270 => _270((i) => i.fontName)]));
5251
+ const headFaces = new Set(_optionalChain([rows, 'access', _273 => _273[0], 'optionalAccess', _274 => _274.items, 'access', _275 => _275.map, 'call', _276 => _276((i) => i.fontName)]));
5148
5252
  const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
5149
5253
  for (let r = 0; r < numRows; r++) {
5150
5254
  const row = rows[r];
@@ -5174,7 +5278,7 @@ function buildClusterTable(rows, columns, pageNum) {
5174
5278
  const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
5175
5279
  if (nonEmptyCols !== 1) continue;
5176
5280
  if (cells[r][0].text.trim() !== "") continue;
5177
- const contentText = _optionalChain([cells, 'access', _271 => _271[r], 'access', _272 => _272.find, 'call', _273 => _273((c) => c.text.trim()), 'optionalAccess', _274 => _274.text, 'access', _275 => _275.trim, 'call', _276 => _276()]) || "";
5281
+ const contentText = _optionalChain([cells, 'access', _277 => _277[r], 'access', _278 => _278.find, 'call', _279 => _279((c) => c.text.trim()), 'optionalAccess', _280 => _280.text, 'access', _281 => _281.trim, 'call', _282 => _282()]) || "";
5178
5282
  if (/^[○●▶\-·]/.test(contentText)) continue;
5179
5283
  for (let pr = r - 1; pr >= 0; pr--) {
5180
5284
  if (cells[pr].some((c) => c.text.trim())) {
@@ -5565,16 +5669,16 @@ function isProseSpread(items) {
5565
5669
  for (let i = 1; i < sorted.length; i++) {
5566
5670
  gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
5567
5671
  }
5568
- const maxGap = _chunkCKMGVW6Scjs.safeMax.call(void 0, gaps);
5672
+ const maxGap = _chunkUZGZRGYMcjs.safeMax.call(void 0, gaps);
5569
5673
  const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
5570
5674
  if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
5571
- const minGap = _chunkCKMGVW6Scjs.safeMin.call(void 0, gaps);
5675
+ const minGap = _chunkUZGZRGYMcjs.safeMin.call(void 0, gaps);
5572
5676
  return minGap > 0 && maxGap - minGap <= Math.max(2, maxGap * 0.15) && items.filter((i) => /^\P{L}*\p{Ll}/u.test(i.text)).length * 2 >= items.length;
5573
5677
  }
5574
5678
  function detectColumns(yLines) {
5575
5679
  const allItems = yLines.flat();
5576
5680
  if (allItems.length === 0) return null;
5577
- const pageWidth = _chunkCKMGVW6Scjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkCKMGVW6Scjs.safeMin.call(void 0, allItems.map((i) => i.x));
5681
+ const pageWidth = _chunkUZGZRGYMcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkUZGZRGYMcjs.safeMin.call(void 0, allItems.map((i) => i.x));
5578
5682
  if (pageWidth < 100) return null;
5579
5683
  let bigoLineIdx = -1;
5580
5684
  for (let i = 0; i < yLines.length; i++) {
@@ -5873,7 +5977,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
5873
5977
  if (ow <= 0) continue;
5874
5978
  const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
5875
5979
  if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
5876
- const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _277 => _277.reduce, 'call', _278 => _278((sum, item) => {
5980
+ const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _283 => _283.reduce, 'call', _284 => _284((sum, item) => {
5877
5981
  const below = item.y - o.y1;
5878
5982
  if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
5879
5983
  return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
@@ -6003,8 +6107,8 @@ function edgesOf(box, h, v, hNear = EDGE_NEAR2) {
6003
6107
  }
6004
6108
  function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
6005
6109
  if (!grids.some((g) => g.cells)) return;
6006
- const h = rules(_optionalChain([nonRules, 'optionalAccess', _279 => _279.size]) ? horizontals.filter((l) => !nonRules.has(l)) : horizontals, "h");
6007
- const v = rules(_optionalChain([nonRules, 'optionalAccess', _280 => _280.size]) ? verticals.filter((l) => !nonRules.has(l)) : verticals, "v");
6110
+ const h = rules(_optionalChain([nonRules, 'optionalAccess', _285 => _285.size]) ? horizontals.filter((l) => !nonRules.has(l)) : horizontals, "h");
6111
+ const v = rules(_optionalChain([nonRules, 'optionalAccess', _286 => _286.size]) ? verticals.filter((l) => !nonRules.has(l)) : verticals, "v");
6008
6112
  for (const g of grids) for (const c of _nullishCoalesce(g.cells, () => ( []))) {
6009
6113
  const near = c.filler ? Math.min(EDGE_NEAR2, (c.bbox.y2 - c.bbox.y1) / 3) : EDGE_NEAR2;
6010
6114
  CLIP_CELL_EDGES.set(c, edgesOf(c.bbox, h, v, near));
@@ -6012,12 +6116,12 @@ function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
6012
6116
  }
6013
6117
  function takeClipCellEdges(from, to) {
6014
6118
  const e = CLIP_CELL_EDGES.get(from);
6015
- if (e) _chunkF4ESJBGUcjs.CELL_EDGES.set(to, e);
6119
+ if (e) _chunkQGFZU3JEcjs.CELL_EDGES.set(to, e);
6016
6120
  }
6017
6121
  function joinCellEdges(a, b) {
6018
- const u = _chunkF4ESJBGUcjs.CELL_EDGES.get(a), d = _chunkF4ESJBGUcjs.CELL_EDGES.get(b);
6122
+ const u = _chunkQGFZU3JEcjs.CELL_EDGES.get(a), d = _chunkQGFZU3JEcjs.CELL_EDGES.get(b);
6019
6123
  if (!u || !d) return;
6020
- _chunkF4ESJBGUcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
6124
+ _chunkQGFZU3JEcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
6021
6125
  }
6022
6126
 
6023
6127
  // src/pdf/table-unit-row.ts
@@ -6033,12 +6137,12 @@ function rebuildUnitLine(items, grid) {
6033
6137
  function prependUnitRow(cells, cols, line, usedItems) {
6034
6138
  const text = cleanCellText(line.map((item) => item.text).join(""));
6035
6139
  cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
6036
- for (const cell of cells[0]) _chunkF4ESJBGUcjs.CELL_EDGES.set(cell, NO_EDGES);
6140
+ for (const cell of cells[0]) _chunkQGFZU3JEcjs.CELL_EDGES.set(cell, NO_EDGES);
6037
6141
  for (const item of line) usedItems.add(item);
6038
6142
  }
6039
6143
  function attachUnitRow(items, grid, cells, cols, usedItems) {
6040
6144
  const all = cells.flat();
6041
- if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _281 => _281[0], 'optionalAccess', _282 => _282[0], 'optionalAccess', _283 => _283.text]), () => ( "")))) return false;
6145
+ if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _287 => _287[0], 'optionalAccess', _288 => _288[0], 'optionalAccess', _289 => _289.text]), () => ( "")))) return false;
6042
6146
  const above = items.filter((it) => !usedItems.has(it) && it.y >= grid.bbox.y2 && it.y - grid.bbox.y2 <= 8 && it.x >= grid.bbox.x1 - 3 && it.x + it.w <= grid.bbox.x2 + 3);
6043
6147
  let nearest = Infinity;
6044
6148
  for (const it of above) nearest = Math.min(nearest, it.y);
@@ -6578,7 +6682,7 @@ function stackedTableBands(items) {
6578
6682
  const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
6579
6683
  while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
6580
6684
  if (runs.length < 2) return null;
6581
- if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _284 => _284[i + 1], 'optionalAccess', _285 => _285.start]), () => ( lines.length))))) return null;
6685
+ if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _290 => _290[i + 1], 'optionalAccess', _291 => _291.start]), () => ( lines.length))))) return null;
6582
6686
  const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
6583
6687
  const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
6584
6688
  const tail = lines.slice(runs[runs.length - 1].end);
@@ -6734,6 +6838,11 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
6734
6838
  if (carry) carry.clip = void 0;
6735
6839
  return [];
6736
6840
  }
6841
+ const tab = sideTabGlyphs(items);
6842
+ if (tab.size) {
6843
+ const glyphs = [...tab].sort((a, b) => b.y - a.y).map((g) => ({ type: "paragraph", text: g.text.trim(), pageNumber: pageNum, bbox: computeBBox([g], pageNum), style: dominantStyle([g]) }));
6844
+ return [...glyphs, ...extractPageBlocksWithLines(items.filter((i) => !tab.has(i)), pageNum, opList, pageWidth, pageHeight, extraLines, detectTables, carry, lexicon)];
6845
+ }
6737
6846
  const lex = _nullishCoalesce(lexicon, () => ( new WrapLexicon()));
6738
6847
  for (const line of streamLines(items)) lex.addLine(mergeLineSimple(line));
6739
6848
  const extracted = extractLines(opList.fnArray, opList.argsArray);
@@ -6742,7 +6851,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
6742
6851
  const filled = fillBlanks(items, horizontals, verticals);
6743
6852
  items = filled.items;
6744
6853
  horizontals = filled.horizontals;
6745
- const prevPage = _optionalChain([carry, 'optionalAccess', _286 => _286.page]) === pageNum - 1 ? carry.clip : void 0;
6854
+ const prevPage = _optionalChain([carry, 'optionalAccess', _292 => _292.page]) === pageNum - 1 ? carry.clip : void 0;
6746
6855
  const clipResult = detectTables ? buildClipCellGrids(extracted.clipRects, horizontals, verticals, pageWidth, pageHeight, items.map((it) => ({ x: it.x + it.w / 2, y: it.y + it.h / 2 })), extracted.fillRects, prevPage) : { grids: [], containers: [], page: void 0 };
6747
6856
  if (carry) {
6748
6857
  carry.page = pageNum;
@@ -7030,14 +7139,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7030
7139
  if (!assignedItems.has(textItems[ti])) usedItems.delete(tableItems[ti]);
7031
7140
  }
7032
7141
  }
7033
- if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _287 => _287[0], 'optionalAccess', _288 => _288[0], 'optionalAccess', _289 => _289.text]), () => ( "")))) {
7142
+ if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _293 => _293[0], 'optionalAccess', _294 => _294[0], 'optionalAccess', _295 => _295.text]), () => ( "")))) {
7034
7143
  prependUnitRow(finalGrid, numCols, unitLine, usedItems);
7035
7144
  finalRows++;
7036
7145
  }
7037
7146
  if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
7038
7147
  let semanticOneColumn = false;
7039
7148
  if (!grid.cells && numCols === 1 && numGridRows >= 2) {
7040
- const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _290 => _290[0], 'optionalAccess', _291 => _291.text, 'access', _292 => _292.trim, 'call', _293 => _293()]));
7149
+ const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _296 => _296[0], 'optionalAccess', _297 => _297.text, 'access', _298 => _298.trim, 'call', _299 => _299()]));
7041
7150
  if (populatedRows.length >= 4) {
7042
7151
  const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
7043
7152
  const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
@@ -7095,6 +7204,11 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7095
7204
  const emptyPart = !hasContent && !!grid.cells && !grid.clipParent && !nestedAttached;
7096
7205
  if (!hasContent && !emptyPart) continue;
7097
7206
  if (emptyPart) EMPTY_PARTS.add(irTable);
7207
+ if (numCols === 1 && isSideTabTable(grid.bbox, irTable, items.filter((it) => !tableItems.includes(it)), pageWidth, pageHeight)) {
7208
+ SIDE_TAB_TABLES.add(irTable);
7209
+ blocks.push({ type: "table", table: irTable, pageNumber: pageNum, bbox: { page: pageNum, x: grid.bbox.x1, y: grid.bbox.y1, width: gridW, height: grid.bbox.y2 - grid.bbox.y1 } });
7210
+ continue;
7211
+ }
7098
7212
  if (grid.clipParent) {
7099
7213
  const nb = { page: pageNum, x: grid.bbox.x1, y: grid.bbox.y1, width: grid.bbox.x2 - grid.bbox.x1, height: grid.bbox.y2 - grid.bbox.y1 };
7100
7214
  pendingNested.push({ parent: grid.clipParent, block: { type: "table", table: irTable, pageNumber: pageNum, bbox: nb } });
@@ -7116,7 +7230,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7116
7230
  height: grid.bbox.y2 - grid.bbox.y1
7117
7231
  };
7118
7232
  if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
7119
- const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _294 => _294[0], 'optionalAccess', _295 => _295[0], 'optionalAccess', _296 => _296.text]), () => ( ""));
7233
+ const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _300 => _300[0], 'optionalAccess', _301 => _301[0], 'optionalAccess', _302 => _302.text]), () => ( ""));
7120
7234
  const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
7121
7235
  const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
7122
7236
  const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
@@ -7170,7 +7284,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7170
7284
  const proseColumns = findTwoColumnProseCutX(clusterItems) !== null || detectPersistentColumnGutter(remaining.map((i) => ({ x: i.x, y: i.y, w: i.w, h: i.h > 0 ? i.h : i.fontSize }))) !== null;
7171
7285
  const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum)).filter((cr) => {
7172
7286
  const b = cr.bbox;
7173
- return !blocks.some((x) => x.type === "paragraph" && x.bbox && (_nullishCoalesce(_optionalChain([x, 'access', _297 => _297.text, 'optionalAccess', _298 => _298.match, 'call', _299 => _299(/\p{L}/gu), 'optionalAccess', _300 => _300.length]), () => ( 0))) >= 10 && Math.min(x.bbox.x + x.bbox.width, b.x + b.width) - Math.max(x.bbox.x, b.x) >= 0.8 * b.width && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2);
7287
+ return !blocks.some((x) => x.type === "paragraph" && x.bbox && (_nullishCoalesce(_optionalChain([x, 'access', _303 => _303.text, 'optionalAccess', _304 => _304.match, 'call', _305 => _305(/\p{L}/gu), 'optionalAccess', _306 => _306.length]), () => ( 0))) >= 10 && Math.min(x.bbox.x + x.bbox.width, b.x + b.width) - Math.max(x.bbox.x, b.x) >= 0.8 * b.width && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2);
7174
7288
  });
7175
7289
  if (clusterResults.length > 0) {
7176
7290
  const ciToIdx = /* @__PURE__ */ new Map();
@@ -7204,7 +7318,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7204
7318
  if (gutterX !== null) {
7205
7319
  const gx = gutterX;
7206
7320
  const allY = remaining.map((i) => i.y);
7207
- const pageH = _chunkCKMGVW6Scjs.safeMax.call(void 0, allY) - _chunkCKMGVW6Scjs.safeMin.call(void 0, allY);
7321
+ const pageH = _chunkUZGZRGYMcjs.safeMax.call(void 0, allY) - _chunkUZGZRGYMcjs.safeMin.call(void 0, allY);
7208
7322
  const gapThreshold = Math.max(15, pageH * 0.03);
7209
7323
  const sides = [
7210
7324
  remaining.filter((i) => i.x + i.w <= gx),
@@ -7224,7 +7338,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7224
7338
  finalTextBlocks = detectListBlocks(textBlocks);
7225
7339
  } else {
7226
7340
  const allY = remaining.map((i) => i.y);
7227
- const pageH = _chunkCKMGVW6Scjs.safeMax.call(void 0, allY) - _chunkCKMGVW6Scjs.safeMin.call(void 0, allY);
7341
+ const pageH = _chunkUZGZRGYMcjs.safeMax.call(void 0, allY) - _chunkUZGZRGYMcjs.safeMin.call(void 0, allY);
7228
7342
  const groups = xyCutOrder(remaining, Math.max(15, pageH * 0.03));
7229
7343
  const textBlocks = [];
7230
7344
  for (const group of groups) {
@@ -7543,7 +7657,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
7543
7657
  blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
7544
7658
  } else {
7545
7659
  const allY = items.map((i) => i.y);
7546
- const pageHeight = _chunkCKMGVW6Scjs.safeMax.call(void 0, allY) - _chunkCKMGVW6Scjs.safeMin.call(void 0, allY);
7660
+ const pageHeight = _chunkUZGZRGYMcjs.safeMax.call(void 0, allY) - _chunkUZGZRGYMcjs.safeMin.call(void 0, allY);
7547
7661
  const gapThreshold = Math.max(15, pageHeight * 0.03);
7548
7662
  const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold);
7549
7663
  for (const group of orderedGroups) {
@@ -7610,5 +7724,6 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
7610
7724
 
7611
7725
 
7612
7726
 
7613
- exports.OCR_DET_MODEL = OCR_DET_MODEL; exports.OCR_REC_MODEL = OCR_REC_MODEL; exports.OCR_REC_DICT = OCR_REC_DICT; exports.getOcrModelsDir = getOcrModelsDir; exports.ensureOcrModels = ensureOcrModels; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.normalizeItems = normalizeItems; exports.WrapLexicon = WrapLexicon; exports.startsNewItem = startsNewItem; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.latinSoftWrap = latinSoftWrap; exports.TOC_BLOCKS = TOC_BLOCKS; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.mergeStackedHeadingLines = mergeStackedHeadingLines; exports.detectTypographyHeadings = detectTypographyHeadings; exports.detectDocumentStyleHeadings = detectDocumentStyleHeadings; exports.detectSiblingStyleHeadings = detectSiblingStyleHeadings; exports.detectRepeatedPageLabels = detectRepeatedPageLabels; exports.detectPageLeadHeadings = detectPageLeadHeadings; exports.refineDocumentStyleHeadings = refineDocumentStyleHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.CLIP_TABLES = CLIP_TABLES; exports.TABLE_COLXS = TABLE_COLXS; exports.TABLE_ROWYS = TABLE_ROWYS; exports.TABLE_TAIL = TABLE_TAIL; exports.PART_COLXS = PART_COLXS; exports.EMPTY_PARTS = EMPTY_PARTS; exports.IMAGE_CELLS = IMAGE_CELLS; exports.FILLER_CELLS = FILLER_CELLS; exports.CONT_PARTS = CONT_PARTS; exports.CELL_LINES = CELL_LINES; exports.ROW_RULES = ROW_RULES; exports.trimTrailingEmptyTableCols = trimTrailingEmptyTableCols; exports.NO_EDGES = NO_EDGES; exports.joinCellEdges = joinCellEdges; exports.extractPageBlocksWithLines = extractPageBlocksWithLines;
7614
- //# sourceMappingURL=chunk-ELTPM4HM.cjs.map
7727
+
7728
+ exports.OCR_DET_MODEL = OCR_DET_MODEL; exports.OCR_REC_MODEL = OCR_REC_MODEL; exports.OCR_REC_DICT = OCR_REC_DICT; exports.getOcrModelsDir = getOcrModelsDir; exports.ensureOcrModels = ensureOcrModels; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.normalizeItems = normalizeItems; exports.WrapLexicon = WrapLexicon; exports.startsNewItem = startsNewItem; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.latinSoftWrap = latinSoftWrap; exports.TOC_BLOCKS = TOC_BLOCKS; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.mergeStackedHeadingLines = mergeStackedHeadingLines; exports.detectTypographyHeadings = detectTypographyHeadings; exports.detectDocumentStyleHeadings = detectDocumentStyleHeadings; exports.detectSiblingStyleHeadings = detectSiblingStyleHeadings; exports.detectRepeatedPageLabels = detectRepeatedPageLabels; exports.detectPageLeadHeadings = detectPageLeadHeadings; exports.refineDocumentStyleHeadings = refineDocumentStyleHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.CLIP_TABLES = CLIP_TABLES; exports.TABLE_COLXS = TABLE_COLXS; exports.TABLE_ROWYS = TABLE_ROWYS; exports.TABLE_TAIL = TABLE_TAIL; exports.PART_COLXS = PART_COLXS; exports.EMPTY_PARTS = EMPTY_PARTS; exports.IMAGE_CELLS = IMAGE_CELLS; exports.FILLER_CELLS = FILLER_CELLS; exports.CONT_PARTS = CONT_PARTS; exports.CELL_LINES = CELL_LINES; exports.ROW_RULES = ROW_RULES; exports.trimTrailingEmptyTableCols = trimTrailingEmptyTableCols; exports.NO_EDGES = NO_EDGES; exports.joinCellEdges = joinCellEdges; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines;
7729
+ //# sourceMappingURL=chunk-KDMAYOWH.cjs.map