kordoc 4.14.2 → 4.14.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 (151) hide show
  1. package/README.md +38 -5
  2. package/dist/{-AQKXLFIM.js → -7XBPXCXN.js} +13 -11
  3. package/dist/{chunk-FOJZNMMK.js → chunk-2LQGSDZ6.js} +1 -1
  4. package/dist/chunk-2LQGSDZ6.js.map +1 -0
  5. package/dist/chunk-4R67INKT.js +1002 -0
  6. package/dist/chunk-4R67INKT.js.map +1 -0
  7. package/dist/{chunk-ILU76UF3.js → chunk-4RJ5D7MT.js} +2 -2
  8. package/dist/chunk-4RJ5D7MT.js.map +1 -0
  9. package/dist/{chunk-EQZI77PP.cjs → chunk-5VVS2QIJ.cjs} +3 -3
  10. package/dist/{chunk-EQZI77PP.cjs.map → chunk-5VVS2QIJ.cjs.map} +1 -1
  11. package/dist/{chunk-3DUADAY2.js → chunk-A275ZQLX.js} +209 -87
  12. package/dist/chunk-A275ZQLX.js.map +1 -0
  13. package/dist/{chunk-EISO3POT.js → chunk-CVEERPMP.js} +788 -194
  14. package/dist/chunk-CVEERPMP.js.map +1 -0
  15. package/dist/{chunk-ZWD734EY.js → chunk-D6KQKMU3.js} +2 -2
  16. package/dist/{chunk-QOMNEWCQ.cjs → chunk-EBZUZC6F.cjs} +305 -31
  17. package/dist/chunk-EBZUZC6F.cjs.map +1 -0
  18. package/dist/{chunk-HR2XNERB.cjs → chunk-EMGF6EEV.cjs} +2 -2
  19. package/dist/{chunk-HR2XNERB.cjs.map → chunk-EMGF6EEV.cjs.map} +1 -1
  20. package/dist/{chunk-GDW4YP7K.js → chunk-FAZR34CA.js} +2 -2
  21. package/dist/{chunk-TNCKOL2O.js → chunk-GTINVM5K.js} +2 -2
  22. package/dist/{chunk-L7DMSMAG.cjs → chunk-HX4UUF7Y.cjs} +1 -1
  23. package/dist/chunk-HX4UUF7Y.cjs.map +1 -0
  24. package/dist/{chunk-UET462HB.js → chunk-I4NNYWIR.js} +2 -2
  25. package/dist/chunk-IH56ZISC.js +620 -0
  26. package/dist/chunk-IH56ZISC.js.map +1 -0
  27. package/dist/{chunk-EDNJLUSE.js → chunk-IHZEFW4L.js} +2 -2
  28. package/dist/chunk-IW2CB755.cjs +1002 -0
  29. package/dist/chunk-IW2CB755.cjs.map +1 -0
  30. package/dist/{chunk-ZWOFQRIB.js → chunk-JCVIOLBF.js} +3 -3
  31. package/dist/{chunk-JQEFP45L.js → chunk-L5EH2NVO.js} +2 -2
  32. package/dist/{chunk-247ANM72.cjs → chunk-NOAQRCV6.cjs} +219 -97
  33. package/dist/chunk-NOAQRCV6.cjs.map +1 -0
  34. package/dist/{chunk-7IAQ4HOK.js → chunk-NQCUAGLR.js} +1 -1
  35. package/dist/chunk-NQCUAGLR.js.map +1 -0
  36. package/dist/{chunk-NS55SM7A.js → chunk-O2PGQNYE.js} +2 -2
  37. package/dist/{chunk-QC5T6D4J.js → chunk-QGW7NMTX.js} +299 -25
  38. package/dist/chunk-QGW7NMTX.js.map +1 -0
  39. package/dist/{chunk-A7QC2ZVP.js → chunk-UVVEBI22.js} +209 -87
  40. package/dist/chunk-UVVEBI22.js.map +1 -0
  41. package/dist/chunk-VJHAUMCF.js +949 -0
  42. package/dist/chunk-VJHAUMCF.js.map +1 -0
  43. package/dist/{chunk-C7FQBSON.js → chunk-VNFJPTU4.js} +2 -2
  44. package/dist/{chunk-VQ5W4MYO.js → chunk-VYOGXNQ3.js} +298 -24
  45. package/dist/chunk-VYOGXNQ3.js.map +1 -0
  46. package/dist/{chunk-DOGPOY4B.js → chunk-WB5LW52Z.js} +2 -2
  47. package/dist/{chunk-TSFS5VKD.js → chunk-YGBZABI4.js} +332 -141
  48. package/dist/chunk-YGBZABI4.js.map +1 -0
  49. package/dist/chunks-I7TEMJXH.js +10 -0
  50. package/dist/cli.js +228 -97
  51. package/dist/cli.js.map +1 -1
  52. package/dist/{formula-PJJ6S3Z2.cjs → formula-CPO2TZGB.cjs} +9 -9
  53. package/dist/{formula-PJJ6S3Z2.cjs.map → formula-CPO2TZGB.cjs.map} +1 -1
  54. package/dist/{formula-5S7WWXGH.js → formula-NOIDZEBA.js} +4 -4
  55. package/dist/{formula-JGFTXWYT.js → formula-X44GV7TN.js} +3 -3
  56. package/dist/{image-ocr-WCAYXLOA.js → image-ocr-72RAR4WR.js} +34 -16
  57. package/dist/image-ocr-72RAR4WR.js.map +1 -0
  58. package/dist/{image-ocr-FLIL7MGN.js → image-ocr-R6W6A75P.js} +32 -14
  59. package/dist/image-ocr-R6W6A75P.js.map +1 -0
  60. package/dist/{image-ocr-ZTYAGV3W.cjs → image-ocr-SUGT64ZM.cjs} +36 -18
  61. package/dist/image-ocr-SUGT64ZM.cjs.map +1 -0
  62. package/dist/index.cjs +2416 -1184
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +62 -25
  65. package/dist/index.d.ts +62 -25
  66. package/dist/index.js +1853 -621
  67. package/dist/index.js.map +1 -1
  68. package/dist/mcp.js +74 -53
  69. package/dist/mcp.js.map +1 -1
  70. package/dist/{model-bundle-FSPZZ2EM.js → model-bundle-57CLEBCO.js} +5 -5
  71. package/dist/{models-CJPAQK5R.js → models-7ELIFTD7.js} +5 -5
  72. package/dist/{parser-SCUTZAIJ.js → parser-4NKAYWAX.js} +261 -241
  73. package/dist/parser-4NKAYWAX.js.map +1 -0
  74. package/dist/{parser-A4TMPJAM.js → parser-HWFQRSUQ.js} +261 -241
  75. package/dist/parser-HWFQRSUQ.js.map +1 -0
  76. package/dist/{parser-VCXE4I5A.cjs → parser-RANGXGBD.cjs} +289 -269
  77. package/dist/parser-RANGXGBD.cjs.map +1 -0
  78. package/dist/pdf-ocr-BNC34MNU.js +13 -0
  79. package/dist/pdf-ocr-QX2GB33Q.js +16 -0
  80. package/dist/pdf-ocr-VHSFACH7.cjs +14 -0
  81. package/dist/{pdf-ocr-MBZZ57LD.cjs.map → pdf-ocr-VHSFACH7.cjs.map} +1 -1
  82. package/dist/{profile-io-LBM263K7.js → profile-io-V52PL5ZO.js} +3 -3
  83. package/dist/{rasterize-46RG4ZF6.js → rasterize-ZIGLJDOG.js} +3 -3
  84. package/dist/redact-TIQEQI3M.js +18 -0
  85. package/dist/redact-doc-KXZ3TZAG.js +1216 -0
  86. package/dist/redact-doc-KXZ3TZAG.js.map +1 -0
  87. package/dist/{render-NGP5T24S.js → render-U5PE6V2E.js} +7 -7
  88. package/dist/seal-DNXJBILR.js +10 -0
  89. package/dist/{setup-AU4OCHNH.js → setup-YRDM4ODP.js} +3 -3
  90. package/dist/visual-5XWMA4EV.js +19 -0
  91. package/dist/{watch-MKPUCPXM.js → watch-5IOLBATT.js} +12 -12
  92. package/package.json +2 -2
  93. package/dist/chunk-247ANM72.cjs.map +0 -1
  94. package/dist/chunk-3DUADAY2.js.map +0 -1
  95. package/dist/chunk-422427XJ.cjs +0 -571
  96. package/dist/chunk-422427XJ.cjs.map +0 -1
  97. package/dist/chunk-7IAQ4HOK.js.map +0 -1
  98. package/dist/chunk-A7QC2ZVP.js.map +0 -1
  99. package/dist/chunk-DZIXKL7E.js +0 -145
  100. package/dist/chunk-DZIXKL7E.js.map +0 -1
  101. package/dist/chunk-EISO3POT.js.map +0 -1
  102. package/dist/chunk-EP7KOI2V.js +0 -571
  103. package/dist/chunk-EP7KOI2V.js.map +0 -1
  104. package/dist/chunk-FOJZNMMK.js.map +0 -1
  105. package/dist/chunk-ILU76UF3.js.map +0 -1
  106. package/dist/chunk-KVWV4ULP.js +0 -516
  107. package/dist/chunk-KVWV4ULP.js.map +0 -1
  108. package/dist/chunk-L7DMSMAG.cjs.map +0 -1
  109. package/dist/chunk-QC5T6D4J.js.map +0 -1
  110. package/dist/chunk-QOMNEWCQ.cjs.map +0 -1
  111. package/dist/chunk-TSFS5VKD.js.map +0 -1
  112. package/dist/chunk-VQ5W4MYO.js.map +0 -1
  113. package/dist/chunks-SX77P5CV.js +0 -10
  114. package/dist/image-ocr-FLIL7MGN.js.map +0 -1
  115. package/dist/image-ocr-WCAYXLOA.js.map +0 -1
  116. package/dist/image-ocr-ZTYAGV3W.cjs.map +0 -1
  117. package/dist/parser-A4TMPJAM.js.map +0 -1
  118. package/dist/parser-SCUTZAIJ.js.map +0 -1
  119. package/dist/parser-VCXE4I5A.cjs.map +0 -1
  120. package/dist/pdf-ocr-76SAUXMZ.js +0 -13
  121. package/dist/pdf-ocr-CPU55CVF.js +0 -16
  122. package/dist/pdf-ocr-MBZZ57LD.cjs +0 -14
  123. package/dist/redact-7ILEAUTS.js +0 -12
  124. package/dist/seal-RGUPOLXD.js +0 -10
  125. package/dist/visual-NZLYIYEM.js +0 -19
  126. /package/dist/{-AQKXLFIM.js.map → -7XBPXCXN.js.map} +0 -0
  127. /package/dist/{chunk-ZWD734EY.js.map → chunk-D6KQKMU3.js.map} +0 -0
  128. /package/dist/{chunk-GDW4YP7K.js.map → chunk-FAZR34CA.js.map} +0 -0
  129. /package/dist/{chunk-TNCKOL2O.js.map → chunk-GTINVM5K.js.map} +0 -0
  130. /package/dist/{chunk-UET462HB.js.map → chunk-I4NNYWIR.js.map} +0 -0
  131. /package/dist/{chunk-EDNJLUSE.js.map → chunk-IHZEFW4L.js.map} +0 -0
  132. /package/dist/{chunk-ZWOFQRIB.js.map → chunk-JCVIOLBF.js.map} +0 -0
  133. /package/dist/{chunk-JQEFP45L.js.map → chunk-L5EH2NVO.js.map} +0 -0
  134. /package/dist/{chunk-NS55SM7A.js.map → chunk-O2PGQNYE.js.map} +0 -0
  135. /package/dist/{chunk-C7FQBSON.js.map → chunk-VNFJPTU4.js.map} +0 -0
  136. /package/dist/{chunk-DOGPOY4B.js.map → chunk-WB5LW52Z.js.map} +0 -0
  137. /package/dist/{chunks-SX77P5CV.js.map → chunks-I7TEMJXH.js.map} +0 -0
  138. /package/dist/{formula-5S7WWXGH.js.map → formula-NOIDZEBA.js.map} +0 -0
  139. /package/dist/{formula-JGFTXWYT.js.map → formula-X44GV7TN.js.map} +0 -0
  140. /package/dist/{model-bundle-FSPZZ2EM.js.map → model-bundle-57CLEBCO.js.map} +0 -0
  141. /package/dist/{models-CJPAQK5R.js.map → models-7ELIFTD7.js.map} +0 -0
  142. /package/dist/{pdf-ocr-76SAUXMZ.js.map → pdf-ocr-BNC34MNU.js.map} +0 -0
  143. /package/dist/{pdf-ocr-CPU55CVF.js.map → pdf-ocr-QX2GB33Q.js.map} +0 -0
  144. /package/dist/{profile-io-LBM263K7.js.map → profile-io-V52PL5ZO.js.map} +0 -0
  145. /package/dist/{rasterize-46RG4ZF6.js.map → rasterize-ZIGLJDOG.js.map} +0 -0
  146. /package/dist/{redact-7ILEAUTS.js.map → redact-TIQEQI3M.js.map} +0 -0
  147. /package/dist/{render-NGP5T24S.js.map → render-U5PE6V2E.js.map} +0 -0
  148. /package/dist/{seal-RGUPOLXD.js.map → seal-DNXJBILR.js.map} +0 -0
  149. /package/dist/{setup-AU4OCHNH.js.map → setup-YRDM4ODP.js.map} +0 -0
  150. /package/dist/{visual-NZLYIYEM.js.map → visual-5XWMA4EV.js.map} +0 -0
  151. /package/dist/{watch-MKPUCPXM.js.map → watch-5IOLBATT.js.map} +0 -0
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ALL_OCR_MODELS
4
- } from "./chunk-ZWD734EY.js";
4
+ } from "./chunk-D6KQKMU3.js";
5
5
  import {
6
6
  ALL_FORMULA_MODELS,
7
7
  getModelStatusIn,
8
8
  getModelsDir
9
- } from "./chunk-NS55SM7A.js";
10
- import "./chunk-GDW4YP7K.js";
11
- import "./chunk-UET462HB.js";
9
+ } from "./chunk-O2PGQNYE.js";
10
+ import "./chunk-FAZR34CA.js";
11
+ import "./chunk-I4NNYWIR.js";
12
12
 
