kordoc 4.22.3 → 4.22.4
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.
- package/README.md +7 -6
- package/dist/{-AOWV7MNY.js → -HAK3YFWW.js} +11 -11
- package/dist/{chunk-M2X766AY.js → chunk-36DK6AOX.js} +2 -2
- package/dist/{chunk-3H2IEU4V.js → chunk-3TUJ34V7.js} +2 -2
- package/dist/{chunk-NLGOMLGU.cjs → chunk-4X7AR4EH.cjs} +34 -28
- package/dist/chunk-4X7AR4EH.cjs.map +1 -0
- package/dist/{chunk-DKJ2RNDG.js → chunk-5ARHF54C.js} +2 -2
- package/dist/{chunk-6LIBF2ZB.js → chunk-A3SKXHAN.js} +2 -2
- package/dist/{chunk-4NQ4EZEE.js → chunk-AYV5VRHL.js} +2 -2
- package/dist/{chunk-SKRWKVVW.js → chunk-C5J5LDWM.js} +14 -8
- package/dist/{chunk-SKRWKVVW.js.map → chunk-C5J5LDWM.js.map} +1 -1
- package/dist/{chunk-FDFXL7VJ.js → chunk-CWBH66IQ.js} +3 -3
- package/dist/{chunk-MEIQ476H.js → chunk-DEFT7Z3B.js} +2 -2
- package/dist/{chunk-YOGMCRM7.js → chunk-EVL6HZQL.js} +80 -69
- package/dist/chunk-EVL6HZQL.js.map +1 -0
- package/dist/{chunk-O3OS6FAW.cjs → chunk-EYQLJ57Y.cjs} +3 -3
- package/dist/{chunk-O3OS6FAW.cjs.map → chunk-EYQLJ57Y.cjs.map} +1 -1
- package/dist/{chunk-3ANXRVI2.js → chunk-F3AWNFMO.js} +3 -3
- package/dist/{chunk-AXX5AQT4.js → chunk-FAFSBCU2.js} +4 -4
- package/dist/{chunk-KBGNPGVY.js → chunk-G2325K2F.js} +2 -2
- package/dist/{chunk-7XITVUAK.js → chunk-G4KNI7EO.js} +11 -11
- package/dist/{chunk-OIF5HRVP.js → chunk-HN3QMHTT.js} +15 -9
- package/dist/{chunk-OIF5HRVP.js.map → chunk-HN3QMHTT.js.map} +1 -1
- package/dist/{chunk-SJ5OZXEL.cjs → chunk-K2NWHLCD.cjs} +6 -6
- package/dist/{chunk-SJ5OZXEL.cjs.map → chunk-K2NWHLCD.cjs.map} +1 -1
- package/dist/{chunk-24YLYR6Q.js → chunk-LVVSMYG4.js} +4 -4
- package/dist/{chunk-MI655NV5.cjs → chunk-MJSHXESK.cjs} +2 -2
- package/dist/{chunk-MI655NV5.cjs.map → chunk-MJSHXESK.cjs.map} +1 -1
- package/dist/{chunk-VJCQOSMT.js → chunk-MYTMZSQO.js} +2 -2
- package/dist/{chunk-X45Q7EAC.js → chunk-Q65HT2BL.js} +2 -2
- package/dist/{chunk-BS2XWGT5.js → chunk-Q6SVCBMK.js} +2 -2
- package/dist/{chunk-6QBBGZST.js → chunk-RPSILMQY.js} +2 -2
- package/dist/{chunk-NJEMRAIF.cjs → chunk-S45M7IQH.cjs} +24 -24
- package/dist/{chunk-NJEMRAIF.cjs.map → chunk-S45M7IQH.cjs.map} +1 -1
- package/dist/{chunk-O5E25RHU.js → chunk-SSL3TKJY.js} +2 -2
- package/dist/{chunk-J5PYESLX.js → chunk-UJVVL6BI.js} +2 -2
- package/dist/{chunk-2BCQVQO2.cjs → chunk-VXQWAPC6.cjs} +3 -3
- package/dist/{chunk-2BCQVQO2.cjs.map → chunk-VXQWAPC6.cjs.map} +1 -1
- package/dist/{chunk-UCLDUUBX.js → chunk-WCTC3LSV.js} +2 -2
- package/dist/{chunk-IRNWAHHZ.js → chunk-WNW77CAY.js} +2 -2
- package/dist/chunks-3N7OFSA4.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-5V2WG4BH.cjs → formula-JGFYGFYX.cjs} +9 -9
- package/dist/{formula-5V2WG4BH.cjs.map → formula-JGFYGFYX.cjs.map} +1 -1
- package/dist/{formula-C26FMMGO.js → formula-KSTY73DQ.js} +3 -3
- package/dist/{formula-W4OL33YQ.js → formula-PWAUR5PF.js} +4 -4
- package/dist/{image-ocr-T72HMX2W.js → image-ocr-RASJHOAK.js} +6 -6
- package/dist/{image-ocr-NSQ34Y6T.js → image-ocr-RPBPO3VT.js} +9 -9
- package/dist/{image-ocr-BELHEWPX.cjs → image-ocr-UULNAC5Y.cjs} +17 -17
- package/dist/{image-ocr-BELHEWPX.cjs.map → image-ocr-UULNAC5Y.cjs.map} +1 -1
- package/dist/index.cjs +489 -478
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +80 -69
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-34T2LJB4.js → model-bundle-ZPQ4IFT7.js} +5 -5
- package/dist/{models-TQH5EM6V.js → models-YJQ5VHOR.js} +5 -5
- package/dist/{parse-worker-v2-YEYLILGJ.js → parse-worker-v2-7PNZYASF.js} +12 -12
- package/dist/{parser-E6BG3ECD.js → parser-DR6ZHYEB.js} +59 -10
- package/dist/parser-DR6ZHYEB.js.map +1 -0
- package/dist/{parser-SJHCBL7T.js → parser-ER3VLB37.js} +62 -13
- package/dist/parser-ER3VLB37.js.map +1 -0
- package/dist/{parser-OAXCXVQ4.cjs → parser-ZFXVZZKQ.cjs} +323 -274
- package/dist/parser-ZFXVZZKQ.cjs.map +1 -0
- package/dist/{pdf-ocr-LGPSJM22.js → pdf-ocr-BYT7XVID.js} +6 -6
- package/dist/{pdf-ocr-T5ASSUKK.js → pdf-ocr-DRQN5BXA.js} +9 -9
- package/dist/pdf-ocr-QWTGWYQT.cjs +31 -0
- package/dist/{pdf-ocr-RKXDY3ZA.cjs.map → pdf-ocr-QWTGWYQT.cjs.map} +1 -1
- package/dist/{profile-io-KMCAFTMG.js → profile-io-3QYTSPNH.js} +3 -3
- package/dist/{rasterize-M52AKY7R.js → rasterize-LPLWCBXV.js} +3 -3
- package/dist/{redact-doc-SWJC27LL.js → redact-doc-HDA6ZG3N.js} +11 -11
- package/dist/{render-45AB5YZR.js → render-MYZGD3SB.js} +7 -7
- package/dist/seal-XA5V6A6V.js +10 -0
- package/dist/{setup-5PBMUI6M.js → setup-EF5TQVAI.js} +3 -3
- package/dist/visual-DB7NJOID.js +21 -0
- package/dist/{watch-QOGKV52T.js → watch-PM5PRSFW.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-NLGOMLGU.cjs.map +0 -1
- package/dist/chunk-YOGMCRM7.js.map +0 -1
- package/dist/chunks-7KXTS7IV.js +0 -10
- package/dist/parser-E6BG3ECD.js.map +0 -1
- package/dist/parser-OAXCXVQ4.cjs.map +0 -1
- package/dist/parser-SJHCBL7T.js.map +0 -1
- package/dist/pdf-ocr-RKXDY3ZA.cjs +0 -31
- package/dist/seal-7KWG6VHS.js +0 -10
- package/dist/visual-OMJNXLNZ.js +0 -21
- /package/dist/{-AOWV7MNY.js.map → -HAK3YFWW.js.map} +0 -0
- /package/dist/{chunk-M2X766AY.js.map → chunk-36DK6AOX.js.map} +0 -0
- /package/dist/{chunk-3H2IEU4V.js.map → chunk-3TUJ34V7.js.map} +0 -0
- /package/dist/{chunk-DKJ2RNDG.js.map → chunk-5ARHF54C.js.map} +0 -0
- /package/dist/{chunk-6LIBF2ZB.js.map → chunk-A3SKXHAN.js.map} +0 -0
- /package/dist/{chunk-4NQ4EZEE.js.map → chunk-AYV5VRHL.js.map} +0 -0
- /package/dist/{chunk-FDFXL7VJ.js.map → chunk-CWBH66IQ.js.map} +0 -0
- /package/dist/{chunk-MEIQ476H.js.map → chunk-DEFT7Z3B.js.map} +0 -0
- /package/dist/{chunk-3ANXRVI2.js.map → chunk-F3AWNFMO.js.map} +0 -0
- /package/dist/{chunk-AXX5AQT4.js.map → chunk-FAFSBCU2.js.map} +0 -0
- /package/dist/{chunk-KBGNPGVY.js.map → chunk-G2325K2F.js.map} +0 -0
- /package/dist/{chunk-7XITVUAK.js.map → chunk-G4KNI7EO.js.map} +0 -0
- /package/dist/{chunk-24YLYR6Q.js.map → chunk-LVVSMYG4.js.map} +0 -0
- /package/dist/{chunk-VJCQOSMT.js.map → chunk-MYTMZSQO.js.map} +0 -0
- /package/dist/{chunk-X45Q7EAC.js.map → chunk-Q65HT2BL.js.map} +0 -0
- /package/dist/{chunk-BS2XWGT5.js.map → chunk-Q6SVCBMK.js.map} +0 -0
- /package/dist/{chunk-6QBBGZST.js.map → chunk-RPSILMQY.js.map} +0 -0
- /package/dist/{chunk-O5E25RHU.js.map → chunk-SSL3TKJY.js.map} +0 -0
- /package/dist/{chunk-J5PYESLX.js.map → chunk-UJVVL6BI.js.map} +0 -0
- /package/dist/{chunk-UCLDUUBX.js.map → chunk-WCTC3LSV.js.map} +0 -0
- /package/dist/{chunk-IRNWAHHZ.js.map → chunk-WNW77CAY.js.map} +0 -0
- /package/dist/{chunks-7KXTS7IV.js.map → chunks-3N7OFSA4.js.map} +0 -0
- /package/dist/{formula-C26FMMGO.js.map → formula-KSTY73DQ.js.map} +0 -0
- /package/dist/{formula-W4OL33YQ.js.map → formula-PWAUR5PF.js.map} +0 -0
- /package/dist/{image-ocr-T72HMX2W.js.map → image-ocr-RASJHOAK.js.map} +0 -0
- /package/dist/{image-ocr-NSQ34Y6T.js.map → image-ocr-RPBPO3VT.js.map} +0 -0
- /package/dist/{model-bundle-34T2LJB4.js.map → model-bundle-ZPQ4IFT7.js.map} +0 -0
- /package/dist/{models-TQH5EM6V.js.map → models-YJQ5VHOR.js.map} +0 -0
- /package/dist/{parse-worker-v2-YEYLILGJ.js.map → parse-worker-v2-7PNZYASF.js.map} +0 -0
- /package/dist/{pdf-ocr-LGPSJM22.js.map → pdf-ocr-BYT7XVID.js.map} +0 -0
- /package/dist/{pdf-ocr-T5ASSUKK.js.map → pdf-ocr-DRQN5BXA.js.map} +0 -0
- /package/dist/{profile-io-KMCAFTMG.js.map → profile-io-3QYTSPNH.js.map} +0 -0
- /package/dist/{rasterize-M52AKY7R.js.map → rasterize-LPLWCBXV.js.map} +0 -0
- /package/dist/{redact-doc-SWJC27LL.js.map → redact-doc-HDA6ZG3N.js.map} +0 -0
- /package/dist/{render-45AB5YZR.js.map → render-MYZGD3SB.js.map} +0 -0
- /package/dist/{seal-7KWG6VHS.js.map → seal-XA5V6A6V.js.map} +0 -0
- /package/dist/{setup-5PBMUI6M.js.map → setup-EF5TQVAI.js.map} +0 -0
- /package/dist/{visual-OMJNXLNZ.js.map → visual-DB7NJOID.js.map} +0 -0
- /package/dist/{watch-QOGKV52T.js.map → watch-PM5PRSFW.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkVXQWAPC6cjs = require('./chunk-VXQWAPC6.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -61,7 +61,7 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
var
|
|
64
|
+
var _chunk4X7AR4EHcjs = require('./chunk-4X7AR4EH.cjs');
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
@@ -75,12 +75,12 @@ var _chunkNLGOMLGUcjs = require('./chunk-NLGOMLGU.cjs');
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
var
|
|
79
|
-
require('./chunk-
|
|
78
|
+
var _chunkK2NWHLCDcjs = require('./chunk-K2NWHLCD.cjs');
|
|
79
|
+
require('./chunk-EYQLJ57Y.cjs');
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
var
|
|
83
|
+
var _chunkMJSHXESKcjs = require('./chunk-MJSHXESK.cjs');
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -217,7 +217,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
217
217
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
218
218
|
state.seen.set(hash, filename);
|
|
219
219
|
if (withBytes) {
|
|
220
|
-
const png =
|
|
220
|
+
const png = _chunkVXQWAPC6cjs.encodePng.call(void 0, w, h, rgba);
|
|
221
221
|
state.totalBytes += png.length;
|
|
222
222
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
223
223
|
}
|
|
@@ -613,13 +613,26 @@ function ocrVectorOps(opList, paths) {
|
|
|
613
613
|
|
|
614
614
|
// src/pdf/split-row-pattern.ts
|
|
615
615
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
616
|
-
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !
|
|
617
|
-
|
|
618
|
-
const
|
|
616
|
+
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !_chunk4X7AR4EHcjs.IMAGE_CELLS.has(cell);
|
|
617
|
+
var labelsOf = (cell) => {
|
|
618
|
+
const labels = textOf(cell).split("\n").map((s) => s.trim()).filter(Boolean);
|
|
619
|
+
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;
|
|
620
|
+
};
|
|
621
|
+
var alignedLabels = (label, value, count) => {
|
|
622
|
+
const L = _chunk4X7AR4EHcjs.CELL_LINES.get(label), V = _chunk4X7AR4EHcjs.CELL_LINES.get(value);
|
|
623
|
+
let next = 0;
|
|
624
|
+
return !!L && !!V && L.length === count && V.length >= count && Math.abs(L[0].y - V[0].y) <= 1 && L.every((l) => {
|
|
625
|
+
while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
|
|
626
|
+
return next++ < V.length;
|
|
627
|
+
});
|
|
628
|
+
};
|
|
629
|
+
function matchesCompleteAlignedLabelListRow(table, owner, first) {
|
|
619
630
|
const pairs = [];
|
|
631
|
+
let carried = false;
|
|
620
632
|
for (let c = 0; c < table.cols; ) {
|
|
621
633
|
const u = _optionalChain([owner, 'access', _11 => _11[first - 1], 'optionalAccess', _12 => _12[c]]), d = _optionalChain([owner, 'access', _13 => _13[first], 'optionalAccess', _14 => _14[c]]);
|
|
622
634
|
if (u && u === d) {
|
|
635
|
+
carried = true;
|
|
623
636
|
c = u.c + u.cs;
|
|
624
637
|
continue;
|
|
625
638
|
}
|
|
@@ -628,6 +641,42 @@ function matchesIndependentRowPair(table, owner, first) {
|
|
|
628
641
|
c++;
|
|
629
642
|
continue;
|
|
630
643
|
}
|
|
644
|
+
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;
|
|
645
|
+
pairs.push({ c, cs: u.cs, upper, lower });
|
|
646
|
+
c += u.cs;
|
|
647
|
+
}
|
|
648
|
+
const filled = pairs.filter((p) => textOf(p.upper) && textOf(p.lower));
|
|
649
|
+
if (!carried || filled.length !== 2) return false;
|
|
650
|
+
const keyed = filled.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
|
|
651
|
+
if (keyed.length !== 1) return false;
|
|
652
|
+
const label = keyed[0], value = filled.find((p) => p !== label);
|
|
653
|
+
const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
|
|
654
|
+
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;
|
|
655
|
+
let peers = 0;
|
|
656
|
+
for (let r = 0; r < table.rows; r++) {
|
|
657
|
+
if (r === first - 1 || r === first) continue;
|
|
658
|
+
const L = _optionalChain([owner, 'access', _21 => _21[r], 'optionalAccess', _22 => _22[label.c]]), V = _optionalChain([owner, 'access', _23 => _23[r], 'optionalAccess', _24 => _24[value.c]]);
|
|
659
|
+
if (_optionalChain([L, 'optionalAccess', _25 => _25.r]) !== r || _optionalChain([V, 'optionalAccess', _26 => _26.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;
|
|
660
|
+
const l = table.cells[r][label.c], v = table.cells[r][value.c];
|
|
661
|
+
if (!plain(l) || !plain(v) || !textOf(v) || _optionalChain([labelsOf, 'call', _27 => _27(l), 'optionalAccess', _28 => _28.join, 'call', _29 => _29("|")]) !== sequence.join("|") || !alignedLabels(l, v, sequence.length)) continue;
|
|
662
|
+
if (++peers >= 2) return true;
|
|
663
|
+
}
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
function matchesIndependentRowPair(table, owner, first) {
|
|
667
|
+
const norm = (cell) => textOf(cell).replace(/\s+/g, "");
|
|
668
|
+
const pairs = [];
|
|
669
|
+
for (let c = 0; c < table.cols; ) {
|
|
670
|
+
const u = _optionalChain([owner, 'access', _30 => _30[first - 1], 'optionalAccess', _31 => _31[c]]), d = _optionalChain([owner, 'access', _32 => _32[first], 'optionalAccess', _33 => _33[c]]);
|
|
671
|
+
if (u && u === d) {
|
|
672
|
+
c = u.c + u.cs;
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
676
|
+
if (!_optionalChain([upper, 'optionalAccess', _34 => _34.text, 'access', _35 => _35.trim, 'call', _36 => _36()]) && !_optionalChain([lower, 'optionalAccess', _37 => _37.text, 'access', _38 => _38.trim, 'call', _39 => _39()])) {
|
|
677
|
+
c++;
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
631
680
|
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) || !norm(upper) || !norm(lower)) return false;
|
|
632
681
|
pairs.push({ c, cs: u.cs, upper: norm(upper), lower: norm(lower) });
|
|
633
682
|
c += u.cs;
|
|
@@ -636,8 +685,8 @@ function matchesIndependentRowPair(table, owner, first) {
|
|
|
636
685
|
return table.cells.some((_, r) => {
|
|
637
686
|
if (r + 1 >= table.rows || r + 1 >= first - 1 && r <= first) return false;
|
|
638
687
|
return pairs.every((p) => [p.upper, p.lower].every((text, i) => {
|
|
639
|
-
const a = _optionalChain([owner, 'access',
|
|
640
|
-
return _optionalChain([a, 'optionalAccess',
|
|
688
|
+
const a = _optionalChain([owner, 'access', _40 => _40[r + i], 'optionalAccess', _41 => _41[p.c]]), cell = _optionalChain([table, 'access', _42 => _42.cells, 'access', _43 => _43[r + i], 'optionalAccess', _44 => _44[p.c]]);
|
|
689
|
+
return _optionalChain([a, 'optionalAccess', _45 => _45.r]) === r + i && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(cell) === text;
|
|
641
690
|
}));
|
|
642
691
|
});
|
|
643
692
|
}
|
|
@@ -646,7 +695,7 @@ function matchesCompleteContextRow(table, owner, first) {
|
|
|
646
695
|
const context = [];
|
|
647
696
|
let value;
|
|
648
697
|
for (let c = 0; c < table.cols; ) {
|
|
649
|
-
const u = _optionalChain([owner, 'access',
|
|
698
|
+
const u = _optionalChain([owner, 'access', _46 => _46[first - 1], 'optionalAccess', _47 => _47[c]]), d = _optionalChain([owner, 'access', _48 => _48[first], 'optionalAccess', _49 => _49[c]]);
|
|
650
699
|
if (u && u === d) {
|
|
651
700
|
const cell = table.cells[u.r][u.c];
|
|
652
701
|
if (u.r === first - 1 && u.rs === 2 && plain(cell) && textOf(cell)) context.push({ c, cs: u.cs, text: norm(textOf(cell)) });
|
|
@@ -654,7 +703,7 @@ function matchesCompleteContextRow(table, owner, first) {
|
|
|
654
703
|
continue;
|
|
655
704
|
}
|
|
656
705
|
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
657
|
-
if (!_optionalChain([upper, 'optionalAccess',
|
|
706
|
+
if (!_optionalChain([upper, 'optionalAccess', _50 => _50.text, 'access', _51 => _51.trim, 'call', _52 => _52()]) && !_optionalChain([lower, 'optionalAccess', _53 => _53.text, 'access', _54 => _54.trim, 'call', _55 => _55()])) {
|
|
658
707
|
c++;
|
|
659
708
|
continue;
|
|
660
709
|
}
|
|
@@ -665,8 +714,8 @@ function matchesCompleteContextRow(table, owner, first) {
|
|
|
665
714
|
if (!value || !context.length) return false;
|
|
666
715
|
const proof = [...context, value];
|
|
667
716
|
return table.cells.some((row, r) => r !== first - 1 && r !== first && proof.every((p) => {
|
|
668
|
-
const a = _optionalChain([owner, 'access',
|
|
669
|
-
return _optionalChain([a, 'optionalAccess',
|
|
717
|
+
const a = _optionalChain([owner, 'access', _56 => _56[r], 'optionalAccess', _57 => _57[p.c]]), cell = row[p.c];
|
|
718
|
+
return _optionalChain([a, 'optionalAccess', _58 => _58.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(textOf(cell)) === p.text;
|
|
670
719
|
}));
|
|
671
720
|
}
|
|
672
721
|
function matchesCompleteSiblingRow(table, owner, first) {
|
|
@@ -694,7 +743,7 @@ function matchesCompleteSiblingRow(table, owner, first) {
|
|
|
694
743
|
const norm = (s, title) => (title ? s.replace(/^[가-힣]\.\s*/, "") : s).replace(/\s+/g, "");
|
|
695
744
|
return table.cells.some((row, r) => r !== first - 1 && r !== first && pairs.every((p) => {
|
|
696
745
|
const anchor = owner[r][p.c], peer = row[p.c];
|
|
697
|
-
return _optionalChain([anchor, 'optionalAccess',
|
|
746
|
+
return _optionalChain([anchor, 'optionalAccess', _59 => _59.r]) === r && anchor.c === p.c && anchor.rs === 1 && anchor.cs === p.cs && plain(peer) && norm(textOf(peer), p === main) === norm(textOf(p.upper) + "\n" + textOf(p.lower), p === main);
|
|
698
747
|
}));
|
|
699
748
|
}
|
|
700
749
|
function matchesCompleteRubricRow(table, owner, first) {
|
|
@@ -728,7 +777,7 @@ function matchesCompleteRubricRow(table, owner, first) {
|
|
|
728
777
|
return table.cells.some((row, r) => {
|
|
729
778
|
if (r === first - 1 || r === first || !pairs.every((p) => {
|
|
730
779
|
const a = owner[r][p.c];
|
|
731
|
-
return _optionalChain([a, 'optionalAccess',
|
|
780
|
+
return _optionalChain([a, 'optionalAccess', _60 => _60.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && plain(row[p.c]);
|
|
732
781
|
})) return false;
|
|
733
782
|
const peer = textOf(row[main.c]), peerMarks = items(peer);
|
|
734
783
|
return peerMarks.length === marks.length && peerMarks.every((m, i) => m.n === marks[i].n) && values(row[score.c]).join("|") === scores.join("|") && norm(peer.slice(peerMarks[peerMarks.length - 1].at)) === tail;
|
|
@@ -750,11 +799,11 @@ function hasNumberedRowSequence(table, owner, first) {
|
|
|
750
799
|
if (first < 3) return false;
|
|
751
800
|
const rows = [first - 3, first - 2, first - 1, first];
|
|
752
801
|
const separate = (c, cs) => rows.every((r) => {
|
|
753
|
-
const a = _optionalChain([owner, 'access',
|
|
754
|
-
return _optionalChain([a, 'optionalAccess',
|
|
802
|
+
const a = _optionalChain([owner, 'access', _61 => _61[r], 'optionalAccess', _62 => _62[c]]), cell = _optionalChain([table, 'access', _63 => _63.cells, 'access', _64 => _64[r], 'optionalAccess', _65 => _65[c]]);
|
|
803
|
+
return _optionalChain([a, 'optionalAccess', _66 => _66.r]) === r && a.c === c && a.rs === 1 && a.cs === cs && !!cell && plain(cell) && !!textOf(cell);
|
|
755
804
|
});
|
|
756
805
|
for (let c = 0; c < table.cols; c++) {
|
|
757
|
-
const a = _optionalChain([owner, 'access',
|
|
806
|
+
const a = _optionalChain([owner, 'access', _67 => _67[first], 'optionalAccess', _68 => _68[c]]);
|
|
758
807
|
if (!a || !separate(c, a.cs)) continue;
|
|
759
808
|
const marks = rows.map((r) => {
|
|
760
809
|
const lines = textOf(table.cells[r][c]).split("\n"), firstMark = itemMark(lines[0]);
|
|
@@ -763,7 +812,7 @@ function hasNumberedRowSequence(table, owner, first) {
|
|
|
763
812
|
const head = marks[0];
|
|
764
813
|
if (!head || marks.some((m, i) => !m || m.style !== head.style || m.n !== head.n + i)) continue;
|
|
765
814
|
for (let d = 0; d < table.cols; d++) {
|
|
766
|
-
const side = _optionalChain([owner, 'access',
|
|
815
|
+
const side = _optionalChain([owner, 'access', _69 => _69[first], 'optionalAccess', _70 => _70[d]]);
|
|
767
816
|
if (side && (d + side.cs <= c || d >= c + a.cs) && separate(d, side.cs)) return true;
|
|
768
817
|
}
|
|
769
818
|
}
|
|
@@ -836,7 +885,7 @@ var CELL_SPLITS = /* @__PURE__ */ new WeakMap();
|
|
|
836
885
|
function relocate(src, dst, from = 0) {
|
|
837
886
|
const out = [];
|
|
838
887
|
for (const s of _nullishCoalesce(CELL_SPLITS.get(src), () => ( []))) {
|
|
839
|
-
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access',
|
|
888
|
+
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access', _71 => _71.at, 'call', _72 => _72(-1), 'optionalAccess', _73 => _73.at]), () => ( 0))));
|
|
840
889
|
if (at >= 0) out.push({ at, page: s.page });
|
|
841
890
|
}
|
|
842
891
|
return out;
|
|
@@ -860,7 +909,7 @@ function rowStarts(t) {
|
|
|
860
909
|
const starts = [];
|
|
861
910
|
for (let c = 0; c < t.cols; c++) {
|
|
862
911
|
if (covered.has(r * 1e5 + c)) continue;
|
|
863
|
-
const cell = _optionalChain([t, 'access',
|
|
912
|
+
const cell = _optionalChain([t, 'access', _74 => _74.cells, 'access', _75 => _75[r], 'optionalAccess', _76 => _76[c]]);
|
|
864
913
|
if (!cell) continue;
|
|
865
914
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) if (dr || dc) covered.add((r + dr) * 1e5 + c + dc);
|
|
866
915
|
starts.push({ cell, c });
|
|
@@ -871,8 +920,8 @@ function rowStarts(t) {
|
|
|
871
920
|
}
|
|
872
921
|
var covering = (t, r) => rowStarts(t).slice(0, r + 1).flatMap((starts, rr) => starts.filter((s) => rr + s.cell.rowSpan > r).map((s) => s.cell));
|
|
873
922
|
function cellPage(cell) {
|
|
874
|
-
const p =
|
|
875
|
-
if (p !== void 0 || !_optionalChain([cell, 'access',
|
|
923
|
+
const p = _chunkK2NWHLCDcjs.CELL_PAGES.get(cell);
|
|
924
|
+
if (p !== void 0 || !_optionalChain([cell, 'access', _77 => _77.blocks, 'optionalAccess', _78 => _78.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
876
925
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
877
926
|
}
|
|
878
927
|
function tableRowPages(t, pageNumber) {
|
|
@@ -883,7 +932,7 @@ function tableRowPages(t, pageNumber) {
|
|
|
883
932
|
for (const { cell } of starts) {
|
|
884
933
|
const p = cellPage(cell);
|
|
885
934
|
if (p !== void 0) mark = Math.max(_nullishCoalesce(mark, () => ( p)), p);
|
|
886
|
-
else if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
935
|
+
else if (cell.text.trim() || _optionalChain([cell, 'access', _79 => _79.blocks, 'optionalAccess', _80 => _80.length])) text = true;
|
|
887
936
|
}
|
|
888
937
|
const page = _nullishCoalesce(mark, () => ( (text ? pageNumber : prev)));
|
|
889
938
|
prev = page !== void 0 && prev !== void 0 ? Math.max(prev, page) : _nullishCoalesce(page, () => ( prev));
|
|
@@ -900,8 +949,8 @@ function markJoinedPages(table, prev, curr) {
|
|
|
900
949
|
rows.forEach((starts, r) => {
|
|
901
950
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
902
951
|
for (const { cell } of starts) {
|
|
903
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
904
|
-
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess',
|
|
952
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkK2NWHLCDcjs.CELL_PAGES.set(cell, page2);
|
|
953
|
+
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _81 => _81.find, 'call', _82 => _82((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
|
|
905
954
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
906
955
|
}
|
|
907
956
|
});
|
|
@@ -911,7 +960,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
911
960
|
for (const { cell } of ctRows[cr]) for (const b of _nullishCoalesce(cell.blocks, () => ( []))) b.pageNumber ??= page;
|
|
912
961
|
const heads = covering(pt, pt.rows - 1);
|
|
913
962
|
for (const cell of covering(table, pt.rows - 1)) {
|
|
914
|
-
if (_optionalChain([cell, 'access',
|
|
963
|
+
if (_optionalChain([cell, 'access', _83 => _83.blocks, 'optionalAccess', _84 => _84.length])) continue;
|
|
915
964
|
const head = heads.filter((h) => h.text.trim() && cell.text.startsWith(h.text.trimEnd()) && cell.text.trim().length > h.text.trim().length).sort((a, b) => b.text.length - a.text.length)[0];
|
|
916
965
|
if (!head) continue;
|
|
917
966
|
const from = head.text.trimEnd().length;
|
|
@@ -922,7 +971,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
922
971
|
}
|
|
923
972
|
function splitCell(cell, page) {
|
|
924
973
|
if (page === void 0) return null;
|
|
925
|
-
if (_optionalChain([cell, 'access',
|
|
974
|
+
if (_optionalChain([cell, 'access', _85 => _85.blocks, 'optionalAccess', _86 => _86.length])) {
|
|
926
975
|
const k2 = cell.blocks.findIndex((b) => (_nullishCoalesce(b.pageNumber, () => ( page))) > page);
|
|
927
976
|
if (k2 <= 0) return null;
|
|
928
977
|
const head = cell.blocks.slice(0, k2), tail = cell.blocks.slice(k2);
|
|
@@ -949,8 +998,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
949
998
|
if (!splits.length) continue;
|
|
950
999
|
const clone = (cell, patch) => {
|
|
951
1000
|
const out = { ...cell, ...patch };
|
|
952
|
-
const p =
|
|
953
|
-
if (p !== void 0)
|
|
1001
|
+
const p = _chunkK2NWHLCDcjs.CELL_PAGES.get(cell);
|
|
1002
|
+
if (p !== void 0) _chunkK2NWHLCDcjs.CELL_PAGES.set(out, p);
|
|
954
1003
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
955
1004
|
return out;
|
|
956
1005
|
};
|
|
@@ -960,7 +1009,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
960
1009
|
for (const { cell, c, split } of splits) {
|
|
961
1010
|
cells[r][c] = clone(cell, split.head);
|
|
962
1011
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
963
|
-
|
|
1012
|
+
_chunkK2NWHLCDcjs.CELL_PAGES.set(tail, split.page);
|
|
964
1013
|
setSplits(tail, split.rest);
|
|
965
1014
|
row[c] = tail;
|
|
966
1015
|
}
|
|
@@ -1002,7 +1051,7 @@ function anchorsOf(table) {
|
|
|
1002
1051
|
for (let r = 0; r < table.rows; r++) {
|
|
1003
1052
|
for (let c = 0; c < table.cols; c++) {
|
|
1004
1053
|
if (covered.has(r * 1e5 + c)) continue;
|
|
1005
|
-
const cell = _optionalChain([table, 'access',
|
|
1054
|
+
const cell = _optionalChain([table, 'access', _87 => _87.cells, 'access', _88 => _88[r], 'optionalAccess', _89 => _89[c]]);
|
|
1006
1055
|
if (!cell) continue;
|
|
1007
1056
|
out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
|
|
1008
1057
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
@@ -1079,24 +1128,24 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1079
1128
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
1080
1129
|
}
|
|
1081
1130
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
1082
|
-
const lines =
|
|
1083
|
-
if (lines)
|
|
1084
|
-
if (
|
|
1085
|
-
const edges =
|
|
1131
|
+
const lines = _chunk4X7AR4EHcjs.CELL_LINES.get(a.cell);
|
|
1132
|
+
if (lines) _chunk4X7AR4EHcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
1133
|
+
if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(a.cell)) _chunk4X7AR4EHcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
1134
|
+
const edges = _chunkK2NWHLCDcjs.CELL_EDGES.get(a.cell);
|
|
1086
1135
|
if (edges) {
|
|
1087
|
-
|
|
1136
|
+
_chunkK2NWHLCDcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
1088
1137
|
edged = true;
|
|
1089
1138
|
}
|
|
1090
1139
|
return true;
|
|
1091
1140
|
};
|
|
1092
|
-
for (const a of pa) if (!
|
|
1141
|
+
for (const a of pa) if (!_chunk4X7AR4EHcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
1093
1142
|
for (const a of ca) {
|
|
1094
|
-
if (a.r < skip ||
|
|
1143
|
+
if (a.r < skip || _chunk4X7AR4EHcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
1095
1144
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
1096
1145
|
}
|
|
1097
1146
|
const first = prev.rows;
|
|
1098
1147
|
for (let c = 0; c < cols; c++) {
|
|
1099
|
-
const above = _optionalChain([owner, 'access',
|
|
1148
|
+
const above = _optionalChain([owner, 'access', _90 => _90[first - 1], 'optionalAccess', _91 => _91[c]]);
|
|
1100
1149
|
if (!above) continue;
|
|
1101
1150
|
let r = first;
|
|
1102
1151
|
while (r < rows && owner[r][c] === null) r++;
|
|
@@ -1115,9 +1164,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1115
1164
|
const grown = { ...above, rs: newRs };
|
|
1116
1165
|
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;
|
|
1117
1166
|
}
|
|
1118
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1167
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunk4X7AR4EHcjs.FILLER_CELLS.add(grid[r][c]);
|
|
1119
1168
|
if (edged) {
|
|
1120
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1169
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkK2NWHLCDcjs.CELL_EDGES.set(grid[r][c], _chunk4X7AR4EHcjs.NO_EDGES);
|
|
1121
1170
|
}
|
|
1122
1171
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1123
1172
|
let r = prev.rows;
|
|
@@ -1126,7 +1175,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1126
1175
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1127
1176
|
}
|
|
1128
1177
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1129
|
-
const pr =
|
|
1178
|
+
const pr = _chunk4X7AR4EHcjs.ROW_RULES.get(prev), cr = _chunk4X7AR4EHcjs.ROW_RULES.get(curr);
|
|
1130
1179
|
const shifted = dx !== 0;
|
|
1131
1180
|
const cut = {
|
|
1132
1181
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1137,7 +1186,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1137
1186
|
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 });
|
|
1138
1187
|
if (pr && cr) {
|
|
1139
1188
|
const cutRuled = pr.bottom || cr.top;
|
|
1140
|
-
|
|
1189
|
+
_chunk4X7AR4EHcjs.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) });
|
|
1141
1190
|
}
|
|
1142
1191
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1143
1192
|
}
|
|
@@ -1198,19 +1247,19 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1198
1247
|
c = u.c + u.cs;
|
|
1199
1248
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1200
1249
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1201
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1202
|
-
const openSeam = hasContent(a) && hasContent(b) &&
|
|
1250
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunk4X7AR4EHcjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
1251
|
+
const openSeam = hasContent(a) && hasContent(b) && _chunk4X7AR4EHcjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
|
|
1203
1252
|
if (!r || r === first) return false;
|
|
1204
1253
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1205
1254
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1206
|
-
const ue =
|
|
1255
|
+
const ue = _chunkK2NWHLCDcjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkK2NWHLCDcjs.CELL_EDGES.get(table.cells[down.r][down.c]);
|
|
1207
1256
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1208
1257
|
});
|
|
1209
1258
|
if (!openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1210
1259
|
if (!straddles && !midWord) continue;
|
|
1211
1260
|
if (u.r >= last && d.rs < 2) continue;
|
|
1212
|
-
const U =
|
|
1213
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1261
|
+
const U = _chunk4X7AR4EHcjs.CELL_LINES.get(a);
|
|
1262
|
+
if (!_optionalChain([U, 'optionalAccess', _92 => _92.length]) || !hasContent(b)) continue;
|
|
1214
1263
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1215
1264
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
1216
1265
|
const lu = U[U.length - 1];
|
|
@@ -1227,7 +1276,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1227
1276
|
return merged;
|
|
1228
1277
|
}
|
|
1229
1278
|
function longLastLine(c) {
|
|
1230
|
-
const L =
|
|
1279
|
+
const L = _chunk4X7AR4EHcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _93 => _93[L.length - 1]]);
|
|
1231
1280
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1232
1281
|
}
|
|
1233
1282
|
function filledToBottom(U, bottom) {
|
|
@@ -1260,8 +1309,8 @@ function nextItemHead(prev, next) {
|
|
|
1260
1309
|
return false;
|
|
1261
1310
|
}
|
|
1262
1311
|
function continuesAcross(u, d, x1, x2) {
|
|
1263
|
-
const U =
|
|
1264
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1312
|
+
const U = _chunk4X7AR4EHcjs.CELL_LINES.get(u), D = _chunk4X7AR4EHcjs.CELL_LINES.get(d);
|
|
1313
|
+
if (!_optionalChain([U, 'optionalAccess', _94 => _94.length]) || !_optionalChain([D, 'optionalAccess', _95 => _95.length])) return false;
|
|
1265
1314
|
const last = U[U.length - 1];
|
|
1266
1315
|
const fs = last.h || 10;
|
|
1267
1316
|
let minL = Infinity, maxR = -Infinity;
|
|
@@ -1278,7 +1327,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1278
1327
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1279
1328
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1280
1329
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1281
|
-
const newItem =
|
|
1330
|
+
const newItem = _chunk4X7AR4EHcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1282
1331
|
const all = D.length ? U.concat(D) : U;
|
|
1283
1332
|
const leftAligned = (l) => maxR - l.r > SHORT_LINE_GAP * fs && (l.l - minL <= fs || !newItem && all.some((o) => o !== l && Math.abs(o.l - l.l) <= HANGING_TOL && Math.abs(o.r - l.r) >= HANGING_MIN * fs));
|
|
1284
1333
|
const hanging = U.length >= 2 && U.every((l) => maxR - l.r <= FULL_LINE_TOL * fs) && indented && Math.abs(D[0].l - last.l) <= HANGING_TOL;
|
|
@@ -1295,12 +1344,12 @@ function outlineContinues(u, d) {
|
|
|
1295
1344
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1296
1345
|
}
|
|
1297
1346
|
function lineEnded(c, x1, x2, next) {
|
|
1298
|
-
const L =
|
|
1347
|
+
const L = _chunk4X7AR4EHcjs.CELL_LINES.get(c);
|
|
1299
1348
|
if (!L || L.length !== 1) return false;
|
|
1300
1349
|
const l = L[0], h = l.h || 10;
|
|
1301
|
-
const d0 = next ? _optionalChain([
|
|
1350
|
+
const d0 = next ? _optionalChain([_chunk4X7AR4EHcjs.CELL_LINES, 'access', _96 => _96.get, 'call', _97 => _97(next), 'optionalAccess', _98 => _98[0]]) : void 0;
|
|
1302
1351
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1303
|
-
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
1352
|
+
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _99 => _99.text]), () => ( "")))) * h;
|
|
1304
1353
|
}
|
|
1305
1354
|
function firstWordUnits(text) {
|
|
1306
1355
|
const word = _nullishCoalesce(flowText(text).trim().replace(/^([(\[「『<〈])\s+/, "$1").split(/\s+/)[0], () => ( ""));
|
|
@@ -1309,15 +1358,15 @@ function firstWordUnits(text) {
|
|
|
1309
1358
|
return units;
|
|
1310
1359
|
}
|
|
1311
1360
|
function appendCell(a, b) {
|
|
1312
|
-
if (
|
|
1313
|
-
if (_optionalChain([a, 'access',
|
|
1314
|
-
const asBlocks = (c) => _optionalChain([c, 'access',
|
|
1361
|
+
if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(b)) _chunk4X7AR4EHcjs.IMAGE_CELLS.add(a);
|
|
1362
|
+
if (_optionalChain([a, 'access', _100 => _100.blocks, 'optionalAccess', _101 => _101.length]) || _optionalChain([b, 'access', _102 => _102.blocks, 'optionalAccess', _103 => _103.length])) {
|
|
1363
|
+
const asBlocks = (c) => _optionalChain([c, 'access', _104 => _104.blocks, 'optionalAccess', _105 => _105.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
|
|
1315
1364
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1316
1365
|
}
|
|
1317
1366
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1318
|
-
|
|
1367
|
+
_chunk4X7AR4EHcjs.joinCellEdges.call(void 0, a, b);
|
|
1319
1368
|
}
|
|
1320
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access',
|
|
1369
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _106 => _106.blocks, 'optionalAccess', _107 => _107.length]) || _chunk4X7AR4EHcjs.IMAGE_CELLS.has(cell);
|
|
1321
1370
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1322
1371
|
var batchim = (ch) => {
|
|
1323
1372
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1325,7 +1374,7 @@ var batchim = (ch) => {
|
|
|
1325
1374
|
};
|
|
1326
1375
|
function clauseContinues(u, d) {
|
|
1327
1376
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1328
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1377
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunk4X7AR4EHcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1329
1378
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1330
1379
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1331
1380
|
}
|
|
@@ -1333,8 +1382,8 @@ function quantityContinues(u, d) {
|
|
|
1333
1382
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1334
1383
|
}
|
|
1335
1384
|
function wordOverflows(u, d, x1, x2) {
|
|
1336
|
-
const U =
|
|
1337
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1385
|
+
const U = _chunk4X7AR4EHcjs.CELL_LINES.get(u);
|
|
1386
|
+
if (!_optionalChain([U, 'optionalAccess', _108 => _108.length]) || _chunk4X7AR4EHcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1338
1387
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1339
1388
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1340
1389
|
}
|
|
@@ -1344,7 +1393,7 @@ function listContinues(u, d, multi = false) {
|
|
|
1344
1393
|
const marks = u.text.split("\n").map((l) => itemMark(l.trim()));
|
|
1345
1394
|
let last = -1, count = 0;
|
|
1346
1395
|
marks.forEach((m, i) => {
|
|
1347
|
-
if (_optionalChain([m, 'optionalAccess',
|
|
1396
|
+
if (_optionalChain([m, 'optionalAccess', _109 => _109.style]) === head.style) {
|
|
1348
1397
|
last = i;
|
|
1349
1398
|
count++;
|
|
1350
1399
|
}
|
|
@@ -1392,13 +1441,13 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1392
1441
|
if (!carriedSplit) {
|
|
1393
1442
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1394
1443
|
if (pairs.some(([u, d]) => hasContent(d.cell) && norm(cell(d)) !== norm(cell(u)) && lineEnded(cell(u), colXs[u.c], colXs[u.c + u.cs], cell(d)))) return false;
|
|
1395
|
-
const oneLine = (c) => _optionalChain([
|
|
1444
|
+
const oneLine = (c) => _optionalChain([_chunk4X7AR4EHcjs.CELL_LINES, 'access', _110 => _110.get, 'call', _111 => _111(c), 'optionalAccess', _112 => _112.length]) === 1;
|
|
1396
1445
|
if (pairs.some(([u, d]) => nextItemHead(cell(u).text, cell(d).text)) && pairs.some(([u, d]) => hasContent(u.cell) && hasContent(d.cell) && oneLine(cell(u)) && oneLine(cell(d)) && norm(cell(u)) !== norm(cell(d)))) return false;
|
|
1397
1446
|
const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d)) || quantityContinues(cell(u), cell(d));
|
|
1398
1447
|
if (!(cut.open && !newCell)) {
|
|
1399
1448
|
if (pairs.some((p) => p[1].rs > 1 && !flows(p))) return false;
|
|
1400
1449
|
const one = pairs.filter(([, d]) => d.rs === 1);
|
|
1401
|
-
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;
|
|
1450
|
+
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;
|
|
1402
1451
|
}
|
|
1403
1452
|
}
|
|
1404
1453
|
for (const [u, d] of pairs) {
|
|
@@ -1423,8 +1472,8 @@ function besideOwn(b, p, c) {
|
|
|
1423
1472
|
}
|
|
1424
1473
|
var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
|
|
1425
1474
|
function pageNumberBetween(b, p, c, pageHeights) {
|
|
1426
|
-
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
1427
|
-
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess',
|
|
1475
|
+
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _113 => _113.text, 'optionalAccess', _114 => _114.trim, 'call', _115 => _115()]), () => ( "")))) return false;
|
|
1476
|
+
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _116 => _116.get, 'call', _117 => _117(b.pageNumber)]) : void 0;
|
|
1428
1477
|
if (!h) return false;
|
|
1429
1478
|
if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
|
|
1430
1479
|
if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
|
|
@@ -1448,7 +1497,7 @@ function insideTable(b, t) {
|
|
|
1448
1497
|
return b.bbox.x >= o.x - 1 && b.bbox.x + b.bbox.width <= o.x + o.width + 1 && b.bbox.y >= o.y - 1 && b.bbox.y + b.bbox.height <= o.y + o.height + 1;
|
|
1449
1498
|
}
|
|
1450
1499
|
function startsWithUnitRow(table) {
|
|
1451
|
-
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access',
|
|
1500
|
+
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _118 => _118.cells, 'access', _119 => _119[0], 'optionalAccess', _120 => _120[0], 'optionalAccess', _121 => _121.text]), () => ( ""))) && _optionalChain([table, 'access', _122 => _122.cells, 'access', _123 => _123[0], 'optionalAccess', _124 => _124.slice, 'call', _125 => _125(1), 'access', _126 => _126.every, 'call', _127 => _127((c) => !c.text.trim())]);
|
|
1452
1501
|
}
|
|
1453
1502
|
function sameHeadShape(a, b) {
|
|
1454
1503
|
if (!a || !b || a.length !== b.length) return false;
|
|
@@ -1460,7 +1509,7 @@ function sameHeadShape(a, b) {
|
|
|
1460
1509
|
return tall;
|
|
1461
1510
|
}
|
|
1462
1511
|
function hasBoxTitle(t) {
|
|
1463
|
-
const titles = _nullishCoalesce(_optionalChain([t, 'access',
|
|
1512
|
+
const titles = _nullishCoalesce(_optionalChain([t, 'access', _128 => _128.cells, 'access', _129 => _129[0], 'optionalAccess', _130 => _130.filter, 'call', _131 => _131((c) => c.text.trim())]), () => ( []));
|
|
1464
1513
|
if (titles.length !== 1 || titles[0].rowSpan < 2) return false;
|
|
1465
1514
|
const body = t.cells[titles[0].rowSpan];
|
|
1466
1515
|
return !!body && body[0].colSpan === t.cols && !!body[0].text.trim();
|
|
@@ -1474,7 +1523,7 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1474
1523
|
const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
|
|
1475
1524
|
while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
|
|
1476
1525
|
const curr = blocks[j];
|
|
1477
|
-
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess',
|
|
1526
|
+
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _132 => _132.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
|
|
1478
1527
|
if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
|
|
1479
1528
|
if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
|
|
1480
1529
|
if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
|
|
@@ -1484,19 +1533,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1484
1533
|
placeJoined(blocks, i, j, joined);
|
|
1485
1534
|
continue;
|
|
1486
1535
|
}
|
|
1487
|
-
if (
|
|
1536
|
+
if (_chunk4X7AR4EHcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1488
1537
|
blocks.splice(j, 1);
|
|
1489
1538
|
i++;
|
|
1490
1539
|
continue;
|
|
1491
1540
|
}
|
|
1492
1541
|
if (joined === null) continue;
|
|
1493
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1542
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunk4X7AR4EHcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1494
1543
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1495
1544
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1496
1545
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1497
1546
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1498
|
-
const px =
|
|
1499
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1547
|
+
const px = _chunk4X7AR4EHcjs.TABLE_COLXS.get(prev.table), cx = _chunk4X7AR4EHcjs.TABLE_COLXS.get(curr.table);
|
|
1548
|
+
if (px && cx && !shiftedSame(px, cx, !_chunk4X7AR4EHcjs.CLIP_TABLES.has(prev.table) && !_chunk4X7AR4EHcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1500
1549
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1501
1550
|
let currCells = curr.table.cells;
|
|
1502
1551
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1507,16 +1556,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1507
1556
|
blocks.splice(j, 1);
|
|
1508
1557
|
continue;
|
|
1509
1558
|
}
|
|
1510
|
-
if (px && cx && !
|
|
1559
|
+
if (px && cx && !_chunk4X7AR4EHcjs.CLIP_TABLES.has(prev.table) && !_chunk4X7AR4EHcjs.CLIP_TABLES.has(curr.table) && currCells.length < curr.table.cells.length && curr.table.cells[0].filter((c) => c.text.trim()).length >= 2 && prev.table.cells.at(-1).concat(currCells[0]).every((c) => c.rowSpan === 1 && c.colSpan === 1 && _chunk4X7AR4EHcjs.CELL_LINES.has(c))) {
|
|
1511
1560
|
const dx = px[0] - cx[0];
|
|
1512
1561
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1513
|
-
if (_optionalChain([part, 'optionalAccess',
|
|
1562
|
+
if (_optionalChain([part, 'optionalAccess', _133 => _133.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1514
1563
|
const last = prev.table.rows - 1;
|
|
1515
1564
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1516
|
-
const U =
|
|
1517
|
-
|
|
1565
|
+
const U = _chunk4X7AR4EHcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunk4X7AR4EHcjs.CELL_LINES.get(currCells[0][c]);
|
|
1566
|
+
_chunk4X7AR4EHcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1518
1567
|
}
|
|
1519
|
-
|
|
1568
|
+
_chunk4X7AR4EHcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1520
1569
|
placeJoined(blocks, i, j, part.table);
|
|
1521
1570
|
continue;
|
|
1522
1571
|
}
|
|
@@ -1529,20 +1578,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1529
1578
|
caption: prev.table.caption,
|
|
1530
1579
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1531
1580
|
};
|
|
1532
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1533
|
-
if (
|
|
1581
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunk4X7AR4EHcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1582
|
+
if (_chunk4X7AR4EHcjs.CLIP_TABLES.has(prev.table) || _chunk4X7AR4EHcjs.CLIP_TABLES.has(curr.table)) _chunk4X7AR4EHcjs.CLIP_TABLES.add(merged);
|
|
1534
1583
|
placeJoined(blocks, i, j, merged);
|
|
1535
1584
|
}
|
|
1536
1585
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1537
1586
|
const t = blocks[i].table;
|
|
1538
|
-
if (blocks[i].type === "table" && t &&
|
|
1587
|
+
if (blocks[i].type === "table" && t && _chunk4X7AR4EHcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1539
1588
|
}
|
|
1540
1589
|
}
|
|
1541
1590
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1542
1591
|
if (!pageHeights) return;
|
|
1543
1592
|
for (let i = 0; i < blocks.length; i++) {
|
|
1544
1593
|
const L = blocks[i];
|
|
1545
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1594
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(L.table) || _chunk4X7AR4EHcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1546
1595
|
const ph = pageHeights.get(L.pageNumber);
|
|
1547
1596
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1548
1597
|
let s0 = i, s1 = i;
|
|
@@ -1571,12 +1620,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1571
1620
|
}
|
|
1572
1621
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1573
1622
|
const pt = prev.table, ct = curr.table;
|
|
1574
|
-
if (!
|
|
1575
|
-
const px =
|
|
1623
|
+
if (!_chunk4X7AR4EHcjs.CLIP_TABLES.has(pt) || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(ct)) return null;
|
|
1624
|
+
const px = _chunk4X7AR4EHcjs.TABLE_COLXS.get(pt), cx = _chunk4X7AR4EHcjs.TABLE_COLXS.get(ct);
|
|
1576
1625
|
if (!px || !cx) return null;
|
|
1577
1626
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1578
1627
|
if (!shiftedSame(px, cx, false)) {
|
|
1579
|
-
if (!_optionalChain([pageHeights, 'optionalAccess',
|
|
1628
|
+
if (!_optionalChain([pageHeights, 'optionalAccess', _134 => _134.get, 'call', _135 => _135(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _136 => _136.get, 'call', _137 => _137(curr.pageNumber)])) return null;
|
|
1580
1629
|
dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1581
1630
|
within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1582
1631
|
if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
|
|
@@ -1588,19 +1637,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1588
1637
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1589
1638
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1590
1639
|
};
|
|
1591
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1640
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunk4X7AR4EHcjs.PART_COLXS.get(ct), () => ( cx))) && (headingRow(_nullishCoalesce(ct.cells[0], () => ( []))) || px.length > FOREIGN_FIRST_ROW_CELLS && anchorsOf(ct).filter((a) => a.r === 0).length >= FOREIGN_FIRST_ROW_CELLS);
|
|
1592
1641
|
}
|
|
1593
|
-
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access',
|
|
1642
|
+
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _138 => _138.bbox, 'optionalAccess', _139 => _139.y]), lex);
|
|
1594
1643
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1595
|
-
|
|
1596
|
-
const ys =
|
|
1597
|
-
if (ys)
|
|
1598
|
-
|
|
1599
|
-
|
|
1644
|
+
_chunk4X7AR4EHcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1645
|
+
const ys = _chunk4X7AR4EHcjs.TABLE_ROWYS.get(pt);
|
|
1646
|
+
if (ys) _chunk4X7AR4EHcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1647
|
+
_chunk4X7AR4EHcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunk4X7AR4EHcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1648
|
+
_chunk4X7AR4EHcjs.CLIP_TABLES.add(res.table);
|
|
1600
1649
|
return res.table;
|
|
1601
1650
|
}
|
|
1602
1651
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
1603
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1652
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _140 => _140.get, 'call', _141 => _141(prev.pageNumber)]);
|
|
1604
1653
|
if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
|
|
1605
1654
|
return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
|
|
1606
1655
|
}
|
|
@@ -1611,21 +1660,21 @@ function headingRow(row) {
|
|
|
1611
1660
|
}
|
|
1612
1661
|
var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
|
|
1613
1662
|
function looksContinued(prev, curr, pageHeights) {
|
|
1614
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1663
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _142 => _142.get, 'call', _143 => _143(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _144 => _144.get, 'call', _145 => _145(curr.pageNumber)]);
|
|
1615
1664
|
if (ph && ch && (prev.bbox.y > ph * PAGE_EDGE_BAND && !pushedLead(prev, curr) || curr.bbox.y + curr.bbox.height < ch * (1 - PAGE_EDGE_BAND))) return false;
|
|
1616
1665
|
const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
|
|
1617
|
-
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access',
|
|
1666
|
+
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _146 => _146.find, 'call', _147 => _147((c) => c.text.trim()), 'optionalAccess', _148 => _148.text]), () => ( ""));
|
|
1618
1667
|
if (!ANNEX_HEAD_RE.test(firstText)) return true;
|
|
1619
1668
|
const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
|
|
1620
1669
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1621
1670
|
}
|
|
1622
1671
|
function pushedLead(prev, curr) {
|
|
1623
|
-
if (!
|
|
1672
|
+
if (!_chunk4X7AR4EHcjs.CLIP_TABLES.has(prev.table) || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1624
1673
|
const lead = leadRows(curr.table);
|
|
1625
1674
|
return lead.image && lead.height > prev.bbox.y;
|
|
1626
1675
|
}
|
|
1627
1676
|
function leadRows(t) {
|
|
1628
|
-
const ys =
|
|
1677
|
+
const ys = _chunk4X7AR4EHcjs.TABLE_ROWYS.get(t);
|
|
1629
1678
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1630
1679
|
const anchors = anchorsOf(t);
|
|
1631
1680
|
let end = 1, image = false;
|
|
@@ -1633,17 +1682,17 @@ function leadRows(t) {
|
|
|
1633
1682
|
for (const a of anchors) {
|
|
1634
1683
|
if (a.r !== r) continue;
|
|
1635
1684
|
end = Math.max(end, r + a.rs);
|
|
1636
|
-
if (
|
|
1685
|
+
if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1637
1686
|
}
|
|
1638
1687
|
}
|
|
1639
1688
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1640
1689
|
}
|
|
1641
1690
|
function tailOf(b) {
|
|
1642
|
-
const t = b.table &&
|
|
1691
|
+
const t = b.table && _chunk4X7AR4EHcjs.TABLE_TAIL.get(b.table);
|
|
1643
1692
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1644
1693
|
}
|
|
1645
1694
|
function firstRowSig(t) {
|
|
1646
|
-
const x =
|
|
1695
|
+
const x = _chunk4X7AR4EHcjs.TABLE_COLXS.get(t);
|
|
1647
1696
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1648
1697
|
return anchorsOf(t).filter((a) => a.r === 0).map((a) => ({ x1: x[a.c], x2: x[a.c + a.cs], t: flowText(a.cell.text).replace(/\s+/g, "") }));
|
|
1649
1698
|
}
|
|
@@ -1668,9 +1717,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
|
|
|
1668
1717
|
}
|
|
1669
1718
|
function restartsTitledForm(head, curr) {
|
|
1670
1719
|
if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
|
|
1671
|
-
const full = (t) => _optionalChain([t, 'access',
|
|
1720
|
+
const full = (t) => _optionalChain([t, 'access', _149 => _149.cells, 'access', _150 => _150[0], 'access', _151 => _151[0], 'optionalAccess', _152 => _152.colSpan]) === t.cols;
|
|
1672
1721
|
if (!full(head) || !full(curr)) return false;
|
|
1673
|
-
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
1722
|
+
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _153 => _153.text]), () => ( ""))).replace(/\s+/g, "");
|
|
1674
1723
|
const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
|
|
1675
1724
|
if (!ht || !ct || ht === ct) return false;
|
|
1676
1725
|
const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
|
|
@@ -1696,7 +1745,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1696
1745
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1697
1746
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1698
1747
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1699
|
-
const px =
|
|
1748
|
+
const px = _chunk4X7AR4EHcjs.TABLE_COLXS.get(pb.table), cx = _chunk4X7AR4EHcjs.TABLE_COLXS.get(cur.table);
|
|
1700
1749
|
if (!px || !cx) break;
|
|
1701
1750
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1702
1751
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1713,7 +1762,7 @@ function continueRowSpans(prevCells, currCells) {
|
|
|
1713
1762
|
if (hasContent(cell) || (cell.rowSpan || 1) < 2) continue;
|
|
1714
1763
|
let anchor;
|
|
1715
1764
|
for (let r = last - 1; r >= 0 && !anchor; r--) {
|
|
1716
|
-
const a = _optionalChain([prevCells, 'access',
|
|
1765
|
+
const a = _optionalChain([prevCells, 'access', _154 => _154[r], 'optionalAccess', _155 => _155[c]]);
|
|
1717
1766
|
if (a && r + (a.rowSpan || 1) === last && (a.colSpan || 1) === (cell.colSpan || 1) && (hasContent(a) || a.rowSpan >= 2)) anchor = a;
|
|
1718
1767
|
}
|
|
1719
1768
|
if (!anchor) continue;
|
|
@@ -1767,12 +1816,12 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1767
1816
|
var COL_MATCH_TOL = 0.5;
|
|
1768
1817
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1769
1818
|
function lastRowCell(t, x1, x2) {
|
|
1770
|
-
const xs =
|
|
1819
|
+
const xs = _chunk4X7AR4EHcjs.TABLE_COLXS.get(t);
|
|
1771
1820
|
const covered = /* @__PURE__ */ new Set();
|
|
1772
1821
|
for (let r = 0; r < t.rows; r++) {
|
|
1773
1822
|
for (let c = 0; c < t.cols; c++) {
|
|
1774
1823
|
if (covered.has(r * 1e5 + c)) continue;
|
|
1775
|
-
const cell = _optionalChain([t, 'access',
|
|
1824
|
+
const cell = _optionalChain([t, 'access', _156 => _156.cells, 'access', _157 => _157[r], 'optionalAccess', _158 => _158[c]]);
|
|
1776
1825
|
if (!cell) continue;
|
|
1777
1826
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
|
|
1778
1827
|
if (r + cell.rowSpan !== t.rows) continue;
|
|
@@ -1785,7 +1834,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1785
1834
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1786
1835
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1787
1836
|
const part = blocks[j];
|
|
1788
|
-
const from = part.table ?
|
|
1837
|
+
const from = part.table ? _chunk4X7AR4EHcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1789
1838
|
if (!from || !part.table) {
|
|
1790
1839
|
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
1791
1840
|
continue;
|
|
@@ -1795,18 +1844,18 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1795
1844
|
const prev = blocks[i];
|
|
1796
1845
|
if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
|
|
1797
1846
|
const cell = lastRowCell(prev.table, from.x1, from.x2);
|
|
1798
|
-
const add = _optionalChain([part, 'access',
|
|
1847
|
+
const add = _optionalChain([part, 'access', _159 => _159.table, 'access', _160 => _160.cells, 'access', _161 => _161[0], 'optionalAccess', _162 => _162[0]]);
|
|
1799
1848
|
if (!cell || !add) continue;
|
|
1800
1849
|
const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
|
|
1801
1850
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1802
1851
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1803
1852
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1804
|
-
if (
|
|
1805
|
-
|
|
1806
|
-
const lines =
|
|
1807
|
-
if (_optionalChain([lines, 'optionalAccess',
|
|
1808
|
-
if (part.pageNumber && part.bbox)
|
|
1809
|
-
if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
1853
|
+
if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(add)) _chunk4X7AR4EHcjs.IMAGE_CELLS.add(cell);
|
|
1854
|
+
_chunk4X7AR4EHcjs.joinCellEdges.call(void 0, cell, add);
|
|
1855
|
+
const lines = _chunk4X7AR4EHcjs.CELL_LINES.get(add);
|
|
1856
|
+
if (_optionalChain([lines, 'optionalAccess', _163 => _163.length])) _chunk4X7AR4EHcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunk4X7AR4EHcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1857
|
+
if (part.pageNumber && part.bbox) _chunk4X7AR4EHcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunk4X7AR4EHcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1858
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _164 => _164.blocks, 'optionalAccess', _165 => _165.length]) || _chunk4X7AR4EHcjs.IMAGE_CELLS.has(cell)) _chunk4X7AR4EHcjs.EMPTY_PARTS.delete(prev.table);
|
|
1810
1859
|
blocks.splice(j, 1);
|
|
1811
1860
|
if (cell.blocks && at > 0) {
|
|
1812
1861
|
const nextAt = cell.blocks[at];
|
|
@@ -1818,29 +1867,29 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1818
1867
|
}
|
|
1819
1868
|
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
1820
1869
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1821
|
-
if (!_optionalChain([prev, 'optionalAccess',
|
|
1822
|
-
const inner = _optionalChain([frame, 'access',
|
|
1823
|
-
const next = _optionalChain([inner, 'optionalAccess',
|
|
1824
|
-
if (!inner || !_optionalChain([next, 'optionalAccess',
|
|
1825
|
-
const px =
|
|
1870
|
+
if (!_optionalChain([prev, 'optionalAccess', _166 => _166.table]) || !_optionalChain([frame, 'optionalAccess', _167 => _167.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1871
|
+
const inner = _optionalChain([frame, 'access', _168 => _168.table, 'access', _169 => _169.cells, 'access', _170 => _170[0], 'optionalAccess', _171 => _171[0], 'optionalAccess', _172 => _172.blocks]);
|
|
1872
|
+
const next = _optionalChain([inner, 'optionalAccess', _173 => _173[0]]);
|
|
1873
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _174 => _174.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(prev.table) || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1874
|
+
const px = _chunk4X7AR4EHcjs.TABLE_COLXS.get(prev.table), nx = _chunk4X7AR4EHcjs.TABLE_COLXS.get(next.table);
|
|
1826
1875
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1827
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1876
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _175 => _175.get, 'call', _176 => _176(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _177 => _177.get, 'call', _178 => _178(next.pageNumber)]);
|
|
1828
1877
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
1829
|
-
if (splitOnly && (inner.length !== 1 || !_optionalChain([joinSplitParts, 'call',
|
|
1878
|
+
if (splitOnly && (inner.length !== 1 || !_optionalChain([joinSplitParts, 'call', _179 => _179(prev.table, px, next.table, nx, 0, prev.bbox.y), 'optionalAccess', _180 => _180.split]))) return;
|
|
1830
1879
|
blocks.splice(at, 1, ...inner);
|
|
1831
1880
|
}
|
|
1832
1881
|
function fillNestedContinuation(blocks, at) {
|
|
1833
1882
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1834
|
-
const t = _optionalChain([prev, 'optionalAccess',
|
|
1835
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1836
|
-
const xs =
|
|
1883
|
+
const t = _optionalChain([prev, 'optionalAccess', _181 => _181.table]), u = _optionalChain([next, 'optionalAccess', _182 => _182.table]);
|
|
1884
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(t) || !_chunk4X7AR4EHcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1885
|
+
const xs = _chunk4X7AR4EHcjs.TABLE_COLXS.get(u);
|
|
1837
1886
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1838
|
-
const add = _optionalChain([u, 'access',
|
|
1839
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access',
|
|
1887
|
+
const add = _optionalChain([u, 'access', _183 => _183.cells, 'access', _184 => _184[0], 'optionalAccess', _185 => _185[0]]);
|
|
1888
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _186 => _186.blocks, 'optionalAccess', _187 => _187.length]) || _chunk4X7AR4EHcjs.IMAGE_CELLS.has(cell)) return;
|
|
1840
1889
|
cell.text = add.text;
|
|
1841
1890
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1842
|
-
if (
|
|
1843
|
-
|
|
1891
|
+
if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(add)) _chunk4X7AR4EHcjs.IMAGE_CELLS.add(cell);
|
|
1892
|
+
_chunk4X7AR4EHcjs.joinCellEdges.call(void 0, cell, add);
|
|
1844
1893
|
blocks.splice(at, 1);
|
|
1845
1894
|
}
|
|
1846
1895
|
|
|
@@ -2013,7 +2062,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
2013
2062
|
if (!cache.has(key)) {
|
|
2014
2063
|
let sym = null;
|
|
2015
2064
|
try {
|
|
2016
|
-
const data = _optionalChain([fontObj, 'call',
|
|
2065
|
+
const data = _optionalChain([fontObj, 'call', _188 => _188(font), 'optionalAccess', _189 => _189.data]);
|
|
2017
2066
|
const code = glyph.fontChar.codePointAt(0);
|
|
2018
2067
|
const outline = data && code !== void 0 ? readOutline(data, code) : null;
|
|
2019
2068
|
if (outline) sym = classifyOutline(outline);
|
|
@@ -2037,7 +2086,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
2037
2086
|
}
|
|
2038
2087
|
for (const [f, list] of byFont) {
|
|
2039
2088
|
const q = queues.get(f);
|
|
2040
|
-
const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access',
|
|
2089
|
+
const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access', _190 => _190.str, 'access', _191 => _191.match, 'call', _192 => _192(//g), 'optionalAccess', _193 => _193.length]), () => ( 0))), 0);
|
|
2041
2090
|
if (!q || q.length !== want) continue;
|
|
2042
2091
|
let k = 0;
|
|
2043
2092
|
for (const it of list) it.str = it.str.replace(//g, () => q[k++]);
|
|
@@ -2060,15 +2109,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
2060
2109
|
function marginContextBlocks(raw, page, view) {
|
|
2061
2110
|
const [x1, y1, x2, y2] = view;
|
|
2062
2111
|
const width = x2 - x1, height = y2 - y1;
|
|
2063
|
-
const items =
|
|
2112
|
+
const items = _chunk4X7AR4EHcjs.filterHiddenText.call(void 0, _chunk4X7AR4EHcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
2064
2113
|
for (const item of items) {
|
|
2065
2114
|
item.x -= x1;
|
|
2066
2115
|
item.y -= y1;
|
|
2067
2116
|
}
|
|
2068
|
-
return
|
|
2069
|
-
const bbox =
|
|
2117
|
+
return _chunk4X7AR4EHcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
2118
|
+
const bbox = _chunk4X7AR4EHcjs.computeBBox.call(void 0, line, page);
|
|
2070
2119
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
2071
|
-
return [{ type: "paragraph", text:
|
|
2120
|
+
return [{ type: "paragraph", text: _chunk4X7AR4EHcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunk4X7AR4EHcjs.dominantStyle.call(void 0, line) }];
|
|
2072
2121
|
});
|
|
2073
2122
|
}
|
|
2074
2123
|
|
|
@@ -2104,7 +2153,7 @@ var WINANSI_REVERSE = {
|
|
|
2104
2153
|
};
|
|
2105
2154
|
function symbolFontTable(fontName) {
|
|
2106
2155
|
if (!fontName) return void 0;
|
|
2107
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
2156
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkK2NWHLCDcjs.WINGDINGS;
|
|
2108
2157
|
return void 0;
|
|
2109
2158
|
}
|
|
2110
2159
|
function remapSymbolText(text, table) {
|
|
@@ -2232,7 +2281,7 @@ function layout(toks) {
|
|
|
2232
2281
|
const bar = rest.find((t) => t.bar && t.x >= rt.x && t.x <= rt.x + rt.w + 2 && Math.abs(t.y - rt.y) <= size * 1.5);
|
|
2233
2282
|
if (!bar) continue;
|
|
2234
2283
|
const inner = rest.filter((t) => !t.bar && t !== rt && t.x + t.w / 2 > bar.x && t.x + t.w / 2 < bar.x + bar.w && bar.y - t.y > 0 && bar.y - t.y <= size * 1.4);
|
|
2235
|
-
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access',
|
|
2284
|
+
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _194 => _194[0], 'optionalAccess', _195 => _195.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
|
|
2236
2285
|
rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
|
|
2237
2286
|
}
|
|
2238
2287
|
const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
|
|
@@ -2334,7 +2383,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
2334
2383
|
for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
|
|
2335
2384
|
const top = [...ys].sort((p, q) => q[1] - p[1]);
|
|
2336
2385
|
const bar = cur.find(isBarItem);
|
|
2337
|
-
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access',
|
|
2386
|
+
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _196 => _196[0], 'optionalAccess', _197 => _197[0]]), () => ( cur[0].y));
|
|
2338
2387
|
const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
|
|
2339
2388
|
const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
|
|
2340
2389
|
added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
|
|
@@ -2691,7 +2740,7 @@ function joinVerticalColumns(items) {
|
|
|
2691
2740
|
const groups = [];
|
|
2692
2741
|
for (const col of columns) {
|
|
2693
2742
|
const g2 = groups[groups.length - 1];
|
|
2694
|
-
const last = _optionalChain([g2, 'optionalAccess',
|
|
2743
|
+
const last = _optionalChain([g2, 'optionalAccess', _198 => _198[g2.length - 1]]);
|
|
2695
2744
|
const fs = col.items[0].fontSize;
|
|
2696
2745
|
if (last && last.x - col.x >= fs * 1.2 && last.x - col.x <= fs * 4 && Math.abs(last.items[0].y - col.items[0].y) <= fs * 1.2) g2.push(col);
|
|
2697
2746
|
else groups.push([col]);
|
|
@@ -2907,7 +2956,7 @@ function relocateEndnotes(blocks) {
|
|
|
2907
2956
|
}
|
|
2908
2957
|
const shapes = /* @__PURE__ */ new Map();
|
|
2909
2958
|
for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
|
|
2910
|
-
const main = _optionalChain([[...shapes], 'access',
|
|
2959
|
+
const main = _optionalChain([[...shapes], 'access', _199 => _199.sort, 'call', _200 => _200((a, b) => b[1] - a[1]), 'access', _201 => _201[0], 'optionalAccess', _202 => _202[0]]);
|
|
2911
2960
|
if (!main || !/#/.test(main)) return blocks;
|
|
2912
2961
|
const lastRun = (hs) => {
|
|
2913
2962
|
let run2 = [];
|
|
@@ -2970,7 +3019,7 @@ function dropTabLeaderDots(items) {
|
|
|
2970
3019
|
let run = [];
|
|
2971
3020
|
const flush = () => {
|
|
2972
3021
|
const last = run[run.length - 1];
|
|
2973
|
-
const tailPage = _optionalChain([DOTS_PAGE, 'access',
|
|
3022
|
+
const tailPage = _optionalChain([DOTS_PAGE, 'access', _203 => _203.exec, 'call', _204 => _204(last.text.trim()), 'optionalAccess', _205 => _205[1]]);
|
|
2974
3023
|
const dots = run.reduce((n, d) => n + d.text.trim().replace(/\d+$/, "").length, 0);
|
|
2975
3024
|
if (dots >= MIN_DOTS && (tailPage ? run.length > 1 : pageNoAfter(last.x + last.w, last))) {
|
|
2976
3025
|
const body = tailPage ? run.slice(0, -1) : run;
|
|
@@ -3058,7 +3107,7 @@ function inlineFootnotes(blocks, pages) {
|
|
|
3058
3107
|
open = true;
|
|
3059
3108
|
continue;
|
|
3060
3109
|
}
|
|
3061
|
-
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3110
|
+
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontSize]), () => ( _optionalChain([b, 'access', _208 => _208.bbox, 'optionalAccess', _209 => _209.height]))), () => ( 10))) * 1.5;
|
|
3062
3111
|
if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
|
|
3063
3112
|
notes[notes.length - 1].text += " " + b.text.trim();
|
|
3064
3113
|
notes[notes.length - 1].blocks.push(b);
|
|
@@ -3081,7 +3130,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
|
|
|
3081
3130
|
var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
|
|
3082
3131
|
var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
|
|
3083
3132
|
function isRunningHead(block, page, pageHeight) {
|
|
3084
|
-
const box = block.bbox, text = _optionalChain([block, 'access',
|
|
3133
|
+
const box = block.bbox, text = _optionalChain([block, 'access', _210 => _210.text, 'optionalAccess', _211 => _211.trim, 'call', _212 => _212()]);
|
|
3085
3134
|
if (!box || !text || !pageHeight) return false;
|
|
3086
3135
|
const top = box.y + box.height >= pageHeight * 0.9;
|
|
3087
3136
|
const bottom = box.y <= pageHeight * 0.1;
|
|
@@ -3089,7 +3138,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
3089
3138
|
const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
|
|
3090
3139
|
if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
|
|
3091
3140
|
if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
|
|
3092
|
-
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access',
|
|
3141
|
+
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _213 => _213.style, 'optionalAccess', _214 => _214.fontSize]), () => ( 0))) * 1.6) return true;
|
|
3093
3142
|
if (!text.includes(" ")) return false;
|
|
3094
3143
|
const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
|
|
3095
3144
|
if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
|
|
@@ -3098,7 +3147,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
3098
3147
|
return right > left && box.width >= (right - left) * 0.6;
|
|
3099
3148
|
}
|
|
3100
3149
|
function unbalancedClose(text) {
|
|
3101
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
3150
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _215 => _215.match, 'call', _216 => _216(/\)/g), 'optionalAccess', _217 => _217.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _218 => _218.match, 'call', _219 => _219(/\(/g), 'optionalAccess', _220 => _220.length]), () => ( 0)));
|
|
3102
3151
|
}
|
|
3103
3152
|
function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
3104
3153
|
const byPage = /* @__PURE__ */ new Map();
|
|
@@ -3114,7 +3163,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3114
3163
|
const sizes = /* @__PURE__ */ new Map();
|
|
3115
3164
|
let proseChars = 0;
|
|
3116
3165
|
for (const b of page) {
|
|
3117
|
-
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access',
|
|
3166
|
+
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _221 => _221.style, 'optionalAccess', _222 => _222.fontName]) || !b.style.fontSize) continue;
|
|
3118
3167
|
const key2 = `${b.style.fontName}:${b.style.fontSize}`;
|
|
3119
3168
|
chars.set(key2, (_nullishCoalesce(chars.get(key2), () => ( 0))) + b.text.length);
|
|
3120
3169
|
if (b.type === "paragraph" && b.style.fontName === "ocr") {
|
|
@@ -3138,13 +3187,13 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3138
3187
|
const citedProse = /* @__PURE__ */ new Set();
|
|
3139
3188
|
const numberedProse = /* @__PURE__ */ new Set();
|
|
3140
3189
|
for (const page of byPage.values()) {
|
|
3141
|
-
const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3190
|
+
const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access', _223 => _223.text, 'optionalAccess', _224 => _224.trim, 'call', _225 => _225()]), () => ( ""))) && b.bbox && _optionalChain([b, 'access', _226 => _226.style, 'optionalAccess', _227 => _227.fontName]) && b.style.fontSize && !/Bold|Black|Heavy|Semibold/i.test(_nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _228 => _228.get, 'call', _229 => _229(b.style.fontName)]), () => ( ""))));
|
|
3142
3191
|
let chain = [];
|
|
3143
3192
|
const finish = () => {
|
|
3144
|
-
if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access',
|
|
3193
|
+
if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access', _230 => _230.text, 'optionalAccess', _231 => _231.length]), () => ( 0))) >= 40 && b.bbox.height >= b.style.fontSize * 2.4)) return;
|
|
3145
3194
|
for (const b of chain) numberedProse.add(b);
|
|
3146
3195
|
const first = chain[0], size = first.style.fontSize;
|
|
3147
|
-
for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3196
|
+
for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access', _232 => _232.text, 'optionalAccess', _233 => _233.trim, 'call', _234 => _234()]), () => ( ""))) && _optionalChain([b, 'access', _235 => _235.style, 'optionalAccess', _236 => _236.fontName]) === _optionalChain([first, 'access', _237 => _237.style, 'optionalAccess', _238 => _238.fontName]) && _optionalChain([b, 'access', _239 => _239.style, 'optionalAccess', _240 => _240.fontSize]) === size && b.bbox && Math.abs(b.bbox.x - first.bbox.x) <= size * 0.5 && (_nullishCoalesce(_optionalChain([b, 'access', _241 => _241.text, 'optionalAccess', _242 => _242.length]), () => ( 0))) >= 15) numberedProse.add(b);
|
|
3148
3197
|
};
|
|
3149
3198
|
for (const b of numbered) {
|
|
3150
3199
|
const prev = chain.at(-1), size = b.style.fontSize;
|
|
@@ -3158,9 +3207,9 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3158
3207
|
}
|
|
3159
3208
|
for (let i = 0; i + 1 < blocks.length; i++) {
|
|
3160
3209
|
const prose = blocks[i], reference = blocks[i + 1];
|
|
3161
|
-
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access',
|
|
3162
|
-
const source = _nullishCoalesce(_optionalChain([reference, 'access',
|
|
3163
|
-
if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access',
|
|
3210
|
+
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _243 => _243.style, 'optionalAccess', _244 => _244.fontSize]), () => ( 0));
|
|
3211
|
+
const source = _nullishCoalesce(_optionalChain([reference, 'access', _245 => _245.text, 'optionalAccess', _246 => _246.replace, 'call', _247 => _247(/<[^>]+>/g, ""), 'access', _248 => _248.trim, 'call', _249 => _249()]), () => ( ""));
|
|
3212
|
+
if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access', _250 => _250.text, 'optionalAccess', _251 => _251.length]), () => ( 0))) < 40 || !a || !b || size <= 0 || a.height < size * 2.4 || prose.pageNumber !== reference.pageNumber || _optionalChain([prose, 'access', _252 => _252.style, 'optionalAccess', _253 => _253.fontName]) !== _optionalChain([reference, 'access', _254 => _254.style, 'optionalAccess', _255 => _255.fontName]) || _optionalChain([prose, 'access', _256 => _256.style, 'optionalAccess', _257 => _257.fontSize]) !== _optionalChain([reference, 'access', _258 => _258.style, 'optionalAccess', _259 => _259.fontSize]) || Math.abs(a.x - b.x) > size && !(/^[○●•◦]\s/.test(_nullishCoalesce(prose.text, () => ( ""))) && b.x >= a.x && b.x - a.x <= size * 2) || a.y - (b.y + b.height) < 0 || a.y - (b.y + b.height) > size || !/^[((].*(?:제\s*\d+\s*조|(?:Article|Section)\s+\d+).*[))]$/i.test(source)) continue;
|
|
3164
3213
|
citedProse.add(prose);
|
|
3165
3214
|
citedProse.add(reference);
|
|
3166
3215
|
}
|
|
@@ -3168,49 +3217,49 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3168
3217
|
const block = blocks[i];
|
|
3169
3218
|
if (block.type !== "heading" || !block.text) continue;
|
|
3170
3219
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
3171
|
-
const fsz = _nullishCoalesce(_optionalChain([block, 'access',
|
|
3172
|
-
const tocEntry = i > 0 &&
|
|
3220
|
+
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _260 => _260.style, 'optionalAccess', _261 => _261.fontSize]), () => ( 0));
|
|
3221
|
+
const tocEntry = i > 0 && _chunk4X7AR4EHcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunk4X7AR4EHcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
3173
3222
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
3174
|
-
const proseStyle = _optionalChain([block, 'access',
|
|
3223
|
+
const proseStyle = _optionalChain([block, 'access', _262 => _262.style, 'optionalAccess', _263 => _263.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
3175
3224
|
const next = blocks[i + 1];
|
|
3176
|
-
const nb = _optionalChain([next, 'optionalAccess',
|
|
3177
|
-
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
3178
|
-
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess',
|
|
3225
|
+
const nb = _optionalChain([next, 'optionalAccess', _264 => _264.bbox]), bb = block.bbox;
|
|
3226
|
+
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _265 => _265.style, 'optionalAccess', _266 => _266.fontSize]), () => ( 0))) * 1.2 && Math.abs(bb.x - nb.x) > fsz && Math.abs(bb.x + bb.width / 2 - (nb.x + nb.width / 2)) < nb.width * 0.1;
|
|
3227
|
+
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _267 => _267.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
|
|
3179
3228
|
next.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
3180
3229
|
blocks.splice(i--, 1);
|
|
3181
3230
|
continue;
|
|
3182
3231
|
}
|
|
3183
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
3232
|
+
if ((_optionalChain([next, 'optionalAccess', _268 => _268.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _269 => _269.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) === _optionalChain([block, 'access', _272 => _272.style, 'optionalAccess', _273 => _273.fontName]) && _optionalChain([next, 'access', _274 => _274.style, 'optionalAccess', _275 => _275.fontSize]) === _optionalChain([block, 'access', _276 => _276.style, 'optionalAccess', _277 => _277.fontSize]) && fsz > 0 && /^[a-z]/.test(next.text.trim()) && next.text.trim().length <= 40 && !/[.:;!?]$/.test(next.text.trim()) && block.bbox.y - (next.bbox.y + next.bbox.height) < fsz * 1.2 && Math.abs(next.bbox.x - block.bbox.x) < fsz) {
|
|
3184
3233
|
block.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
3185
3234
|
block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
|
|
3186
3235
|
blocks.splice(i + 1, 1);
|
|
3187
3236
|
}
|
|
3188
3237
|
const after = blocks[i + 2];
|
|
3189
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
3238
|
+
if ((_optionalChain([next, 'optionalAccess', _278 => _278.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _279 => _279.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _280 => _280.text, 'optionalAccess', _281 => _281.trim, 'call', _282 => _282()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _283 => _283.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _284 => _284.style, 'optionalAccess', _285 => _285.fontSize]) === _optionalChain([block, 'access', _286 => _286.style, 'optionalAccess', _287 => _287.fontSize])) {
|
|
3190
3239
|
block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
|
|
3191
3240
|
blocks.splice(i + 1, 2);
|
|
3192
3241
|
}
|
|
3193
3242
|
const tiny = fsz > 0 && fsz < 7.5;
|
|
3194
3243
|
const prev = blocks[i - 1];
|
|
3195
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
3244
|
+
if (_optionalChain([prev, 'optionalAccess', _288 => _288.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _289 => _289.text, 'optionalAccess', _290 => _290.trim, 'call', _291 => _291()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
|
|
3196
3245
|
prev.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
3197
3246
|
prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
|
|
3198
3247
|
blocks.splice(i--, 1);
|
|
3199
3248
|
continue;
|
|
3200
3249
|
}
|
|
3201
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
3250
|
+
if (_optionalChain([prev, 'optionalAccess', _292 => _292.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _293 => _293.text, 'optionalAccess', _294 => _294.trim, 'call', _295 => _295()]), () => ( ""))) && prev.bbox && block.bbox && fsz > 0 && (Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x && block.bbox.x - (prev.bbox.x + prev.bbox.width) < fsz * 3 || Math.abs(prev.bbox.x - block.bbox.x) < 2 && (_nullishCoalesce(_optionalChain([prev, 'access', _296 => _296.style, 'optionalAccess', _297 => _297.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
|
|
3202
3251
|
block.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
3203
3252
|
blocks.splice(i - 1, 1);
|
|
3204
3253
|
i -= 2;
|
|
3205
3254
|
continue;
|
|
3206
3255
|
}
|
|
3207
|
-
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
3208
|
-
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess',
|
|
3209
|
-
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess',
|
|
3256
|
+
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _298 => _298.style, 'optionalAccess', _299 => _299.fontSize]), () => ( 0));
|
|
3257
|
+
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _300 => _300.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _301 => _301.style, 'optionalAccess', _302 => _302.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _303 => _303.style, 'optionalAccess', _304 => _304.fontSize]), () => ( 0))) >= size * 1.3 && box.y - (next.bbox.y + next.bbox.height) <= size * 3 && Math.min(box.x + box.width, next.bbox.x + next.bbox.width) - Math.max(box.x, next.bbox.x) >= Math.min(box.width, next.bbox.width) * 0.5 && !page.some((o) => o !== block && o.bbox && o.bbox.y > box.y + box.height && o.type !== "image");
|
|
3258
|
+
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _305 => _305.get, 'call', _306 => _306(_nullishCoalesce(_optionalChain([block, 'access', _307 => _307.style, 'optionalAccess', _308 => _308.fontName]), () => ( "")))]), () => ( ""));
|
|
3210
3259
|
const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
|
|
3211
|
-
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access',
|
|
3212
|
-
const ocrFragment = _optionalChain([block, 'access',
|
|
3213
|
-
const crowdedOcr = _optionalChain([block, 'access',
|
|
3260
|
+
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _309 => _309[i - 1], 'optionalAccess', _310 => _310.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
|
|
3261
|
+
const ocrFragment = _optionalChain([block, 'access', _311 => _311.style, 'optionalAccess', _312 => _312.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _313 => _313.match, 'call', _314 => _314(/\p{L}/gu), 'optionalAccess', _315 => _315.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
|
|
3262
|
+
const crowdedOcr = _optionalChain([block, 'access', _316 => _316.style, 'optionalAccess', _317 => _317.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _318 => _318.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _319 => _319.style, 'optionalAccess', _320 => _320.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _321 => _321.text, 'optionalAccess', _322 => _322.length]), () => ( 0))) >= 15 && Math.abs(o.bbox.x - box.x) <= size * 0.25 && Math.min(o.bbox.y + o.bbox.height, box.y + box.height) - Math.max(o.bbox.y, box.y) >= o.bbox.height * 0.2) && prev.bbox.y > box.y && next.bbox.y < box.y;
|
|
3214
3263
|
if (numberedProse.has(block) || citedProse.has(block) || ocrFragment || crowdedOcr || tocEntry || proseStyle || kicker || byline || tiny || !/\p{L}/u.test(text) && !chapterNumber || /^[a-z]/.test(text) || CAPTION.test(text) || EQUATION_NUMBER.test(block.text) || DISPLAY_MATH.test(text) || // 닫는 괄호가 여는 괄호보다 많으면 앞 줄에서 이어진 문장 조각이다 ("Fact-checking) and is used …") — "1)"·"가)" 앞머리 번호는 빼고 센다
|
|
3215
3264
|
unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
|
|
3216
3265
|
block.type = "paragraph";
|
|
@@ -3260,34 +3309,34 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
|
|
|
3260
3309
|
function captionTableText(t) {
|
|
3261
3310
|
if (!t || t.rows !== 1 || t.cols !== 2) return null;
|
|
3262
3311
|
const [label, body] = t.cells[0];
|
|
3263
|
-
if (!label || !body || _optionalChain([label, 'access',
|
|
3312
|
+
if (!label || !body || _optionalChain([label, 'access', _323 => _323.blocks, 'optionalAccess', _324 => _324.length]) || _optionalChain([body, 'access', _325 => _325.blocks, 'optionalAccess', _326 => _326.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
|
|
3264
3313
|
return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
|
|
3265
3314
|
}
|
|
3266
3315
|
function splitSingleCellTables(blocks) {
|
|
3267
3316
|
const out = [];
|
|
3268
3317
|
for (const b of blocks) {
|
|
3269
3318
|
const t = b.type === "table" ? b.table : void 0;
|
|
3270
|
-
const title = t &&
|
|
3319
|
+
const title = t && _chunk4X7AR4EHcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3271
3320
|
if (title) {
|
|
3272
3321
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3273
3322
|
continue;
|
|
3274
3323
|
}
|
|
3275
|
-
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access',
|
|
3324
|
+
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _327 => _327.cells, 'access', _328 => _328[0], 'optionalAccess', _329 => _329[0], 'optionalAccess', _330 => _330.blocks, 'optionalAccess', _331 => _331.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
|
|
3276
3325
|
const squash = (s) => s.replace(/\s/g, "");
|
|
3277
3326
|
const inner = only && (!squash(t.cells[0][0].text) || only.type === "table" && squash(t.cells[0][0].text) === squash(only.table.cells.flat().map((c) => c.text).join(""))) ? only : void 0;
|
|
3278
|
-
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess',
|
|
3327
|
+
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _332 => _332.type]) === "table" ? captionTableText(inner.table) : null)));
|
|
3279
3328
|
if (caption) {
|
|
3280
3329
|
out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
|
|
3281
3330
|
continue;
|
|
3282
3331
|
}
|
|
3283
|
-
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access',
|
|
3332
|
+
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _333 => _333.cells, 'access', _334 => _334[0], 'optionalAccess', _335 => _335[0]]) : void 0;
|
|
3284
3333
|
if (!cell) {
|
|
3285
3334
|
out.push(b);
|
|
3286
3335
|
continue;
|
|
3287
3336
|
}
|
|
3288
3337
|
const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
|
|
3289
|
-
if (_optionalChain([t, 'optionalAccess',
|
|
3290
|
-
if (_optionalChain([cell, 'access',
|
|
3338
|
+
if (_optionalChain([t, 'optionalAccess', _336 => _336.caption, 'optionalAccess', _337 => _337.trim, 'call', _338 => _338()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
|
|
3339
|
+
if (_optionalChain([cell, 'access', _339 => _339.blocks, 'optionalAccess', _340 => _340.length])) {
|
|
3291
3340
|
out.push(...splitSingleCellTables(cell.blocks));
|
|
3292
3341
|
continue;
|
|
3293
3342
|
}
|
|
@@ -3303,7 +3352,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
3303
3352
|
const lines = cell.text.split("\n");
|
|
3304
3353
|
const out = [lines[0]];
|
|
3305
3354
|
for (const line of lines.slice(1)) {
|
|
3306
|
-
if (
|
|
3355
|
+
if (_chunk4X7AR4EHcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
3307
3356
|
else out.push(line);
|
|
3308
3357
|
}
|
|
3309
3358
|
cell.text = out.join("\n");
|
|
@@ -3314,19 +3363,19 @@ function joinLatinCellWraps(blocks) {
|
|
|
3314
3363
|
}
|
|
3315
3364
|
function cleanPdfText(text, opts) {
|
|
3316
3365
|
let clean = normalizeAraea(stripControlChars(text));
|
|
3317
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
3366
|
+
if (!_optionalChain([opts, 'optionalAccess', _341 => _341.keepLoneNumbers])) {
|
|
3318
3367
|
clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
|
|
3319
3368
|
}
|
|
3320
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
3369
|
+
if (!_optionalChain([opts, 'optionalAccess', _342 => _342.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
|
|
3321
3370
|
return mergeKoreanLines(
|
|
3322
3371
|
clean.replace(/^[\s]*[-–—]\s*[-–—]?\d+[-–—]?[\s]*[-–—]?[\s]*$/gm, "").replace(/^\s*\d+\s*\/\s*\d+\s*$/gm, "").replace(/\.(?: \.){3,}/g, (m) => ".".repeat(m.length + 1 >> 1))
|
|
3323
3372
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
3324
3373
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
3325
3374
|
if (line.startsWith("|")) {
|
|
3326
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
3375
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunk4X7AR4EHcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
3327
3376
|
}
|
|
3328
|
-
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access',
|
|
3329
|
-
return mark +
|
|
3377
|
+
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _343 => _343.exec, 'call', _344 => _344(line), 'optionalAccess', _345 => _345[0]]), () => ( ""));
|
|
3378
|
+
return mark + _chunk4X7AR4EHcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
3330
3379
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
3331
3380
|
}
|
|
3332
3381
|
function startsWithMarker(line) {
|
|
@@ -3358,7 +3407,7 @@ function mergeKoreanLines(text) {
|
|
|
3358
3407
|
continue;
|
|
3359
3408
|
}
|
|
3360
3409
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
3361
|
-
result[result.length - 1] = prev +
|
|
3410
|
+
result[result.length - 1] = prev + _chunk4X7AR4EHcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
3362
3411
|
} else {
|
|
3363
3412
|
result.push(curr);
|
|
3364
3413
|
}
|
|
@@ -3374,7 +3423,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3374
3423
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3375
3424
|
for (const a of annots) {
|
|
3376
3425
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3377
|
-
const url =
|
|
3426
|
+
const url = _chunkMJSHXESKcjs.sanitizeHref.call(void 0, a.url);
|
|
3378
3427
|
if (!url) continue;
|
|
3379
3428
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3380
3429
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -3426,7 +3475,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3426
3475
|
|
|
3427
3476
|
// src/pdf/formula-ocr.ts
|
|
3428
3477
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3429
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
3478
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-JGFYGFYX.cjs")));
|
|
3430
3479
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3431
3480
|
await ensureFormulaModels((p) => {
|
|
3432
3481
|
if (p.phase === "download" && p.total) {
|
|
@@ -3617,13 +3666,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3617
3666
|
try {
|
|
3618
3667
|
return await Promise.race([
|
|
3619
3668
|
loadingTask.promise.catch((e) => {
|
|
3620
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
3669
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkMJSHXESKcjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C PDF \uD30C\uC77C\uC785\uB2C8\uB2E4 (PDF \uC5F4\uAE30 \uC554\uD638\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4)");
|
|
3621
3670
|
throw e;
|
|
3622
3671
|
}),
|
|
3623
3672
|
new Promise((_, reject) => {
|
|
3624
3673
|
timer = setTimeout(() => {
|
|
3625
3674
|
loadingTask.destroy();
|
|
3626
|
-
reject(new (0,
|
|
3675
|
+
reject(new (0, _chunkMJSHXESKcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
3627
3676
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
3628
3677
|
})
|
|
3629
3678
|
]);
|
|
@@ -3632,15 +3681,15 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3632
3681
|
}
|
|
3633
3682
|
}
|
|
3634
3683
|
async function parsePdfDocument(buffer, options) {
|
|
3635
|
-
const formulaBuffer = _optionalChain([options, 'optionalAccess',
|
|
3636
|
-
const ocrOptionError =
|
|
3637
|
-
if (ocrOptionError) throw new (0,
|
|
3638
|
-
const autoOcr = _optionalChain([options, 'optionalAccess',
|
|
3639
|
-
const ocrBuffer = _optionalChain([options, 'optionalAccess',
|
|
3684
|
+
const formulaBuffer = _optionalChain([options, 'optionalAccess', _346 => _346.formulaOcr]) ? buffer : null;
|
|
3685
|
+
const ocrOptionError = _chunkK2NWHLCDcjs.validateOcrOptions.call(void 0, options);
|
|
3686
|
+
if (ocrOptionError) throw new (0, _chunkMJSHXESKcjs.KordocError)(ocrOptionError);
|
|
3687
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _347 => _347.ocr]) === void 0 && await _chunk4X7AR4EHcjs.ocrModelsCached.call(void 0, _chunk4X7AR4EHcjs.resolveOcrModels.call(void 0, options));
|
|
3688
|
+
const ocrBuffer = _optionalChain([options, 'optionalAccess', _348 => _348.ocr]) || autoOcr ? buffer : null;
|
|
3640
3689
|
const doc = await loadPdfWithTimeout(buffer);
|
|
3641
3690
|
try {
|
|
3642
3691
|
const pageCount = doc.numPages;
|
|
3643
|
-
if (pageCount === 0) throw new (0,
|
|
3692
|
+
if (pageCount === 0) throw new (0, _chunkMJSHXESKcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
3644
3693
|
const metadata = { pageCount, pageMode: "layout" };
|
|
3645
3694
|
await extractPdfMetadata(doc, metadata);
|
|
3646
3695
|
const blocks = [];
|
|
@@ -3649,8 +3698,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3649
3698
|
let totalChars = 0;
|
|
3650
3699
|
let totalTextBytes = 0;
|
|
3651
3700
|
const effectivePageCount = Math.min(pageCount, MAX_PAGES);
|
|
3652
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3653
|
-
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess',
|
|
3701
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _349 => _349.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
|
|
3702
|
+
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _350 => _350.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
|
|
3654
3703
|
warnings.push({ message: `${pageCount}\uCABD \uC911 \uC55E ${MAX_PAGES}\uCABD\uB9CC \uD30C\uC2F1\uD588\uC2B5\uB2C8\uB2E4 (\uCABD \uC218 \uC0C1\uD55C)`, code: "PARTIAL_PARSE" });
|
|
3655
3704
|
}
|
|
3656
3705
|
const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
|
|
@@ -3669,10 +3718,10 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3669
3718
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
3670
3719
|
const carry = {};
|
|
3671
3720
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
3672
|
-
const wrapLexicon = new (0,
|
|
3721
|
+
const wrapLexicon = new (0, _chunk4X7AR4EHcjs.WrapLexicon)();
|
|
3673
3722
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
3674
3723
|
const headerContext = [];
|
|
3675
|
-
if (pageFilter && _optionalChain([options, 'optionalAccess',
|
|
3724
|
+
if (pageFilter && _optionalChain([options, 'optionalAccess', _351 => _351.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
3676
3725
|
for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
|
|
3677
3726
|
let contextPage;
|
|
3678
3727
|
try {
|
|
@@ -3682,7 +3731,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3682
3731
|
headerContext.push(...marginContextBlocks(content.items, number, contextPage.view));
|
|
3683
3732
|
} catch (e6) {
|
|
3684
3733
|
} finally {
|
|
3685
|
-
_optionalChain([contextPage, 'optionalAccess',
|
|
3734
|
+
_optionalChain([contextPage, 'optionalAccess', _352 => _352.cleanup, 'call', _353 => _353()]);
|
|
3686
3735
|
}
|
|
3687
3736
|
}
|
|
3688
3737
|
}
|
|
@@ -3709,15 +3758,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3709
3758
|
return void 0;
|
|
3710
3759
|
}
|
|
3711
3760
|
};
|
|
3712
|
-
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call',
|
|
3761
|
+
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _354 => _354(loadedName), 'optionalAccess', _355 => _355.differences]);
|
|
3713
3762
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3714
3763
|
markTrailingSpaceGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3715
|
-
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call',
|
|
3764
|
+
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _356 => _356(n), 'optionalAccess', _357 => _357.name]));
|
|
3716
3765
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
3717
3766
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3718
3767
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3719
|
-
const items =
|
|
3720
|
-
const filtered =
|
|
3768
|
+
const items = _chunk4X7AR4EHcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
3769
|
+
const filtered = _chunk4X7AR4EHcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
3721
3770
|
const joined = joinVerticalColumns(filtered.visible);
|
|
3722
3771
|
const visible = dropTabLeaderDots(joined);
|
|
3723
3772
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -3741,27 +3790,27 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3741
3790
|
fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
|
|
3742
3791
|
argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
|
|
3743
3792
|
} : rawOps;
|
|
3744
|
-
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call',
|
|
3793
|
+
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _358 => _358(loadedName), 'optionalAccess', _359 => _359.name]));
|
|
3745
3794
|
remapControlGlyphs(visible, differencesOf);
|
|
3746
|
-
await
|
|
3795
|
+
await _chunk4X7AR4EHcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
3747
3796
|
const faces = /* @__PURE__ */ new Map();
|
|
3748
3797
|
for (const it of visible) {
|
|
3749
3798
|
if (!it.fontName) continue;
|
|
3750
3799
|
let face = faces.get(it.fontName);
|
|
3751
3800
|
if (face === void 0) {
|
|
3752
3801
|
const obj = fontObj(it.fontName);
|
|
3753
|
-
face = _optionalChain([obj, 'optionalAccess',
|
|
3802
|
+
face = _optionalChain([obj, 'optionalAccess', _360 => _360.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
|
|
3754
3803
|
faces.set(it.fontName, face);
|
|
3755
3804
|
}
|
|
3756
3805
|
it.fontName = face;
|
|
3757
|
-
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call',
|
|
3806
|
+
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _361 => _361(face), 'optionalAccess', _362 => _362.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
3758
3807
|
}
|
|
3759
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
3760
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
3808
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkK2NWHLCDcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
3809
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkK2NWHLCDcjs.escapeLiteralTags.call(void 0, it.text);
|
|
3761
3810
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
3762
3811
|
const pageArea = pageW * pageH;
|
|
3763
3812
|
if (pageArea > 0) {
|
|
3764
|
-
const imageRegions =
|
|
3813
|
+
const imageRegions = _chunk4X7AR4EHcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
3765
3814
|
let uncovered = 0;
|
|
3766
3815
|
for (const r of imageRegions) {
|
|
3767
3816
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -3787,15 +3836,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3787
3836
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
3788
3837
|
}
|
|
3789
3838
|
const marks = superscriptNoteMarks(visible);
|
|
3790
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
3839
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunk4X7AR4EHcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
3791
3840
|
const stamp = marginStamp(visible);
|
|
3792
3841
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
3793
|
-
const rightArrows = _optionalChain([options, 'optionalAccess',
|
|
3794
|
-
const pageBlocks = orderTwoUpPage(
|
|
3842
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _363 => _363.tables]) !== false ? await _chunk4X7AR4EHcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
3843
|
+
const pageBlocks = orderTwoUpPage(_chunk4X7AR4EHcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _364 => _364.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
3795
3844
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
3796
3845
|
for (const b of pageBlocks) blocks.push(b);
|
|
3797
3846
|
try {
|
|
3798
|
-
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess',
|
|
3847
|
+
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _365 => _365.images]) !== false);
|
|
3799
3848
|
if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
|
|
3800
3849
|
extractedImages.push(...pageImages);
|
|
3801
3850
|
} catch (e9) {
|
|
@@ -3814,17 +3863,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3814
3863
|
const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
|
|
3815
3864
|
const quality = computePageQuality(i, pageText, vector.glyphs);
|
|
3816
3865
|
pageQuality.push(quality);
|
|
3817
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3866
|
+
if (_optionalChain([options, 'optionalAccess', _366 => _366.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
3818
3867
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
3819
3868
|
}
|
|
3820
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
3869
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkMJSHXESKcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
3821
3870
|
parsedPages++;
|
|
3822
|
-
_optionalChain([options, 'optionalAccess',
|
|
3871
|
+
_optionalChain([options, 'optionalAccess', _367 => _367.onProgress, 'optionalCall', _368 => _368(parsedPages, totalTarget)]);
|
|
3823
3872
|
} catch (pageErr) {
|
|
3824
|
-
if (pageErr instanceof
|
|
3873
|
+
if (pageErr instanceof _chunkMJSHXESKcjs.KordocError) throw pageErr;
|
|
3825
3874
|
warnings.push({ page: i, message: `\uD398\uC774\uC9C0 ${i} \uD30C\uC2F1 \uC2E4\uD328: ${pageErr instanceof Error ? pageErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
3826
3875
|
} finally {
|
|
3827
|
-
_optionalChain([loadedPage, 'optionalAccess',
|
|
3876
|
+
_optionalChain([loadedPage, 'optionalAccess', _369 => _369.cleanup, 'call', _370 => _370()]);
|
|
3828
3877
|
}
|
|
3829
3878
|
if (loadedFonts.size > FONT_CACHE_LIMIT) {
|
|
3830
3879
|
await doc.cleanup();
|
|
@@ -3832,14 +3881,14 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3832
3881
|
}
|
|
3833
3882
|
}
|
|
3834
3883
|
const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
|
|
3835
|
-
const isImageBased = _optionalChain([pageFilter, 'optionalAccess',
|
|
3884
|
+
const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _371 => _371.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
|
|
3836
3885
|
const ocrDone = /* @__PURE__ */ new Set();
|
|
3837
3886
|
const ocrLinesOut = /* @__PURE__ */ new Map();
|
|
3838
|
-
const ocrRegions = _optionalChain([options, 'optionalAccess',
|
|
3887
|
+
const ocrRegions = _optionalChain([options, 'optionalAccess', _372 => _372.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _373 => _373.ocr]) === true) : /* @__PURE__ */ new Map();
|
|
3839
3888
|
if (ocrBuffer) {
|
|
3840
3889
|
const inScope = (p) => !pageFilter || pageFilter.has(p);
|
|
3841
3890
|
const targets = /* @__PURE__ */ new Set();
|
|
3842
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3891
|
+
if (_optionalChain([options, 'optionalAccess', _374 => _374.ocr]) === "force" || isImageBased) {
|
|
3843
3892
|
for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
|
|
3844
3893
|
} else {
|
|
3845
3894
|
for (const pq of pageQuality) {
|
|
@@ -3852,25 +3901,25 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3852
3901
|
}
|
|
3853
3902
|
if (targets.size > 0) {
|
|
3854
3903
|
try {
|
|
3855
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3856
|
-
const mode = typeof _optionalChain([options, 'optionalAccess',
|
|
3857
|
-
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess',
|
|
3858
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3859
|
-
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess',
|
|
3860
|
-
for (const obs of ocrPageBlocks.values())
|
|
3904
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-QWTGWYQT.cjs")));
|
|
3905
|
+
const mode = typeof _optionalChain([options, 'optionalAccess', _375 => _375.ocr]) === "function" ? options.ocr : "builtin";
|
|
3906
|
+
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _376 => _376.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _377 => _377.find, 'call', _378 => _378((q) => q.page === p), 'optionalAccess', _379 => _379.needsOcr])));
|
|
3907
|
+
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-QWTGWYQT.cjs")));
|
|
3908
|
+
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _380 => _380.onProgress]), _optionalChain([options, 'optionalAccess', _381 => _381.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
3909
|
+
for (const obs of ocrPageBlocks.values()) _chunkK2NWHLCDcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
3861
3910
|
if (ocrPageBlocks.size > 0) {
|
|
3862
3911
|
const replacePages = /* @__PURE__ */ new Set();
|
|
3863
3912
|
for (const [p, obs] of ocrPageBlocks) {
|
|
3864
|
-
const needsOcr = _optionalChain([pageQuality, 'access',
|
|
3865
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3913
|
+
const needsOcr = _optionalChain([pageQuality, 'access', _382 => _382.find, 'call', _383 => _383((q) => q.page === p), 'optionalAccess', _384 => _384.needsOcr]);
|
|
3914
|
+
if (_optionalChain([options, 'optionalAccess', _385 => _385.ocr]) === "force" || isImageBased || needsOcr) {
|
|
3866
3915
|
replacePages.add(p);
|
|
3867
3916
|
ocrDone.add(p);
|
|
3868
3917
|
continue;
|
|
3869
3918
|
}
|
|
3870
3919
|
const regions = ocrRegions.get(p);
|
|
3871
|
-
if (!regions ||
|
|
3920
|
+
if (!regions || _chunk4X7AR4EHcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
3872
3921
|
ocrDone.add(p);
|
|
3873
|
-
if (_optionalChain([pageImageBlocks, 'access',
|
|
3922
|
+
if (_optionalChain([pageImageBlocks, 'access', _386 => _386.get, 'call', _387 => _387(p), 'optionalAccess', _388 => _388.length]) === 1) pageImageBlocks.delete(p);
|
|
3874
3923
|
}
|
|
3875
3924
|
if (replacePages.size) {
|
|
3876
3925
|
const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
|
|
@@ -3920,18 +3969,18 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3920
3969
|
warnings.push({ page, message: `${count}\uAC1C \uC774\uBBF8\uC9C0 \uC601\uC5ED\uC5D0 \uCD94\uCD9C \uAC00\uB2A5\uD55C \uD14D\uC2A4\uD2B8 \uC5C6\uC74C (\uADF8\uB9BC/\uCC28\uD2B8/\uB3C4\uC7A5 \uB0B4\uC6A9 \uB204\uB77D \uAC00\uB2A5 \u2014 \uADF8\uB9BC \uC18D \uAE00\uC740 ocr: true / CLI --ocr \uB85C \uC77D\uC2B5\uB2C8\uB2E4)`, code: "SKIPPED_IMAGE" });
|
|
3921
3970
|
}
|
|
3922
3971
|
}
|
|
3923
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3924
|
-
const removed =
|
|
3925
|
-
const running =
|
|
3972
|
+
if (_optionalChain([options, 'optionalAccess', _389 => _389.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
3973
|
+
const removed = _chunk4X7AR4EHcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
3974
|
+
const running = _chunk4X7AR4EHcjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
3926
3975
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
3927
3976
|
blocks.splice(removed[ri], 1);
|
|
3928
3977
|
}
|
|
3929
|
-
const stripped =
|
|
3978
|
+
const stripped = _chunk4X7AR4EHcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
3930
3979
|
if (stripped !== blocks) {
|
|
3931
3980
|
blocks.length = 0;
|
|
3932
3981
|
blocks.push(...stripped);
|
|
3933
3982
|
}
|
|
3934
|
-
const kept =
|
|
3983
|
+
const kept = _chunk4X7AR4EHcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
3935
3984
|
if (kept !== blocks) {
|
|
3936
3985
|
blocks.length = 0;
|
|
3937
3986
|
blocks.push(...kept);
|
|
@@ -3939,15 +3988,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3939
3988
|
}
|
|
3940
3989
|
mergeContinuedCells(blocks, pageHeights);
|
|
3941
3990
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
3942
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3943
|
-
const boxes =
|
|
3991
|
+
if (_optionalChain([options, 'optionalAccess', _390 => _390.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
3992
|
+
const boxes = _chunk4X7AR4EHcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
3944
3993
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
3945
3994
|
}
|
|
3946
3995
|
splitContactTables(blocks);
|
|
3947
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
3948
|
-
|
|
3996
|
+
if (!_optionalChain([options, 'optionalAccess', _391 => _391.keepTrailingEmptyCols])) _chunk4X7AR4EHcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
3997
|
+
_chunk4X7AR4EHcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
3949
3998
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
3950
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3999
|
+
if (_optionalChain([options, 'optionalAccess', _392 => _392.formulaOcr]) && formulaBuffer) {
|
|
3951
4000
|
try {
|
|
3952
4001
|
await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
|
|
3953
4002
|
} catch (e) {
|
|
@@ -3957,54 +4006,54 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3957
4006
|
});
|
|
3958
4007
|
}
|
|
3959
4008
|
}
|
|
3960
|
-
const medianFontSize =
|
|
4009
|
+
const medianFontSize = _chunk4X7AR4EHcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
3961
4010
|
if (medianFontSize > 0) {
|
|
3962
|
-
|
|
3963
|
-
}
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
4011
|
+
_chunk4X7AR4EHcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
4012
|
+
}
|
|
4013
|
+
_chunk4X7AR4EHcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
4014
|
+
_chunk4X7AR4EHcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
4015
|
+
_chunk4X7AR4EHcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
4016
|
+
_chunk4X7AR4EHcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
4017
|
+
_chunk4X7AR4EHcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
4018
|
+
_chunk4X7AR4EHcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
4019
|
+
_chunk4X7AR4EHcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
4020
|
+
_chunk4X7AR4EHcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
3972
4021
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3973
|
-
|
|
3974
|
-
|
|
4022
|
+
_chunk4X7AR4EHcjs.detectTableCaptions.call(void 0, blocks);
|
|
4023
|
+
_chunk4X7AR4EHcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3975
4024
|
sanitizeBlockControlChars(blocks);
|
|
3976
4025
|
let outBlocks = splitSingleCellTables(blocks);
|
|
3977
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4026
|
+
if (_optionalChain([options, 'optionalAccess', _393 => _393.layoutTables]) !== "keep") {
|
|
3978
4027
|
blocks.length = 0;
|
|
3979
4028
|
for (const block of outBlocks) blocks.push(block);
|
|
3980
4029
|
}
|
|
3981
4030
|
outBlocks = inlineFootnotes(outBlocks, noteMarks);
|
|
3982
4031
|
outBlocks = relocateEndnotes(outBlocks);
|
|
3983
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4032
|
+
if (_optionalChain([options, 'optionalAccess', _394 => _394.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
|
|
3984
4033
|
if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
|
|
3985
4034
|
const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
|
|
3986
4035
|
if (!b.bbox || !h) return false;
|
|
3987
4036
|
return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
|
|
3988
4037
|
});
|
|
3989
4038
|
joinLatinCellWraps(outBlocks);
|
|
3990
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4039
|
+
if (_optionalChain([options, 'optionalAccess', _395 => _395.layoutTables]) !== "keep") {
|
|
3991
4040
|
const hancom = await isHancomPdf(doc);
|
|
3992
4041
|
const shown = /* @__PURE__ */ new Map();
|
|
3993
4042
|
const markContent = (bs) => {
|
|
3994
4043
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
3995
|
-
if (
|
|
3996
|
-
const lines =
|
|
3997
|
-
if (lines)
|
|
4044
|
+
if (_chunk4X7AR4EHcjs.IMAGE_CELLS.has(c)) _chunkK2NWHLCDcjs.CONTENT_CELLS.add(c);
|
|
4045
|
+
const lines = _chunk4X7AR4EHcjs.CELL_LINES.get(c);
|
|
4046
|
+
if (lines) _chunkK2NWHLCDcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
3998
4047
|
markContent(c.blocks);
|
|
3999
4048
|
}
|
|
4000
4049
|
};
|
|
4001
4050
|
const visual = (bs) => bs.flatMap((b) => {
|
|
4002
4051
|
if (b.type !== "table") return [b];
|
|
4003
|
-
if (!hancom && b.table &&
|
|
4052
|
+
if (!hancom && b.table && _chunk4X7AR4EHcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
4004
4053
|
let v = shown.get(b);
|
|
4005
4054
|
if (!v) {
|
|
4006
4055
|
markContent([b]);
|
|
4007
|
-
shown.set(b, v =
|
|
4056
|
+
shown.set(b, v = _chunkK2NWHLCDcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _396 => _396.keepTrailingEmptyCols])));
|
|
4008
4057
|
}
|
|
4009
4058
|
return v;
|
|
4010
4059
|
});
|
|
@@ -4013,13 +4062,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4013
4062
|
blocks.length = 0;
|
|
4014
4063
|
for (const b of kept) blocks.push(b);
|
|
4015
4064
|
}
|
|
4016
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
4017
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4065
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkK2NWHLCDcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _397 => _397.tableFormat]) }), { keepLoneNumbers: true }));
|
|
4066
|
+
if (_optionalChain([options, 'optionalAccess', _398 => _398.tableFormat]) === "gfm") _chunkK2NWHLCDcjs.assignTableIds.call(void 0, blocks);
|
|
4018
4067
|
let markdown = finishMarkdown(outBlocks);
|
|
4019
4068
|
const outline = collectPdfOutline(outBlocks);
|
|
4020
4069
|
return {
|
|
4021
4070
|
markdown,
|
|
4022
|
-
pages:
|
|
4071
|
+
pages: _chunkVXQWAPC6cjs.blocksToPages.call(void 0, splitPageTables(_chunk4X7AR4EHcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
4023
4072
|
blocks,
|
|
4024
4073
|
metadata,
|
|
4025
4074
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -4028,7 +4077,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4028
4077
|
pageQuality,
|
|
4029
4078
|
qualitySummary: summarizeDocumentQuality(pageQuality),
|
|
4030
4079
|
images: extractedImages.length > 0 ? extractedImages : void 0,
|
|
4031
|
-
..._optionalChain([options, 'optionalAccess',
|
|
4080
|
+
..._optionalChain([options, 'optionalAccess', _399 => _399.ocrLines]) ? { ocrLines: [...ocrLinesOut.values()].sort((a, b) => a.pageNumber - b.pageNumber) } : {}
|
|
4032
4081
|
};
|
|
4033
4082
|
} finally {
|
|
4034
4083
|
await doc.destroy().catch(() => {
|
|
@@ -4038,7 +4087,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4038
4087
|
async function extractPdfMetadata(doc, metadata) {
|
|
4039
4088
|
try {
|
|
4040
4089
|
const result = await doc.getMetadata();
|
|
4041
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
4090
|
+
if (!_optionalChain([result, 'optionalAccess', _400 => _400.info])) return;
|
|
4042
4091
|
const info = result.info;
|
|
4043
4092
|
if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
|
|
4044
4093
|
if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
|
|
@@ -4054,8 +4103,8 @@ async function extractPdfMetadata(doc, metadata) {
|
|
|
4054
4103
|
}
|
|
4055
4104
|
async function isHancomPdf(doc) {
|
|
4056
4105
|
try {
|
|
4057
|
-
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async
|
|
4058
|
-
return [_optionalChain([info, 'optionalAccess',
|
|
4106
|
+
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _401 => _401.info]);
|
|
4107
|
+
return [_optionalChain([info, 'optionalAccess', _402 => _402.Producer]), _optionalChain([info, 'optionalAccess', _403 => _403.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
|
|
4059
4108
|
} catch (e11) {
|
|
4060
4109
|
return false;
|
|
4061
4110
|
}
|
|
@@ -4099,5 +4148,5 @@ function marginStamp(items) {
|
|
|
4099
4148
|
|
|
4100
4149
|
|
|
4101
4150
|
|
|
4102
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
4103
|
-
//# sourceMappingURL=parser-
|
|
4151
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunk4X7AR4EHcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunk4X7AR4EHcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunk4X7AR4EHcjs.removeHeaderFooterBlocks;
|
|
4152
|
+
//# sourceMappingURL=parser-ZFXVZZKQ.cjs.map
|