kordoc 4.15.1 → 4.15.3

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 (128) hide show
  1. package/README.md +8 -0
  2. package/dist/{-HOFQN2B6.js → -V6UUFZDG.js} +10 -10
  3. package/dist/{chunk-XTVXSZLI.js → chunk-23RP6N2G.js} +2 -2
  4. package/dist/{chunk-KTCMOJMO.js → chunk-3YDASJV2.js} +5 -5
  5. package/dist/{chunk-ZFFGEHEX.cjs → chunk-4U2UK5XN.cjs} +6 -6
  6. package/dist/chunk-4U2UK5XN.cjs.map +1 -0
  7. package/dist/{chunk-PBKVXTQG.cjs → chunk-5HHU64LY.cjs} +95 -34
  8. package/dist/chunk-5HHU64LY.cjs.map +1 -0
  9. package/dist/{chunk-R5IRAI37.js → chunk-6ONRBCZM.js} +2 -2
  10. package/dist/{chunk-K5JLJLBF.js → chunk-7J4PX2EZ.js} +2 -2
  11. package/dist/{chunk-RK5O53QZ.cjs → chunk-BP5BIALD.cjs} +3 -3
  12. package/dist/chunk-BP5BIALD.cjs.map +1 -0
  13. package/dist/{chunk-WFGECRCK.js → chunk-D2DMHJWK.js} +2 -2
  14. package/dist/{chunk-AMLVAG2D.js → chunk-DLXP2KTO.js} +2 -2
  15. package/dist/chunk-EKYI3Z6M.cjs.map +1 -1
  16. package/dist/{chunk-XZDCCPXJ.js → chunk-GC5RACQO.js} +2 -2
  17. package/dist/{chunk-EZO64OIB.js → chunk-HMNXCVFN.js} +9 -9
  18. package/dist/{chunk-IKYSR5DO.js → chunk-I75K4WCK.js} +2 -2
  19. package/dist/{chunk-I6DJPTUG.js → chunk-IUUFAJAQ.js} +2 -2
  20. package/dist/chunk-J55UQC5H.cjs.map +1 -1
  21. package/dist/{chunk-WN7TX63H.js → chunk-JZUY3KFB.js} +70 -9
  22. package/dist/chunk-JZUY3KFB.js.map +1 -0
  23. package/dist/{chunk-MZWXRAHL.cjs → chunk-KANKOFGS.cjs} +6 -6
  24. package/dist/chunk-KANKOFGS.cjs.map +1 -0
  25. package/dist/{chunk-E24LPQP7.js → chunk-LRZ4WVXO.js} +2 -2
  26. package/dist/{chunk-AMYZJ25W.cjs → chunk-NJGA67VC.cjs} +2 -2
  27. package/dist/chunk-NJGA67VC.cjs.map +1 -0
  28. package/dist/{chunk-NCSC7WHQ.js → chunk-NKVLVONL.js} +3 -3
  29. package/dist/{chunk-TSRZ2QYT.js → chunk-NRDQPS77.js} +3 -3
  30. package/dist/{chunk-CAVXZLCQ.js → chunk-PE73XWRU.js} +2 -2
  31. package/dist/chunk-PY2M7YVN.cjs.map +1 -1
  32. package/dist/{chunk-5NU3ENDC.js → chunk-TT5SRAFO.js} +2 -2
  33. package/dist/{chunk-STC2OLKL.js → chunk-TVCW6NUJ.js} +3 -3
  34. package/dist/{chunk-IGVDBC3T.js → chunk-XFTJLW36.js} +70 -9
  35. package/dist/chunk-XFTJLW36.js.map +1 -0
  36. package/dist/{chunk-V25RXRBG.js → chunk-Y3TAEI7A.js} +2 -2
  37. package/dist/{chunk-NTNZGLKD.js → chunk-YNIK3EYN.js} +2 -2
  38. package/dist/chunks-EPNQ264U.js +10 -0
  39. package/dist/cli.js +25 -25
  40. package/dist/{formula-X32XVHDP.js → formula-2YW2PQJE.js} +3 -3
  41. package/dist/{formula-GNI3H5DK.cjs → formula-5NGEGKVP.cjs} +9 -9
  42. package/dist/formula-5NGEGKVP.cjs.map +1 -0
  43. package/dist/{formula-UU7MMWPQ.js → formula-72V7KDJN.js} +4 -4
  44. package/dist/{image-ocr-L3762E4X.js → image-ocr-25AQGYOM.js} +7 -7
  45. package/dist/{image-ocr-D2FGNPSN.js → image-ocr-WUIUC3YR.js} +5 -5
  46. package/dist/{image-ocr-6FFSJ453.cjs → image-ocr-Z4JMGF6G.cjs} +13 -13
  47. package/dist/image-ocr-Z4JMGF6G.cjs.map +1 -0
  48. package/dist/index.cjs +230 -230
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.js +4 -4
  51. package/dist/mcp.js +21 -21
  52. package/dist/{model-bundle-NCHSUEEK.js → model-bundle-4QPUNHTB.js} +5 -5
  53. package/dist/{models-LD35H2GR.js → models-XRV2MHKI.js} +5 -5
  54. package/dist/page-range-XPJTQHZK.cjs.map +1 -1
  55. package/dist/{parser-ZX2DXJXE.js → parser-DQOZBSD6.js} +24 -7
  56. package/dist/parser-DQOZBSD6.js.map +1 -0
  57. package/dist/{parser-3Q4NKZA5.js → parser-IPYUQBOK.js} +25 -8
  58. package/dist/parser-IPYUQBOK.js.map +1 -0
  59. package/dist/{parser-UK5ITZUH.cjs → parser-WRNYM56K.cjs} +101 -84
  60. package/dist/parser-WRNYM56K.cjs.map +1 -0
  61. package/dist/pdf-ocr-6IUPUV2V.js +18 -0
  62. package/dist/pdf-ocr-O67H6KNE.cjs +16 -0
  63. package/dist/pdf-ocr-O67H6KNE.cjs.map +1 -0
  64. package/dist/pdf-ocr-RY7BICID.js +15 -0
  65. package/dist/{profile-io-P2PX5RMA.js → profile-io-CNM44RRV.js} +3 -3
  66. package/dist/{rasterize-XR6C6XXA.js → rasterize-XGRABZQD.js} +3 -3
  67. package/dist/{redact-doc-UCLPLJTY.js → redact-doc-DXJN6W4K.js} +10 -10
  68. package/dist/{render-GDKZFZRO.js → render-JYZCUX5R.js} +6 -6
  69. package/dist/seal-3SZWLZIQ.js +10 -0
  70. package/dist/{setup-D726M3LY.js → setup-NCFO2A5K.js} +3 -3
  71. package/dist/visual-WGB7QAII.js +20 -0
  72. package/dist/{watch-D4INCK6G.js → watch-S4T6ZG32.js} +11 -11
  73. package/package.json +1 -1
  74. package/dist/chunk-AMYZJ25W.cjs.map +0 -1
  75. package/dist/chunk-IGVDBC3T.js.map +0 -1
  76. package/dist/chunk-MZWXRAHL.cjs.map +0 -1
  77. package/dist/chunk-PBKVXTQG.cjs.map +0 -1
  78. package/dist/chunk-RK5O53QZ.cjs.map +0 -1
  79. package/dist/chunk-WN7TX63H.js.map +0 -1
  80. package/dist/chunk-ZFFGEHEX.cjs.map +0 -1
  81. package/dist/chunks-7BPHK374.js +0 -10
  82. package/dist/formula-GNI3H5DK.cjs.map +0 -1
  83. package/dist/image-ocr-6FFSJ453.cjs.map +0 -1
  84. package/dist/parser-3Q4NKZA5.js.map +0 -1
  85. package/dist/parser-UK5ITZUH.cjs.map +0 -1
  86. package/dist/parser-ZX2DXJXE.js.map +0 -1
  87. package/dist/pdf-ocr-DDAR6KEC.js +0 -18
  88. package/dist/pdf-ocr-OMLFE4MQ.js +0 -15
  89. package/dist/pdf-ocr-YMPMO4VB.cjs +0 -16
  90. package/dist/pdf-ocr-YMPMO4VB.cjs.map +0 -1
  91. package/dist/seal-IYAANGGT.js +0 -10
  92. package/dist/visual-QTIWR7TC.js +0 -20
  93. /package/dist/{-HOFQN2B6.js.map → -V6UUFZDG.js.map} +0 -0
  94. /package/dist/{chunk-XTVXSZLI.js.map → chunk-23RP6N2G.js.map} +0 -0
  95. /package/dist/{chunk-KTCMOJMO.js.map → chunk-3YDASJV2.js.map} +0 -0
  96. /package/dist/{chunk-R5IRAI37.js.map → chunk-6ONRBCZM.js.map} +0 -0
  97. /package/dist/{chunk-K5JLJLBF.js.map → chunk-7J4PX2EZ.js.map} +0 -0
  98. /package/dist/{chunk-WFGECRCK.js.map → chunk-D2DMHJWK.js.map} +0 -0
  99. /package/dist/{chunk-AMLVAG2D.js.map → chunk-DLXP2KTO.js.map} +0 -0
  100. /package/dist/{chunk-XZDCCPXJ.js.map → chunk-GC5RACQO.js.map} +0 -0
  101. /package/dist/{chunk-EZO64OIB.js.map → chunk-HMNXCVFN.js.map} +0 -0
  102. /package/dist/{chunk-IKYSR5DO.js.map → chunk-I75K4WCK.js.map} +0 -0
  103. /package/dist/{chunk-I6DJPTUG.js.map → chunk-IUUFAJAQ.js.map} +0 -0
  104. /package/dist/{chunk-E24LPQP7.js.map → chunk-LRZ4WVXO.js.map} +0 -0
  105. /package/dist/{chunk-NCSC7WHQ.js.map → chunk-NKVLVONL.js.map} +0 -0
  106. /package/dist/{chunk-TSRZ2QYT.js.map → chunk-NRDQPS77.js.map} +0 -0
  107. /package/dist/{chunk-CAVXZLCQ.js.map → chunk-PE73XWRU.js.map} +0 -0
  108. /package/dist/{chunk-5NU3ENDC.js.map → chunk-TT5SRAFO.js.map} +0 -0
  109. /package/dist/{chunk-STC2OLKL.js.map → chunk-TVCW6NUJ.js.map} +0 -0
  110. /package/dist/{chunk-V25RXRBG.js.map → chunk-Y3TAEI7A.js.map} +0 -0
  111. /package/dist/{chunk-NTNZGLKD.js.map → chunk-YNIK3EYN.js.map} +0 -0
  112. /package/dist/{chunks-7BPHK374.js.map → chunks-EPNQ264U.js.map} +0 -0
  113. /package/dist/{formula-X32XVHDP.js.map → formula-2YW2PQJE.js.map} +0 -0
  114. /package/dist/{formula-UU7MMWPQ.js.map → formula-72V7KDJN.js.map} +0 -0
  115. /package/dist/{image-ocr-L3762E4X.js.map → image-ocr-25AQGYOM.js.map} +0 -0
  116. /package/dist/{image-ocr-D2FGNPSN.js.map → image-ocr-WUIUC3YR.js.map} +0 -0
  117. /package/dist/{model-bundle-NCHSUEEK.js.map → model-bundle-4QPUNHTB.js.map} +0 -0
  118. /package/dist/{models-LD35H2GR.js.map → models-XRV2MHKI.js.map} +0 -0
  119. /package/dist/{pdf-ocr-DDAR6KEC.js.map → pdf-ocr-6IUPUV2V.js.map} +0 -0
  120. /package/dist/{pdf-ocr-OMLFE4MQ.js.map → pdf-ocr-RY7BICID.js.map} +0 -0
  121. /package/dist/{profile-io-P2PX5RMA.js.map → profile-io-CNM44RRV.js.map} +0 -0
  122. /package/dist/{rasterize-XR6C6XXA.js.map → rasterize-XGRABZQD.js.map} +0 -0
  123. /package/dist/{redact-doc-UCLPLJTY.js.map → redact-doc-DXJN6W4K.js.map} +0 -0
  124. /package/dist/{render-GDKZFZRO.js.map → render-JYZCUX5R.js.map} +0 -0
  125. /package/dist/{seal-IYAANGGT.js.map → seal-3SZWLZIQ.js.map} +0 -0
  126. /package/dist/{setup-D726M3LY.js.map → setup-NCFO2A5K.js.map} +0 -0
  127. /package/dist/{visual-QTIWR7TC.js.map → visual-WGB7QAII.js.map} +0 -0
  128. /package/dist/{watch-D4INCK6G.js.map → watch-S4T6ZG32.js.map} +0 -0
