kordoc 4.22.3 → 4.22.5

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 +9 -7
  2. package/dist/{-AOWV7MNY.js → -WFRWBH7T.js} +11 -11
  3. package/dist/{chunk-3ANXRVI2.js → chunk-2L3Q7REU.js} +3 -3
  4. package/dist/{chunk-FDFXL7VJ.js → chunk-35ZHXEJA.js} +3 -3
  5. package/dist/{chunk-BS2XWGT5.js → chunk-3BR7VKWL.js} +2 -2
  6. package/dist/{chunk-KBGNPGVY.js → chunk-3G3TLZDK.js} +2 -2
  7. package/dist/{chunk-M2X766AY.js → chunk-3YEL7P4L.js} +2 -2
  8. package/dist/{chunk-NJEMRAIF.cjs → chunk-4SUB43EJ.cjs} +24 -24
  9. package/dist/{chunk-NJEMRAIF.cjs.map → chunk-4SUB43EJ.cjs.map} +1 -1
  10. package/dist/{chunk-DKJ2RNDG.js → chunk-4TWN7PWJ.js} +2 -2
  11. package/dist/{chunk-UCLDUUBX.js → chunk-52HIK4C2.js} +4 -3
  12. package/dist/chunk-52HIK4C2.js.map +1 -0
  13. package/dist/{chunk-3H2IEU4V.js → chunk-63N6CEJE.js} +2 -2
  14. package/dist/{chunk-MEIQ476H.js → chunk-6MCC2XNB.js} +2 -2
  15. package/dist/{chunk-SKRWKVVW.js → chunk-6MQKNB6K.js} +15 -8
  16. package/dist/chunk-6MQKNB6K.js.map +1 -0
  17. package/dist/{chunk-MI655NV5.cjs → chunk-AS25R4EU.cjs} +2 -2
  18. package/dist/{chunk-MI655NV5.cjs.map → chunk-AS25R4EU.cjs.map} +1 -1
  19. package/dist/{chunk-4NQ4EZEE.js → chunk-C3REGEQO.js} +2 -2
  20. package/dist/{chunk-NLGOMLGU.cjs → chunk-C6B5GWN7.cjs} +35 -28
  21. package/dist/chunk-C6B5GWN7.cjs.map +1 -0
  22. package/dist/{chunk-6LIBF2ZB.js → chunk-CO7O3ZT6.js} +2 -2
  23. package/dist/{chunk-IRNWAHHZ.js → chunk-CRSTBATY.js} +2 -2
  24. package/dist/{chunk-VJCQOSMT.js → chunk-CW67DAAH.js} +2 -2
  25. package/dist/{chunk-6QBBGZST.js → chunk-DN55FTJP.js} +2 -2
  26. package/dist/{chunk-OIF5HRVP.js → chunk-HLPMC7L4.js} +16 -9
  27. package/dist/chunk-HLPMC7L4.js.map +1 -0
  28. package/dist/{chunk-24YLYR6Q.js → chunk-LE4VHWIT.js} +4 -4
  29. package/dist/{chunk-2BCQVQO2.cjs → chunk-N6KXGIIN.cjs} +3 -3
  30. package/dist/{chunk-2BCQVQO2.cjs.map → chunk-N6KXGIIN.cjs.map} +1 -1
  31. package/dist/{chunk-7XITVUAK.js → chunk-PSORL4PA.js} +11 -11
  32. package/dist/{chunk-AXX5AQT4.js → chunk-RYKDIUHT.js} +4 -4
  33. package/dist/{chunk-O5E25RHU.js → chunk-SETAYS6P.js} +2 -2
  34. package/dist/{chunk-X45Q7EAC.js → chunk-T7OZ7X6A.js} +2 -2
  35. package/dist/{chunk-J5PYESLX.js → chunk-TOUJCO2P.js} +2 -2
  36. package/dist/{chunk-YOGMCRM7.js → chunk-U3GUZQ54.js} +1353 -1335
  37. package/dist/chunk-U3GUZQ54.js.map +1 -0
  38. package/dist/{chunk-O3OS6FAW.cjs → chunk-UCK6WGHY.cjs} +3 -3
  39. package/dist/{chunk-O3OS6FAW.cjs.map → chunk-UCK6WGHY.cjs.map} +1 -1
  40. package/dist/{chunk-SJ5OZXEL.cjs → chunk-YG4GFQB7.cjs} +6 -6
  41. package/dist/{chunk-SJ5OZXEL.cjs.map → chunk-YG4GFQB7.cjs.map} +1 -1
  42. package/dist/chunks-NXABWR6G.js +10 -0
  43. package/dist/cli.js +30 -30
  44. package/dist/{formula-W4OL33YQ.js → formula-FSVHUQ6Y.js} +4 -4
  45. package/dist/{formula-C26FMMGO.js → formula-L625ULJP.js} +3 -3
  46. package/dist/{formula-5V2WG4BH.cjs → formula-QZGTF3DZ.cjs} +9 -9
  47. package/dist/{formula-5V2WG4BH.cjs.map → formula-QZGTF3DZ.cjs.map} +1 -1
  48. package/dist/{image-ocr-BELHEWPX.cjs → image-ocr-AELVAU75.cjs} +17 -17
  49. package/dist/{image-ocr-BELHEWPX.cjs.map → image-ocr-AELVAU75.cjs.map} +1 -1
  50. package/dist/{image-ocr-T72HMX2W.js → image-ocr-KE3RUS3R.js} +6 -6
  51. package/dist/{image-ocr-NSQ34Y6T.js → image-ocr-QTZNBP5V.js} +9 -9
  52. package/dist/index.cjs +859 -840
  53. package/dist/index.cjs.map +1 -1
  54. package/dist/index.js +322 -303
  55. package/dist/index.js.map +1 -1
  56. package/dist/mcp.js +22 -22
  57. package/dist/{model-bundle-34T2LJB4.js → model-bundle-F6TU6ZAV.js} +5 -5
  58. package/dist/{models-TQH5EM6V.js → models-ZHNNVH2W.js} +5 -5
  59. package/dist/{parse-worker-v2-YEYLILGJ.js → parse-worker-v2-KQRG3NQO.js} +12 -12
  60. package/dist/{parser-SJHCBL7T.js → parser-RVMH4PUB.js} +183 -21
  61. package/dist/parser-RVMH4PUB.js.map +1 -0
  62. package/dist/{parser-E6BG3ECD.js → parser-WBKVRDPV.js} +179 -17
  63. package/dist/parser-WBKVRDPV.js.map +1 -0
  64. package/dist/{parser-OAXCXVQ4.cjs → parser-WNDH2X6N.cjs} +442 -280
  65. package/dist/parser-WNDH2X6N.cjs.map +1 -0
  66. package/dist/pdf-ocr-IOUZTPPH.cjs +31 -0
  67. package/dist/{pdf-ocr-RKXDY3ZA.cjs.map → pdf-ocr-IOUZTPPH.cjs.map} +1 -1
  68. package/dist/{pdf-ocr-LGPSJM22.js → pdf-ocr-X5XLGL5J.js} +6 -6
  69. package/dist/{pdf-ocr-T5ASSUKK.js → pdf-ocr-ZP2CUWSO.js} +9 -9
  70. package/dist/{profile-io-KMCAFTMG.js → profile-io-B4VSI4LW.js} +3 -3
  71. package/dist/{rasterize-M52AKY7R.js → rasterize-Y7NVUVXU.js} +3 -3
  72. package/dist/{redact-doc-SWJC27LL.js → redact-doc-GIBTFWCO.js} +11 -11
  73. package/dist/{render-45AB5YZR.js → render-JVCGYRRO.js} +7 -7
  74. package/dist/seal-WNX2ZJTK.js +10 -0
  75. package/dist/{setup-5PBMUI6M.js → setup-7L7EQPMG.js} +3 -3
  76. package/dist/visual-VPWPXIHN.js +21 -0
  77. package/dist/{watch-QOGKV52T.js → watch-VYMFGX72.js} +12 -12
  78. package/package.json +1 -1
  79. package/dist/chunk-NLGOMLGU.cjs.map +0 -1
  80. package/dist/chunk-OIF5HRVP.js.map +0 -1
  81. package/dist/chunk-SKRWKVVW.js.map +0 -1
  82. package/dist/chunk-UCLDUUBX.js.map +0 -1
  83. package/dist/chunk-YOGMCRM7.js.map +0 -1
  84. package/dist/chunks-7KXTS7IV.js +0 -10
  85. package/dist/parser-E6BG3ECD.js.map +0 -1
  86. package/dist/parser-OAXCXVQ4.cjs.map +0 -1
  87. package/dist/parser-SJHCBL7T.js.map +0 -1
  88. package/dist/pdf-ocr-RKXDY3ZA.cjs +0 -31
  89. package/dist/seal-7KWG6VHS.js +0 -10
  90. package/dist/visual-OMJNXLNZ.js +0 -21
  91. /package/dist/{-AOWV7MNY.js.map → -WFRWBH7T.js.map} +0 -0
  92. /package/dist/{chunk-3ANXRVI2.js.map → chunk-2L3Q7REU.js.map} +0 -0
  93. /package/dist/{chunk-FDFXL7VJ.js.map → chunk-35ZHXEJA.js.map} +0 -0
  94. /package/dist/{chunk-BS2XWGT5.js.map → chunk-3BR7VKWL.js.map} +0 -0
  95. /package/dist/{chunk-KBGNPGVY.js.map → chunk-3G3TLZDK.js.map} +0 -0
  96. /package/dist/{chunk-M2X766AY.js.map → chunk-3YEL7P4L.js.map} +0 -0
  97. /package/dist/{chunk-DKJ2RNDG.js.map → chunk-4TWN7PWJ.js.map} +0 -0
  98. /package/dist/{chunk-3H2IEU4V.js.map → chunk-63N6CEJE.js.map} +0 -0
  99. /package/dist/{chunk-MEIQ476H.js.map → chunk-6MCC2XNB.js.map} +0 -0
  100. /package/dist/{chunk-4NQ4EZEE.js.map → chunk-C3REGEQO.js.map} +0 -0
  101. /package/dist/{chunk-6LIBF2ZB.js.map → chunk-CO7O3ZT6.js.map} +0 -0
  102. /package/dist/{chunk-IRNWAHHZ.js.map → chunk-CRSTBATY.js.map} +0 -0
  103. /package/dist/{chunk-VJCQOSMT.js.map → chunk-CW67DAAH.js.map} +0 -0
  104. /package/dist/{chunk-6QBBGZST.js.map → chunk-DN55FTJP.js.map} +0 -0
  105. /package/dist/{chunk-24YLYR6Q.js.map → chunk-LE4VHWIT.js.map} +0 -0
  106. /package/dist/{chunk-7XITVUAK.js.map → chunk-PSORL4PA.js.map} +0 -0
  107. /package/dist/{chunk-AXX5AQT4.js.map → chunk-RYKDIUHT.js.map} +0 -0
  108. /package/dist/{chunk-O5E25RHU.js.map → chunk-SETAYS6P.js.map} +0 -0
  109. /package/dist/{chunk-X45Q7EAC.js.map → chunk-T7OZ7X6A.js.map} +0 -0
  110. /package/dist/{chunk-J5PYESLX.js.map → chunk-TOUJCO2P.js.map} +0 -0
  111. /package/dist/{chunks-7KXTS7IV.js.map → chunks-NXABWR6G.js.map} +0 -0
  112. /package/dist/{formula-W4OL33YQ.js.map → formula-FSVHUQ6Y.js.map} +0 -0
  113. /package/dist/{formula-C26FMMGO.js.map → formula-L625ULJP.js.map} +0 -0
  114. /package/dist/{image-ocr-T72HMX2W.js.map → image-ocr-KE3RUS3R.js.map} +0 -0
  115. /package/dist/{image-ocr-NSQ34Y6T.js.map → image-ocr-QTZNBP5V.js.map} +0 -0
  116. /package/dist/{model-bundle-34T2LJB4.js.map → model-bundle-F6TU6ZAV.js.map} +0 -0
  117. /package/dist/{models-TQH5EM6V.js.map → models-ZHNNVH2W.js.map} +0 -0
  118. /package/dist/{parse-worker-v2-YEYLILGJ.js.map → parse-worker-v2-KQRG3NQO.js.map} +0 -0
  119. /package/dist/{pdf-ocr-LGPSJM22.js.map → pdf-ocr-X5XLGL5J.js.map} +0 -0
  120. /package/dist/{pdf-ocr-T5ASSUKK.js.map → pdf-ocr-ZP2CUWSO.js.map} +0 -0
  121. /package/dist/{profile-io-KMCAFTMG.js.map → profile-io-B4VSI4LW.js.map} +0 -0
  122. /package/dist/{rasterize-M52AKY7R.js.map → rasterize-Y7NVUVXU.js.map} +0 -0
  123. /package/dist/{redact-doc-SWJC27LL.js.map → redact-doc-GIBTFWCO.js.map} +0 -0
  124. /package/dist/{render-45AB5YZR.js.map → render-JVCGYRRO.js.map} +0 -0
  125. /package/dist/{seal-7KWG6VHS.js.map → seal-WNX2ZJTK.js.map} +0 -0
  126. /package/dist/{setup-5PBMUI6M.js.map → setup-7L7EQPMG.js.map} +0 -0
  127. /package/dist/{visual-OMJNXLNZ.js.map → visual-VPWPXIHN.js.map} +0 -0
  128. /package/dist/{watch-QOGKV52T.js.map → watch-VYMFGX72.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  blocksToPages,
3
3
  encodePng
4
- } from "./chunk-IRNWAHHZ.js";
4
+ } from "./chunk-CRSTBATY.js";
5
5
  import {
6
6
  hasRequestedPagesAfter,
7
7
  parsePageRange
@@ -61,7 +61,7 @@ import {
61
61
  stripAbsorbedRunningLines,
62
62
  trimTrailingEmptyTableCols,
63
63
  wrapJoiner
64
- } from "./chunk-OIF5HRVP.js";
64
+ } from "./chunk-HLPMC7L4.js";
65
65
  import {
66
66
  CELL_BASELINES,
67
67
  CELL_EDGES,
@@ -72,15 +72,16 @@ import {
72
72
  blocksToMarkdown,
73
73
  escapeLiteralDollar,
74
74
  escapeLiteralTags,
75
+ mapPuaText,
75
76
  stripScriptTags,
76
77
  unframeLayoutTables,
77
78
  validateOcrOptions
78
- } from "./chunk-J5PYESLX.js";
79
- import "./chunk-O5E25RHU.js";
79
+ } from "./chunk-TOUJCO2P.js";
80
+ import "./chunk-SETAYS6P.js";
80
81
  import {
81
82
  KordocError,
82
83
  sanitizeHref
83
- } from "./chunk-X45Q7EAC.js";
84
+ } from "./chunk-T7OZ7X6A.js";
84
85
 
