ooxml-core 1.9.0 → 1.11.0

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 (202) hide show
  1. package/dist/PptxHandler-DNZHAHUY.cjs +12 -0
  2. package/dist/PptxHandler-E44KDHMQ.mjs +3 -0
  3. package/dist/{PptxHandler-EX4WBIQQ.mjs → PptxHandler-NROFYT2N.mjs} +2 -2
  4. package/dist/automation/index.cjs +3236 -2258
  5. package/dist/automation/index.mjs +3236 -2258
  6. package/dist/{chunk-SWF7KVL5.cjs → chunk-2UVH6RHI.cjs} +1608 -1163
  7. package/dist/{chunk-M76PHYRR.mjs → chunk-7DSZI7S6.mjs} +1 -1
  8. package/dist/{chunk-AT66SA5M.cjs → chunk-7QZGRB3T.cjs} +28 -10
  9. package/dist/chunk-ANZ4Q6I3.cjs +21 -0
  10. package/dist/{chunk-CPKNMQLX.cjs → chunk-AWIDASUW.cjs} +25 -2
  11. package/dist/{chunk-SVQZXP3F.mjs → chunk-CBNKBVX5.mjs} +25 -2
  12. package/dist/{chunk-FIELY5PI.mjs → chunk-EC2W2MDY.mjs} +30 -2
  13. package/dist/chunk-EGTRL3QJ.mjs +19 -0
  14. package/dist/chunk-GXHKNSZX.mjs +9 -0
  15. package/dist/{chunk-OXHMZS7B.mjs → chunk-HCXUI5UC.mjs} +943 -273
  16. package/dist/chunk-HDQXPSHY.cjs +17 -0
  17. package/dist/chunk-KTYBFGEY.mjs +14 -0
  18. package/dist/chunk-QOO36KG4.cjs +42 -0
  19. package/dist/chunk-R2KZXD6U.mjs +39 -0
  20. package/dist/{chunk-IGOA57LE.mjs → chunk-U2DF3EGK.mjs} +1 -1
  21. package/dist/{chunk-OB277ZGE.mjs → chunk-UAY26XOI.mjs} +27 -9
  22. package/dist/{chunk-WSO4T2LJ.mjs → chunk-W5ARCUJB.mjs} +26 -3
  23. package/dist/chunk-XZPZHXV4.cjs +12 -0
  24. package/dist/{chunk-LCS3J3QI.mjs → chunk-YB5SRNFS.mjs} +717 -272
  25. package/dist/docx/layout/adapt-table.d.ts +2 -2
  26. package/dist/docx/layout/adapt-table.d.ts.map +1 -1
  27. package/dist/docx/layout/flow-table.d.ts.map +1 -1
  28. package/dist/docx/layout/index.cjs +554 -83
  29. package/dist/docx/layout/index.mjs +554 -84
  30. package/dist/docx/layout/nested-fragment-edges.d.ts +9 -0
  31. package/dist/docx/layout/nested-fragment-edges.d.ts.map +1 -0
  32. package/dist/docx/layout/nested-frame-profile.d.ts +9 -0
  33. package/dist/docx/layout/nested-frame-profile.d.ts.map +1 -0
  34. package/dist/docx/layout/page-cursor.d.ts +2 -0
  35. package/dist/docx/layout/page-cursor.d.ts.map +1 -1
  36. package/dist/docx/layout/result.d.ts +20 -0
  37. package/dist/docx/layout/result.d.ts.map +1 -1
  38. package/dist/docx/layout/table-border-layout.d.ts +16 -0
  39. package/dist/docx/layout/table-border-layout.d.ts.map +1 -0
  40. package/dist/docx/layout/table-cell-layout.d.ts +3 -2
  41. package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
  42. package/dist/docx/layout/table-content.d.ts +4 -0
  43. package/dist/docx/layout/table-content.d.ts.map +1 -0
  44. package/dist/docx/layout/table-footnotes.d.ts +5 -0
  45. package/dist/docx/layout/table-footnotes.d.ts.map +1 -1
  46. package/dist/docx/layout/table-frames.d.ts +4 -0
  47. package/dist/docx/layout/table-frames.d.ts.map +1 -0
  48. package/dist/docx/layout/table-layout.d.ts +8 -3
  49. package/dist/docx/layout/table-layout.d.ts.map +1 -1
  50. package/dist/docx/layout/table-note-completion.d.ts +5 -0
  51. package/dist/docx/layout/table-note-completion.d.ts.map +1 -0
  52. package/dist/docx/layout/table-note-stories.d.ts +6 -0
  53. package/dist/docx/layout/table-note-stories.d.ts.map +1 -0
  54. package/dist/pptx/automation/index.cjs +801 -296
  55. package/dist/pptx/automation/index.d.ts +5 -4
  56. package/dist/pptx/automation/index.d.ts.map +1 -1
  57. package/dist/pptx/automation/index.mjs +5 -5
  58. package/dist/pptx/chunks/{text-operations-BLodkuXE.d.ts → elements-DD3UGOMd.d.ts} +27 -3248
  59. package/dist/pptx/chunks/elements-DD3UGOMd.d.ts.map +1 -0
  60. package/dist/pptx/chunks/{index-B4cnSPNz.d.ts → index-BZrFyNtU.d.ts} +113 -5
  61. package/dist/pptx/chunks/index-BZrFyNtU.d.ts.map +1 -0
  62. package/dist/pptx/chunks/{index-BZh-IMkN.d.ts → index-DdX02BSm.d.ts} +19 -3
  63. package/dist/pptx/chunks/index-DdX02BSm.d.ts.map +1 -0
  64. package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts +1512 -0
  65. package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts.map +1 -0
  66. package/dist/pptx/chunks/text-D49FKllA.d.ts +1473 -0
  67. package/dist/pptx/chunks/text-D49FKllA.d.ts.map +1 -0
  68. package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts +3261 -0
  69. package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts.map +1 -0
  70. package/dist/pptx/cli/index.cjs +801 -296
  71. package/dist/pptx/cli/index.d.ts +1 -1
  72. package/dist/pptx/cli/index.mjs +4 -4
  73. package/dist/pptx/converter/index.cjs +1 -0
  74. package/dist/pptx/converter/index.d.ts +1 -1
  75. package/dist/pptx/converter/index.mjs +2 -2
  76. package/dist/pptx/editor/render/collaboration-live-patch-target.cjs +2 -2
  77. package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +1 -1
  78. package/dist/pptx/editor/render/find-replace.cjs +19 -18
  79. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  80. package/dist/pptx/editor/render/find-replace.mjs +3 -2
  81. package/dist/pptx/editor/render/font-family-update.cjs +14 -0
  82. package/dist/pptx/editor/render/font-family-update.d.ts +17 -0
  83. package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -0
  84. package/dist/pptx/editor/render/font-family-update.mjs +1 -0
  85. package/dist/pptx/editor/render/paragraph-geometry-overrides.cjs +14 -0
  86. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +17 -0
  87. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -0
  88. package/dist/pptx/editor/render/paragraph-geometry-overrides.mjs +12 -0
  89. package/dist/pptx/editor/render/remap-text.cjs +2 -2
  90. package/dist/pptx/editor/render/remap-text.d.ts.map +1 -1
  91. package/dist/pptx/editor/render/remap-text.mjs +1 -1
  92. package/dist/pptx/editor/render/slide-operations.cjs +9 -8
  93. package/dist/pptx/editor/render/slide-operations.mjs +3 -2
  94. package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
  95. package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
  96. package/dist/pptx/editor/render/text-content-style.cjs +18 -0
  97. package/dist/pptx/editor/render/text-content-style.d.ts +9 -0
  98. package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -0
  99. package/dist/pptx/editor/render/text-content-style.mjs +5 -0
  100. package/dist/pptx/editor/render/text-runs-style-patch.cjs +17 -0
  101. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +7 -0
  102. package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -0
  103. package/dist/pptx/editor/render/text-runs-style-patch.mjs +15 -0
  104. package/dist/pptx/editor/render/text-style-scope.cjs +173 -0
  105. package/dist/pptx/editor/render/text-style-scope.d.ts +76 -0
  106. package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -0
  107. package/dist/pptx/editor/render/text-style-scope.mjs +164 -0
  108. package/dist/pptx/editor/render/theme-editor-model.cjs +1 -1
  109. package/dist/pptx/editor/render/theme-editor-model.mjs +1 -1
  110. package/dist/pptx/editor/render/update-text-segment-style.cjs +11 -0
  111. package/dist/pptx/editor/render/update-text-segment-style.d.ts +14 -0
  112. package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -0
  113. package/dist/pptx/editor/render/update-text-segment-style.mjs +2 -0
  114. package/dist/pptx/index.cjs +1091 -296
  115. package/dist/pptx/index.d.ts +7 -5
  116. package/dist/pptx/index.mjs +5 -5
  117. package/dist/pptx/smartart-layouts/index.d.ts +1 -1
  118. package/dist/teams/index.cjs +590 -122
  119. package/dist/teams/index.mjs +590 -122
  120. package/dist/visio/date-cache.d.ts +3 -0
  121. package/dist/visio/date-cache.d.ts.map +1 -0
  122. package/dist/visio/edit-commands.d.ts +3 -3
  123. package/dist/visio/edit-commands.d.ts.map +1 -1
  124. package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
  125. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  126. package/dist/visio/edit-text-field-commands.d.ts +15 -0
  127. package/dist/visio/edit-text-field-commands.d.ts.map +1 -1
  128. package/dist/visio/edit-text-field.d.ts +2 -2
  129. package/dist/visio/edit-text-field.d.ts.map +1 -1
  130. package/dist/visio/edit.d.ts +1 -1
  131. package/dist/visio/edit.d.ts.map +1 -1
  132. package/dist/visio/index.cjs +501 -220
  133. package/dist/visio/index.d.ts +1 -1
  134. package/dist/visio/index.d.ts.map +1 -1
  135. package/dist/visio/index.mjs +501 -220
  136. package/dist/visio/model.d.ts +6 -0
  137. package/dist/visio/model.d.ts.map +1 -1
  138. package/dist/visio/shape-metadata.d.ts.map +1 -1
  139. package/dist/visio/shapes.d.ts.map +1 -1
  140. package/dist/visio/style.d.ts +1 -1
  141. package/dist/visio/style.d.ts.map +1 -1
  142. package/dist/visio/text-field-display.d.ts +3 -0
  143. package/dist/visio/text-field-display.d.ts.map +1 -1
  144. package/dist/visio/text-field-editability.d.ts +6 -0
  145. package/dist/visio/text-field-editability.d.ts.map +1 -0
  146. package/dist/visio/text-field-fraction.d.ts +3 -0
  147. package/dist/visio/text-field-fraction.d.ts.map +1 -0
  148. package/dist/visio/text-field-independent.d.ts +4 -0
  149. package/dist/visio/text-field-independent.d.ts.map +1 -0
  150. package/dist/visio/text-field-numeric.d.ts +1 -1
  151. package/dist/visio/text-field-numeric.d.ts.map +1 -1
  152. package/dist/visio/text-field-source.d.ts +6 -0
  153. package/dist/visio/text-field-source.d.ts.map +1 -0
  154. package/dist/visio/text-field-system-date.d.ts +4 -0
  155. package/dist/visio/text-field-system-date.d.ts.map +1 -0
  156. package/dist/visio/text-fields.d.ts +1 -0
  157. package/dist/visio/text-fields.d.ts.map +1 -1
  158. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  159. package/dist/visio/ui/index.cjs +514 -221
  160. package/dist/visio/ui/index.mjs +514 -221
  161. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  162. package/dist/visio/ui/text-field-catalog.d.ts.map +1 -1
  163. package/dist/xlsx/edit/pivots.d.ts.map +1 -1
  164. package/dist/xlsx/index.cjs +1362 -659
  165. package/dist/xlsx/index.mjs +1361 -660
  166. package/dist/xlsx/load/index.cjs +1091 -430
  167. package/dist/xlsx/load/index.mjs +1091 -430
  168. package/dist/xlsx/model-pivots.d.ts +31 -2
  169. package/dist/xlsx/model-pivots.d.ts.map +1 -1
  170. package/dist/xlsx/pivot/admission.d.ts.map +1 -1
  171. package/dist/xlsx/pivot/aggregate.d.ts +3 -1
  172. package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
  173. package/dist/xlsx/pivot/data.d.ts +2 -2
  174. package/dist/xlsx/pivot/data.d.ts.map +1 -1
  175. package/dist/xlsx/pivot/hierarchy-first.d.ts +21 -0
  176. package/dist/xlsx/pivot/hierarchy-first.d.ts.map +1 -0
  177. package/dist/xlsx/pivot/hierarchy.d.ts +2 -4
  178. package/dist/xlsx/pivot/hierarchy.d.ts.map +1 -1
  179. package/dist/xlsx/pivot/index.d.ts +2 -0
  180. package/dist/xlsx/pivot/index.d.ts.map +1 -1
  181. package/dist/xlsx/pivot/measures.d.ts +13 -0
  182. package/dist/xlsx/pivot/measures.d.ts.map +1 -0
  183. package/dist/xlsx/pivot/page-filter-admission.d.ts +5 -0
  184. package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -0
  185. package/dist/xlsx/pivot/page-filter.d.ts +11 -0
  186. package/dist/xlsx/pivot/page-filter.d.ts.map +1 -0
  187. package/dist/xlsx/pivot/read.d.ts.map +1 -1
  188. package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
  189. package/dist/xlsx/pivot/values-axis.d.ts +12 -0
  190. package/dist/xlsx/pivot/values-axis.d.ts.map +1 -0
  191. package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
  192. package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
  193. package/dist/xlsx/ui/index.cjs +640 -137
  194. package/dist/xlsx/ui/index.mjs +640 -137
  195. package/package.json +2 -2
  196. package/dist/PptxHandler-AT7FVG5Q.mjs +0 -2
  197. package/dist/PptxHandler-VFSCECPL.cjs +0 -11
  198. package/dist/pptx/chunks/index-B4cnSPNz.d.ts.map +0 -1
  199. package/dist/pptx/chunks/index-BZh-IMkN.d.ts.map +0 -1
  200. package/dist/pptx/chunks/smart-art-Q2kZQtHh.d.ts +0 -2970
  201. package/dist/pptx/chunks/smart-art-Q2kZQtHh.d.ts.map +0 -1
  202. package/dist/pptx/chunks/text-operations-BLodkuXE.d.ts.map +0 -1