@@ -6,7 +6,7 @@ var _chunkPY2M7YVNcjs = require('./chunk-PY2M7YVN.cjs');
6
6
 
7
7
 
8
8
 
9
- var _chunkAMYZJ25Wcjs = require('./chunk-AMYZJ25W.cjs');
9
+ var _chunkNJGA67VCcjs = require('./chunk-NJGA67VC.cjs');
10
10
 
11
11
  // src/pdf/image-regions.ts
12
12
  var _pdfmjs = require('pdfjs-dist/legacy/build/pdf.mjs');
@@ -720,10 +720,16 @@ function mergeVertices(vertices) {
720
720
  const cell = Math.max(VERTEX_MERGE_FACTOR * maxRadiusAll, 1);
721
721
  const buckets = /* @__PURE__ */ new Map();
722
722
  for (let i = 0; i < vertices.length; i++) {
723
- const key = Math.floor(vertices[i].x / cell) + "," + Math.floor(vertices[i].y / cell);
724
- const arr = buckets.get(key);
723
+ const cx = Math.floor(vertices[i].x / cell);
724
+ const cy = Math.floor(vertices[i].y / cell);
725
+ let column = buckets.get(cx);
726
+ if (!column) {
727
+ column = /* @__PURE__ */ new Map();
728
+ buckets.set(cx, column);
729
+ }
730
+ const arr = column.get(cy);
725
731
  if (arr) arr.push(i);
726
- else buckets.set(key, [i]);
732
+ else column.set(cy, [i]);
727
733
  }
728
734
  const merged = [];
729
735
  const used = new Array(vertices.length).fill(false);
@@ -737,7 +743,7 @@ function mergeVertices(vertices) {
737
743
  const candidates = [];
738
744
  for (let dx = -1; dx <= 1; dx++) {
739
745
  for (let dy = -1; dy <= 1; dy++) {
740
- const arr = buckets.get(cx + dx + "," + (cy + dy));
746
+ const arr = _optionalChain([buckets, 'access', _6 => _6.get, 'call', _7 => _7(cx + dx), 'optionalAccess', _8 => _8.get, 'call', _9 => _9(cy + dy)]);
741
747
  if (!arr) continue;
742
748
  for (const j of arr) {
743
749
  if (j > i && !used[j]) candidates.push(j);
@@ -850,7 +856,7 @@ function dropShadingClipGrids(clipGrids, lineGrids, fillRects, verticals = []) {
850
856
  const area = (b) => Math.max(0, b.x2 - b.x1) * Math.max(0, b.y2 - b.y1);
851
857
  const inter = (a, b) => area({ x1: Math.max(a.x1, b.x1), y1: Math.max(a.y1, b.y1), x2: Math.min(a.x2, b.x2), y2: Math.min(a.y2, b.y2) });
852
858
  return clipGrids.filter((c) => {
853
- if (!_optionalChain([c, 'access', _6 => _6.cells, 'optionalAccess', _7 => _7.length]) || c.clipParent) return true;
859
+ if (!_optionalChain([c, 'access', _10 => _10.cells, 'optionalAccess', _11 => _11.length]) || c.clipParent) return true;
854
860
  const shaded = c.cells.every((cell) => fillRects.some((f) => near(f.x1, cell.bbox.x1) && near(f.x2, cell.bbox.x2) && near(f.y1, cell.bbox.y1) && near(f.y2, cell.bbox.y2)));
855
861
  if (!shaded) return true;
856
862
  const ruled = c.cells.every((cell) => cell.bbox.x2 >= c.bbox.x2 - SHADE_CLIP_TOL || verticals.some((v) => Math.abs(v.x1 - cell.bbox.x2) <= SHADE_CLIP_TOL * 2 && Math.min(v.y2, cell.bbox.y2) - Math.max(v.y1, cell.bbox.y1) >= (cell.bbox.y2 - cell.bbox.y1) * 0.75));
@@ -1142,10 +1148,28 @@ function buildClipCellGrids(rects, strokedH, strokedV, pageWidth, pageHeight, te
1142
1148
  const pageArea = pageWidth * pageHeight;
1143
1149
  const sameRect = (a, b) => Math.abs(a.x1 - b.x1) <= CLIP_EDGE_TOL && Math.abs(a.x2 - b.x2) <= CLIP_EDGE_TOL && Math.abs(a.y1 - b.y1) <= CLIP_EDGE_TOL && Math.abs(a.y2 - b.y2) <= CLIP_EDGE_TOL;
1144
1150
  const cells = [];
1151
+ const buckets = /* @__PURE__ */ new Map();
1145
1152
  for (const r of rects) {
1146
1153
  if (r.x2 - r.x1 < CLIP_MIN_W2 || r.y2 - r.y1 < CLIP_MIN_H2) continue;
1147
1154
  if (pageArea > 0 && (r.x2 - r.x1) * (r.y2 - r.y1) >= pageArea * CLIP_MAX_PAGE_FRAC) continue;
1148
- if (!cells.some((c) => sameRect(c, r))) cells.push(r);
1155
+ const bx = Math.floor(r.x1 / CLIP_EDGE_TOL), by = Math.floor(r.y1 / CLIP_EDGE_TOL);
1156
+ let duplicate = false;
1157
+ for (let dx = -1; dx <= 1 && !duplicate; dx++) {
1158
+ const ys2 = buckets.get(bx + dx);
1159
+ for (let dy = -1; dy <= 1 && !duplicate; dy++) {
1160
+ duplicate = _nullishCoalesce(_optionalChain([ys2, 'optionalAccess', _12 => _12.get, 'call', _13 => _13(by + dy), 'optionalAccess', _14 => _14.some, 'call', _15 => _15((c) => sameRect(c, r))]), () => ( false));
1161
+ }
1162
+ }
1163
+ if (duplicate) continue;
1164
+ cells.push(r);
1165
+ let ys = buckets.get(bx);
1166
+ if (!ys) {
1167
+ ys = /* @__PURE__ */ new Map();
1168
+ buckets.set(bx, ys);
1169
+ }
1170
+ const row = ys.get(by);
1171
+ if (row) row.push(r);
1172
+ else ys.set(by, [r]);
1149
1173
  }
1150
1174
  if (cells.length < 1) return { grids: [], containers: [], page: { lastCells: [], clips: [] } };
1151
1175
  const parent = new Array(cells.length).fill(-1);
@@ -1204,9 +1228,32 @@ function buildClipCellGrids(rects, strokedH, strokedV, pageWidth, pageHeight, te
1204
1228
  }
1205
1229
  return i;
1206
1230
  };
1231
+ const edgeBin = (v) => Math.floor(v / CLIP_ADJ_GAP);
1232
+ const startsX = /* @__PURE__ */ new Map(), endsX = /* @__PURE__ */ new Map();
1233
+ const startsY = /* @__PURE__ */ new Map(), endsY = /* @__PURE__ */ new Map();
1234
+ const addEdge = (map, v, i) => {
1235
+ const k = edgeBin(v), row = map.get(k);
1236
+ if (row) row.push(i);
1237
+ else map.set(k, [i]);
1238
+ };
1239
+ for (let i = 0; i < cells.length; i++) {
1240
+ addEdge(startsX, cells[i].x1, i);
1241
+ addEdge(endsX, cells[i].x2, i);
1242
+ addEdge(startsY, cells[i].y1, i);
1243
+ addEdge(endsY, cells[i].y2, i);
1244
+ }
1207
1245
  for (let i = 0; i < cells.length; i++) {
1208
1246
  if (tableClip[i]) continue;
1209
- for (let j = i + 1; j < cells.length; j++) {
1247
+ const candidates = /* @__PURE__ */ new Set();
1248
+ const near = (map, v) => {
1249
+ const k = edgeBin(v);
1250
+ for (let d = -1; d <= 1; d++) for (const j of _nullishCoalesce(map.get(k + d), () => ( []))) if (j > i) candidates.add(j);
1251
+ };
1252
+ near(startsX, cells[i].x2);
1253
+ near(endsX, cells[i].x1);
1254
+ near(startsY, cells[i].y2);
1255
+ near(endsY, cells[i].y1);
1256
+ for (const j of [...candidates].sort((a, b) => a - b)) {
1210
1257
  if (tableClip[j] || parent[i] !== parent[j]) continue;
1211
1258
  if (adjacent(cells[i], cells[j])) {
1212
1259
  const ra = find(i), rb = find(j);
@@ -1227,7 +1274,7 @@ function buildClipCellGrids(rects, strokedH, strokedV, pageWidth, pageHeight, te
1227
1274
  else groups.set(r, [i]);
1228
1275
  }
1229
1276
  const containers = cells.filter((_, i) => isContainer[i]);
1230
- const groupSize = (i) => _nullishCoalesce(_optionalChain([groups, 'access', _8 => _8.get, 'call', _9 => _9(find(i)), 'optionalAccess', _10 => _10.length]), () => ( 0));
1277
+ const groupSize = (i) => _nullishCoalesce(_optionalChain([groups, 'access', _16 => _16.get, 'call', _17 => _17(find(i)), 'optionalAccess', _18 => _18.length]), () => ( 0));
1231
1278
  const isGridMember = (i) => groupSize(i) >= CLIP_MIN_GROUP;
1232
1279
  const framed = (r) => edgeStroked(strokedH, "h", r.y1, r.x1, r.x2) && edgeStroked(strokedH, "h", r.y2, r.x1, r.x2) && edgeStroked(strokedV, "v", r.x1, r.y1, r.y2) && edgeStroked(strokedV, "v", r.x2, r.y1, r.y2);
1233
1280
  const titledFrame = (r) => r.y1 >= pageHeight * TITLED_FRAME_MIN_TOP && r.x2 - r.x1 >= pageWidth * TITLED_FRAME_MIN_WIDTH && textPoints.some((p) => p.y < r.y1 && p.y > pageHeight * HEADER_BAND && p.x >= r.x1 - CLIP_EDGE_TOL && p.x <= r.x2 + CLIP_EDGE_TOL) && textPoints.some((p) => p.x > r.x1 && p.x < r.x2 && p.y > r.y1 && p.y < r.y2);
@@ -1405,11 +1452,25 @@ function closeGaps(members, gaps) {
1405
1452
  } else lines.push({ ...g });
1406
1453
  }
1407
1454
  const spacing = gaps.some((g) => g.axis === "x") && gaps.some((g) => g.axis === "y");
1455
+ const repeatedBlankColumn = (l) => {
1456
+ if (spacing || l.axis !== "x" || !l.both) return false;
1457
+ const spans = gaps.filter((g) => g.axis === "x" && al(g.lo, l.lo) && al(g.hi, l.hi)).map((g) => [g.e1, g.e2]).sort((a, b) => a[0] - b[0]);
1458
+ if (spans.length < 3) return false;
1459
+ let covered = 0, end = -Infinity, distinct = 0;
1460
+ for (const [lo, hi] of spans) {
1461
+ if (hi <= end + CLIP_COORD_TOL) continue;
1462
+ covered += hi - Math.max(lo, end);
1463
+ end = hi;
1464
+ distinct++;
1465
+ }
1466
+ const height = Math.max(...members.map((r) => r.y2)) - Math.min(...members.map((r) => r.y1));
1467
+ return distinct >= 3 && covered >= height * 0.65;
1468
+ };
1408
1469
  const out = members.map((r) => ({ ...r }));
1409
1470
  for (const l of lines) {
1410
1471
  const shared = (p) => members.some((u) => members.some((v) => u !== v && (l.axis === "y" ? Math.abs(u.y1 - v.y2) <= CLIP_ADJ_GAP && al(u.y1, p) && overlap(u.x1, u.x2, v.x1, v.x2) > CLIP_EDGE_TOL : Math.abs(u.x2 - v.x1) <= CLIP_ADJ_GAP && al(u.x2, p) && overlap(u.y1, u.y2, v.y1, v.y2) > CLIP_EDGE_TOL)));
1411
1472
  const atLo = shared(l.lo), atHi = shared(l.hi);
1412
- if (l.both && !spacing && !atLo && !atHi) continue;
1473
+ if (repeatedBlankColumn(l) && !atLo && !atHi) continue;
1413
1474
  const to = atLo && !atHi ? l.lo : atHi && !atLo ? l.hi : l.to;
1414
1475
  const onEdge = (r) => l.axis === "y" ? al(r.y2, l.lo) || al(r.y1, l.hi) : al(r.x2, l.lo) || al(r.x1, l.hi);
1415
1476
  const span = (r) => l.axis === "y" ? [r.x1, r.x2] : [r.y1, r.y2];
@@ -1644,7 +1705,7 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
1644
1705
  const n = left.length;
1645
1706
  if (n >= 2 && right.length >= 2) {
1646
1707
  const k1 = pairKey(left.charCodeAt(n - 2), left.charCodeAt(n - 1)), k2 = pairKey(right.charCodeAt(0), right.charCodeAt(1));
1647
- const v = decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _11 => _11.joined2, 'access', _12 => _12.get, 'call', _13 => _13(k1), 'optionalAccess', _14 => _14.get, 'call', _15 => _15(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _16 => _16.spaced2, 'access', _17 => _17.get, 'call', _18 => _18(k1), 'optionalAccess', _19 => _19.get, 'call', _20 => _20(k2)]), () => ( 0)));
1708
+ const v = decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _19 => _19.joined2, 'access', _20 => _20.get, 'call', _21 => _21(k1), 'optionalAccess', _22 => _22.get, 'call', _23 => _23(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _24 => _24.spaced2, 'access', _25 => _25.get, 'call', _26 => _26(k1), 'optionalAccess', _27 => _27.get, 'call', _28 => _28(k2)]), () => ( 0)));
1648
1709
  if (v !== null) return v;
1649
1710
  }
1650
1711
  if (n && right.length) {
@@ -1715,7 +1776,7 @@ function wrapJoiner(prevText, nextText, lex) {
1715
1776
  if (endsAsWord(left)) return " ";
1716
1777
  if (/[·ㆍ‧-]/.test(a) && !/[·ㆍ‧…]{2}$/.test(prev) && /[가-힣A-Za-z0-9]/.test(b)) return "";
1717
1778
  if (/[A-Za-z]/.test(a) && /[A-Za-z]/.test(b) || /\d/.test(a) && /\d/.test(b)) return " ";
1718
- const ev = _optionalChain([lex, 'optionalAccess', _21 => _21.evidence, 'call', _22 => _22(left, right)]);
1779
+ const ev = _optionalChain([lex, 'optionalAccess', _29 => _29.evidence, 'call', _30 => _30(left, right)]);
1719
1780
  if (ev != null) return ev;
1720
1781
  if (lex && /[가-힣A-Za-z0-9]$/.test(left) && /^[가-힣A-Za-z0-9]/.test(right) && lex.joinedWord(left, right.replace(/[.,)」』’”;:]+$/, ""))) return "";
1721
1782
  if (/\d$/.test(left) && COUNTER.test(right)) return "";
@@ -1737,7 +1798,7 @@ function joinPageBreakWraps(blocks, lex) {
1737
1798
  if (a.type !== "paragraph" && a.type !== "list" || b.type !== "paragraph") continue;
1738
1799
  const last = a.bbox && PARA_LAST_LINE.get(a.bbox), fs = last ? last.fontSize : 0;
1739
1800
  if (!last || fs <= 0 || (_nullishCoalesce(pageRight.get(a.pageNumber), () => ( Infinity))) - last.right >= BODY_FULL_TOL * fs) continue;
1740
- if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _23 => _23.style, 'optionalAccess', _24 => _24.fontSize]), () => ( 0))) - fs) > 0.15 * fs) continue;
1801
+ if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _31 => _31.style, 'optionalAccess', _32 => _32.fontSize]), () => ( 0))) - fs) > 0.15 * fs) continue;
1741
1802
  if (startsNewItem(a.text, b.text)) continue;