13
13
  // src/shared/model-bundle.ts
14
14
  import { copyFile, mkdir } from "fs/promises";
@@ -101,4 +101,4 @@ export {
101
101
  importModels,
102
102
  modelCacheStatus
103
103
  };
104
- //# sourceMappingURL=model-bundle-FSPZZ2EM.js.map
104
+ //# sourceMappingURL=model-bundle-57CLEBCO.js.map
@@ -9,10 +9,10 @@ import {
9
9
  getOcrModelsDir,
10
10
  ocrModelPath,
11
11
  parseCharacterDict
12
- } from "./chunk-ZWD734EY.js";
13
- import "./chunk-NS55SM7A.js";
14
- import "./chunk-GDW4YP7K.js";
15
- import "./chunk-UET462HB.js";
12
+ } from "./chunk-D6KQKMU3.js";
13
+ import "./chunk-O2PGQNYE.js";
14
+ import "./chunk-FAZR34CA.js";
15
+ import "./chunk-I4NNYWIR.js";
16
16
  export {
17
17
  ALL_OCR_MODELS,
18
18
  OCR_DET_MODEL,
@@ -24,4 +24,4 @@ export {
24
24
  ocrModelPath,
25
25
  parseCharacterDict
26
26
  };
27
- //# sourceMappingURL=models-CJPAQK5R.js.map
27
+ //# sourceMappingURL=models-7ELIFTD7.js.map
@@ -1,5 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ CELL_LINES,
4
+ CLIP_TABLES,
5
+ EMPTY_PARTS,
6
+ FILLER_CELLS,
7
+ IMAGE_CELLS,
8
+ TABLE_COLXS,
3
9
  collapseEvenSpacing,
4
10
  computeMedianFontSizeFromFreq,
5
11
  detectHeadings,
@@ -9,24 +15,25 @@ import {
9
15
  extractImageRegions,
10
16
  extractPageBlocksWithLines,
11
17
  filterHiddenText,
12
- mergeCrossPageTables,
13
18
  normalizeItems,
14
- removeHeaderFooterBlocks
15
- } from "./chunk-3DUADAY2.js";
19
+ removeHeaderFooterBlocks,
20
+ trimTrailingEmptyTableCols
21
+ } from "./chunk-A275ZQLX.js";
16
22
  import {
17
23
  encodePng
18
24
  } from "./chunk-7FCNOKOR.js";
