kordoc 4.22.12 → 4.22.14

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 (122) hide show
  1. package/README.md +7 -5
  2. package/dist/{-KQIWF7GR.js → -AF5OVQ2B.js} +11 -11
  3. package/dist/{chunk-A7ZUDINW.js → chunk-2HLWRP2W.js} +2 -2
  4. package/dist/{chunk-P32MSVJI.js → chunk-5IWMX3MX.js} +2 -2
  5. package/dist/{chunk-45GOHDHP.js → chunk-634XJS2B.js} +2 -2
  6. package/dist/{chunk-O7F6PWT4.js → chunk-6LKB7UWJ.js} +2 -2
  7. package/dist/{chunk-S2B4CTQT.js → chunk-AA7VSDW7.js} +3 -3
  8. package/dist/{chunk-L3WMBMDN.js → chunk-DERMNCUV.js} +2 -2
  9. package/dist/{chunk-RDWNQARC.js → chunk-DWP5CLVR.js} +2 -2
  10. package/dist/{chunk-FX6Y3N4K.js → chunk-EAUI4MGW.js} +4 -4
  11. package/dist/{chunk-5WOYDR7R.js → chunk-EMC23F72.js} +4 -4
  12. package/dist/{chunk-VVU45ET4.cjs → chunk-F4IXPKBU.cjs} +6 -6
  13. package/dist/{chunk-VVU45ET4.cjs.map → chunk-F4IXPKBU.cjs.map} +1 -1
  14. package/dist/{chunk-LYZGZMLW.js → chunk-FJ5RGHZW.js} +12 -12
  15. package/dist/chunk-FJ5RGHZW.js.map +1 -0
  16. package/dist/{chunk-NFLXHIF7.js → chunk-FN462MNZ.js} +4 -4
  17. package/dist/{chunk-TFYEKMLY.js → chunk-FNF3IGCT.js} +2 -2
  18. package/dist/{chunk-C7E5WHUJ.js → chunk-H2J3WNB3.js} +3 -3
  19. package/dist/{chunk-52XK5GKO.js → chunk-IE6LE6W3.js} +2 -2
  20. package/dist/{chunk-BU7SJLB4.js → chunk-JKSHF4LV.js} +3 -3
  21. package/dist/{chunk-EZIUU32T.cjs → chunk-KNG6HPBO.cjs} +2 -2
  22. package/dist/{chunk-EZIUU32T.cjs.map → chunk-KNG6HPBO.cjs.map} +1 -1
  23. package/dist/{chunk-X4EYUXOV.js → chunk-LVKASU3G.js} +2 -2
  24. package/dist/{chunk-KXHVDSXA.cjs → chunk-M6LVRVKB.cjs} +3 -3
  25. package/dist/{chunk-KXHVDSXA.cjs.map → chunk-M6LVRVKB.cjs.map} +1 -1
  26. package/dist/{chunk-BTRNHZWT.js → chunk-NMA5P7SJ.js} +2 -2
  27. package/dist/{chunk-RWHOVUUS.js → chunk-PFVDY2EK.js} +2 -2
  28. package/dist/{chunk-D4QSFRKK.js → chunk-PHULZF6L.js} +2 -2
  29. package/dist/{chunk-GHTV5OON.cjs → chunk-SHJPQ3QB.cjs} +23 -23
  30. package/dist/{chunk-GHTV5OON.cjs.map → chunk-SHJPQ3QB.cjs.map} +1 -1
  31. package/dist/{chunk-5YGTRWCN.js → chunk-SXSBYB4M.js} +74 -17
  32. package/dist/chunk-SXSBYB4M.js.map +1 -0
  33. package/dist/{chunk-HR5OB3PJ.js → chunk-THAL2XH4.js} +2 -2
  34. package/dist/{chunk-X26KQYRU.cjs → chunk-TMJJKLNC.cjs} +24 -24
  35. package/dist/{chunk-X26KQYRU.cjs.map → chunk-TMJJKLNC.cjs.map} +1 -1
  36. package/dist/{chunk-CLVIG2P5.cjs → chunk-WHNF67YI.cjs} +3 -3
  37. package/dist/{chunk-CLVIG2P5.cjs.map → chunk-WHNF67YI.cjs.map} +1 -1
  38. package/dist/{chunk-6DIUB4XS.js → chunk-WQWOCG53.js} +2 -2
  39. package/dist/{chunk-JHWISUYV.js → chunk-YDKJZF5L.js} +2 -2
  40. package/dist/chunks-75SH4S3P.js +10 -0
  41. package/dist/cli.js +30 -30
  42. package/dist/{formula-NG3YI7AK.cjs → formula-4AJAVAWT.cjs} +9 -9
  43. package/dist/{formula-NG3YI7AK.cjs.map → formula-4AJAVAWT.cjs.map} +1 -1
  44. package/dist/{formula-2QCZI77K.js → formula-HUREVQCI.js} +4 -4
  45. package/dist/{formula-DYNRSHYF.js → formula-UBZCYRF4.js} +3 -3
  46. package/dist/{image-ocr-TQB7UVGP.js → image-ocr-3R2YM67Q.js} +9 -9
  47. package/dist/{image-ocr-P7YLKRUT.cjs → image-ocr-DTZWQOQL.cjs} +17 -17
  48. package/dist/{image-ocr-P7YLKRUT.cjs.map → image-ocr-DTZWQOQL.cjs.map} +1 -1
  49. package/dist/{image-ocr-7D5KQUCQ.js → image-ocr-PJT3Z4YE.js} +6 -6
  50. package/dist/index.cjs +393 -336
  51. package/dist/index.cjs.map +1 -1
  52. package/dist/index.js +75 -18
  53. package/dist/index.js.map +1 -1
  54. package/dist/mcp.js +22 -22
  55. package/dist/{model-bundle-KSCQNHCC.js → model-bundle-37BM65SF.js} +5 -5
  56. package/dist/{models-FL5TCXCT.js → models-SINSBMMS.js} +5 -5
  57. package/dist/{parse-worker-v2-EAGA4B4A.js → parse-worker-v2-XZE6G3YZ.js} +12 -12
  58. package/dist/{parser-LJE3SCND.cjs → parser-7NEY6KUC.cjs} +157 -157
  59. package/dist/{parser-LJE3SCND.cjs.map → parser-7NEY6KUC.cjs.map} +1 -1
  60. package/dist/{parser-DANL24BN.js → parser-BN6SMWKJ.js} +12 -12
  61. package/dist/{parser-I7LDZPKR.js → parser-PYLI2HSC.js} +9 -9
  62. package/dist/{pdf-ocr-C3ZLE47I.js → pdf-ocr-2O7FQ6JB.js} +6 -6
  63. package/dist/{pdf-ocr-MWQTRCXQ.js → pdf-ocr-472YHMNQ.js} +9 -9
  64. package/dist/pdf-ocr-W5UAELPX.cjs +31 -0
  65. package/dist/{pdf-ocr-P6TG2KCD.cjs.map → pdf-ocr-W5UAELPX.cjs.map} +1 -1
  66. package/dist/{profile-io-Z5I6I6KS.js → profile-io-KENW2S4U.js} +3 -3
  67. package/dist/{rasterize-HTNSO4VK.js → rasterize-CDGVIXWB.js} +3 -3
  68. package/dist/{redact-doc-C2PNNX47.js → redact-doc-LGIC27QL.js} +11 -11
  69. package/dist/{render-AFFWMWKU.js → render-4WB6VKAI.js} +7 -7
  70. package/dist/seal-V6YQIAUC.js +10 -0
  71. package/dist/{setup-GJKNGTRT.js → setup-RNR35MKP.js} +3 -3
  72. package/dist/visual-ZZZ65FH6.js +21 -0
  73. package/dist/{watch-F7W4ZM6Q.js → watch-VLHG2G5B.js} +12 -12
  74. package/package.json +1 -1
  75. package/dist/chunk-5YGTRWCN.js.map +0 -1
  76. package/dist/chunk-LYZGZMLW.js.map +0 -1
  77. package/dist/chunks-6V34GQOS.js +0 -10
  78. package/dist/pdf-ocr-P6TG2KCD.cjs +0 -31
  79. package/dist/seal-PBREQDNO.js +0 -10
  80. package/dist/visual-HTE3YLPV.js +0 -21
  81. /package/dist/{-KQIWF7GR.js.map → -AF5OVQ2B.js.map} +0 -0
  82. /package/dist/{chunk-A7ZUDINW.js.map → chunk-2HLWRP2W.js.map} +0 -0
  83. /package/dist/{chunk-P32MSVJI.js.map → chunk-5IWMX3MX.js.map} +0 -0
  84. /package/dist/{chunk-45GOHDHP.js.map → chunk-634XJS2B.js.map} +0 -0
  85. /package/dist/{chunk-O7F6PWT4.js.map → chunk-6LKB7UWJ.js.map} +0 -0
  86. /package/dist/{chunk-S2B4CTQT.js.map → chunk-AA7VSDW7.js.map} +0 -0
  87. /package/dist/{chunk-L3WMBMDN.js.map → chunk-DERMNCUV.js.map} +0 -0
  88. /package/dist/{chunk-RDWNQARC.js.map → chunk-DWP5CLVR.js.map} +0 -0
  89. /package/dist/{chunk-FX6Y3N4K.js.map → chunk-EAUI4MGW.js.map} +0 -0
  90. /package/dist/{chunk-5WOYDR7R.js.map → chunk-EMC23F72.js.map} +0 -0
  91. /package/dist/{chunk-NFLXHIF7.js.map → chunk-FN462MNZ.js.map} +0 -0
  92. /package/dist/{chunk-TFYEKMLY.js.map → chunk-FNF3IGCT.js.map} +0 -0
  93. /package/dist/{chunk-C7E5WHUJ.js.map → chunk-H2J3WNB3.js.map} +0 -0
  94. /package/dist/{chunk-52XK5GKO.js.map → chunk-IE6LE6W3.js.map} +0 -0
  95. /package/dist/{chunk-BU7SJLB4.js.map → chunk-JKSHF4LV.js.map} +0 -0
  96. /package/dist/{chunk-X4EYUXOV.js.map → chunk-LVKASU3G.js.map} +0 -0
  97. /package/dist/{chunk-BTRNHZWT.js.map → chunk-NMA5P7SJ.js.map} +0 -0
  98. /package/dist/{chunk-RWHOVUUS.js.map → chunk-PFVDY2EK.js.map} +0 -0
  99. /package/dist/{chunk-D4QSFRKK.js.map → chunk-PHULZF6L.js.map} +0 -0
  100. /package/dist/{chunk-HR5OB3PJ.js.map → chunk-THAL2XH4.js.map} +0 -0
  101. /package/dist/{chunk-6DIUB4XS.js.map → chunk-WQWOCG53.js.map} +0 -0
  102. /package/dist/{chunk-JHWISUYV.js.map → chunk-YDKJZF5L.js.map} +0 -0
  103. /package/dist/{chunks-6V34GQOS.js.map → chunks-75SH4S3P.js.map} +0 -0
  104. /package/dist/{formula-2QCZI77K.js.map → formula-HUREVQCI.js.map} +0 -0
  105. /package/dist/{formula-DYNRSHYF.js.map → formula-UBZCYRF4.js.map} +0 -0
  106. /package/dist/{image-ocr-TQB7UVGP.js.map → image-ocr-3R2YM67Q.js.map} +0 -0
  107. /package/dist/{image-ocr-7D5KQUCQ.js.map → image-ocr-PJT3Z4YE.js.map} +0 -0
  108. /package/dist/{model-bundle-KSCQNHCC.js.map → model-bundle-37BM65SF.js.map} +0 -0
  109. /package/dist/{models-FL5TCXCT.js.map → models-SINSBMMS.js.map} +0 -0
  110. /package/dist/{parse-worker-v2-EAGA4B4A.js.map → parse-worker-v2-XZE6G3YZ.js.map} +0 -0
  111. /package/dist/{parser-DANL24BN.js.map → parser-BN6SMWKJ.js.map} +0 -0
  112. /package/dist/{parser-I7LDZPKR.js.map → parser-PYLI2HSC.js.map} +0 -0
  113. /package/dist/{pdf-ocr-C3ZLE47I.js.map → pdf-ocr-2O7FQ6JB.js.map} +0 -0
  114. /package/dist/{pdf-ocr-MWQTRCXQ.js.map → pdf-ocr-472YHMNQ.js.map} +0 -0
  115. /package/dist/{profile-io-Z5I6I6KS.js.map → profile-io-KENW2S4U.js.map} +0 -0
  116. /package/dist/{rasterize-HTNSO4VK.js.map → rasterize-CDGVIXWB.js.map} +0 -0
  117. /package/dist/{redact-doc-C2PNNX47.js.map → redact-doc-LGIC27QL.js.map} +0 -0
  118. /package/dist/{render-AFFWMWKU.js.map → render-4WB6VKAI.js.map} +0 -0
  119. /package/dist/{seal-PBREQDNO.js.map → seal-V6YQIAUC.js.map} +0 -0
  120. /package/dist/{setup-GJKNGTRT.js.map → setup-RNR35MKP.js.map} +0 -0
  121. /package/dist/{visual-HTE3YLPV.js.map → visual-ZZZ65FH6.js.map} +0 -0
  122. /package/dist/{watch-F7W4ZM6Q.js.map → watch-VLHG2G5B.js.map} +0 -0
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  loadSharp,
4
4
  rasterizePageSvg