85
86
  // src/pdf/image-extract.ts
86
87
  import { createHash } from "crypto";
@@ -611,6 +612,117 @@ function ocrVectorOps(opList, paths) {
611
612
  // src/pdf/split-row-pattern.ts
612
613
  var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
613
614
  var plain = (cell) => !cell.blocks?.length && !IMAGE_CELLS.has(cell);
615
+ var labelsOf = (cell) => {
616
+ const labels = textOf(cell).split("\n").map((s) => s.trim()).filter(Boolean);
617
+ return labels.length && labels.every((s) => /^\p{L}[\p{L}\p{N} ]{0,15}[::]$/u.test(s)) ? labels.map((s) => s.replace(/\s+/g, "").replace(/:/g, ":")) : void 0;
618
+ };
619
+ var alignedLabels = (label, value, count) => {
620
+ const L = CELL_LINES.get(label), V = CELL_LINES.get(value);
621
+ let next = 0;
622
+ return !!L && !!V && L.length === count && V.length >= count && Math.abs(L[0].y - V[0].y) <= 1 && L.every((l) => {
623
+ while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
624
+ return next++ < V.length;
625
+ });
626
+ };
627
+ function partialAlignedLabelCells(table, owner, first) {
628
+ const pageOf = (a) => CELL_PAGES.get(a.cell ?? table.cells[a.r][a.c]) ?? (a.r < first ? -1 : -2);
629
+ const pairs = [];
630
+ let carried = false;
631
+ for (let c = 0; c < table.cols; ) {
632
+ const u = owner[first - 1]?.[c], d = owner[first]?.[c];
633
+ if (u && u === d) {
634
+ carried = true;
635
+ c = u.c + u.cs;
636
+ continue;
637
+ }
638
+ const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
639
+ if (!upper?.text.trim() && !lower?.text.trim()) {
640
+ c++;
641
+ continue;
642
+ }
643
+ if (!u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower) || !textOf(upper) || !textOf(lower)) return;
644
+ pairs.push({ c, cs: u.cs, upper, lower });
645
+ c += u.cs;
646
+ }
647
+ if (!carried || pairs.length !== 3) return;
648
+ const keyed = pairs.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
649
+ if (keyed.length !== 1) return;
650
+ const label = keyed[0], value = pairs.find((p) => p.c === label.c + label.cs), context = pairs.find((p) => p.c + p.cs === label.c);
651
+ if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !CELL_EDGES.get(context.upper)?.b || !CELL_EDGES.get(context.lower)?.t) return;
652
+ const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
653
+ if (D.length < 2 || sequence.length < 3 || new Set(sequence).size !== sequence.length || !alignedLabels(label.upper, value.upper, U.length)) return;
654
+ const L = CELL_LINES.get(label.lower), V = CELL_LINES.get(value.lower);
655
+ if (!L || !V || L.length !== D.length) return;
656
+ let next = V.findIndex((v) => Math.abs(v.y - L[0].y) <= 1);
657
+ if (next <= 0 || !V.slice(0, next).every((v) => v.y > L[0].y + 1) || !L.every((l) => {
658
+ while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
659
+ return next++ < V.length;
660
+ })) return;
661
+ let peers = 0, shared = false;
662
+ for (let r = 0; r < table.rows; r++) {
663
+ if (r === first - 1 || r === first) continue;
664
+ const l = owner[r]?.[label.c], v = owner[r]?.[value.c];
665
+ if (!l || !v || l.r !== r || v.r !== r || l.c !== label.c || v.c !== value.c || l.cs !== label.cs || v.cs !== value.cs || l.rs !== v.rs) continue;
666
+ const lc = table.cells[r][l.c], vc = table.cells[r][v.c];
667
+ const list = labelsOf(lc);
668
+ if (!plain(lc) || !plain(vc) || !textOf(vc) || !list || pageOf(l) !== pageOf(v)) continue;
669
+ if (l.rs === 1) {
670
+ if (list.join("|") === sequence.join("|") && alignedLabels(lc, vc, list.length)) peers++;
671
+ continue;
672
+ }
673
+ if (list.length < 3 || new Set(list).size !== list.length) continue;
674
+ const visible = CELL_LINES.get(lc)?.length ?? 0, values = CELL_LINES.get(vc);
675
+ if (visible < 3 || visible > list.length || !values || !alignedLabels(lc, vc, visible)) continue;
676
+ const top = Math.max(...values.map((v2) => v2.y)), bottom = Math.min(...values.map((v2) => v2.y));
677
+ const contexts = [];
678
+ for (let rr = r; rr < r + l.rs && rr < table.rows; rr++) {
679
+ const a = owner[rr]?.[context.c], cell = a ? table.cells[a.r][a.c] : void 0;
680
+ if (!a || a.r !== rr || a.c !== context.c || a.cs !== context.cs || a.rs !== 1 || !cell || !plain(cell) || !textOf(cell) || pageOf(a) !== pageOf(l)) break;
681
+ const lines = CELL_LINES.get(cell);
682
+ if (!lines?.length || lines.some((line) => line.y > top + 1 || line.y < bottom - 1)) break;
683
+ contexts.push(textOf(cell).replace(/\s+/g, ""));
684
+ }
685
+ if (new Set(contexts).size >= 2) shared = true;
686
+ }
687
+ return peers >= 2 && shared ? { context, label, value } : void 0;
688
+ }
689
+ function matchesCompleteAlignedLabelListRow(table, owner, first) {
690
+ const pairs = [];
691
+ let carried = false;
692
+ for (let c = 0; c < table.cols; ) {
693
+ const u = owner[first - 1]?.[c], d = owner[first]?.[c];
694
+ if (u && u === d) {
695
+ carried = true;
696
+ c = u.c + u.cs;
697
+ continue;
698
+ }
699
+ const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
700
+ if (!upper?.text.trim() && !lower?.text.trim()) {
701
+ c++;
702
+ continue;
703
+ }
704
+ if (!u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower)) return false;
705
+ pairs.push({ c, cs: u.cs, upper, lower });
706
+ c += u.cs;
707
+ }
708
+ const filled = pairs.filter((p) => textOf(p.upper) && textOf(p.lower));
709
+ if (!carried || filled.length !== 2) return false;
710
+ const keyed = filled.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
711
+ if (keyed.length !== 1) return false;
712
+ const label = keyed[0], value = filled.find((p) => p !== label);
713
+ const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
714
+ if (D.length < 2 || sequence.length < 3 || new Set(sequence).size !== sequence.length || value.c !== label.c + label.cs || pairs.some((p) => p !== label && p !== value && textOf(p.lower)) || !pairs.some((p) => p.c < label.c && textOf(p.upper) && !textOf(p.lower)) || !alignedLabels(label.upper, value.upper, U.length) || !alignedLabels(label.lower, value.lower, D.length)) return false;
715
+ let peers = 0;
716
+ for (let r = 0; r < table.rows; r++) {
717
+ if (r === first - 1 || r === first) continue;
718
+ const L = owner[r]?.[label.c], V = owner[r]?.[value.c];
719
+ if (L?.r !== r || V?.r !== r || L.c !== label.c || V.c !== value.c || L.rs !== 1 || V.rs !== 1 || L.cs !== label.cs || V.cs !== value.cs) continue;
720
+ const l = table.cells[r][label.c], v = table.cells[r][value.c];
721
+ if (!plain(l) || !plain(v) || !textOf(v) || labelsOf(l)?.join("|") !== sequence.join("|") || !alignedLabels(l, v, sequence.length)) continue;
722
+ if (++peers >= 2) return true;
723
+ }
724
+ return false;
725
+ }
614
726
  function matchesIndependentRowPair(table, owner, first) {
615
727
  const norm = (cell) => textOf(cell).replace(/\s+/g, "");
616
728
  const pairs = [];
@@ -903,6 +1015,17 @@ function markJoinedPages(table, prev, curr) {
903
1015
  }
904
1016
  });