19
- import "./chunk-7IAQ4HOK.js";
25
+ import "./chunk-NQCUAGLR.js";
20
26
  import {
21
27
  parsePageRange
22
28
  } from "./chunk-MOL7MDBG.js";
23
29
  import {
30
+ WINGDINGS,
24
31
  blocksToMarkdown
25
- } from "./chunk-QC5T6D4J.js";
32
+ } from "./chunk-QGW7NMTX.js";
26
33
  import {
27
34
  KordocError,
28
35
  sanitizeHref
29
- } from "./chunk-UET462HB.js";
36
+ } from "./chunk-I4NNYWIR.js";
30
37
 
31
38
  // src/pdf/image-extract.ts
32
39
  import { OPS, ImageKind } from "pdfjs-dist/legacy/build/pdf.mjs";
@@ -110,7 +117,7 @@ function toRgba(img) {
110
117
  }
111
118
  return null;
112
119
  }
113
- async function extractPageImages(page, fnArray, argsArray, pageNumber, state, warnings) {
120
+ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, warnings, withBytes = true) {
114
121
  const blocks = [];
115
122
  const images = [];
116
123
  const pageSeenIds = /* @__PURE__ */ new Set();
@@ -149,12 +156,14 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
149
156
  if (state.seen.has(hash)) continue;
150
157
  const rgba = toRgba(imgData);
151
158
  if (!rgba) continue;
152
- const png = encodePng(w, h, rgba);
153
159
  state.imageIndex++;
154
- state.totalBytes += png.length;
155
160
  const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
156
161
  state.seen.set(hash, filename);
157
- images.push({ filename, data: png, mimeType: "image/png" });
162
+ if (withBytes) {
163
+ const png = encodePng(w, h, rgba);
164
+ state.totalBytes += png.length;
165
+ images.push({ filename, data: png, mimeType: "image/png" });
166
+ }
158
167
  blocks.push({ type: "image", text: filename, pageNumber });
159
168
  }