5
- } from "./chunk-RWHOVUUS.js";
5
+ } from "./chunk-PFVDY2EK.js";
6
6
  import {
7
7
  inlineImagesIntoMarkdown
8
8
  } from "./chunk-VKVDMH7X.js";
@@ -16,7 +16,7 @@ import {
16
16
  HEADING_RATIO_H3,
17
17
  tidyScriptTags,
18
18
  unframeLayoutTables
19
- } from "./chunk-TFYEKMLY.js";
19
+ } from "./chunk-FNF3IGCT.js";
20
20
  import {
21
21
  MAX_COLS,
22
22
  MAX_ROWS,
@@ -32,7 +32,7 @@ import {
32
32
  mapPuaText,
33
33
  markNonLayoutTable,
34
34
  romanNumeral
35
- } from "./chunk-L3WMBMDN.js";
35
+ } from "./chunk-DERMNCUV.js";
36
36
  import {
37
37
  DEFAULT_CHAR,
38
38
  DEFAULT_PARA_GEOM,
@@ -46,7 +46,7 @@ import {
46
46
  hwpxAppMajor,
47
47
  parseRenderStyles,
48
48
  readZipEntry
49
- } from "./chunk-52XK5GKO.js";
49
+ } from "./chunk-IE6LE6W3.js";
50
50
  import {
51
51
  KordocError,
52
52
  compareSectionPaths,
@@ -54,7 +54,7 @@ import {
54
54
  precheckZipSize,
55
55
  sanitizeHref,
56
56
  toArrayBuffer
57
- } from "./chunk-D4QSFRKK.js";
57
+ } from "./chunk-PHULZF6L.js";
58
58
 