1742
1803
  a.text += wrapJoiner(a.text, b.text, lex) + b.text;
1743
1804
  const bl = b.bbox && PARA_LAST_LINE.get(b.bbox);
@@ -2215,7 +2276,7 @@ function dominantStyle(items) {
2215
2276
  }
2216
2277
  }
2217
2278
  if (dominantSize === 0) return void 0;
2218
- const fontName = _optionalChain([items, 'access', _25 => _25.find, 'call', _26 => _26((i) => i.fontSize === dominantSize), 'optionalAccess', _27 => _27.fontName]) || void 0;
2279
+ const fontName = _optionalChain([items, 'access', _33 => _33.find, 'call', _34 => _34((i) => i.fontSize === dominantSize), 'optionalAccess', _35 => _35.fontName]) || void 0;
2219
2280
  return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
2220
2281
  }
2221
2282
  function normalizeItems(rawItems) {
@@ -2324,7 +2385,7 @@ function splitAroundOverlays(c, overlays) {
2324
2385
  const ov = overlays.filter((o) => {
2325
2386
  for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
2326
2387
  const prefix = c.text.slice(0, at);
2327
- const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _28 => _28.match, 'call', _29 => _29(/\s+/g), 'optionalAccess', _30 => _30.length]), () => ( 0))) * ws;
2388
+ const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _36 => _36.match, 'call', _37 => _37(/\s+/g), 'optionalAccess', _38 => _38.length]), () => ( 0))) * ws;
2328
2389
  if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