160
169
  return { blocks, images };
@@ -325,232 +334,241 @@ function summarizeDocumentQuality(pages) {
325
334
  };
326
335
  }
327
336
 
337
+ // src/pdf/table-parts.ts
338
+ var PART_COL_TOL = 1;
339
+ function anchorsOf(table) {
340
+ const out = [];
341
+ const covered = /* @__PURE__ */ new Set();
342
+ for (let r = 0; r < table.rows; r++) {
343
+ for (let c = 0; c < table.cols; c++) {
344
+ if (covered.has(r * 1e5 + c)) continue;
345
+ const cell = table.cells[r]?.[c];
346
+ if (!cell) continue;
347
+ out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
348
+ for (let dr = 0; dr < cell.rowSpan; dr++) {
349
+ for (let dc = 0; dc < cell.colSpan; dc++) if (dr || dc) covered.add((r + dr) * 1e5 + (c + dc));
350
+ }
351
+ }
352
+ }
353
+ return out;
354
+ }
355
+ function unionCoords(a, b) {
356
+ const out = [...a];
357
+ for (const v of b) if (!a.some((x) => Math.abs(x - v) <= PART_COL_TOL)) out.push(v);
358
+ return out.sort((x, y) => x - y);
359
+ }
360
+ var indexOf = (coords, x) => {
361
+ let best = -1, bestD = Infinity;
362
+ for (let i = 0; i < coords.length; i++) {
363
+ const d = Math.abs(coords[i] - x);
364
+ if (d < bestD) {
365
+ bestD = d;
366
+ best = i;
367
+ }
368
+ }
369
+ return bestD <= PART_COL_TOL ? best : -1;
370
+ };
371
+ var rowText = (anchors, r) => anchors.filter((a) => a.r === r).map((a) => a.cell.text.replace(/\s+/g, "")).join("|");
372
+ function joinSplitParts(prev, pcx, curr, ccx) {
373
+ if (pcx.length !== prev.cols + 1 || ccx.length !== curr.cols + 1) return null;
374
+ const U = unionCoords(pcx, ccx);
375
+ const cols = U.length - 1;
376
+ if (cols < 1) return null;
377
+ const pa = anchorsOf(prev), ca = anchorsOf(curr);
378
+ let skip = 0;
379
+ while (skip < Math.min(3, curr.rows - 1, prev.rows) && rowText(ca, skip) !== "" && rowText(ca, skip) === rowText(pa, skip)) skip++;
380
+ const rows = prev.rows + curr.rows - skip;
381
+ const grid = Array.from({ length: rows }, () => Array.from({ length: cols }, () => ({ text: "", colSpan: 1, rowSpan: 1 })));
382
+ const owner = Array.from({ length: rows }, () => new Array(cols).fill(null));
383
+ const place = (a, x, rowOff) => {
384
+ const c1 = indexOf(U, x[a.c]), c2 = indexOf(U, x[a.c + a.cs]);
385
+ if (c1 < 0 || c2 <= c1) return false;
386
+ const r = a.r + rowOff;
387
+ const placed = { r, c: c1, rs: a.rs, cs: c2 - c1, cell: a.cell };
388
+ for (let dr = 0; dr < a.rs; dr++) for (let dc = c1; dc < c2; dc++) {
389
+ if (r + dr < rows) owner[r + dr][dc] = placed;
390
+ }
391
+ grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
392
+ const lines = CELL_LINES.get(a.cell);
393
+ if (lines) CELL_LINES.set(grid[r][c1], lines);
394
+ if (IMAGE_CELLS.has(a.cell)) IMAGE_CELLS.add(grid[r][c1]);
395
+ return true;
396
+ };
397
+ for (const a of pa) if (!FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
398
+ for (const a of ca) {
399
+ if (a.r < skip || FILLER_CELLS.has(a.cell)) continue;
400
+ if (!place(a, ccx, prev.rows - skip)) return null;
401
+ }
402
+ const first = prev.rows;
403
+ for (let c = 0; c < cols; c++) {
404
+ const above = owner[first - 1]?.[c];
405
+ if (!above) continue;
406
+ let r = first;
407
+ while (r < rows && owner[r][c] === null) r++;
408
+ if (r === first) continue;
409
+ const span = r - first;
410
+ let ok = true;
411
+ for (let dc = above.c; dc < above.c + above.cs && ok; dc++) {
412
+ for (let rr = first; rr < first + span; rr++) if (owner[rr][dc] !== null) {
413
+ ok = false;
414
+ break;
415
+ }
416
+ }
417
+ if (!ok) continue;
418
+ const newRs = above.rs + span;
419
+ grid[above.r][above.c].rowSpan = newRs;
420
+ const grown = { ...above, rs: newRs };
421
+ 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;
422
+ }
423
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) FILLER_CELLS.add(grid[r][c]);
424
+ const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
425
+ if (rows > prev.rows) mergeSplitRow(table, owner, prev.rows, U);
426
+ return { table, colXs: U };
427
+ }
428
+ var FULL_LINE_TOL = 1;
429
+ var FULL_LINE_MIN_FRAC = 0.5;
430
+ var FULL_LINE_EDGE_MIN = 12;
431
+ var SINGLE_LINE_WORD_GAP = 3.5;
432
+ var SHORT_LINE_GAP = 1.5;
433
+ function continuesAcross(u, d, x1, x2) {
434
+ const U = CELL_LINES.get(u), D = CELL_LINES.get(d);
435
+ if (!U?.length || !D?.length) return false;
436
+ const last = U[U.length - 1];
437
+ const fs = last.h || 10;
438
+ let minL = Infinity, maxR = -Infinity;
439
+ for (const l of U) {
440
+ minL = Math.min(minL, l.l);
441
+ maxR = Math.max(maxR, l.r);
442
+ }
443
+ for (const l of D) {
444
+ minL = Math.min(minL, l.l);
445
+ maxR = Math.max(maxR, l.r);
446
+ }
447
+ if (maxR - last.r > FULL_LINE_TOL * fs) return false;
448
+ if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
449
+ if (last.r - last.l < FULL_LINE_MIN_FRAC * (x2 - x1)) return false;
450
+ const leftAligned = (l) => l.l - minL <= fs && maxR - l.r > SHORT_LINE_GAP * fs;
451
+ return U.some(leftAligned) || D.some(leftAligned);
452
+ }
453
+ function mergeSplitRow(table, owner, first, colXs) {
454
+ const last = first - 1;
455
+ const pairs = [];
456
+ for (let c = 0; c < table.cols; ) {
457
+ const a = owner[last][c], b = owner[first][c];
458
+ if (!a || !b) return;
459
+ if (a !== b) {
460
+ if (a.c !== b.c || a.cs !== b.cs || a.r + a.rs - 1 !== last || b.r !== first || b.rs !== 1) return;
461
+ pairs.push([a, b]);
462
+ }
463
+ c = a.c + a.cs;
464
+ }
465
+ if (!pairs.some(([u, d]) => continuesAcross(u.cell, d.cell, colXs[u.c], colXs[u.c + u.cs]))) return;
466
+ for (const [u, d] of pairs) {
467
+ const a = table.cells[u.r][u.c], b = table.cells[d.r][d.c];
468
+ if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
469
+ if (b.blocks?.length) a.blocks = [...a.blocks ?? [], ...b.blocks];
470
+ }
471
+ for (let r = 0; r < first; r++) for (let c = 0; c < table.cols; c++) {
472
+ const o = owner[r][c];
473
+ if (o && o.r === r && o.c === c && r + table.cells[r][c].rowSpan > first) table.cells[r][c].rowSpan--;
474
+ }
475
+ table.cells.splice(first, 1);
476
+ table.rows--;
477
+ }
478
+ var NEIGHBOR_TABLE_EPSILON = 0.2;
479
+ function besideBoth(b, p, c) {
480
+ if (b.type === "table" || !b.bbox) return false;
481
+ const bx1 = b.bbox.x, bx2 = b.bbox.x + b.bbox.width;
482
+ return [p.bbox, c.bbox].every((t) => bx2 <= t.x + 1 || bx1 >= t.x + t.width - 1);
483
+ }
484
+ function mergeCrossPageTables(blocks, pageHeights) {
485
+ for (let i = blocks.length - 2; i >= 0; i--) {
486
+ const prev = blocks[i];
487
+ if (prev.type !== "table" || !prev.table || !prev.bbox || !prev.pageNumber) continue;
488
+ let j = i + 1;
489
+ while (j < blocks.length && blocks[j].type !== "table" && (blocks[j].pageNumber ?? 0) <= prev.pageNumber + 1) j++;
490
+ const curr = blocks[j];
491
+ if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
492
+ const joined = j === i + 1 || blocks.slice(i + 1, j).every((b) => besideBoth(b, prev, curr)) ? looksContinued(prev, curr, pageHeights) ? joinClipParts(prev, curr, pageHeights) ?? false : null : null;
493
+ if (joined) {
494
+ blocks[i] = { ...prev, table: joined };
495
+ blocks.splice(j, 1);
496
+ continue;
497
+ }
498
+ if (EMPTY_PARTS.has(curr.table)) {
499
+ blocks.splice(j, 1);
500
+ i++;
501
+ continue;
502
+ }
503
+ if (joined === null) continue;
504
+ if (prev.table.cols !== curr.table.cols || EMPTY_PARTS.has(prev.table)) continue;
505
+ const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
506
+ const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
507
+ const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
508
+ if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
509
+ const px = TABLE_COLXS.get(prev.table), cx = TABLE_COLXS.get(curr.table);
510
+ if (px && cx && (px.length !== cx.length || px.some((x, k) => Math.abs(x - cx[k]) > CONTINUATION_COL_TOL))) continue;
511
+ let currCells = curr.table.cells;
512
+ if (currCells.length > 1 && prev.table.cells.length > 0 && rowTextsEqual(prev.table.cells[0], currCells[0])) {
513
+ currCells = currCells.slice(1);
514
+ }
515
+ if (currCells.length === 0) {
516
+ blocks.splice(j, 1);
517
+ continue;
518
+ }
519
+ const merged = {
520
+ rows: prev.table.rows + currCells.length,
521
+ cols: prev.table.cols,
522
+ cells: [...prev.table.cells, ...currCells],
523
+ hasHeader: prev.table.hasHeader,
524
+ caption: prev.table.caption
525
+ };
526
+ if (px ?? cx) TABLE_COLXS.set(merged, px ?? cx);
527
+ if (CLIP_TABLES.has(prev.table) || CLIP_TABLES.has(curr.table)) CLIP_TABLES.add(merged);
528
+ blocks[i] = { ...prev, table: merged };
529
+ blocks.splice(j, 1);
530
+ }
531
+ for (let i = blocks.length - 1; i >= 0; i--) {
532
+ const t = blocks[i].table;
533
+ if (blocks[i].type === "table" && t && EMPTY_PARTS.has(t)) blocks.splice(i, 1);
534
+ }
535
+ }
536
+ function joinClipParts(prev, curr, pageHeights) {
537
+ const pt = prev.table, ct = curr.table;
538
+ if (!CLIP_TABLES.has(pt) || !CLIP_TABLES.has(ct)) return null;
539
+ const px = TABLE_COLXS.get(pt), cx = TABLE_COLXS.get(ct);
540
+ if (!px || !cx) return null;
541
+ const sameCols = px.length === cx.length && px.every((x, k) => Math.abs(x - cx[k]) <= CONTINUATION_COL_TOL);
542
+ if (!sameCols) {
543
+ if (!pageHeights?.get(prev.pageNumber) || !pageHeights?.get(curr.pageNumber)) return null;
544
+ if (Math.abs(px[px.length - 1] - cx[cx.length - 1]) > CONTINUATION_COL_TOL) return null;
545
+ if (!px.some((x) => Math.abs(x - cx[0]) <= CONTINUATION_COL_TOL)) return null;
546
+ }
547
+ const res = joinSplitParts(pt, px, ct, cx);
548
+ if (!res) return null;
549
+ TABLE_COLXS.set(res.table, res.colXs);
550
+ CLIP_TABLES.add(res.table);
551
+ return res.table;
552
+ }
553
+ var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
554
+ function looksContinued(prev, curr, pageHeights) {
555
+ const ph = pageHeights?.get(prev.pageNumber), ch = pageHeights?.get(curr.pageNumber);
556
+ if (ph && ch && (prev.bbox.y > ph * PAGE_EDGE_BAND || curr.bbox.y + curr.bbox.height < ch * (1 - PAGE_EDGE_BAND))) return false;
557
+ const firstText = curr.table.cells[0]?.find((c) => c.text.trim())?.text ?? "";
558
+ return !ANNEX_HEAD_RE.test(firstText);
559
+ }
560
+ function rowTextsEqual(a, b) {
561
+ if (a.length !== b.length) return false;
562
+ const norm = (t) => t.replace(/\s+/g, "");
563
+ for (let i = 0; i < a.length; i++) {
564
+ if (norm(a[i].text) !== norm(b[i].text)) return false;
565
+ }
566
+ return a.some((c) => c.text.trim() !== "");
567
+ }
568
+ var CONTINUATION_COL_TOL = 2;
569
+ var PAGE_EDGE_BAND = 0.16;
570
+
328
571
  // src/pdf/symbol-fonts.ts
