kordoc 4.24.3 → 4.24.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 +5 -5
- package/dist/{-Q56U3KCA.js → -WND2HWVH.js} +11 -11
- package/dist/{chunk-3EWXRIPH.js → chunk-3LSHLWTX.js} +3 -3
- package/dist/{chunk-HNX2I7D6.js → chunk-44E52JJ7.js} +2 -2
- package/dist/{chunk-XNNMMYFO.js → chunk-47MTLP4U.js} +2 -2
- package/dist/{chunk-42FSKT7R.js → chunk-4XVL3OBP.js} +2 -2
- package/dist/{chunk-OAOM7IEI.js → chunk-5AHG3XY3.js} +11 -11
- package/dist/{chunk-6ZRZLV3J.cjs → chunk-6A4KYMQR.cjs} +2 -2
- package/dist/{chunk-6ZRZLV3J.cjs.map → chunk-6A4KYMQR.cjs.map} +1 -1
- package/dist/{chunk-EWCJCWTT.js → chunk-6CPBNK5O.js} +2 -2
- package/dist/{chunk-FZT34MUI.js → chunk-A5JDO52L.js} +4 -4
- package/dist/{chunk-4X73CGIL.js → chunk-AKIJTKEA.js} +2 -2
- package/dist/{chunk-YG4YOPK6.cjs → chunk-BODFTRWA.cjs} +3 -3
- package/dist/{chunk-YG4YOPK6.cjs.map → chunk-BODFTRWA.cjs.map} +1 -1
- package/dist/{chunk-XAZ5RGVG.js → chunk-BYYZUFPC.js} +11 -8
- package/dist/chunk-BYYZUFPC.js.map +1 -0
- package/dist/{chunk-Q2QKRE4P.js → chunk-D4YWVZHD.js} +2 -2
- package/dist/{chunk-33NZN73M.js → chunk-DTADAHJD.js} +2 -2
- package/dist/{chunk-XZOAE2Q7.js → chunk-E7N6BUJT.js} +12 -9
- package/dist/chunk-E7N6BUJT.js.map +1 -0
- package/dist/{chunk-I2QETSZN.js → chunk-FK3JPTHI.js} +2 -2
- package/dist/{chunk-AEEQN6L3.js → chunk-GGVHKYKZ.js} +2 -2
- package/dist/{chunk-PMX5CPK5.js → chunk-JHUW5PKO.js} +8 -7
- package/dist/chunk-JHUW5PKO.js.map +1 -0
- package/dist/{chunk-VFEI2GIE.cjs → chunk-KFQNG2EA.cjs} +3 -3
- package/dist/{chunk-VFEI2GIE.cjs.map → chunk-KFQNG2EA.cjs.map} +1 -1
- package/dist/{chunk-PHZDAHZC.js → chunk-LBOXKGAH.js} +3 -3
- package/dist/{chunk-JILIA5EV.cjs → chunk-LJ7U7MFN.cjs} +31 -28
- package/dist/chunk-LJ7U7MFN.cjs.map +1 -0
- package/dist/{chunk-W6O7KBOD.js → chunk-MC4DPT4I.js} +2 -2
- package/dist/{chunk-KXHNIHLC.js → chunk-MMPBJGWQ.js} +2 -2
- package/dist/{chunk-NKDPCALC.js → chunk-QTJTBCTZ.js} +4 -4
- package/dist/{chunk-N65EY5BI.cjs → chunk-TPKP3WQU.cjs} +6 -6
- package/dist/{chunk-N65EY5BI.cjs.map → chunk-TPKP3WQU.cjs.map} +1 -1
- package/dist/{chunk-EEXIFCXC.js → chunk-VBY3JQL2.js} +2 -2
- package/dist/{chunk-TZ753B6A.js → chunk-WMDGGQXJ.js} +2 -2
- package/dist/{chunk-HTG3VVET.cjs → chunk-WN5X4DT3.cjs} +24 -24
- package/dist/{chunk-HTG3VVET.cjs.map → chunk-WN5X4DT3.cjs.map} +1 -1
- package/dist/{chunk-HU7POUBS.js → chunk-YBCW544D.js} +2 -2
- package/dist/{chunk-J45OVEUM.js → chunk-YEYNBH5W.js} +112 -23
- package/dist/chunk-YEYNBH5W.js.map +1 -0
- package/dist/chunks-2UDUNVGQ.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-2BPHF6O7.cjs → formula-6DJAY3KI.cjs} +9 -9
- package/dist/{formula-2BPHF6O7.cjs.map → formula-6DJAY3KI.cjs.map} +1 -1
- package/dist/{formula-IREEAC4T.js → formula-MPBZ7OMN.js} +3 -3
- package/dist/{formula-EA5GDCUD.js → formula-NA3LD35B.js} +4 -4
- package/dist/{image-ocr-LGOFUS3O.js → image-ocr-6TGDXUAS.js} +9 -9
- package/dist/{image-ocr-CCTE7HX3.cjs → image-ocr-REM4LZKX.cjs} +17 -17
- package/dist/{image-ocr-CCTE7HX3.cjs.map → image-ocr-REM4LZKX.cjs.map} +1 -1
- package/dist/{image-ocr-JQJC5HWK.js → image-ocr-THA5BASF.js} +6 -6
- package/dist/index.cjs +740 -650
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +118 -28
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +23 -23
- package/dist/{model-bundle-YW62Y6UD.js → model-bundle-3YDTJ6EQ.js} +5 -5
- package/dist/{models-AAL3IS2R.js → models-M7AX7VIN.js} +5 -5
- package/dist/{parse-worker-v2-3JAHV7NY.js → parse-worker-v2-3ZMFWDFW.js} +12 -12
- package/dist/{parser-HE45CCSG.cjs → parser-GIDYL5LH.cjs} +158 -158
- package/dist/{parser-HE45CCSG.cjs.map → parser-GIDYL5LH.cjs.map} +1 -1
- package/dist/{parser-ZBP5GOQK.js → parser-MNNJSFEZ.js} +9 -9
- package/dist/{parser-4FCKKJ2N.js → parser-TD4VZDGY.js} +12 -12
- package/dist/{pdf-ocr-HFAEOA7W.js → pdf-ocr-5HEVZKG5.js} +6 -6
- package/dist/{pdf-ocr-Q4TPGDDI.js → pdf-ocr-6BAOQ6CY.js} +9 -9
- package/dist/pdf-ocr-NOSNTEDS.cjs +31 -0
- package/dist/{pdf-ocr-7MDCLWAA.cjs.map → pdf-ocr-NOSNTEDS.cjs.map} +1 -1
- package/dist/{profile-io-EDQTKLLL.js → profile-io-H4WQIGN6.js} +3 -3
- package/dist/{rasterize-VD2XGHUJ.js → rasterize-EOPWJWBO.js} +3 -3
- package/dist/{redact-doc-TBIBQJCT.js → redact-doc-BBZVAA3I.js} +11 -11
- package/dist/{render-J5KAZAQH.js → render-ZZ4CGJ6J.js} +7 -7
- package/dist/seal-RRYFKTEQ.js +10 -0
- package/dist/{setup-5LYHCQRU.js → setup-UIPKBNLA.js} +3 -3
- package/dist/visual-DLLRTF6C.js +21 -0
- package/dist/{watch-YP4IWM75.js → watch-OXQ6O5HD.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-J45OVEUM.js.map +0 -1
- package/dist/chunk-JILIA5EV.cjs.map +0 -1
- package/dist/chunk-PMX5CPK5.js.map +0 -1
- package/dist/chunk-XAZ5RGVG.js.map +0 -1
- package/dist/chunk-XZOAE2Q7.js.map +0 -1
- package/dist/chunks-REYSCBPB.js +0 -10
- package/dist/pdf-ocr-7MDCLWAA.cjs +0 -31
- package/dist/seal-H2JNAZU7.js +0 -10
- package/dist/visual-7EO6GR3M.js +0 -21
- /package/dist/{-Q56U3KCA.js.map → -WND2HWVH.js.map} +0 -0
- /package/dist/{chunk-3EWXRIPH.js.map → chunk-3LSHLWTX.js.map} +0 -0
- /package/dist/{chunk-HNX2I7D6.js.map → chunk-44E52JJ7.js.map} +0 -0
- /package/dist/{chunk-XNNMMYFO.js.map → chunk-47MTLP4U.js.map} +0 -0
- /package/dist/{chunk-42FSKT7R.js.map → chunk-4XVL3OBP.js.map} +0 -0
- /package/dist/{chunk-OAOM7IEI.js.map → chunk-5AHG3XY3.js.map} +0 -0
- /package/dist/{chunk-EWCJCWTT.js.map → chunk-6CPBNK5O.js.map} +0 -0
- /package/dist/{chunk-FZT34MUI.js.map → chunk-A5JDO52L.js.map} +0 -0
- /package/dist/{chunk-4X73CGIL.js.map → chunk-AKIJTKEA.js.map} +0 -0
- /package/dist/{chunk-Q2QKRE4P.js.map → chunk-D4YWVZHD.js.map} +0 -0
- /package/dist/{chunk-33NZN73M.js.map → chunk-DTADAHJD.js.map} +0 -0
- /package/dist/{chunk-I2QETSZN.js.map → chunk-FK3JPTHI.js.map} +0 -0
- /package/dist/{chunk-AEEQN6L3.js.map → chunk-GGVHKYKZ.js.map} +0 -0
- /package/dist/{chunk-PHZDAHZC.js.map → chunk-LBOXKGAH.js.map} +0 -0
- /package/dist/{chunk-W6O7KBOD.js.map → chunk-MC4DPT4I.js.map} +0 -0
- /package/dist/{chunk-KXHNIHLC.js.map → chunk-MMPBJGWQ.js.map} +0 -0
- /package/dist/{chunk-NKDPCALC.js.map → chunk-QTJTBCTZ.js.map} +0 -0
- /package/dist/{chunk-EEXIFCXC.js.map → chunk-VBY3JQL2.js.map} +0 -0
- /package/dist/{chunk-TZ753B6A.js.map → chunk-WMDGGQXJ.js.map} +0 -0
- /package/dist/{chunk-HU7POUBS.js.map → chunk-YBCW544D.js.map} +0 -0
- /package/dist/{chunks-REYSCBPB.js.map → chunks-2UDUNVGQ.js.map} +0 -0
- /package/dist/{formula-IREEAC4T.js.map → formula-MPBZ7OMN.js.map} +0 -0
- /package/dist/{formula-EA5GDCUD.js.map → formula-NA3LD35B.js.map} +0 -0
- /package/dist/{image-ocr-LGOFUS3O.js.map → image-ocr-6TGDXUAS.js.map} +0 -0
- /package/dist/{image-ocr-JQJC5HWK.js.map → image-ocr-THA5BASF.js.map} +0 -0
- /package/dist/{model-bundle-YW62Y6UD.js.map → model-bundle-3YDTJ6EQ.js.map} +0 -0
- /package/dist/{models-AAL3IS2R.js.map → models-M7AX7VIN.js.map} +0 -0
- /package/dist/{parse-worker-v2-3JAHV7NY.js.map → parse-worker-v2-3ZMFWDFW.js.map} +0 -0
- /package/dist/{parser-ZBP5GOQK.js.map → parser-MNNJSFEZ.js.map} +0 -0
- /package/dist/{parser-4FCKKJ2N.js.map → parser-TD4VZDGY.js.map} +0 -0
- /package/dist/{pdf-ocr-HFAEOA7W.js.map → pdf-ocr-5HEVZKG5.js.map} +0 -0
- /package/dist/{pdf-ocr-Q4TPGDDI.js.map → pdf-ocr-6BAOQ6CY.js.map} +0 -0
- /package/dist/{profile-io-EDQTKLLL.js.map → profile-io-H4WQIGN6.js.map} +0 -0
- /package/dist/{rasterize-VD2XGHUJ.js.map → rasterize-EOPWJWBO.js.map} +0 -0
- /package/dist/{redact-doc-TBIBQJCT.js.map → redact-doc-BBZVAA3I.js.map} +0 -0
- /package/dist/{render-J5KAZAQH.js.map → render-ZZ4CGJ6J.js.map} +0 -0
- /package/dist/{seal-H2JNAZU7.js.map → seal-RRYFKTEQ.js.map} +0 -0
- /package/dist/{setup-5LYHCQRU.js.map → setup-UIPKBNLA.js.map} +0 -0
- /package/dist/{visual-7EO6GR3M.js.map → visual-DLLRTF6C.js.map} +0 -0
- /package/dist/{watch-YP4IWM75.js.map → watch-OXQ6O5HD.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 _chunkBODFTRWAcjs = require('./chunk-BODFTRWA.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 _chunkLJ7U7MFNcjs = require('./chunk-LJ7U7MFN.cjs');
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
@@ -78,12 +78,12 @@ var _chunkJILIA5EVcjs = require('./chunk-JILIA5EV.cjs');
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
var
|
|
82
|
-
require('./chunk-
|
|
81
|
+
var _chunkTPKP3WQUcjs = require('./chunk-TPKP3WQU.cjs');
|
|
82
|
+
require('./chunk-KFQNG2EA.cjs');
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
var
|
|
86
|
+
var _chunk6A4KYMQRcjs = require('./chunk-6A4KYMQR.cjs');
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -220,7 +220,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
220
220
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
221
221
|
state.seen.set(hash, filename);
|
|
222
222
|
if (withBytes) {
|
|
223
|
-
const png =
|
|
223
|
+
const png = _chunkBODFTRWAcjs.encodePng.call(void 0, w, h, rgba);
|
|
224
224
|
state.totalBytes += png.length;
|
|
225
225
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
226
226
|
}
|
|
@@ -616,13 +616,13 @@ function ocrVectorOps(opList, paths) {
|
|
|
616
616
|
|
|
617
617
|
// src/pdf/split-row-pattern.ts
|
|
618
618
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
619
|
-
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !
|
|
619
|
+
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !_chunkLJ7U7MFNcjs.IMAGE_CELLS.has(cell);
|
|
620
620
|
var labelsOf = (cell) => {
|
|
621
621
|
const labels = textOf(cell).split("\n").map((s) => s.trim()).filter(Boolean);
|
|
622
622
|
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;
|
|
623
623
|
};
|
|
624
624
|
var alignedLabels = (label, value, count) => {
|
|
625
|
-
const L =
|
|
625
|
+
const L = _chunkLJ7U7MFNcjs.CELL_LINES.get(label), V = _chunkLJ7U7MFNcjs.CELL_LINES.get(value);
|
|
626
626
|
let next = 0;
|
|
627
627
|
return !!L && !!V && L.length === count && V.length >= count && Math.abs(L[0].y - V[0].y) <= 1 && L.every((l) => {
|
|
628
628
|
while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
|
|
@@ -630,7 +630,7 @@ var alignedLabels = (label, value, count) => {
|
|
|
630
630
|
});
|
|
631
631
|
};
|
|
632
632
|
function partialAlignedLabelCells(table, owner, first) {
|
|
633
|
-
const pageOf = (a) => _nullishCoalesce(
|
|
633
|
+
const pageOf = (a) => _nullishCoalesce(_chunkTPKP3WQUcjs.CELL_PAGES.get(_nullishCoalesce(a.cell, () => ( table.cells[a.r][a.c]))), () => ( (a.r < first ? -1 : -2)));
|
|
634
634
|
const pairs = [];
|
|
635
635
|
let carried = false;
|
|
636
636
|
for (let c = 0; c < table.cols; ) {
|
|
@@ -653,10 +653,10 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
653
653
|
const keyed = pairs.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
|
|
654
654
|
if (keyed.length !== 1) return;
|
|
655
655
|
const label = keyed[0], value = pairs.find((p) => p.c === label.c + label.cs), context = pairs.find((p) => p.c + p.cs === label.c);
|
|
656
|
-
if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([
|
|
656
|
+
if (!value || !context || value === context || textOf(context.upper).replace(/\s+/g, "") === textOf(context.lower).replace(/\s+/g, "") || !_optionalChain([_chunkTPKP3WQUcjs.CELL_EDGES, 'access', _21 => _21.get, 'call', _22 => _22(context.upper), 'optionalAccess', _23 => _23.b]) || !_optionalChain([_chunkTPKP3WQUcjs.CELL_EDGES, 'access', _24 => _24.get, 'call', _25 => _25(context.lower), 'optionalAccess', _26 => _26.t])) return;
|
|
657
657
|
const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
|
|
658
658
|
if (D.length < 2 || sequence.length < 3 || new Set(sequence).size !== sequence.length || !alignedLabels(label.upper, value.upper, U.length)) return;
|
|
659
|
-
const L =
|
|
659
|
+
const L = _chunkLJ7U7MFNcjs.CELL_LINES.get(label.lower), V = _chunkLJ7U7MFNcjs.CELL_LINES.get(value.lower);
|
|
660
660
|
if (!L || !V || L.length !== D.length) return;
|
|
661
661
|
let next = V.findIndex((v) => Math.abs(v.y - L[0].y) <= 1);
|
|
662
662
|
if (next <= 0 || !V.slice(0, next).every((v) => v.y > L[0].y + 1) || !L.every((l) => {
|
|
@@ -676,14 +676,14 @@ function partialAlignedLabelCells(table, owner, first) {
|
|
|
676
676
|
continue;
|
|
677
677
|
}
|
|
678
678
|
if (list.length < 3 || new Set(list).size !== list.length) continue;
|
|
679
|
-
const visible = _nullishCoalesce(_optionalChain([
|
|
679
|
+
const visible = _nullishCoalesce(_optionalChain([_chunkLJ7U7MFNcjs.CELL_LINES, 'access', _31 => _31.get, 'call', _32 => _32(lc), 'optionalAccess', _33 => _33.length]), () => ( 0)), values = _chunkLJ7U7MFNcjs.CELL_LINES.get(vc);
|
|
680
680
|
if (visible < 3 || visible > list.length || !values || !alignedLabels(lc, vc, visible)) continue;
|
|
681
681
|
const top = Math.max(...values.map((v2) => v2.y)), bottom = Math.min(...values.map((v2) => v2.y));
|
|
682
682
|
const contexts = [];
|
|
683
683
|
for (let rr = r; rr < r + l.rs && rr < table.rows; rr++) {
|
|
684
684
|
const a = _optionalChain([owner, 'access', _34 => _34[rr], 'optionalAccess', _35 => _35[context.c]]), cell = a ? table.cells[a.r][a.c] : void 0;
|
|
685
685
|
if (!a || a.r !== rr || a.c !== context.c || a.cs !== context.cs || a.rs !== 1 || !cell || !plain(cell) || !textOf(cell) || pageOf(a) !== pageOf(l)) break;
|
|
686
|
-
const lines =
|
|
686
|
+
const lines = _chunkLJ7U7MFNcjs.CELL_LINES.get(cell);
|
|
687
687
|
if (!_optionalChain([lines, 'optionalAccess', _36 => _36.length]) || lines.some((line) => line.y > top + 1 || line.y < bottom - 1)) break;
|
|
688
688
|
contexts.push(textOf(cell).replace(/\s+/g, ""));
|
|
689
689
|
}
|
|
@@ -985,7 +985,7 @@ function rowStarts(t) {
|
|
|
985
985
|
}
|
|
986
986
|
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));
|
|
987
987
|
function cellPage(cell) {
|
|
988
|
-
const p =
|
|
988
|
+
const p = _chunkTPKP3WQUcjs.CELL_PAGES.get(cell);
|
|
989
989
|
if (p !== void 0 || !_optionalChain([cell, 'access', _103 => _103.blocks, 'optionalAccess', _104 => _104.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
990
990
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
991
991
|
}
|
|
@@ -1014,7 +1014,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
1014
1014
|
rows.forEach((starts, r) => {
|
|
1015
1015
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
1016
1016
|
for (const { cell } of starts) {
|
|
1017
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
1017
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkTPKP3WQUcjs.CELL_PAGES.set(cell, page2);
|
|
1018
1018
|
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _107 => _107.find, 'call', _108 => _108((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
|
|
1019
1019
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
1020
1020
|
}
|
|
@@ -1074,8 +1074,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1074
1074
|
if (!splits.length) continue;
|
|
1075
1075
|
const clone = (cell, patch) => {
|
|
1076
1076
|
const out = { ...cell, ...patch };
|
|
1077
|
-
const p =
|
|
1078
|
-
if (p !== void 0)
|
|
1077
|
+
const p = _chunkTPKP3WQUcjs.CELL_PAGES.get(cell);
|
|
1078
|
+
if (p !== void 0) _chunkTPKP3WQUcjs.CELL_PAGES.set(out, p);
|
|
1079
1079
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
1080
1080
|
return out;
|
|
1081
1081
|
};
|
|
@@ -1086,7 +1086,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1086
1086
|
for (const { cell, c, split } of splits) {
|
|
1087
1087
|
cells[r][c] = clone(cell, { ...split.head, rowSpan: cut - r });
|
|
1088
1088
|
const tail = { ...cell, ...split.tail, rowSpan: r + cell.rowSpan - cut };
|
|
1089
|
-
|
|
1089
|
+
_chunkTPKP3WQUcjs.CELL_PAGES.set(tail, split.page);
|
|
1090
1090
|
setSplits(tail, split.rest);
|
|
1091
1091
|
cells[cut][c] = tail;
|
|
1092
1092
|
}
|
|
@@ -1096,7 +1096,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
1096
1096
|
for (const { cell, c, split } of splits) {
|
|
1097
1097
|
cells[r][c] = clone(cell, split.head);
|
|
1098
1098
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
1099
|
-
|
|
1099
|
+
_chunkTPKP3WQUcjs.CELL_PAGES.set(tail, split.page);
|
|
1100
1100
|
setSplits(tail, split.rest);
|
|
1101
1101
|
row[c] = tail;
|
|
1102
1102
|
}
|
|
@@ -1187,7 +1187,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1187
1187
|
if (cols < 1) return null;
|
|
1188
1188
|
const pa = anchorsOf(prev), ca = anchorsOf(curr);
|
|
1189
1189
|
const cutOpen = (() => {
|
|
1190
|
-
const u =
|
|
1190
|
+
const u = _chunkLJ7U7MFNcjs.ROW_RULES.get(prev), d = _chunkLJ7U7MFNcjs.ROW_RULES.get(curr);
|
|
1191
1191
|
return !!u && !!d && !u.bottom && !d.top;
|
|
1192
1192
|
})();
|
|
1193
1193
|
let skip = 0, head = 0;
|
|
@@ -1219,19 +1219,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1219
1219
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
1220
1220
|
}
|
|
1221
1221
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
1222
|
-
const lines =
|
|
1223
|
-
if (lines)
|
|
1224
|
-
if (
|
|
1225
|
-
const edges =
|
|
1222
|
+
const lines = _chunkLJ7U7MFNcjs.CELL_LINES.get(a.cell);
|
|
1223
|
+
if (lines) _chunkLJ7U7MFNcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
1224
|
+
if (_chunkLJ7U7MFNcjs.IMAGE_CELLS.has(a.cell)) _chunkLJ7U7MFNcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
1225
|
+
const edges = _chunkTPKP3WQUcjs.CELL_EDGES.get(a.cell);
|
|
1226
1226
|
if (edges) {
|
|
1227
|
-
|
|
1227
|
+
_chunkTPKP3WQUcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
1228
1228
|
edged = true;
|
|
1229
1229
|
}
|
|
1230
1230
|
return true;
|
|
1231
1231
|
};
|
|
1232
|
-
for (const a of pa) if (!
|
|
1232
|
+
for (const a of pa) if (!_chunkLJ7U7MFNcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
1233
1233
|
for (const a of ca) {
|
|
1234
|
-
if (a.r < skip ||
|
|
1234
|
+
if (a.r < skip || _chunkLJ7U7MFNcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
1235
1235
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
1236
1236
|
}
|
|
1237
1237
|
const first = prev.rows;
|
|
@@ -1255,9 +1255,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1255
1255
|
const grown = { ...above, rs: newRs };
|
|
1256
1256
|
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;
|
|
1257
1257
|
}
|
|
1258
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1258
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkLJ7U7MFNcjs.FILLER_CELLS.add(grid[r][c]);
|
|
1259
1259
|
if (edged) {
|
|
1260
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1260
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkTPKP3WQUcjs.CELL_EDGES.set(grid[r][c], _chunkLJ7U7MFNcjs.NO_EDGES);
|
|
1261
1261
|
}
|
|
1262
1262
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1263
1263
|
let r = prev.rows;
|
|
@@ -1266,7 +1266,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1266
1266
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1267
1267
|
}
|
|
1268
1268
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1269
|
-
const pr =
|
|
1269
|
+
const pr = _chunkLJ7U7MFNcjs.ROW_RULES.get(prev), cr = _chunkLJ7U7MFNcjs.ROW_RULES.get(curr);
|
|
1270
1270
|
const shifted = dx !== 0;
|
|
1271
1271
|
const cut = {
|
|
1272
1272
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1274,13 +1274,13 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1274
1274
|
list: !shifted ? "any" : skip > 0 && ca.filter((a) => a.r < skip && a.cell.text.trim()).length < 2 ? "none" : "multi"
|
|
1275
1275
|
};
|
|
1276
1276
|
let partial = !skip && cols === prev.cols && cols === curr.cols && cut.ruled && prevBottom !== void 0 ? partialAlignedLabelCells(table, owner, first) : void 0;
|
|
1277
|
-
if (partial && (continuesAcross(partial.context.upper, partial.context.lower, U[partial.context.c], U[partial.context.c + partial.context.cs]) || clauseContinues(partial.context.upper, partial.context.lower) || quantityContinues(partial.context.upper, partial.context.lower) || !continuesAcross(partial.value.upper, partial.value.lower, U[partial.value.c], U[partial.value.c + partial.value.cs]) ||
|
|
1277
|
+
if (partial && (continuesAcross(partial.context.upper, partial.context.lower, U[partial.context.c], U[partial.context.c + partial.context.cs]) || clauseContinues(partial.context.upper, partial.context.lower) || quantityContinues(partial.context.upper, partial.context.lower) || !continuesAcross(partial.value.upper, partial.value.lower, U[partial.value.c], U[partial.value.c + partial.value.cs]) || _chunkLJ7U7MFNcjs.startsNewItem.call(void 0, partial.value.upper.text, partial.value.lower.text))) partial = void 0;
|
|
1278
1278
|
const selected = partial ? /* @__PURE__ */ new Set([partial.label.c, partial.value.c]) : void 0;
|
|
1279
1279
|
let split = !selected && rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
|
|
1280
1280
|
if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U, selected) && !selected) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
|
|
1281
1281
|
if (pr && cr) {
|
|
1282
1282
|
const cutRuled = pr.bottom || cr.top;
|
|
1283
|
-
|
|
1283
|
+
_chunkLJ7U7MFNcjs.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) });
|
|
1284
1284
|
}
|
|
1285
1285
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1286
1286
|
}
|
|
@@ -1342,18 +1342,18 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1342
1342
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1343
1343
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1344
1344
|
if (selected && !selected.has(u.c)) continue;
|
|
1345
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1346
|
-
const openSeam = hasContent(a) && hasContent(b) &&
|
|
1345
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkLJ7U7MFNcjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
1346
|
+
const openSeam = hasContent(a) && hasContent(b) && _chunkLJ7U7MFNcjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
|
|
1347
1347
|
if (!r || r === first) return false;
|
|
1348
1348
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1349
1349
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1350
|
-
const ue =
|
|
1350
|
+
const ue = _chunkTPKP3WQUcjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkTPKP3WQUcjs.CELL_EDGES.get(table.cells[down.r][down.c]);
|
|
1351
1351
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1352
1352
|
});
|
|
1353
1353
|
if (!selected && !openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1354
1354
|
if (!straddles && !midWord) continue;
|
|
1355
1355
|
if (u.r >= last && d.rs < 2) continue;
|
|
1356
|
-
const U =
|
|
1356
|
+
const U = _chunkLJ7U7MFNcjs.CELL_LINES.get(a);
|
|
1357
1357
|
if (!_optionalChain([U, 'optionalAccess', _134 => _134.length]) || !hasContent(b)) continue;
|
|
1358
1358
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1359
1359
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -1371,7 +1371,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1371
1371
|
return merged;
|
|
1372
1372
|
}
|
|
1373
1373
|
function longLastLine(c) {
|
|
1374
|
-
const L =
|
|
1374
|
+
const L = _chunkLJ7U7MFNcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _135 => _135[L.length - 1]]);
|
|
1375
1375
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1376
1376
|
}
|
|
1377
1377
|
function filledToBottom(U, bottom) {
|
|
@@ -1404,7 +1404,7 @@ function nextItemHead(prev, next) {
|
|
|
1404
1404
|
return false;
|
|
1405
1405
|
}
|
|
1406
1406
|
function continuesAcross(u, d, x1, x2) {
|
|
1407
|
-
const U =
|
|
1407
|
+
const U = _chunkLJ7U7MFNcjs.CELL_LINES.get(u), D = _chunkLJ7U7MFNcjs.CELL_LINES.get(d);
|
|
1408
1408
|
if (!_optionalChain([U, 'optionalAccess', _136 => _136.length]) || !_optionalChain([D, 'optionalAccess', _137 => _137.length])) return false;
|
|
1409
1409
|
const last = U[U.length - 1];
|
|
1410
1410
|
const fs = last.h || 10;
|
|
@@ -1422,7 +1422,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1422
1422
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1423
1423
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1424
1424
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1425
|
-
const newItem =
|
|
1425
|
+
const newItem = _chunkLJ7U7MFNcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1426
1426
|
const all = D.length ? U.concat(D) : U;
|
|
1427
1427
|
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));
|
|
1428
1428
|
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;
|
|
@@ -1439,10 +1439,10 @@ function outlineContinues(u, d) {
|
|
|
1439
1439
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1440
1440
|
}
|
|
1441
1441
|
function lineEnded(c, x1, x2, next) {
|
|
1442
|
-
const L =
|
|
1442
|
+
const L = _chunkLJ7U7MFNcjs.CELL_LINES.get(c);
|
|
1443
1443
|
if (!L || L.length !== 1) return false;
|
|
1444
1444
|
const l = L[0], h = l.h || 10;
|
|
1445
|
-
const d0 = next ? _optionalChain([
|
|
1445
|
+
const d0 = next ? _optionalChain([_chunkLJ7U7MFNcjs.CELL_LINES, 'access', _138 => _138.get, 'call', _139 => _139(next), 'optionalAccess', _140 => _140[0]]) : void 0;
|
|
1446
1446
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1447
1447
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _141 => _141.text]), () => ( "")))) * h;
|
|
1448
1448
|
}
|
|
@@ -1453,15 +1453,15 @@ function firstWordUnits(text) {
|
|
|
1453
1453
|
return units;
|
|
1454
1454
|
}
|
|
1455
1455
|
function appendCell(a, b) {
|
|
1456
|
-
if (
|
|
1456
|
+
if (_chunkLJ7U7MFNcjs.IMAGE_CELLS.has(b)) _chunkLJ7U7MFNcjs.IMAGE_CELLS.add(a);
|
|
1457
1457
|
if (_optionalChain([a, 'access', _142 => _142.blocks, 'optionalAccess', _143 => _143.length]) || _optionalChain([b, 'access', _144 => _144.blocks, 'optionalAccess', _145 => _145.length])) {
|
|
1458
1458
|
const asBlocks = (c) => _optionalChain([c, 'access', _146 => _146.blocks, 'optionalAccess', _147 => _147.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
|
|
1459
1459
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1460
1460
|
}
|
|
1461
1461
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1462
|
-
|
|
1462
|
+
_chunkLJ7U7MFNcjs.joinCellEdges.call(void 0, a, b);
|
|
1463
1463
|
}
|
|
1464
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _148 => _148.blocks, 'optionalAccess', _149 => _149.length]) ||
|
|
1464
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _148 => _148.blocks, 'optionalAccess', _149 => _149.length]) || _chunkLJ7U7MFNcjs.IMAGE_CELLS.has(cell);
|
|
1465
1465
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1466
1466
|
var batchim = (ch) => {
|
|
1467
1467
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1469,7 +1469,7 @@ var batchim = (ch) => {
|
|
|
1469
1469
|
};
|
|
1470
1470
|
function clauseContinues(u, d) {
|
|
1471
1471
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1472
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1472
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkLJ7U7MFNcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1473
1473
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1474
1474
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1475
1475
|
}
|
|
@@ -1477,8 +1477,8 @@ function quantityContinues(u, d) {
|
|
|
1477
1477
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1478
1478
|
}
|
|
1479
1479
|
function wordOverflows(u, d, x1, x2) {
|
|
1480
|
-
const U =
|
|
1481
|
-
if (!_optionalChain([U, 'optionalAccess', _150 => _150.length]) ||
|
|
1480
|
+
const U = _chunkLJ7U7MFNcjs.CELL_LINES.get(u);
|
|
1481
|
+
if (!_optionalChain([U, 'optionalAccess', _150 => _150.length]) || _chunkLJ7U7MFNcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1482
1482
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1483
1483
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1484
1484
|
}
|
|
@@ -1536,7 +1536,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1536
1536
|
if (!carriedSplit) {
|
|
1537
1537
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1538
1538
|
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;
|
|
1539
|
-
const oneLine = (c) => _optionalChain([
|
|
1539
|
+
const oneLine = (c) => _optionalChain([_chunkLJ7U7MFNcjs.CELL_LINES, 'access', _152 => _152.get, 'call', _153 => _153(c), 'optionalAccess', _154 => _154.length]) === 1;
|
|
1540
1540
|
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;
|
|
1541
1541
|
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));
|
|
1542
1542
|
if (!(cut.open && !newCell)) {
|
|
@@ -1628,19 +1628,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1628
1628
|
placeJoined(blocks, i, j, joined);
|
|
1629
1629
|
continue;
|
|
1630
1630
|
}
|
|
1631
|
-
if (
|
|
1631
|
+
if (_chunkLJ7U7MFNcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1632
1632
|
blocks.splice(j, 1);
|
|
1633
1633
|
i++;
|
|
1634
1634
|
continue;
|
|
1635
1635
|
}
|
|
1636
1636
|
if (joined === null) continue;
|
|
1637
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1637
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkLJ7U7MFNcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1638
1638
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1639
1639
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1640
1640
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1641
1641
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1642
|
-
const px =
|
|
1643
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1642
|
+
const px = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(prev.table), cx = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(curr.table);
|
|
1643
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(prev.table) && !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1644
1644
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1645
1645
|
let currCells = curr.table.cells;
|
|
1646
1646
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1651,16 +1651,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1651
1651
|
blocks.splice(j, 1);
|
|
1652
1652
|
continue;
|
|
1653
1653
|
}
|
|
1654
|
-
if (px && cx && !
|
|
1654
|
+
if (px && cx && !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(prev.table) && !_chunkLJ7U7MFNcjs.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 && _chunkLJ7U7MFNcjs.CELL_LINES.has(c))) {
|
|
1655
1655
|
const dx = px[0] - cx[0];
|
|
1656
1656
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1657
1657
|
if (_optionalChain([part, 'optionalAccess', _175 => _175.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1658
1658
|
const last = prev.table.rows - 1;
|
|
1659
1659
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1660
|
-
const U =
|
|
1661
|
-
|
|
1660
|
+
const U = _chunkLJ7U7MFNcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkLJ7U7MFNcjs.CELL_LINES.get(currCells[0][c]);
|
|
1661
|
+
_chunkLJ7U7MFNcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1662
1662
|
}
|
|
1663
|
-
|
|
1663
|
+
_chunkLJ7U7MFNcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1664
1664
|
placeJoined(blocks, i, j, part.table);
|
|
1665
1665
|
continue;
|
|
1666
1666
|
}
|
|
@@ -1673,20 +1673,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1673
1673
|
caption: prev.table.caption,
|
|
1674
1674
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1675
1675
|
};
|
|
1676
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1677
|
-
if (
|
|
1676
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkLJ7U7MFNcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1677
|
+
if (_chunkLJ7U7MFNcjs.CLIP_TABLES.has(prev.table) || _chunkLJ7U7MFNcjs.CLIP_TABLES.has(curr.table)) _chunkLJ7U7MFNcjs.CLIP_TABLES.add(merged);
|
|
1678
1678
|
placeJoined(blocks, i, j, merged);
|
|
1679
1679
|
}
|
|
1680
1680
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1681
1681
|
const t = blocks[i].table;
|
|
1682
|
-
if (blocks[i].type === "table" && t &&
|
|
1682
|
+
if (blocks[i].type === "table" && t && _chunkLJ7U7MFNcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1683
1683
|
}
|
|
1684
1684
|
}
|
|
1685
1685
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1686
1686
|
if (!pageHeights) return;
|
|
1687
1687
|
for (let i = 0; i < blocks.length; i++) {
|
|
1688
1688
|
const L = blocks[i];
|
|
1689
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1689
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(L.table) || _chunkLJ7U7MFNcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1690
1690
|
const ph = pageHeights.get(L.pageNumber);
|
|
1691
1691
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1692
1692
|
let s0 = i, s1 = i;
|
|
@@ -1715,8 +1715,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1715
1715
|
}
|
|
1716
1716
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1717
1717
|
const pt = prev.table, ct = curr.table;
|
|
1718
|
-
if (!
|
|
1719
|
-
const px =
|
|
1718
|
+
if (!_chunkLJ7U7MFNcjs.CLIP_TABLES.has(pt) || !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(ct)) return null;
|
|
1719
|
+
const px = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(pt), cx = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(ct);
|
|
1720
1720
|
if (!px || !cx) return null;
|
|
1721
1721
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1722
1722
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -1732,15 +1732,15 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1732
1732
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1733
1733
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1734
1734
|
};
|
|
1735
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1735
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkLJ7U7MFNcjs.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);
|
|
1736
1736
|
}
|
|
1737
1737
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _180 => _180.bbox, 'optionalAccess', _181 => _181.y]), lex);
|
|
1738
1738
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1739
|
-
|
|
1740
|
-
const ys =
|
|
1741
|
-
if (ys)
|
|
1742
|
-
|
|
1743
|
-
|
|
1739
|
+
_chunkLJ7U7MFNcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1740
|
+
const ys = _chunkLJ7U7MFNcjs.TABLE_ROWYS.get(pt);
|
|
1741
|
+
if (ys) _chunkLJ7U7MFNcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1742
|
+
_chunkLJ7U7MFNcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkLJ7U7MFNcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1743
|
+
_chunkLJ7U7MFNcjs.CLIP_TABLES.add(res.table);
|
|
1744
1744
|
return res.table;
|
|
1745
1745
|
}
|
|
1746
1746
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
@@ -1764,12 +1764,12 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
1764
1764
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1765
1765
|
}
|
|
1766
1766
|
function pushedLead(prev, curr) {
|
|
1767
|
-
if (!
|
|
1767
|
+
if (!_chunkLJ7U7MFNcjs.CLIP_TABLES.has(prev.table) || !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1768
1768
|
const lead = leadRows(curr.table);
|
|
1769
1769
|
return lead.image && lead.height > prev.bbox.y;
|
|
1770
1770
|
}
|
|
1771
1771
|
function leadRows(t) {
|
|
1772
|
-
const ys =
|
|
1772
|
+
const ys = _chunkLJ7U7MFNcjs.TABLE_ROWYS.get(t);
|
|
1773
1773
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1774
1774
|
const anchors = anchorsOf(t);
|
|
1775
1775
|
let end = 1, image = false;
|
|
@@ -1777,17 +1777,17 @@ function leadRows(t) {
|
|
|
1777
1777
|
for (const a of anchors) {
|
|
1778
1778
|
if (a.r !== r) continue;
|
|
1779
1779
|
end = Math.max(end, r + a.rs);
|
|
1780
|
-
if (
|
|
1780
|
+
if (_chunkLJ7U7MFNcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1781
1781
|
}
|
|
1782
1782
|
}
|
|
1783
1783
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1784
1784
|
}
|
|
1785
1785
|
function tailOf(b) {
|
|
1786
|
-
const t = b.table &&
|
|
1786
|
+
const t = b.table && _chunkLJ7U7MFNcjs.TABLE_TAIL.get(b.table);
|
|
1787
1787
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1788
1788
|
}
|
|
1789
1789
|
function firstRowSig(t) {
|
|
1790
|
-
const x =
|
|
1790
|
+
const x = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(t);
|
|
1791
1791
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1792
1792
|
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, "") }));
|
|
1793
1793
|
}
|
|
@@ -1840,7 +1840,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1840
1840
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1841
1841
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1842
1842
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1843
|
-
const px =
|
|
1843
|
+
const px = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(pb.table), cx = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(cur.table);
|
|
1844
1844
|
if (!px || !cx) break;
|
|
1845
1845
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1846
1846
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1911,7 +1911,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1911
1911
|
var COL_MATCH_TOL = 0.5;
|
|
1912
1912
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1913
1913
|
function lastRowCell(t, x1, x2) {
|
|
1914
|
-
const xs =
|
|
1914
|
+
const xs = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(t);
|
|
1915
1915
|
const covered = /* @__PURE__ */ new Set();
|
|
1916
1916
|
for (let r = 0; r < t.rows; r++) {
|
|
1917
1917
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -1929,7 +1929,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1929
1929
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1930
1930
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1931
1931
|
const part = blocks[j];
|
|
1932
|
-
const from = part.table ?
|
|
1932
|
+
const from = part.table ? _chunkLJ7U7MFNcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1933
1933
|
if (!from || !part.table) {
|
|
1934
1934
|
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
1935
1935
|
continue;
|
|
@@ -1945,12 +1945,12 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1945
1945
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1946
1946
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1947
1947
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1948
|
-
if (
|
|
1949
|
-
|
|
1950
|
-
const lines =
|
|
1951
|
-
if (_optionalChain([lines, 'optionalAccess', _205 => _205.length]))
|
|
1952
|
-
if (part.pageNumber && part.bbox)
|
|
1953
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _206 => _206.blocks, 'optionalAccess', _207 => _207.length]) ||
|
|
1948
|
+
if (_chunkLJ7U7MFNcjs.IMAGE_CELLS.has(add)) _chunkLJ7U7MFNcjs.IMAGE_CELLS.add(cell);
|
|
1949
|
+
_chunkLJ7U7MFNcjs.joinCellEdges.call(void 0, cell, add);
|
|
1950
|
+
const lines = _chunkLJ7U7MFNcjs.CELL_LINES.get(add);
|
|
1951
|
+
if (_optionalChain([lines, 'optionalAccess', _205 => _205.length])) _chunkLJ7U7MFNcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkLJ7U7MFNcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1952
|
+
if (part.pageNumber && part.bbox) _chunkLJ7U7MFNcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkLJ7U7MFNcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1953
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _206 => _206.blocks, 'optionalAccess', _207 => _207.length]) || _chunkLJ7U7MFNcjs.IMAGE_CELLS.has(cell)) _chunkLJ7U7MFNcjs.EMPTY_PARTS.delete(prev.table);
|
|
1954
1954
|
blocks.splice(j, 1);
|
|
1955
1955
|
if (cell.blocks && at > 0) {
|
|
1956
1956
|
const nextAt = cell.blocks[at];
|
|
@@ -1962,11 +1962,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1962
1962
|
}
|
|
1963
1963
|
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
1964
1964
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1965
|
-
if (!_optionalChain([prev, 'optionalAccess', _208 => _208.table]) || !_optionalChain([frame, 'optionalAccess', _209 => _209.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !
|
|
1965
|
+
if (!_optionalChain([prev, 'optionalAccess', _208 => _208.table]) || !_optionalChain([frame, 'optionalAccess', _209 => _209.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1966
1966
|
const inner = _optionalChain([frame, 'access', _210 => _210.table, 'access', _211 => _211.cells, 'access', _212 => _212[0], 'optionalAccess', _213 => _213[0], 'optionalAccess', _214 => _214.blocks]);
|
|
1967
1967
|
const next = _optionalChain([inner, 'optionalAccess', _215 => _215[0]]);
|
|
1968
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _216 => _216.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
1969
|
-
const px =
|
|
1968
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _216 => _216.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(prev.table) || !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1969
|
+
const px = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(prev.table), nx = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(next.table);
|
|
1970
1970
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1971
1971
|
const ph = _optionalChain([pageHeights, 'optionalAccess', _217 => _217.get, 'call', _218 => _218(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _219 => _219.get, 'call', _220 => _220(next.pageNumber)]);
|
|
1972
1972
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
@@ -1976,15 +1976,15 @@ function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
|
1976
1976
|
function fillNestedContinuation(blocks, at) {
|
|
1977
1977
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1978
1978
|
const t = _optionalChain([prev, 'optionalAccess', _223 => _223.table]), u = _optionalChain([next, 'optionalAccess', _224 => _224.table]);
|
|
1979
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1980
|
-
const xs =
|
|
1979
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(t) || !_chunkLJ7U7MFNcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1980
|
+
const xs = _chunkLJ7U7MFNcjs.TABLE_COLXS.get(u);
|
|
1981
1981
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1982
1982
|
const add = _optionalChain([u, 'access', _225 => _225.cells, 'access', _226 => _226[0], 'optionalAccess', _227 => _227[0]]);
|
|
1983
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _228 => _228.blocks, 'optionalAccess', _229 => _229.length]) ||
|
|
1983
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _228 => _228.blocks, 'optionalAccess', _229 => _229.length]) || _chunkLJ7U7MFNcjs.IMAGE_CELLS.has(cell)) return;
|
|
1984
1984
|
cell.text = add.text;
|
|
1985
1985
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1986
|
-
if (
|
|
1987
|
-
|
|
1986
|
+
if (_chunkLJ7U7MFNcjs.IMAGE_CELLS.has(add)) _chunkLJ7U7MFNcjs.IMAGE_CELLS.add(cell);
|
|
1987
|
+
_chunkLJ7U7MFNcjs.joinCellEdges.call(void 0, cell, add);
|
|
1988
1988
|
blocks.splice(at, 1);
|
|
1989
1989
|
}
|
|
1990
1990
|
|
|
@@ -2584,12 +2584,12 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
2584
2584
|
}
|
|
2585
2585
|
}
|
|
2586
2586
|
for (const q of queues.values()) for (let k = 0; k < q.length; k++) {
|
|
2587
|
-
const pair = k + 1 < q.length ?
|
|
2587
|
+
const pair = k + 1 < q.length ? _chunkTPKP3WQUcjs.pairedNumber.call(void 0, q[k], q[k + 1]) : void 0;
|
|
2588
2588
|
if (pair !== void 0) {
|
|
2589
2589
|
q[k] = pair;
|
|
2590
2590
|
q[k + 1] = "";
|
|
2591
2591
|
k++;
|
|
2592
|
-
} else q[k] =
|
|
2592
|
+
} else q[k] = _chunkTPKP3WQUcjs.mapPuaText.call(void 0, q[k]);
|
|
2593
2593
|
}
|
|
2594
2594
|
const byFont = /* @__PURE__ */ new Map();
|
|
2595
2595
|
for (const it of items) {
|
|
@@ -2624,15 +2624,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
2624
2624
|
function marginContextBlocks(raw, page, view) {
|
|
2625
2625
|
const [x1, y1, x2, y2] = view;
|
|
2626
2626
|
const width = x2 - x1, height = y2 - y1;
|
|
2627
|
-
const items =
|
|
2627
|
+
const items = _chunkLJ7U7MFNcjs.filterHiddenText.call(void 0, _chunkLJ7U7MFNcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
2628
2628
|
for (const item of items) {
|
|
2629
2629
|
item.x -= x1;
|
|
2630
2630
|
item.y -= y1;
|
|
2631
2631
|
}
|
|
2632
|
-
return
|
|
2633
|
-
const bbox =
|
|
2632
|
+
return _chunkLJ7U7MFNcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
2633
|
+
const bbox = _chunkLJ7U7MFNcjs.computeBBox.call(void 0, line, page);
|
|
2634
2634
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
2635
|
-
return [{ type: "paragraph", text:
|
|
2635
|
+
return [{ type: "paragraph", text: _chunkLJ7U7MFNcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkLJ7U7MFNcjs.dominantStyle.call(void 0, line) }];
|
|
2636
2636
|
});
|
|
2637
2637
|
}
|
|
2638
2638
|
|
|
@@ -2668,7 +2668,7 @@ var WINANSI_REVERSE = {
|
|
|
2668
2668
|
};
|
|
2669
2669
|
function symbolFontTable(fontName) {
|
|
2670
2670
|
if (!fontName) return void 0;
|
|
2671
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
2671
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkTPKP3WQUcjs.WINGDINGS;
|
|
2672
2672
|
return void 0;
|
|
2673
2673
|
}
|
|
2674
2674
|
function remapSymbolText(text, table) {
|
|
@@ -3571,7 +3571,7 @@ function mergeEnclosedDigits(items) {
|
|
|
3571
3571
|
if (!/^\d\d?$/.test(digits)) continue;
|
|
3572
3572
|
const mid = (inside2[0].x + inside2[inside2.length - 1].x + inside2[inside2.length - 1].w) / 2;
|
|
3573
3573
|
if (Math.abs(mid - (s.x + s.w / 2)) > s.fontSize * 0.15) continue;
|
|
3574
|
-
s.text =
|
|
3574
|
+
s.text = _chunkTPKP3WQUcjs.enclosedNumber.call(void 0, Number(digits));
|
|
3575
3575
|
for (const d of inside2) drop.add(d);
|
|
3576
3576
|
}
|
|
3577
3577
|
if (!drop.size) return;
|
|
@@ -3753,7 +3753,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3753
3753
|
if (block.type !== "heading" || !block.text) continue;
|
|
3754
3754
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
3755
3755
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _304 => _304.style, 'optionalAccess', _305 => _305.fontSize]), () => ( 0));
|
|
3756
|
-
const tocEntry = i > 0 &&
|
|
3756
|
+
const tocEntry = i > 0 && _chunkLJ7U7MFNcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkLJ7U7MFNcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
3757
3757
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
3758
3758
|
const proseStyle = _optionalChain([block, 'access', _306 => _306.style, 'optionalAccess', _307 => _307.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
3759
3759
|
const next = blocks[i + 1];
|
|
@@ -3851,7 +3851,7 @@ function splitSingleCellTables(blocks) {
|
|
|
3851
3851
|
const out = [];
|
|
3852
3852
|
for (const b of blocks) {
|
|
3853
3853
|
const t = b.type === "table" ? b.table : void 0;
|
|
3854
|
-
const title = t &&
|
|
3854
|
+
const title = t && _chunkLJ7U7MFNcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3855
3855
|
if (title) {
|
|
3856
3856
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3857
3857
|
continue;
|
|
@@ -3887,7 +3887,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
3887
3887
|
const lines = cell.text.split("\n");
|
|
3888
3888
|
const out = [lines[0]];
|
|
3889
3889
|
for (const line of lines.slice(1)) {
|
|
3890
|
-
if (
|
|
3890
|
+
if (_chunkLJ7U7MFNcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
3891
3891
|
else out.push(line);
|
|
3892
3892
|
}
|
|
3893
3893
|
cell.text = out.join("\n");
|
|
@@ -3907,10 +3907,10 @@ function cleanPdfText(text, opts) {
|
|
|
3907
3907
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
3908
3908
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
3909
3909
|
if (line.startsWith("|")) {
|
|
3910
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
3910
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkLJ7U7MFNcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
3911
3911
|
}
|
|
3912
3912
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _387 => _387.exec, 'call', _388 => _388(line), 'optionalAccess', _389 => _389[0]]), () => ( ""));
|
|
3913
|
-
return mark +
|
|
3913
|
+
return mark + _chunkLJ7U7MFNcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
3914
3914
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
3915
3915
|
}
|
|
3916
3916
|
function startsWithMarker(line) {
|
|
@@ -3942,7 +3942,7 @@ function mergeKoreanLines(text) {
|
|
|
3942
3942
|
continue;
|
|
3943
3943
|
}
|
|
3944
3944
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
3945
|
-
result[result.length - 1] = prev +
|
|
3945
|
+
result[result.length - 1] = prev + _chunkLJ7U7MFNcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
3946
3946
|
} else {
|
|
3947
3947
|
result.push(curr);
|
|
3948
3948
|
}
|
|
@@ -3958,7 +3958,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3958
3958
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3959
3959
|
for (const a of annots) {
|
|
3960
3960
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3961
|
-
const url =
|
|
3961
|
+
const url = _chunk6A4KYMQRcjs.sanitizeHref.call(void 0, a.url);
|
|
3962
3962
|
if (!url) continue;
|
|
3963
3963
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3964
3964
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -4010,7 +4010,7 @@ function mergeLinkRuns(markdown) {
|
|
|
4010
4010
|
|
|
4011
4011
|
// src/pdf/formula-ocr.ts
|
|
4012
4012
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
4013
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
4013
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-6DJAY3KI.cjs")));
|
|
4014
4014
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
4015
4015
|
await ensureFormulaModels((p) => {
|
|
4016
4016
|
if (p.phase === "download" && p.total) {
|
|
@@ -4201,13 +4201,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
4201
4201
|
try {
|
|
4202
4202
|
return await Promise.race([
|
|
4203
4203
|
loadingTask.promise.catch((e) => {
|
|
4204
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
4204
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunk6A4KYMQRcjs.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)");
|
|
4205
4205
|
throw e;
|
|
4206
4206
|
}),
|
|
4207
4207
|
new Promise((_, reject) => {
|
|
4208
4208
|
timer = setTimeout(() => {
|
|
4209
4209
|
loadingTask.destroy();
|
|
4210
|
-
reject(new (0,
|
|
4210
|
+
reject(new (0, _chunk6A4KYMQRcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
4211
4211
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
4212
4212
|
})
|
|
4213
4213
|
]);
|
|
@@ -4217,14 +4217,14 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
4217
4217
|
}
|
|
4218
4218
|
async function parsePdfDocument(buffer, options) {
|
|
4219
4219
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _390 => _390.formulaOcr]) ? buffer : null;
|
|
4220
|
-
const ocrOptionError =
|
|
4221
|
-
if (ocrOptionError) throw new (0,
|
|
4222
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _391 => _391.ocr]) === void 0 && await
|
|
4220
|
+
const ocrOptionError = _chunkTPKP3WQUcjs.validateOcrOptions.call(void 0, options);
|
|
4221
|
+
if (ocrOptionError) throw new (0, _chunk6A4KYMQRcjs.KordocError)(ocrOptionError);
|
|
4222
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _391 => _391.ocr]) === void 0 && await _chunkLJ7U7MFNcjs.ocrModelsCached.call(void 0, _chunkLJ7U7MFNcjs.resolveOcrModels.call(void 0, options));
|
|
4223
4223
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _392 => _392.ocr]) || autoOcr ? buffer : null;
|
|
4224
4224
|
const doc = await loadPdfWithTimeout(buffer);
|
|
4225
4225
|
try {
|
|
4226
4226
|
const pageCount = doc.numPages;
|
|
4227
|
-
if (pageCount === 0) throw new (0,
|
|
4227
|
+
if (pageCount === 0) throw new (0, _chunk6A4KYMQRcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
4228
4228
|
const metadata = { pageCount, pageMode: "layout" };
|
|
4229
4229
|
await extractPdfMetadata(doc, metadata);
|
|
4230
4230
|
const blocks = [];
|
|
@@ -4253,7 +4253,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4253
4253
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
4254
4254
|
const carry = {};
|
|
4255
4255
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
4256
|
-
const wrapLexicon = new (0,
|
|
4256
|
+
const wrapLexicon = new (0, _chunkLJ7U7MFNcjs.WrapLexicon)();
|
|
4257
4257
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
4258
4258
|
const headerContext = [];
|
|
4259
4259
|
if (pageFilter && _optionalChain([options, 'optionalAccess', _395 => _395.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
@@ -4300,8 +4300,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4300
4300
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
4301
4301
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4302
4302
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4303
|
-
const items =
|
|
4304
|
-
const filtered =
|
|
4303
|
+
const items = _chunkLJ7U7MFNcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
4304
|
+
const filtered = _chunkLJ7U7MFNcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
4305
4305
|
const joined = joinVerticalColumns(filtered.visible);
|
|
4306
4306
|
const visible = dropTabLeaderDots(joined);
|
|
4307
4307
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -4328,7 +4328,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4328
4328
|
} : rawOps;
|
|
4329
4329
|
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _402 => _402(loadedName), 'optionalAccess', _403 => _403.name]));
|
|
4330
4330
|
remapControlGlyphs(visible, differencesOf);
|
|
4331
|
-
await
|
|
4331
|
+
await _chunkLJ7U7MFNcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
4332
4332
|
const faces = /* @__PURE__ */ new Map();
|
|
4333
4333
|
for (const it of visible) {
|
|
4334
4334
|
if (!it.fontName) continue;
|
|
@@ -4341,12 +4341,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4341
4341
|
it.fontName = face;
|
|
4342
4342
|
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _405 => _405(face), 'optionalAccess', _406 => _406.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
4343
4343
|
}
|
|
4344
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
4345
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
4344
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkTPKP3WQUcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
4345
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkTPKP3WQUcjs.escapeLiteralTags.call(void 0, it.text);
|
|
4346
4346
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
4347
4347
|
const pageArea = pageW * pageH;
|
|
4348
4348
|
if (pageArea > 0) {
|
|
4349
|
-
const imageRegions =
|
|
4349
|
+
const imageRegions = _chunkLJ7U7MFNcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
4350
4350
|
let uncovered = 0;
|
|
4351
4351
|
for (const r of imageRegions) {
|
|
4352
4352
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -4372,11 +4372,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4372
4372
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
4373
4373
|
}
|
|
4374
4374
|
const marks = superscriptNoteMarks(visible);
|
|
4375
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
4375
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkLJ7U7MFNcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
4376
4376
|
const stamp = marginStamp(visible);
|
|
4377
4377
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
4378
|
-
const rightArrows = _optionalChain([options, 'optionalAccess', _407 => _407.tables]) !== false ? await
|
|
4379
|
-
const pageBlocks = orderTwoUpPage(
|
|
4378
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _407 => _407.tables]) !== false ? await _chunkLJ7U7MFNcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
4379
|
+
const pageBlocks = orderTwoUpPage(_chunkLJ7U7MFNcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _408 => _408.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
4380
4380
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
4381
4381
|
for (const b of pageBlocks) blocks.push(b);
|
|
4382
4382
|
try {
|
|
@@ -4402,11 +4402,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4402
4402
|
if (_optionalChain([options, 'optionalAccess', _410 => _410.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
4403
4403
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
4404
4404
|
}
|
|
4405
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
4405
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunk6A4KYMQRcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
4406
4406
|
parsedPages++;
|
|
4407
4407
|
_optionalChain([options, 'optionalAccess', _411 => _411.onProgress, 'optionalCall', _412 => _412(parsedPages, totalTarget)]);
|
|
4408
4408
|
} catch (pageErr) {
|
|
4409
|
-
if (pageErr instanceof
|
|
4409
|
+
if (pageErr instanceof _chunk6A4KYMQRcjs.KordocError) throw pageErr;
|
|
4410
4410
|
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" });
|
|
4411
4411
|
} finally {
|
|
4412
4412
|
_optionalChain([loadedPage, 'optionalAccess', _413 => _413.cleanup, 'call', _414 => _414()]);
|
|
@@ -4437,12 +4437,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4437
4437
|
}
|
|
4438
4438
|
if (targets.size > 0) {
|
|
4439
4439
|
try {
|
|
4440
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
4440
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-NOSNTEDS.cjs")));
|
|
4441
4441
|
const mode = typeof _optionalChain([options, 'optionalAccess', _419 => _419.ocr]) === "function" ? options.ocr : "builtin";
|
|
4442
4442
|
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _420 => _420.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _421 => _421.find, 'call', _422 => _422((q) => q.page === p), 'optionalAccess', _423 => _423.needsOcr])));
|
|
4443
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
4443
|
+
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-NOSNTEDS.cjs")));
|
|
4444
4444
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _424 => _424.onProgress]), _optionalChain([options, 'optionalAccess', _425 => _425.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
4445
|
-
for (const obs of ocrPageBlocks.values())
|
|
4445
|
+
for (const obs of ocrPageBlocks.values()) _chunkTPKP3WQUcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
4446
4446
|
if (ocrPageBlocks.size > 0) {
|
|
4447
4447
|
const replacePages = /* @__PURE__ */ new Set();
|
|
4448
4448
|
for (const [p, obs] of ocrPageBlocks) {
|
|
@@ -4453,7 +4453,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4453
4453
|
continue;
|
|
4454
4454
|
}
|
|
4455
4455
|
const regions = ocrRegions.get(p);
|
|
4456
|
-
if (!regions ||
|
|
4456
|
+
if (!regions || _chunkLJ7U7MFNcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
4457
4457
|
ocrDone.add(p);
|
|
4458
4458
|
if (_optionalChain([pageImageBlocks, 'access', _430 => _430.get, 'call', _431 => _431(p), 'optionalAccess', _432 => _432.length]) === 1) pageImageBlocks.delete(p);
|
|
4459
4459
|
}
|
|
@@ -4506,17 +4506,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4506
4506
|
}
|
|
4507
4507
|
}
|
|
4508
4508
|
if (_optionalChain([options, 'optionalAccess', _433 => _433.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
4509
|
-
const removed =
|
|
4510
|
-
const running =
|
|
4509
|
+
const removed = _chunkLJ7U7MFNcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
4510
|
+
const running = _chunkLJ7U7MFNcjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
4511
4511
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
4512
4512
|
blocks.splice(removed[ri], 1);
|
|
4513
4513
|
}
|
|
4514
|
-
const stripped =
|
|
4514
|
+
const stripped = _chunkLJ7U7MFNcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
4515
4515
|
if (stripped !== blocks) {
|
|
4516
4516
|
blocks.length = 0;
|
|
4517
4517
|
blocks.push(...stripped);
|
|
4518
4518
|
}
|
|
4519
|
-
const kept =
|
|
4519
|
+
const kept = _chunkLJ7U7MFNcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
4520
4520
|
if (kept !== blocks) {
|
|
4521
4521
|
blocks.length = 0;
|
|
4522
4522
|
blocks.push(...kept);
|
|
@@ -4525,12 +4525,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4525
4525
|
mergeContinuedCells(blocks, pageHeights);
|
|
4526
4526
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
4527
4527
|
if (_optionalChain([options, 'optionalAccess', _434 => _434.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
4528
|
-
const boxes =
|
|
4528
|
+
const boxes = _chunkLJ7U7MFNcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
4529
4529
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
4530
4530
|
}
|
|
4531
4531
|
splitContactTables(blocks);
|
|
4532
|
-
if (!_optionalChain([options, 'optionalAccess', _435 => _435.keepTrailingEmptyCols]))
|
|
4533
|
-
|
|
4532
|
+
if (!_optionalChain([options, 'optionalAccess', _435 => _435.keepTrailingEmptyCols])) _chunkLJ7U7MFNcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
4533
|
+
_chunkLJ7U7MFNcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
4534
4534
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
4535
4535
|
if (_optionalChain([options, 'optionalAccess', _436 => _436.formulaOcr]) && formulaBuffer) {
|
|
4536
4536
|
try {
|
|
@@ -4542,21 +4542,21 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4542
4542
|
});
|
|
4543
4543
|
}
|
|
4544
4544
|
}
|
|
4545
|
-
const medianFontSize =
|
|
4545
|
+
const medianFontSize = _chunkLJ7U7MFNcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
4546
4546
|
if (medianFontSize > 0) {
|
|
4547
|
-
|
|
4548
|
-
}
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4547
|
+
_chunkLJ7U7MFNcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
4548
|
+
}
|
|
4549
|
+
_chunkLJ7U7MFNcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
4550
|
+
_chunkLJ7U7MFNcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
4551
|
+
_chunkLJ7U7MFNcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
4552
|
+
_chunkLJ7U7MFNcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
4553
|
+
_chunkLJ7U7MFNcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
4554
|
+
_chunkLJ7U7MFNcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
4555
|
+
_chunkLJ7U7MFNcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
4556
|
+
_chunkLJ7U7MFNcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
4557
4557
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
4558
|
-
|
|
4559
|
-
|
|
4558
|
+
_chunkLJ7U7MFNcjs.detectTableCaptions.call(void 0, blocks);
|
|
4559
|
+
_chunkLJ7U7MFNcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
4560
4560
|
sanitizeBlockControlChars(blocks);
|
|
4561
4561
|
let outBlocks = splitSingleCellTables(blocks);
|
|
4562
4562
|
if (_optionalChain([options, 'optionalAccess', _437 => _437.layoutTables]) !== "keep") {
|
|
@@ -4577,19 +4577,19 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4577
4577
|
const shown = /* @__PURE__ */ new Map();
|
|
4578
4578
|
const markContent = (bs) => {
|
|
4579
4579
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
4580
|
-
if (
|
|
4581
|
-
const lines =
|
|
4582
|
-
if (lines)
|
|
4580
|
+
if (_chunkLJ7U7MFNcjs.IMAGE_CELLS.has(c)) _chunkTPKP3WQUcjs.CONTENT_CELLS.add(c);
|
|
4581
|
+
const lines = _chunkLJ7U7MFNcjs.CELL_LINES.get(c);
|
|
4582
|
+
if (lines) _chunkTPKP3WQUcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
4583
4583
|
markContent(c.blocks);
|
|
4584
4584
|
}
|
|
4585
4585
|
};
|
|
4586
4586
|
const visual = (bs) => bs.flatMap((b) => {
|
|
4587
4587
|
if (b.type !== "table") return [b];
|
|
4588
|
-
if (!hancom && b.table &&
|
|
4588
|
+
if (!hancom && b.table && _chunkLJ7U7MFNcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
4589
4589
|
let v = shown.get(b);
|
|
4590
4590
|
if (!v) {
|
|
4591
4591
|
markContent([b]);
|
|
4592
|
-
shown.set(b, v =
|
|
4592
|
+
shown.set(b, v = _chunkTPKP3WQUcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _440 => _440.keepTrailingEmptyCols])));
|
|
4593
4593
|
}
|
|
4594
4594
|
return v;
|
|
4595
4595
|
});
|
|
@@ -4598,13 +4598,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4598
4598
|
blocks.length = 0;
|
|
4599
4599
|
for (const b of kept) blocks.push(b);
|
|
4600
4600
|
}
|
|
4601
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
4602
|
-
if (_optionalChain([options, 'optionalAccess', _442 => _442.tableFormat]) === "gfm")
|
|
4601
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkTPKP3WQUcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _441 => _441.tableFormat]) }), { keepLoneNumbers: true }));
|
|
4602
|
+
if (_optionalChain([options, 'optionalAccess', _442 => _442.tableFormat]) === "gfm") _chunkTPKP3WQUcjs.assignTableIds.call(void 0, blocks);
|
|
4603
4603
|
let markdown = finishMarkdown(outBlocks);
|
|
4604
4604
|
const outline = collectPdfOutline(outBlocks);
|
|
4605
4605
|
return {
|
|
4606
4606
|
markdown,
|
|
4607
|
-
pages:
|
|
4607
|
+
pages: _chunkBODFTRWAcjs.blocksToPages.call(void 0, splitPageTables(_chunkLJ7U7MFNcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
4608
4608
|
blocks,
|
|
4609
4609
|
metadata,
|
|
4610
4610
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -4684,5 +4684,5 @@ function marginStamp(items) {
|
|
|
4684
4684
|
|
|
4685
4685
|
|
|
4686
4686
|
|
|
4687
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
4688
|
-
//# sourceMappingURL=parser-
|
|
4687
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkLJ7U7MFNcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkLJ7U7MFNcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkLJ7U7MFNcjs.removeHeaderFooterBlocks;
|
|
4688
|
+
//# sourceMappingURL=parser-GIDYL5LH.cjs.map
|