905
1017
  const cr = pt.rows - 1 - off, page = cp[cr];
1018
+ if (cr === -1 && table.cols === pt.cols && pt.cols === ct.cols) {
1019
+ const tailPage = cp[0];
1020
+ if (tailPage === void 0 || tailPage === prev.pageNumber) return;
1021
+ for (let r = 0; r < pt.rows; r++) for (const { cell, c } of rows[r]) {
1022
+ const head = ptRows[r]?.find((s) => s.c === c)?.cell, tail = ctRows[0]?.find((s) => s.c === c)?.cell;
1023
+ if (!head?.text.trim() || !tail?.text.trim() || cell.blocks?.length || cell.colSpan !== head.colSpan || cell.colSpan !== tail.colSpan || cell.rowSpan <= head.rowSpan || r + head.rowSpan !== pt.rows || r + cell.rowSpan <= pt.rows || !cell.text.startsWith(head.text.trimEnd()) || !cell.text.trimEnd().endsWith(tail.text.trimEnd())) continue;
1024
+ const from = head.text.trimEnd().length, at = cell.text.indexOf(tail.text.trim().slice(0, 20), from);
1025
+ if (at >= from) setSplits(cell, [...relocate(head, cell), { at, page: tailPage }, ...relocate(tail, cell, at)]);
1026
+ }
1027
+ return;
1028
+ }
906
1029
  if (cr < 0 || page === void 0 || page === prev.pageNumber) return;