329
- var WINGDINGS = [
330
- "\u{1F589}",
331
- "\u2702",
332
- "\u2701",
333
- "\u{1F453}",
334
- "\u{1F56D}",
335
- "\u{1F56E}",
336
- "\u{1F56F}",
337
- "\u{1F57F}",
338
- "\u2706",
339
- "\u{1F582}",
340
- "\u{1F583}",
341
- "\u{1F4EA}",
342
- "\u{1F4EB}",
343
- "\u{1F4EC}",
344
- "\u{1F4ED}",
345
- "\u{1F4C1}",
346
- "\u{1F4C2}",
347
- "\u{1F4C4}",
348
- "\u{1F5CF}",
349
- "\u{1F5D0}",
350
- "\u{1F5C4}",
351
- "\u231B",
352
- "\u{1F5AE}",
353
- "\u{1F5B0}",
354
- "\u{1F5B2}",
355
- "\u{1F5B3}",
356
- "\u{1F5B4}",
357
- "\u{1F5AB}",
358
- "\u{1F5AC}",
359
- "\u2707",
360
- "\u270D",
361
- "\u{1F58E}",
362
- "\u270C",
363
- "\u{1F44C}",
364
- "\u{1F44D}",
365
- "\u{1F44E}",
366
- "\u261C",
367
- "\u261E",
368
- "\u261D",
369
- "\u261F",
370
- "\u{1F590}",
371
- "\u263A",
372
- "\u{1F610}",
373
- "\u2639",
374
- "\u{1F4A3}",
375
- "\u2620",
376
- "\u{1F3F3}",
377
- "\u{1F3F1}",
378
- "\u2708",
379
- "\u263C",
380
- "\u{1F4A7}",
381
- "\u2744",
382
- "\u{1F546}",
383
- "\u271E",
384
- "\u{1F548}",
385
- "\u2720",
386
- "\u2721",
387
- "\u262A",
388
- "\u262F",
389
- "\u0950",
390
- "\u2638",
391
- "\u2648",
392
- "\u2649",
393
- "\u264A",
394
- "\u264B",
395
- "\u264C",
396
- "\u264D",
397
- "\u264E",
398
- "\u264F",
399
- "\u2650",
400
- "\u2651",
401
- "\u2652",
402
- "\u2653",
403
- "\u{1F670}",
404
- "\u{1F675}",
405
- "\u25CF",
406
- "\u25CB",
407
- "\u25A0",
408
- "\u25A1",
409
- "\u25A1",
410
- "\u2751",
411
- "\u2752",
412
- "\u2B27",
413
- "\u29EB",
414
- "\u25C6",
415
- "\u2756",
416
- "\u2B25",
417
- "\u2327",
418
- "\u2BB9",
419
- "\u2318",
420
- "\u{1F3F5}",
421
- "\u{1F3F6}",
422
- "\u{1F676}",
423
- "\u{1F677}",
424
- "",
425
- "\u24EA",
426
- "\u2460",
427
- "\u2461",
428
- "\u2462",
429
- "\u2463",
430
- "\u2464",
431
- "\u2465",
432
- "\u2466",
433
- "\u2467",
434
- "\u2468",
435
- "\u2469",
436
- "\u24FF",
437
- "\u2776",
438
- "\u2777",
439
- "\u2778",
440
- "\u2779",
441
- "\u277A",
442
- "\u277B",
443
- "\u277C",
444
- "\u277D",
445
- "\u277E",
446
- "\u277F",
447
- "\u{1F662}",
448
- "\u{1F660}",
449
- "\u{1F661}",
450
- "\u{1F663}",
451
- "\u{1F65E}",
452
- "\u{1F65C}",
453
- "\u{1F65D}",
454
- "\u{1F65F}",
455
- "\xB7",
456
- "\u2022",
457
- "\u25AA",
458
- "\u26AA",
459
- "\u25CB",
460
- "\u25EF",
461
- "\u25C9",
462
- "\u25CE",
463
- "\u{1F53F}",
464
- "\u25AA",
465
- "\u25FB",
466
- "\u{1F7C2}",
467
- "\u2726",
468
- "\u2605",
469
- "\u2736",
470
- "\u2734",
471
- "\u2739",
472
- "\u2735",
473
- "\u2BD0",
474
- "\u2316",
475
- "\u27E1",
476
- "\u2311",
477
- "\u2BD1",
478
- "\u272A",
479
- "\u2730",
480
- "\u{1F550}",
481
- "\u{1F551}",
482
- "\u{1F552}",
483
- "\u{1F553}",
484
- "\u{1F554}",
485
- "\u{1F555}",
486
- "\u{1F556}",
487
- "\u{1F557}",
488
- "\u{1F558}",
489
- "\u{1F559}",
490
- "\u{1F55A}",
491
- "\u{1F55B}",
492
- "\u2BB0",
493
- "\u2BB1",
494
- "\u2BB2",
495
- "\u2BB3",
496
- "\u2BB4",
497
- "\u2BB5",
498
- "\u2BB6",
499
- "\u2BB7",
500
- "\u{1F66A}",
501
- "\u{1F66B}",
502
- "\u{1F655}",
503
- "\u{1F654}",
504
- "\u{1F657}",
505
- "\u{1F656}",
506
- "\u{1F650}",
507
- "\u{1F651}",
508
- "\u{1F652}",
509
- "\u{1F653}",
510
- "\u232B",
511
- "\u2326",
512
- "\u2B98",
513
- "\u2B9A",
514
- "\u2B99",
515
- "\u2B9B",
516
- "\u2B88",
517
- "\u2B8A",
518
- "\u2B89",
519
- "\u2B8B",
520
- "\u2190",
521
- "\u2192",
522
- "\u2191",
523
- "\u2193",
524
- "\u2196",
525
- "\u2197",
526
- "\u2199",
527
- "\u2198",
528
- "\u2B05",
529
- "\u2794",
530
- "\u2B06",
531
- "\u2B07",
532
- "\u2B09",
533
- "\u2B08",
534
- "\u2B0B",
535
- "\u2B0A",
536
- "\u21E6",
537
- "\u21E8",
538
- "\u21E7",
539
- "\u21E9",
540
- "\u2B04",
541
- "\u21F3",
542
- "\u2B00",
543
- "\u2B01",
544
- "\u2B03",
545
- "\u2B02",
546
- "\u{1F8AC}",
547
- "\u{1F8AD}",
548
- "\u2717",
549
- "\u2714",
550
- "\u2612",
551
- "\u2611",
552
- ""
553
- ];
554
572
  var WINANSI_REVERSE = {
555
573
  8364: 128,
556
574
  8218: 130,
@@ -623,7 +641,8 @@ function remapSymbolFontItems(items, resolveFontName) {
623
641
  function normalizeAraea(text) {
624
642
  return text.replace(/(?<![\u1100-\u115F])\u119E/g, "\u318D");
625
643
  }
626
- var cleanChars = (text) => normalizeAraea(stripControlChars(text));
644
+ var stripNoUnicodeGlyph = (text) => text.includes("\uF000") ? text.replace(/\uF000/g, "") : text;
645
+ var cleanChars = (text) => normalizeAraea(stripNoUnicodeGlyph(stripControlChars(text)));
627
646
  function sanitizeBlockControlChars(blocks) {
628
647
  for (const b of blocks) {
629
648
  if (b.text) b.text = cleanChars(b.text);
@@ -737,7 +756,7 @@ function applyLinkAnnotations(items, annots) {
737
756
 
738
757
  // src/pdf/formula-ocr.ts
739
758
  async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
740
- const formulaMod = await import("./formula-5S7WWXGH.js");
759
+ const formulaMod = await import("./formula-NOIDZEBA.js");
741
760
  const { FormulaPipeline, ensureFormulaModels } = formulaMod;
742
761
  await ensureFormulaModels((p) => {
743
762
  if (p.phase === "download" && p.total) {
@@ -987,7 +1006,7 @@ async function parsePdfDocument(buffer, options) {
987
1006
  const pageBlocks = extractPageBlocksWithLines(visible, i, opList, viewport.width, viewport.height, void 0, options?.tables !== false);
988
1007
  for (const b of pageBlocks) blocks.push(b);
989
1008
  try {
990
- const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings);
1009
+ const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, options?.images !== false);
991
1010
  if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
992
1011
  extractedImages.push(...pageImages);
993
1012
  } catch {
@@ -1029,7 +1048,7 @@ async function parsePdfDocument(buffer, options) {
1029
1048
  }
1030
1049
  if (targets.size > 0) {
1031
1050
  try {
1032
- const { runPdfOcr } = await import("./pdf-ocr-CPU55CVF.js");
1051
+ const { runPdfOcr } = await import("./pdf-ocr-QX2GB33Q.js");
1033
1052
  const mode = typeof options.ocr === "function" ? options.ocr : "builtin";
1034
1053
  const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, options.onProgress, options.tables !== false);
1035
1054
  if (ocrPageBlocks.size > 0) {
@@ -1084,7 +1103,8 @@ async function parsePdfDocument(buffer, options) {
1084
1103
  blocks.splice(removed[ri], 1);
1085
1104
  }
1086
1105
  }
1087
- mergeCrossPageTables(blocks);
1106
+ mergeCrossPageTables(blocks, pageHeights);
1107
+ if (!options?.keepTrailingEmptyCols) trimTrailingEmptyTableCols(blocks);
1088
1108
  injectPageImageBlocks(blocks, pageImageBlocks);
1089
1109
  if (options?.formulaOcr && formulaBuffer) {
1090
1110
  try {
@@ -1166,4 +1186,4 @@ export {
1166
1186
  parsePdfDocument,
1167
1187
  removeHeaderFooterBlocks
1168
1188
  };
1169
- //# sourceMappingURL=parser-SCUTZAIJ.js.map
1189
+ //# sourceMappingURL=parser-4NKAYWAX.js.map