@@ -4425,6 +4425,12 @@ function appendBreakMarker(tokens, runIndex, sourceStart, kind) {
4425
4425
  tokens.push({ kind: kind === "page" ? "pageBreak" : "columnBreak", runIndex, sourceStart });
4426
4426
  }
4427
4427
 
4428
+ // docx/layout/result.ts
4429
+ function cellVerticalOffset(geometry, rowHeightPx) {
4430
+ const free = Math.max(0, (geometry.alignmentHeightPx ?? rowHeightPx) - geometry.contentHeightPx);
4431
+ return geometry.verticalAlign === "center" ? free / 2 : geometry.verticalAlign === "bottom" ? free : 0;
4432
+ }
4433
+
4428
4434
  // docx/layout/page-fields.ts
4429
4435
  function fieldDisplayText(run, values) {
4430
4436
  if (!run.field || isFieldLocked(run)) return run.text;
@@ -4889,6 +4895,124 @@ function widowControlEnabled(value) {
4889
4895
  return value !== false;
4890
4896
  }
4891
4897
 
4898
+ // docx/layout/nested-frame-profile.ts
4899
+ var equal = (a, b) => a !== void 0 && b !== void 0 && a.style === b.style && a.color === b.color && Math.abs(a.widthPx - b.widthPx) < 1e-6;
4900
+ function nestedFrameProfile(table, tableWidthPx = table.widthPx) {
4901
+ const sides = table.rows.flatMap(
4902
+ (row) => row.cells.flatMap(
4903
+ (cell) => ["top", "right", "bottom", "left"].map((side) => cell.borders?.[side])
4904
+ )
4905
+ );
4906
+ if (sides.every((side) => !side)) return { leftPx: 0, rightPx: 0, bottomPx: 0 };
4907
+ if (!sides.every((side) => side?.style === "solid" && side.widthPx > 0)) return void 0;
4908
+ const first3 = table.rows[0], left = first3.cells[0].borders.left, right = first3.cells.at(-1).borders.right;
4909
+ for (const [index, row] of table.rows.entries()) {
4910
+ if (row.cells.length !== first3.cells.length || !equal(row.cells[0]?.borders?.left, left) || !equal(row.cells.at(-1)?.borders?.right, right))
4911
+ return void 0;
4912
+ for (const [column, cell] of row.cells.entries()) {
4913
+ const sourceWidth = cell.widthPx ?? (tableWidthPx === void 0 ? void 0 : tableWidthPx / row.cells.length);
4914
+ const paintWidth = sourceWidth === void 0 ? void 0 : sourceWidth + (cell.borders.left.widthPx - cell.borders.right.widthPx) / 2 + (column === row.cells.length - 1 ? cell.borders.right.widthPx : 0);
4915
+ if (paintWidth !== void 0 && paintWidth <= 0) return void 0;
4916
+ if (!equal(cell.borders?.top, row.cells[0]?.borders?.top) || !equal(cell.borders?.bottom, row.cells[0]?.borders?.bottom))
4917
+ return void 0;
4918
+ if (column && !equal(row.cells[column - 1]?.borders?.right, cell.borders?.left))
4919
+ return void 0;
4920
+ if (index) {
4921
+ const previous = table.rows[index - 1].cells[column];
4922
+ if (previous.xPx !== cell.xPx || previous.widthPx !== cell.widthPx || !equal(previous.borders?.bottom, cell.borders?.top))
4923
+ return void 0;
4924
+ }
4925
+ }
4926
+ }
4927
+ return {
4928
+ leftPx: left.widthPx,
4929
+ rightPx: right.widthPx,
4930
+ bottomPx: table.rows.at(-1).cells[0].borders.bottom.widthPx
4931
+ };
4932
+ }
4933
+
4934
+ // docx/layout/nested-fragment-edges.ts
4935
+ var plain = (paragraph) => !paragraph.keepLines && !paragraph.keepNext && !paragraph.pageBreakBefore && !paragraph.footnotes?.length && !paragraph.runs.some((run) => run.footnoteReferenceId !== void 0 || run.breakAfter);
4936
+ function nestedFragmentEdges(table) {
4937
+ if (table.widthPx === void 0 || !Number.isFinite(table.widthPx) || table.widthPx <= 0 || table.rows.length < 2 || !nestedFrameProfile(table, table.widthPx) || table.rows.some(
4938
+ (row) => row.heightPx !== void 0 || row.cantSplit || row.isHeader || row.cells.length !== 2 || row.cells.some(
4939
+ (cell) => cell.verticalAlign && cell.verticalAlign !== "top" || cell.blocks?.some((block) => block.kind !== "paragraph") || !(cell.blocks ?? cell.paragraphs).every(
4940
+ (block) => block.kind === "paragraph" && plain(block)
4941
+ )
4942
+ )
4943
+ ))
4944
+ return void 0;
4945
+ const top = table.rows[0].cells.map((cell) => cell.borders?.top);
4946
+ const bottom = table.rows.at(-1).cells.map((cell) => cell.borders?.bottom);
4947
+ return top.every(Boolean) && bottom.every(Boolean) ? { top, bottom } : void 0;
4948
+ }
4949
+ function reflowNestedFragments(row) {
4950
+ if (row.heightPx !== void 0 || row.cantSplit || row.isHeader || row.cells.length !== 2)
4951
+ return false;
4952
+ let tables = 0;
4953
+ for (const cell of row.cells) {
4954
+ if (cell.verticalAlign && cell.verticalAlign !== "top") return false;
4955
+ for (const [index, block] of (cell.blocks ?? cell.paragraphs).entries()) {
4956
+ if (block.kind === "paragraph") {
4957
+ if (!plain(block)) return false;
4958
+ } else {
4959
+ if (index !== 0 || !nestedFragmentEdges(block) || ++tables > 1) return false;
4960
+ }
4961
+ }
4962
+ }
4963
+ return tables === 1;
4964
+ }
4965
+
4966
+ // docx/layout/table-content.ts
4967
+ function cellContentBottom(boxes, paddingBottom = 0) {
4968
+ return Math.max(
4969
+ 0,
4970
+ ...boxes.map(
4971
+ (box) => box.yPx + box.heightPx + (box.tableFrameInsets?.bottom ?? 0) + paddingBottom
4972
+ )
4973
+ );
4974
+ }
4975
+
4976
+ // docx/layout/table-frames.ts
4977
+ function clipTableFrames(tables, start, end, inset = 0) {
4978
+ return tables.flatMap((table) => {
4979
+ const top = Math.max(start, table.yPx);
4980
+ const bottom = Math.min(end, table.yPx + table.heightPx);
4981
+ if (bottom <= top) return [];
4982
+ const rows = table.rows.flatMap((row) => {
4983
+ const rowTop = table.yPx + row.yPx;
4984
+ const a = Math.max(top, rowTop), b = Math.min(bottom, rowTop + row.heightPx);
4985
+ if (b <= a) return [];
4986
+ return [
4987
+ {
4988
+ ...row,
4989
+ yPx: a - top,
4990
+ heightPx: b - a,
4991
+ ...row.cellTables ? {
4992
+ cellTables: row.cellTables.map(
4993
+ (nested) => clipTableFrames(nested, a - rowTop, b - rowTop)
4994
+ )
4995
+ } : {}
4996
+ }
4997
+ ];
4998
+ });
4999
+ if (table.fragmentEdges && rows.length) {
5000
+ const edges = table.fragmentEdges;
5001
+ for (const [row, side] of [
5002
+ [rows[0], "top"],
5003
+ [rows.at(-1), "bottom"]
5004
+ ]) {
5005
+ if (row.geometry)
5006
+ row.geometry = row.geometry.map((cell, index) => ({
5007
+ ...cell,
5008
+ borders: { ...cell.borders, [side]: edges[side][index] }
5009
+ }));
5010
+ }
5011
+ }
5012
+ return [{ ...table, yPx: top - start + inset, heightPx: bottom - top, rows }];
5013
+ });
5014
+ }
5015
+
4892
5016
  // docx/layout/table-cell-layout.ts
4893
5017
  function cellParagraphs(cell) {
4894
5018
  const walk = (blocks) => blocks.flatMap(
@@ -4896,7 +5020,7 @@ function cellParagraphs(cell) {
4896
5020
  );
4897
5021
  return cell.blocks ? walk(cell.blocks) : cell.paragraphs;
4898
5022
  }
4899
- function stackCellBlocks(cell, width, measurer, note, top, starts) {
5023
+ function stackCellBlocks(cell, width, measurer, note, top, starts, physicalFragments = false) {
4900
5024
  if (!cell.blocks)
4901
5025
  return stackParagraphs(
4902
5026
  starts ? cell.paragraphs.filter((p) => starts.has(p.id)) : cell.paragraphs,
@@ -4908,6 +5032,7 @@ function stackCellBlocks(cell, width, measurer, note, top, starts) {
4908
5032
  );
4909
5033
  let y = top;
4910
5034
  const boxes = [];
5035
+ const tables = [];
4911
5036
  for (const block of cell.blocks) {
4912
5037
  if (block.kind === "paragraph") {
4913
5038
  if (starts && !starts.has(block.id)) continue;
@@ -4916,28 +5041,83 @@ function stackCellBlocks(cell, width, measurer, note, top, starts) {
4916
5041
  y = result.heightPx;
4917
5042
  continue;
4918
5043
  }
5044
+ const edges = physicalFragments ? nestedFragmentEdges(block) : void 0;
4919
5045
  const tableWidth = block.widthPx ?? width;
4920
- const x = block.alignment === "center" ? Math.max(0, (width - tableWidth) / 2) : block.alignment === "right" ? Math.max(0, width - tableWidth) : block.indentPx ?? 0;
5046
+ const profile = nestedFrameProfile(block, tableWidth);
5047
+ const reserveBorders = profile !== void 0;
5048
+ if (!reserveBorders)
5049
+ note(
5050
+ "Nested table border occupancy is approximate for missing edges, non-solid or conflicting shared borders and changing row grids."
5051
+ );
5052
+ const externalRight = profile ? (profile.leftPx + profile.rightPx) / 2 : 0;
5053
+ const paintedWidth = tableWidth + externalRight;
5054
+ const x = block.alignment === "center" ? Math.max(0, (width - paintedWidth) / 2) : block.alignment === "right" ? Math.max(0, width - paintedWidth) : block.indentPx ?? 0;
5055
+ const frame = {
5056
+ kind: "table",
5057
+ blockId: block.id,
5058
+ xPx: x,
5059
+ widthPx: paintedWidth,
5060
+ yPx: y,
5061
+ heightPx: 0,
5062
+ rows: [],
5063
+ ...edges ? { fragmentEdges: edges } : {}
5064
+ };
4921
5065
  for (const row of block.rows) {
4922
5066
  if (starts && !row.cells.some((nested) => cellParagraphs(nested).some((p) => starts.has(p.id))))
4923
5067
  continue;
4924
- const layout = layoutRow(row, tableWidth, measurer, note, void 0, starts);
5068
+ const visibleRow = edges && starts && !frame.rows.length ? {
5069
+ ...row,
5070
+ cells: row.cells.map((cell2, index) => ({
5071
+ ...cell2,
5072
+ borders: { ...cell2.borders, top: edges.top[index] }
5073
+ }))
5074
+ } : row;
5075
+ const layout = layoutRow(
5076
+ visibleRow,
5077
+ tableWidth,
5078
+ measurer,
5079
+ note,
5080
+ void 0,
5081
+ starts,
5082
+ reserveBorders,
5083
+ profile?.leftPx
5084
+ );
5085
+ frame.rows.push({
5086
+ yPx: y - frame.yPx,
5087
+ heightPx: layout.heightPx,
5088
+ repeated: false,
5089
+ cells: layout.cells,
5090
+ geometry: layout.geometry,
5091
+ ...layout.cellTables ? { cellTables: layout.cellTables } : {}
5092
+ });
4925
5093
  layout.cells.forEach((paragraphs, index) => {
4926
5094
  const geometry = layout.geometry[index];
4927
5095
  for (const paragraph of paragraphs)
4928
5096
  boxes.push({
4929
5097
  ...paragraph,
4930
- yPx: y + paragraph.yPx,
5098
+ yPx: y + paragraph.yPx + cellVerticalOffset(geometry, layout.heightPx),
4931
5099
  xPx: x + geometry.xPx + geometry.paddingLeftPx + (paragraph.xPx ?? 0),
4932
5100
  widthPx: paragraph.widthPx ?? Math.max(1, geometry.widthPx - geometry.paddingLeftPx - geometry.paddingRightPx),
4933
- readOnly: true
5101
+ readOnly: true,
5102
+ ...edges ? { tableFragmentBottomPx: edges.bottom[index].widthPx } : {},
5103
+ tableFrameInsets: {
5104
+ top: (paragraph.tableFrameInsets?.top ?? 0) + (reserveBorders ? geometry.borders?.top?.widthPx ?? 0 : 0),
5105
+ bottom: (paragraph.tableFrameInsets?.bottom ?? 0) + (reserveBorders ? geometry.borders?.bottom?.widthPx ?? 0 : 0)
5106
+ }
4934
5107
  });
4935
5108
  });
4936
5109
  y += layout.heightPx;
4937
5110
  }
5111
+ const bottomBorder = profile?.bottomPx ?? 0;
5112
+ if (frame.rows.length) {
5113
+ frame.rows.at(-1).heightPx += bottomBorder;
5114
+ y += bottomBorder;
5115
+ frame.heightPx = y - frame.yPx;
5116
+ tables.push(frame);
5117
+ }
4938
5118
  }
4939
5119
  boxes.sort((a, b) => a.yPx - b.yPx);
4940
- return { heightPx: y, boxes };
5120
+ return { heightPx: y, boxes, tables };
4941
5121
  }
4942
5122
 
4943
5123
  // docx/layout/table-layout.ts
@@ -4968,7 +5148,7 @@ function stackParagraphs(paragraphs, widthPx, measurer, note, topPx = 0, startTo
4968
5148
  }
4969
5149
  return { heightPx: y, boxes };
4970
5150
  }
4971
- function layoutRow(row, tableWidthPx, measurer, note, remaining, startTokens) {
5151
+ function layoutRow(row, tableWidthPx, measurer, note, remaining, startTokens, frameBorders = false, frameLeftBorderPx, physicalFragments = reflowNestedFragments(row)) {
4972
5152
  const count = row.cells.length || 1;
4973
5153
  let x = 0;
4974
5154
  const geometry = [];
@@ -4976,59 +5156,81 @@ function layoutRow(row, tableWidthPx, measurer, note, remaining, startTokens) {
4976
5156
  const continuation = remaining?.[geometry.length];
4977
5157
  const starts = continuation ? new Map(continuation.map((box) => [box.blockId, box.lines[0]?.firstToken ?? 0])) : startTokens;
4978
5158
  const widthPx = cell.widthPx ?? tableWidthPx / count;
4979
- const padding = cell.padding ?? { top: 0, right: 0, bottom: 0, left: 0 };
5159
+ const margins = cell.padding ?? { top: 0, right: 0, bottom: 0, left: 0 };
5160
+ const leftBorder = frameBorders ? cell.borders?.left?.widthPx ?? 0 : 0;
5161
+ const rightBorder = frameBorders ? cell.borders?.right?.widthPx ?? 0 : 0;
5162
+ const padding = frameBorders ? {
5163
+ top: margins.top + (cell.borders?.top?.widthPx ?? 0),
5164
+ bottom: margins.bottom,
5165
+ left: leftBorder / 2 + Math.max(margins.left, leftBorder / 2),
5166
+ right: Math.max(margins.right, rightBorder / 2) - rightBorder / 2
5167
+ } : margins;
5168
+ const externalRight = frameBorders && geometry.length === row.cells.length - 1 ? rightBorder : 0;
5169
+ const paintWidth = widthPx + (frameBorders ? (leftBorder - rightBorder) / 2 + externalRight : 0);
5170
+ const frameX = frameBorders ? ((frameLeftBorderPx ?? leftBorder) - leftBorder) / 2 : 0;
4980
5171
  const content2 = stackCellBlocks(
4981
5172
  cell,
4982
- Math.max(1, widthPx - padding.left - padding.right),
5173
+ Math.max(1, paintWidth - padding.left - padding.right - externalRight),
4983
5174
  measurer,
4984
5175
  note,
4985
5176
  padding.top,
4986
- starts
5177
+ starts,
5178
+ physicalFragments
4987
5179
  );
4988
5180
  const heightPx2 = content2.heightPx + padding.bottom;
4989
5181
  geometry.push({
4990
- xPx: cell.xPx ?? x,
4991
- widthPx,
5182
+ xPx: (cell.xPx ?? x) + frameX,
5183
+ widthPx: paintWidth,
5184
+ ...frameBorders ? { borderInsetsReserved: true } : {},
4992
5185
  paddingLeftPx: padding.left,
4993
- paddingRightPx: padding.right,
5186
+ paddingRightPx: padding.right + externalRight,
4994
5187
  contentHeightPx: heightPx2,
4995
5188
  ...cell.borders ? { borders: cell.borders } : {},
4996
5189
  ...cell.shading ? { shading: cell.shading } : {},
4997
5190
  ...cell.verticalAlign ? { verticalAlign: cell.verticalAlign } : {}
4998
5191
  });
4999
5192
  x = (cell.xPx ?? x) + widthPx;
5000
- return { heightPx: heightPx2, boxes: content2.boxes };
5193
+ return { heightPx: heightPx2, boxes: content2.boxes, tables: content2.tables ?? [] };
5001
5194
  });
5002
5195
  const content = Math.max(0, ...laidOut.map((cell) => cell.heightPx));
5003
5196
  const heightPx = row.heightPx === void 0 ? content : row.heightRule === "exact" ? row.heightPx : Math.max(content, row.heightPx);
5197
+ if (frameBorders) for (const cell of geometry) cell.alignmentHeightPx = heightPx;
5004
5198
  return {
5005
5199
  heightPx,
5006
5200
  cells: laidOut.map((cell) => cell.boxes),
5007
5201
  geometry,
5202
+ ...laidOut.some((cell) => cell.tables.length) ? { cellTables: laidOut.map((cell) => cell.tables) } : {},
5008
5203
  cellPadding: row.cells.map((cell) => ({
5009
5204
  top: cell.padding?.top ?? 0,
5010
5205
  bottom: cell.padding?.bottom ?? 0
5011
5206
  }))
5012
5207
  };
5013
5208
  }
5014
- function splitCellAtHeight(boxes, cutHeightPx) {
5209
+ function splitCellAtHeight(boxes, cutHeightPx, paragraphCuts) {
5015
5210
  const before = [];
5016
5211
  const after = [];
5017
5212
  let beforeHeightPx = 0;
5018
5213
  for (const box of boxes) {
5019
- if (box.yPx + box.heightPx <= cutHeightPx) {
5214
+ const cut = paragraphCuts?.get(box.blockId) ?? cutHeightPx;
5215
+ if (box.yPx + box.heightPx + (box.tableFragmentBottomPx ?? box.tableFrameInsets?.bottom ?? 0) <= cut) {
5020
5216
  before.push(box);
5021
- beforeHeightPx = Math.max(beforeHeightPx, box.yPx + box.heightPx);
5217
+ beforeHeightPx = Math.max(
5218
+ beforeHeightPx,
5219
+ box.yPx + box.heightPx + (box.tableFragmentBottomPx ?? box.tableFrameInsets?.bottom ?? 0)
5220
+ );
5022
5221
  continue;
5023
5222
  }
5024
5223
  const beforeLines = box.lines.filter(
5025
- (line2) => box.yPx + line2.yPx + line2.heightPx <= cutHeightPx
5224
+ (line2) => box.yPx + line2.yPx + line2.heightPx + (box.tableFragmentBottomPx ?? box.tableFrameInsets?.bottom ?? 0) <= cut
5026
5225
  );
5027
5226
  const afterLines = box.lines.slice(beforeLines.length);
5028
5227
  if (beforeLines.length) {
5029
5228
  const bottom = beforeLines.at(-1).yPx + beforeLines.at(-1).heightPx;
5030
5229
  before.push({ ...box, heightPx: bottom, lines: beforeLines });
5031
- beforeHeightPx = Math.max(beforeHeightPx, box.yPx + bottom);
5230
+ beforeHeightPx = Math.max(
5231
+ beforeHeightPx,
5232
+ box.yPx + bottom + (box.tableFragmentBottomPx ?? box.tableFrameInsets?.bottom ?? 0)
5233
+ );
5032
5234
  }
5033
5235
  if (afterLines.length) {
5034
5236
  const shift = expectDefined(afterLines[0], "first line after split").yPx;
@@ -5040,43 +5242,81 @@ function splitCellAtHeight(boxes, cutHeightPx) {
5040
5242
  });
5041
5243
  }
5042
5244
  }
5043
- const afterOrigin = Math.min(...after.map((box) => box.yPx));
5245
+ const afterOrigin = Math.min(...after.map((box) => box.yPx - (box.tableFrameInsets?.top ?? 0)));
5044
5246
  for (const box of after) box.yPx -= afterOrigin;
5045
- return { before, after, beforeHeightPx };
5247
+ return { before, after, beforeHeightPx, ...after.length ? { afterOrigin } : {} };
5046
5248
  }
5047
- function splitRowAtHeight(row, cutHeightPx, cellCuts) {
5249
+ function splitRowAtHeight(row, cutHeightPx, cellCuts, paragraphCuts) {
5048
5250
  const splits = row.cells.map((cell, index) => {
5049
5251
  const padding = row.cellPadding?.[index] ?? { top: 0, bottom: 0 };
5050
- const split = splitCellAtHeight(cell, (cellCuts?.[index] ?? cutHeightPx) - padding.bottom);
5252
+ const cuts = paragraphCuts ? new Map(
5253
+ cell.flatMap((box) => {
5254
+ const cut = paragraphCuts.get(box.blockId);
5255
+ return cut === void 0 ? [] : [[box.blockId, cut - padding.bottom]];
5256
+ })
5257
+ ) : void 0;
5258
+ const split = splitCellAtHeight(
5259
+ cell,
5260
+ (cellCuts?.[index] ?? cutHeightPx) - padding.bottom,
5261
+ cuts
5262
+ );
5051
5263
  if (split.before.length) split.beforeHeightPx += padding.bottom;
5052
5264
  if (split.after.length)
5053
5265
  split.after = split.after.map((box) => ({ ...box, yPx: box.yPx + padding.top }));
5054
5266
  return split;
5055
5267
  });
5056
5268
  const anyAfter = splits.some((split) => split.after.length > 0);
5269
+ const beforeHeightPx = Math.max(0, ...splits.map((split) => split.beforeHeightPx));
5057
5270
  const before = {
5058
- heightPx: Math.max(0, ...splits.map((split) => split.beforeHeightPx)),
5271
+ heightPx: beforeHeightPx,
5059
5272
  cells: splits.map((split) => split.before),
5273
+ ...row.cellTables ? {
5274
+ cellTables: row.cellTables.map(
5275
+ (tables, index) => clipTableFrames(
5276
+ tables,
5277
+ 0,
5278
+ splits[index].beforeHeightPx - (row.cellPadding?.[index]?.bottom ?? 0)
5279
+ )
5280
+ )
5281
+ } : {},
5060
5282
  geometry: row.geometry.map((geometry, index) => ({
5061
5283
  ...geometry,
5062
- contentHeightPx: splits[index].beforeHeightPx
5284
+ contentHeightPx: splits[index].beforeHeightPx,
5285
+ ...row.borderBottomPx !== void 0 ? { alignmentHeightPx: beforeHeightPx } : {}
5063
5286
  })),
5064
- ...row.cellPadding ? { cellPadding: row.cellPadding } : {}
5287
+ ...row.cellPadding ? { cellPadding: row.cellPadding } : {},
5288
+ ...row.borderBottomPx !== void 0 ? { borderBottomPx: row.borderBottomPx } : {}
5065
5289
  };
5066
5290
  if (!anyAfter) return { before, after: null };
5291
+ const afterHeightPx = Math.max(
5292
+ 0,
5293
+ ...splits.map(
5294
+ (split, index) => cellContentBottom(split.after, row.cellPadding?.[index]?.bottom ?? 0)
5295
+ )
5296
+ );
5067
5297
  const after = {
5068
- heightPx: Math.max(
5069
- 0,
5070
- ...splits.map(
5071
- (split, index) => split.after.length ? split.after.at(-1).yPx + split.after.at(-1).heightPx + (row.cellPadding?.[index]?.bottom ?? 0) : 0
5072
- )
5073
- ),
5298
+ heightPx: afterHeightPx,
5074
5299
  cells: splits.map((split) => split.after),
5300
+ ...row.cellTables ? {
5301
+ cellTables: row.cellTables.map(
5302
+ (tables, index) => splits[index].after.length ? clipTableFrames(
5303
+ tables,
5304
+ splits[index].afterOrigin ?? 0,
5305
+ row.heightPx,
5306
+ row.cellPadding?.[index]?.top ?? 0
5307
+ ) : []
5308
+ )
5309
+ } : {},
5075
5310
  geometry: row.geometry.map((geometry, index) => ({
5076
5311
  ...geometry,
5077
- contentHeightPx: splits[index].after.length ? splits[index].after.at(-1).yPx + splits[index].after.at(-1).heightPx + (row.cellPadding?.[index]?.bottom ?? 0) : 0
5312
+ contentHeightPx: cellContentBottom(
5313
+ splits[index].after,
5314
+ row.cellPadding?.[index]?.bottom ?? 0
5315
+ ),
5316
+ ...row.borderBottomPx !== void 0 ? { alignmentHeightPx: afterHeightPx } : {}
5078
5317
  })),
5079
- ...row.cellPadding ? { cellPadding: row.cellPadding } : {}
5318
+ ...row.cellPadding ? { cellPadding: row.cellPadding } : {},
5319
+ ...row.borderBottomPx !== void 0 ? { borderBottomPx: row.borderBottomPx } : {}
5080
5320
  };
5081
5321
  return { before, after };
5082
5322
  }
@@ -5137,11 +5377,11 @@ function splitNote(note, budget) {
5137
5377
  // docx/layout/footnote-columns.ts
5138
5378
  function footnoteColumns(page, columns) {
5139
5379
  const width = page.widthPx - page.marginLeftPx - page.marginRightPx;
5140
- const equal = (width - columns.gapPx * (columns.count - 1)) / columns.count;
5380
+ const equal2 = (width - columns.gapPx * (columns.count - 1)) / columns.count;
5141
5381
  let x = 0;
5142
5382
  return Array.from({ length: columns.count }, (_, index) => {
5143
5383
  const own = columns.widths?.[index];
5144
- const column = { xPx: x, widthPx: Math.max(1, own?.widthPx ?? equal) };
5384
+ const column = { xPx: x, widthPx: Math.max(1, own?.widthPx ?? equal2) };
5145
5385
  x += column.widthPx + (own?.gapPx ?? columns.gapPx);
5146
5386
  return column;
5147
5387
  });
@@ -5549,6 +5789,10 @@ var PageCursor = class {
5549
5789
  this.page.heightPx - this.page.marginTopPx - this.geometry.marginBottomPx - this.columnTopPx
5550
5790
  );
5551
5791
  }
5792
+ /** Number of independently balanced note columns, distinct from legacy body-column notes. */
5793
+ get footnoteColumnCount() {
5794
+ return this.legacyFootnoteColumns ? 1 : this.noteColumns?.count ?? 1;
5795
+ }
5552
5796
  remainingHeightPx() {
5553
5797
  return this.columnHeightPx - (this.yPx - this.columnTopPx) - this.footnotes.reserved(this.page, this.noteColumnIndex) - this.pendingHeightPx();
5554
5798
  }
@@ -5793,20 +6037,133 @@ function placeParagraph(cursor, placement, note) {
5793
6037
  }
5794
6038
  }
5795
6039
 
6040
+ // docx/layout/table-note-stories.ts
6041
+ function independentNoteStories(cell) {
6042
+ const first3 = cell.blocks?.[0];
6043
+ if (first3?.kind !== "table" || first3.rows.length !== 1 || cell.verticalAlign && cell.verticalAlign !== "top")
6044
+ return void 0;
6045
+ if (cell.blocks.slice(1).some((block) => block.kind !== "paragraph" || block.footnotes?.length))
6046
+ return void 0;
6047
+ const row = first3.rows[0];
6048
+ if (row.heightPx !== void 0 || row.cantSplit || row.isHeader || !nestedFrameProfile(first3, first3.widthPx))
6049
+ return void 0;
6050
+ if (row.cells.some(
6051
+ (inner) => inner.blocks?.some((block) => block.kind === "table") || cellParagraphs(inner).some(
6052
+ (paragraph) => paragraph.keepLines || paragraph.keepNext || paragraph.pageBreakBefore
6053
+ ) || inner.verticalAlign && inner.verticalAlign !== "top"
6054
+ ))
6055
+ return void 0;
6056
+ if (!measuredNoteReferences(row.cells.flatMap(cellParagraphs))) return void 0;
6057
+ const groups = /* @__PURE__ */ new Map();
6058
+ row.cells.forEach((inner, index) => {
6059
+ for (const paragraph of cellParagraphs(inner)) groups.set(paragraph.id, first3.id + ":" + index);
6060
+ });
6061
+ return groups.size ? groups : void 0;
6062
+ }
6063
+ function measuredNoteReferences(paragraphs) {
6064
+ const markers = paragraphs.flatMap(
6065
+ (paragraph) => paragraph.runs.flatMap(
6066
+ (run) => run.footnoteReferenceId === void 0 ? [] : [run.footnoteReferenceId]
6067
+ )
6068
+ );
6069
+ const ids = new Set(markers);
6070
+ const unanchored = paragraphs.flatMap(
6071
+ (paragraph) => (paragraph.footnotes ?? []).filter(
6072
+ (note) => !paragraph.runs.some((run) => run.footnoteReferenceId === note.id)
6073
+ )
6074
+ ).length;
6075
+ return markers.length + unanchored <= 3 && ids.size === markers.length && !(markers.length + unanchored > 1 && unanchored);
6076
+ }
6077
+
6078
+ // docx/layout/table-border-layout.ts
6079
+ function layoutBorderedRow(row, width, measurer, note, profile, remaining, physicalFragments) {
6080
+ const reserved = profile !== void 0 && (profile.leftPx > 0 || profile.rightPx > 0 || profile.bottomPx > 0);
6081
+ const layout = layoutRow(
6082
+ row,
6083
+ width,
6084
+ measurer,
6085
+ note,
6086
+ remaining,
6087
+ void 0,
6088
+ reserved,
6089
+ profile?.leftPx,
6090
+ physicalFragments
6091
+ );
6092
+ if (!reserved) return layout;
6093
+ const bottom = Math.max(0, ...layout.geometry.map((cell) => cell.borders?.bottom?.widthPx ?? 0));
6094
+ return {
6095
+ ...layout,
6096
+ heightPx: layout.heightPx + bottom,
6097
+ borderBottomPx: bottom,
6098
+ cellPadding: row.cells.map((cell) => ({
6099
+ top: (cell.padding?.top ?? 0) + (cell.borders?.top?.widthPx ?? 0),
6100
+ bottom: (cell.padding?.bottom ?? 0) + (cell.borders?.bottom?.widthPx ?? 0)
6101
+ }))
6102
+ };
6103
+ }
6104
+ var TableFragmentBorders = class {
6105
+ bottom = 0;
6106
+ included = true;
6107
+ record(bottom) {
6108
+ this.bottom = bottom ?? 0;
6109
+ this.included = true;
6110
+ }
6111
+ remove(row) {
6112
+ if (!row || !this.included) return 0;
6113
+ row.heightPx -= this.bottom;
6114
+ this.included = false;
6115
+ return -this.bottom;
6116
+ }
6117
+ restore(row) {
6118
+ if (!row || this.included) return 0;
6119
+ row.heightPx += this.bottom;
6120
+ this.included = true;
6121
+ return this.bottom;
6122
+ }
6123
+ };
6124
+
6125
+ // docx/layout/table-note-completion.ts
6126
+ function completedNoteStoryMinimum(row, stories, pendingBlocks, available) {
6127
+ let minimum = 0;
6128
+ for (const [index, cell] of row.cells.entries()) {
6129
+ const groups = /* @__PURE__ */ new Map();
6130
+ for (const box of cell) {
6131
+ const group = stories.get(box.blockId);
6132
+ if (group !== void 0) {
6133
+ const boxes = groups.get(group) ?? [];
6134
+ boxes.push(box);
6135
+ groups.set(group, boxes);
6136
+ }
6137
+ }
6138
+ for (const boxes of groups.values()) {
6139
+ if (boxes.reduce((count, box) => count + box.lines.length, 0) !== 1 || boxes.some((box) => pendingBlocks.has(box.blockId)))
6140
+ continue;
6141
+ const bottom = cellContentBottom(boxes, row.cellPadding?.[index]?.bottom ?? 0);
6142
+ if (bottom <= available + 1e-6) minimum = Math.max(minimum, bottom);
6143
+ }
6144
+ }
6145
+ return minimum;
6146
+ }
6147
+
5796
6148
  // docx/layout/table-footnotes.ts
5797
- function prefix(row, cut, cellCuts) {
6149
+ function prefix(row, cut, cellCuts, paragraphCuts) {
5798
6150
  const cells = row.cells.map((cell, index) => {
5799
- const contentCut = (cellCuts?.[index] ?? cut) - (row.cellPadding?.[index]?.bottom ?? 0);
6151
+ const padding = row.cellPadding?.[index]?.bottom ?? 0;
5800
6152
  const boxes = [];
5801
6153
  for (const box of cell) {
5802
- if (box.yPx >= contentCut + 1e-6) break;
5803
- if (box.yPx + box.heightPx <= contentCut + 1e-6) {
6154
+ const contentCut = (paragraphCuts?.get(box.blockId) ?? cellCuts?.[index] ?? cut) - padding;
6155
+ if (box.yPx >= contentCut + 1e-6) {
6156
+ if (!paragraphCuts?.size) break;
6157
+ continue;
6158
+ }
6159
+ if (box.yPx + box.heightPx + (box.tableFrameInsets?.bottom ?? 0) <= contentCut + 1e-6) {
5804
6160
  boxes.push(box);
5805
6161
  continue;
5806
6162
  }
5807
6163
  const lines = [];
5808
6164
  for (const line2 of box.lines) {
5809
- if (box.yPx + line2.yPx + line2.heightPx > contentCut + 1e-6) break;
6165
+ if (box.yPx + line2.yPx + line2.heightPx + (box.tableFrameInsets?.bottom ?? 0) > contentCut + 1e-6)
6166
+ break;
5810
6167
  lines.push(line2);
5811
6168
  }
5812
6169
  if (lines.length)
@@ -5826,9 +6183,7 @@ function prefix(row, cut, cellCuts) {
5826
6183
  cells,
5827
6184
  heightPx: Math.max(
5828
6185
  0,
5829
- ...cells.flatMap(
5830
- (cell, index) => cell.map((box) => box.yPx + box.heightPx + (row.cellPadding?.[index]?.bottom ?? 0))
5831
- )
6186
+ ...cells.map((cell, index) => cellContentBottom(cell, row.cellPadding?.[index]?.bottom ?? 0))
5832
6187
  )
5833
6188
  };
5834
6189
  }
@@ -5838,16 +6193,23 @@ var TableFootnotes = class {
5838
6193
  this.table = table;
5839
6194
  this.height = height;
5840
6195
  this.resolve = resolve;
5841
- for (const row of table.rows)
5842
- for (const cell of row.cells)
6196
+ for (const row of table.rows) {
6197
+ const measured = measuredNoteReferences(row.cells.flatMap(cellParagraphs));
6198
+ for (const cell of row.cells) {
5843
6199
  for (const paragraph of cellParagraphs(cell))
5844
6200
  if (paragraph.footnotes?.length) this.paragraphs.set(paragraph.id, paragraph);
6201
+ for (const [id, group] of (measured ? independentNoteStories(cell) : void 0) ?? []) {
6202
+ this.stories.set(id, group);
6203
+ }
6204
+ }
6205
+ }
5845
6206
  }
5846
6207
  cursor;
5847
6208
  table;
5848
6209
  height;
5849
6210
  resolve;
5850
6211
  paragraphs = /* @__PURE__ */ new Map();
6212
+ stories = /* @__PURE__ */ new Map();
5851
6213
  placed = /* @__PURE__ */ new Set();
5852
6214
  fragment = /* @__PURE__ */ new Map();
5853
6215
  references(row) {
@@ -5869,14 +6231,30 @@ var TableFootnotes = class {
5869
6231
  ) ?? box.lines[0];
5870
6232
  const bottom = Math.min(
5871
6233
  row.heightPx,
5872
- box.yPx + (line2?.yPx ?? 0) + (line2?.heightPx ?? box.heightPx)
6234
+ box.yPx + (line2?.yPx ?? 0) + (line2?.heightPx ?? box.heightPx) + (box.tableFrameInsets?.bottom ?? 0)
5873
6235
  );
5874
6236
  const prior = refs.get(note.id);
5875
- if (!prior || bottom < prior.bottom) refs.set(note.id, { note, bottom });
6237
+ if (!prior || bottom < prior.bottom)
6238
+ refs.set(note.id, {
6239
+ note,
6240
+ bottom,
6241
+ blockId: box.blockId,
6242
+ before: box.yPx + (line2?.yPx ?? 0) + (box.tableFrameInsets?.bottom ?? 0)
6243
+ });
5876
6244
  }
5877
6245
  }
5878
6246
  return [...refs.values()];
5879
6247
  }
6248
+ /** A consumed marker no longer constrains its story. Deferred markers stop just before
6249
+ * their own line, allowing another pending story to use a different complete prefix. */
6250
+ storyCut(pending, boxes, padding, cut, space, included) {
6251
+ const ids = new Set(boxes.map((box) => box.blockId));
6252
+ const refs = pending.filter((ref) => ids.has(ref.blockId));
6253
+ let limit = refs.some((ref) => included.has(ref.note.id)) ? Math.min(cut, space) : space;
6254
+ for (const ref of refs)
6255
+ if (!included.has(ref.note.id)) limit = Math.min(limit, ref.before + padding);
6256
+ return limit;
6257
+ }
5880
6258
  hold(refs, minimumBody = 0) {
5881
6259
  const referenceBottom = Math.max(0, ...[...refs.values()].map((ref) => ref.bottom));
5882
6260
  const bodyHeight = Math.max(referenceBottom, minimumBody);
@@ -5887,17 +6265,20 @@ var TableFootnotes = class {
5887
6265
  this.cursor.usedColumnHeightPx + referenceBottom
5888
6266
  );
5889
6267
  }
5890
- holdCandidate(row) {
6268
+ holdCandidate(row, completionMinimum = 0) {
5891
6269
  const refs = new Map(this.fragment);
5892
6270
  for (const ref of this.references(row))
5893
6271
  if (!refs.has(ref.note.id))
5894
6272
  refs.set(ref.note.id, { ...ref, bottom: this.height() + ref.bottom });
5895
6273
  const referenceBottom = Math.max(0, ...[...refs.values()].map((ref) => ref.bottom));
5896
- const contentBottom = this.height() + Math.max(0, ...row.cells.flatMap((cell) => cell.map((box) => box.yPx + box.heightPx)));
6274
+ const contentBottom = this.height() + Math.max(0, ...row.cells.map((cell) => cellContentBottom(cell)));
5897
6275
  const paddingBottom = Math.max(0, ...(row.cellPadding ?? []).map((padding) => padding.bottom));
5898
6276
  this.hold(
5899
6277
  refs,
5900
- contentBottom <= referenceBottom + 1e-6 ? this.height() + row.heightPx : referenceBottom + paddingBottom
6278
+ Math.max(
6279
+ completionMinimum,
6280
+ contentBottom <= referenceBottom + 1e-6 ? this.height() + row.heightPx : referenceBottom + paddingBottom
6281
+ )
5901
6282
  );
5902
6283
  }
5903
6284
  /** Largest complete prefix that keeps each new marker with available note content. */
@@ -5910,29 +6291,76 @@ var TableFootnotes = class {
5910
6291
  return { layout: row, cut: row.heightPx };
5911
6292
  }
5912
6293
  if (!atomic) {
6294
+ const independent = row.cells.some(
6295
+ (cell) => cell.some((box) => this.stories.has(box.blockId))
6296
+ );
6297
+ const pending = independent ? this.references(row) : [];
6298
+ const completing = (this.cursor.footnoteColumnCount === 2 || this.cursor.footnoteColumnCount === 3) && pending.length === 1 && !this.stories.has(pending[0].blockId) ? completedNoteStoryMinimum(
6299
+ row,
6300
+ this.stories,
6301
+ new Set(pending.map((ref) => ref.blockId)),
6302
+ available
6303
+ ) : 0;
5913
6304
  const cuts = /* @__PURE__ */ new Set();
5914
6305
  for (const [index, cell] of row.cells.entries())
5915
6306
  for (const box of cell) {
5916
6307
  if (box.yPx > available + 1e-6) break;
5917
6308
  for (const line2 of box.lines) {
5918
- const bottom = box.yPx + line2.yPx + line2.heightPx + (row.cellPadding?.[index]?.bottom ?? 0);
6309
+ const bottom = box.yPx + line2.yPx + line2.heightPx + (box.tableFrameInsets?.bottom ?? 0) + (row.cellPadding?.[index]?.bottom ?? 0);
5919
6310
  if (bottom > available + 1e-6) break;
5920
6311
  if (bottom > 0) cuts.add(bottom);
5921
6312
  }
5922
6313
  }
5923
6314
  for (const cut of [...cuts].sort((a, b) => b - a)) {
5924
6315
  const candidate = prefix(row, cut);
5925
- this.holdCandidate(candidate);
6316
+ const included = new Set(this.references(candidate).map((ref) => ref.note.id));
6317
+ const completion = completing > 0 && included.has(pending[0]?.note.id ?? "") ? this.height() + completing : 0;
6318
+ this.holdCandidate(candidate, completion);
5926
6319
  if (candidate.heightPx <= this.cursor.remainingHeightPx() - this.height() + 1e-6) {
5927
6320
  const space = this.cursor.remainingHeightPx() - this.height();
5928
6321
  const cellCuts = row.cells.map(
5929
- (cell) => cell.some((box) => this.paragraphs.has(box.blockId)) ? cut : space
6322
+ (cell, index) => independent ? this.storyCut(
6323
+ pending,
6324
+ cell,
6325
+ row.cellPadding?.[index]?.bottom ?? 0,
6326
+ cut,
6327
+ space,
6328
+ included
6329
+ ) : cell.some((box) => this.paragraphs.has(box.blockId)) ? cut : space
5930
6330
  );
5931
- const expanded = prefix(row, cut, cellCuts);
5932
- this.holdCandidate(expanded);
6331
+ const paragraphCuts = /* @__PURE__ */ new Map();
6332
+ for (const [index, cell] of row.cells.entries()) {
6333
+ const groups = /* @__PURE__ */ new Map();
6334
+ for (const box of cell) {
6335
+ const group = this.stories.get(box.blockId);
6336
+ if (group !== void 0) {
6337
+ const boxes = groups.get(group) ?? [];
6338
+ boxes.push(box);
6339
+ groups.set(group, boxes);
6340
+ }
6341
+ }
6342
+ for (const boxes of groups.values()) {
6343
+ const limit = this.storyCut(
6344
+ pending,
6345
+ boxes,
6346
+ row.cellPadding?.[index]?.bottom ?? 0,
6347
+ cut,
6348
+ space,
6349
+ included
6350
+ );
6351
+ for (const box of boxes) paragraphCuts.set(box.blockId, limit);
6352
+ }
6353
+ }
6354
+ const expanded = prefix(row, cut, cellCuts, paragraphCuts);
6355
+ this.holdCandidate(expanded, completion);
5933
6356
  if (expanded.heightPx <= this.cursor.remainingHeightPx() - this.height() + 1e-6)
5934
- return { layout: expanded, cut, cellCuts };
5935
- this.holdCandidate(candidate);
6357
+ return {
6358
+ layout: expanded,
6359
+ cut,
6360
+ cellCuts,
6361
+ ...paragraphCuts.size ? { paragraphCuts } : {}
6362
+ };
6363
+ this.holdCandidate(candidate, completion);
5936
6364
  return { layout: candidate, cut };
5937
6365
  }
5938
6366
  }
@@ -5959,26 +6387,47 @@ var TableFootnotes = class {
5959
6387
  function placeTable(cursor, table, measurer, note, resolveFootnotes) {
5960
6388
  const firstBodyRow = table.rows.findIndex((row) => !row.isHeader);
5961
6389
  const headerRows = table.rows.slice(0, firstBodyRow < 0 ? table.rows.length : firstBodyRow);
6390
+ const nativeFragments = new Map(table.rows.map((row) => [row, reflowNestedFragments(row)]));
5962
6391
  const xPosition = () => {
5963
- const width = table.widthPx ?? cursor.columnWidthPx;
6392
+ const width = (table.widthPx ?? cursor.columnWidthPx) + (activeBorders ? (profile.leftPx + profile.rightPx) / 2 : 0);
5964
6393
  return table.alignment === "center" ? Math.max(0, (cursor.columnWidthPx - width) / 2) : table.alignment === "right" ? Math.max(0, cursor.columnWidthPx - width) : table.indentPx ?? 0;
5965
6394
  };
6395
+ const profile = nestedFrameProfile(table, table.widthPx ?? cursor.columnWidthPx);
6396
+ const activeBorders = profile !== void 0 && (profile.leftPx > 0 || profile.rightPx > 0 || profile.bottomPx > 0);
6397
+ if (!profile && table.rows.some((row) => row.cells.some((cell) => cell.borders)))
6398
+ note(
6399
+ "Ordinary table border occupancy remains approximate for missing edges, non-solid or conflicting shared borders and changing row grids."
6400
+ );
6401
+ const layoutRow2 = (row, width, m, n2, remaining, sourceRow = row) => layoutBorderedRow(
6402
+ row,
6403
+ activeBorders ? table.widthPx ?? width : width,
6404
+ m,
6405
+ n2,
6406
+ profile,
6407
+ remaining,
6408
+ nativeFragments.get(sourceRow) ?? false
6409
+ );
6410
+ const fragmentBorders = new TableFragmentBorders();
5966
6411
  let fragmentRows = [];
5967
6412
  let fragmentHeight = 0;
5968
6413
  const footnotes = resolveFootnotes ? new TableFootnotes(cursor, table, () => fragmentHeight, resolveFootnotes) : void 0;
5969
6414
  const toRowBox = (layout, repeated) => {
6415
+ fragmentHeight += fragmentBorders.remove(fragmentRows.at(-1));
5970
6416
  footnotes?.add(layout, repeated);
5971
6417
  const box = {
5972
6418
  yPx: fragmentHeight,
5973
6419
  heightPx: layout.heightPx,
5974
6420
  repeated,
5975
6421
  cells: layout.cells,
5976
- geometry: layout.geometry
6422
+ geometry: layout.geometry,
6423
+ ...layout.cellTables ? { cellTables: layout.cellTables } : {}
5977
6424
  };
5978
6425
  fragmentHeight += layout.heightPx;
6426
+ fragmentBorders.record(layout.borderBottomPx);
5979
6427
  return box;
5980
6428
  };
5981
6429
  function flushFragment() {
6430
+ fragmentHeight += fragmentBorders.restore(fragmentRows.at(-1));
5982
6431
  if (!fragmentRows.length) {
5983
6432
  footnotes?.holdFragment();
5984
6433
  return;
@@ -5986,6 +6435,9 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
5986
6435
  const box = {
5987
6436
  kind: "table",
5988
6437
  blockId: table.id,
6438
+ ...activeBorders ? {
6439
+ widthPx: (table.widthPx ?? cursor.columnWidthPx) + (profile.leftPx + profile.rightPx) / 2
6440
+ } : {},
5989
6441
  ...xPosition() ? { xPx: xPosition() } : {},
5990
6442
  yPx: 0,
5991
6443
  heightPx: fragmentHeight,
@@ -6004,15 +6456,16 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
6004
6456
  }
6005
6457
  function addHeaders() {
6006
6458
  for (const header of headerRows)
6007
- fragmentRows.push(toRowBox(layoutRow(header, cursor.columnWidthPx, measurer, note), true));
6459
+ fragmentRows.push(toRowBox(layoutRow2(header, cursor.columnWidthPx, measurer, note), true));
6008
6460
  }
6009
6461
  function placeRow(row, initial, cantSplit) {
6010
6462
  let remainingRow = initial;
6011
6463
  while (remainingRow) {
6464
+ fragmentHeight += fragmentBorders.remove(fragmentRows.at(-1));
6012
6465
  const minimum = cantSplit ? Math.min(remainingRow.heightPx, cursor.columnHeightPx) : Math.min(
6013
6466
  ...remainingRow.cells.flatMap(
6014
- (cell) => cell.map(
6015
- (paragraph) => paragraph.yPx + (paragraph.lines[0]?.yPx ?? 0) + (paragraph.lines[0]?.heightPx ?? 0)
6467
+ (cell, index) => cell.map(
6468
+ (paragraph) => paragraph.yPx + (paragraph.lines[0]?.yPx ?? 0) + (paragraph.lines[0]?.heightPx ?? 0) + (remainingRow.borderBottomPx !== void 0 ? (remainingRow.cellPadding?.[index]?.bottom ?? 0) + (paragraph.tableFrameInsets?.bottom ?? 0) : 0)
6016
6469
  )
6017
6470
  )
6018
6471
  );
@@ -6020,12 +6473,13 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
6020
6473
  const width = cursor.columnWidthPx;
6021
6474
  cursor.advancePastFootnotes(fragmentHeight + (Number.isFinite(minimum) ? minimum : 0));
6022
6475
  if (width !== cursor.columnWidthPx) {
6023
- remainingRow = layoutRow(
6476
+ remainingRow = layoutRow2(
6024
6477
  remainingRow === initial ? row : { ...row, heightPx: 0, heightRule: "atLeast" },
6025
6478
  cursor.columnWidthPx,
6026
6479
  measurer,
6027
6480
  note,
6028
- remainingRow.cells
6481
+ remainingRow.cells,
6482
+ row
6029
6483
  );
6030
6484
  if (fragmentRows.length) {
6031
6485
  fragmentRows = [];
@@ -6046,17 +6500,19 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
6046
6500
  const { before: before2, after: after2 } = splitRowAtHeight(
6047
6501
  remainingRow,
6048
6502
  selected.cut + 1e-6,
6049
- selected.cellCuts?.map((cut) => cut + 1e-6)
6503
+ selected.cellCuts?.map((cut) => cut + 1e-6),
6504
+ selected.paragraphCuts ? new Map([...selected.paragraphCuts].map(([id, cut]) => [id, cut + 1e-6])) : void 0
6050
6505
  );
6051
6506
  fragmentRows.push(toRowBox(before2, false));
6052
6507
  const previousWidth2 = cursor.columnWidthPx;
6053
6508
  startNewFragment();
6054
- remainingRow = after2 && previousWidth2 !== cursor.columnWidthPx ? layoutRow(
6509
+ remainingRow = after2 && (selected.paragraphCuts || previousWidth2 !== cursor.columnWidthPx) ? layoutRow2(
6055
6510
  { ...row, heightPx: 0, heightRule: "atLeast" },
6056
6511
  cursor.columnWidthPx,
6057
6512
  measurer,
6058
6513
  note,
6059
- after2.cells
6514
+ after2.cells,
6515
+ row
6060
6516
  ) : after2;
6061
6517
  continue;
6062
6518
  }
@@ -6064,12 +6520,13 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
6064
6520
  const previousWidth2 = cursor.columnWidthPx;
6065
6521
  startNewFragment();
6066
6522
  if (previousWidth2 !== cursor.columnWidthPx)
6067
- remainingRow = layoutRow(
6523
+ remainingRow = layoutRow2(
6068
6524
  remainingRow === initial ? row : { ...row, heightPx: 0, heightRule: "atLeast" },
6069
6525
  cursor.columnWidthPx,
6070
6526
  measurer,
6071
6527
  note,
6072
- remainingRow === initial ? void 0 : remainingRow.cells
6528
+ remainingRow === initial ? void 0 : remainingRow.cells,
6529
+ row
6073
6530
  );
6074
6531
  continue;
6075
6532
  }
@@ -6083,14 +6540,14 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
6083
6540
  if (cantSplit) {
6084
6541
  if (fragmentRows.length || !cursor.atColumnTop) {
6085
6542
  startNewFragment();
6086
- remainingRow = layoutRow(row, cursor.columnWidthPx, measurer, note);
6543
+ remainingRow = layoutRow2(row, cursor.columnWidthPx, measurer, note);
6087
6544
  }
6088
6545
  const noteWidth = cursor.columnWidthPx;
6089
6546
  cursor.advancePastFootnotes(
6090
6547
  fragmentHeight + Math.min(remainingRow.heightPx, cursor.columnHeightPx)
6091
6548
  );
6092
6549
  if (noteWidth !== cursor.columnWidthPx) {
6093
- remainingRow = layoutRow(row, cursor.columnWidthPx, measurer, note);
6550
+ remainingRow = layoutRow2(row, cursor.columnWidthPx, measurer, note);
6094
6551
  if (fragmentRows.length) {
6095
6552
  fragmentRows = [];
6096
6553
  fragmentHeight = 0;
@@ -6116,17 +6573,30 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
6116
6573
  const previousWidth = cursor.columnWidthPx;
6117
6574
  if (before.cells.some((cell) => cell.length)) fragmentRows.push(toRowBox(before, false));
6118
6575
  startNewFragment();
6119
- remainingRow = after && previousWidth !== cursor.columnWidthPx ? layoutRow(
6576
+ remainingRow = after && (previousWidth !== cursor.columnWidthPx || nativeFragments.get(row)) ? layoutRow2(
6120
6577
  { ...row, heightPx: 0, heightRule: "atLeast" },
6121
6578
  cursor.columnWidthPx,
6122
6579
  measurer,
6123
6580
  note,
6124
- after.cells
6581
+ after.cells,
6582
+ row
6125
6583
  ) : after;
6126
6584
  }
6127
6585
  }
6128
6586
  for (const row of table.rows) {
6129
- const layout = layoutRow(row, cursor.columnWidthPx, measurer, note);
6587
+ const layout = layoutRow2(row, cursor.columnWidthPx, measurer, note);
6588
+ if (layout.heightPx > cursor.remainingHeightPx() && !nativeFragments.get(row) && row.cells.some(
6589
+ (cell) => cell.blocks?.some((block) => block.kind === "table" && block.rows.length > 1)
6590
+ ))
6591
+ note(
6592
+ "Nested physical border edges at page cuts remain approximate outside automatic, top-aligned tables with two or more two-cell, note-free rows, direct paragraphs and complete shared borders."
6593
+ );
6594
+ if (activeBorders && layout.heightPx > cursor.remainingHeightPx() && row.cells.some(
6595
+ (cell) => (!measuredNoteReferences(row.cells.flatMap(cellParagraphs)) || !independentNoteStories(cell)) && cell.blocks?.some((block) => block.kind === "table") && cellParagraphs(cell).some((p) => p.footnotes?.length)
6596
+ ))
6597
+ note(
6598
+ "Independent inner-cell continuation around nested note references remains approximate when an enclosing bordered row splits."
6599
+ );
6130
6600
  placeRow(
6131
6601
  row,
6132
6602
  layout,
@@ -6384,9 +6854,9 @@ var SectionFlow = class {
6384
6854
  const page = this.cursor.page;
6385
6855
  const exclusions = this.exclusions?.get(page.index);
6386
6856
  if (!exclusions) return void 0;
6387
- const plain = this.paragraphLayout(index);
6857
+ const plain2 = this.paragraphLayout(index);
6388
6858
  const topPx = page.marginTopPx + this.cursor.y + spacingBeforePx;
6389
- const bottomPx = topPx + plain.contentHeightPx;
6859
+ const bottomPx = topPx + plain2.contentHeightPx;
6390
6860
  if (!exclusions.some((item) => item.yPx < bottomPx && item.yPx + item.heightPx > topPx))
6391
6861
  return void 0;
6392
6862
  return layoutParagraph(
@@ -6637,13 +7107,13 @@ function cssHex(value) {
6637
7107
  const hex = value?.replace(/^#/, "");
6638
7108
  return hex && /^[0-9a-f]{6}$/i.test(hex) ? `#${hex}` : void 0;
6639
7109
  }
6640
- function border(side, theme) {
7110
+ function border(side, theme, preserveSingleWidth = false) {
6641
7111
  if (!side?.style || side.style === "none" || side.style === "nil") return void 0;
6642
7112
  const style = side.style.startsWith("double") ? "double" : /dot/i.test(side.style) ? "dotted" : /dash/i.test(side.style) ? "dashed" : "solid";
6643
7113
  const themed = side.themeColor && theme ? resolveThemeColorReference({ token: side.themeColor }, theme) : void 0;
6644
7114
  const hex = cssHex(side.color);
6645
7115
  const widthPx = Math.max(
6646
- style === "double" ? 3 : 1,
7116
+ style === "double" ? 3 : preserveSingleWidth && style === "solid" ? 0 : 1,
6647
7117
  (side.sizeEighthPoints ?? 4) / 8 * 96 / 72
6648
7118
  );
6649
7119
  return { widthPx, style, color: themed ?? hex ?? "#000000" };
@@ -6656,7 +7126,7 @@ function rowLayout(props) {
6656
7126
  ...props.header ? { isHeader: true } : {}
6657
7127
  };
6658
7128
  }
6659
- function adaptTable(table, model, adaptParagraph) {
7129
+ function adaptTable(table, model, adaptParagraph, _nested = false) {
6660
7130
  const grid = table.grid?.map(twipsToPx2);
6661
7131
  const columnCount = grid?.length ?? Math.max(1, ...table.rows.map((row) => row.length));
6662
7132
  const gridWidth = (start, span) => grid ? grid.slice(start, start + span).reduce((sum, width) => sum + width, 0) : void 0;
@@ -6698,7 +7168,7 @@ function adaptTable(table, model, adaptParagraph) {
6698
7168
  );
6699
7169
  const borders = {};
6700
7170
  for (const side of ["top", "right", "bottom", "left"]) {
6701
- const resolved = border(visuals.borders?.[side], model.theme);
7171
+ const resolved = border(visuals.borders?.[side], model.theme, true);
6702
7172
  if (resolved) borders[side] = resolved;
6703
7173
  }
6704
7174
  if (cell.verticalMerge === "continue") delete borders.top;
@@ -6717,7 +7187,7 @@ function adaptTable(table, model, adaptParagraph) {
6717
7187
  paragraphs: cell.paragraphs.map(adaptParagraph),
6718
7188
  ...cell.sourceBlocks ? {
6719
7189
  blocks: cellSourceBlocks(cell).map(
6720
- (block) => block.type === "paragraph" ? adaptParagraph(block) : adaptTable(block, model, adaptParagraph)
7190
+ (block) => block.type === "paragraph" ? adaptParagraph(block) : adaptTable(block, model, adaptParagraph, true)
6721
7191
  )
6722
7192
  } : {},
6723
7193
  ...width !== void 0 ? { widthPx: width } : {},
@@ -7017,7 +7487,7 @@ function adaptDocumentModel(model, note = () => {
7017
7487
  reportOnce(VERTICAL_MERGE_NOTE);
7018
7488
  if (block.rows.some((row) => row.some((cell) => cell.nestedTables?.length)))
7019
7489
  reportOnce(
7020
- "Nested tables are projected as read-only cell paragraphs in Print Layout; their borders, shading, vertical merge and repeated header geometry are not rendered."
7490
+ "Nested tables are projected as read-only cell paragraphs in Print Layout; vertical merge and repeated header geometry are not rendered."
7021
7491
  );
7022
7492
  return adaptTable(block, model, adaptParagraph);
7023
7493
  }
@@ -7284,4 +7754,4 @@ function cssFontStack(family) {
7284
7754
  );
7285
7755
  }
7286
7756
 
7287
- export { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE_PT, DEFAULT_TAB_STOP_PX, FLOAT_WRAP_NOTE, NO_TWIPS, PageCursor, SINGLE_LINE_SPACING_UNITS, adaptDocumentModel, adjustForWidowOrphan, appendBreakMarker, createFakeMeasurer, cssFontStack, fieldDisplayText, floatPosition, fontMetrics, headerFooterForPage, isEastAsianChar, layoutDocument, layoutDocumentModel, layoutParagraph, layoutRow, layoutSections, ligatureCss, pageNumberValues, pageNumbers, paragraphFloats, placeParagraph, placeTab, placeTable, positionFloats, ptToPx, pxToTwips, sectionPageCounts, splitRowAtHeight, suppressesSpacing, tokenizeRun, twipsToPx, widowControlEnabled };
7757
+ export { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE_PT, DEFAULT_TAB_STOP_PX, FLOAT_WRAP_NOTE, NO_TWIPS, PageCursor, SINGLE_LINE_SPACING_UNITS, adaptDocumentModel, adjustForWidowOrphan, appendBreakMarker, cellVerticalOffset, createFakeMeasurer, cssFontStack, fieldDisplayText, floatPosition, fontMetrics, headerFooterForPage, isEastAsianChar, layoutDocument, layoutDocumentModel, layoutParagraph, layoutRow, layoutSections, ligatureCss, pageNumberValues, pageNumbers, paragraphFloats, placeParagraph, placeTab, placeTable, positionFloats, ptToPx, pxToTwips, sectionPageCounts, splitRowAtHeight, suppressesSpacing, tokenizeRun, twipsToPx, widowControlEnabled };