kordoc 4.17.2 → 4.17.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/{-2UA2JHVA.js → -SQRLFE4N.js} +11 -11
  2. package/dist/{chunk-4HRJISJF.js → chunk-4D52VUGA.js} +3 -3
  3. package/dist/{chunk-6OCKAXIS.js → chunk-6DXSRQ65.js} +2 -2
  4. package/dist/{chunk-XZA6X34R.js → chunk-7TE6TK52.js} +2 -2
  5. package/dist/{chunk-KQIYC2ZU.js → chunk-AAQR4RIX.js} +2 -2
  6. package/dist/{chunk-GPC72VSF.cjs → chunk-AFXX3YSP.cjs} +262 -171
  7. package/dist/chunk-AFXX3YSP.cjs.map +1 -0
  8. package/dist/{chunk-6DOCSYEM.cjs → chunk-AOONZC4S.cjs} +3 -3
  9. package/dist/chunk-AOONZC4S.cjs.map +1 -0
  10. package/dist/{chunk-A2W2JQ3S.js → chunk-DD6AY6EI.js} +2 -2
  11. package/dist/{chunk-KZVQK5NS.cjs → chunk-EXBZHI25.cjs} +2 -2
  12. package/dist/chunk-EXBZHI25.cjs.map +1 -0
  13. package/dist/{chunk-FGL4IGOT.js → chunk-FSCVZR4A.js} +4 -4
  14. package/dist/{chunk-HAW2VL62.cjs → chunk-GNORDND5.cjs} +12 -12
  15. package/dist/chunk-GNORDND5.cjs.map +1 -0
  16. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  17. package/dist/{chunk-GYTL6WT3.js → chunk-HQ6TM2JE.js} +3 -3
  18. package/dist/{chunk-WJLICIYV.js → chunk-HY33WBAH.js} +24 -21
  19. package/dist/{chunk-WJLICIYV.js.map → chunk-HY33WBAH.js.map} +1 -1
  20. package/dist/{chunk-O4CB7D2Q.js → chunk-IERSVUW6.js} +2 -2
  21. package/dist/chunk-J55UQC5H.cjs.map +1 -1
  22. package/dist/chunk-KIYHQQVO.cjs +170 -0
  23. package/dist/chunk-KIYHQQVO.cjs.map +1 -0
  24. package/dist/{chunk-SDRKHEVT.js → chunk-NNNRN6BY.js} +255 -164
  25. package/dist/chunk-NNNRN6BY.js.map +1 -0
  26. package/dist/{chunk-MDCTITUG.js → chunk-O5T5OIJM.js} +2 -2
  27. package/dist/{chunk-WL3BWROT.js → chunk-ODVIUG6Q.js} +22 -12
  28. package/dist/chunk-ODVIUG6Q.js.map +1 -0
  29. package/dist/{chunk-C4MVZXB5.js → chunk-P2ZPPRM7.js} +2 -2
  30. package/dist/chunk-PNXJYEOR.js +170 -0
  31. package/dist/chunk-PNXJYEOR.js.map +1 -0
  32. package/dist/{chunk-YGKC6E6A.js → chunk-PTMYCK7R.js} +2 -2
  33. package/dist/{chunk-4TSYMJDL.js → chunk-PVJFCDND.js} +38 -13
  34. package/dist/chunk-PVJFCDND.js.map +1 -0
  35. package/dist/{chunk-ZDX5PIWR.js → chunk-RCS7WXOM.js} +2 -2
  36. package/dist/{chunk-VU26WGE5.js → chunk-SSY6FQLS.js} +200 -97
  37. package/dist/chunk-SSY6FQLS.js.map +1 -0
  38. package/dist/{chunk-JY2NBFIG.js → chunk-TMHMJUYU.js} +302 -75
  39. package/dist/chunk-TMHMJUYU.js.map +1 -0
  40. package/dist/{chunk-5JZEY5IL.js → chunk-VJP7O6BL.js} +2 -2
  41. package/dist/{chunk-2XHXABCX.js → chunk-W3OY3SLY.js} +3 -3
  42. package/dist/chunk-W3OY3SLY.js.map +1 -0
  43. package/dist/{chunk-WWMKIHF7.cjs → chunk-WNF3TSV3.cjs} +129 -104
  44. package/dist/chunk-WNF3TSV3.cjs.map +1 -0
  45. package/dist/{chunk-3N272C5L.js → chunk-YBIWPCUX.js} +39 -14
  46. package/dist/chunk-YBIWPCUX.js.map +1 -0
  47. package/dist/chunks-VNSLMJQD.js +10 -0
  48. package/dist/cli.js +26 -26
  49. package/dist/{formula-5RETDCIC.cjs → formula-U37MTMBD.cjs} +9 -9
  50. package/dist/formula-U37MTMBD.cjs.map +1 -0
  51. package/dist/{formula-MBLN2DG4.js → formula-U3MJXXIL.js} +4 -4
  52. package/dist/{formula-QZZDW5GW.js → formula-WZH5CMA3.js} +3 -3
  53. package/dist/{image-ocr-EREKAS47.js → image-ocr-HYWDBN72.js} +6 -6
  54. package/dist/{image-ocr-PSPVRLB5.cjs → image-ocr-OXU55EW3.cjs} +15 -15
  55. package/dist/image-ocr-OXU55EW3.cjs.map +1 -0
  56. package/dist/{image-ocr-CJSO3QSR.js → image-ocr-V6MICC6R.js} +9 -8
  57. package/dist/{image-ocr-CJSO3QSR.js.map → image-ocr-V6MICC6R.js.map} +1 -1
  58. package/dist/index.cjs +1194 -864
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.js +531 -201
  61. package/dist/index.js.map +1 -1
  62. package/dist/mcp.js +22 -22
  63. package/dist/{model-bundle-MA4MMCRJ.js → model-bundle-AHBUQ6SD.js} +5 -5
  64. package/dist/{models-SEJ7LNSN.js → models-UF7B5LLG.js} +5 -5
  65. package/dist/page-range-QHHFTL7X.cjs.map +1 -1
  66. package/dist/{parser-M5WHRX25.js → parser-F6N6ID25.js} +22 -13
  67. package/dist/parser-F6N6ID25.js.map +1 -0
  68. package/dist/{parser-QILYPWSI.cjs → parser-IXRGUYZW.cjs} +207 -198
  69. package/dist/parser-IXRGUYZW.cjs.map +1 -0
  70. package/dist/{parser-VH3F4EQU.js → parser-T4FBG2FR.js} +23 -14
  71. package/dist/parser-T4FBG2FR.js.map +1 -0
  72. package/dist/pdf-ocr-2CITOAIG.cjs +16 -0
  73. package/dist/pdf-ocr-2CITOAIG.cjs.map +1 -0
  74. package/dist/pdf-ocr-RG2MFWBX.js +15 -0
  75. package/dist/pdf-ocr-U7Z4IUMA.js +19 -0
  76. package/dist/{profile-io-5YB627EO.js → profile-io-GM3NVLV3.js} +3 -3
  77. package/dist/{rasterize-V2XHHS2I.js → rasterize-4A3LJXTG.js} +3 -3
  78. package/dist/{redact-doc-5MK5L5IQ.js → redact-doc-SQ7C3LIG.js} +11 -11
  79. package/dist/{render-SYZMHYK6.js → render-6LTQZG4W.js} +7 -7
  80. package/dist/seal-ROSVLTRQ.js +10 -0
  81. package/dist/{setup-ZPLJENSK.js → setup-DGBJOROA.js} +3 -3
  82. package/dist/visual-6W34SFIW.js +20 -0
  83. package/dist/{watch-FNWHVKK3.js → watch-DJVJRSLE.js} +12 -12
  84. package/package.json +1 -1
  85. package/dist/chunk-2XHXABCX.js.map +0 -1
  86. package/dist/chunk-3N272C5L.js.map +0 -1
  87. package/dist/chunk-4TSYMJDL.js.map +0 -1
  88. package/dist/chunk-6DOCSYEM.cjs.map +0 -1
  89. package/dist/chunk-GPC72VSF.cjs.map +0 -1
  90. package/dist/chunk-HAW2VL62.cjs.map +0 -1
  91. package/dist/chunk-JY2NBFIG.js.map +0 -1
  92. package/dist/chunk-KZVQK5NS.cjs.map +0 -1
  93. package/dist/chunk-SDRKHEVT.js.map +0 -1
  94. package/dist/chunk-UX3HHAWH.js +0 -248
  95. package/dist/chunk-UX3HHAWH.js.map +0 -1
  96. package/dist/chunk-VU26WGE5.js.map +0 -1
  97. package/dist/chunk-WL3BWROT.js.map +0 -1
  98. package/dist/chunk-WWMKIHF7.cjs.map +0 -1
  99. package/dist/chunk-YIANW5QX.cjs +0 -248
  100. package/dist/chunk-YIANW5QX.cjs.map +0 -1
  101. package/dist/chunks-EBWJR55V.js +0 -10
  102. package/dist/formula-5RETDCIC.cjs.map +0 -1
  103. package/dist/image-ocr-PSPVRLB5.cjs.map +0 -1
  104. package/dist/parser-M5WHRX25.js.map +0 -1
  105. package/dist/parser-QILYPWSI.cjs.map +0 -1
  106. package/dist/parser-VH3F4EQU.js.map +0 -1
  107. package/dist/pdf-ocr-3SZUM3CN.cjs +0 -16
  108. package/dist/pdf-ocr-3SZUM3CN.cjs.map +0 -1
  109. package/dist/pdf-ocr-QB2TB5W5.js +0 -18
  110. package/dist/pdf-ocr-XC33L43D.js +0 -15
  111. package/dist/seal-IPKIQHYB.js +0 -10
  112. package/dist/visual-RTTGNOAE.js +0 -20
  113. /package/dist/{-2UA2JHVA.js.map → -SQRLFE4N.js.map} +0 -0
  114. /package/dist/{chunk-4HRJISJF.js.map → chunk-4D52VUGA.js.map} +0 -0
  115. /package/dist/{chunk-6OCKAXIS.js.map → chunk-6DXSRQ65.js.map} +0 -0
  116. /package/dist/{chunk-XZA6X34R.js.map → chunk-7TE6TK52.js.map} +0 -0
  117. /package/dist/{chunk-KQIYC2ZU.js.map → chunk-AAQR4RIX.js.map} +0 -0
  118. /package/dist/{chunk-A2W2JQ3S.js.map → chunk-DD6AY6EI.js.map} +0 -0
  119. /package/dist/{chunk-FGL4IGOT.js.map → chunk-FSCVZR4A.js.map} +0 -0
  120. /package/dist/{chunk-GYTL6WT3.js.map → chunk-HQ6TM2JE.js.map} +0 -0
  121. /package/dist/{chunk-O4CB7D2Q.js.map → chunk-IERSVUW6.js.map} +0 -0
  122. /package/dist/{chunk-MDCTITUG.js.map → chunk-O5T5OIJM.js.map} +0 -0
  123. /package/dist/{chunk-C4MVZXB5.js.map → chunk-P2ZPPRM7.js.map} +0 -0
  124. /package/dist/{chunk-YGKC6E6A.js.map → chunk-PTMYCK7R.js.map} +0 -0
  125. /package/dist/{chunk-ZDX5PIWR.js.map → chunk-RCS7WXOM.js.map} +0 -0
  126. /package/dist/{chunk-5JZEY5IL.js.map → chunk-VJP7O6BL.js.map} +0 -0
  127. /package/dist/{chunks-EBWJR55V.js.map → chunks-VNSLMJQD.js.map} +0 -0
  128. /package/dist/{formula-MBLN2DG4.js.map → formula-U3MJXXIL.js.map} +0 -0
  129. /package/dist/{formula-QZZDW5GW.js.map → formula-WZH5CMA3.js.map} +0 -0
  130. /package/dist/{image-ocr-EREKAS47.js.map → image-ocr-HYWDBN72.js.map} +0 -0
  131. /package/dist/{model-bundle-MA4MMCRJ.js.map → model-bundle-AHBUQ6SD.js.map} +0 -0
  132. /package/dist/{models-SEJ7LNSN.js.map → models-UF7B5LLG.js.map} +0 -0
  133. /package/dist/{pdf-ocr-QB2TB5W5.js.map → pdf-ocr-RG2MFWBX.js.map} +0 -0
  134. /package/dist/{pdf-ocr-XC33L43D.js.map → pdf-ocr-U7Z4IUMA.js.map} +0 -0
  135. /package/dist/{profile-io-5YB627EO.js.map → profile-io-GM3NVLV3.js.map} +0 -0
  136. /package/dist/{rasterize-V2XHHS2I.js.map → rasterize-4A3LJXTG.js.map} +0 -0
  137. /package/dist/{redact-doc-5MK5L5IQ.js.map → redact-doc-SQ7C3LIG.js.map} +0 -0
  138. /package/dist/{render-SYZMHYK6.js.map → render-6LTQZG4W.js.map} +0 -0
  139. /package/dist/{seal-IPKIQHYB.js.map → seal-ROSVLTRQ.js.map} +0 -0
  140. /package/dist/{setup-ZPLJENSK.js.map → setup-DGBJOROA.js.map} +0 -0
  141. /package/dist/{visual-RTTGNOAE.js.map → visual-6W34SFIW.js.map} +0 -0
  142. /package/dist/{watch-FNWHVKK3.js.map → watch-DJVJRSLE.js.map} +0 -0
