kordoc 4.24.2 → 4.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/dist/{-SRNEV7LS.js → -Q56U3KCA.js} +11 -11
- package/dist/{chunk-E7B5CXYI.js → chunk-33NZN73M.js} +2 -2
- package/dist/{chunk-NJ5RUDCW.js → chunk-3EWXRIPH.js} +3 -3
- package/dist/{chunk-NMFFIUI6.js → chunk-42FSKT7R.js} +2 -2
- package/dist/{chunk-M46PB75E.js → chunk-4X73CGIL.js} +2 -2
- package/dist/{chunk-PNSALBXH.cjs → chunk-6ZRZLV3J.cjs} +2 -2
- package/dist/{chunk-PNSALBXH.cjs.map → chunk-6ZRZLV3J.cjs.map} +1 -1
- package/dist/{chunk-W24TJJNN.js → chunk-AEEQN6L3.js} +2 -2
- package/dist/{chunk-TW3V6FSH.js → chunk-EEXIFCXC.js} +2 -2
- package/dist/{chunk-LMEF7FN5.js → chunk-EWCJCWTT.js} +2 -2
- package/dist/{chunk-MHNJOJQV.js → chunk-FZT34MUI.js} +4 -4
- package/dist/{chunk-WDSTW3BD.js → chunk-HNX2I7D6.js} +2 -2
- package/dist/{chunk-PNX5FYHC.cjs → chunk-HTG3VVET.cjs} +24 -24
- package/dist/{chunk-PNX5FYHC.cjs.map → chunk-HTG3VVET.cjs.map} +1 -1
- package/dist/{chunk-KUC5I5MB.js → chunk-HU7POUBS.js} +2 -2
- package/dist/{chunk-WJAFE3Z6.js → chunk-I2QETSZN.js} +2 -2
- package/dist/{chunk-DHMBPMKC.js → chunk-J45OVEUM.js} +139 -15
- package/dist/chunk-J45OVEUM.js.map +1 -0
- package/dist/{chunk-UNICY546.cjs → chunk-JILIA5EV.cjs} +23 -23
- package/dist/{chunk-UNICY546.cjs.map → chunk-JILIA5EV.cjs.map} +1 -1
- package/dist/{chunk-TDMBTG7U.js → chunk-KXHNIHLC.js} +2 -2
- package/dist/{chunk-JFUUFJZW.cjs → chunk-N65EY5BI.cjs} +6 -6
- package/dist/{chunk-JFUUFJZW.cjs.map → chunk-N65EY5BI.cjs.map} +1 -1
- package/dist/{chunk-4XC4O7FJ.js → chunk-NKDPCALC.js} +4 -4
- package/dist/{chunk-C6ZVB547.js → chunk-OAOM7IEI.js} +11 -11
- package/dist/{chunk-4745MFQU.js → chunk-PHZDAHZC.js} +3 -3
- package/dist/{chunk-RIRPLFPN.js → chunk-PMX5CPK5.js} +2 -2
- package/dist/{chunk-E6VBLBOO.js → chunk-Q2QKRE4P.js} +2 -2
- package/dist/{chunk-7NTMM6PO.js → chunk-TZ753B6A.js} +2 -2
- package/dist/{chunk-HLTPMSYW.cjs → chunk-VFEI2GIE.cjs} +3 -3
- package/dist/{chunk-HLTPMSYW.cjs.map → chunk-VFEI2GIE.cjs.map} +1 -1
- package/dist/{chunk-3HN65YAL.js → chunk-W6O7KBOD.js} +2 -2
- package/dist/{chunk-VPSF5LEM.js → chunk-XAZ5RGVG.js} +3 -3
- package/dist/{chunk-R2GIGE5H.js → chunk-XNNMMYFO.js} +2 -2
- package/dist/{chunk-JMOAMKAR.js → chunk-XZOAE2Q7.js} +4 -4
- package/dist/{chunk-IGG63DFK.cjs → chunk-YG4YOPK6.cjs} +3 -3
- package/dist/{chunk-IGG63DFK.cjs.map → chunk-YG4YOPK6.cjs.map} +1 -1
- package/dist/chunks-REYSCBPB.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-HK2MNZ3Q.cjs → formula-2BPHF6O7.cjs} +9 -9
- package/dist/{formula-HK2MNZ3Q.cjs.map → formula-2BPHF6O7.cjs.map} +1 -1
- package/dist/{formula-DSB574H7.js → formula-EA5GDCUD.js} +4 -4
- package/dist/{formula-U2LZ67KI.js → formula-IREEAC4T.js} +3 -3
- package/dist/{image-ocr-QNIMVE5A.cjs → image-ocr-CCTE7HX3.cjs} +17 -17
- package/dist/{image-ocr-QNIMVE5A.cjs.map → image-ocr-CCTE7HX3.cjs.map} +1 -1
- package/dist/{image-ocr-J54Q3YWP.js → image-ocr-JQJC5HWK.js} +6 -6
- package/dist/{image-ocr-3QB2HLSI.js → image-ocr-LGOFUS3O.js} +9 -9
- package/dist/index.cjs +517 -393
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +139 -15
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +23 -23
- package/dist/{model-bundle-CGWU4ALC.js → model-bundle-YW62Y6UD.js} +5 -5
- package/dist/{models-A3TF3BDV.js → models-AAL3IS2R.js} +5 -5
- package/dist/{parse-worker-v2-MNUD4WAR.js → parse-worker-v2-3JAHV7NY.js} +12 -12
- package/dist/{parser-C3ARF26I.js → parser-4FCKKJ2N.js} +18 -14
- package/dist/parser-4FCKKJ2N.js.map +1 -0
- package/dist/{parser-RPAHN3OR.cjs → parser-HE45CCSG.cjs} +163 -159
- package/dist/parser-HE45CCSG.cjs.map +1 -0
- package/dist/{parser-OBGWEWSU.js → parser-ZBP5GOQK.js} +15 -11
- package/dist/parser-ZBP5GOQK.js.map +1 -0
- package/dist/pdf-ocr-7MDCLWAA.cjs +31 -0
- package/dist/{pdf-ocr-GA5QJFNK.cjs.map → pdf-ocr-7MDCLWAA.cjs.map} +1 -1
- package/dist/{pdf-ocr-K53REDNY.js → pdf-ocr-HFAEOA7W.js} +6 -6
- package/dist/{pdf-ocr-ENLVEEYL.js → pdf-ocr-Q4TPGDDI.js} +9 -9
- package/dist/{profile-io-ZGFEO7CB.js → profile-io-EDQTKLLL.js} +3 -3
- package/dist/{rasterize-QMC2SAUT.js → rasterize-VD2XGHUJ.js} +3 -3
- package/dist/{redact-doc-JH6RZZBE.js → redact-doc-TBIBQJCT.js} +11 -11
- package/dist/{render-ZGKQLKPJ.js → render-J5KAZAQH.js} +7 -7
- package/dist/seal-H2JNAZU7.js +10 -0
- package/dist/{setup-LAQGCYQ2.js → setup-5LYHCQRU.js} +3 -3
- package/dist/visual-7EO6GR3M.js +21 -0
- package/dist/{watch-7YPB4TKC.js → watch-YP4IWM75.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-DHMBPMKC.js.map +0 -1
- package/dist/chunks-AL4P5TO5.js +0 -10
- package/dist/parser-C3ARF26I.js.map +0 -1
- package/dist/parser-OBGWEWSU.js.map +0 -1
- package/dist/parser-RPAHN3OR.cjs.map +0 -1
- package/dist/pdf-ocr-GA5QJFNK.cjs +0 -31
- package/dist/seal-KMGYTJAV.js +0 -10
- package/dist/visual-4OYJFGXL.js +0 -21
- /package/dist/{-SRNEV7LS.js.map → -Q56U3KCA.js.map} +0 -0
- /package/dist/{chunk-E7B5CXYI.js.map → chunk-33NZN73M.js.map} +0 -0
- /package/dist/{chunk-NJ5RUDCW.js.map → chunk-3EWXRIPH.js.map} +0 -0
- /package/dist/{chunk-NMFFIUI6.js.map → chunk-42FSKT7R.js.map} +0 -0
- /package/dist/{chunk-M46PB75E.js.map → chunk-4X73CGIL.js.map} +0 -0
- /package/dist/{chunk-W24TJJNN.js.map → chunk-AEEQN6L3.js.map} +0 -0
- /package/dist/{chunk-TW3V6FSH.js.map → chunk-EEXIFCXC.js.map} +0 -0
- /package/dist/{chunk-LMEF7FN5.js.map → chunk-EWCJCWTT.js.map} +0 -0
- /package/dist/{chunk-MHNJOJQV.js.map → chunk-FZT34MUI.js.map} +0 -0
- /package/dist/{chunk-WDSTW3BD.js.map → chunk-HNX2I7D6.js.map} +0 -0
- /package/dist/{chunk-KUC5I5MB.js.map → chunk-HU7POUBS.js.map} +0 -0
- /package/dist/{chunk-WJAFE3Z6.js.map → chunk-I2QETSZN.js.map} +0 -0
- /package/dist/{chunk-TDMBTG7U.js.map → chunk-KXHNIHLC.js.map} +0 -0
- /package/dist/{chunk-4XC4O7FJ.js.map → chunk-NKDPCALC.js.map} +0 -0
- /package/dist/{chunk-C6ZVB547.js.map → chunk-OAOM7IEI.js.map} +0 -0
- /package/dist/{chunk-4745MFQU.js.map → chunk-PHZDAHZC.js.map} +0 -0
- /package/dist/{chunk-RIRPLFPN.js.map → chunk-PMX5CPK5.js.map} +0 -0
- /package/dist/{chunk-E6VBLBOO.js.map → chunk-Q2QKRE4P.js.map} +0 -0
- /package/dist/{chunk-7NTMM6PO.js.map → chunk-TZ753B6A.js.map} +0 -0
- /package/dist/{chunk-3HN65YAL.js.map → chunk-W6O7KBOD.js.map} +0 -0
- /package/dist/{chunk-VPSF5LEM.js.map → chunk-XAZ5RGVG.js.map} +0 -0
- /package/dist/{chunk-R2GIGE5H.js.map → chunk-XNNMMYFO.js.map} +0 -0
- /package/dist/{chunk-JMOAMKAR.js.map → chunk-XZOAE2Q7.js.map} +0 -0
- /package/dist/{chunks-AL4P5TO5.js.map → chunks-REYSCBPB.js.map} +0 -0
- /package/dist/{formula-DSB574H7.js.map → formula-EA5GDCUD.js.map} +0 -0
- /package/dist/{formula-U2LZ67KI.js.map → formula-IREEAC4T.js.map} +0 -0
- /package/dist/{image-ocr-J54Q3YWP.js.map → image-ocr-JQJC5HWK.js.map} +0 -0
- /package/dist/{image-ocr-3QB2HLSI.js.map → image-ocr-LGOFUS3O.js.map} +0 -0
- /package/dist/{model-bundle-CGWU4ALC.js.map → model-bundle-YW62Y6UD.js.map} +0 -0
- /package/dist/{models-A3TF3BDV.js.map → models-AAL3IS2R.js.map} +0 -0
- /package/dist/{parse-worker-v2-MNUD4WAR.js.map → parse-worker-v2-3JAHV7NY.js.map} +0 -0
- /package/dist/{pdf-ocr-ENLVEEYL.js.map → pdf-ocr-HFAEOA7W.js.map} +0 -0
- /package/dist/{pdf-ocr-K53REDNY.js.map → pdf-ocr-Q4TPGDDI.js.map} +0 -0
- /package/dist/{profile-io-ZGFEO7CB.js.map → profile-io-EDQTKLLL.js.map} +0 -0
- /package/dist/{rasterize-QMC2SAUT.js.map → rasterize-VD2XGHUJ.js.map} +0 -0
- /package/dist/{redact-doc-JH6RZZBE.js.map → redact-doc-TBIBQJCT.js.map} +0 -0
- /package/dist/{render-ZGKQLKPJ.js.map → render-J5KAZAQH.js.map} +0 -0
- /package/dist/{seal-KMGYTJAV.js.map → seal-H2JNAZU7.js.map} +0 -0
- /package/dist/{setup-LAQGCYQ2.js.map → setup-5LYHCQRU.js.map} +0 -0
- /package/dist/{visual-4OYJFGXL.js.map → visual-7EO6GR3M.js.map} +0 -0
- /package/dist/{watch-7YPB4TKC.js.map → watch-YP4IWM75.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 _chunkYG4YOPK6cjs = require('./chunk-YG4YOPK6.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 _chunkJILIA5EVcjs = require('./chunk-JILIA5EV.cjs');
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
@@ -78,12 +78,12 @@ var _chunkUNICY546cjs = require('./chunk-UNICY546.cjs');
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
var
|
|
82
|
-
require('./chunk-
|
|
81
|
+
var _chunkN65EY5BIcjs = require('./chunk-N65EY5BI.cjs');
|
|
82
|
+
require('./chunk-VFEI2GIE.cjs');
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
var
|
|
86
|
+
var _chunk6ZRZLV3Jcjs = require('./chunk-6ZRZLV3J.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 = _chunkYG4YOPK6cjs.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]) && !_chunkJILIA5EVcjs.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 = _chunkJILIA5EVcjs.CELL_LINES.get(label), V = _chunkJILIA5EVcjs.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(_chunkN65EY5BIcjs.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([_chunkN65EY5BIcjs.CELL_EDGES, 'access', _21 => _21.get, 'call', _22 => _22(context.upper), 'optionalAccess', _23 => _23.b]) || !_optionalChain([_chunkN65EY5BIcjs.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 = _chunkJILIA5EVcjs.CELL_LINES.get(label.lower), V = _chunkJILIA5EVcjs.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([_chunkJILIA5EVcjs.CELL_LINES, 'access', _31 => _31.get, 'call', _32 => _32(lc), 'optionalAccess', _33 => _33.length]), () => ( 0)), values = _chunkJILIA5EVcjs.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 = _chunkJILIA5EVcjs.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 = _chunkN65EY5BIcjs.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) _chunkN65EY5BIcjs.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 = _chunkN65EY5BIcjs.CELL_PAGES.get(cell);
|
|
1078
|
+
if (p !== void 0) _chunkN65EY5BIcjs.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
|
+
_chunkN65EY5BIcjs.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
|
+
_chunkN65EY5BIcjs.CELL_PAGES.set(tail, split.page);
|
|
1100
1100
|
setSplits(tail, split.rest);
|
|
1101
1101
|
row[c] = tail;
|
|
1102
1102
|
}
|
|
@@ -1186,9 +1186,13 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1186
1186
|
const cols = U.length - 1;
|
|
1187
1187
|
if (cols < 1) return null;
|
|
1188
1188
|
const pa = anchorsOf(prev), ca = anchorsOf(curr);
|
|
1189
|
+
const cutOpen = (() => {
|
|
1190
|
+
const u = _chunkJILIA5EVcjs.ROW_RULES.get(prev), d = _chunkJILIA5EVcjs.ROW_RULES.get(curr);
|
|
1191
|
+
return !!u && !!d && !u.bottom && !d.top;
|
|
1192
|
+
})();
|
|
1189
1193
|
let skip = 0, head = 0;
|
|
1190
|
-
while (skip < Math.min(3, curr.rows - 1, prev.rows) && rowText(ca, skip) !== "" && rowText(ca, skip) === rowText(pa, skip)) skip++;
|
|
1191
|
-
for (let h = 1; h <= 2 && !skip; h++) {
|
|
1194
|
+
while (!cutOpen && skip < Math.min(3, curr.rows - 1, prev.rows) && rowText(ca, skip) !== "" && rowText(ca, skip) === rowText(pa, skip)) skip++;
|
|
1195
|
+
for (let h = 1; h <= 2 && !skip && !cutOpen; h++) {
|
|
1192
1196
|
head = h;
|
|
1193
1197
|
while (skip < Math.min(3, curr.rows - 1, prev.rows - h) && hasText(rowText(ca, skip)) && rowText(ca, skip) === rowText(pa, h + skip)) skip++;
|
|
1194
1198
|
}
|
|
@@ -1215,19 +1219,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1215
1219
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
1216
1220
|
}
|
|
1217
1221
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
1218
|
-
const lines =
|
|
1219
|
-
if (lines)
|
|
1220
|
-
if (
|
|
1221
|
-
const edges =
|
|
1222
|
+
const lines = _chunkJILIA5EVcjs.CELL_LINES.get(a.cell);
|
|
1223
|
+
if (lines) _chunkJILIA5EVcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
1224
|
+
if (_chunkJILIA5EVcjs.IMAGE_CELLS.has(a.cell)) _chunkJILIA5EVcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
1225
|
+
const edges = _chunkN65EY5BIcjs.CELL_EDGES.get(a.cell);
|
|
1222
1226
|
if (edges) {
|
|
1223
|
-
|
|
1227
|
+
_chunkN65EY5BIcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
1224
1228
|
edged = true;
|
|
1225
1229
|
}
|
|
1226
1230
|
return true;
|
|
1227
1231
|
};
|
|
1228
|
-
for (const a of pa) if (!
|
|
1232
|
+
for (const a of pa) if (!_chunkJILIA5EVcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
1229
1233
|
for (const a of ca) {
|
|
1230
|
-
if (a.r < skip ||
|
|
1234
|
+
if (a.r < skip || _chunkJILIA5EVcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
1231
1235
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
1232
1236
|
}
|
|
1233
1237
|
const first = prev.rows;
|
|
@@ -1251,9 +1255,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1251
1255
|
const grown = { ...above, rs: newRs };
|
|
1252
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;
|
|
1253
1257
|
}
|
|
1254
|
-
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) _chunkJILIA5EVcjs.FILLER_CELLS.add(grid[r][c]);
|
|
1255
1259
|
if (edged) {
|
|
1256
|
-
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) _chunkN65EY5BIcjs.CELL_EDGES.set(grid[r][c], _chunkJILIA5EVcjs.NO_EDGES);
|
|
1257
1261
|
}
|
|
1258
1262
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1259
1263
|
let r = prev.rows;
|
|
@@ -1262,7 +1266,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1262
1266
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1263
1267
|
}
|
|
1264
1268
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1265
|
-
const pr =
|
|
1269
|
+
const pr = _chunkJILIA5EVcjs.ROW_RULES.get(prev), cr = _chunkJILIA5EVcjs.ROW_RULES.get(curr);
|
|
1266
1270
|
const shifted = dx !== 0;
|
|
1267
1271
|
const cut = {
|
|
1268
1272
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1270,13 +1274,13 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1270
1274
|
list: !shifted ? "any" : skip > 0 && ca.filter((a) => a.r < skip && a.cell.text.trim()).length < 2 ? "none" : "multi"
|
|
1271
1275
|
};
|
|
1272
1276
|
let partial = !skip && cols === prev.cols && cols === curr.cols && cut.ruled && prevBottom !== void 0 ? partialAlignedLabelCells(table, owner, first) : void 0;
|
|
1273
|
-
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]) || _chunkJILIA5EVcjs.startsNewItem.call(void 0, partial.value.upper.text, partial.value.lower.text))) partial = void 0;
|
|
1274
1278
|
const selected = partial ? /* @__PURE__ */ new Set([partial.label.c, partial.value.c]) : void 0;
|
|
1275
1279
|
let split = !selected && rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U, false, cut);
|
|
1276
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 });
|
|
1277
1281
|
if (pr && cr) {
|
|
1278
1282
|
const cutRuled = pr.bottom || cr.top;
|
|
1279
|
-
|
|
1283
|
+
_chunkJILIA5EVcjs.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) });
|
|
1280
1284
|
}
|
|
1281
1285
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1282
1286
|
}
|
|
@@ -1338,18 +1342,18 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1338
1342
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1339
1343
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1340
1344
|
if (selected && !selected.has(u.c)) continue;
|
|
1341
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1342
|
-
const openSeam = hasContent(a) && hasContent(b) &&
|
|
1345
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkJILIA5EVcjs.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) && _chunkJILIA5EVcjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
|
|
1343
1347
|
if (!r || r === first) return false;
|
|
1344
1348
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1345
1349
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1346
|
-
const ue =
|
|
1350
|
+
const ue = _chunkN65EY5BIcjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkN65EY5BIcjs.CELL_EDGES.get(table.cells[down.r][down.c]);
|
|
1347
1351
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1348
1352
|
});
|
|
1349
1353
|
if (!selected && !openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1350
1354
|
if (!straddles && !midWord) continue;
|
|
1351
1355
|
if (u.r >= last && d.rs < 2) continue;
|
|
1352
|
-
const U =
|
|
1356
|
+
const U = _chunkJILIA5EVcjs.CELL_LINES.get(a);
|
|
1353
1357
|
if (!_optionalChain([U, 'optionalAccess', _134 => _134.length]) || !hasContent(b)) continue;
|
|
1354
1358
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1355
1359
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -1367,7 +1371,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs, selec
|
|
|
1367
1371
|
return merged;
|
|
1368
1372
|
}
|
|
1369
1373
|
function longLastLine(c) {
|
|
1370
|
-
const L =
|
|
1374
|
+
const L = _chunkJILIA5EVcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _135 => _135[L.length - 1]]);
|
|
1371
1375
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1372
1376
|
}
|
|
1373
1377
|
function filledToBottom(U, bottom) {
|
|
@@ -1400,7 +1404,7 @@ function nextItemHead(prev, next) {
|
|
|
1400
1404
|
return false;
|
|
1401
1405
|
}
|
|
1402
1406
|
function continuesAcross(u, d, x1, x2) {
|
|
1403
|
-
const U =
|
|
1407
|
+
const U = _chunkJILIA5EVcjs.CELL_LINES.get(u), D = _chunkJILIA5EVcjs.CELL_LINES.get(d);
|
|
1404
1408
|
if (!_optionalChain([U, 'optionalAccess', _136 => _136.length]) || !_optionalChain([D, 'optionalAccess', _137 => _137.length])) return false;
|
|
1405
1409
|
const last = U[U.length - 1];
|
|
1406
1410
|
const fs = last.h || 10;
|
|
@@ -1418,7 +1422,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1418
1422
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1419
1423
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1420
1424
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1421
|
-
const newItem =
|
|
1425
|
+
const newItem = _chunkJILIA5EVcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1422
1426
|
const all = D.length ? U.concat(D) : U;
|
|
1423
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));
|
|
1424
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;
|
|
@@ -1435,10 +1439,10 @@ function outlineContinues(u, d) {
|
|
|
1435
1439
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1436
1440
|
}
|
|
1437
1441
|
function lineEnded(c, x1, x2, next) {
|
|
1438
|
-
const L =
|
|
1442
|
+
const L = _chunkJILIA5EVcjs.CELL_LINES.get(c);
|
|
1439
1443
|
if (!L || L.length !== 1) return false;
|
|
1440
1444
|
const l = L[0], h = l.h || 10;
|
|
1441
|
-
const d0 = next ? _optionalChain([
|
|
1445
|
+
const d0 = next ? _optionalChain([_chunkJILIA5EVcjs.CELL_LINES, 'access', _138 => _138.get, 'call', _139 => _139(next), 'optionalAccess', _140 => _140[0]]) : void 0;
|
|
1442
1446
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1443
1447
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _141 => _141.text]), () => ( "")))) * h;
|
|
1444
1448
|
}
|
|
@@ -1449,15 +1453,15 @@ function firstWordUnits(text) {
|
|
|
1449
1453
|
return units;
|
|
1450
1454
|
}
|
|
1451
1455
|
function appendCell(a, b) {
|
|
1452
|
-
if (
|
|
1456
|
+
if (_chunkJILIA5EVcjs.IMAGE_CELLS.has(b)) _chunkJILIA5EVcjs.IMAGE_CELLS.add(a);
|
|
1453
1457
|
if (_optionalChain([a, 'access', _142 => _142.blocks, 'optionalAccess', _143 => _143.length]) || _optionalChain([b, 'access', _144 => _144.blocks, 'optionalAccess', _145 => _145.length])) {
|
|
1454
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 }));
|
|
1455
1459
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1456
1460
|
}
|
|
1457
1461
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1458
|
-
|
|
1462
|
+
_chunkJILIA5EVcjs.joinCellEdges.call(void 0, a, b);
|
|
1459
1463
|
}
|
|
1460
|
-
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]) || _chunkJILIA5EVcjs.IMAGE_CELLS.has(cell);
|
|
1461
1465
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1462
1466
|
var batchim = (ch) => {
|
|
1463
1467
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1465,7 +1469,7 @@ var batchim = (ch) => {
|
|
|
1465
1469
|
};
|
|
1466
1470
|
function clauseContinues(u, d) {
|
|
1467
1471
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1468
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1472
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkJILIA5EVcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1469
1473
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1470
1474
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1471
1475
|
}
|
|
@@ -1473,8 +1477,8 @@ function quantityContinues(u, d) {
|
|
|
1473
1477
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1474
1478
|
}
|
|
1475
1479
|
function wordOverflows(u, d, x1, x2) {
|
|
1476
|
-
const U =
|
|
1477
|
-
if (!_optionalChain([U, 'optionalAccess', _150 => _150.length]) ||
|
|
1480
|
+
const U = _chunkJILIA5EVcjs.CELL_LINES.get(u);
|
|
1481
|
+
if (!_optionalChain([U, 'optionalAccess', _150 => _150.length]) || _chunkJILIA5EVcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1478
1482
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1479
1483
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1480
1484
|
}
|
|
@@ -1532,7 +1536,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1532
1536
|
if (!carriedSplit) {
|
|
1533
1537
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1534
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;
|
|
1535
|
-
const oneLine = (c) => _optionalChain([
|
|
1539
|
+
const oneLine = (c) => _optionalChain([_chunkJILIA5EVcjs.CELL_LINES, 'access', _152 => _152.get, 'call', _153 => _153(c), 'optionalAccess', _154 => _154.length]) === 1;
|
|
1536
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;
|
|
1537
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));
|
|
1538
1542
|
if (!(cut.open && !newCell)) {
|
|
@@ -1624,19 +1628,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1624
1628
|
placeJoined(blocks, i, j, joined);
|
|
1625
1629
|
continue;
|
|
1626
1630
|
}
|
|
1627
|
-
if (
|
|
1631
|
+
if (_chunkJILIA5EVcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1628
1632
|
blocks.splice(j, 1);
|
|
1629
1633
|
i++;
|
|
1630
1634
|
continue;
|
|
1631
1635
|
}
|
|
1632
1636
|
if (joined === null) continue;
|
|
1633
|
-
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 || _chunkJILIA5EVcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1634
1638
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1635
1639
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1636
1640
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1637
1641
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1638
|
-
const px =
|
|
1639
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1642
|
+
const px = _chunkJILIA5EVcjs.TABLE_COLXS.get(prev.table), cx = _chunkJILIA5EVcjs.TABLE_COLXS.get(curr.table);
|
|
1643
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkJILIA5EVcjs.CLIP_TABLES.has(prev.table) && !_chunkJILIA5EVcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1640
1644
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1641
1645
|
let currCells = curr.table.cells;
|
|
1642
1646
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1647,16 +1651,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1647
1651
|
blocks.splice(j, 1);
|
|
1648
1652
|
continue;
|
|
1649
1653
|
}
|
|
1650
|
-
if (px && cx && !
|
|
1654
|
+
if (px && cx && !_chunkJILIA5EVcjs.CLIP_TABLES.has(prev.table) && !_chunkJILIA5EVcjs.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 && _chunkJILIA5EVcjs.CELL_LINES.has(c))) {
|
|
1651
1655
|
const dx = px[0] - cx[0];
|
|
1652
1656
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1653
1657
|
if (_optionalChain([part, 'optionalAccess', _175 => _175.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1654
1658
|
const last = prev.table.rows - 1;
|
|
1655
1659
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1656
|
-
const U =
|
|
1657
|
-
|
|
1660
|
+
const U = _chunkJILIA5EVcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkJILIA5EVcjs.CELL_LINES.get(currCells[0][c]);
|
|
1661
|
+
_chunkJILIA5EVcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1658
1662
|
}
|
|
1659
|
-
|
|
1663
|
+
_chunkJILIA5EVcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1660
1664
|
placeJoined(blocks, i, j, part.table);
|
|
1661
1665
|
continue;
|
|
1662
1666
|
}
|
|
@@ -1669,20 +1673,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1669
1673
|
caption: prev.table.caption,
|
|
1670
1674
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1671
1675
|
};
|
|
1672
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1673
|
-
if (
|
|
1676
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkJILIA5EVcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1677
|
+
if (_chunkJILIA5EVcjs.CLIP_TABLES.has(prev.table) || _chunkJILIA5EVcjs.CLIP_TABLES.has(curr.table)) _chunkJILIA5EVcjs.CLIP_TABLES.add(merged);
|
|
1674
1678
|
placeJoined(blocks, i, j, merged);
|
|
1675
1679
|
}
|
|
1676
1680
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1677
1681
|
const t = blocks[i].table;
|
|
1678
|
-
if (blocks[i].type === "table" && t &&
|
|
1682
|
+
if (blocks[i].type === "table" && t && _chunkJILIA5EVcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1679
1683
|
}
|
|
1680
1684
|
}
|
|
1681
1685
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1682
1686
|
if (!pageHeights) return;
|
|
1683
1687
|
for (let i = 0; i < blocks.length; i++) {
|
|
1684
1688
|
const L = blocks[i];
|
|
1685
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1689
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkJILIA5EVcjs.CLIP_TABLES.has(L.table) || _chunkJILIA5EVcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1686
1690
|
const ph = pageHeights.get(L.pageNumber);
|
|
1687
1691
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1688
1692
|
let s0 = i, s1 = i;
|
|
@@ -1711,8 +1715,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1711
1715
|
}
|
|
1712
1716
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1713
1717
|
const pt = prev.table, ct = curr.table;
|
|
1714
|
-
if (!
|
|
1715
|
-
const px =
|
|
1718
|
+
if (!_chunkJILIA5EVcjs.CLIP_TABLES.has(pt) || !_chunkJILIA5EVcjs.CLIP_TABLES.has(ct)) return null;
|
|
1719
|
+
const px = _chunkJILIA5EVcjs.TABLE_COLXS.get(pt), cx = _chunkJILIA5EVcjs.TABLE_COLXS.get(ct);
|
|
1716
1720
|
if (!px || !cx) return null;
|
|
1717
1721
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1718
1722
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -1728,15 +1732,15 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1728
1732
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1729
1733
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1730
1734
|
};
|
|
1731
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1735
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkJILIA5EVcjs.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);
|
|
1732
1736
|
}
|
|
1733
1737
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _180 => _180.bbox, 'optionalAccess', _181 => _181.y]), lex);
|
|
1734
1738
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1735
|
-
|
|
1736
|
-
const ys =
|
|
1737
|
-
if (ys)
|
|
1738
|
-
|
|
1739
|
-
|
|
1739
|
+
_chunkJILIA5EVcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1740
|
+
const ys = _chunkJILIA5EVcjs.TABLE_ROWYS.get(pt);
|
|
1741
|
+
if (ys) _chunkJILIA5EVcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1742
|
+
_chunkJILIA5EVcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkJILIA5EVcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1743
|
+
_chunkJILIA5EVcjs.CLIP_TABLES.add(res.table);
|
|
1740
1744
|
return res.table;
|
|
1741
1745
|
}
|
|
1742
1746
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
@@ -1760,12 +1764,12 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
1760
1764
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1761
1765
|
}
|
|
1762
1766
|
function pushedLead(prev, curr) {
|
|
1763
|
-
if (!
|
|
1767
|
+
if (!_chunkJILIA5EVcjs.CLIP_TABLES.has(prev.table) || !_chunkJILIA5EVcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1764
1768
|
const lead = leadRows(curr.table);
|
|
1765
1769
|
return lead.image && lead.height > prev.bbox.y;
|
|
1766
1770
|
}
|
|
1767
1771
|
function leadRows(t) {
|
|
1768
|
-
const ys =
|
|
1772
|
+
const ys = _chunkJILIA5EVcjs.TABLE_ROWYS.get(t);
|
|
1769
1773
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1770
1774
|
const anchors = anchorsOf(t);
|
|
1771
1775
|
let end = 1, image = false;
|
|
@@ -1773,17 +1777,17 @@ function leadRows(t) {
|
|
|
1773
1777
|
for (const a of anchors) {
|
|
1774
1778
|
if (a.r !== r) continue;
|
|
1775
1779
|
end = Math.max(end, r + a.rs);
|
|
1776
|
-
if (
|
|
1780
|
+
if (_chunkJILIA5EVcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1777
1781
|
}
|
|
1778
1782
|
}
|
|
1779
1783
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1780
1784
|
}
|
|
1781
1785
|
function tailOf(b) {
|
|
1782
|
-
const t = b.table &&
|
|
1786
|
+
const t = b.table && _chunkJILIA5EVcjs.TABLE_TAIL.get(b.table);
|
|
1783
1787
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1784
1788
|
}
|
|
1785
1789
|
function firstRowSig(t) {
|
|
1786
|
-
const x =
|
|
1790
|
+
const x = _chunkJILIA5EVcjs.TABLE_COLXS.get(t);
|
|
1787
1791
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1788
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, "") }));
|
|
1789
1793
|
}
|
|
@@ -1836,7 +1840,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1836
1840
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1837
1841
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1838
1842
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1839
|
-
const px =
|
|
1843
|
+
const px = _chunkJILIA5EVcjs.TABLE_COLXS.get(pb.table), cx = _chunkJILIA5EVcjs.TABLE_COLXS.get(cur.table);
|
|
1840
1844
|
if (!px || !cx) break;
|
|
1841
1845
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1842
1846
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1907,7 +1911,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1907
1911
|
var COL_MATCH_TOL = 0.5;
|
|
1908
1912
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1909
1913
|
function lastRowCell(t, x1, x2) {
|
|
1910
|
-
const xs =
|
|
1914
|
+
const xs = _chunkJILIA5EVcjs.TABLE_COLXS.get(t);
|
|
1911
1915
|
const covered = /* @__PURE__ */ new Set();
|
|
1912
1916
|
for (let r = 0; r < t.rows; r++) {
|
|
1913
1917
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -1925,7 +1929,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1925
1929
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1926
1930
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1927
1931
|
const part = blocks[j];
|
|
1928
|
-
const from = part.table ?
|
|
1932
|
+
const from = part.table ? _chunkJILIA5EVcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1929
1933
|
if (!from || !part.table) {
|
|
1930
1934
|
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
1931
1935
|
continue;
|
|
@@ -1941,12 +1945,12 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1941
1945
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1942
1946
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1943
1947
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1944
|
-
if (
|
|
1945
|
-
|
|
1946
|
-
const lines =
|
|
1947
|
-
if (_optionalChain([lines, 'optionalAccess', _205 => _205.length]))
|
|
1948
|
-
if (part.pageNumber && part.bbox)
|
|
1949
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _206 => _206.blocks, 'optionalAccess', _207 => _207.length]) ||
|
|
1948
|
+
if (_chunkJILIA5EVcjs.IMAGE_CELLS.has(add)) _chunkJILIA5EVcjs.IMAGE_CELLS.add(cell);
|
|
1949
|
+
_chunkJILIA5EVcjs.joinCellEdges.call(void 0, cell, add);
|
|
1950
|
+
const lines = _chunkJILIA5EVcjs.CELL_LINES.get(add);
|
|
1951
|
+
if (_optionalChain([lines, 'optionalAccess', _205 => _205.length])) _chunkJILIA5EVcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkJILIA5EVcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1952
|
+
if (part.pageNumber && part.bbox) _chunkJILIA5EVcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkJILIA5EVcjs.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]) || _chunkJILIA5EVcjs.IMAGE_CELLS.has(cell)) _chunkJILIA5EVcjs.EMPTY_PARTS.delete(prev.table);
|
|
1950
1954
|
blocks.splice(j, 1);
|
|
1951
1955
|
if (cell.blocks && at > 0) {
|
|
1952
1956
|
const nextAt = cell.blocks[at];
|
|
@@ -1958,11 +1962,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1958
1962
|
}
|
|
1959
1963
|
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
1960
1964
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1961
|
-
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 || !_chunkJILIA5EVcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1962
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]);
|
|
1963
1967
|
const next = _optionalChain([inner, 'optionalAccess', _215 => _215[0]]);
|
|
1964
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _216 => _216.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
1965
|
-
const px =
|
|
1968
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _216 => _216.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkJILIA5EVcjs.CLIP_TABLES.has(prev.table) || !_chunkJILIA5EVcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1969
|
+
const px = _chunkJILIA5EVcjs.TABLE_COLXS.get(prev.table), nx = _chunkJILIA5EVcjs.TABLE_COLXS.get(next.table);
|
|
1966
1970
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1967
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)]);
|
|
1968
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;
|
|
@@ -1972,15 +1976,15 @@ function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
|
1972
1976
|
function fillNestedContinuation(blocks, at) {
|
|
1973
1977
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1974
1978
|
const t = _optionalChain([prev, 'optionalAccess', _223 => _223.table]), u = _optionalChain([next, 'optionalAccess', _224 => _224.table]);
|
|
1975
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1976
|
-
const xs =
|
|
1979
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkJILIA5EVcjs.CLIP_TABLES.has(t) || !_chunkJILIA5EVcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1980
|
+
const xs = _chunkJILIA5EVcjs.TABLE_COLXS.get(u);
|
|
1977
1981
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1978
1982
|
const add = _optionalChain([u, 'access', _225 => _225.cells, 'access', _226 => _226[0], 'optionalAccess', _227 => _227[0]]);
|
|
1979
|
-
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]) || _chunkJILIA5EVcjs.IMAGE_CELLS.has(cell)) return;
|
|
1980
1984
|
cell.text = add.text;
|
|
1981
1985
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1982
|
-
if (
|
|
1983
|
-
|
|
1986
|
+
if (_chunkJILIA5EVcjs.IMAGE_CELLS.has(add)) _chunkJILIA5EVcjs.IMAGE_CELLS.add(cell);
|
|
1987
|
+
_chunkJILIA5EVcjs.joinCellEdges.call(void 0, cell, add);
|
|
1984
1988
|
blocks.splice(at, 1);
|
|
1985
1989
|
}
|
|
1986
1990
|
|
|
@@ -2580,12 +2584,12 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
2580
2584
|
}
|
|
2581
2585
|
}
|
|
2582
2586
|
for (const q of queues.values()) for (let k = 0; k < q.length; k++) {
|
|
2583
|
-
const pair = k + 1 < q.length ?
|
|
2587
|
+
const pair = k + 1 < q.length ? _chunkN65EY5BIcjs.pairedNumber.call(void 0, q[k], q[k + 1]) : void 0;
|
|
2584
2588
|
if (pair !== void 0) {
|
|
2585
2589
|
q[k] = pair;
|
|
2586
2590
|
q[k + 1] = "";
|
|
2587
2591
|
k++;
|
|
2588
|
-
} else q[k] =
|
|
2592
|
+
} else q[k] = _chunkN65EY5BIcjs.mapPuaText.call(void 0, q[k]);
|
|
2589
2593
|
}
|
|
2590
2594
|
const byFont = /* @__PURE__ */ new Map();
|
|
2591
2595
|
for (const it of items) {
|
|
@@ -2620,15 +2624,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
2620
2624
|
function marginContextBlocks(raw, page, view) {
|
|
2621
2625
|
const [x1, y1, x2, y2] = view;
|
|
2622
2626
|
const width = x2 - x1, height = y2 - y1;
|
|
2623
|
-
const items =
|
|
2627
|
+
const items = _chunkJILIA5EVcjs.filterHiddenText.call(void 0, _chunkJILIA5EVcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
2624
2628
|
for (const item of items) {
|
|
2625
2629
|
item.x -= x1;
|
|
2626
2630
|
item.y -= y1;
|
|
2627
2631
|
}
|
|
2628
|
-
return
|
|
2629
|
-
const bbox =
|
|
2632
|
+
return _chunkJILIA5EVcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
2633
|
+
const bbox = _chunkJILIA5EVcjs.computeBBox.call(void 0, line, page);
|
|
2630
2634
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
2631
|
-
return [{ type: "paragraph", text:
|
|
2635
|
+
return [{ type: "paragraph", text: _chunkJILIA5EVcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkJILIA5EVcjs.dominantStyle.call(void 0, line) }];
|
|
2632
2636
|
});
|
|
2633
2637
|
}
|
|
2634
2638
|
|
|
@@ -2664,7 +2668,7 @@ var WINANSI_REVERSE = {
|
|
|
2664
2668
|
};
|
|
2665
2669
|
function symbolFontTable(fontName) {
|
|
2666
2670
|
if (!fontName) return void 0;
|
|
2667
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
2671
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkN65EY5BIcjs.WINGDINGS;
|
|
2668
2672
|
return void 0;
|
|
2669
2673
|
}
|
|
2670
2674
|
function remapSymbolText(text, table) {
|
|
@@ -3567,7 +3571,7 @@ function mergeEnclosedDigits(items) {
|
|
|
3567
3571
|
if (!/^\d\d?$/.test(digits)) continue;
|
|
3568
3572
|
const mid = (inside2[0].x + inside2[inside2.length - 1].x + inside2[inside2.length - 1].w) / 2;
|
|
3569
3573
|
if (Math.abs(mid - (s.x + s.w / 2)) > s.fontSize * 0.15) continue;
|
|
3570
|
-
s.text =
|
|
3574
|
+
s.text = _chunkN65EY5BIcjs.enclosedNumber.call(void 0, Number(digits));
|
|
3571
3575
|
for (const d of inside2) drop.add(d);
|
|
3572
3576
|
}
|
|
3573
3577
|
if (!drop.size) return;
|
|
@@ -3749,7 +3753,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3749
3753
|
if (block.type !== "heading" || !block.text) continue;
|
|
3750
3754
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
3751
3755
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _304 => _304.style, 'optionalAccess', _305 => _305.fontSize]), () => ( 0));
|
|
3752
|
-
const tocEntry = i > 0 &&
|
|
3756
|
+
const tocEntry = i > 0 && _chunkJILIA5EVcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkJILIA5EVcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
3753
3757
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
3754
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;
|
|
3755
3759
|
const next = blocks[i + 1];
|
|
@@ -3847,7 +3851,7 @@ function splitSingleCellTables(blocks) {
|
|
|
3847
3851
|
const out = [];
|
|
3848
3852
|
for (const b of blocks) {
|
|
3849
3853
|
const t = b.type === "table" ? b.table : void 0;
|
|
3850
|
-
const title = t &&
|
|
3854
|
+
const title = t && _chunkJILIA5EVcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3851
3855
|
if (title) {
|
|
3852
3856
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3853
3857
|
continue;
|
|
@@ -3883,7 +3887,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
3883
3887
|
const lines = cell.text.split("\n");
|
|
3884
3888
|
const out = [lines[0]];
|
|
3885
3889
|
for (const line of lines.slice(1)) {
|
|
3886
|
-
if (
|
|
3890
|
+
if (_chunkJILIA5EVcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
3887
3891
|
else out.push(line);
|
|
3888
3892
|
}
|
|
3889
3893
|
cell.text = out.join("\n");
|
|
@@ -3903,10 +3907,10 @@ function cleanPdfText(text, opts) {
|
|
|
3903
3907
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
3904
3908
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
3905
3909
|
if (line.startsWith("|")) {
|
|
3906
|
-
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) => _chunkJILIA5EVcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
3907
3911
|
}
|
|
3908
3912
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _387 => _387.exec, 'call', _388 => _388(line), 'optionalAccess', _389 => _389[0]]), () => ( ""));
|
|
3909
|
-
return mark +
|
|
3913
|
+
return mark + _chunkJILIA5EVcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
3910
3914
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
3911
3915
|
}
|
|
3912
3916
|
function startsWithMarker(line) {
|
|
@@ -3938,7 +3942,7 @@ function mergeKoreanLines(text) {
|
|
|
3938
3942
|
continue;
|
|
3939
3943
|
}
|
|
3940
3944
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
3941
|
-
result[result.length - 1] = prev +
|
|
3945
|
+
result[result.length - 1] = prev + _chunkJILIA5EVcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
3942
3946
|
} else {
|
|
3943
3947
|
result.push(curr);
|
|
3944
3948
|
}
|
|
@@ -3954,7 +3958,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3954
3958
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3955
3959
|
for (const a of annots) {
|
|
3956
3960
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3957
|
-
const url =
|
|
3961
|
+
const url = _chunk6ZRZLV3Jcjs.sanitizeHref.call(void 0, a.url);
|
|
3958
3962
|
if (!url) continue;
|
|
3959
3963
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3960
3964
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -4006,7 +4010,7 @@ function mergeLinkRuns(markdown) {
|
|
|
4006
4010
|
|
|
4007
4011
|
// src/pdf/formula-ocr.ts
|
|
4008
4012
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
4009
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
4013
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-2BPHF6O7.cjs")));
|
|
4010
4014
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
4011
4015
|
await ensureFormulaModels((p) => {
|
|
4012
4016
|
if (p.phase === "download" && p.total) {
|
|
@@ -4197,13 +4201,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
4197
4201
|
try {
|
|
4198
4202
|
return await Promise.race([
|
|
4199
4203
|
loadingTask.promise.catch((e) => {
|
|
4200
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
4204
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunk6ZRZLV3Jcjs.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)");
|
|
4201
4205
|
throw e;
|
|
4202
4206
|
}),
|
|
4203
4207
|
new Promise((_, reject) => {
|
|
4204
4208
|
timer = setTimeout(() => {
|
|
4205
4209
|
loadingTask.destroy();
|
|
4206
|
-
reject(new (0,
|
|
4210
|
+
reject(new (0, _chunk6ZRZLV3Jcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
4207
4211
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
4208
4212
|
})
|
|
4209
4213
|
]);
|
|
@@ -4213,14 +4217,14 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
4213
4217
|
}
|
|
4214
4218
|
async function parsePdfDocument(buffer, options) {
|
|
4215
4219
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _390 => _390.formulaOcr]) ? buffer : null;
|
|
4216
|
-
const ocrOptionError =
|
|
4217
|
-
if (ocrOptionError) throw new (0,
|
|
4218
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _391 => _391.ocr]) === void 0 && await
|
|
4220
|
+
const ocrOptionError = _chunkN65EY5BIcjs.validateOcrOptions.call(void 0, options);
|
|
4221
|
+
if (ocrOptionError) throw new (0, _chunk6ZRZLV3Jcjs.KordocError)(ocrOptionError);
|
|
4222
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _391 => _391.ocr]) === void 0 && await _chunkJILIA5EVcjs.ocrModelsCached.call(void 0, _chunkJILIA5EVcjs.resolveOcrModels.call(void 0, options));
|
|
4219
4223
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _392 => _392.ocr]) || autoOcr ? buffer : null;
|
|
4220
4224
|
const doc = await loadPdfWithTimeout(buffer);
|
|
4221
4225
|
try {
|
|
4222
4226
|
const pageCount = doc.numPages;
|
|
4223
|
-
if (pageCount === 0) throw new (0,
|
|
4227
|
+
if (pageCount === 0) throw new (0, _chunk6ZRZLV3Jcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
4224
4228
|
const metadata = { pageCount, pageMode: "layout" };
|
|
4225
4229
|
await extractPdfMetadata(doc, metadata);
|
|
4226
4230
|
const blocks = [];
|
|
@@ -4249,7 +4253,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4249
4253
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
4250
4254
|
const carry = {};
|
|
4251
4255
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
4252
|
-
const wrapLexicon = new (0,
|
|
4256
|
+
const wrapLexicon = new (0, _chunkJILIA5EVcjs.WrapLexicon)();
|
|
4253
4257
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
4254
4258
|
const headerContext = [];
|
|
4255
4259
|
if (pageFilter && _optionalChain([options, 'optionalAccess', _395 => _395.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
@@ -4296,8 +4300,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4296
4300
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
4297
4301
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4298
4302
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
4299
|
-
const items =
|
|
4300
|
-
const filtered =
|
|
4303
|
+
const items = _chunkJILIA5EVcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
4304
|
+
const filtered = _chunkJILIA5EVcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
4301
4305
|
const joined = joinVerticalColumns(filtered.visible);
|
|
4302
4306
|
const visible = dropTabLeaderDots(joined);
|
|
4303
4307
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -4324,7 +4328,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4324
4328
|
} : rawOps;
|
|
4325
4329
|
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _402 => _402(loadedName), 'optionalAccess', _403 => _403.name]));
|
|
4326
4330
|
remapControlGlyphs(visible, differencesOf);
|
|
4327
|
-
await
|
|
4331
|
+
await _chunkJILIA5EVcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
4328
4332
|
const faces = /* @__PURE__ */ new Map();
|
|
4329
4333
|
for (const it of visible) {
|
|
4330
4334
|
if (!it.fontName) continue;
|
|
@@ -4337,12 +4341,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4337
4341
|
it.fontName = face;
|
|
4338
4342
|
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _405 => _405(face), 'optionalAccess', _406 => _406.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
4339
4343
|
}
|
|
4340
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
4341
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
4344
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkN65EY5BIcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
4345
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkN65EY5BIcjs.escapeLiteralTags.call(void 0, it.text);
|
|
4342
4346
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
4343
4347
|
const pageArea = pageW * pageH;
|
|
4344
4348
|
if (pageArea > 0) {
|
|
4345
|
-
const imageRegions =
|
|
4349
|
+
const imageRegions = _chunkJILIA5EVcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
4346
4350
|
let uncovered = 0;
|
|
4347
4351
|
for (const r of imageRegions) {
|
|
4348
4352
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -4368,11 +4372,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4368
4372
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
4369
4373
|
}
|
|
4370
4374
|
const marks = superscriptNoteMarks(visible);
|
|
4371
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
4375
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkJILIA5EVcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
4372
4376
|
const stamp = marginStamp(visible);
|
|
4373
4377
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
4374
|
-
const rightArrows = _optionalChain([options, 'optionalAccess', _407 => _407.tables]) !== false ? await
|
|
4375
|
-
const pageBlocks = orderTwoUpPage(
|
|
4378
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _407 => _407.tables]) !== false ? await _chunkJILIA5EVcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
4379
|
+
const pageBlocks = orderTwoUpPage(_chunkJILIA5EVcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _408 => _408.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
4376
4380
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
4377
4381
|
for (const b of pageBlocks) blocks.push(b);
|
|
4378
4382
|
try {
|
|
@@ -4398,11 +4402,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4398
4402
|
if (_optionalChain([options, 'optionalAccess', _410 => _410.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
4399
4403
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
4400
4404
|
}
|
|
4401
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
4405
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunk6ZRZLV3Jcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
4402
4406
|
parsedPages++;
|
|
4403
4407
|
_optionalChain([options, 'optionalAccess', _411 => _411.onProgress, 'optionalCall', _412 => _412(parsedPages, totalTarget)]);
|
|
4404
4408
|
} catch (pageErr) {
|
|
4405
|
-
if (pageErr instanceof
|
|
4409
|
+
if (pageErr instanceof _chunk6ZRZLV3Jcjs.KordocError) throw pageErr;
|
|
4406
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" });
|
|
4407
4411
|
} finally {
|
|
4408
4412
|
_optionalChain([loadedPage, 'optionalAccess', _413 => _413.cleanup, 'call', _414 => _414()]);
|
|
@@ -4433,12 +4437,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4433
4437
|
}
|
|
4434
4438
|
if (targets.size > 0) {
|
|
4435
4439
|
try {
|
|
4436
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
4440
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-7MDCLWAA.cjs")));
|
|
4437
4441
|
const mode = typeof _optionalChain([options, 'optionalAccess', _419 => _419.ocr]) === "function" ? options.ocr : "builtin";
|
|
4438
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])));
|
|
4439
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
4443
|
+
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-7MDCLWAA.cjs")));
|
|
4440
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);
|
|
4441
|
-
for (const obs of ocrPageBlocks.values())
|
|
4445
|
+
for (const obs of ocrPageBlocks.values()) _chunkN65EY5BIcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
4442
4446
|
if (ocrPageBlocks.size > 0) {
|
|
4443
4447
|
const replacePages = /* @__PURE__ */ new Set();
|
|
4444
4448
|
for (const [p, obs] of ocrPageBlocks) {
|
|
@@ -4449,7 +4453,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4449
4453
|
continue;
|
|
4450
4454
|
}
|
|
4451
4455
|
const regions = ocrRegions.get(p);
|
|
4452
|
-
if (!regions ||
|
|
4456
|
+
if (!regions || _chunkJILIA5EVcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
4453
4457
|
ocrDone.add(p);
|
|
4454
4458
|
if (_optionalChain([pageImageBlocks, 'access', _430 => _430.get, 'call', _431 => _431(p), 'optionalAccess', _432 => _432.length]) === 1) pageImageBlocks.delete(p);
|
|
4455
4459
|
}
|
|
@@ -4502,17 +4506,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4502
4506
|
}
|
|
4503
4507
|
}
|
|
4504
4508
|
if (_optionalChain([options, 'optionalAccess', _433 => _433.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
4505
|
-
const removed =
|
|
4506
|
-
const running =
|
|
4509
|
+
const removed = _chunkJILIA5EVcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
4510
|
+
const running = _chunkJILIA5EVcjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
4507
4511
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
4508
4512
|
blocks.splice(removed[ri], 1);
|
|
4509
4513
|
}
|
|
4510
|
-
const stripped =
|
|
4514
|
+
const stripped = _chunkJILIA5EVcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
4511
4515
|
if (stripped !== blocks) {
|
|
4512
4516
|
blocks.length = 0;
|
|
4513
4517
|
blocks.push(...stripped);
|
|
4514
4518
|
}
|
|
4515
|
-
const kept =
|
|
4519
|
+
const kept = _chunkJILIA5EVcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
4516
4520
|
if (kept !== blocks) {
|
|
4517
4521
|
blocks.length = 0;
|
|
4518
4522
|
blocks.push(...kept);
|
|
@@ -4521,12 +4525,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4521
4525
|
mergeContinuedCells(blocks, pageHeights);
|
|
4522
4526
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
4523
4527
|
if (_optionalChain([options, 'optionalAccess', _434 => _434.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
4524
|
-
const boxes =
|
|
4528
|
+
const boxes = _chunkJILIA5EVcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
4525
4529
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
4526
4530
|
}
|
|
4527
4531
|
splitContactTables(blocks);
|
|
4528
|
-
if (!_optionalChain([options, 'optionalAccess', _435 => _435.keepTrailingEmptyCols]))
|
|
4529
|
-
|
|
4532
|
+
if (!_optionalChain([options, 'optionalAccess', _435 => _435.keepTrailingEmptyCols])) _chunkJILIA5EVcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
4533
|
+
_chunkJILIA5EVcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
4530
4534
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
4531
4535
|
if (_optionalChain([options, 'optionalAccess', _436 => _436.formulaOcr]) && formulaBuffer) {
|
|
4532
4536
|
try {
|
|
@@ -4538,21 +4542,21 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4538
4542
|
});
|
|
4539
4543
|
}
|
|
4540
4544
|
}
|
|
4541
|
-
const medianFontSize =
|
|
4545
|
+
const medianFontSize = _chunkJILIA5EVcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
4542
4546
|
if (medianFontSize > 0) {
|
|
4543
|
-
|
|
4544
|
-
}
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4547
|
+
_chunkJILIA5EVcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
4548
|
+
}
|
|
4549
|
+
_chunkJILIA5EVcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
4550
|
+
_chunkJILIA5EVcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
4551
|
+
_chunkJILIA5EVcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
4552
|
+
_chunkJILIA5EVcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
4553
|
+
_chunkJILIA5EVcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
4554
|
+
_chunkJILIA5EVcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
4555
|
+
_chunkJILIA5EVcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
4556
|
+
_chunkJILIA5EVcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
4553
4557
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
4554
|
-
|
|
4555
|
-
|
|
4558
|
+
_chunkJILIA5EVcjs.detectTableCaptions.call(void 0, blocks);
|
|
4559
|
+
_chunkJILIA5EVcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
4556
4560
|
sanitizeBlockControlChars(blocks);
|
|
4557
4561
|
let outBlocks = splitSingleCellTables(blocks);
|
|
4558
4562
|
if (_optionalChain([options, 'optionalAccess', _437 => _437.layoutTables]) !== "keep") {
|
|
@@ -4573,19 +4577,19 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4573
4577
|
const shown = /* @__PURE__ */ new Map();
|
|
4574
4578
|
const markContent = (bs) => {
|
|
4575
4579
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
4576
|
-
if (
|
|
4577
|
-
const lines =
|
|
4578
|
-
if (lines)
|
|
4580
|
+
if (_chunkJILIA5EVcjs.IMAGE_CELLS.has(c)) _chunkN65EY5BIcjs.CONTENT_CELLS.add(c);
|
|
4581
|
+
const lines = _chunkJILIA5EVcjs.CELL_LINES.get(c);
|
|
4582
|
+
if (lines) _chunkN65EY5BIcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
4579
4583
|
markContent(c.blocks);
|
|
4580
4584
|
}
|
|
4581
4585
|
};
|
|
4582
4586
|
const visual = (bs) => bs.flatMap((b) => {
|
|
4583
4587
|
if (b.type !== "table") return [b];
|
|
4584
|
-
if (!hancom && b.table &&
|
|
4588
|
+
if (!hancom && b.table && _chunkJILIA5EVcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
4585
4589
|
let v = shown.get(b);
|
|
4586
4590
|
if (!v) {
|
|
4587
4591
|
markContent([b]);
|
|
4588
|
-
shown.set(b, v =
|
|
4592
|
+
shown.set(b, v = _chunkN65EY5BIcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _440 => _440.keepTrailingEmptyCols])));
|
|
4589
4593
|
}
|
|
4590
4594
|
return v;
|
|
4591
4595
|
});
|
|
@@ -4594,13 +4598,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4594
4598
|
blocks.length = 0;
|
|
4595
4599
|
for (const b of kept) blocks.push(b);
|
|
4596
4600
|
}
|
|
4597
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
4598
|
-
if (_optionalChain([options, 'optionalAccess', _442 => _442.tableFormat]) === "gfm")
|
|
4601
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkN65EY5BIcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _441 => _441.tableFormat]) }), { keepLoneNumbers: true }));
|
|
4602
|
+
if (_optionalChain([options, 'optionalAccess', _442 => _442.tableFormat]) === "gfm") _chunkN65EY5BIcjs.assignTableIds.call(void 0, blocks);
|
|
4599
4603
|
let markdown = finishMarkdown(outBlocks);
|
|
4600
4604
|
const outline = collectPdfOutline(outBlocks);
|
|
4601
4605
|
return {
|
|
4602
4606
|
markdown,
|
|
4603
|
-
pages:
|
|
4607
|
+
pages: _chunkYG4YOPK6cjs.blocksToPages.call(void 0, splitPageTables(_chunkJILIA5EVcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
4604
4608
|
blocks,
|
|
4605
4609
|
metadata,
|
|
4606
4610
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -4680,5 +4684,5 @@ function marginStamp(items) {
|
|
|
4680
4684
|
|
|
4681
4685
|
|
|
4682
4686
|
|
|
4683
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
4684
|
-
//# sourceMappingURL=parser-
|
|
4687
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkJILIA5EVcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkJILIA5EVcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkJILIA5EVcjs.removeHeaderFooterBlocks;
|
|
4688
|
+
//# sourceMappingURL=parser-HE45CCSG.cjs.map
|