kordoc 4.18.11 → 4.18.13
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 +2 -1
- package/dist/{-TUDCOQX6.js → -DC2OO5KO.js} +11 -11
- package/dist/{chunk-PF4O626Y.js → chunk-32ZUIHSY.js} +3 -3
- package/dist/{chunk-Q5GB73E7.cjs → chunk-3FGHQWJP.cjs} +151 -130
- package/dist/chunk-3FGHQWJP.cjs.map +1 -0
- package/dist/{chunk-GNXDTPP6.js → chunk-6AYTYTFY.js} +3 -3
- package/dist/{chunk-DT5OWHWO.cjs → chunk-6CQZMVXW.cjs} +3 -3
- package/dist/{chunk-DT5OWHWO.cjs.map → chunk-6CQZMVXW.cjs.map} +1 -1
- package/dist/{chunk-IUOGBCVI.cjs → chunk-6FW3AZWN.cjs} +6 -6
- package/dist/{chunk-IUOGBCVI.cjs.map → chunk-6FW3AZWN.cjs.map} +1 -1
- package/dist/{chunk-KFB7LHCB.js → chunk-7LOD4IGO.js} +4 -4
- package/dist/{chunk-5GVDHHHO.js → chunk-DHEUQXXR.js} +2 -2
- package/dist/{chunk-KA2NMWIC.js → chunk-EBXJ45VZ.js} +2 -2
- package/dist/{chunk-DU2DV4LO.js → chunk-EZSWBHHI.js} +2 -2
- package/dist/{chunk-7H5P475X.cjs → chunk-GGMIPTM5.cjs} +12 -12
- package/dist/{chunk-7H5P475X.cjs.map → chunk-GGMIPTM5.cjs.map} +1 -1
- package/dist/{chunk-PIRSOTKK.js → chunk-GSW7W7AL.js} +2 -2
- package/dist/{chunk-TYIUJKUT.js → chunk-GUH6HYSZ.js} +10 -10
- package/dist/{chunk-CNU4NPCC.js → chunk-INESPVEV.js} +26 -5
- package/dist/chunk-INESPVEV.js.map +1 -0
- package/dist/{chunk-DXRKZWC3.js → chunk-IRN5SDY2.js} +2 -2
- package/dist/{chunk-P6GO34IP.js → chunk-ISC2TH24.js} +2 -2
- package/dist/{chunk-WP6KG5Z7.js → chunk-JKHU7HID.js} +2 -2
- package/dist/{chunk-UAWOYMBR.js → chunk-JPSLMPFI.js} +2 -2
- package/dist/{chunk-QK6AJJMJ.js → chunk-JWTZ3OVZ.js} +2 -2
- package/dist/{chunk-FS6RCEF6.cjs → chunk-K6WSMTVU.cjs} +2 -2
- package/dist/{chunk-FS6RCEF6.cjs.map → chunk-K6WSMTVU.cjs.map} +1 -1
- package/dist/{chunk-56QHHRWD.js → chunk-LKA7Z2NH.js} +2 -2
- package/dist/{chunk-XJCWMVVY.js → chunk-PHMWSWHJ.js} +2 -2
- package/dist/{chunk-JZ3VPASI.js → chunk-PN5WWW56.js} +2 -2
- package/dist/{chunk-PC4U3XRK.cjs → chunk-RQEDNI4P.cjs} +3 -3
- package/dist/{chunk-PC4U3XRK.cjs.map → chunk-RQEDNI4P.cjs.map} +1 -1
- package/dist/{chunk-L7TALZNE.js → chunk-SVIOP7PE.js} +6 -6
- package/dist/{chunk-UG4GIJSH.js → chunk-V7LKQNC4.js} +2 -2
- package/dist/{chunk-DKVS6CFO.js → chunk-VDEENOPW.js} +2 -2
- package/dist/{chunk-UETNJSA7.js → chunk-XVB3PUPJ.js} +2 -2
- package/dist/{chunk-CMROXIWJ.js → chunk-ZNY5BRV6.js} +27 -6
- package/dist/chunk-ZNY5BRV6.js.map +1 -0
- package/dist/chunks-JZW2TXIZ.js +10 -0
- package/dist/cli.js +26 -26
- package/dist/{formula-5BPY5GQL.js → formula-DAMFHLQO.js} +3 -3
- package/dist/{formula-VUI2AJUZ.cjs → formula-HJNQGPRC.cjs} +9 -9
- package/dist/{formula-VUI2AJUZ.cjs.map → formula-HJNQGPRC.cjs.map} +1 -1
- package/dist/{formula-RA2JV55J.js → formula-YCAO5IVW.js} +4 -4
- package/dist/{image-ocr-3LUFXLSS.cjs → image-ocr-AZ25IOC7.cjs} +15 -15
- package/dist/{image-ocr-3LUFXLSS.cjs.map → image-ocr-AZ25IOC7.cjs.map} +1 -1
- package/dist/{image-ocr-MOGXLPIS.js → image-ocr-PAF76DAW.js} +9 -9
- package/dist/{image-ocr-QDNBFOLW.js → image-ocr-VH54SDZ7.js} +6 -6
- package/dist/index.cjs +277 -277
- package/dist/index.js +5 -5
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-PKJUJTPC.js → model-bundle-53CHDYCG.js} +5 -5
- package/dist/{models-ZZCRW54N.js → models-UVLAKK3M.js} +5 -5
- package/dist/{parser-SL5XDJYU.cjs → parser-HWAOPQYK.cjs} +126 -126
- package/dist/{parser-SL5XDJYU.cjs.map → parser-HWAOPQYK.cjs.map} +1 -1
- package/dist/{parser-PICN5MDD.js → parser-I4D3TRGU.js} +11 -11
- package/dist/{parser-IU4QXSEQ.js → parser-Z6PHB54O.js} +8 -8
- package/dist/pdf-ocr-F4ICXO7W.js +20 -0
- package/dist/pdf-ocr-HR6CXGTX.cjs +17 -0
- package/dist/{pdf-ocr-37GLDHR2.cjs.map → pdf-ocr-HR6CXGTX.cjs.map} +1 -1
- package/dist/pdf-ocr-JI3K7JIN.js +16 -0
- package/dist/{profile-io-TQXBV4NZ.js → profile-io-WHCWCOPW.js} +3 -3
- package/dist/{rasterize-QHUKA2N7.js → rasterize-5DZ3DHGH.js} +3 -3
- package/dist/{redact-doc-HHTMXA3E.js → redact-doc-RNJVMFGQ.js} +11 -11
- package/dist/{render-RZF6SNSN.js → render-NZ6RA6SW.js} +7 -7
- package/dist/seal-WHJ6O5HT.js +10 -0
- package/dist/{setup-IUCBBXYG.js → setup-U3EQNK4Z.js} +3 -3
- package/dist/visual-JDAS4R43.js +20 -0
- package/dist/{watch-G46MOBKP.js → watch-GB2M7XU6.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-CMROXIWJ.js.map +0 -1
- package/dist/chunk-CNU4NPCC.js.map +0 -1
- package/dist/chunk-Q5GB73E7.cjs.map +0 -1
- package/dist/chunks-ZZZGBVGM.js +0 -10
- package/dist/pdf-ocr-37GLDHR2.cjs +0 -17
- package/dist/pdf-ocr-7AWV7MY3.js +0 -20
- package/dist/pdf-ocr-UXP4CV6V.js +0 -16
- package/dist/seal-TBTMKXLY.js +0 -10
- package/dist/visual-I64Z7W3Q.js +0 -20
- /package/dist/{-TUDCOQX6.js.map → -DC2OO5KO.js.map} +0 -0
- /package/dist/{chunk-PF4O626Y.js.map → chunk-32ZUIHSY.js.map} +0 -0
- /package/dist/{chunk-GNXDTPP6.js.map → chunk-6AYTYTFY.js.map} +0 -0
- /package/dist/{chunk-KFB7LHCB.js.map → chunk-7LOD4IGO.js.map} +0 -0
- /package/dist/{chunk-5GVDHHHO.js.map → chunk-DHEUQXXR.js.map} +0 -0
- /package/dist/{chunk-KA2NMWIC.js.map → chunk-EBXJ45VZ.js.map} +0 -0
- /package/dist/{chunk-DU2DV4LO.js.map → chunk-EZSWBHHI.js.map} +0 -0
- /package/dist/{chunk-PIRSOTKK.js.map → chunk-GSW7W7AL.js.map} +0 -0
- /package/dist/{chunk-TYIUJKUT.js.map → chunk-GUH6HYSZ.js.map} +0 -0
- /package/dist/{chunk-DXRKZWC3.js.map → chunk-IRN5SDY2.js.map} +0 -0
- /package/dist/{chunk-P6GO34IP.js.map → chunk-ISC2TH24.js.map} +0 -0
- /package/dist/{chunk-WP6KG5Z7.js.map → chunk-JKHU7HID.js.map} +0 -0
- /package/dist/{chunk-UAWOYMBR.js.map → chunk-JPSLMPFI.js.map} +0 -0
- /package/dist/{chunk-QK6AJJMJ.js.map → chunk-JWTZ3OVZ.js.map} +0 -0
- /package/dist/{chunk-56QHHRWD.js.map → chunk-LKA7Z2NH.js.map} +0 -0
- /package/dist/{chunk-XJCWMVVY.js.map → chunk-PHMWSWHJ.js.map} +0 -0
- /package/dist/{chunk-JZ3VPASI.js.map → chunk-PN5WWW56.js.map} +0 -0
- /package/dist/{chunk-L7TALZNE.js.map → chunk-SVIOP7PE.js.map} +0 -0
- /package/dist/{chunk-UG4GIJSH.js.map → chunk-V7LKQNC4.js.map} +0 -0
- /package/dist/{chunk-DKVS6CFO.js.map → chunk-VDEENOPW.js.map} +0 -0
- /package/dist/{chunk-UETNJSA7.js.map → chunk-XVB3PUPJ.js.map} +0 -0
- /package/dist/{chunks-ZZZGBVGM.js.map → chunks-JZW2TXIZ.js.map} +0 -0
- /package/dist/{formula-5BPY5GQL.js.map → formula-DAMFHLQO.js.map} +0 -0
- /package/dist/{formula-RA2JV55J.js.map → formula-YCAO5IVW.js.map} +0 -0
- /package/dist/{image-ocr-MOGXLPIS.js.map → image-ocr-PAF76DAW.js.map} +0 -0
- /package/dist/{image-ocr-QDNBFOLW.js.map → image-ocr-VH54SDZ7.js.map} +0 -0
- /package/dist/{model-bundle-PKJUJTPC.js.map → model-bundle-53CHDYCG.js.map} +0 -0
- /package/dist/{models-ZZCRW54N.js.map → models-UVLAKK3M.js.map} +0 -0
- /package/dist/{parser-PICN5MDD.js.map → parser-I4D3TRGU.js.map} +0 -0
- /package/dist/{parser-IU4QXSEQ.js.map → parser-Z6PHB54O.js.map} +0 -0
- /package/dist/{pdf-ocr-7AWV7MY3.js.map → pdf-ocr-F4ICXO7W.js.map} +0 -0
- /package/dist/{pdf-ocr-UXP4CV6V.js.map → pdf-ocr-JI3K7JIN.js.map} +0 -0
- /package/dist/{profile-io-TQXBV4NZ.js.map → profile-io-WHCWCOPW.js.map} +0 -0
- /package/dist/{rasterize-QHUKA2N7.js.map → rasterize-5DZ3DHGH.js.map} +0 -0
- /package/dist/{redact-doc-HHTMXA3E.js.map → redact-doc-RNJVMFGQ.js.map} +0 -0
- /package/dist/{render-RZF6SNSN.js.map → render-NZ6RA6SW.js.map} +0 -0
- /package/dist/{seal-TBTMKXLY.js.map → seal-WHJ6O5HT.js.map} +0 -0
- /package/dist/{setup-IUCBBXYG.js.map → setup-U3EQNK4Z.js.map} +0 -0
- /package/dist/{visual-I64Z7W3Q.js.map → visual-JDAS4R43.js.map} +0 -0
- /package/dist/{watch-G46MOBKP.js.map → watch-GB2M7XU6.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 _chunkRQEDNI4Pcjs = require('./chunk-RQEDNI4P.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -58,7 +58,7 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
var
|
|
61
|
+
var _chunk3FGHQWJPcjs = require('./chunk-3FGHQWJP.cjs');
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
|
|
@@ -68,12 +68,12 @@ var _chunkQ5GB73E7cjs = require('./chunk-Q5GB73E7.cjs');
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
var
|
|
72
|
-
require('./chunk-
|
|
71
|
+
var _chunk6FW3AZWNcjs = require('./chunk-6FW3AZWN.cjs');
|
|
72
|
+
require('./chunk-6CQZMVXW.cjs');
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
var
|
|
76
|
+
var _chunkK6WSMTVUcjs = require('./chunk-K6WSMTVU.cjs');
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -114,7 +114,7 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
114
114
|
const selectedSet = new Set(selected), seen = /* @__PURE__ */ new Set();
|
|
115
115
|
for (const block of selected) {
|
|
116
116
|
if (seen.has(block)) continue;
|
|
117
|
-
const frame =
|
|
117
|
+
const frame = _chunk3FGHQWJPcjs.FRAME_READING_UNITS.get(block);
|
|
118
118
|
const source = _optionalChain([frame, 'optionalAccess', _25 => _25.blocks, 'access', _26 => _26.every, 'call', _27 => _27((member) => selectedSet.has(member))]) ? frame.blocks : [block];
|
|
119
119
|
source.forEach((member) => seen.add(member));
|
|
120
120
|
const available = source.filter((member) => !hasOriginal(member));
|
|
@@ -122,13 +122,13 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
122
122
|
for (const unit of units) {
|
|
123
123
|
const b = unit.bbox;
|
|
124
124
|
const index = blocks.findIndex((existing) => {
|
|
125
|
-
const e = _nullishCoalesce(_optionalChain([
|
|
125
|
+
const e = _nullishCoalesce(_optionalChain([_chunk3FGHQWJPcjs.FRAME_READING_UNITS, 'access', _28 => _28.get, 'call', _29 => _29(existing), 'optionalAccess', _30 => _30.bbox]), () => ( existing.bbox));
|
|
126
126
|
if (existing.pageNumber !== page || !e) return false;
|
|
127
127
|
const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
|
|
128
128
|
return e.y < b.y || beside;
|
|
129
129
|
});
|
|
130
130
|
const placed = unit.blocks.map((member) => member.type === "paragraph" ? { ...member, style: void 0 } : member);
|
|
131
|
-
if (unit.atomic)
|
|
131
|
+
if (unit.atomic) _chunk3FGHQWJPcjs.recordFrameReadingUnit.call(void 0, placed, unit.bbox);
|
|
132
132
|
blocks.splice(index < 0 ? blocks.length : index, 0, ...placed);
|
|
133
133
|
added += placed.length;
|
|
134
134
|
}
|
|
@@ -329,7 +329,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
329
329
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
330
330
|
state.seen.set(hash, filename);
|
|
331
331
|
if (withBytes) {
|
|
332
|
-
const png =
|
|
332
|
+
const png = _chunkRQEDNI4Pcjs.encodePng.call(void 0, w, h, rgba);
|
|
333
333
|
state.totalBytes += png.length;
|
|
334
334
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
335
335
|
}
|
|
@@ -844,19 +844,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
844
844
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
845
845
|
}
|
|
846
846
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
847
|
-
const lines =
|
|
848
|
-
if (lines)
|
|
849
|
-
if (
|
|
850
|
-
const edges =
|
|
847
|
+
const lines = _chunk3FGHQWJPcjs.CELL_LINES.get(a.cell);
|
|
848
|
+
if (lines) _chunk3FGHQWJPcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
849
|
+
if (_chunk3FGHQWJPcjs.IMAGE_CELLS.has(a.cell)) _chunk3FGHQWJPcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
850
|
+
const edges = _chunk6FW3AZWNcjs.CELL_EDGES.get(a.cell);
|
|
851
851
|
if (edges) {
|
|
852
|
-
|
|
852
|
+
_chunk6FW3AZWNcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
853
853
|
edged = true;
|
|
854
854
|
}
|
|
855
855
|
return true;
|
|
856
856
|
};
|
|
857
|
-
for (const a of pa) if (!
|
|
857
|
+
for (const a of pa) if (!_chunk3FGHQWJPcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
858
858
|
for (const a of ca) {
|
|
859
|
-
if (a.r < skip ||
|
|
859
|
+
if (a.r < skip || _chunk3FGHQWJPcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
860
860
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
861
861
|
}
|
|
862
862
|
const first = prev.rows;
|
|
@@ -880,9 +880,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
880
880
|
const grown = { ...above, rs: newRs };
|
|
881
881
|
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;
|
|
882
882
|
}
|
|
883
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
883
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunk3FGHQWJPcjs.FILLER_CELLS.add(grid[r][c]);
|
|
884
884
|
if (edged) {
|
|
885
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
885
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunk6FW3AZWNcjs.CELL_EDGES.set(grid[r][c], _chunk3FGHQWJPcjs.NO_EDGES);
|
|
886
886
|
}
|
|
887
887
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
888
888
|
let r = prev.rows;
|
|
@@ -891,7 +891,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
891
891
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
892
892
|
}
|
|
893
893
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
894
|
-
const pr =
|
|
894
|
+
const pr = _chunk3FGHQWJPcjs.ROW_RULES.get(prev), cr = _chunk3FGHQWJPcjs.ROW_RULES.get(curr);
|
|
895
895
|
const shifted = dx !== 0;
|
|
896
896
|
const cut = {
|
|
897
897
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -902,7 +902,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
902
902
|
if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U)) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
|
|
903
903
|
if (pr && cr) {
|
|
904
904
|
const cutRuled = pr.bottom || cr.top;
|
|
905
|
-
|
|
905
|
+
_chunk3FGHQWJPcjs.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) });
|
|
906
906
|
}
|
|
907
907
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
908
908
|
}
|
|
@@ -956,7 +956,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
956
956
|
if (!crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
957
957
|
if (!straddles && !midWord) continue;
|
|
958
958
|
if (u.r >= last && d.rs < 2) continue;
|
|
959
|
-
const U =
|
|
959
|
+
const U = _chunk3FGHQWJPcjs.CELL_LINES.get(a);
|
|
960
960
|
if (!_optionalChain([U, 'optionalAccess', _62 => _62.length]) || !hasContent(b)) continue;
|
|
961
961
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
962
962
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -1003,7 +1003,7 @@ function nextItemHead(prev, next) {
|
|
|
1003
1003
|
return false;
|
|
1004
1004
|
}
|
|
1005
1005
|
function continuesAcross(u, d, x1, x2) {
|
|
1006
|
-
const U =
|
|
1006
|
+
const U = _chunk3FGHQWJPcjs.CELL_LINES.get(u), D = _chunk3FGHQWJPcjs.CELL_LINES.get(d);
|
|
1007
1007
|
if (!_optionalChain([U, 'optionalAccess', _63 => _63.length]) || !_optionalChain([D, 'optionalAccess', _64 => _64.length])) return false;
|
|
1008
1008
|
const last = U[U.length - 1];
|
|
1009
1009
|
const fs = last.h || 10;
|
|
@@ -1021,7 +1021,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1021
1021
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1022
1022
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1023
1023
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1024
|
-
const newItem =
|
|
1024
|
+
const newItem = _chunk3FGHQWJPcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1025
1025
|
const all = D.length ? U.concat(D) : U;
|
|
1026
1026
|
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));
|
|
1027
1027
|
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;
|
|
@@ -1038,10 +1038,10 @@ function outlineContinues(u, d) {
|
|
|
1038
1038
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1039
1039
|
}
|
|
1040
1040
|
function lineEnded(c, x1, x2, next) {
|
|
1041
|
-
const L =
|
|
1041
|
+
const L = _chunk3FGHQWJPcjs.CELL_LINES.get(c);
|
|
1042
1042
|
if (!L || L.length !== 1) return false;
|
|
1043
1043
|
const l = L[0], h = l.h || 10;
|
|
1044
|
-
const d0 = next ? _optionalChain([
|
|
1044
|
+
const d0 = next ? _optionalChain([_chunk3FGHQWJPcjs.CELL_LINES, 'access', _65 => _65.get, 'call', _66 => _66(next), 'optionalAccess', _67 => _67[0]]) : void 0;
|
|
1045
1045
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1046
1046
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _68 => _68.text]), () => ( "")))) * h;
|
|
1047
1047
|
}
|
|
@@ -1057,9 +1057,9 @@ function appendCell(a, b) {
|
|
|
1057
1057
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1058
1058
|
}
|
|
1059
1059
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1060
|
-
|
|
1060
|
+
_chunk3FGHQWJPcjs.joinCellEdges.call(void 0, a, b);
|
|
1061
1061
|
}
|
|
1062
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _75 => _75.blocks, 'optionalAccess', _76 => _76.length]) ||
|
|
1062
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _75 => _75.blocks, 'optionalAccess', _76 => _76.length]) || _chunk3FGHQWJPcjs.IMAGE_CELLS.has(cell);
|
|
1063
1063
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1064
1064
|
var batchim = (ch) => {
|
|
1065
1065
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1067,13 +1067,13 @@ var batchim = (ch) => {
|
|
|
1067
1067
|
};
|
|
1068
1068
|
function clauseContinues(u, d) {
|
|
1069
1069
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1070
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1070
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunk3FGHQWJPcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1071
1071
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1072
1072
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1073
1073
|
}
|
|
1074
1074
|
function wordOverflows(u, d, x1, x2) {
|
|
1075
|
-
const U =
|
|
1076
|
-
if (!_optionalChain([U, 'optionalAccess', _77 => _77.length]) ||
|
|
1075
|
+
const U = _chunk3FGHQWJPcjs.CELL_LINES.get(u);
|
|
1076
|
+
if (!_optionalChain([U, 'optionalAccess', _77 => _77.length]) || _chunk3FGHQWJPcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1077
1077
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1078
1078
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1079
1079
|
}
|
|
@@ -1133,7 +1133,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1133
1133
|
if (!carriedSplit) {
|
|
1134
1134
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1135
1135
|
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;
|
|
1136
|
-
const oneLine = (c) => _optionalChain([
|
|
1136
|
+
const oneLine = (c) => _optionalChain([_chunk3FGHQWJPcjs.CELL_LINES, 'access', _79 => _79.get, 'call', _80 => _80(c), 'optionalAccess', _81 => _81.length]) === 1;
|
|
1137
1137
|
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;
|
|
1138
1138
|
const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d));
|
|
1139
1139
|
if (!(cut.open && !newCell)) {
|
|
@@ -1217,19 +1217,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1217
1217
|
placeJoined(blocks, i, j, joined);
|
|
1218
1218
|
continue;
|
|
1219
1219
|
}
|
|
1220
|
-
if (
|
|
1220
|
+
if (_chunk3FGHQWJPcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1221
1221
|
blocks.splice(j, 1);
|
|
1222
1222
|
i++;
|
|
1223
1223
|
continue;
|
|
1224
1224
|
}
|
|
1225
1225
|
if (joined === null) continue;
|
|
1226
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1226
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunk3FGHQWJPcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1227
1227
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1228
1228
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1229
1229
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1230
1230
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1231
|
-
const px =
|
|
1232
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1231
|
+
const px = _chunk3FGHQWJPcjs.TABLE_COLXS.get(prev.table), cx = _chunk3FGHQWJPcjs.TABLE_COLXS.get(curr.table);
|
|
1232
|
+
if (px && cx && !shiftedSame(px, cx, !_chunk3FGHQWJPcjs.CLIP_TABLES.has(prev.table) && !_chunk3FGHQWJPcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1233
1233
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1234
1234
|
let currCells = curr.table.cells;
|
|
1235
1235
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1240,16 +1240,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1240
1240
|
blocks.splice(j, 1);
|
|
1241
1241
|
continue;
|
|
1242
1242
|
}
|
|
1243
|
-
if (px && cx && !
|
|
1243
|
+
if (px && cx && !_chunk3FGHQWJPcjs.CLIP_TABLES.has(prev.table) && !_chunk3FGHQWJPcjs.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 && _chunk3FGHQWJPcjs.CELL_LINES.has(c))) {
|
|
1244
1244
|
const dx = px[0] - cx[0];
|
|
1245
1245
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1246
1246
|
if (_optionalChain([part, 'optionalAccess', _98 => _98.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1247
1247
|
const last = prev.table.rows - 1;
|
|
1248
1248
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1249
|
-
const U =
|
|
1250
|
-
|
|
1249
|
+
const U = _chunk3FGHQWJPcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunk3FGHQWJPcjs.CELL_LINES.get(currCells[0][c]);
|
|
1250
|
+
_chunk3FGHQWJPcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1251
1251
|
}
|
|
1252
|
-
|
|
1252
|
+
_chunk3FGHQWJPcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1253
1253
|
placeJoined(blocks, i, j, part.table);
|
|
1254
1254
|
continue;
|
|
1255
1255
|
}
|
|
@@ -1262,20 +1262,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1262
1262
|
caption: prev.table.caption,
|
|
1263
1263
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1264
1264
|
};
|
|
1265
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1266
|
-
if (
|
|
1265
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunk3FGHQWJPcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1266
|
+
if (_chunk3FGHQWJPcjs.CLIP_TABLES.has(prev.table) || _chunk3FGHQWJPcjs.CLIP_TABLES.has(curr.table)) _chunk3FGHQWJPcjs.CLIP_TABLES.add(merged);
|
|
1267
1267
|
placeJoined(blocks, i, j, merged);
|
|
1268
1268
|
}
|
|
1269
1269
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1270
1270
|
const t = blocks[i].table;
|
|
1271
|
-
if (blocks[i].type === "table" && t &&
|
|
1271
|
+
if (blocks[i].type === "table" && t && _chunk3FGHQWJPcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
1274
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1275
1275
|
if (!pageHeights) return;
|
|
1276
1276
|
for (let i = 0; i < blocks.length; i++) {
|
|
1277
1277
|
const L = blocks[i];
|
|
1278
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1278
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(L.table) || _chunk3FGHQWJPcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1279
1279
|
const ph = pageHeights.get(L.pageNumber);
|
|
1280
1280
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1281
1281
|
let s0 = i, s1 = i;
|
|
@@ -1304,8 +1304,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1304
1304
|
}
|
|
1305
1305
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1306
1306
|
const pt = prev.table, ct = curr.table;
|
|
1307
|
-
if (!
|
|
1308
|
-
const px =
|
|
1307
|
+
if (!_chunk3FGHQWJPcjs.CLIP_TABLES.has(pt) || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(ct)) return null;
|
|
1308
|
+
const px = _chunk3FGHQWJPcjs.TABLE_COLXS.get(pt), cx = _chunk3FGHQWJPcjs.TABLE_COLXS.get(ct);
|
|
1309
1309
|
if (!px || !cx) return null;
|
|
1310
1310
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1311
1311
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -1321,15 +1321,15 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1321
1321
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1322
1322
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1323
1323
|
};
|
|
1324
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1324
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunk3FGHQWJPcjs.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);
|
|
1325
1325
|
}
|
|
1326
1326
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _103 => _103.bbox, 'optionalAccess', _104 => _104.y]), lex);
|
|
1327
1327
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1328
|
-
|
|
1329
|
-
const ys =
|
|
1330
|
-
if (ys)
|
|
1331
|
-
|
|
1332
|
-
|
|
1328
|
+
_chunk3FGHQWJPcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1329
|
+
const ys = _chunk3FGHQWJPcjs.TABLE_ROWYS.get(pt);
|
|
1330
|
+
if (ys) _chunk3FGHQWJPcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1331
|
+
_chunk3FGHQWJPcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunk3FGHQWJPcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1332
|
+
_chunk3FGHQWJPcjs.CLIP_TABLES.add(res.table);
|
|
1333
1333
|
return res.table;
|
|
1334
1334
|
}
|
|
1335
1335
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
@@ -1353,12 +1353,12 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
1353
1353
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1354
1354
|
}
|
|
1355
1355
|
function pushedLead(prev, curr) {
|
|
1356
|
-
if (!
|
|
1356
|
+
if (!_chunk3FGHQWJPcjs.CLIP_TABLES.has(prev.table) || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1357
1357
|
const lead = leadRows(curr.table);
|
|
1358
1358
|
return lead.image && lead.height > prev.bbox.y;
|
|
1359
1359
|
}
|
|
1360
1360
|
function leadRows(t) {
|
|
1361
|
-
const ys =
|
|
1361
|
+
const ys = _chunk3FGHQWJPcjs.TABLE_ROWYS.get(t);
|
|
1362
1362
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1363
1363
|
const anchors = anchorsOf(t);
|
|
1364
1364
|
let end = 1, image = false;
|
|
@@ -1366,17 +1366,17 @@ function leadRows(t) {
|
|
|
1366
1366
|
for (const a of anchors) {
|
|
1367
1367
|
if (a.r !== r) continue;
|
|
1368
1368
|
end = Math.max(end, r + a.rs);
|
|
1369
|
-
if (
|
|
1369
|
+
if (_chunk3FGHQWJPcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1370
1370
|
}
|
|
1371
1371
|
}
|
|
1372
1372
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1373
1373
|
}
|
|
1374
1374
|
function tailOf(b) {
|
|
1375
|
-
const t = b.table &&
|
|
1375
|
+
const t = b.table && _chunk3FGHQWJPcjs.TABLE_TAIL.get(b.table);
|
|
1376
1376
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1377
1377
|
}
|
|
1378
1378
|
function firstRowSig(t) {
|
|
1379
|
-
const x =
|
|
1379
|
+
const x = _chunk3FGHQWJPcjs.TABLE_COLXS.get(t);
|
|
1380
1380
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1381
1381
|
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, "") }));
|
|
1382
1382
|
}
|
|
@@ -1429,7 +1429,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1429
1429
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1430
1430
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1431
1431
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1432
|
-
const px =
|
|
1432
|
+
const px = _chunk3FGHQWJPcjs.TABLE_COLXS.get(pb.table), cx = _chunk3FGHQWJPcjs.TABLE_COLXS.get(cur.table);
|
|
1433
1433
|
if (!px || !cx) break;
|
|
1434
1434
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1435
1435
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1500,7 +1500,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1500
1500
|
var COL_MATCH_TOL = 0.5;
|
|
1501
1501
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1502
1502
|
function lastRowCell(t, x1, x2) {
|
|
1503
|
-
const xs =
|
|
1503
|
+
const xs = _chunk3FGHQWJPcjs.TABLE_COLXS.get(t);
|
|
1504
1504
|
const covered = /* @__PURE__ */ new Set();
|
|
1505
1505
|
for (let r = 0; r < t.rows; r++) {
|
|
1506
1506
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -1518,7 +1518,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1518
1518
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1519
1519
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1520
1520
|
const part = blocks[j];
|
|
1521
|
-
const from = part.table ?
|
|
1521
|
+
const from = part.table ? _chunk3FGHQWJPcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1522
1522
|
if (!from || !part.table) continue;
|
|
1523
1523
|
let i = j - 1;
|
|
1524
1524
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
@@ -1530,11 +1530,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1530
1530
|
const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
|
|
1531
1531
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1532
1532
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1533
|
-
|
|
1534
|
-
const lines =
|
|
1535
|
-
if (_optionalChain([lines, 'optionalAccess', _128 => _128.length]))
|
|
1536
|
-
if (part.pageNumber && part.bbox)
|
|
1537
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _129 => _129.blocks, 'optionalAccess', _130 => _130.length]))
|
|
1533
|
+
_chunk3FGHQWJPcjs.joinCellEdges.call(void 0, cell, add);
|
|
1534
|
+
const lines = _chunk3FGHQWJPcjs.CELL_LINES.get(add);
|
|
1535
|
+
if (_optionalChain([lines, 'optionalAccess', _128 => _128.length])) _chunk3FGHQWJPcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunk3FGHQWJPcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1536
|
+
if (part.pageNumber && part.bbox) _chunk3FGHQWJPcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunk3FGHQWJPcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1537
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _129 => _129.blocks, 'optionalAccess', _130 => _130.length])) _chunk3FGHQWJPcjs.EMPTY_PARTS.delete(prev.table);
|
|
1538
1538
|
blocks.splice(j, 1);
|
|
1539
1539
|
if (cell.blocks && at > 0) {
|
|
1540
1540
|
const nextAt = cell.blocks[at];
|
|
@@ -1546,11 +1546,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1546
1546
|
}
|
|
1547
1547
|
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1548
1548
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1549
|
-
if (!_optionalChain([prev, 'optionalAccess', _131 => _131.table]) || !_optionalChain([frame, 'optionalAccess', _132 => _132.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !
|
|
1549
|
+
if (!_optionalChain([prev, 'optionalAccess', _131 => _131.table]) || !_optionalChain([frame, 'optionalAccess', _132 => _132.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1550
1550
|
const inner = _optionalChain([frame, 'access', _133 => _133.table, 'access', _134 => _134.cells, 'access', _135 => _135[0], 'optionalAccess', _136 => _136[0], 'optionalAccess', _137 => _137.blocks]);
|
|
1551
1551
|
const next = _optionalChain([inner, 'optionalAccess', _138 => _138[0]]);
|
|
1552
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _139 => _139.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
1553
|
-
const px =
|
|
1552
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _139 => _139.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(prev.table) || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1553
|
+
const px = _chunk3FGHQWJPcjs.TABLE_COLXS.get(prev.table), nx = _chunk3FGHQWJPcjs.TABLE_COLXS.get(next.table);
|
|
1554
1554
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1555
1555
|
const ph = _optionalChain([pageHeights, 'optionalAccess', _140 => _140.get, 'call', _141 => _141(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _142 => _142.get, 'call', _143 => _143(next.pageNumber)]);
|
|
1556
1556
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
@@ -1559,14 +1559,14 @@ function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
|
1559
1559
|
function fillNestedContinuation(blocks, at) {
|
|
1560
1560
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1561
1561
|
const t = _optionalChain([prev, 'optionalAccess', _144 => _144.table]), u = _optionalChain([next, 'optionalAccess', _145 => _145.table]);
|
|
1562
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1563
|
-
const xs =
|
|
1562
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(t) || !_chunk3FGHQWJPcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1563
|
+
const xs = _chunk3FGHQWJPcjs.TABLE_COLXS.get(u);
|
|
1564
1564
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1565
1565
|
const add = _optionalChain([u, 'access', _146 => _146.cells, 'access', _147 => _147[0], 'optionalAccess', _148 => _148[0]]);
|
|
1566
1566
|
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _149 => _149.blocks, 'optionalAccess', _150 => _150.length])) return;
|
|
1567
1567
|
cell.text = add.text;
|
|
1568
1568
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1569
|
-
|
|
1569
|
+
_chunk3FGHQWJPcjs.joinCellEdges.call(void 0, cell, add);
|
|
1570
1570
|
blocks.splice(at, 1);
|
|
1571
1571
|
}
|
|
1572
1572
|
|
|
@@ -1586,15 +1586,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
1586
1586
|
function marginContextBlocks(raw, page, view) {
|
|
1587
1587
|
const [x1, y1, x2, y2] = view;
|
|
1588
1588
|
const width = x2 - x1, height = y2 - y1;
|
|
1589
|
-
const items =
|
|
1589
|
+
const items = _chunk3FGHQWJPcjs.filterHiddenText.call(void 0, _chunk3FGHQWJPcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
1590
1590
|
for (const item of items) {
|
|
1591
1591
|
item.x -= x1;
|
|
1592
1592
|
item.y -= y1;
|
|
1593
1593
|
}
|
|
1594
|
-
return
|
|
1595
|
-
const bbox =
|
|
1594
|
+
return _chunk3FGHQWJPcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
1595
|
+
const bbox = _chunk3FGHQWJPcjs.computeBBox.call(void 0, line, page);
|
|
1596
1596
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
1597
|
-
return [{ type: "paragraph", text:
|
|
1597
|
+
return [{ type: "paragraph", text: _chunk3FGHQWJPcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunk3FGHQWJPcjs.dominantStyle.call(void 0, line) }];
|
|
1598
1598
|
});
|
|
1599
1599
|
}
|
|
1600
1600
|
|
|
@@ -1630,7 +1630,7 @@ var WINANSI_REVERSE = {
|
|
|
1630
1630
|
};
|
|
1631
1631
|
function symbolFontTable(fontName) {
|
|
1632
1632
|
if (!fontName) return void 0;
|
|
1633
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
1633
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunk6FW3AZWNcjs.WINGDINGS;
|
|
1634
1634
|
return void 0;
|
|
1635
1635
|
}
|
|
1636
1636
|
function remapSymbolText(text, table) {
|
|
@@ -2646,7 +2646,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
2646
2646
|
if (block.type !== "heading" || !block.text) continue;
|
|
2647
2647
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
2648
2648
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _214 => _214.style, 'optionalAccess', _215 => _215.fontSize]), () => ( 0));
|
|
2649
|
-
const tocEntry = i > 0 &&
|
|
2649
|
+
const tocEntry = i > 0 && _chunk3FGHQWJPcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunk3FGHQWJPcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
2650
2650
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
2651
2651
|
const proseStyle = _optionalChain([block, 'access', _216 => _216.style, 'optionalAccess', _217 => _217.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
2652
2652
|
const next = blocks[i + 1];
|
|
@@ -2729,7 +2729,7 @@ function splitSingleCellTables(blocks) {
|
|
|
2729
2729
|
const out = [];
|
|
2730
2730
|
for (const b of blocks) {
|
|
2731
2731
|
const t = b.type === "table" ? b.table : void 0;
|
|
2732
|
-
const title = t &&
|
|
2732
|
+
const title = t && _chunk3FGHQWJPcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
2733
2733
|
if (title) {
|
|
2734
2734
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
2735
2735
|
continue;
|
|
@@ -2765,7 +2765,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
2765
2765
|
const lines = cell.text.split("\n");
|
|
2766
2766
|
const out = [lines[0]];
|
|
2767
2767
|
for (const line of lines.slice(1)) {
|
|
2768
|
-
if (
|
|
2768
|
+
if (_chunk3FGHQWJPcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
2769
2769
|
else out.push(line);
|
|
2770
2770
|
}
|
|
2771
2771
|
cell.text = out.join("\n");
|
|
@@ -2785,10 +2785,10 @@ function cleanPdfText(text, opts) {
|
|
|
2785
2785
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
2786
2786
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
2787
2787
|
if (line.startsWith("|")) {
|
|
2788
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
2788
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunk3FGHQWJPcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
2789
2789
|
}
|
|
2790
2790
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _297 => _297.exec, 'call', _298 => _298(line), 'optionalAccess', _299 => _299[0]]), () => ( ""));
|
|
2791
|
-
return mark +
|
|
2791
|
+
return mark + _chunk3FGHQWJPcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
2792
2792
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
2793
2793
|
}
|
|
2794
2794
|
function startsWithMarker(line) {
|
|
@@ -2820,7 +2820,7 @@ function mergeKoreanLines(text) {
|
|
|
2820
2820
|
continue;
|
|
2821
2821
|
}
|
|
2822
2822
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
2823
|
-
result[result.length - 1] = prev +
|
|
2823
|
+
result[result.length - 1] = prev + _chunk3FGHQWJPcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
2824
2824
|
} else {
|
|
2825
2825
|
result.push(curr);
|
|
2826
2826
|
}
|
|
@@ -2836,7 +2836,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
2836
2836
|
const wrapped = /* @__PURE__ */ new Set();
|
|
2837
2837
|
for (const a of annots) {
|
|
2838
2838
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
2839
|
-
const url =
|
|
2839
|
+
const url = _chunkK6WSMTVUcjs.sanitizeHref.call(void 0, a.url);
|
|
2840
2840
|
if (!url) continue;
|
|
2841
2841
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
2842
2842
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -2877,7 +2877,7 @@ function mergeLinkRuns(markdown) {
|
|
|
2877
2877
|
|
|
2878
2878
|
// src/pdf/formula-ocr.ts
|
|
2879
2879
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
2880
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
2880
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-HJNQGPRC.cjs")));
|
|
2881
2881
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
2882
2882
|
await ensureFormulaModels((p) => {
|
|
2883
2883
|
if (p.phase === "download" && p.total) {
|
|
@@ -3068,13 +3068,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3068
3068
|
try {
|
|
3069
3069
|
return await Promise.race([
|
|
3070
3070
|
loadingTask.promise.catch((e) => {
|
|
3071
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
3071
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkK6WSMTVUcjs.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)");
|
|
3072
3072
|
throw e;
|
|
3073
3073
|
}),
|
|
3074
3074
|
new Promise((_, reject) => {
|
|
3075
3075
|
timer = setTimeout(() => {
|
|
3076
3076
|
loadingTask.destroy();
|
|
3077
|
-
reject(new (0,
|
|
3077
|
+
reject(new (0, _chunkK6WSMTVUcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
3078
3078
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
3079
3079
|
})
|
|
3080
3080
|
]);
|
|
@@ -3084,12 +3084,12 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3084
3084
|
}
|
|
3085
3085
|
async function parsePdfDocument(buffer, options) {
|
|
3086
3086
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _300 => _300.formulaOcr]) ? buffer : null;
|
|
3087
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _301 => _301.ocr]) === void 0 && await
|
|
3087
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _301 => _301.ocr]) === void 0 && await _chunk3FGHQWJPcjs.ocrModelsCached.call(void 0, );
|
|
3088
3088
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _302 => _302.ocr]) || autoOcr ? buffer : null;
|
|
3089
3089
|
const doc = await loadPdfWithTimeout(buffer);
|
|
3090
3090
|
try {
|
|
3091
3091
|
const pageCount = doc.numPages;
|
|
3092
|
-
if (pageCount === 0) throw new (0,
|
|
3092
|
+
if (pageCount === 0) throw new (0, _chunkK6WSMTVUcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
3093
3093
|
const metadata = { pageCount, pageMode: "layout" };
|
|
3094
3094
|
await extractPdfMetadata(doc, metadata);
|
|
3095
3095
|
const blocks = [];
|
|
@@ -3118,7 +3118,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3118
3118
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
3119
3119
|
const carry = {};
|
|
3120
3120
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
3121
|
-
const wrapLexicon = new (0,
|
|
3121
|
+
const wrapLexicon = new (0, _chunk3FGHQWJPcjs.WrapLexicon)();
|
|
3122
3122
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
3123
3123
|
const headerContext = [];
|
|
3124
3124
|
if (pageFilter && _optionalChain([options, 'optionalAccess', _305 => _305.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
@@ -3163,8 +3163,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3163
3163
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3164
3164
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3165
3165
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3166
|
-
const items =
|
|
3167
|
-
const filtered =
|
|
3166
|
+
const items = _chunk3FGHQWJPcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
3167
|
+
const filtered = _chunk3FGHQWJPcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
3168
3168
|
const joined = joinVerticalColumns(filtered.visible);
|
|
3169
3169
|
const visible = dropTabLeaderDots(joined);
|
|
3170
3170
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -3190,7 +3190,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3190
3190
|
} : rawOps;
|
|
3191
3191
|
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _312 => _312(loadedName), 'optionalAccess', _313 => _313.name]));
|
|
3192
3192
|
remapControlGlyphs(visible, differencesOf);
|
|
3193
|
-
await
|
|
3193
|
+
await _chunk3FGHQWJPcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
3194
3194
|
const faces = /* @__PURE__ */ new Map();
|
|
3195
3195
|
for (const it of visible) {
|
|
3196
3196
|
if (!it.fontName) continue;
|
|
@@ -3203,12 +3203,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3203
3203
|
it.fontName = face;
|
|
3204
3204
|
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _315 => _315(face), 'optionalAccess', _316 => _316.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
3205
3205
|
}
|
|
3206
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
3207
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
3206
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunk6FW3AZWNcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
3207
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunk6FW3AZWNcjs.escapeLiteralTags.call(void 0, it.text);
|
|
3208
3208
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
3209
3209
|
const pageArea = pageW * pageH;
|
|
3210
3210
|
if (pageArea > 0) {
|
|
3211
|
-
const imageRegions =
|
|
3211
|
+
const imageRegions = _chunk3FGHQWJPcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
3212
3212
|
let uncovered = 0;
|
|
3213
3213
|
for (const r of imageRegions) {
|
|
3214
3214
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -3234,11 +3234,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3234
3234
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
3235
3235
|
}
|
|
3236
3236
|
const marks = superscriptNoteMarks(visible);
|
|
3237
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
3237
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunk3FGHQWJPcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
3238
3238
|
const stamp = marginStamp(visible);
|
|
3239
3239
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
3240
|
-
const rightArrows = _optionalChain([options, 'optionalAccess', _317 => _317.tables]) !== false ? await
|
|
3241
|
-
const pageBlocks = orderTwoUpPage(
|
|
3240
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _317 => _317.tables]) !== false ? await _chunk3FGHQWJPcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
3241
|
+
const pageBlocks = orderTwoUpPage(_chunk3FGHQWJPcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _318 => _318.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
3242
3242
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
3243
3243
|
for (const b of pageBlocks) blocks.push(b);
|
|
3244
3244
|
try {
|
|
@@ -3264,11 +3264,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3264
3264
|
if (_optionalChain([options, 'optionalAccess', _320 => _320.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
3265
3265
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
3266
3266
|
}
|
|
3267
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
3267
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkK6WSMTVUcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
3268
3268
|
parsedPages++;
|
|
3269
3269
|
_optionalChain([options, 'optionalAccess', _321 => _321.onProgress, 'optionalCall', _322 => _322(parsedPages, totalTarget)]);
|
|
3270
3270
|
} catch (pageErr) {
|
|
3271
|
-
if (pageErr instanceof
|
|
3271
|
+
if (pageErr instanceof _chunkK6WSMTVUcjs.KordocError) throw pageErr;
|
|
3272
3272
|
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" });
|
|
3273
3273
|
} finally {
|
|
3274
3274
|
_optionalChain([loadedPage, 'optionalAccess', _323 => _323.cleanup, 'call', _324 => _324()]);
|
|
@@ -3298,11 +3298,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3298
3298
|
}
|
|
3299
3299
|
if (targets.size > 0) {
|
|
3300
3300
|
try {
|
|
3301
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3301
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-HR6CXGTX.cjs")));
|
|
3302
3302
|
const mode = typeof _optionalChain([options, 'optionalAccess', _329 => _329.ocr]) === "function" ? options.ocr : "builtin";
|
|
3303
3303
|
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _330 => _330.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _331 => _331.find, 'call', _332 => _332((q) => q.page === p), 'optionalAccess', _333 => _333.needsOcr])));
|
|
3304
3304
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _334 => _334.onProgress]), _optionalChain([options, 'optionalAccess', _335 => _335.tables]) !== false, vectorPageOps, regionPages);
|
|
3305
|
-
for (const obs of ocrPageBlocks.values())
|
|
3305
|
+
for (const obs of ocrPageBlocks.values()) _chunk6FW3AZWNcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
3306
3306
|
if (ocrPageBlocks.size > 0) {
|
|
3307
3307
|
const replacePages = /* @__PURE__ */ new Set();
|
|
3308
3308
|
for (const [p, obs] of ocrPageBlocks) {
|
|
@@ -3366,11 +3366,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3366
3366
|
}
|
|
3367
3367
|
}
|
|
3368
3368
|
if (_optionalChain([options, 'optionalAccess', _343 => _343.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
3369
|
-
const removed =
|
|
3369
|
+
const removed = _chunk3FGHQWJPcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
3370
3370
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
3371
3371
|
blocks.splice(removed[ri], 1);
|
|
3372
3372
|
}
|
|
3373
|
-
const kept =
|
|
3373
|
+
const kept = _chunk3FGHQWJPcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
3374
3374
|
if (kept !== blocks) {
|
|
3375
3375
|
blocks.length = 0;
|
|
3376
3376
|
blocks.push(...kept);
|
|
@@ -3379,12 +3379,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3379
3379
|
mergeContinuedCells(blocks, pageHeights);
|
|
3380
3380
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
3381
3381
|
if (_optionalChain([options, 'optionalAccess', _344 => _344.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
3382
|
-
const boxes =
|
|
3382
|
+
const boxes = _chunk3FGHQWJPcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
3383
3383
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
3384
3384
|
}
|
|
3385
3385
|
splitContactTables(blocks);
|
|
3386
|
-
if (!_optionalChain([options, 'optionalAccess', _345 => _345.keepTrailingEmptyCols]))
|
|
3387
|
-
|
|
3386
|
+
if (!_optionalChain([options, 'optionalAccess', _345 => _345.keepTrailingEmptyCols])) _chunk3FGHQWJPcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
3387
|
+
_chunk3FGHQWJPcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
3388
3388
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
3389
3389
|
if (_optionalChain([options, 'optionalAccess', _346 => _346.formulaOcr]) && formulaBuffer) {
|
|
3390
3390
|
try {
|
|
@@ -3396,21 +3396,21 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3396
3396
|
});
|
|
3397
3397
|
}
|
|
3398
3398
|
}
|
|
3399
|
-
const medianFontSize =
|
|
3399
|
+
const medianFontSize = _chunk3FGHQWJPcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
3400
3400
|
if (medianFontSize > 0) {
|
|
3401
|
-
|
|
3402
|
-
}
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3401
|
+
_chunk3FGHQWJPcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
3402
|
+
}
|
|
3403
|
+
_chunk3FGHQWJPcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
3404
|
+
_chunk3FGHQWJPcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
3405
|
+
_chunk3FGHQWJPcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
3406
|
+
_chunk3FGHQWJPcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
3407
|
+
_chunk3FGHQWJPcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
3408
|
+
_chunk3FGHQWJPcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
3409
|
+
_chunk3FGHQWJPcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
3410
|
+
_chunk3FGHQWJPcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
3411
3411
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3412
|
-
|
|
3413
|
-
|
|
3412
|
+
_chunk3FGHQWJPcjs.detectTableCaptions.call(void 0, blocks);
|
|
3413
|
+
_chunk3FGHQWJPcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3414
3414
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3415
3415
|
sanitizeBlockControlChars(blocks);
|
|
3416
3416
|
let outBlocks = splitSingleCellTables(blocks);
|
|
@@ -3432,17 +3432,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3432
3432
|
const shown = /* @__PURE__ */ new Map();
|
|
3433
3433
|
const markContent = (bs) => {
|
|
3434
3434
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
3435
|
-
if (
|
|
3435
|
+
if (_chunk3FGHQWJPcjs.IMAGE_CELLS.has(c)) _chunk6FW3AZWNcjs.CONTENT_CELLS.add(c);
|
|
3436
3436
|
markContent(c.blocks);
|
|
3437
3437
|
}
|
|
3438
3438
|
};
|
|
3439
3439
|
const visual = (bs) => bs.flatMap((b) => {
|
|
3440
3440
|
if (b.type !== "table") return [b];
|
|
3441
|
-
if (!hancom && b.table &&
|
|
3441
|
+
if (!hancom && b.table && _chunk3FGHQWJPcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
3442
3442
|
let v = shown.get(b);
|
|
3443
3443
|
if (!v) {
|
|
3444
3444
|
markContent([b]);
|
|
3445
|
-
shown.set(b, v =
|
|
3445
|
+
shown.set(b, v = _chunk6FW3AZWNcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _350 => _350.keepTrailingEmptyCols])));
|
|
3446
3446
|
}
|
|
3447
3447
|
return v;
|
|
3448
3448
|
});
|
|
@@ -3451,11 +3451,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3451
3451
|
blocks.length = 0;
|
|
3452
3452
|
for (const b of kept) blocks.push(b);
|
|
3453
3453
|
}
|
|
3454
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
3454
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunk6FW3AZWNcjs.blocksToMarkdown.call(void 0, bs), { keepLoneNumbers: true }));
|
|
3455
3455
|
let markdown = finishMarkdown(outBlocks);
|
|
3456
3456
|
return {
|
|
3457
3457
|
markdown,
|
|
3458
|
-
pages:
|
|
3458
|
+
pages: _chunkRQEDNI4Pcjs.blocksToPages.call(void 0, _chunk3FGHQWJPcjs.splitPageBreakWraps.call(void 0, outBlocks), finishMarkdown),
|
|
3459
3459
|
blocks,
|
|
3460
3460
|
metadata,
|
|
3461
3461
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3534,5 +3534,5 @@ function marginStamp(items) {
|
|
|
3534
3534
|
|
|
3535
3535
|
|
|
3536
3536
|
|
|
3537
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
3538
|
-
//# sourceMappingURL=parser-
|
|
3537
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunk3FGHQWJPcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunk3FGHQWJPcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunk3FGHQWJPcjs.removeHeaderFooterBlocks;
|
|
3538
|
+
//# sourceMappingURL=parser-HWAOPQYK.cjs.map
|