907
1030
  const tails = ctRows[cr].filter((s) => s.cell.text.trim());
908
1031
  for (const { cell } of ctRows[cr]) for (const b of cell.blocks ?? []) b.pageNumber ??= page;
@@ -953,6 +1076,17 @@ function splitCrossPageRows(t, pageNumber) {
953
1076
  };
954
1077
  const e = Math.max(...splits.map((s) => r + s.cell.rowSpan - 1));
955
1078
  const cells = t.cells.map((row2) => row2.slice());
1079
+ const cut = pages.findIndex((p, rr) => rr > r && p !== pages[r]);
1080
+ if (cut > r && splits.every((s) => cut < r + s.cell.rowSpan && pages[cut] === s.split.page)) {
1081
+ for (const { cell, c, split } of splits) {
1082
+ cells[r][c] = clone(cell, { ...split.head, rowSpan: cut - r });
1083
+ const tail = { ...cell, ...split.tail, rowSpan: r + cell.rowSpan - cut };
1084
+ CELL_PAGES.set(tail, split.page);
1085
+ setSplits(tail, split.rest);
1086
+ cells[cut][c] = tail;
1087
+ }
1088
+ return splitCrossPageRows({ ...t, cells }, pageNumber);
1089
+ }
956
1090
  const row = Array.from({ length: t.cols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }));