@@ -4,15 +4,15 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkYIANW5QXcjs = require('./chunk-YIANW5QX.cjs');
7
+ var _chunkAFXX3YSPcjs = require('./chunk-AFXX3YSP.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunk6DOCSYEMcjs = require('./chunk-6DOCSYEM.cjs');
11
+ var _chunkAOONZC4Scjs = require('./chunk-AOONZC4S.cjs');
12
12
 
13
13
 
14
14
 
15
- var _chunkKZVQK5NScjs = require('./chunk-KZVQK5NS.cjs');
15
+ var _chunkEXBZHI25cjs = require('./chunk-EXBZHI25.cjs');
16
16
 
17
17
  // src/ocr/models.ts
18
18
  var _path = require('path');
@@ -40,10 +40,10 @@ var OCR_REC_DICT = {
40
40
  };
41
41
  var ALL_OCR_MODELS = [OCR_DET_MODEL, OCR_REC_MODEL, OCR_REC_DICT];
42
42
  function getOcrModelsDir() {
43
- return _chunk6DOCSYEMcjs.getModelsDir.call(void 0, "ppocr");
43
+ return _chunkAOONZC4Scjs.getModelsDir.call(void 0, "ppocr");
44
44
  }
45
45
  async function ensureOcrModels(onProgress) {
46
- return _chunk6DOCSYEMcjs.ensureModelsIn.call(void 0, getOcrModelsDir(), ALL_OCR_MODELS, onProgress);
46
+ return _chunkAOONZC4Scjs.ensureModelsIn.call(void 0, getOcrModelsDir(), ALL_OCR_MODELS, onProgress);
47
47
  }
48
48
  async function ocrModelsCached() {
49
49
  const dir = getOcrModelsDir();
@@ -2090,7 +2090,7 @@ function tagScripts(text, lines) {
2090
2090
  const [s, e, kind] = marks[m];
2091
2091
  out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
2092
2092
  }
2093
- return _chunkYIANW5QXcjs.tidyScriptTags.call(void 0, out);
2093
+ return _chunkAFXX3YSPcjs.tidyScriptTags.call(void 0, out);
2094
2094
  }
2095
2095
 
2096
2096
  // src/pdf/line-wrap.ts
@@ -2170,6 +2170,7 @@ var hasBatchim = (c) => {
2170
2170
  return k >= 0 && k < 11172 && k % 28 !== 0;
2171
2171
  };
2172
2172
  var CJK = /[\u3000-\u303F\u3040-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFF00-\uFFEF]/;
2173
+ var unspacedCjkBoundary = (prev, next) => CJK.test(prev.trimEnd().slice(-1)) && CJK.test(next.trimStart().charAt(0)) && !/[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(prev + next);
2173
2174
  var CLOSE_TAIL = /[’”」』)\]〉》>]+$/;
2174
2175
  var TAIL = "[.,)\u300D\u300F\u2019\u201D]*";
2175
2176
  var PARTICLE = new RegExp(`^(?:\uB2E4\\.|\uC758|\uC5D0|\uC5D0\uC11C|\uC5D0\uB294|\uC5D0\uAC8C|\uC5D0\uB3C4|\uC5D0\uC11C\uB294|\uAE4C\uC9C0|\uBD80\uD130|\uCC98\uB7FC|\uB9C8\uB2E4|\uB9CC|\uB3C4|\uB4E4|\uB4E4\uC774|\uB4E4\uC758|\uB4E4\uC740|\uB4E4\uC744|\uB4E4\uC5D0\uAC8C|\uC11C\uB294|\uC11C\uB3C4|\uB77C\uACE0|\uB77C\uBA70|\uC740|\uB294|\uC744|\uB97C|\uC73C\uB85C|\uB85C|\uC73C\uB85C\uC11C|\uB85C\uC11C|\uC73C\uB85C\uC368|\uB85C\uC368)${TAIL}$`);
@@ -2219,7 +2220,7 @@ function wrapJoiner(prevText, nextText, lex) {
2219
2220
  const prev = prevText.replace(MARKUP, "").trimEnd(), next = nextText.replace(MARKUP, "").trimStart();
2220
2221
  const a = prev[prev.length - 1], b = next[0];
2221
2222
  if (!a || !b || /[,;:!?]/.test(a) || DATE_DAY_END.test(prev) && b !== "(") return " ";
2222
- if (CJK.test(a) && CJK.test(b) && !/[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(prev + next)) return "";
2223
+ if (unspacedCjkBoundary(prev, next)) return "";
2223
2224
  let s = prev.length;
2224
2225
  while (s > 0 && !/\s/.test(prev[s - 1])) s--;
2225
2226
  const left = prev.slice(s), right = next.match(/^\S+/)[0];
@@ -2262,17 +2263,32 @@ function joinPageBreakWraps(blocks, lex) {
2262
2263
  }
2263
2264
  }
2264
2265
  var HANGING = /[,。、:;!?)」』】〕》〉.]\s*$/;
2266
+ var MULTI_LEVEL_NUMBER = /^\d{1,2}(?:\.\d{1,3})+\.?\s/;
2265
2267
  var BODY_FULL_TOL = 0.25;
2266
2268
  var BODY_MIN_WIDTH_EM = 12;
2267
2269
  var BODY_MAX_PITCH_EM = 2;
2268
2270
  var BODY_PITCH_REL = 1.05;
2269
2271
  var BODY_MAX_PITCH_ABS_EM = 3.5;
2270
2272
  function bodyLineJoins(lines, lex) {
2273
+ lines = lines.map((l) => {
2274
+ const text = l.text.replace(MARKUP, "");
2275
+ return text === l.text ? l : { ...l, text };
2276
+ });
2271
2277
  let right = -Infinity;
2272
2278
  for (const l of lines) if (l.right > right) right = l.right;
2273
2279
  let inner = -Infinity;
2274
2280
  for (const l of lines) if (!HANGING.test(l.text) && l.right > inner) inner = l.right;
2275
2281
  const full = (l) => right - l.right < BODY_FULL_TOL * l.fontSize || right - inner <= 1.2 * l.fontSize && inner - l.right < BODY_FULL_TOL * l.fontSize;
2282
+ const nextWordNoRoom = (a, b) => {
2283
+ const w = _optionalChain([b, 'access', _56 => _56.text, 'access', _57 => _57.trim, 'call', _58 => _58(), 'access', _59 => _59.match, 'call', _60 => _60(/^\S+/), 'optionalAccess', _61 => _61[0]]);
2284
+ const n = [...b.text.trim()].length;
2285
+ if (!w || n === 0) return false;
2286
+ const em = (b.right - b.left) / n;
2287
+ const advance = unspacedCjkBoundary(a.text, b.text) ? 1 : [...w].length + 1;
2288
+ return right - a.right < advance * em;
2289
+ };
2290
+ const candidates = lines.filter((l, i) => full(l) || i + 1 < lines.length && nextWordNoRoom(l, lines[i + 1]));
2291
+ const ragged = candidates.filter(full).length * 2 < candidates.length;
2276
2292
  const pitch = (k) => lines[k].y - lines[k + 1].y;
2277
2293
  const sameSize = (k) => Math.abs(lines[k + 1].fontSize - lines[k].fontSize) <= 0.15 * lines[k].fontSize;
2278
2294
  let p1 = Infinity, p2 = Infinity, i1 = -1;
@@ -2291,8 +2307,9 @@ function bodyLineJoins(lines, lex) {
2291
2307
  const fs = a.fontSize;
2292
2308
  const others = i === i1 ? p2 : p1;
2293
2309
  const maxPitch = Number.isFinite(others) ? Math.min(BODY_MAX_PITCH_ABS_EM * fs, Math.max(BODY_MAX_PITCH_EM * fs, others * BODY_PITCH_REL)) : BODY_MAX_PITCH_EM * fs;
2294
- const wraps = fs > 0 && full(a) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && a.y - b.y < maxPitch && Math.abs(b.fontSize - fs) <= 0.15 * fs && !startsNewItem(a.text, b.text);
2295
- out.push(wraps ? wrapJoiner(a.text, b.text, lex) : "\n");
2310
+ const wordWrap = ragged && !full(a) && nextWordNoRoom(a, b) && !MULTI_LEVEL_NUMBER.test(b.text.trimStart());
2311
+ const wraps = fs > 0 && (full(a) || wordWrap) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && a.y - b.y < maxPitch && Math.abs(b.fontSize - fs) <= 0.15 * fs && !startsNewItem(a.text, b.text);
2312
+ out.push(!wraps ? "\n" : wordWrap ? unspacedCjkBoundary(a.text, b.text) ? "" : " " : wrapJoiner(a.text, b.text, lex));
2296
2313
  }
2297
2314
  return out;
2298
2315
  }