2329
2390
  }
2330
2391
  return true;
@@ -2437,7 +2498,7 @@ function mergeSuperscriptLines(lines) {
2437
2498
  return result;
2438
2499
  }
2439
2500
  function mergeLineSimple(items) {
2440
- if (items.length <= 1) return _optionalChain([items, 'access', _31 => _31[0], 'optionalAccess', _32 => _32.text]) || "";
2501
+ if (items.length <= 1) return _optionalChain([items, 'access', _39 => _39[0], 'optionalAccess', _40 => _40.text]) || "";
2441
2502
  const sorted = sortLineByX([...items]);
2442
2503
  const isEvenSpaced = detectEvenSpacedItems(sorted);
2443
2504
  let result = sorted[0].text;
@@ -2486,7 +2547,7 @@ function computeMedianFontSizeFromFreq(freq) {
2486
2547
  }
2487
2548
  function detectHeadings(blocks, medianFontSize) {
2488
2549
  for (const block of blocks) {
2489
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _33 => _33.style, 'optionalAccess', _34 => _34.fontSize])) continue;
2550
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _41 => _41.style, 'optionalAccess', _42 => _42.fontSize])) continue;
2490
2551
  const text = block.text.trim();
2491
2552
  if (text.length === 0 || text.length > 200) continue;