59
59
  // src/render/svg-render.ts
60
60
  import JSZip from "jszip";
@@ -10784,11 +10784,11 @@ function cjkWidthEm1000(cp) {
10784
10784
  function fixedPitchWidthEm1000(cp) {
10785
10785
  return cp < 128 || isHalfwidthForm(cp) ? 500 : 1e3;
10786
10786
  }
10787
- var PUA_FULL = /* @__PURE__ */ new Set([983729, 983730, 983731, 983732, 983733, 983734, 983803]);
10787
+ var isPuaFull = (cp) => cp <= 983803 || cp >= 983903 && cp <= 984052;
10788
10788
  function widthFnOf(faceClass, fallback = true) {
10789
10789
  const base = baseWidthFnOf(faceClass, fallback);
10790
10790
  const hcr = faceClass === "hcr" || faceClass === "font:\uD568\uCD08\uB86C\uB3CB\uC6C0" || faceClass === "font:\uD568\uCD08\uB86C\uBC14\uD0D5";
10791
- const f = (cp) => cp >= 983040 ? PUA_FULL.has(cp) ? 1e3 : 500 : cp === 61600 ? base(32) : !hcr && cp >= 10102 && cp <= 10131 ? 1e3 : base(cp);
10791
+ const f = (cp) => cp >= 983040 ? isPuaFull(cp) ? 1e3 : 500 : cp === 61600 ? base(32) : !hcr && cp >= 10102 && cp <= 10131 ? 1e3 : base(cp);
10792
10792
  if (fallback && (faceClass === "fixedPitch" || faceClass === "cjk")) return (cp) => isZeroWidthCp(cp) ? 0 : HANCOM_FALLBACK_W[cp] ?? f(cp);
10793
10793
  return (cp) => isZeroWidthCp(cp) ? 0 : f(cp);
10794
10794
  }
@@ -11304,6 +11304,7 @@ function buildPara(p) {
11304
11304
  let segs = [];
11305
11305
  const runs = [];
11306
11306
  let deleted = deletedStarts.get(p) ?? 0;
11307
+ let secSlots = 0;
11307
11308
  for (const runEl of elements(p)) {
11308
11309
  const tag = ln(runEl);
11309
11310
  if (tag === "run") {
@@ -11340,7 +11341,8 @@ function buildPara(p) {
11340
11341
  } else {
11341
11342
  if (cn === "ctrl" || cn === "deleteBegin" || cn === "deleteEnd") deleted = deletionDelta(ch, deleted);
11342
11343
  pushFillers(chars, 8, prId);
11343
- if (cn !== "secPr" && !(cn === "ctrl" && findChildByLocalName(ch, "colPr"))) {
11344
+ if (cn === "secPr" || cn === "ctrl" && findChildByLocalName(ch, "colPr")) secSlots += 8;
11345
+ else {
11344
11346
  const slot = chars[chars.length - 8];
11345
11347
  slot.ctrl = true;
11346
11348
  const an = cn === "ctrl" ? findChildByLocalName(ch, "autoNum") : null;
@@ -11365,6 +11367,11 @@ function buildPara(p) {
11365
11367
  });
11366
11368
  }
11367
11369
  }
11370
+ if (secSlots > 0 && segs.length > 1) {
11371
+ let lead = 0;
11372
+ while (lead < chars.length && chars[lead].ch === "" && !chars[lead].ctrl && !objs.some((o) => o.index === lead)) lead++;
11373
+ if (segs.slice(1).some((s) => s.textpos < lead)) segs = segs.map((s, k) => k > 0 ? { ...s, textpos: s.textpos + secSlots } : s);
11374
+ }
11368
11375
  return { chars, segs, objs, paraPrId: p.getAttribute("paraPrIDRef"), runs };
11369
11376
  }
11370
11377
  function captionOf(el) {
@@ -11412,6 +11419,7 @@ function cellContentExtent(cell, memo) {
11412
11419
  for (const p of elements(cell.sub)) {
11413
11420
  if (ln(p) !== "p") continue;
11414
11421
  const m = buildPara(p);
11422
+ const paraStart = prevEnd;
11415
11423
  let firstShift = shift;
11416
11424
  const lineTops = [];
11417
11425
  m.segs.forEach((s, k) => {
@@ -11436,9 +11444,10 @@ function cellContentExtent(cell, memo) {
11436
11444
  if ((pos?.getAttribute("vertRelTo") ?? "PARA") !== "PARA") continue;
11437
11445
  const om = findChildByLocalName(o.el, "outMargin");
11438
11446
  const pushed = baseV - (num(om, "top") + o.height + num(om, "bottom"));
11439
- const anchor = pushed >= -100 ? pushed : baseV - (memo?.paraGeom?.get(p.getAttribute("paraPrIDRef") ?? "")?.spaceBefore ?? 0);
11447
+ const anchor = pushed >= (paraStart > 0 ? paraStart - 100 : -100) ? pushed : baseV - (memo?.paraGeom?.get(p.getAttribute("paraPrIDRef") ?? "")?.spaceBefore ?? 0);
11440
11448
  const vo = num(pos, "vertOffset");
11441
- ext = Math.max(ext, anchor + num(om, "top") + Math.max(0, vo) + o.height);
11449
+ const oh = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, memo)) : o.height;
11450
+ ext = Math.max(ext, anchor + num(om, "top") + Math.max(0, vo) + oh);
11442
11451
  }
11443
11452
  }
11444
11453
  memo?.cell.set(cell.el, ext);
@@ -13265,6 +13274,11 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13265
13274
  const st = stackedFloats(rc[0]);
13266
13275
  return st.length >= 2 && st.reduce((a, f) => a + f.h, 0) > h;
13267
13276
  });
13277
+ if (slack > 0 && ty + rowY[nRows] > pageBottom && ty + rowY[nRows] <= pageBottom + slack && cells.some((c) => cellLineBoxes(c).some((b) => b.part > 0))) slack = 0;
13278
+ if (slack > 0 && ty + rowY[nRows] > pageBottom && ty + rowY[nRows] <= pageBottom + slack) {
13279
+ const declared = num(findChildByLocalName(tbl, "sz"), "height");
13280
+ if (rowY.some((v, k) => k > 0 && k < nRows && Math.abs(v - declared) <= 2)) slack = 0;
13281
+ }
13268
13282
  if (BODY_H <= 0 || ty + rowY[nRows] <= pageBottom + slack && !stackOver) return plain();
13269
13283
  if (findChildByLocalName(tbl, "pos")?.getAttribute("treatAsChar") === "1") {
13270
13284
  const declared = num(findChildByLocalName(tbl, "sz"), "height") || rowY[nRows];
@@ -13315,6 +13329,14 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13315
13329
  const boxes = splittable ? new Map(rowCells.map((c) => [c.el, cellLineBoxes(c)])) : void 0;
13316
13330
  const hParts = boxes ? Math.max(0, ...[...boxes.values()].flatMap((bs) => bs.map((b) => b.part))) : 0;
13317
13331
  if (boxes && hParts > 0) {
13332
+ if (!first && rowCells.some((c) => {
13333
+ const b = (boxes.get(c.el) ?? []).find((x) => x.part === 0);
13334
+ return !!b && c.marginT + b.bottom - b.origin > pageBottom - y - c.marginB;
13335
+ })) {
13336
+ page++;
13337
+ y = contTop;
13338
+ first = true;
13339
+ }
13318
13340
  const declared = num(findChildByLocalName(tbl, "sz"), "height");
13319
13341
  const led = /* @__PURE__ */ new Set();
13320
13342
  let firstPh = 0;
@@ -13389,6 +13411,29 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13389
13411
  first = false;
13390
13412
  continue;
13391
13413
  }
13414
+ if (boxes && floatSpan) {
13415
+ let span = 0, spanEnd = 0, mB = 0;
13416
+ for (const c of rowCells) for (const b of boxes.get(c.el) ?? []) {
13417
+ const f = floatSpan(b.seg, y + c.marginT + b.top, contTop + c.marginT);
13418
+ if (f && f.pages > span) {
13419
+ span = f.pages;
13420
+ spanEnd = f.endY;
13421
+ mB = c.marginB;
13422
+ }
13423
+ }
13424
+ if (span > 0) {
13425
+ const none = new Map(rowCells.map((c) => [c.el, [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]]));
13426
+ pieces.push({ page, y, h: pageBottom - y, range: new Map(rowCells.map((c) => [c.el, [0, Number.POSITIVE_INFINITY]])), fill: true });
13427
+ for (let e = 1; e < span; e++) pieces.push({ page: page + e, y: contTop, h: pageBottom - contTop, range: none, fill: true });
13428
+ page += span;
13429
+ const endH = Math.max(0, spanEnd - contTop) + mB;
13430
+ pieces.push({ page, y: contTop, h: endH, range: none });
13431
+ out.push(pieces);
13432
+ y = contTop + endH;
13433
+ first = false;
13434
+ continue;
13435
+ }
13436
+ }
13392
13437
  if (splittable && y + h > pageBottom) {
13393
13438
  const from = /* @__PURE__ */ new Map();
13394
13439
  const lines = new Map(rowCells.map((c) => [c.el, cellLines(c)]));
@@ -14492,6 +14537,16 @@ function planLines(m, styles, numText = "") {
14492
14537
  let scale = 1;
14493
14538
  const lineW = seg.horzsize - lead;
14494
14539
  const avail = lineW - nat.obj;
14540
+ let lastSp = 0;
14541
+ if (fixedTo === start) {
14542
+ let k = textEnd - 1;
14543
+ while (k >= start && m.chars[k].ch === "") k--;
14544
+ if (k >= start) {
14545
+ const c = m.chars[k], st = (c.prId != null ? styles.charPr.get(c.prId) : void 0) ?? DEFAULT_CHAR;
14546
+ const cps = [...c.ch];
14547
+ lastSp = glyphWidth(cps[cps.length - 1], st).sp;
14548
+ }
14549
+ }
14495
14550
  const stretch = align === "JUSTIFY" || align === "DISTRIBUTE" || align === "DISTRIBUTE_SPACE";
14496
14551
  let spaceAdd = 0, spaceFrom = fixedTo;
14497
14552
  if (nat.text > 0 && stretch && (!isLast || align === "DISTRIBUTE" || align === "DISTRIBUTE_SPACE")) {
@@ -14499,11 +14554,11 @@ function planLines(m, styles, numText = "") {
14499
14554
  while (spFrom < textEnd && (m.chars[spFrom].ch === " " || m.chars[spFrom].ch === "")) spFrom++;
14500
14555
  for (let k = spFrom; k < textEnd; k++) if (m.chars[k].ch === " ") nSp++;
14501
14556
  if (nSp > 0 && align !== "DISTRIBUTE") {
14502
- spaceAdd = (avail - nat.text) / nSp;
14557
+ spaceAdd = (avail - nat.text + lastSp) / nSp;
14503
14558
  spaceFrom = spFrom;
14504
14559
  } else scale = avail > 0 ? avail / nat.text : 1;
14505
14560
  } else if (nat.text + nat.obj > 0 && (isLast || !stretch)) {
14506
- const w = nat.text + nat.obj;
14561
+ const w = nat.text + nat.obj - lastSp;
14507
14562
  if (align === "CENTER") xoff = Math.max(0, (lineW - w) / 2);
14508
14563
  else if (align === "RIGHT") xoff = Math.max(0, lineW - w);
14509
14564
  }
@@ -14731,7 +14786,7 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
14731
14786
  const tbFloats = m.objs.filter((q) => !q.inline && (q.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM" && (findChildByLocalName(q.el, "pos")?.getAttribute("vertRelTo") ?? "PARA") === "PARA").length;
14732
14787
  let stay = tbFloats < 2 && !m.objs.some((q) => q.inline) && !m.chars.some((c) => c.ch !== "" && !c.nb && c.ch.trim() !== "");
14733
14788
  const sbA = m.paraPrId != null ? ctx.styles.paraGeom.get(m.paraPrId)?.spaceBefore ?? 0 : 0;
14734
- if (stay && wrapA === "TOP_AND_BOTTOM" && linePushedBy(o, anchorLineV ?? baseV, pTop)) stay = false;
14789
+ if (stay && wrapA === "TOP_AND_BOTTOM" && linePushedBy(o, anchorLineV ?? baseV, pTop ?? (depth > 0 ? cellParaTop(p, ctx.styles.paraGeom) : void 0))) stay = false;
14735
14790
  const firstLine = anchorLineV === void 0 || anchorLineV === baseV;
14736
14791
  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);
14737
14792
  if (depth === 0 && tbFloats >= 2 && wrapA === "TOP_AND_BOTTOM") {
@@ -14925,7 +14980,9 @@ function cellFloatSpan(MT, BODY_H, memo, slack) {
14925
14980
  if ((pos?.getAttribute("vertRelTo") ?? "PARA") !== "PARA") continue;
14926
14981
  const segK = Math.max(0, m.segs.findIndex((sg, i) => sg.textpos <= o.index && (i === m.segs.length - 1 || m.segs[i + 1].textpos > o.index)));
14927
14982
  if (segK !== k) continue;
14928
- const ty = top + num(findChildByLocalName(o.el, "outMargin"), "top") + Math.max(0, toInt32(pos?.getAttribute("vertOffset") ?? void 0, 0));
14983
+ const segV = num(seg, "vertpos"), pTop = cellParaTop(p, memo.paraGeom ?? /* @__PURE__ */ new Map());
14984
+ const start = linePushedBy(o, segV, pTop) ? top - (segV - (pTop ?? segV)) : top;
14985
+ const ty = start + num(findChildByLocalName(o.el, "outMargin"), "top") + Math.max(0, toInt32(pos?.getAttribute("vertOffset") ?? void 0, 0));
14929
14986
  const span = tableContPages(o.el, ty, MT, BODY_H, memo, slack, cellFloatSpan(MT, BODY_H, memo, slack), true, contMT);
14930
14987
  if (span.pages > 0 && (!best || span.pages > best.pages)) best = { ...span, el: o.el };
14931
14988
  }
@@ -15005,7 +15062,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
15005
15062
  const va2 = c.sub.getAttribute("vertAlign") ?? "TOP";
15006
15063
  const lastK = g.pieces.length - 1;
15007
15064
  const pieceOff = g.pieces.map((pc, k) => {
15008
- if (va2 === "TOP" || k > 0 && k < lastK) return 0;
15065
+ if (va2 === "TOP" || k > 0 && k < lastK || pc.fill) return 0;
15009
15066
  const from = pc.range?.get(c.el)?.[0] ?? 0;
15010
15067
  const bottoms = boxes.filter((b) => pieceOf(b.top) === k).map((b) => b.bottom - from);
15011
15068
  if (k > 0) for (const f of subFloatBottoms(c.sub)) {
@@ -15544,7 +15601,7 @@ function drawPageNumbers(root, paraPages, ctx) {
15544
15601
  const text = side ? `${side} ${formatHeadNumber2(n, decl.el.getAttribute("formatType") ?? "DIGIT")} ${side}` : formatHeadNumber2(n, decl.el.getAttribute("formatType") ?? "DIGIT");
15545
15602
  const w = measureTextWidth(text, h, 100, { faceClass: faceClassOf(st.face) });
15546
15603
  const x = /LEFT/.test(pos) ? ML : /RIGHT/.test(pos) ? ML + BODY_W - w : (PW - w) / 2;
15547
- const y = /^TOP/.test(pos) ? num(margin, "top", 5668) - 225 : PH - num(margin, "bottom", 4252) - 225;
15604
+ const y = /^TOP/.test(pos) ? num(margin, "top", 5668) - 225 : num(margin, "footer", 0) > 0 ? PH - num(margin, "bottom", 4252) - 225 : PH - Math.round(num(margin, "bottom", 4252) / 2) - 243;
15548
15605
  const attrs = [`x="${pt2(x)}"`, `y="${pt2(y)}"`, `font-size="${pt2(h)}"`];
15549
15606
  if (st.fontFamily) attrs.push(`font-family="${escapeXml(st.fontFamily)}"`);
15550
15607
  ctx.page = page;
@@ -19859,4 +19916,4 @@ export {
19859
19916
  cropRect,
19860
19917
  extractRenderedRegions
19861
19918
  };
19862
- //# sourceMappingURL=chunk-5YGTRWCN.js.map
19919
+ //# sourceMappingURL=chunk-SXSBYB4M.js.map