@@ -2439,7 +2456,7 @@ function cellTextToString(items, wrap) {
2439
2456
  const merged = mergeSuperscriptRows(lines).map((line) => sortLineByX(line));
2440
2457
  const textLines = merged.map((s) => {
2441
2458
  if (s.length === 1) return s[0].text;
2442
- if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _56 => _56.lex]) && (wrap.lex.isWord(s[0].text + s[1].text) || wrap.lex.evidence(s[0].text, s[1].text) === "" || REGION_LABELS.has(s[0].text + s[1].text)) && s[1].x - (s[0].x + s[0].w) >= Math.max(s[0].fontSize, s[1].fontSize) * 1.5 && s[1].x + s[1].w - s[0].x >= wrap.box.x2 - wrap.box.x1 - Math.max(s[0].fontSize, s[1].fontSize) * 2) return s[0].text + s[1].text;
2459
+ if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _62 => _62.lex]) && (wrap.lex.isWord(s[0].text + s[1].text) || wrap.lex.evidence(s[0].text, s[1].text) === "" || REGION_LABELS.has(s[0].text + s[1].text)) && s[1].x - (s[0].x + s[0].w) >= Math.max(s[0].fontSize, s[1].fontSize) * 1.5 && s[1].x + s[1].w - s[0].x >= wrap.box.x2 - wrap.box.x1 - Math.max(s[0].fontSize, s[1].fontSize) * 2) return s[0].text + s[1].text;
2443
2460
  const evenSpaced = detectEvenSpacedItems(s, true);
2444
2461
  let result = s[0].text;
2445
2462
  for (let j = 1; j < s.length; j++) {
@@ -2587,7 +2604,7 @@ function mergeCellTextLines(textLines, wrap) {
2587
2604
  merged[merged.length - 1] = prev + curr.trim();
2588
2605
  } else if (!wrap && /[,(]$/.test(prev.trim()) && curr.trim().length <= 15) {
2589
2606
  merged[merged.length - 1] = prev + curr.trim();
2590
- } else if (/[\d,]$/.test(prev) && /^[\d,]+[)\]]?$/.test(curr.trim()) && curr.trim().length <= 10 && !(/\d,\d{3}$/.test(prev) && /^\d/.test(curr.trim())) && !(/(?:^|[^\d,])\d{1,3}$/.test(prev) && /^(\d{1,3}(,\d{3})+|\d{1,3})$/.test(curr.trim()) && !_optionalChain([wrap, 'optionalAccess', _57 => _57.wraps, 'access', _58 => _58[i - 1]])) && !(/(?:^|\s)\d{1,7}$/.test(prev) && /^\d{1,7}$/.test(curr.trim()) && !_optionalChain([wrap, 'optionalAccess', _59 => _59.wraps, 'access', _60 => _60[i - 1]]))) {
2607
+ } else if (/[\d,]$/.test(prev) && /^[\d,]+[)\]]?$/.test(curr.trim()) && curr.trim().length <= 10 && !(/\d,\d{3}$/.test(prev) && /^\d/.test(curr.trim())) && !(/(?:^|[^\d,])\d{1,3}$/.test(prev) && /^(\d{1,3}(,\d{3})+|\d{1,3})$/.test(curr.trim()) && !_optionalChain([wrap, 'optionalAccess', _63 => _63.wraps, 'access', _64 => _64[i - 1]])) && !(/(?:^|\s)\d{1,7}$/.test(prev) && /^\d{1,7}$/.test(curr.trim()) && !_optionalChain([wrap, 'optionalAccess', _65 => _65.wraps, 'access', _66 => _66[i - 1]]))) {
2591
2608
  merged[merged.length - 1] = prev + curr.trim();
2592
2609
  } else {
2593
2610
  merged.push(curr);
@@ -2657,7 +2674,7 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs) {
2657
2674
  if (numRows > MAX_UNDERSEGMENTED_ROWS || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
2658
2675
  if (items.length === 0) return null;
2659
2676
  if (numRows >= 3) {
2660
- if (_optionalChain([rowYs, 'optionalAccess', _61 => _61.length]) !== numRows + 1) return null;
2677
+ if (_optionalChain([rowYs, 'optionalAccess', _67 => _67.length]) !== numRows + 1) return null;
2661
2678
  const rebuilt2 = [];
2662
2679
  let expanded = 0;
2663
2680
  for (let r = 0; r < numRows; r++) {
@@ -2810,7 +2827,7 @@ function dominantStyle(items) {
2810
2827
  let maxCount = 0, dominantSize = 0;
2811
2828
  for (const i of items) {
2812
2829
  if (i.fontSize <= 0) continue;
2813
- const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _62 => _62.text, 'access', _63 => _63.match, 'call', _64 => _64(/[\p{L}\p{N}]/gu), 'optionalAccess', _65 => _65.length]), () => ( 0)));
2830
+ const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _68 => _68.text, 'access', _69 => _69.match, 'call', _70 => _70(/[\p{L}\p{N}]/gu), 'optionalAccess', _71 => _71.length]), () => ( 0)));
2814
2831
  freq.set(i.fontSize, count);
2815
2832
  if (count > maxCount) {
2816
2833
  maxCount = count;
@@ -2818,7 +2835,7 @@ function dominantStyle(items) {
2818
2835
  }
2819
2836
  }
2820
2837
  if (dominantSize === 0) return void 0;
2821
- const fontName = _optionalChain([items, 'access', _66 => _66.find, 'call', _67 => _67((i) => i.fontSize === dominantSize), 'optionalAccess', _68 => _68.fontName]) || void 0;
2838
+ const fontName = _optionalChain([items, 'access', _72 => _72.find, 'call', _73 => _73((i) => i.fontSize === dominantSize), 'optionalAccess', _74 => _74.fontName]) || void 0;
2822
2839
  return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
2823
2840
  }
2824
2841
  function normalizeItems(rawItems) {
@@ -2938,7 +2955,7 @@ function splitAroundOverlays(c, overlays) {
2938
2955
  const ov = overlays.filter((o) => {
2939
2956
  for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
2940
2957
  const prefix = c.text.slice(0, at);
2941
- const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _69 => _69.match, 'call', _70 => _70(/\s+/g), 'optionalAccess', _71 => _71.length]), () => ( 0))) * ws;
2958
+ const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _75 => _75.match, 'call', _76 => _76(/\s+/g), 'optionalAccess', _77 => _77.length]), () => ( 0))) * ws;
2942
2959
  if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
2943
2960
  }
2944
2961
  return true;
@@ -3058,7 +3075,7 @@ function mergeSuperscriptLines(lines) {
3058
3075
  return result;
3059
3076
  }
3060
3077
  function mergeLineSimple(items) {
3061
- if (items.length <= 1) return _optionalChain([items, 'access', _72 => _72[0], 'optionalAccess', _73 => _73.text]) || "";
3078
+ if (items.length <= 1) return _optionalChain([items, 'access', _78 => _78[0], 'optionalAccess', _79 => _79.text]) || "";
3062
3079
  const sorted = sortLineByX([...items]);
3063
3080
  const isEvenSpaced = detectEvenSpacedItems(sorted);
3064
3081
  let result = sorted[0].text;
@@ -3203,7 +3220,7 @@ function splitTrailingColumnRegion(items) {
3203
3220
  }
3204
3221
  function panelBlocks(items, panel, pageNum) {
3205
3222
  const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
3206
- const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _74 => _74(line), 'optionalAccess', _75 => _75.fontName]), () => ( ""));
3223
+ const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _80 => _80(line), 'optionalAccess', _81 => _81.fontName]), () => ( ""));
3207
3224
  const runs = [];
3208
3225
  for (const line of lines) {
3209
3226
  const last = runs[runs.length - 1];
@@ -3233,7 +3250,7 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
3233
3250
  const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
3234
3251
  const geo = lines.map((l) => {
3235
3252
  const b = computeBBox(l.items, pageNum);
3236
- return { text: l.text, left: b.x, right: b.x + b.width, y: l.items.reduce((s, i) => s + i.y, 0) / l.items.length, fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _76 => _76(l.items), 'optionalAccess', _77 => _77.fontSize]), () => ( 0)) };
3253
+ return { text: l.text, left: b.x, right: b.x + b.width, y: l.items.reduce((s, i) => s + i.y, 0) / l.items.length, fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _82 => _82(l.items), 'optionalAccess', _83 => _83.fontSize]), () => ( 0)) };
3237
3254
  });
3238
3255
  const joins = bodyLineJoins(geo, lex);
3239
3256
  for (let i = 0; i + 1 < geo.length; i++) {
@@ -3280,15 +3297,15 @@ function computeMedianFontSizeFromFreq(freq) {
3280
3297
  function detectHeadings(blocks, medianFontSize) {
3281
3298
  for (let bi = 0; bi < blocks.length; bi++) {
3282
3299
  const block = blocks[bi];
3283
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _78 => _78.style, 'optionalAccess', _79 => _79.fontSize])) continue;
3300
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _84 => _84.style, 'optionalAccess', _85 => _85.fontSize])) continue;
3284
3301
  const text = block.text.trim();
3285
3302
  if (text.length === 0 || text.length > 200) continue;
3286
3303
  if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
3287
3304
  const ratio = block.style.fontSize / medianFontSize;
3288
3305
  let level = 0;
3289
- if (ratio >= _chunkYIANW5QXcjs.HEADING_RATIO_H1) level = 1;
3290
- else if (ratio >= _chunkYIANW5QXcjs.HEADING_RATIO_H2) level = 2;
3291
- else if (ratio >= _chunkYIANW5QXcjs.HEADING_RATIO_H3) level = 3;
3306
+ if (ratio >= _chunkAFXX3YSPcjs.HEADING_RATIO_H1) level = 1;
3307
+ else if (ratio >= _chunkAFXX3YSPcjs.HEADING_RATIO_H2) level = 2;
3308
+ else if (ratio >= _chunkAFXX3YSPcjs.HEADING_RATIO_H3) level = 3;
3292
3309
  if (level > 0) {
3293
3310
  block.type = "heading";
3294
3311
  block.level = level;
@@ -3297,21 +3314,21 @@ function detectHeadings(blocks, medianFontSize) {
3297
3314
  }
3298
3315
  }
3299
3316
  function isChapterNumber(block, next, medianFontSize) {
3300
- const size = _nullishCoalesce(_optionalChain([block, 'access', _80 => _80.style, 'optionalAccess', _81 => _81.fontSize]), () => ( 0));
3301
- const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _82 => _82.style, 'optionalAccess', _83 => _83.fontSize]), () => ( 0));
3302
- const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _84 => _84.text, 'optionalAccess', _85 => _85.trim, 'call', _86 => _86()]), () => ( ""));
3303
- const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _87 => _87.bbox]);
3304
- return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _88 => _88.text, 'optionalAccess', _89 => _89.trim, 'call', _90 => _90()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkYIANW5QXcjs.HEADING_RATIO_H1 && text.length > 0 && text.length <= 80 && !/^[\d\s.]+$/.test(text) && !!a && !!b && a.y > b.y && a.y - (b.y + b.height) <= size * 2;
3317
+ const size = _nullishCoalesce(_optionalChain([block, 'access', _86 => _86.style, 'optionalAccess', _87 => _87.fontSize]), () => ( 0));
3318
+ const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _88 => _88.style, 'optionalAccess', _89 => _89.fontSize]), () => ( 0));
3319
+ const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _90 => _90.text, 'optionalAccess', _91 => _91.trim, 'call', _92 => _92()]), () => ( ""));
3320
+ const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _93 => _93.bbox]);
3321
+ return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _94 => _94.text, 'optionalAccess', _95 => _95.trim, 'call', _96 => _96()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkAFXX3YSPcjs.HEADING_RATIO_H1 && text.length > 0 && text.length <= 80 && !/^[\d\s.]+$/.test(text) && !!a && !!b && a.y > b.y && a.y - (b.y + b.height) <= size * 2;
3305
3322
  }