957
1091
  for (const { cell, c, split } of splits) {
958
1092
  cells[r][c] = clone(cell, split.head);
@@ -1130,15 +1264,18 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
1130
1264
  ruled: !!pr && !!cr && pr.bottom && cr.top,
1131
1265
  list: !shifted ? "any" : skip > 0 && ca.filter((a) => a.r < skip && a.cell.text.trim()).length < 2 ? "none" : "multi"
1132
1266
  };
1133
- let split = rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
1134
- if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U)) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
1267
+ let partial = !skip && cols === prev.cols && cols === curr.cols && cut.ruled && prevBottom !== void 0 ? partialAlignedLabelCells(table, owner, first) : void 0;
1268
+ if (partial && (continuesAcross(partial.context.upper, partial.context.lower, U[partial.context.c], U[partial.context.c + partial.context.cs]) || clauseContinues(partial.context.upper, partial.context.lower) || quantityContinues(partial.context.upper, partial.context.lower) || !continuesAcross(partial.value.upper, partial.value.lower, U[partial.value.c], U[partial.value.c + partial.value.cs]) || startsNewItem(partial.value.upper.text, partial.value.lower.text))) partial = void 0;
1269
+ const selected = partial ? /* @__PURE__ */ new Set([partial.label.c, partial.value.c]) : void 0;
1270
+ let split = !selected && rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
1271
+ if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U, selected) && !selected) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
1135
1272
  if (pr && cr) {
1136
1273
  const cutRuled = pr.bottom || cr.top;
1137
1274
  ROW_RULES.set(table, { top: pr.top, bottom: cr.bottom, innerRuled: pr.innerRuled + cr.innerRuled + (!split && cutRuled ? 1 : 0), innerOpen: pr.innerOpen + cr.innerOpen + (!split && !cutRuled ? 1 : 0) });
1138
1275
  }