2492
2553
  if (/^\d+$/.test(text)) continue;
@@ -2547,7 +2608,7 @@ function detectMarkerHeadings(blocks) {
2547
2608
  block.level = 4;
2548
2609
  continue;
2549
2610
  }
2550
- if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _35 => _35.style, 'optionalAccess', _36 => _36.fontSize])) {
2611
+ if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _43 => _43.style, 'optionalAccess', _44 => _44.fontSize])) {
2551
2612
  const prev = blocks[i - 1];
2552
2613
  const next = blocks[i + 1];
2553
2614
  const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
@@ -2802,7 +2863,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings) {
2802
2863
  const bottomEntries = [];
2803
2864
  for (let bi = 0; bi < blocks.length; bi++) {
2804
2865
  const b = blocks[bi];
2805
- if (!b.bbox || !b.pageNumber || !_optionalChain([b, 'access', _37 => _37.text, 'optionalAccess', _38 => _38.trim, 'call', _39 => _39()])) continue;
2866
+ if (!b.bbox || !b.pageNumber || !_optionalChain([b, 'access', _45 => _45.text, 'optionalAccess', _46 => _46.trim, 'call', _47 => _47()])) continue;
2806
2867
  const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
2807
2868
  if (!ph) continue;
2808
2869
  const blockTop = ph - (b.bbox.y + b.bbox.height);
@@ -2825,7 +2886,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings) {
2825
2886
  }
2826
2887
  const repeatedPatterns = /* @__PURE__ */ new Set();
2827
2888
  for (const [p, count] of patternCount) {
2828
- if (count >= MIN_REPEAT && (_nullishCoalesce(_optionalChain([patternPages, 'access', _40 => _40.get, 'call', _41 => _41(p), 'optionalAccess', _42 => _42.size]), () => ( 0))) >= MIN_REPEAT) {
2889
+ if (count >= MIN_REPEAT && (_nullishCoalesce(_optionalChain([patternPages, 'access', _48 => _48.get, 'call', _49 => _49(p), 'optionalAccess', _50 => _50.size]), () => ( 0))) >= MIN_REPEAT) {
2829
2890
  repeatedPatterns.add(p);
2830
2891
  }
2831
2892
  }
@@ -2845,7 +2906,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings) {
2845
2906
  if (bi === e.blockIdx) continue;
2846
2907
  const o = blocks[bi];
2847
2908
  if (!o.bbox || o.bbox.page !== cb.page) continue;
2848
- const oNorm = _optionalChain([o, 'access', _43 => _43.text, 'optionalAccess', _44 => _44.trim, 'call', _45 => _45(), 'access', _46 => _46.replace, 'call', _47 => _47(/\d+/g, "#")]);
2909
+ const oNorm = _optionalChain([o, 'access', _51 => _51.text, 'optionalAccess', _52 => _52.trim, 'call', _53 => _53(), 'access', _54 => _54.replace, 'call', _55 => _55(/\d+/g, "#")]);
2849
2910
  if (oNorm && repeatedPatterns.has(oNorm)) continue;
2850
2911
  const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
2851
2912
  if (overlap2 >= cb.height * 0.5) {
@@ -2888,7 +2949,7 @@ function recordCellLines(cell, items) {
2888
2949
  function markImageCell(cell) {
2889
2950
  IMAGE_CELLS.add(cell);
2890
2951
  }
2891
- var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _48 => _48.text, 'optionalAccess', _49 => _49.trim, 'call', _50 => _50()]) && !_optionalChain([cell, 'access', _51 => _51.blocks, 'optionalAccess', _52 => _52.length]) && !IMAGE_CELLS.has(cell);
2952
+ var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _56 => _56.text, 'optionalAccess', _57 => _57.trim, 'call', _58 => _58()]) && !_optionalChain([cell, 'access', _59 => _59.blocks, 'optionalAccess', _60 => _60.length]) && !IMAGE_CELLS.has(cell);
2892
2953
  function trimTable(table) {
2893
2954
  let cols = table.cols;
2894
2955
  while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
@@ -2904,7 +2965,7 @@ function trimTable(table) {
2904
2965
  function trimTrailingEmptyTableCols(blocks) {
2905
2966
  for (const b of blocks) {
2906
2967
  if (b.type !== "table" || !b.table) continue;
2907
- for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _53 => _53.blocks, 'optionalAccess', _54 => _54.length])) trimTrailingEmptyTableCols(cell.blocks);
2968
+ for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _61 => _61.blocks, 'optionalAccess', _62 => _62.length])) trimTrailingEmptyTableCols(cell.blocks);
2908
2969
  trimTable(b.table);