3306
3323
  function mergeStackedHeadingLines(blocks, medianFontSize) {
3307
3324
  for (let i = 0; i < blocks.length - 1; ) {
3308
3325
  const a = blocks[i], b = blocks[i + 1];
3309
3326
  const ab = a.bbox, bb = b.bbox;
3310
- const af = _nullishCoalesce(_optionalChain([a, 'access', _91 => _91.style, 'optionalAccess', _92 => _92.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _93 => _93.style, 'optionalAccess', _94 => _94.fontSize]), () => ( 0));
3327
+ const af = _nullishCoalesce(_optionalChain([a, 'access', _97 => _97.style, 'optionalAccess', _98 => _98.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _99 => _99.style, 'optionalAccess', _100 => _100.fontSize]), () => ( 0));
3311
3328
  const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
3312
- const centered = ab && bb && _optionalChain([a, 'access', _95 => _95.style, 'optionalAccess', _96 => _96.fontName]) === _optionalChain([b, 'access', _97 => _97.style, 'optionalAccess', _98 => _98.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
3329
+ const centered = ab && bb && _optionalChain([a, 'access', _101 => _101.style, 'optionalAccess', _102 => _102.fontName]) === _optionalChain([b, 'access', _103 => _103.style, 'optionalAccess', _104 => _104.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
3313
3330
  const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
3314
- const wrapped = sameAnchor && _optionalChain([a, 'access', _99 => _99.style, 'optionalAccess', _100 => _100.fontName]) === _optionalChain([b, 'access', _101 => _101.style, 'optionalAccess', _102 => _102.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _103 => _103.text, 'optionalAccess', _104 => _104.trim, 'call', _105 => _105(), 'access', _106 => _106.split, 'call', _107 => _107(/\s+/), 'access', _108 => _108.length]), () => ( 0))) >= 3;
3331
+ const wrapped = sameAnchor && _optionalChain([a, 'access', _105 => _105.style, 'optionalAccess', _106 => _106.fontName]) === _optionalChain([b, 'access', _107 => _107.style, 'optionalAccess', _108 => _108.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _109 => _109.text, 'optionalAccess', _110 => _110.trim, 'call', _111 => _111(), 'access', _112 => _112.split, 'call', _113 => _113(/\s+/), 'access', _114 => _114.length]), () => ( 0))) >= 3;
3315
3332
  const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
3316
3333
  if (a.type !== "heading" || b.type !== "heading" || !a.text || !b.text || /^\d+$/.test(a.text.trim()) || !ab || !bb || ab.page !== bb.page || !(sameAnchor && af >= medianFontSize * 2 && bf >= medianFontSize * 2) && !wrapped && !(centered && af >= medianFontSize * 1.25 && bf >= medianFontSize * 1.25) || Math.abs(af - bf) > Math.max(af, bf) * 0.15 && !displayStack || gap < -2 || gap > Math.max(af, bf) * 0.45 || a.text.length > (centered ? 120 : 50) || b.text.length > (centered ? 120 : 50)) {
3317
3334
  i++;
@@ -3340,22 +3357,25 @@ function detectTypographyHeadings(blocks) {
3340
3357
  if (page.some((block) => block.type === "heading")) continue;
3341
3358
  const faceWeight = /* @__PURE__ */ new Map();
3342
3359
  for (const block of page) {
3343
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _109 => _109.style, 'optionalAccess', _110 => _110.fontName])) continue;
3344
- const face = block.style.fontName;
3345
- faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + block.text.length);
3360
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _115 => _115.style, 'optionalAccess', _116 => _116.fontName])) continue;
3361
+ const faces = FACE_CHARS.get(block);
3362
+ if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
3363
+ else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
3346
3364
  }
3347
- const bodyFace = _optionalChain([[...faceWeight], 'access', _111 => _111.sort, 'call', _112 => _112((a, b) => b[1] - a[1]), 'access', _113 => _113[0], 'optionalAccess', _114 => _114[0]]);
3365
+ const bodyFace = _optionalChain([[...faceWeight], 'access', _117 => _117.sort, 'call', _118 => _118((a, b) => b[1] - a[1]), 'access', _119 => _119[0], 'optionalAccess', _120 => _120[0]]);
3348
3366
  if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
3349
3367
  const sizeWeight = /* @__PURE__ */ new Map();
3350
3368
  for (const block of page) {
3351
- if (block.type !== "paragraph" || _optionalChain([block, 'access', _115 => _115.style, 'optionalAccess', _116 => _116.fontName]) !== bodyFace || !block.style.fontSize) continue;
3352
- sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + block.text.length);
3369
+ if (block.type !== "paragraph" || !_optionalChain([block, 'access', _121 => _121.style, 'optionalAccess', _122 => _122.fontSize])) continue;
3370
+ const faces = FACE_CHARS.get(block);
3371
+ const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _123 => _123.text, 'optionalAccess', _124 => _124.length]), () => ( 0)) : 0;
3372
+ if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
3353
3373
  }
3354
- const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _117 => _117.sort, 'call', _118 => _118((a, b) => b[1] - a[1]), 'access', _119 => _119[0], 'optionalAccess', _120 => _120[0]]), () => ( 0));
3374
+ const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _125 => _125.sort, 'call', _126 => _126((a, b) => b[1] - a[1]), 'access', _127 => _127[0], 'optionalAccess', _128 => _128[0]]), () => ( 0));
3355
3375
  for (let i = 0; i < page.length; i++) {
3356
3376
  const block = page[i];
3357
3377
  const { text, bbox, style } = block;
3358
- if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _121 => _121.fontName]) || !style.fontSize) continue;
3378
+ if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _129 => _129.fontName]) || !style.fontSize) continue;
3359
3379
  const title = text.trim();
3360
3380
  const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
3361
3381
  const faces = FACE_CHARS.get(block);
@@ -3385,16 +3405,16 @@ function detectDocumentStyleHeadings(blocks) {
3385
3405
  for (const page of byPage.values()) {
3386
3406
  const faceChars = /* @__PURE__ */ new Map();
3387
3407
  for (const block of page) {
3388
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _122 => _122.style, 'optionalAccess', _123 => _123.fontName])) continue;
3408
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _130 => _130.style, 'optionalAccess', _131 => _131.fontName])) continue;
3389
3409
  faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
3390
3410
  }
3391
- const bodyFace = _optionalChain([[...faceChars], 'access', _124 => _124.sort, 'call', _125 => _125((a, b) => b[1] - a[1]), 'access', _126 => _126[0], 'optionalAccess', _127 => _127[0]]);
3411
+ const bodyFace = _optionalChain([[...faceChars], 'access', _132 => _132.sort, 'call', _133 => _133((a, b) => b[1] - a[1]), 'access', _134 => _134[0], 'optionalAccess', _135 => _135[0]]);
3392
3412
  if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
3393
- const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _128 => _128.style, 'optionalAccess', _129 => _129.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
3413
+ const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _136 => _136.style, 'optionalAccess', _137 => _137.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
3394
3414
  for (const label of labels) {
3395
- const peers = labels.filter((b) => _optionalChain([b, 'access', _130 => _130.style, 'optionalAccess', _131 => _131.fontName]) === _optionalChain([label, 'access', _132 => _132.style, 'optionalAccess', _133 => _133.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
3415
+ const peers = labels.filter((b) => _optionalChain([b, 'access', _138 => _138.style, 'optionalAccess', _139 => _139.fontName]) === _optionalChain([label, 'access', _140 => _140.style, 'optionalAccess', _141 => _141.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
3396
3416
  if (peers.length < 2) continue;
3397
- const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _134 => _134.style, 'optionalAccess', _135 => _135.fontName]) !== _optionalChain([label, 'access', _136 => _136.style, 'optionalAccess', _137 => _137.fontName]) && b.bbox.x >= label.bbox.x - 5 && b.bbox.x <= label.bbox.x + 20 && b.bbox.y < label.bbox.y && label.bbox.y - (b.bbox.y + b.bbox.height) <= 60);
3417
+ const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _142 => _142.style, 'optionalAccess', _143 => _143.fontName]) !== _optionalChain([label, 'access', _144 => _144.style, 'optionalAccess', _145 => _145.fontName]) && b.bbox.x >= label.bbox.x - 5 && b.bbox.x <= label.bbox.x + 20 && b.bbox.y < label.bbox.y && label.bbox.y - (b.bbox.y + b.bbox.height) <= 60);
3398
3418
  if (value) {
3399
3419
  label.type = "heading";
3400
3420
  label.level = 2;
@@ -3403,7 +3423,7 @@ function detectDocumentStyleHeadings(blocks) {
3403
3423
  const first = page.find((b) => b.type !== "image" && b.type !== "separator");
3404
3424
  const second = page[page.indexOf(first) + 1];
3405
3425
  const third = page[page.indexOf(first) + 2];
3406
- if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _138 => _138.style, 'optionalAccess', _139 => _139.fontName]) || !_optionalChain([second, 'access', _140 => _140.style, 'optionalAccess', _141 => _141.fontName]) || !/^\d+(?:\.\d+)*\.\s+/.test(first.text.trim()) || first.style.fontName === bodyFace || second.style.fontName === bodyFace || first.text.length + second.text.length > 140 || Math.abs(first.bbox.x - second.bbox.x) > 30 || first.bbox.y - (second.bbox.y + second.bbox.height) > (_nullishCoalesce(first.style.fontSize, () => ( 0))) * 1.5 || _optionalChain([third, 'access', _142 => _142.style, 'optionalAccess', _143 => _143.fontName]) !== bodyFace) continue;
3426
+ if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _146 => _146.style, 'optionalAccess', _147 => _147.fontName]) || !_optionalChain([second, 'access', _148 => _148.style, 'optionalAccess', _149 => _149.fontName]) || !/^\d+(?:\.\d+)*\.\s+/.test(first.text.trim()) || first.style.fontName === bodyFace || second.style.fontName === bodyFace || first.text.length + second.text.length > 140 || Math.abs(first.bbox.x - second.bbox.x) > 30 || first.bbox.y - (second.bbox.y + second.bbox.height) > (_nullishCoalesce(first.style.fontSize, () => ( 0))) * 1.5 || _optionalChain([third, 'access', _150 => _150.style, 'optionalAccess', _151 => _151.fontName]) !== bodyFace) continue;
3407
3427
  first.type = "heading";