1139
1276
  return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
1140
1277
  }
1141
- function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
1278
+ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selected) {
1142
1279
  const last = first - 1;
1143
1280
  const straddles = owner[first].some((o, c) => o !== null && o === owner[last][c]);
1144
1281
  let firstNew = table.cols;
@@ -1195,6 +1332,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
1195
1332
  c = u.c + u.cs;
1196
1333
  if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
1197
1334
  const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
1335
+ if (selected && !selected.has(u.c)) continue;
1198
1336
  const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !startsNewItem(a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
1199
1337
  const openSeam = hasContent(a) && hasContent(b) && hasOpenCellSeam(a, b) && !owner.some((row, r) => {
1200
1338
  if (!r || r === first) return false;
@@ -1203,7 +1341,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
1203
1341
  const ue = CELL_EDGES.get(table.cells[up.r][up.c]), de = CELL_EDGES.get(table.cells[down.r][down.c]);
1204
1342
  return !!ue && !!de && !ue.b && !de.t;
1205
1343
  });
1206
- if (!openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
1344
+ if (!selected && !openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
1207
1345
  if (!straddles && !midWord) continue;
1208
1346
  if (u.r >= last && d.rs < 2) continue;
1209
1347
  const U = CELL_LINES.get(a);
@@ -1395,7 +1533,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
1395
1533
  if (!(cut.open && !newCell)) {
1396
1534
  if (pairs.some((p) => p[1].rs > 1 && !flows(p))) return false;
1397
1535
  const one = pairs.filter(([, d]) => d.rs === 1);
1398
- if (!matchesCompleteSiblingRow(table, owner, first) && !matchesCompleteRubricRow(table, owner, first) && !(cut.ruled && matchesCompleteContextRow(table, owner, first)) && !outlineOnly(pairs, cell) && !one.some(flows) && (cut.list === "none" || !one.some(([u, d]) => listContinues(cell(u), cell(d), cut.list === "multi")))) return false;
1536
+ if (!matchesCompleteSiblingRow(table, owner, first) && !matchesCompleteRubricRow(table, owner, first) && !(cut.ruled && (matchesCompleteContextRow(table, owner, first) || matchesCompleteAlignedLabelListRow(table, owner, first))) && !outlineOnly(pairs, cell) && !one.some(flows) && (cut.list === "none" || !one.some(([u, d]) => listContinues(cell(u), cell(d), cut.list === "multi")))) return false;
1399
1537
  }
1400
1538
  }
1401
1539
  for (const [u, d] of pairs) {
@@ -1843,6 +1981,30 @@ function fillNestedContinuation(blocks, at) {
1843
1981
 
1844
1982
  // src/pdf/symbol-glyphs.ts
1845
1983
  import { OPS as OPS3 } from "pdfjs-dist/legacy/build/pdf.mjs";
1984
+
1985
+ // src/pdf/known-font-glyphs.ts
1986
+ import { createHash as createHash2 } from "crypto";
1987
+ var HCR_DOT = "bb7a2a3ab48d5bfdfd9582c0fb6525401c3a7f1851bb1c1bdb45048be95d1599";
1988
+ var BATANG_NUMBERS = [
1989
+ "8a4af2cf2dfe3238b4e2b35af976746216ade6e89cd3c55ec1e43bca532379b9",
1990
+ "7332dcab9d77002bdb92723a7fa4afa963ad01601f6328fbedd7289798fb77d0",
1991
+ "e7cc725807eae1ae0311898429629931f5924ade91a876c899b0c5bd109b325b",
1992
+ "3956a9db6baa74ef40ff93291ef5c42245cd4b36d613e5c956e307f347705adb",
1993
+ "8340732dc5f6a75a6808e87749ae9e9e7d54f4299f86eabbfaedd95da10ad447",
1994
+ "1412a79bd9ed7fdb34a8f04c29e341230a3bef649fb7b44a58ea6a56da0f3e44"
1995
+ ];
1996
+ function knownFontGlyph(name, outline, width) {
1997
+ const face = name?.replace(/^[A-Z]{6}\+/, "");
1998
+ const dot = face === "HCRDotum" && width === 970 && outline.upm === 1e3;
1999
+ const number = (face === "Haansoft Batang" || face === "Haansoft-Batang") && width === 1e3 && outline.upm === 1024;
2000
+ if (!dot && !number) return null;
2001
+ const signature = createHash2("sha256").update(JSON.stringify([outline.upm, width, outline.contours])).digest("hex");
2002
+ if (dot) return signature === HCR_DOT ? mapPuaText(String.fromCodePoint(983791)) : null;
2003
+ const index = BATANG_NUMBERS.indexOf(signature);
2004
+ return index < 0 ? null : mapPuaText(String.fromCodePoint(983729 + index));
2005
+ }
2006
+
2007
+ // src/pdf/symbol-glyphs.ts
1846
2008
  var NO_UNICODE = "\uF000";
1847
2009
  var u16 = (b, o) => b[o] << 8 | b[o + 1];
1848
2010
  var i16 = (b, o) => {
@@ -2006,14 +2168,14 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
2006
2168
  for (const g2 of args[0]) {
2007
2169
  const glyph = g2;
2008
2170
  if (!glyph || glyph.unicode !== NO_UNICODE || typeof glyph.fontChar !== "string") continue;
2009
- const key = font + "\0" + glyph.fontChar;
2171
+ const key = font + "\0" + glyph.fontChar + "\0" + typeof glyph.width + ":" + String(glyph.width);
2010
2172
  if (!cache.has(key)) {
2011
2173
  let sym = null;
2012
2174
  try {
2013
- const data = fontObj(font)?.data;
2175
+ const source = fontObj(font), data = source?.data;
2014
2176
  const code = glyph.fontChar.codePointAt(0);
2015
2177
  const outline = data && code !== void 0 ? readOutline(data, code) : null;
2016
- if (outline) sym = classifyOutline(outline);
2178
+ if (outline) sym = knownFontGlyph(source?.name, outline, glyph.width) ?? classifyOutline(outline);
2017
2179
  } catch {
2018
2180
  }
2019
2181
  cache.set(key, sym);
@@ -3423,7 +3585,7 @@ function mergeLinkRuns(markdown) {
3423
3585
 
3424
3586
  // src/pdf/formula-ocr.ts
3425
3587
  async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
3426
- const formulaMod = await import("./formula-C26FMMGO.js");
3588
+ const formulaMod = await import("./formula-L625ULJP.js");
3427
3589
  const { FormulaPipeline, ensureFormulaModels } = formulaMod;
3428
3590
  await ensureFormulaModels((p) => {
3429
3591
  if (p.phase === "download" && p.total) {
@@ -3849,10 +4011,10 @@ async function parsePdfDocument(buffer, options) {
3849
4011
  }
3850
4012
  if (targets.size > 0) {
3851
4013
  try {
3852
- const { runPdfOcr } = await import("./pdf-ocr-LGPSJM22.js");
4014
+ const { runPdfOcr } = await import("./pdf-ocr-X5XLGL5J.js");
3853
4015
  const mode = typeof options?.ocr === "function" ? options.ocr : "builtin";
3854
4016
  const regionPages = new Map([...ocrRegions].filter(([p]) => options?.ocr !== "force" && !isImageBased && !pageQuality.find((q) => q.page === p)?.needsOcr));
3855
- const { builtinOcrConfig } = await import("./pdf-ocr-LGPSJM22.js");
4017
+ const { builtinOcrConfig } = await import("./pdf-ocr-X5XLGL5J.js");
3856
4018
  const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, options?.onProgress, options?.tables !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
3857
4019
  for (const obs of ocrPageBlocks.values()) stripScriptTags({ blocks: obs });
3858
4020
  if (ocrPageBlocks.size > 0) {
@@ -4097,4 +4259,4 @@ export {
4097
4259
  parsePdfDocument,
4098
4260
  removeHeaderFooterBlocks
4099
4261
  };
4100
- //# sourceMappingURL=parser-E6BG3ECD.js.map
4262
+ //# sourceMappingURL=parser-WBKVRDPV.js.map