kordoc 4.24.1 → 4.24.2

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 (135) hide show
  1. package/README.md +2 -2
  2. package/dist/{-TSN4SWFV.js → -SRNEV7LS.js} +11 -11
  3. package/dist/{chunk-B77K6J3U.js → chunk-3HN65YAL.js} +2 -2
  4. package/dist/{chunk-SWCO5NP6.js → chunk-4745MFQU.js} +3 -3
  5. package/dist/{chunk-2SMANR76.js → chunk-4XC4O7FJ.js} +4 -4
  6. package/dist/{chunk-RS2Q64N5.js → chunk-7NTMM6PO.js} +2 -2
  7. package/dist/{chunk-4BCQ3FQS.js → chunk-C6ZVB547.js} +11 -11
  8. package/dist/{chunk-LBPUPT6S.js → chunk-DHMBPMKC.js} +74 -30
  9. package/dist/chunk-DHMBPMKC.js.map +1 -0
  10. package/dist/{chunk-LEL5UBGR.js → chunk-E6VBLBOO.js} +2 -2
  11. package/dist/{chunk-LEUS275C.js → chunk-E7B5CXYI.js} +2 -2
  12. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  13. package/dist/{chunk-RIQVVWVF.cjs → chunk-HLTPMSYW.cjs} +3 -3
  14. package/dist/chunk-HLTPMSYW.cjs.map +1 -0
  15. package/dist/{chunk-KGOVG47P.cjs → chunk-IGG63DFK.cjs} +3 -3
  16. package/dist/chunk-IGG63DFK.cjs.map +1 -0
  17. package/dist/chunk-J55UQC5H.cjs.map +1 -1
  18. package/dist/{chunk-5QBTJ4LA.cjs → chunk-JFUUFJZW.cjs} +6 -6
  19. package/dist/chunk-JFUUFJZW.cjs.map +1 -0
  20. package/dist/{chunk-HP24FYLJ.js → chunk-JMOAMKAR.js} +4 -4
  21. package/dist/{chunk-W4P3QPSB.js → chunk-KUC5I5MB.js} +2 -2
  22. package/dist/{chunk-YE4T2P6F.js → chunk-LMEF7FN5.js} +2 -2
  23. package/dist/{chunk-NAPPGU3W.js → chunk-M46PB75E.js} +2 -2
  24. package/dist/{chunk-AJ3DJSO6.js → chunk-MHNJOJQV.js} +4 -4
  25. package/dist/{chunk-5EP6VFP5.js → chunk-NJ5RUDCW.js} +3 -3
  26. package/dist/{chunk-MI25BZSU.js → chunk-NMFFIUI6.js} +2 -2
  27. package/dist/{chunk-TYXXTWPH.cjs → chunk-PNSALBXH.cjs} +2 -2
  28. package/dist/chunk-PNSALBXH.cjs.map +1 -0
  29. package/dist/{chunk-JSI5T77E.cjs → chunk-PNX5FYHC.cjs} +24 -24
  30. package/dist/chunk-PNX5FYHC.cjs.map +1 -0
  31. package/dist/{chunk-V2GW3M2F.js → chunk-R2GIGE5H.js} +2 -2
  32. package/dist/{chunk-L2OJUIII.js → chunk-RIRPLFPN.js} +2 -2
  33. package/dist/{chunk-WYYUWBTS.js → chunk-TDMBTG7U.js} +2 -2
  34. package/dist/chunk-TK3FDAEE.cjs.map +1 -1
  35. package/dist/{chunk-G7SKCXQG.js → chunk-TW3V6FSH.js} +2 -2
  36. package/dist/{chunk-4VNIEHWM.cjs → chunk-UNICY546.cjs} +23 -23
  37. package/dist/chunk-UNICY546.cjs.map +1 -0
  38. package/dist/{chunk-ZR3BPESP.js → chunk-VPSF5LEM.js} +3 -3
  39. package/dist/{chunk-6H7D4QTM.js → chunk-W24TJJNN.js} +2 -2
  40. package/dist/{chunk-BIVO2GMU.js → chunk-WDSTW3BD.js} +2 -2
  41. package/dist/{chunk-RVKOFZAT.js → chunk-WJAFE3Z6.js} +2 -2
  42. package/dist/chunks-AL4P5TO5.js +10 -0
  43. package/dist/cli.js +30 -30
  44. package/dist/{formula-6J26PNHL.js → formula-DSB574H7.js} +4 -4
  45. package/dist/{formula-5DGAZK6N.cjs → formula-HK2MNZ3Q.cjs} +9 -9
  46. package/dist/formula-HK2MNZ3Q.cjs.map +1 -0
  47. package/dist/{formula-PNZX2ZAZ.js → formula-U2LZ67KI.js} +3 -3
  48. package/dist/{image-ocr-UNTKJLQL.js → image-ocr-3QB2HLSI.js} +9 -9
  49. package/dist/{image-ocr-RPHNFU7I.js → image-ocr-J54Q3YWP.js} +6 -6
  50. package/dist/{image-ocr-I4PGBAJ7.cjs → image-ocr-QNIMVE5A.cjs} +17 -17
  51. package/dist/image-ocr-QNIMVE5A.cjs.map +1 -0
  52. package/dist/index.cjs +472 -428
  53. package/dist/index.cjs.map +1 -1
  54. package/dist/index.js +74 -30
  55. package/dist/index.js.map +1 -1
  56. package/dist/mcp.js +23 -23
  57. package/dist/{model-bundle-ZSDEJFA7.js → model-bundle-CGWU4ALC.js} +5 -5
  58. package/dist/{models-JS66XYKO.js → models-A3TF3BDV.js} +5 -5
  59. package/dist/page-range-QHHFTL7X.cjs.map +1 -1
  60. package/dist/{parse-worker-v2-JHPEY3MI.js → parse-worker-v2-MNUD4WAR.js} +12 -12
  61. package/dist/{parser-YKATDDQV.js → parser-C3ARF26I.js} +12 -12
  62. package/dist/{parser-N64TUIWU.js → parser-OBGWEWSU.js} +9 -9
  63. package/dist/{parser-NMV5GTKC.cjs → parser-RPAHN3OR.cjs} +157 -157
  64. package/dist/parser-RPAHN3OR.cjs.map +1 -0
  65. package/dist/{pdf-ocr-KTKR2JQH.js → pdf-ocr-ENLVEEYL.js} +9 -9
  66. package/dist/pdf-ocr-GA5QJFNK.cjs +31 -0
  67. package/dist/pdf-ocr-GA5QJFNK.cjs.map +1 -0
  68. package/dist/{pdf-ocr-W3LDJYCA.js → pdf-ocr-K53REDNY.js} +6 -6
  69. package/dist/{profile-io-JRODOL7A.js → profile-io-ZGFEO7CB.js} +3 -3
  70. package/dist/{rasterize-2DMR7RGP.js → rasterize-QMC2SAUT.js} +3 -3
  71. package/dist/{redact-doc-TC6QSTPM.js → redact-doc-JH6RZZBE.js} +11 -11
  72. package/dist/{render-WEUU5EDS.js → render-ZGKQLKPJ.js} +7 -7
  73. package/dist/seal-KMGYTJAV.js +10 -0
  74. package/dist/{setup-LKJKGMKJ.js → setup-LAQGCYQ2.js} +3 -3
  75. package/dist/visual-4OYJFGXL.js +21 -0
  76. package/dist/{watch-HHFVXB3G.js → watch-7YPB4TKC.js} +12 -12
  77. package/package.json +1 -1
  78. package/dist/chunk-4VNIEHWM.cjs.map +0 -1
  79. package/dist/chunk-5QBTJ4LA.cjs.map +0 -1
  80. package/dist/chunk-JSI5T77E.cjs.map +0 -1
  81. package/dist/chunk-KGOVG47P.cjs.map +0 -1
  82. package/dist/chunk-LBPUPT6S.js.map +0 -1
  83. package/dist/chunk-RIQVVWVF.cjs.map +0 -1
  84. package/dist/chunk-TYXXTWPH.cjs.map +0 -1
  85. package/dist/chunks-HPPVNSBT.js +0 -10
  86. package/dist/formula-5DGAZK6N.cjs.map +0 -1
  87. package/dist/image-ocr-I4PGBAJ7.cjs.map +0 -1
  88. package/dist/parser-NMV5GTKC.cjs.map +0 -1
  89. package/dist/pdf-ocr-JXK752RC.cjs +0 -31
  90. package/dist/pdf-ocr-JXK752RC.cjs.map +0 -1
  91. package/dist/seal-LSALFURW.js +0 -10
  92. package/dist/visual-PHZHJRY5.js +0 -21
  93. /package/dist/{-TSN4SWFV.js.map → -SRNEV7LS.js.map} +0 -0
  94. /package/dist/{chunk-B77K6J3U.js.map → chunk-3HN65YAL.js.map} +0 -0
  95. /package/dist/{chunk-SWCO5NP6.js.map → chunk-4745MFQU.js.map} +0 -0
  96. /package/dist/{chunk-2SMANR76.js.map → chunk-4XC4O7FJ.js.map} +0 -0
  97. /package/dist/{chunk-RS2Q64N5.js.map → chunk-7NTMM6PO.js.map} +0 -0
  98. /package/dist/{chunk-4BCQ3FQS.js.map → chunk-C6ZVB547.js.map} +0 -0
  99. /package/dist/{chunk-LEL5UBGR.js.map → chunk-E6VBLBOO.js.map} +0 -0
  100. /package/dist/{chunk-LEUS275C.js.map → chunk-E7B5CXYI.js.map} +0 -0
  101. /package/dist/{chunk-HP24FYLJ.js.map → chunk-JMOAMKAR.js.map} +0 -0
  102. /package/dist/{chunk-W4P3QPSB.js.map → chunk-KUC5I5MB.js.map} +0 -0
  103. /package/dist/{chunk-YE4T2P6F.js.map → chunk-LMEF7FN5.js.map} +0 -0
  104. /package/dist/{chunk-NAPPGU3W.js.map → chunk-M46PB75E.js.map} +0 -0
  105. /package/dist/{chunk-AJ3DJSO6.js.map → chunk-MHNJOJQV.js.map} +0 -0
  106. /package/dist/{chunk-5EP6VFP5.js.map → chunk-NJ5RUDCW.js.map} +0 -0
  107. /package/dist/{chunk-MI25BZSU.js.map → chunk-NMFFIUI6.js.map} +0 -0
  108. /package/dist/{chunk-V2GW3M2F.js.map → chunk-R2GIGE5H.js.map} +0 -0
  109. /package/dist/{chunk-L2OJUIII.js.map → chunk-RIRPLFPN.js.map} +0 -0
  110. /package/dist/{chunk-WYYUWBTS.js.map → chunk-TDMBTG7U.js.map} +0 -0
  111. /package/dist/{chunk-G7SKCXQG.js.map → chunk-TW3V6FSH.js.map} +0 -0
  112. /package/dist/{chunk-ZR3BPESP.js.map → chunk-VPSF5LEM.js.map} +0 -0
  113. /package/dist/{chunk-6H7D4QTM.js.map → chunk-W24TJJNN.js.map} +0 -0
  114. /package/dist/{chunk-BIVO2GMU.js.map → chunk-WDSTW3BD.js.map} +0 -0
  115. /package/dist/{chunk-RVKOFZAT.js.map → chunk-WJAFE3Z6.js.map} +0 -0
  116. /package/dist/{chunks-HPPVNSBT.js.map → chunks-AL4P5TO5.js.map} +0 -0
  117. /package/dist/{formula-6J26PNHL.js.map → formula-DSB574H7.js.map} +0 -0
  118. /package/dist/{formula-PNZX2ZAZ.js.map → formula-U2LZ67KI.js.map} +0 -0
  119. /package/dist/{image-ocr-UNTKJLQL.js.map → image-ocr-3QB2HLSI.js.map} +0 -0
  120. /package/dist/{image-ocr-RPHNFU7I.js.map → image-ocr-J54Q3YWP.js.map} +0 -0
  121. /package/dist/{model-bundle-ZSDEJFA7.js.map → model-bundle-CGWU4ALC.js.map} +0 -0
  122. /package/dist/{models-JS66XYKO.js.map → models-A3TF3BDV.js.map} +0 -0
  123. /package/dist/{parse-worker-v2-JHPEY3MI.js.map → parse-worker-v2-MNUD4WAR.js.map} +0 -0
  124. /package/dist/{parser-YKATDDQV.js.map → parser-C3ARF26I.js.map} +0 -0
  125. /package/dist/{parser-N64TUIWU.js.map → parser-OBGWEWSU.js.map} +0 -0
  126. /package/dist/{pdf-ocr-KTKR2JQH.js.map → pdf-ocr-ENLVEEYL.js.map} +0 -0
  127. /package/dist/{pdf-ocr-W3LDJYCA.js.map → pdf-ocr-K53REDNY.js.map} +0 -0
  128. /package/dist/{profile-io-JRODOL7A.js.map → profile-io-ZGFEO7CB.js.map} +0 -0
  129. /package/dist/{rasterize-2DMR7RGP.js.map → rasterize-QMC2SAUT.js.map} +0 -0
  130. /package/dist/{redact-doc-TC6QSTPM.js.map → redact-doc-JH6RZZBE.js.map} +0 -0
  131. /package/dist/{render-WEUU5EDS.js.map → render-ZGKQLKPJ.js.map} +0 -0
  132. /package/dist/{seal-LSALFURW.js.map → seal-KMGYTJAV.js.map} +0 -0
  133. /package/dist/{setup-LKJKGMKJ.js.map → setup-LAQGCYQ2.js.map} +0 -0
  134. /package/dist/{visual-PHZHJRY5.js.map → visual-4OYJFGXL.js.map} +0 -0
  135. /package/dist/{watch-HHFVXB3G.js.map → watch-7YPB4TKC.js.map} +0 -0
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  blocksToPages,
3
3
  bmpToPng,