3408
3428
  first.level = 1;
3409
3429
  first.text = `${first.text.trim()} ${second.text.trim()}`;
@@ -3427,18 +3447,18 @@ function detectSiblingStyleHeadings(blocks) {
3427
3447
  for (const page of byPage.values()) {
3428
3448
  const bodyChars = /* @__PURE__ */ new Map();
3429
3449
  for (const block of page) {
3430
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _144 => _144.style, 'optionalAccess', _145 => _145.fontName])) continue;
3450
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _152 => _152.style, 'optionalAccess', _153 => _153.fontName])) continue;
3431
3451
  const face = block.style.fontName;
3432
3452
  bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
3433
3453
  }
3434
- const bodyFace = _optionalChain([[...bodyChars], 'access', _146 => _146.sort, 'call', _147 => _147((a, b) => b[1] - a[1]), 'access', _148 => _148[0], 'optionalAccess', _149 => _149[0]]);
3435
- const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _150 => _150.style, 'optionalAccess', _151 => _151.fontName]) && b.style.fontName !== bodyFace);
3454
+ const bodyFace = _optionalChain([[...bodyChars], 'access', _154 => _154.sort, 'call', _155 => _155((a, b) => b[1] - a[1]), 'access', _156 => _156[0], 'optionalAccess', _157 => _157[0]]);
3455
+ const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _158 => _158.style, 'optionalAccess', _159 => _159.fontName]) && b.style.fontName !== bodyFace);
3436
3456
  for (const anchor of anchors) {
3437
3457
  const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
3438
3458
  const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
3439
- const peers = anchors.filter((b) => _optionalChain([b, 'access', _152 => _152.style, 'optionalAccess', _153 => _153.fontName]) === _optionalChain([anchor, 'access', _154 => _154.style, 'optionalAccess', _155 => _155.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _156 => _156.style, 'optionalAccess', _157 => _157.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _158 => _158.style, 'optionalAccess', _159 => _159.fontSize]), () => ( 0)))) < 0.5);
3459
+ const peers = anchors.filter((b) => _optionalChain([b, 'access', _160 => _160.style, 'optionalAccess', _161 => _161.fontName]) === _optionalChain([anchor, 'access', _162 => _162.style, 'optionalAccess', _163 => _163.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _164 => _164.style, 'optionalAccess', _165 => _165.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _166 => _166.style, 'optionalAccess', _167 => _167.fontSize]), () => ( 0)))) < 0.5);
3440
3460
  if (peers.length < 2 && !numbered && !lettered) continue;
3441
- const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _160 => _160.style, 'optionalAccess', _161 => _161.fontName]) === _optionalChain([anchor, 'access', _162 => _162.style, 'optionalAccess', _163 => _163.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _164 => _164.style, 'optionalAccess', _165 => _165.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _166 => _166.style, 'optionalAccess', _167 => _167.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _168 => _168.style, 'optionalAccess', _169 => _169.fontSize]), () => ( 0))) * 1.6 && /^[A-Z]/.test(b.text.trim()) && !/[.!?:;,]$/.test(b.text.trim()) && !/^(?:Table|Figure|Fig\.?|Appendix)\s+\d/i.test(b.text.trim()));
3461
+ const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _168 => _168.style, 'optionalAccess', _169 => _169.fontName]) === _optionalChain([anchor, 'access', _170 => _170.style, 'optionalAccess', _171 => _171.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _172 => _172.style, 'optionalAccess', _173 => _173.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _174 => _174.style, 'optionalAccess', _175 => _175.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _176 => _176.style, 'optionalAccess', _177 => _177.fontSize]), () => ( 0))) * 1.6 && /^[A-Z]/.test(b.text.trim()) && !/[.!?:;,]$/.test(b.text.trim()) && !/^(?:Table|Figure|Fig\.?|Appendix)\s+\d/i.test(b.text.trim()));
3442
3462
  const siblings = candidates.filter((b) => numbered ? new RegExp(`^${numbered[1]}\\.\\d+\\s+`).test(b.text.trim()) : lettered ? /^[A-Z]\s+/.test(b.text.trim()) && Math.abs(anchor.bbox.x - b.bbox.x) < 8 : peers.some((h) => h.bbox && Math.abs(h.bbox.x - b.bbox.x) < 8));
3443
3463
  if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
3444
3464
  for (const sibling of siblings) {
@@ -3457,11 +3477,13 @@ function detectRepeatedPageLabels(blocks) {
3457
3477
  }
3458
3478
  for (const page of byPage.values()) {
3459
3479
  const bodyChars = /* @__PURE__ */ new Map();
3460
- for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _170 => _170.style, 'optionalAccess', _171 => _171.fontName])) {
3461
- bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
3480
+ for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _178 => _178.style, 'optionalAccess', _179 => _179.fontName])) {
3481
+ const faces = FACE_CHARS.get(b);
3482
+ if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
3483
+ else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
3462
3484
  }
3463
- const bodyFace = _optionalChain([[...bodyChars], 'access', _172 => _172.sort, 'call', _173 => _173((a, b) => b[1] - a[1]), 'access', _174 => _174[0], 'optionalAccess', _175 => _175[0]]);
3464
- const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _176 => _176.style, 'optionalAccess', _177 => _177.fontName]) && b.style.fontName !== bodyFace && b.bbox.height <= (_nullishCoalesce(b.style.fontSize, () => ( 0))) * 1.6 && b.text.trim().length >= 5 && b.text.trim().length <= 80);
3485
+ const bodyFace = _optionalChain([[...bodyChars], 'access', _180 => _180.sort, 'call', _181 => _181((a, b) => b[1] - a[1]), 'access', _182 => _182[0], 'optionalAccess', _183 => _183[0]]);
3486
+ const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _184 => _184.style, 'optionalAccess', _185 => _185.fontName]) && b.style.fontName !== bodyFace && b.bbox.height <= (_nullishCoalesce(b.style.fontSize, () => ( 0))) * 1.6 && b.text.trim().length >= 5 && b.text.trim().length <= 80);
3465
3487
  const groups = /* @__PURE__ */ new Map();
3466
3488
  for (const b of candidates) {
3467
3489
  const key = `${b.style.fontName}:${b.style.fontSize}`;
@@ -3497,19 +3519,19 @@ function detectPageLeadHeadings(blocks) {
3497
3519
  for (const page of byPage.values()) {
3498
3520
  const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
3499
3521
  const [first, second, third] = content;
3500
- if (!_optionalChain([first, 'optionalAccess', _178 => _178.bbox]) || !first.text || !_optionalChain([first, 'access', _179 => _179.style, 'optionalAccess', _180 => _180.fontSize]) || !second) continue;
3522
+ if (!_optionalChain([first, 'optionalAccess', _186 => _186.bbox]) || !first.text || !_optionalChain([first, 'access', _187 => _187.style, 'optionalAccess', _188 => _188.fontSize]) || !second) continue;
3501
3523
  const firstText = first.text.trim();
3502
3524
  const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
3503
3525
  const hasImage = page.some((b) => b.type === "image");
3504
- const firstIsTitle = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 1.6 && (/^(?:CONTENTS|Table of Contents)$/i.test(firstText) || hasImage && /^[A-Z]/.test(firstText) && !captionLike.test(firstText) && second.type === "paragraph" && /^[A-Z]/.test(_nullishCoalesce(_optionalChain([second, 'access', _181 => _181.text, 'optionalAccess', _182 => _182.trim, 'call', _183 => _183()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _184 => _184.text, 'optionalAccess', _185 => _185.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
3526
+ const firstIsTitle = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 1.6 && (/^(?:CONTENTS|Table of Contents)$/i.test(firstText) || hasImage && /^[A-Z]/.test(firstText) && !captionLike.test(firstText) && second.type === "paragraph" && /^[A-Z]/.test(_nullishCoalesce(_optionalChain([second, 'access', _189 => _189.text, 'optionalAccess', _190 => _190.trim, 'call', _191 => _191()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _192 => _192.text, 'optionalAccess', _193 => _193.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
3505
3527
  const firstAboveProse = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 2 && second.type === "paragraph" && second.bbox && second.bbox.height >= first.style.fontSize * 4 && Math.abs(first.bbox.x - second.bbox.x) <= first.style.fontSize * 2 && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize * 2 && !captionLike.test(firstText) && !/^(?:doi:|https?:|www\.)/i.test(firstText);
3506
- const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _186 => _186.text, 'optionalAccess', _187 => _187.length]), () => ( 0))) >= 100;
3528
+ const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _194 => _194.text, 'optionalAccess', _195 => _195.length]), () => ( 0))) >= 100;
3507
3529
  if (firstIsTitle || firstAboveProse || firstIsSection) {
3508
3530
  first.type = "heading";
3509
3531
  first.level = 1;
3510
3532
  }
3511
- if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _188 => _188.style, 'optionalAccess', _189 => _189.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _190 => _190.text]) || !third.bbox || second.text.trim().length < 5 || second.text.trim().length > 80 || captionLike.test(second.text.trim()) || /^(?:doi:|https?:)/i.test(second.text.trim()) || second.bbox.height > second.style.fontSize * 1.6 || Math.abs(second.bbox.x - third.bbox.x) > 30) continue;
3512
- const distinctFace = _optionalChain([third, 'access', _191 => _191.style, 'optionalAccess', _192 => _192.fontName]) !== second.style.fontName;
3533
+ if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _196 => _196.style, 'optionalAccess', _197 => _197.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _198 => _198.text]) || !third.bbox || second.text.trim().length < 5 || second.text.trim().length > 80 || captionLike.test(second.text.trim()) || /^(?:doi:|https?:)/i.test(second.text.trim()) || second.bbox.height > second.style.fontSize * 1.6 || Math.abs(second.bbox.x - third.bbox.x) > 30) continue;
3534
+ const distinctFace = _optionalChain([third, 'access', _199 => _199.style, 'optionalAccess', _200 => _200.fontName]) !== second.style.fontName;
3513
3535
  const namedContents = /^Table of Contents$/i.test(second.text.trim());
3514
3536
  if (distinctFace && third.text.length >= 60 || namedContents) {
3515
3537
  second.type = "heading";
@@ -3520,24 +3542,24 @@ function detectPageLeadHeadings(blocks) {
3520
3542
  function refineDocumentStyleHeadings(blocks) {
3521
3543
  const faceChars = /* @__PURE__ */ new Map();
3522
3544
  for (const block of blocks) {
3523
- if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontName])) continue;
3545
+ if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _201 => _201.style, 'optionalAccess', _202 => _202.fontName])) continue;
3524
3546
  faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
3525
3547
  }
3526
3548
  const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
3527
3549
  if (!bodyFace || !bodyChars || bodyChars < 300) return;
3528
3550
  for (let i = 0; i < blocks.length; i++) {
3529
3551
  const block = blocks[i];
3530
- const text = _nullishCoalesce(_optionalChain([block, 'access', _195 => _195.text, 'optionalAccess', _196 => _196.trim, 'call', _197 => _197()]), () => ( ""));
3552
+ const text = _nullishCoalesce(_optionalChain([block, 'access', _203 => _203.text, 'optionalAccess', _204 => _204.trim, 'call', _205 => _205()]), () => ( ""));
3531
3553
  if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
3532
3554
  block.type = "paragraph";
3533
3555
  block.level = void 0;
3534
3556
  continue;
3535
3557
  }