2909
2970
  }
2910
2971
  }
@@ -2963,12 +3024,12 @@ function isTwoColumnProse(r) {
2963
3024
  if (t.rows < 8) return false;
2964
3025
  const dense = [];
2965
3026
  for (let c = 0; c < t.cols; c++) {
2966
- const filled = t.cells.filter((row) => _optionalChain([row, 'access', _55 => _55[c], 'optionalAccess', _56 => _56.text, 'access', _57 => _57.trim, 'call', _58 => _58()])).length;
3027
+ const filled = t.cells.filter((row) => _optionalChain([row, 'access', _63 => _63[c], 'optionalAccess', _64 => _64.text, 'access', _65 => _65.trim, 'call', _66 => _66()])).length;
2967
3028
  if (filled / t.rows >= 0.3) dense.push(c);
2968
3029
  }
2969
3030
  if (dense.length !== 2) return false;
2970
3031
  for (const c of dense) {
2971
- const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _59 => _59[c], 'optionalAccess', _60 => _60.text, 'access', _61 => _61.replace, 'call', _62 => _62(/\s+/g, ""), 'access', _63 => _63.length]), () => ( 0))).filter((n) => n > 0);
3032
+ const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _67 => _67[c], 'optionalAccess', _68 => _68.text, 'access', _69 => _69.replace, 'call', _70 => _70(/\s+/g, ""), 'access', _71 => _71.length]), () => ( 0))).filter((n) => n > 0);
2972
3033
  const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