4
4
  inlineImagesIntoMarkdown
5
- } from "./chunk-B77K6J3U.js";
5
+ } from "./chunk-3HN65YAL.js";
6
6
  import {
7
7
  parsePageRange
8
8
  } from "./chunk-V4BH5SRQ.js";
@@ -43,7 +43,7 @@ import {
43
43
  validateOcrOptions,
44
44
  visibleText,
45
45
  wrapScript
46
- } from "./chunk-G7SKCXQG.js";
46
+ } from "./chunk-TW3V6FSH.js";
47
47
  import {
48
48
  KordocError,
49
49
  OPTIONAL_DEP_INSTALL_HINT,
@@ -61,7 +61,7 @@ import {
61
61
  toArrayBuffer,
62
62
  unescapeHtml,
63
63
  unzipLimitBytes
64
- } from "./chunk-RVKOFZAT.js";
64
+ } from "./chunk-WJAFE3Z6.js";
65
65
 
66
66
  // src/plain-markdown.ts
67
67
  function toPlainMarkdown(md2) {
@@ -24620,7 +24620,7 @@ var MIN_SIDE = 24;
24620
24620
  async function ocrEmbeddedImages(blocks, options, warnings) {
24621
24621
  const ocr = options?.ocr;
24622
24622
  if (ocr !== true && ocr !== "force" && typeof ocr !== "function") return false;
24623
- const { parseImageDocument } = await import("./image-ocr-RPHNFU7I.js");
24623
+ const { parseImageDocument } = await import("./image-ocr-J54Q3YWP.js");
24624
24624
  let inserted = false, unreadable = 0;
24625
24625
  let failed = null;
24626
24626
  const walk = async (list, depth) => {
@@ -52462,7 +52462,7 @@ function tableColumnBoundaries(constraints, count, total, noExactRow = false) {
52462
52462
  const lp = longestPathBoundaries(constraints, count);
52463
52463
  return lp && Math.abs(lp.x[count] - total) <= 2 && (noExactRow || lp.x.every((v, k) => Math.abs(v - prop[k]) <= 2 || lp.tight[k])) ? lp.x : prop;
52464
52464
  }
52465
- function solveRowHeights(cells, rowCount, maxTotal = Number.POSITIVE_INFINITY) {
52465
+ function solveRowHeights(cells, rowCount, maxTotal = Number.POSITIVE_INFINITY, shrinkLast = false) {
52466
52466
  const h = new Array(rowCount).fill(0);
52467
52467
  for (const c of cells) {
52468
52468
  if (c.rowSpan === 1 && c.rowAddr >= 0 && c.rowAddr < rowCount) {
@@ -52509,6 +52509,9 @@ function solveRowHeights(cells, rowCount, maxTotal = Number.POSITIVE_INFINITY) {
52509
52509
  total += add;
52510
52510
  }
52511
52511
  }
52512
+ const last = rowCount - 1, over = total - maxTotal;
52513
+ const lastCells = cells.filter((c) => c.rowAddr + c.rowSpan - 1 === last);
52514
+ if (shrinkLast && over > 0 && last >= 0 && lastCells.length && lastCells.every((c) => c.rowSpan === 1 && c.contentH != null && c.contentH <= h[last] - over)) h[last] -= over;
52512
52515
  return h;
52513
52516
  }
52514
52517
 
@@ -52772,9 +52775,9 @@ function cellContentExtent(cell2, memo) {
52772
52775
  const pos = findChildByLocalName(o.el, "pos");
52773
52776
  if ((pos?.getAttribute("vertRelTo") ?? "PARA") !== "PARA") continue;
52774
52777
  const om = findChildByLocalName(o.el, "outMargin");
52775
- const pushed = baseV - (num2(om, "top") + o.height + num2(om, "bottom"));
52776
- const anchor = pushed >= (paraStart > 0 ? paraStart - 100 : -100) ? pushed : baseV - (memo?.paraGeom?.get(p.getAttribute("paraPrIDRef") ?? "")?.spaceBefore ?? 0);
52777
52778
  const vo = num2(pos, "vertOffset");
52779
+ const pushed = baseV - (Math.max(0, vo) + num2(om, "top") + o.height + num2(om, "bottom"));
52780
+ const anchor = pushed >= (paraStart > 0 ? paraStart - 100 : -100) ? pushed : baseV - (memo?.paraGeom?.get(p.getAttribute("paraPrIDRef") ?? "")?.spaceBefore ?? 0);
52778
52781
  const oh = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, memo)) : o.height;
52779
52782
  ext = Math.max(ext, anchor + num2(om, "top") + Math.max(0, vo) + oh);
52780
52783
  }
@@ -52820,6 +52823,21 @@ function collectCells(tbl2) {
52820
52823
  }
52821
52824
  return cells;
52822
52825
  }
52826
+ function inCell(el) {
52827
+ for (let n = el.parentNode; n; n = n.parentNode) if (ln(n) === "tc") return true;
52828
+ return false;
52829
+ }
52830
+ function splitSaved(c) {
52831
+ let prev = Number.NEGATIVE_INFINITY;
52832
+ for (const p of c.sub ? elements(c.sub) : []) {
52833
+ if (ln(p) !== "p") continue;
52834
+ for (const s of buildPara(p).segs) {
52835
+ if (s.vertpos < prev) return true;
52836
+ prev = s.vertpos;
52837
+ }
52838
+ }
52839
+ return false;
52840
+ }
52823
52841
  function measureTableRowHeights(tbl2, memo) {
52824
52842
  const cells = collectCells(tbl2);
52825
52843
  if (cells.length === 0 || cells.length > 4096) return [];
@@ -52830,7 +52848,8 @@ function measureTableRowHeights(tbl2, memo) {
52830
52848
  // (같은 판 PDF: 두 줄 든 2행 병합 칸 내용 2882 > 저장 2564 → 둘째 행이 318 자라고 첫 행은 그대로)
52831
52849
  cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: (c.rs > 1 ? Math.max(c.h, cellContentExtent(c, memo) + c.marginT + c.marginB) : c.h) - sp * (c.rs - 1), contentH: c.rs === 1 ? cellContentExtent(c, memo) + c.marginT + c.marginB : void 0 })),
52832
52850
  nRows,
52833
- num2(findChildByLocalName(tbl2, "sz"), "height") - (sp > 0 ? sp * (nRows + 1) : 0) || Number.POSITIVE_INFINITY
52851
+ num2(findChildByLocalName(tbl2, "sz"), "height") - (sp > 0 ? sp * (nRows + 1) : 0) || Number.POSITIVE_INFINITY,
52852
+ !inCell(tbl2) && !cells.some((c) => c.ra + c.rs === nRows && splitSaved(c))
52834
52853
  );