3536
3558
  const box = block.bbox, style = block.style;
3537
- if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _198 => _198.fontName]) || !style.fontSize || style.fontName === bodyFace || (_nullishCoalesce(faceChars.get(style.fontName), () => ( 0))) > bodyChars * 0.25 || text.length < 3 || text.length > 70 || text.includes("\n") || box.height > style.fontSize * 1.6 || /^(?:table|figure|fig\.?|source|doi:|arxiv:|https?:|www\.|[•●○▪▫⮚*∗†])/i.test(text) || /(?:https?:\/\/|www\.|@|[=¼≪þ])/i.test(text) || /^definition\s+\d+[.:]?\s+.*\b(?:is|are|means)\b/i.test(text) || /^[\d\s.,:%+\-–]+$/.test(text)) continue;
3559
+ if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _206 => _206.fontName]) || !style.fontSize || style.fontName === bodyFace || (_nullishCoalesce(faceChars.get(style.fontName), () => ( 0))) > bodyChars * 0.25 || text.length < 3 || text.length > 70 || text.includes("\n") || box.height > style.fontSize * 1.6 || /^(?:table|figure|fig\.?|source|doi:|arxiv:|https?:|www\.|[•●○▪▫⮚*∗†])/i.test(text) || /(?:https?:\/\/|www\.|@|[=¼≪þ])/i.test(text) || /^definition\s+\d+[.:]?\s+.*\b(?:is|are|means)\b/i.test(text) || /^[\d\s.,:%+\-–]+$/.test(text)) continue;
3538
3560
  const previous = blocks[i - 1], next = blocks[i + 1];
3539
- const pb = _optionalChain([previous, 'optionalAccess', _199 => _199.bbox]), nb = _optionalChain([next, 'optionalAccess', _200 => _200.bbox]);
3540
- if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _201 => _201.style, 'optionalAccess', _202 => _202.fontName]) !== bodyFace || !next.text || next.text.length < 40 || style.fontSize < (_nullishCoalesce(next.style.fontSize, () => ( 0))) * 0.95 || pb.y - (box.y + box.height) < style.fontSize * 0.5 || box.y - (nb.y + nb.height) < 0 || box.y - (nb.y + nb.height) > style.fontSize * 2 || box.x + box.width / 2 < nb.x - 10 || box.x + box.width / 2 > nb.x + nb.width + 10) continue;
3561
+ const pb = _optionalChain([previous, 'optionalAccess', _207 => _207.bbox]), nb = _optionalChain([next, 'optionalAccess', _208 => _208.bbox]);
3562
+ if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _209 => _209.style, 'optionalAccess', _210 => _210.fontName]) !== bodyFace || !next.text || next.text.length < 40 || style.fontSize < (_nullishCoalesce(next.style.fontSize, () => ( 0))) * 0.95 || pb.y - (box.y + box.height) < style.fontSize * 0.5 || box.y - (nb.y + nb.height) < 0 || box.y - (nb.y + nb.height) > style.fontSize * 2 || box.x + box.width / 2 < nb.x - 10 || box.x + box.width / 2 > nb.x + nb.width + 10) continue;
3541
3563
  block.type = "heading";
3542
3564
  block.level = 2;
3543
3565
  }
@@ -3587,7 +3609,7 @@ function detectMarkerHeadings(blocks) {
3587
3609
  block.level = 4;
3588
3610
  continue;
3589
3611
  }
3590
- if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _203 => _203.style, 'optionalAccess', _204 => _204.fontSize])) {
3612
+ if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _211 => _211.style, 'optionalAccess', _212 => _212.fontSize])) {
3591
3613
  const prev = blocks[i - 1];
3592
3614
  const next = blocks[i + 1];
3593
3615
  const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
@@ -3628,7 +3650,7 @@ function detectTableCaptions(blocks) {
3628
3650
  block.table.caption = blocks[i - 1].text.trim();
3629
3651
  blocks.splice(i - 1, 1);
3630
3652
  i--;
3631
- } else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _205 => _205[i + 2], 'optionalAccess', _206 => _206.type]) !== "table") {
3653
+ } else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _213 => _213[i + 2], 'optionalAccess', _214 => _214.type]) !== "table") {
3632
3654
  block.table.caption = blocks[i + 1].text.trim();
3633
3655
  blocks.splice(i + 1, 1);
3634
3656
  }
@@ -3842,7 +3864,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
3842
3864
  const bottomEntries = [];
3843
3865
  for (let bi = 0; bi < blocks.length; bi++) {
3844
3866
  const b = blocks[bi];
3845
- const text = !tables ? _optionalChain([b, 'access', _207 => _207.text, 'optionalAccess', _208 => _208.trim, 'call', _209 => _209()]) : b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean).join(" | ") : void 0;
3867
+ const text = !tables ? _optionalChain([b, 'access', _215 => _215.text, 'optionalAccess', _216 => _216.trim, 'call', _217 => _217()]) : b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean).join(" | ") : void 0;
3846
3868
  if (!b.bbox || !b.pageNumber || !text) continue;
3847
3869
  const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
3848
3870
  if (!ph) continue;
@@ -3873,7 +3895,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
3873
3895
  for (const [p, count] of patternCount) {
3874
3896
  const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
3875
3897
  const span = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
3876
- const pageNumbered = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _210 => _210.get, 'call', _211 => _211(p), 'optionalAccess', _212 => _212.size]), () => ( 0))) > 1;
3898
+ const pageNumbered = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _218 => _218.get, 'call', _219 => _219(p), 'optionalAccess', _220 => _220.size]), () => ( 0))) > 1;
3877
3899
  if (count >= MIN_REPEAT && pages.length >= MIN_REPEAT && (pages.length >= span * 0.4 || pageNumbered)) {
3878
3900
  repeatedPatterns.add(p);
3879
3901
  }
@@ -3881,8 +3903,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
3881
3903
  for (const e of entries) {
3882
3904
  const norm = e.text.replace(/\d+/g, "#");
3883
3905
  if (!repeatedPatterns.has(norm)) continue;
3884
- const noteMark = _optionalChain([e, 'access', _213 => _213.text, 'access', _214 => _214.match, 'call', _215 => _215(/^\d{1,3}\)/), 'optionalAccess', _216 => _216[0]]);
3885
- if (noteMark && _optionalChain([notes, 'optionalAccess', _217 => _217.get, 'call', _218 => _218(e.page), 'optionalAccess', _219 => _219.marks, 'access', _220 => _220.some, 'call', _221 => _221((m) => m.mark === noteMark)])) continue;
3906
+ const noteMark = _optionalChain([e, 'access', _221 => _221.text, 'access', _222 => _222.match, 'call', _223 => _223(/^\d{1,3}\)/), 'optionalAccess', _224 => _224[0]]);
3907
+ if (noteMark && _optionalChain([notes, 'optionalAccess', _225 => _225.get, 'call', _226 => _226(e.page), 'optionalAccess', _227 => _227.marks, 'access', _228 => _228.some, 'call', _229 => _229((m) => m.mark === noteMark)])) continue;
3886
3908
  const cand = blocks[e.blockIdx];
3887
3909
  const cb = cand.bbox;
3888
3910
  const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::])/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
@@ -3896,7 +3918,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
3896
3918
  if (bi === e.blockIdx) continue;
3897
3919
  const o = blocks[bi];
3898
3920
  if (!o.bbox || o.bbox.page !== cb.page) continue;
3899
- const oNorm = _optionalChain([o, 'access', _222 => _222.text, 'optionalAccess', _223 => _223.trim, 'call', _224 => _224(), 'access', _225 => _225.replace, 'call', _226 => _226(/\d+/g, "#")]);
3921
+ const oNorm = _optionalChain([o, 'access', _230 => _230.text, 'optionalAccess', _231 => _231.trim, 'call', _232 => _232(), 'access', _233 => _233.replace, 'call', _234 => _234(/\d+/g, "#")]);
3900
3922
  if (oNorm && repeatedPatterns.has(oNorm)) continue;
3901
3923
  const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
3902
3924
  if (overlap2 >= cb.height * 0.5) {
@@ -3970,7 +3992,7 @@ function recordRowRules(table, cells, bbox, hs) {
3970
3992
  function markImageCell(cell) {
3971
3993
  IMAGE_CELLS.add(cell);
3972
3994
  }
3973
- var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _227 => _227.text, 'optionalAccess', _228 => _228.trim, 'call', _229 => _229()]) && !_optionalChain([cell, 'access', _230 => _230.blocks, 'optionalAccess', _231 => _231.length]) && !IMAGE_CELLS.has(cell);
3995
+ var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _235 => _235.text, 'optionalAccess', _236 => _236.trim, 'call', _237 => _237()]) && !_optionalChain([cell, 'access', _238 => _238.blocks, 'optionalAccess', _239 => _239.length]) && !IMAGE_CELLS.has(cell);
3974
3996
  function trimTable(table) {
3975
3997
  let cols = table.cols;
3976
3998
  while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
@@ -3986,7 +4008,7 @@ function trimTable(table) {
3986
4008
  function trimTrailingEmptyTableCols(blocks) {
3987
4009
  for (const b of blocks) {
3988
4010
  if (b.type !== "table" || !b.table) continue;
3989
- for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _232 => _232.blocks, 'optionalAccess', _233 => _233.length])) trimTrailingEmptyTableCols(cell.blocks);
4011
+ for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _240 => _240.blocks, 'optionalAccess', _241 => _241.length])) trimTrailingEmptyTableCols(cell.blocks);
3990
4012
  trimTable(b.table);
3991
4013
  }
3992
4014
  }
@@ -4006,7 +4028,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
4006
4028
  }
4007
4029
  const ok = owner.every((row) => {
4008
4030
  const o = row[c];
4009
- return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _234 => _234.blocks, 'optionalAccess', _235 => _235.length]));
4031
+ return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _242 => _242.blocks, 'optionalAccess', _243 => _243.length]));
4010
4032
  });
4011
4033
  if (!ok) continue;
4012
4034
  const spanning = /* @__PURE__ */ new Set();
@@ -4072,7 +4094,7 @@ function isProseTable(table) {
4072
4094
  if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
4073
4095
  for (let c = 0; c < table.cols; c++) {
4074
4096
  const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
4075
- if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _236 => _236.match, 'call', _237 => _237(/\p{L}/gu), 'optionalAccess', _238 => _238.length]), () => ( 0))) >= 2)) return false;
4097
+ if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _244 => _244.match, 'call', _245 => _245(/\p{L}/gu), 'optionalAccess', _246 => _246.length]), () => ( 0))) >= 2)) return false;
4076
4098
  }
4077
4099
  return true;
4078
4100
  }