2973
3034
  if (avg < 12) return false;
2974
3035
  }
@@ -3443,7 +3504,7 @@ function buildClusterTable(rows, columns, pageNum) {
3443
3504
  const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
3444
3505
  if (nonEmptyCols !== 1) continue;
3445
3506
  if (cells[r][0].text.trim() !== "") continue;
3446
- const contentText = _optionalChain([cells, 'access', _64 => _64[r], 'access', _65 => _65.find, 'call', _66 => _66((c) => c.text.trim()), 'optionalAccess', _67 => _67.text, 'access', _68 => _68.trim, 'call', _69 => _69()]) || "";
3507
+ const contentText = _optionalChain([cells, 'access', _72 => _72[r], 'access', _73 => _73.find, 'call', _74 => _74((c) => c.text.trim()), 'optionalAccess', _75 => _75.text, 'access', _76 => _76.trim, 'call', _77 => _77()]) || "";
3447
3508
  if (/^[○●▶\-·]/.test(contentText)) continue;
3448
3509
  for (let pr = r - 1; pr >= 0; pr--) {
3449
3510
  if (cells[pr].some((c) => c.text.trim())) {
@@ -3832,14 +3893,14 @@ function isProseSpread(items) {
3832
3893
  for (let i = 1; i < sorted.length; i++) {
3833
3894
  gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
3834
3895
  }
3835
- const maxGap = _chunkAMYZJ25Wcjs.safeMax.call(void 0, gaps);
3896
+ const maxGap = _chunkNJGA67VCcjs.safeMax.call(void 0, gaps);
3836
3897
  const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
3837
3898
  return maxGap < 40 && avgLen < 5;
3838
3899
  }
3839
3900
  function detectColumns(yLines) {
3840
3901
  const allItems = yLines.flat();
3841
3902
  if (allItems.length === 0) return null;
3842
- const pageWidth = _chunkAMYZJ25Wcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkAMYZJ25Wcjs.safeMin.call(void 0, allItems.map((i) => i.x));
3903
+ const pageWidth = _chunkNJGA67VCcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkNJGA67VCcjs.safeMin.call(void 0, allItems.map((i) => i.x));
3843
3904
  if (pageWidth < 100) return null;
3844
3905
  let bigoLineIdx = -1;
3845
3906
  for (let i = 0; i < yLines.length; i++) {
@@ -4167,7 +4228,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
4167
4228
  for (const line of streamLines(items)) lex.addLine(mergeLineSimple(line));
4168
4229
  const extracted = extractLines(opList.fnArray, opList.argsArray);
4169
4230
  let { horizontals, verticals } = extracted;
4170
- const prevPage = _optionalChain([carry, 'optionalAccess', _70 => _70.page]) === pageNum - 1 ? carry.clip : void 0;
4231
+ const prevPage = _optionalChain([carry, 'optionalAccess', _78 => _78.page]) === pageNum - 1 ? carry.clip : void 0;
4171
4232
  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 };
4172
4233
  if (carry) {
4173
4234
  carry.page = pageNum;
@@ -4497,7 +4558,7 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals, i
4497
4558
  if (gutterX !== null) {
4498
4559
  const gx = gutterX;
4499
4560
  const allY = remaining.map((i) => i.y);
4500
- const pageH = _chunkAMYZJ25Wcjs.safeMax.call(void 0, allY) - _chunkAMYZJ25Wcjs.safeMin.call(void 0, allY);
4561
+ const pageH = _chunkNJGA67VCcjs.safeMax.call(void 0, allY) - _chunkNJGA67VCcjs.safeMin.call(void 0, allY);
4501
4562
  const gapThreshold = Math.max(15, pageH * 0.03);
4502
4563
  const sides = [
4503
4564
  remaining.filter((i) => i.x + i.w <= gx),
@@ -4517,7 +4578,7 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals, i
4517
4578
  finalTextBlocks = detectListBlocks(textBlocks);
4518
4579
  } else {
4519
4580
  const allY = remaining.map((i) => i.y);
4520
- const pageH = _chunkAMYZJ25Wcjs.safeMax.call(void 0, allY) - _chunkAMYZJ25Wcjs.safeMin.call(void 0, allY);
4581
+ const pageH = _chunkNJGA67VCcjs.safeMax.call(void 0, allY) - _chunkNJGA67VCcjs.safeMin.call(void 0, allY);
4521
4582
  const groups = xyCutOrder(remaining, Math.max(15, pageH * 0.03));
4522
4583
  const textBlocks = [];
4523
4584
  for (const group of groups) {
@@ -4651,7 +4712,7 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
4651
4712
  const lines = yLines.map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
4652
4713
  const geo = lines.map((l) => {
4653
4714
  const b = computeBBox(l.items, pageNum);
4654
- return { text: l.text, left: b.x, right: b.x + b.width, y: l.items.reduce((s, i) => s + i.y, 0) / l.items.length, fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _71 => _71(l.items), 'optionalAccess', _72 => _72.fontSize]), () => ( 0)) };
4715
+ return { text: l.text, left: b.x, right: b.x + b.width, y: l.items.reduce((s, i) => s + i.y, 0) / l.items.length, fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _79 => _79(l.items), 'optionalAccess', _80 => _80.fontSize]), () => ( 0)) };
4655
4716
  });
4656
4717
  const joins = bodyLineJoins(geo, lex);
4657
4718
  for (let i = 0; i < lines.length; ) {
@@ -4712,7 +4773,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
4712
4773
  blocks.push({ type: "paragraph", text: tableText, pageNumber: pageNum, bbox, style: dominantStyle(items) });
4713
4774
  } else {
4714
4775
  const allY = items.map((i) => i.y);
4715
- const pageHeight = _chunkAMYZJ25Wcjs.safeMax.call(void 0, allY) - _chunkAMYZJ25Wcjs.safeMin.call(void 0, allY);
4776
+ const pageHeight = _chunkNJGA67VCcjs.safeMax.call(void 0, allY) - _chunkNJGA67VCcjs.safeMin.call(void 0, allY);
4716
4777
  const gapThreshold = Math.max(15, pageHeight * 0.03);
4717
4778
  const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold);
4718
4779
  for (const group of orderedGroups) {
@@ -4756,4 +4817,4 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
4756
4817
 
4757
4818
 
4758
4819
  exports.extractImageRegions = extractImageRegions; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.normalizeItems = normalizeItems; exports.WrapLexicon = WrapLexicon; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.CLIP_TABLES = CLIP_TABLES; exports.TABLE_COLXS = TABLE_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.trimTrailingEmptyTableCols = trimTrailingEmptyTableCols; exports.extractPageBlocksWithLines = extractPageBlocksWithLines;
4759
- //# sourceMappingURL=chunk-PBKVXTQG.cjs.map
4820
+ //# sourceMappingURL=chunk-5HHU64LY.cjs.map