52835
52854
  if (sp > 0) {
52836
52855
  for (let r = 0; r < rows.length; r++) rows[r] += sp;
@@ -54790,7 +54809,8 @@ function planTableRows(tbl2, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan,
54790
54809
  rem = Math.max(rem, end - ls[k][0] + c.marginT + c.marginB);
54791
54810
  }
54792
54811
  if (allFit) {
54793
- if (!first && h <= pageBottom - contTop && rowCells.some((c) => cellContentExtent(c) + c.marginT + c.marginB > avail)) {
54812
+ const spanCells = cells.filter((c) => c.ra === r && c.rs > 1);
54813
+ if (!first && h <= pageBottom - contTop && [...rowCells, ...spanCells].some((c) => cellContentExtent(c) + c.marginT + c.marginB > avail)) {
54794
54814
  page++;
54795
54815
  y = contTop;
54796
54816
  first = true;
@@ -54988,9 +55008,11 @@ function shapeGeometry(o, boxX, boxY, defs, images, warn, local2 = false) {
54988
55008
  function linePushedBy(o, lineV, paraTop) {
54989
55009
  if (paraTop === void 0) return false;
54990
55010
  const om = findChildByLocalName(o.el, "outMargin");
54991
- return Math.abs(lineV - (num2(om, "top") + o.height + num2(om, "bottom")) - paraTop) <= 10;
55011
+ const pos = findChildByLocalName(o.el, "pos");
55012
+ const raw = num2(pos, "vertOffset"), vo = (pos?.getAttribute("vertRelTo") ?? "PARA") === "PARA" ? Math.max(0, raw >= 2 ** 31 ? raw - 2 ** 32 : raw) : 0;
55013
+ return Math.abs(lineV - (vo + num2(om, "top") + o.height + num2(om, "bottom")) - paraTop) <= 10;
54992
55014
  }
54993
- function anchorObject(o, ox, oy, baseV, areaW, ctx, anchorLineV, stayLine = false, paraStartV, laterLineH) {
55015
+ function anchorObject(o, ox, oy, baseV, areaW, ctx, anchorLineV, stayLine = false, paraStartV, lineH, lineSB = 0) {
54994
55016
  const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
54995
55017
  const pos = findChildByLocalName(o.el, "pos");
54996
55018
  const om = findChildByLocalName(o.el, "outMargin");
@@ -55012,13 +55034,14 @@ function anchorObject(o, ox, oy, baseV, areaW, ctx, anchorLineV, stayLine = fals
55012
55034
  y = va === "BOTTOM" ? MT + BODY_H - h - vo : va === "CENTER" ? MT + (BODY_H - h) / 2 + vo : MT + vo;
55013
55035
  } else if (wrap === "TOP_AND_BOTTOM") {
55014
55036
  const lineV = anchorLineV ?? baseV;
55015
- const pushed = lineV - (omT + h + omB);
55016
- const below = laterLineH !== void 0 && vo + omT >= laterLineH;
55017
- const anchor = below ? lineV : stayLine !== false ? lineV - stayLine : pushed >= -100 ? pushed : paraStartV !== void 0 ? paraStartV : lineV;
55037
+ const pushed = lineV - (vo + omT + h + omB);
55038
+ const below = lineH !== void 0 && vo + omT >= lineH && !(paraStartV !== void 0 && Math.abs(pushed - paraStartV) <= 10);
55039
+ const anchor = below ? lineV - lineSB : stayLine !== false ? lineV - stayLine : pushed >= -100 ? pushed : paraStartV !== void 0 ? paraStartV : lineV;
55018
55040
  y = oy + anchor + omT + vo;
55019
55041
  } else {
55020
55042
  const origin = vrel === "PARA" && wrap === "SQUARE" ? paraStartV ?? baseV : baseV;
55021
- y = oy + Math.max(origin + vo, wrap === "SQUARE" && anchorLineV !== void 0 ? anchorLineV : -Infinity) + omT;
55043
+ const later = vrel === "PARA" && wrap === "SQUARE" && anchorLineV !== void 0 && anchorLineV > baseV;
55044
+ y = later ? oy + anchorLineV + vo + omT : oy + Math.max(origin + vo, wrap === "SQUARE" && anchorLineV !== void 0 ? anchorLineV : -Infinity) + omT;
55022
55045
  }
55023
55046
  let x;
55024
55047
  const omL = num2(om, "left"), omR = num2(om, "right");
@@ -55317,6 +55340,7 @@ function planLines(m, styles, numText = "") {
55317
55340
  }
55318
55341
  if (fixedTo > start) fixedW = lineNaturalWidth(m, styles, start, fixedTo).text + [...tabs.values()].reduce((a, b) => a + b, 0);
55319
55342
  let textEnd = Math.min(end, m.chars.length);
55343
+ while (textEnd > fixedTo && m.chars[textEnd - 1].br) textEnd--;
55320
55344
  while (textEnd > fixedTo && m.chars[textEnd - 1].ch === " ") textEnd--;
55321
55345
  const nat = lineNaturalWidth(m, styles, fixedTo, textEnd);
55322
55346
  for (const o of m.objs) if (o.inline && o.index >= textEnd && o.index < end) nat.obj += o.omL + o.width + o.omR;
@@ -55536,6 +55560,7 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
55536
55560
  if (gOpenOn >= 0) ctx.pages[gOpenOn].push("</g>");
55537
55561
  if (paraRegionId) ctx.parentStack.push(paraRegionId);
55538
55562
  let tbStack;
55563
+ let tbStackTop;
55539
55564
  for (const o of m.objs) {
55540
55565
  if (o.inline) {
55541
55566
  let planIdx = 0;
@@ -55580,21 +55605,26 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
55580
55605
  const sbA = m.paraPrId != null ? ctx.styles.paraGeom.get(m.paraPrId)?.spaceBefore ?? 0 : 0;
55581
55606
  if (stay && wrapA === "TOP_AND_BOTTOM" && linePushedBy(o, anchorLineV ?? baseV, pTop ?? (depth > 0 ? cellParaTop(p, ctx.styles.paraGeom) : void 0))) stay = false;
55582
55607
  const firstLine = anchorLineV === void 0 || anchorLineV === baseV;
55583
- let { x, y } = anchorObject(o, ax, oy, objBaseV, aw, ctx, anchorLineV, stay ? sbA : false, (firstLine || wrapA === "SQUARE") && pTop !== void 0 && pTop < baseV ? pTop : void 0, firstLine ? void 0 : anchorLineH);
55584
- if (depth === 0 && tbFloats >= 2 && wrapA === "TOP_AND_BOTTOM") {
55608
+ let { x, y } = anchorObject(o, ax, oy, objBaseV, aw, ctx, anchorLineV, stay ? sbA : false, (firstLine || wrapA === "SQUARE") && pTop !== void 0 && pTop < baseV ? pTop : void 0, anchorLineH, firstLine ? sbA : 0);
55609
+ let stackTop = depth === 0 ? pTop ?? 0 : cellParaTop(p, ctx.styles.paraGeom);
55610
+ if (tbFloats >= 2 && wrapA === "TOP_AND_BOTTOM" && stackTop !== void 0) {
55585
55611
  if (!tbStack) {
55586
55612
  tbStack = /* @__PURE__ */ new Map();
55587
- let below = 0;
55613
+ const placed = [];
55588
55614
  const stackable = m.objs.filter((q) => !q.inline && (q.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM" && (findChildByLocalName(q.el, "pos")?.getAttribute("vertRelTo") ?? "PARA") === "PARA" && findChildByLocalName(q.el, "pos")?.getAttribute("allowOverlap") !== "1");
55589
55615
  for (const q of stackable.length >= 2 ? stackable.sort((a, b) => a.index - b.index) : []) {
55590
- const omQ = findChildByLocalName(q.el, "outMargin"), raw = num2(findChildByLocalName(q.el, "pos"), "vertOffset");
55591
- const top = Math.max(below, raw >= 2 ** 31 ? raw - 2 ** 32 : raw);
55616
+ const posQ = findChildByLocalName(q.el, "pos"), omQ = findChildByLocalName(q.el, "outMargin"), raw = num2(posQ, "vertOffset");
55617
+ const x0 = num2(posQ, "horzOffset"), x1 = x0 + num2(omQ, "left") + q.width + num2(omQ, "right");
55618
+ const below = Math.max(0, ...placed.filter((r) => r.x0 < x1 && x0 < r.x1).map((r) => r.bottom));
55619
+ const top = Math.max(below, depth > 0 ? Math.max(0, raw) : raw);
55592
55620
  tbStack.set(q.el, top + num2(omQ, "top"));
55593
- below = top + num2(omQ, "top") + (q.tag === "tbl" ? Math.max(q.height, measureTableHeight(q.el, ctx.extentMemo)) : q.height) + num2(omQ, "bottom");
55621
+ placed.push({ x0, x1, bottom: top + num2(omQ, "top") + (q.tag === "tbl" ? Math.max(q.height, measureTableHeight(q.el, ctx.extentMemo)) : q.height) + num2(omQ, "bottom") });
55594
55622
  }
55623
+ if (depth > 0 && placed.length) tbStackTop = Math.max(stackTop, baseV - Math.max(...placed.map((r) => r.bottom)));
55595
55624
  }
55625
+ if (depth > 0 && tbStackTop !== void 0) stackTop = tbStackTop;
55596
55626
  const st = tbStack.get(o.el);
55597
- if (st !== void 0) y = oy + (pTop ?? 0) + st;
55627
+ if (st !== void 0) y = oy + stackTop + st;
55598
55628
  }
55599
55629
  const moved = ctx.objPlace?.get(o.el);
55600
55630
  if (moved) {
@@ -55817,7 +55847,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
55817
55847
  const slack = ctx.geom.PH - ctx.geom.MT - ctx.geom.BODY_H;
55818
55848
  const splitHere = depth === 1 || !!ctx.splitCell && findChildByLocalName(tbl2, "pos")?.getAttribute("treatAsChar") !== "1";
55819
55849
  const plan = splitHere ? planTableRows(tbl2, cells, rowH, ty, ctx.geom.MT, ctx.geom.BODY_H, slack, cellFloatSpan(ctx.geom.MT, ctx.geom.BODY_H, ctx.extentMemo, slack), depth !== 1, depth !== 1 && ctx.splitContMT !== void 0 ? ctx.splitContMT : ctx.geom.MT) : rowH.map((h, r) => [{ page: 0, y: ty + rowY[r], h }]);
55820
- const splitSaved = ctx.splitCell;
55850
+ const splitSaved2 = ctx.splitCell;
55821
55851
  ctx.splitCell = false;
55822
55852
  for (const pc of plan.flat()) for (const [el, py] of pc.place ?? []) (ctx.objPlace ??= /* @__PURE__ */ new Map()).set(el, { page: startPage + pc.page, y: py });
55823
55853
  const contPages = [...new Set(plan.flat().map((pc) => pc.page).filter((pg) => pg > 0))].map((pg) => startPage + pg);
@@ -55937,7 +55967,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
55937
55967
  if (bf.right) emit(ctx, edgeLine(g3.x + g3.w, g3.y, g3.x + g3.w, g3.y + g3.h, bf.right));
55938
55968
  }
55939
55969
  ctx.page = startPage;
55940
- ctx.splitCell = splitSaved;
55970
+ ctx.splitCell = splitSaved2;
55941
55971
  ctx.parentStack.pop();
55942
55972
  emit(ctx, "</g>");
55943
55973
  }
@@ -56096,6 +56126,7 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
56096
56126
  }
56097
56127
  const paraSegPages = /* @__PURE__ */ new Map();
56098
56128
  const paraTops = /* @__PURE__ */ new Map();
56129
+ const backPlace = /* @__PURE__ */ new Map();
56099
56130
  const geom0 = ctxBase.styles.paraGeom;
56100
56131
  let tableEndPage = -1;
56101
56132
  let nPages = 1;
@@ -56107,6 +56138,7 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
56107
56138
  let cur = 0, col = 0;
56108
56139
  let pendingEnd = 0, pendingEndY = 0;
56109
56140
  let lastEnd = 0, lastPage = -1;
56141
+ let lastSA = 0;
56110
56142
  let prevSeg;
56111
56143
  for (const p of elements(root)) {
56112
56144
  if (ln(p) !== "p") continue;
@@ -56144,6 +56176,7 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
56144
56176
  if (prevSeg.p !== p) {
56145
56177
  lastPage = cur;
56146
56178
  lastEnd = v;
56179
+ lastSA = 0;
56147
56180
  }
56148
56181
  }
56149
56182
  }
@@ -56157,11 +56190,13 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
56157
56190
  prevEnd = v + num2(s, "vertsize") + num2(s, "spacing");
56158
56191
  }
56159
56192
  paraSegPages.set(p, pagesOf);
56160
- if (segEls.length) paraTops.set(p, pagesOf[0] === lastPage ? lastEnd : 0);
56193
+ const prevEnd0 = lastEnd, prevPage0 = lastPage;
56194
+ if (segEls.length) paraTops.set(p, pagesOf[0] === lastPage ? lastEnd + lastSA : 0);
56161
56195
  if (segEls.length) {
56162
56196
  const ls = segEls[segEls.length - 1];
56163
56197
  lastEnd = num2(ls, "vertpos") + num2(ls, "vertsize") + num2(ls, "spacing");
56164
56198
  lastPage = pagesOf[pagesOf.length - 1];
56199
+ lastSA = geom0.get(p.getAttribute("paraPrIDRef") ?? "")?.spaceAfter ?? 0;
56165
56200
  }
56166
56201
  if (!localCols && segEls.length) {
56167
56202
  const m0 = buildPara(p);
@@ -56173,6 +56208,13 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
56173
56208
  const segV = num2(segEls[segK], "vertpos");
56174
56209
  const h = Math.max(o.height, measureTableHeight(o.el, ctxBase.extentMemo)), omT = num2(om, "top"), omB = num2(om, "bottom");
56175
56210
  const pushed = segV - (omT + h + omB);
56211
+ if (!o.inline && segK === 0 && pushed < -100 && prevPage0 >= 0 && pagesOf[0] === prevPage0 + 1 && (o.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM") {
56212
+ const back = tableContPages(o.el, MT + prevEnd0 + omT, MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H, cellFloatSpan(MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H));
56213
+ if (back.pages === 1 && Math.abs(back.endY - MT + omB - segV) <= 300) {
56214
+ backPlace.set(o.el, { page: prevPage0, y: MT + prevEnd0 + omT });
56215
+ continue;
56216
+ }
56217
+ }
56176
56218
  const nTb = m0.objs.filter((q) => !q.inline && (q.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM").length;
56177
56219
  const wrapP = o.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM";
56178
56220
  const pTop = paraTops.get(p), sbP = m0.paraPrId != null ? geom0.get(m0.paraPrId)?.spaceBefore ?? 0 : 0;
@@ -56180,7 +56222,8 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
56180
56222
  const nonPush = wrapP !== "TOP_AND_BOTTOM" && pTop !== void 0 && segV > pTop + sbP + 100 ? pTop + sbP : void 0;
56181
56223
  const voP = Math.max(0, toInt32(pos?.getAttribute("vertOffset") ?? void 0, 0));
56182
56224
  const paraStart = segK === 0 && pTop !== void 0 && pTop < segV ? pTop : segV;
56183
- const ty = o.inline ? MT + segV + omT : nonPush !== void 0 ? MT + nonPush + omT + voP : MT + (stay ? segV - sbP : pushed >= -100 ? pushed : paraStart) + omT + voP;
56225
+ const below = !o.inline && wrapP === "TOP_AND_BOTTOM" && voP + omT >= num2(segEls[segK], "textheight") && !linePushedBy(o, segV, pTop);
56226
+ const ty = o.inline ? MT + segV + omT : nonPush !== void 0 ? MT + nonPush + omT + voP : MT + (below ? segV - (segK === 0 ? sbP : 0) : stay ? segV - sbP : pushed - voP >= -100 ? pushed - voP : paraStart) + omT + voP;
56184
56227
  const span2 = tableContPages(o.el, ty, MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H, cellFloatSpan(MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H));
56185
56228
  const anchorPage = pagesOf[segK];
56186
56229
  const sp = !o.inline && !stay && nonPush === void 0 && segV - (omT + o.height + omB) >= -100 && pagesOf.some((pg, j) => j > segK && pg > anchorPage) ? tableContPages(o.el, MT + segV - o.height - omB, MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H, cellFloatSpan(MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H)) : void 0;
@@ -56265,6 +56308,7 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
56265
56308
  if (geom.mirrorDx) ctx.bodyDx = mirrorDx;
56266
56309
  ctx.cols = multiCol ? { w: colW, gap: colGap } : void 0;
56267
56310
  ctx.paraTops = paraTops;
56311
+ if (backPlace.size) ctx.objPlace = new Map([...ctx.objPlace ?? [], ...backPlace]);
56268
56312
  for (const p of elements(root)) {
56269
56313
  if (ln(p) !== "p") continue;
56270
56314
  drawPara(p, ML, MT, BODY_W, ctx, 0, paraSegPages.get(p));
@@ -56384,7 +56428,7 @@ function drawPageNumbers(root, paraPages, ctx) {
56384
56428
  const side = decl.el.getAttribute("sideChar") ?? "";
56385
56429
  const pnId = ctx.styles.pageNumCharPr ?? decl.prId;
56386
56430
  const st = (pnId != null ? ctx.styles.charPr.get(pnId) : void 0) ?? DEFAULT_CHAR;
56387
- const { PW, PH, ML, BODY_W } = ctx.geom;
56431
+ const { PH, ML, BODY_W } = ctx.geom;
56388
56432
  const pagePr = findFirst(root, "pagePr"), margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
56389
56433
  const h = 1e3;
56390
56434
  for (let page = decl.page; page < ctx.pages.length; page++) {
@@ -56392,7 +56436,7 @@ function drawPageNumbers(root, paraPages, ctx) {
56392
56436
  const n = ctx.pageBase + page + 1;
56393
56437
  const text = side ? `${side} ${formatHeadNumber2(n, decl.el.getAttribute("formatType") ?? "DIGIT")} ${side}` : formatHeadNumber2(n, decl.el.getAttribute("formatType") ?? "DIGIT");
56394
56438
  const w = measureTextWidth(text, h, 100, { faceClass: faceClassOf(st.face) });
56395
- const x = /LEFT/.test(pos) ? ML : /RIGHT/.test(pos) ? ML + BODY_W - w : (PW - w) / 2;
56439
+ const x = /LEFT/.test(pos) ? ML : /RIGHT/.test(pos) ? ML + BODY_W - w : ML + (BODY_W - w) / 2;
56396
56440
  const y = /^TOP/.test(pos) ? num2(margin, "top", 5668) - 225 : num2(margin, "footer", 0) > 0 ? PH - num2(margin, "bottom", 4252) - 225 : PH - Math.round(num2(margin, "bottom", 4252) / 2) - 243;
56397
56441
  const attrs = [`x="${pt2(x)}"`, `y="${pt2(y)}"`, `font-size="${pt2(h)}"`];
56398
56442
  if (st.fontFamily) attrs.push(`font-family="${escapeXml7(st.fontFamily)}"`);
@@ -57561,7 +57605,7 @@ function scriptsOff(r, off) {
57561
57605
  }
57562
57606
  async function parseImage(buffer, options) {
57563
57607
  try {
57564
- const { parseImageDocument } = await import("./image-ocr-RPHNFU7I.js");
57608
+ const { parseImageDocument } = await import("./image-ocr-J54Q3YWP.js");
57565
57609
  const { blocks, warnings, lines } = await parseImageDocument(buffer, options);
57566
57610
  stripScriptTags({ blocks });
57567
57611
  return {
@@ -57625,7 +57669,7 @@ async function parseHwp(buffer, options) {
57625
57669
  async function parsePdf(buffer, options) {
57626
57670
  let parsePdfDocument;
57627
57671
  try {
57628
- const mod = await import("./parser-N64TUIWU.js");
57672
+ const mod = await import("./parser-OBGWEWSU.js");
57629
57673
  parsePdfDocument = mod.parsePdfDocument;
57630
57674
  } catch {
57631
57675
  return {