@@ -4099,7 +4121,7 @@ function isChartTable(table) {
4099
4121
  const numeric = texts.filter((text) => NUMERIC_CELL.test(text)).length;
4100
4122
  if (numeric < texts.length * 0.5) return false;
4101
4123
  for (let c = 0; c < table.cols; c++) {
4102
- const ticks = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _239 => _239[c], 'optionalAccess', _240 => _240.text]), () => ( ""))).split(/\s+/)).filter((token) => /^-?[\d,]+(?:\.\d+)?%?$/.test(token)).map((token) => Number(token.replace(/[,%]/g, "")));
4124
+ const ticks = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _247 => _247[c], 'optionalAccess', _248 => _248.text]), () => ( ""))).split(/\s+/)).filter((token) => /^-?[\d,]+(?:\.\d+)?%?$/.test(token)).map((token) => Number(token.replace(/[,%]/g, "")));
4103
4125
  if (hasValueAxis(ticks)) return true;
4104
4126
  }
4105
4127
  const values = texts.filter((text) => text.split(/\s+/).every((token) => /^[-−–]?[\d,]*\.?\d+%?$/.test(token))).length;
@@ -4253,7 +4275,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
4253
4275
  continue;
4254
4276
  }
4255
4277
  const top = rows[i - 1];
4256
- const title = _optionalChain([top, 'optionalAccess', _241 => _241.items, 'access', _242 => _242.length]) === 1 && Math.abs(top.items[0].x - first[0].x) <= 5 && top.items[0].text.length <= 65 && top.y - first[0].y <= Math.max(24, first[0].fontSize * 2.8) ? top : void 0;
4278
+ const title = _optionalChain([top, 'optionalAccess', _249 => _249.items, 'access', _250 => _250.length]) === 1 && Math.abs(top.items[0].x - first[0].x) <= 5 && top.items[0].text.length <= 65 && top.y - first[0].y <= Math.max(24, first[0].fontSize * 2.8) ? top : void 0;
4257
4279
  const tableRows = title ? [title, ...body] : body;
4258
4280
  const cells = tableRows.map((row, idx) => {
4259
4281
  if (title && idx === 0) return [{ text: row.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }];
@@ -4309,12 +4331,12 @@ function isTwoColumnProse(r) {
4309
4331
  if (t.rows < 8) return false;
4310
4332
  const dense = [];
4311
4333
  for (let c = 0; c < t.cols; c++) {
4312
- const filled = t.cells.filter((row) => _optionalChain([row, 'access', _243 => _243[c], 'optionalAccess', _244 => _244.text, 'access', _245 => _245.trim, 'call', _246 => _246()])).length;
4334
+ const filled = t.cells.filter((row) => _optionalChain([row, 'access', _251 => _251[c], 'optionalAccess', _252 => _252.text, 'access', _253 => _253.trim, 'call', _254 => _254()])).length;
4313
4335
  if (filled / t.rows >= 0.3) dense.push(c);
4314
4336
  }
4315
4337
  if (dense.length !== 2) return false;
4316
4338
  for (const c of dense) {
4317
- const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _247 => _247[c], 'optionalAccess', _248 => _248.text, 'access', _249 => _249.replace, 'call', _250 => _250(/\s+/g, ""), 'access', _251 => _251.length]), () => ( 0))).filter((n) => n > 0);
4339
+ const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _255 => _255[c], 'optionalAccess', _256 => _256.text, 'access', _257 => _257.replace, 'call', _258 => _258(/\s+/g, ""), 'access', _259 => _259.length]), () => ( 0))).filter((n) => n > 0);
4318
4340
  const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
4319
4341
  if (avg < 12) return false;
4320
4342
  }
@@ -4710,7 +4732,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
4710
4732
  const runs = [];
4711
4733
  for (const it of sorted) {
4712
4734
  const last = runs[runs.length - 1];
4713
- const prev = _optionalChain([last, 'optionalAccess', _252 => _252[last.length - 1]]);
4735
+ const prev = _optionalChain([last, 'optionalAccess', _260 => _260[last.length - 1]]);
4714
4736
  if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
4715
4737
  else runs.push([it]);
4716
4738
  }
@@ -4784,7 +4806,7 @@ function buildClusterTable(rows, columns, pageNum) {
4784
4806
  () => Array.from({ length: numCols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }))
4785
4807
  );
4786
4808
  const usedItems = /* @__PURE__ */ new Set();
4787
- const headFaces = new Set(_optionalChain([rows, 'access', _253 => _253[0], 'optionalAccess', _254 => _254.items, 'access', _255 => _255.map, 'call', _256 => _256((i) => i.fontName)]));
4809
+ const headFaces = new Set(_optionalChain([rows, 'access', _261 => _261[0], 'optionalAccess', _262 => _262.items, 'access', _263 => _263.map, 'call', _264 => _264((i) => i.fontName)]));
4788
4810
  const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
4789
4811
  for (let r = 0; r < numRows; r++) {
4790
4812
  const row = rows[r];
@@ -4814,7 +4836,7 @@ function buildClusterTable(rows, columns, pageNum) {
4814
4836
  const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
4815
4837
  if (nonEmptyCols !== 1) continue;
4816
4838
  if (cells[r][0].text.trim() !== "") continue;
4817
- const contentText = _optionalChain([cells, 'access', _257 => _257[r], 'access', _258 => _258.find, 'call', _259 => _259((c) => c.text.trim()), 'optionalAccess', _260 => _260.text, 'access', _261 => _261.trim, 'call', _262 => _262()]) || "";
4839
+ const contentText = _optionalChain([cells, 'access', _265 => _265[r], 'access', _266 => _266.find, 'call', _267 => _267((c) => c.text.trim()), 'optionalAccess', _268 => _268.text, 'access', _269 => _269.trim, 'call', _270 => _270()]) || "";
4818
4840
  if (/^[○●▶\-·]/.test(contentText)) continue;
4819
4841
  for (let pr = r - 1; pr >= 0; pr--) {
4820
4842
  if (cells[pr].some((c) => c.text.trim())) {
@@ -5441,16 +5463,16 @@ function isProseSpread(items) {
5441
5463
  for (let i = 1; i < sorted.length; i++) {
5442
5464
  gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
5443
5465
  }
5444
- const maxGap = _chunkKZVQK5NScjs.safeMax.call(void 0, gaps);
5466
+ const maxGap = _chunkEXBZHI25cjs.safeMax.call(void 0, gaps);
5445
5467
  const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
5446
5468
  if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
5447
- const minGap = _chunkKZVQK5NScjs.safeMin.call(void 0, gaps);
5469
+ const minGap = _chunkEXBZHI25cjs.safeMin.call(void 0, gaps);
5448
5470
  return minGap > 0 && maxGap - minGap <= Math.max(2, maxGap * 0.15) && items.filter((i) => /^\P{L}*\p{Ll}/u.test(i.text)).length * 2 >= items.length;
5449
5471
  }
5450
5472
  function detectColumns(yLines) {
5451
5473
  const allItems = yLines.flat();
5452
5474
  if (allItems.length === 0) return null;
5453
- const pageWidth = _chunkKZVQK5NScjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkKZVQK5NScjs.safeMin.call(void 0, allItems.map((i) => i.x));
5475
+ const pageWidth = _chunkEXBZHI25cjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkEXBZHI25cjs.safeMin.call(void 0, allItems.map((i) => i.x));
5454
5476
  if (pageWidth < 100) return null;
5455
5477
  let bigoLineIdx = -1;
5456
5478
  for (let i = 0; i < yLines.length; i++) {
@@ -5749,7 +5771,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
5749
5771
  if (ow <= 0) continue;
5750
5772
  const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
5751
5773
  if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
5752
- const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _263 => _263.reduce, 'call', _264 => _264((sum, item) => {
5774
+ const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _271 => _271.reduce, 'call', _272 => _272((sum, item) => {
5753
5775
  const below = item.y - o.y1;
5754
5776
  if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
5755
5777
  return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
@@ -5879,8 +5901,8 @@ function edgesOf(box, h, v, hNear = EDGE_NEAR2) {
5879
5901
  }
5880
5902
  function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
5881
5903
  if (!grids.some((g) => g.cells)) return;
5882
- const h = rules(_optionalChain([nonRules, 'optionalAccess', _265 => _265.size]) ? horizontals.filter((l) => !nonRules.has(l)) : horizontals, "h");
5883
- const v = rules(_optionalChain([nonRules, 'optionalAccess', _266 => _266.size]) ? verticals.filter((l) => !nonRules.has(l)) : verticals, "v");
5904
+ const h = rules(_optionalChain([nonRules, 'optionalAccess', _273 => _273.size]) ? horizontals.filter((l) => !nonRules.has(l)) : horizontals, "h");
5905
+ const v = rules(_optionalChain([nonRules, 'optionalAccess', _274 => _274.size]) ? verticals.filter((l) => !nonRules.has(l)) : verticals, "v");
5884
5906
  for (const g of grids) for (const c of _nullishCoalesce(g.cells, () => ( []))) {
5885
5907
  const near = c.filler ? Math.min(EDGE_NEAR2, (c.bbox.y2 - c.bbox.y1) / 3) : EDGE_NEAR2;
5886
5908
  CLIP_CELL_EDGES.set(c, edgesOf(c.bbox, h, v, near));
@@ -5888,12 +5910,12 @@ function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
5888
5910
  }
5889
5911
  function takeClipCellEdges(from, to) {
5890
5912
  const e = CLIP_CELL_EDGES.get(from);
5891
- if (e) _chunkYIANW5QXcjs.CELL_EDGES.set(to, e);
5913
+ if (e) _chunkAFXX3YSPcjs.CELL_EDGES.set(to, e);
5892
5914
  }
5893
5915
  function joinCellEdges(a, b) {
5894
- const u = _chunkYIANW5QXcjs.CELL_EDGES.get(a), d = _chunkYIANW5QXcjs.CELL_EDGES.get(b);
5916
+ const u = _chunkAFXX3YSPcjs.CELL_EDGES.get(a), d = _chunkAFXX3YSPcjs.CELL_EDGES.get(b);
5895
5917
  if (!u || !d) return;
5896
- _chunkYIANW5QXcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
5918
+ _chunkAFXX3YSPcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
5897
5919
  }
5898
5920
 
5899
5921
  // src/pdf/table-unit-row.ts
@@ -5909,12 +5931,12 @@ function rebuildUnitLine(items, grid) {
5909
5931
  function prependUnitRow(cells, cols, line, usedItems) {
5910
5932
  const text = cleanCellText(line.map((item) => item.text).join(""));
5911
5933
  cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
5912
- for (const cell of cells[0]) _chunkYIANW5QXcjs.CELL_EDGES.set(cell, NO_EDGES);
5934
+ for (const cell of cells[0]) _chunkAFXX3YSPcjs.CELL_EDGES.set(cell, NO_EDGES);
5913
5935
  for (const item of line) usedItems.add(item);
5914
5936
  }
5915
5937
  function attachUnitRow(items, grid, cells, cols, usedItems) {
5916
5938
  const all = cells.flat();
5917
- if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _267 => _267[0], 'optionalAccess', _268 => _268[0], 'optionalAccess', _269 => _269.text]), () => ( "")))) return false;
5939
+ if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _275 => _275[0], 'optionalAccess', _276 => _276[0], 'optionalAccess', _277 => _277.text]), () => ( "")))) return false;
5918
5940
  const above = items.filter((it) => !usedItems.has(it) && it.y >= grid.bbox.y2 && it.y - grid.bbox.y2 <= 8 && it.x >= grid.bbox.x1 - 3 && it.x + it.w <= grid.bbox.x2 + 3);
5919
5941
  let nearest = Infinity;
5920
5942
  for (const it of above) nearest = Math.min(nearest, it.y);
@@ -6454,7 +6476,7 @@ function stackedTableBands(items) {
6454
6476
  const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
6455
6477
  while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
6456
6478
  if (runs.length < 2) return null;
6457
- if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _270 => _270[i + 1], 'optionalAccess', _271 => _271.start]), () => ( lines.length))))) return null;
6479
+ if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _278 => _278[i + 1], 'optionalAccess', _279 => _279.start]), () => ( lines.length))))) return null;
6458
6480
  const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
6459
6481
  const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
6460
6482
  const tail = lines.slice(runs[runs.length - 1].end);
@@ -6618,7 +6640,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
6618
6640
  const filled = fillBlanks(items, horizontals, verticals);
6619
6641
  items = filled.items;
6620
6642
  horizontals = filled.horizontals;
6621
- const prevPage = _optionalChain([carry, 'optionalAccess', _272 => _272.page]) === pageNum - 1 ? carry.clip : void 0;
6643
+ const prevPage = _optionalChain([carry, 'optionalAccess', _280 => _280.page]) === pageNum - 1 ? carry.clip : void 0;
6622
6644
  const clipResult = detectTables ? buildClipCellGrids(extracted.clipRects, horizontals, verticals, pageWidth, pageHeight, items.map((it) => ({ x: it.x + it.w / 2, y: it.y + it.h / 2 })), extracted.fillRects, prevPage) : { grids: [], containers: [], page: void 0 };
6623
6645
  if (carry) {
6624
6646
  carry.page = pageNum;
@@ -6906,14 +6928,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
6906
6928
  if (!assignedItems.has(textItems[ti])) usedItems.delete(tableItems[ti]);
6907
6929
  }
6908
6930
  }
6909
- if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _273 => _273[0], 'optionalAccess', _274 => _274[0], 'optionalAccess', _275 => _275.text]), () => ( "")))) {
6931
+ if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _281 => _281[0], 'optionalAccess', _282 => _282[0], 'optionalAccess', _283 => _283.text]), () => ( "")))) {
6910
6932
  prependUnitRow(finalGrid, numCols, unitLine, usedItems);
6911
6933
  finalRows++;
6912
6934
  }
6913
6935
  if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
6914
6936
  let semanticOneColumn = false;
6915
6937
  if (!grid.cells && numCols === 1 && numGridRows >= 2) {
6916
- const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _276 => _276[0], 'optionalAccess', _277 => _277.text, 'access', _278 => _278.trim, 'call', _279 => _279()]));
6938
+ const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _284 => _284[0], 'optionalAccess', _285 => _285.text, 'access', _286 => _286.trim, 'call', _287 => _287()]));
6917
6939
  if (populatedRows.length >= 4) {
6918
6940
  const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
6919
6941
  const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
@@ -6992,7 +7014,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
6992
7014
  height: grid.bbox.y2 - grid.bbox.y1
6993
7015
  };
6994
7016
  if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
6995
- const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _280 => _280[0], 'optionalAccess', _281 => _281[0], 'optionalAccess', _282 => _282.text]), () => ( ""));
7017
+ const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _288 => _288[0], 'optionalAccess', _289 => _289[0], 'optionalAccess', _290 => _290.text]), () => ( ""));
6996
7018
  const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
6997
7019
  const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
6998
7020
  const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
@@ -7046,7 +7068,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7046
7068
  const proseColumns = findTwoColumnProseCutX(clusterItems) !== null || detectPersistentColumnGutter(remaining.map((i) => ({ x: i.x, y: i.y, w: i.w, h: i.h > 0 ? i.h : i.fontSize }))) !== null;
7047
7069
  const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum)).filter((cr) => {
7048
7070
  const b = cr.bbox;
7049
- return !blocks.some((x) => x.type === "paragraph" && x.bbox && (_nullishCoalesce(_optionalChain([x, 'access', _283 => _283.text, 'optionalAccess', _284 => _284.match, 'call', _285 => _285(/\p{L}/gu), 'optionalAccess', _286 => _286.length]), () => ( 0))) >= 10 && Math.min(x.bbox.x + x.bbox.width, b.x + b.width) - Math.max(x.bbox.x, b.x) >= 0.8 * b.width && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2);
7071
+ return !blocks.some((x) => x.type === "paragraph" && x.bbox && (_nullishCoalesce(_optionalChain([x, 'access', _291 => _291.text, 'optionalAccess', _292 => _292.match, 'call', _293 => _293(/\p{L}/gu), 'optionalAccess', _294 => _294.length]), () => ( 0))) >= 10 && Math.min(x.bbox.x + x.bbox.width, b.x + b.width) - Math.max(x.bbox.x, b.x) >= 0.8 * b.width && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2);
7050
7072
  });
7051
7073
  if (clusterResults.length > 0) {
7052
7074
  const ciToIdx = /* @__PURE__ */ new Map();
@@ -7080,7 +7102,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7080
7102
  if (gutterX !== null) {
7081
7103
  const gx = gutterX;
7082
7104
  const allY = remaining.map((i) => i.y);
7083
- const pageH = _chunkKZVQK5NScjs.safeMax.call(void 0, allY) - _chunkKZVQK5NScjs.safeMin.call(void 0, allY);
7105
+ const pageH = _chunkEXBZHI25cjs.safeMax.call(void 0, allY) - _chunkEXBZHI25cjs.safeMin.call(void 0, allY);
7084
7106
  const gapThreshold = Math.max(15, pageH * 0.03);
7085
7107
  const sides = [
7086
7108
  remaining.filter((i) => i.x + i.w <= gx),
@@ -7100,7 +7122,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7100
7122
  finalTextBlocks = detectListBlocks(textBlocks);
7101
7123
  } else {
7102
7124
  const allY = remaining.map((i) => i.y);
7103
- const pageH = _chunkKZVQK5NScjs.safeMax.call(void 0, allY) - _chunkKZVQK5NScjs.safeMin.call(void 0, allY);
7125
+ const pageH = _chunkEXBZHI25cjs.safeMax.call(void 0, allY) - _chunkEXBZHI25cjs.safeMin.call(void 0, allY);
7104
7126
  const groups = xyCutOrder(remaining, Math.max(15, pageH * 0.03));
7105
7127
  const textBlocks = [];
7106
7128
  for (const group of groups) {
@@ -7186,9 +7208,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7186
7208
  continue;
7187
7209
  }
7188
7210
  let lastLeft = -1;
7189
- const beside = (b) => !!b.bbox && b.bbox.x + b.bbox.width <= box.x - 3 && b.bbox.y + b.bbox.height >= box.y && b.bbox.y <= box.y + box.height;
7190
7211
  units.forEach((unit, index) => {
7191
- if (unit.some(beside) && unit.every((b) => beside(b) || !!b.bbox && b.bbox.y + b.bbox.height < box.y)) lastLeft = index;
7212
+ if (isProseBesidePanel(unit, box)) lastLeft = index;
7192
7213
  });
7193
7214
  const current = units.findIndex((unit) => unit.includes(sidebar));
7194
7215
  if (lastLeft > current) {
@@ -7204,6 +7225,10 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
7204
7225
  }
7205
7226
  return mergeAdjacentTableBlocks(ordered);
7206
7227
  }
7228
+ function isProseBesidePanel(unit, box) {
7229
+ const beside = (b) => !!b.bbox && b.bbox.x + b.bbox.width <= box.x - 3 && b.bbox.y + b.bbox.height >= box.y && b.bbox.y <= box.y + box.height;
7230
+ return unit.some(beside) && unit.every((b) => beside(b) || !!b.bbox && b.bbox.y < box.y);
7231
+ }
7207
7232
  var SIDEBAR_ITEMS = /* @__PURE__ */ new WeakMap();
7208
7233
  function clusterTableBlock(cr, source, pageNum, horizontals = []) {
7209
7234
  const b = cr.bbox;
@@ -7416,7 +7441,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
7416
7441
  blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
7417
7442
  } else {
7418
7443
  const allY = items.map((i) => i.y);
7419
- const pageHeight = _chunkKZVQK5NScjs.safeMax.call(void 0, allY) - _chunkKZVQK5NScjs.safeMin.call(void 0, allY);
7444
+ const pageHeight = _chunkEXBZHI25cjs.safeMax.call(void 0, allY) - _chunkEXBZHI25cjs.safeMin.call(void 0, allY);
7420
7445
  const gapThreshold = Math.max(15, pageHeight * 0.03);
7421
7446
  const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold);
7422
7447
  for (const group of orderedGroups) {
@@ -7484,4 +7509,4 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
7484
7509
 
7485
7510
 
7486
7511
  exports.OCR_DET_MODEL = OCR_DET_MODEL; exports.OCR_REC_MODEL = OCR_REC_MODEL; exports.OCR_REC_DICT = OCR_REC_DICT; exports.getOcrModelsDir = getOcrModelsDir; exports.ensureOcrModels = ensureOcrModels; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.normalizeItems = normalizeItems; exports.WrapLexicon = WrapLexicon; exports.startsNewItem = startsNewItem; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.latinSoftWrap = latinSoftWrap; exports.TOC_BLOCKS = TOC_BLOCKS; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.mergeStackedHeadingLines = mergeStackedHeadingLines; exports.detectTypographyHeadings = detectTypographyHeadings; exports.detectDocumentStyleHeadings = detectDocumentStyleHeadings; exports.detectSiblingStyleHeadings = detectSiblingStyleHeadings; exports.detectRepeatedPageLabels = detectRepeatedPageLabels; exports.detectPageLeadHeadings = detectPageLeadHeadings; exports.refineDocumentStyleHeadings = refineDocumentStyleHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.CLIP_TABLES = CLIP_TABLES; exports.TABLE_COLXS = TABLE_COLXS; exports.TABLE_ROWYS = TABLE_ROWYS; exports.TABLE_TAIL = TABLE_TAIL; exports.PART_COLXS = PART_COLXS; exports.EMPTY_PARTS = EMPTY_PARTS; exports.IMAGE_CELLS = IMAGE_CELLS; exports.FILLER_CELLS = FILLER_CELLS; exports.CONT_PARTS = CONT_PARTS; exports.CELL_LINES = CELL_LINES; exports.ROW_RULES = ROW_RULES; exports.trimTrailingEmptyTableCols = trimTrailingEmptyTableCols; exports.NO_EDGES = NO_EDGES; exports.joinCellEdges = joinCellEdges; exports.extractPageBlocksWithLines = extractPageBlocksWithLines;
7487
- //# sourceMappingURL=chunk-WWMKIHF7.cjs.map
7512
+ //# sourceMappingURL=chunk-WNF3TSV3.cjs.map