@superdoc-dev/cli 0.16.0-next.23 → 0.16.0-next.25

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 (2) hide show
  1. package/dist/index.js +706 -300
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -59714,7 +59714,7 @@ var init_uuid_qzgm05fK_es = __esm(() => {
59714
59714
  v5_default = v35("v5", 80, sha1);
59715
59715
  });
59716
59716
 
59717
- // ../../packages/superdoc/dist/chunks/constants-D-X7xF4s.es.js
59717
+ // ../../packages/superdoc/dist/chunks/constants-D9qj59G2.es.js
59718
59718
  function toProtocolSet(values) {
59719
59719
  const result = /* @__PURE__ */ new Set;
59720
59720
  if (!values)
@@ -60300,7 +60300,7 @@ var DEFAULT_ALLOWED_PROTOCOLS, OPTIONAL_PROTOCOLS, BLOCKED_PROTOCOLS, DEFAULT_MA
60300
60300
  return a.length === 1 ? "0" + a : a;
60301
60301
  }, rgbToHex = (rgb) => {
60302
60302
  return "#" + rgb.match(/\d+/g).map(componentToHex).join("");
60303
- }, DEFAULT_SHADING_FOREGROUND_COLOR = "#000000", hexToRgb = (hex) => {
60303
+ }, DEFAULT_SHADING_FOREGROUND_COLOR = "#000000", DEFAULT_SHADING_FILL_COLOR = "#FFFFFF", hexToRgb = (hex) => {
60304
60304
  const normalized = normalizeHexColor(hex);
60305
60305
  if (!normalized)
60306
60306
  return null;
@@ -60327,16 +60327,19 @@ var DEFAULT_ALLOWED_PROTOCOLS, OPTIONAL_PROTOCOLS, BLOCKED_PROTOCOLS, DEFAULT_MA
60327
60327
  }, resolveShadingFillColor = (shading) => {
60328
60328
  if (!shading || typeof shading !== "object")
60329
60329
  return null;
60330
- const fill = normalizeHexColor(shading.fill);
60331
- if (!fill)
60330
+ const val = typeof shading.val === "string" ? shading.val.trim().toLowerCase() : "";
60331
+ if (val === "nil" || val === "none")
60332
60332
  return null;
60333
- const pctMatch = (typeof shading.val === "string" ? shading.val.trim().toLowerCase() : "").match(/^pct(\d{1,3})$/);
60334
- if (!pctMatch)
60335
- return fill;
60336
- const pct = Number.parseInt(pctMatch[1], 10);
60333
+ const fillHex = typeof shading.fill === "string" && shading.fill.trim().toLowerCase() === "auto" ? null : normalizeHexColor(shading.fill);
60334
+ const pctMatch = val.match(/^pct(\d{1,3})$/);
60335
+ if (!(Boolean(pctMatch) || val === "solid"))
60336
+ return fillHex;
60337
+ const baseHex = fillHex ?? DEFAULT_SHADING_FILL_COLOR;
60338
+ const foregroundHex = typeof shading.color !== "string" || shading.color.trim() === "" || shading.color.trim().toLowerCase() === "auto" ? DEFAULT_SHADING_FOREGROUND_COLOR : normalizeHexColor(shading.color) ?? DEFAULT_SHADING_FOREGROUND_COLOR;
60339
+ const pct = pctMatch ? Number.parseInt(pctMatch[1], 10) : 100;
60337
60340
  if (!Number.isFinite(pct) || pct < 0 || pct > 100)
60338
- return fill;
60339
- return blendHexColors(fill, normalizeHexColor(shading.color) ?? DEFAULT_SHADING_FOREGROUND_COLOR, pct / 100) ?? fill;
60341
+ return fillHex;
60342
+ return blendHexColors(baseHex, foregroundHex, pct / 100) ?? fillHex;
60340
60343
  }, deobfuscateFont = (arrayBuffer, guidHex) => {
60341
60344
  const dta = new Uint8Array(arrayBuffer);
60342
60345
  const guidStr = guidHex.replace(/[-{}]/g, "");
@@ -60382,7 +60385,7 @@ var DEFAULT_ALLOWED_PROTOCOLS, OPTIONAL_PROTOCOLS, BLOCKED_PROTOCOLS, DEFAULT_MA
60382
60385
  return "webp";
60383
60386
  return null;
60384
60387
  }, COMMENT_FILE_BASENAMES, DEFAULT_XML_DECLARATION, COMMENT_RELATIONSHIP_TYPES;
60385
- var init_constants_D_X7xF4s_es = __esm(() => {
60388
+ var init_constants_D9qj59G2_es = __esm(() => {
60386
60389
  init_jszip_C49i9kUs_es();
60387
60390
  init_xml_js_CqGKpaft_es();
60388
60391
  init_dist4();
@@ -68342,7 +68345,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
68342
68345
  emptyOptions2 = {};
68343
68346
  });
68344
68347
 
68345
- // ../../packages/superdoc/dist/chunks/SuperConverter-B9mZiCO9.es.js
68348
+ // ../../packages/superdoc/dist/chunks/SuperConverter-DBsJeu9t.es.js
68346
68349
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
68347
68350
  const fieldValue = extension$1.config[field];
68348
68351
  if (typeof fieldValue === "function")
@@ -78291,6 +78294,70 @@ function computeFragmentPmRange(block, lines, fromLine, toLine) {
78291
78294
  pmEnd
78292
78295
  };
78293
78296
  }
78297
+ function resolveAnchoredGraphicY(input) {
78298
+ const { anchor, objectHeight, contentTop, contentBottom, pageBottomMargin = 0, anchorParagraphY = contentTop, firstLineHeight = 0, preRegisteredFallbackToContentTop = false } = input;
78299
+ const offsetV = anchor?.offsetV ?? 0;
78300
+ const vRelativeFrom = anchor?.vRelativeFrom;
78301
+ const alignV = anchor?.alignV;
78302
+ const contentHeight = Math.max(0, contentBottom - contentTop);
78303
+ if (vRelativeFrom === "margin") {
78304
+ if (alignV === "bottom")
78305
+ return contentBottom - objectHeight + offsetV;
78306
+ if (alignV === "center")
78307
+ return contentTop + (contentHeight - objectHeight) / 2 + offsetV;
78308
+ return contentTop + offsetV;
78309
+ }
78310
+ if (vRelativeFrom === "page") {
78311
+ const pageHeight = contentBottom + pageBottomMargin;
78312
+ if (alignV === "bottom")
78313
+ return pageHeight - objectHeight + offsetV;
78314
+ if (alignV === "center")
78315
+ return (pageHeight - objectHeight) / 2 + offsetV;
78316
+ return offsetV;
78317
+ }
78318
+ if (vRelativeFrom === "paragraph") {
78319
+ if (preRegisteredFallbackToContentTop)
78320
+ return contentTop + offsetV;
78321
+ const baseAnchorY = anchorParagraphY;
78322
+ if (alignV === "bottom")
78323
+ return baseAnchorY + firstLineHeight - objectHeight + offsetV;
78324
+ if (alignV === "center")
78325
+ return baseAnchorY + (firstLineHeight - objectHeight) / 2 + offsetV;
78326
+ return baseAnchorY + offsetV;
78327
+ }
78328
+ if (preRegisteredFallbackToContentTop)
78329
+ return contentTop + offsetV;
78330
+ return anchorParagraphY + offsetV;
78331
+ }
78332
+ function resolveAnchoredGraphicX(anchor, columnIndex, columns, objectWidth, margins, pageWidth) {
78333
+ const alignH = anchor.alignH ?? "left";
78334
+ const offsetH = anchor.offsetH ?? 0;
78335
+ const marginLeft = Math.max(0, margins?.left ?? 0);
78336
+ const marginRight = Math.max(0, margins?.right ?? 0);
78337
+ const contentWidth = pageWidth != null ? Math.max(1, pageWidth - (marginLeft + marginRight)) : columns.width;
78338
+ const contentLeft = marginLeft;
78339
+ const columnLeft = contentLeft + columnIndex * (columns.width + columns.gap);
78340
+ const relativeFrom = anchor.hRelativeFrom ?? "column";
78341
+ let baseX;
78342
+ let availableWidth;
78343
+ if (relativeFrom === "page") {
78344
+ baseX = 0;
78345
+ availableWidth = pageWidth != null ? pageWidth : contentWidth + marginLeft + marginRight;
78346
+ } else if (relativeFrom === "margin") {
78347
+ baseX = contentLeft;
78348
+ availableWidth = contentWidth;
78349
+ } else {
78350
+ baseX = columnLeft;
78351
+ availableWidth = columns.width;
78352
+ }
78353
+ if (alignH === "left")
78354
+ return baseX + offsetH;
78355
+ if (alignH === "right")
78356
+ return baseX + availableWidth - objectWidth - offsetH;
78357
+ if (alignH === "center")
78358
+ return baseX + (availableWidth - objectWidth) / 2 + offsetH;
78359
+ return baseX;
78360
+ }
78294
78361
  function widthsEqual(a, b) {
78295
78362
  if (!a && !b)
78296
78363
  return true;
@@ -78317,10 +78384,12 @@ function cloneColumnLayout(columns) {
78317
78384
  }
78318
78385
  function normalizeColumnLayout(input, contentWidth, epsilon = 0.0001) {
78319
78386
  const rawCount = input && Number.isFinite(input.count) ? Math.floor(input.count) : 1;
78320
- const count2 = Math.max(1, rawCount || 1);
78387
+ let count2 = Math.max(1, rawCount || 1);
78321
78388
  const gap = Math.max(0, input?.gap ?? 0);
78389
+ const explicitWidths = input?.equalWidth === false && Array.isArray(input?.widths) && input.widths.length > 0 ? input.widths.filter((width$1) => typeof width$1 === "number" && Number.isFinite(width$1) && width$1 > 0) : [];
78390
+ if (explicitWidths.length > 0 && explicitWidths.length < count2)
78391
+ count2 = explicitWidths.length;
78322
78392
  const availableWidth = contentWidth - gap * (count2 - 1);
78323
- const explicitWidths = Array.isArray(input?.widths) && input.widths.length > 0 ? input.widths.filter((width$1) => typeof width$1 === "number" && Number.isFinite(width$1) && width$1 > 0) : [];
78324
78393
  let widths = explicitWidths.length > 0 ? explicitWidths.slice(0, count2) : Array.from({ length: count2 }, () => availableWidth > 0 ? availableWidth / count2 : contentWidth);
78325
78394
  if (widths.length < count2) {
78326
78395
  const remaining = Math.max(0, availableWidth - widths.reduce((sum, width$1) => sum + width$1, 0));
@@ -83755,6 +83824,8 @@ function handleImageNode$1(node3, params3, isAnchor) {
83755
83824
  default:
83756
83825
  break;
83757
83826
  }
83827
+ if (wrap$1.type === "Square" || wrap$1.type === "Tight" || wrap$1.type === "Through" || wrap$1.type === "TopAndBottom")
83828
+ mergeAnchorPaddingIntoWrapDistances(wrap$1, padding);
83758
83829
  const docPr = node3.elements.find((el) => el.name === "wp:docPr");
83759
83830
  const isHidden = isDocPrHidden(docPr);
83760
83831
  let anchorData = null;
@@ -101825,18 +101896,22 @@ function extractColumns(elements) {
101825
101896
  const cols = elements.find((el) => el?.name === "w:cols");
101826
101897
  if (!cols?.attributes)
101827
101898
  return;
101828
- const count2 = parseColumnCount(cols.attributes["w:num"]);
101899
+ let count2 = parseColumnCount(cols.attributes["w:num"]);
101829
101900
  const withSeparator = parseColumnSeparator(cols.attributes["w:sep"]);
101830
101901
  const equalWidthRaw = cols.attributes["w:equalWidth"];
101831
101902
  const equalWidth = equalWidthRaw === "0" || equalWidthRaw === 0 || equalWidthRaw === false ? false : equalWidthRaw === "1" || equalWidthRaw === 1 || equalWidthRaw === true ? true : undefined;
101832
101903
  const columnChildren = Array.isArray(cols.elements) ? cols.elements.filter((child) => child?.name === "w:col") : [];
101833
- const gapInches = parseColumnGap(cols.attributes["w:space"] ?? columnChildren.find((child) => child?.attributes?.["w:space"] != null)?.attributes?.["w:space"]);
101904
+ const isExplicit = equalWidth === false;
101905
+ const firstChildSpace = columnChildren.find((child) => child?.attributes?.["w:space"] != null)?.attributes?.["w:space"];
101906
+ const gapInches = parseColumnGap(isExplicit ? firstChildSpace ?? 0 : cols.attributes["w:space"]);
101834
101907
  const widths = columnChildren.map((child) => Number(child.attributes?.["w:w"])).filter((widthTwips) => Number.isFinite(widthTwips) && widthTwips > 0).map((widthTwips) => widthTwips / 1440 * PX_PER_INCH$1);
101908
+ if (isExplicit && widths.length > 0)
101909
+ count2 = Math.min(count2, widths.length);
101835
101910
  return {
101836
101911
  count: count2,
101837
101912
  gap: gapInches * PX_PER_INCH$1,
101838
101913
  withSeparator,
101839
- ...widths.length > 0 ? { widths } : {},
101914
+ ...isExplicit && widths.length > 0 ? { widths } : {},
101840
101915
  ...equalWidth !== undefined ? { equalWidth } : {}
101841
101916
  };
101842
101917
  }
@@ -104680,6 +104755,8 @@ function imageNodeToBlock(node3, nextBlockId, positions, _trackedMeta, _trackedC
104680
104755
  const height = typeof size2.height === "number" && Number.isFinite(size2.height) ? size2.height : undefined;
104681
104756
  const explicitDisplay = typeof attrs.display === "string" ? attrs.display : undefined;
104682
104757
  const normalizedWrap = normalizeWrap$1(attrs.wrap);
104758
+ if (normalizedWrap)
104759
+ mergeWrapDistancesFromPadding(normalizedWrap, toBoxSpacing$1(attrs.padding));
104683
104760
  let anchor = normalizeAnchorData(attrs.anchorData, attrs, normalizedWrap?.behindDoc);
104684
104761
  if (!anchor && normalizedWrap) {
104685
104762
  anchor = { isAnchored: true };
@@ -120153,6 +120230,17 @@ var isRegExp = (value) => {
120153
120230
  if (!hasValue || !hasPositive)
120154
120231
  return null;
120155
120232
  return `inset(${percentEdges.top ?? 0}% ${percentEdges.right ?? 0}% ${percentEdges.bottom ?? 0}% ${percentEdges.left ?? 0}%)`;
120233
+ }, mergeAnchorPaddingIntoWrapDistances = (wrap$1, padding) => {
120234
+ if (!wrap$1?.attrs || !padding)
120235
+ return;
120236
+ if (wrap$1.attrs.distTop == null && Number.isFinite(padding.top) && padding.top !== 0)
120237
+ wrap$1.attrs.distTop = padding.top;
120238
+ if (wrap$1.attrs.distBottom == null && Number.isFinite(padding.bottom) && padding.bottom !== 0)
120239
+ wrap$1.attrs.distBottom = padding.bottom;
120240
+ if (wrap$1.attrs.distLeft == null && Number.isFinite(padding.left) && padding.left !== 0)
120241
+ wrap$1.attrs.distLeft = padding.left;
120242
+ if (wrap$1.attrs.distRight == null && Number.isFinite(padding.right) && padding.right !== 0)
120243
+ wrap$1.attrs.distRight = padding.right;
120156
120244
  }, handleShapeDrawing = (params3, node3, graphicData, size2, padding, marginOffset, anchorData, wrap$1, isAnchor, isHidden) => {
120157
120245
  const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
120158
120246
  const textBoxContent = wsp.elements.find((el) => el.name === "wps:txbx")?.elements?.find((el) => el.name === "w:txbxContent");
@@ -127885,6 +127973,44 @@ var isRegExp = (value) => {
127885
127973
  ...comment,
127886
127974
  commentParaId: generateDocxRandomId()
127887
127975
  };
127976
+ }, getCommentIds = (comment) => {
127977
+ if (!comment)
127978
+ return [];
127979
+ return [
127980
+ comment.commentId,
127981
+ comment.importedId,
127982
+ comment.internalId
127983
+ ].filter((id2) => id2 != null).map((id2) => String(id2));
127984
+ }, buildCommentLookup = (comments = []) => {
127985
+ const byId = /* @__PURE__ */ new Map;
127986
+ for (const comment of comments)
127987
+ getCommentIds(comment).forEach((id2) => byId.set(id2, comment));
127988
+ return byId;
127989
+ }, findCommentById = (comments = [], id2) => {
127990
+ if (id2 == null)
127991
+ return null;
127992
+ return buildCommentLookup(comments).get(String(id2)) || null;
127993
+ }, isCommentResolvedInThread = (comment, allComments = []) => {
127994
+ const isDone = (c$1) => Boolean(c$1?.resolvedTime || c$1?.isDone);
127995
+ if (isDone(comment))
127996
+ return true;
127997
+ const byId = buildCommentLookup(allComments);
127998
+ const seen = /* @__PURE__ */ new Set;
127999
+ let current = comment;
128000
+ while (current) {
128001
+ const parentId = current.threadingParentCommentId || current.parentCommentId;
128002
+ const parentKey = parentId != null ? String(parentId) : null;
128003
+ if (parentKey == null || seen.has(parentKey))
128004
+ break;
128005
+ seen.add(parentKey);
128006
+ const parent = byId.get(parentKey);
128007
+ if (!parent)
128008
+ break;
128009
+ if (isDone(parent))
128010
+ return true;
128011
+ current = parent;
128012
+ }
128013
+ return false;
127888
128014
  }, getCommentDefinition = (comment, commentId, allComments, editor) => {
127889
128015
  const translatedParagraphs = (Array.isArray(comment.commentJSON) ? comment.commentJSON : comment.commentJSON ? [comment.commentJSON] : []).map((node3) => translator.decode({
127890
128016
  editor,
@@ -127895,7 +128021,7 @@ var isRegExp = (value) => {
127895
128021
  "w:author": comment.creatorName || comment.importedAuthor?.name,
127896
128022
  "w:date": toIsoNoFractional(comment.createdTime),
127897
128023
  "w:initials": getInitials(comment.creatorName),
127898
- "w:done": comment.resolvedTime ? "1" : "0",
128024
+ "w:done": isCommentResolvedInThread(comment, allComments) ? "1" : "0",
127899
128025
  "w15:paraId": comment.commentParaId,
127900
128026
  "custom:internalId": comment.commentId || comment.internalId,
127901
128027
  "custom:trackedChange": comment.trackedChange,
@@ -127906,7 +128032,7 @@ var isRegExp = (value) => {
127906
128032
  "custom:email": comment.creatorEmail || comment.importedAuthor?.email
127907
128033
  };
127908
128034
  if (comment?.parentCommentId) {
127909
- const parentComment = allComments.find((c$1) => c$1.commentId === comment.parentCommentId);
128035
+ const parentComment = findCommentById(allComments, comment.parentCommentId);
127910
128036
  if (parentComment && !parentComment.trackedChange)
127911
128037
  attributes["w15:paraIdParent"] = parentComment.commentParaId;
127912
128038
  }
@@ -127982,7 +128108,7 @@ var isRegExp = (value) => {
127982
128108
  return null;
127983
128109
  const xmlCopy = carbonCopy(commentsExtendedXml);
127984
128110
  const commentsEx = comments.map((comment) => {
127985
- const isResolved = comment.resolvedTime || comment.isDone;
128111
+ const isResolved = isCommentResolvedInThread(comment, comments);
127986
128112
  const attributes = {
127987
128113
  "w15:paraId": comment.commentParaId,
127988
128114
  "w15:done": isResolved ? "1" : "0"
@@ -127990,7 +128116,7 @@ var isRegExp = (value) => {
127990
128116
  const parentId = comment.threadingParentCommentId || comment.parentCommentId;
127991
128117
  const threadingStyle = resolveThreadingStyle(comment, profile);
127992
128118
  if (parentId && (threadingStyle === "commentsExtended" || shouldIncludeForThreads)) {
127993
- const parentComment = comments.find((c$1) => c$1.commentId === parentId);
128119
+ const parentComment = findCommentById(comments, parentId);
127994
128120
  const allowTrackedParent = profile?.defaultStyle === "commentsExtended";
127995
128121
  if (parentComment && (allowTrackedParent || !parentComment.trackedChange))
127996
128122
  attributes["w15:paraIdParent"] = parentComment.commentParaId;
@@ -128717,6 +128843,17 @@ var isRegExp = (value) => {
128717
128843
  const parsed = parseFloat(value);
128718
128844
  return Number.isFinite(parsed) ? parsed : undefined;
128719
128845
  }
128846
+ }, mergeWrapDistancesFromPadding = (wrap$1, padding) => {
128847
+ if (!padding || wrap$1.type === "None" || wrap$1.type === "Inline")
128848
+ return;
128849
+ if (wrap$1.distTop == null && padding.top != null)
128850
+ wrap$1.distTop = padding.top;
128851
+ if (wrap$1.distBottom == null && padding.bottom != null)
128852
+ wrap$1.distBottom = padding.bottom;
128853
+ if (wrap$1.distLeft == null && padding.left != null)
128854
+ wrap$1.distLeft = padding.left;
128855
+ if (wrap$1.distRight == null && padding.right != null)
128856
+ wrap$1.distRight = padding.right;
128720
128857
  }, normalizeColor = (value) => {
128721
128858
  if (typeof value !== "string")
128722
128859
  return;
@@ -130525,6 +130662,8 @@ var isRegExp = (value) => {
130525
130662
  return anchor.isAnchored || anchor.hRelativeFrom != null || anchor.vRelativeFrom != null || anchor.alignH != null || anchor.alignV != null || anchor.offsetH != null || anchor.offsetV != null || anchor.behindDoc != null ? anchor : undefined;
130526
130663
  }, buildDrawingBlock = (rawAttrs, nextBlockId, positions, node3, geometry, drawingKind, extraProps) => {
130527
130664
  const normalizedWrap = normalizeWrap$2(rawAttrs.wrap);
130665
+ if (normalizedWrap)
130666
+ mergeWrapDistancesFromPadding(normalizedWrap, toBoxSpacing(rawAttrs.padding));
130528
130667
  const sourceAnchor = isPlainObject3(rawAttrs.sourceAnchor) ? rawAttrs.sourceAnchor : undefined;
130529
130668
  const baseAnchor = normalizeAnchorData$1(rawAttrs.anchorData, rawAttrs, normalizedWrap?.behindDoc);
130530
130669
  const pos = positions.get(node3);
@@ -130998,15 +131137,17 @@ var isRegExp = (value) => {
130998
131137
  }
130999
131138
  }
131000
131139
  if (!cellBackgroundColor && resolvedTcProps?.shading) {
131001
- const { fill, themeFill, themeFillTint, themeFillShade } = resolvedTcProps.shading;
131002
- const normalizedFill = normalizeShadingColor(fill);
131003
- if (normalizedFill)
131004
- cellBackgroundColor = normalizedFill;
131005
- else if (themeFill && context.themeColors) {
131006
- const normalizedTheme = normalizeShadingColor(resolveThemeColorValue(themeFill, themeFillTint, themeFillShade, context.themeColors));
131007
- if (normalizedTheme)
131008
- cellBackgroundColor = normalizedTheme;
131009
- }
131140
+ const { fill, color: color2, val, themeFill, themeFillTint, themeFillShade } = resolvedTcProps.shading;
131141
+ let fillBase = normalizeShadingColor(fill);
131142
+ if (!fillBase && themeFill && context.themeColors)
131143
+ fillBase = normalizeShadingColor(resolveThemeColorValue(themeFill, themeFillTint, themeFillShade, context.themeColors));
131144
+ const resolved = resolveShadingFillColor({
131145
+ val,
131146
+ color: color2,
131147
+ fill: fillBase ?? fill
131148
+ });
131149
+ if (resolved)
131150
+ cellBackgroundColor = resolved.startsWith("#") ? resolved : `#${resolved}`;
131010
131151
  }
131011
131152
  const cellConverterContext = tableInfo || cellBackgroundColor ? {
131012
131153
  ...context.converterContext,
@@ -131260,9 +131401,12 @@ var isRegExp = (value) => {
131260
131401
  return null;
131261
131402
  const rowProps = rowNode.attrs?.tableRowProperties;
131262
131403
  const rowHeight = normalizeRowHeight(rowProps);
131404
+ const tblPrExBordersRaw = rowProps?.tblPrExBorders;
131405
+ const rowBorders = tblPrExBordersRaw && typeof tblPrExBordersRaw === "object" ? extractTableBorders(tblPrExBordersRaw, { unit: "eighthPoints" }) : undefined;
131263
131406
  const attrs = rowProps && typeof rowProps === "object" ? {
131264
131407
  tableRowProperties: rowProps,
131265
- ...rowHeight ? { rowHeight } : {}
131408
+ ...rowHeight ? { rowHeight } : {},
131409
+ ...rowBorders ? { borders: rowBorders } : {}
131266
131410
  } : rowHeight ? { rowHeight } : undefined;
131267
131411
  return {
131268
131412
  id: context.nextBlockId(`row-${rowIndex}`),
@@ -131579,12 +131723,12 @@ var isRegExp = (value) => {
131579
131723
  state.kern = kernNode.attributes["w:val"];
131580
131724
  }
131581
131725
  }, SuperConverter;
131582
- var init_SuperConverter_B9mZiCO9_es = __esm(() => {
131726
+ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
131583
131727
  init_rolldown_runtime_Bg48TavK_es();
131584
131728
  init_jszip_C49i9kUs_es();
131585
131729
  init_xml_js_CqGKpaft_es();
131586
131730
  init_uuid_qzgm05fK_es();
131587
- init_constants_D_X7xF4s_es();
131731
+ init_constants_D9qj59G2_es();
131588
131732
  init_dist_B8HfvhaK_es();
131589
131733
  init_unified_Dsuw2be5_es();
131590
131734
  init_lib_CYqLdG4z_es();
@@ -170614,7 +170758,7 @@ var init_SuperConverter_B9mZiCO9_es = __esm(() => {
170614
170758
  };
170615
170759
  });
170616
170760
 
170617
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-pn-wKqsL.es.js
170761
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BiY_0zZP.es.js
170618
170762
  function parseSizeUnit(val = "0") {
170619
170763
  const length3 = val.toString() || "0";
170620
170764
  const value = Number.parseFloat(length3);
@@ -180947,10 +181091,10 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
180947
181091
  }
180948
181092
  };
180949
181093
  };
180950
- var init_create_headless_toolbar_pn_wKqsL_es = __esm(() => {
180951
- init_SuperConverter_B9mZiCO9_es();
181094
+ var init_create_headless_toolbar_BiY_0zZP_es = __esm(() => {
181095
+ init_SuperConverter_DBsJeu9t_es();
180952
181096
  init_uuid_qzgm05fK_es();
180953
- init_constants_D_X7xF4s_es();
181097
+ init_constants_D9qj59G2_es();
180954
181098
  init_dist_B8HfvhaK_es();
180955
181099
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
180956
181100
  DOM_SIZE_UNITS = [
@@ -182847,7 +182991,7 @@ var init_decrypt_docx_G2a7hkiV_es = __esm(() => {
182847
182991
  ]);
182848
182992
  });
182849
182993
 
182850
- // ../../packages/superdoc/dist/chunks/DocxZipper-VodIk8WL.es.js
182994
+ // ../../packages/superdoc/dist/chunks/DocxZipper-Bu2Fhqkw.es.js
182851
182995
  function sniffEncoding(u8) {
182852
182996
  if (u8.length >= 2) {
182853
182997
  const b0 = u8[0], b1 = u8[1];
@@ -183520,11 +183664,11 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
183520
183664
  return `image/${MIME_TYPE_FOR_EXT[detectedType] || detectedType}`;
183521
183665
  }
183522
183666
  }, DocxZipper_default;
183523
- var init_DocxZipper_VodIk8WL_es = __esm(() => {
183667
+ var init_DocxZipper_Bu2Fhqkw_es = __esm(() => {
183524
183668
  init_rolldown_runtime_Bg48TavK_es();
183525
183669
  init_jszip_C49i9kUs_es();
183526
183670
  init_xml_js_CqGKpaft_es();
183527
- init_constants_D_X7xF4s_es();
183671
+ init_constants_D9qj59G2_es();
183528
183672
  init_dist_B8HfvhaK_es();
183529
183673
  MANAGED_PACKAGE_PARTS = [
183530
183674
  {
@@ -230111,7 +230255,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
230111
230255
  init_remark_gfm_BhnWr3yf_es();
230112
230256
  });
230113
230257
 
230114
- // ../../packages/superdoc/dist/chunks/src-DvgAvHbj.es.js
230258
+ // ../../packages/superdoc/dist/chunks/src-DPx6wkCz.es.js
230115
230259
  function deleteProps(obj, propOrProps) {
230116
230260
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
230117
230261
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -270395,6 +270539,9 @@ function isSettled(status) {
270395
270539
  function normalizeFamilyKey$2(family$1) {
270396
270540
  return family$1.trim().replace(/^["']|["']$/g, "").toLowerCase();
270397
270541
  }
270542
+ function stripFamilyQuotes(family$1) {
270543
+ return family$1.trim().replace(/^["']|["']$/g, "");
270544
+ }
270398
270545
  function splitStack(cssFontFamily) {
270399
270546
  return cssFontFamily.split(",").map((part) => part.trim()).filter(Boolean);
270400
270547
  }
@@ -272004,7 +272151,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
272004
272151
  let currentPageWidth = pageWidth;
272005
272152
  let marginLeft = Math.max(0, currentMargins?.left ?? 0);
272006
272153
  return {
272007
- registerDrawing(drawingBlock, measure, anchorY, columnIndex, pageNumber) {
272154
+ registerDrawing(drawingBlock, measure, resolvedAnchorY, columnIndex, pageNumber) {
272008
272155
  if (!drawingBlock.anchor?.isAnchored)
272009
272156
  return;
272010
272157
  const { wrap: wrap5, anchor } = drawingBlock;
@@ -272014,14 +272161,13 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
272014
272161
  const objectWidth = measure.width ?? 0;
272015
272162
  const objectHeight = measure.height ?? 0;
272016
272163
  const x = computeAnchorX(anchor, columnIndex, currentColumns, objectWidth, currentMargins, currentPageWidth);
272017
- const y$1 = anchorY + (anchor.offsetV ?? 0);
272018
272164
  const zone = {
272019
272165
  imageBlockId: drawingBlock.id,
272020
272166
  pageNumber,
272021
272167
  columnIndex,
272022
272168
  bounds: {
272023
272169
  x,
272024
- y: y$1,
272170
+ y: resolvedAnchorY,
272025
272171
  width: objectWidth,
272026
272172
  height: objectHeight
272027
272173
  },
@@ -272036,7 +272182,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
272036
272182
  };
272037
272183
  zones.push(zone);
272038
272184
  },
272039
- registerTable(tableBlock, measure, anchorY, columnIndex, pageNumber) {
272185
+ registerTable(tableBlock, measure, resolvedAnchorY, columnIndex, pageNumber) {
272040
272186
  if (!tableBlock.anchor?.isAnchored)
272041
272187
  return;
272042
272188
  const { wrap: wrap5, anchor } = tableBlock;
@@ -272045,14 +272191,13 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
272045
272191
  const tableWidth = measure.totalWidth ?? 0;
272046
272192
  const tableHeight = measure.totalHeight ?? 0;
272047
272193
  const x = computeTableAnchorX(anchor, columnIndex, currentColumns, tableWidth, currentMargins, currentPageWidth);
272048
- const y$1 = anchorY + (anchor.offsetV ?? 0);
272049
272194
  const zone = {
272050
272195
  imageBlockId: tableBlock.id,
272051
272196
  pageNumber,
272052
272197
  columnIndex,
272053
272198
  bounds: {
272054
272199
  x,
272055
- y: y$1,
272200
+ y: resolvedAnchorY,
272056
272201
  width: tableWidth,
272057
272202
  height: tableHeight
272058
272203
  },
@@ -272106,12 +272251,12 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
272106
272251
  rightFloats.push(zone);
272107
272252
  let leftBoundary = 0;
272108
272253
  for (const zone of leftFloats) {
272109
- const boundary = zone.bounds.x + zone.bounds.width + zone.distances.left + zone.distances.right;
272254
+ const boundary = zone.bounds.x + zone.bounds.width + zone.distances.right;
272110
272255
  leftBoundary = Math.max(leftBoundary, boundary);
272111
272256
  }
272112
272257
  let rightBoundary = columnOrigin + baseWidth;
272113
272258
  for (const zone of rightFloats) {
272114
- const boundary = zone.bounds.x - zone.distances.left - zone.distances.right;
272259
+ const boundary = zone.bounds.x - zone.distances.left;
272115
272260
  rightBoundary = Math.min(rightBoundary, boundary);
272116
272261
  }
272117
272262
  const availableWidth = rightBoundary - leftBoundary;
@@ -272141,27 +272286,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
272141
272286
  };
272142
272287
  }
272143
272288
  function computeAnchorX(anchor, columnIndex, columns, imageWidth, margins, pageWidth) {
272144
- const alignH = anchor.alignH ?? "left";
272145
- const offsetH = anchor.offsetH ?? 0;
272146
- const marginLeft = Math.max(0, margins?.left ?? 0);
272147
- const marginRight = Math.max(0, margins?.right ?? 0);
272148
- const contentWidth = pageWidth != null ? Math.max(1, pageWidth - (marginLeft + marginRight)) : columns.width;
272149
- const contentLeft = marginLeft;
272150
- const columnLeft = contentLeft + columnIndex * (columns.width + columns.gap);
272151
- const relativeFrom = anchor.hRelativeFrom ?? "column";
272152
- let baseX;
272153
- let availableWidth;
272154
- if (relativeFrom === "page") {
272155
- baseX = 0;
272156
- availableWidth = pageWidth != null ? pageWidth : contentWidth + marginLeft + marginRight;
272157
- } else if (relativeFrom === "margin") {
272158
- baseX = contentLeft;
272159
- availableWidth = contentWidth;
272160
- } else {
272161
- baseX = columnLeft;
272162
- availableWidth = columns.width;
272163
- }
272164
- return alignH === "left" ? baseX + offsetH : alignH === "right" ? baseX + availableWidth - imageWidth - offsetH : alignH === "center" ? baseX + (availableWidth - imageWidth) / 2 + offsetH : baseX;
272289
+ return resolveAnchoredGraphicX(anchor, columnIndex, columns, imageWidth, margins, pageWidth);
272165
272290
  }
272166
272291
  function computeWrapMode(wrap5, _anchor) {
272167
272292
  if (!wrap5)
@@ -272496,6 +272621,30 @@ function normalizeLines(measure) {
272496
272621
  function shouldSuppressOwnSpacing(ownStyleId, ownContextualSpacing, adjacentStyleId) {
272497
272622
  return ownContextualSpacing && !!ownStyleId && !!adjacentStyleId && ownStyleId === adjacentStyleId;
272498
272623
  }
272624
+ function collapseSpacingBefore(spacingBefore, trailingSpacing) {
272625
+ const prevTrailing = trailingSpacing ?? 0;
272626
+ return Math.max(spacingBefore - prevTrailing, 0);
272627
+ }
272628
+ function rewindPreviousParagraphTrailing(cursorY, trailingSpacing) {
272629
+ const prevTrailing = trailingSpacing ?? 0;
272630
+ return prevTrailing > 0 ? cursorY - prevTrailing : cursorY;
272631
+ }
272632
+ function computeParagraphContentStartY(cursorY, spacingBefore, appliedSpacingBefore, trailingSpacing) {
272633
+ if (appliedSpacingBefore || spacingBefore <= 0)
272634
+ return cursorY;
272635
+ return cursorY + collapseSpacingBefore(spacingBefore, trailingSpacing);
272636
+ }
272637
+ function computeParagraphLayoutStartY(input2) {
272638
+ let y$1 = input2.cursorY;
272639
+ let trailingForCollapse = input2.trailingSpacing;
272640
+ if (input2.rewindTrailingFromPrevious) {
272641
+ y$1 = rewindPreviousParagraphTrailing(y$1, input2.trailingSpacing);
272642
+ if ((input2.trailingSpacing ?? 0) > 0)
272643
+ trailingForCollapse = 0;
272644
+ }
272645
+ const effectiveSpacingBefore = input2.suppressSpacingBefore ? 0 : input2.spacingBefore;
272646
+ return computeParagraphContentStartY(y$1, effectiveSpacingBefore, effectiveSpacingBefore === 0, trailingForCollapse);
272647
+ }
272499
272648
  function calculateFirstLineIndent(block, measure) {
272500
272649
  const wordLayout = block.attrs?.wordLayout;
272501
272650
  if (!wordLayout?.firstLineIndentMode)
@@ -272511,52 +272660,75 @@ function layoutParagraphBlock(ctx$1, anchors) {
272511
272660
  const { block, measure, columnWidth, ensurePage, advanceColumn, columnX, floatManager } = ctx$1;
272512
272661
  const remeasureParagraph$1 = ctx$1.remeasureParagraph;
272513
272662
  const frame = getParagraphAttrs(block)?.frame;
272514
- if (anchors?.anchoredDrawings?.length)
272663
+ let lines = normalizeLines(measure);
272664
+ const measurementWidth = lines[0]?.maxWidth;
272665
+ const paraIndent = block.attrs?.indent;
272666
+ const indentLeft = typeof paraIndent?.left === "number" && Number.isFinite(paraIndent.left) ? paraIndent.left : 0;
272667
+ const indentRight = typeof paraIndent?.right === "number" && Number.isFinite(paraIndent.right) ? paraIndent.right : 0;
272668
+ const negativeLeftIndent = indentLeft < 0 ? indentLeft : 0;
272669
+ const negativeRightIndent = indentRight < 0 ? indentRight : 0;
272670
+ const remeasureWidth = Math.max(1, columnWidth - indentLeft - indentRight);
272671
+ let didRemeasureForColumnWidth = false;
272672
+ let remeasuredMarkerInfo;
272673
+ if (typeof remeasureParagraph$1 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
272674
+ const newMeasure = remeasureParagraph$1(block, columnWidth, calculateFirstLineIndent(block, measure));
272675
+ lines = normalizeLines(newMeasure);
272676
+ didRemeasureForColumnWidth = true;
272677
+ if (newMeasure.marker)
272678
+ remeasuredMarkerInfo = newMeasure.marker;
272679
+ }
272680
+ let fromLine = 0;
272681
+ const attrs = getParagraphAttrs(block);
272682
+ const spacing = attrs?.spacing ?? {};
272683
+ const spacingExplicit = attrs?.spacingExplicit;
272684
+ const styleId$1 = asString2(attrs?.styleId);
272685
+ const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
272686
+ let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
272687
+ let spacingAfter = ctx$1.overrideSpacingAfter ?? Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
272688
+ if (isEmptyTextParagraph(block) && spacingExplicit) {
272689
+ if (!spacingExplicit.before)
272690
+ spacingBefore = 0;
272691
+ if (!spacingExplicit.after)
272692
+ spacingAfter = 0;
272693
+ }
272694
+ const baseSpacingBefore = spacingBefore;
272695
+ let appliedSpacingBefore = spacingBefore === 0;
272696
+ let lastState = null;
272697
+ const previewState = ensurePage();
272698
+ const rawBorderExpansion = computeBorderVerticalExpansion(attrs?.borders);
272699
+ const currentBorderHash = hashBorders(attrs?.borders);
272700
+ const inBorderGroup = currentBorderHash != null && currentBorderHash === previewState.lastParagraphBorderHash;
272701
+ const borderExpansion = {
272702
+ top: inBorderGroup ? 0 : rawBorderExpansion.top,
272703
+ bottom: rawBorderExpansion.bottom
272704
+ };
272705
+ const paragraphAnchorBaseY = computeParagraphLayoutStartY({
272706
+ cursorY: previewState.cursorY,
272707
+ spacingBefore,
272708
+ trailingSpacing: previewState.trailingSpacing,
272709
+ suppressSpacingBefore: shouldSuppressOwnSpacing(styleId$1, contextualSpacing, previewState.lastParagraphStyleId),
272710
+ rewindTrailingFromPrevious: shouldSuppressOwnSpacing(previewState.lastParagraphStyleId, previewState.lastParagraphContextualSpacing, styleId$1)
272711
+ }) + borderExpansion.top - (inBorderGroup ? rawBorderExpansion.bottom : 0);
272712
+ const registerAnchoredDrawingsAt = (paragraphContentStartY) => {
272713
+ if (!anchors?.anchoredDrawings?.length)
272714
+ return;
272515
272715
  for (const entry of anchors.anchoredDrawings) {
272516
272716
  if (anchors.placedAnchoredIds.has(entry.block.id))
272517
272717
  continue;
272518
272718
  const state = ensurePage();
272519
- const vRelativeFrom = entry.block.anchor?.vRelativeFrom;
272520
- const alignV = entry.block.anchor?.alignV;
272521
- const offsetV = entry.block.anchor?.offsetV ?? 0;
272522
- const imageHeight = entry.measure.height;
272523
272719
  const contentTop = state.topMargin;
272524
272720
  const contentBottom = state.contentBottom;
272525
- const contentHeight = Math.max(0, contentBottom - contentTop);
272526
- let anchorY;
272527
- if (vRelativeFrom === "margin")
272528
- if (alignV === "top")
272529
- anchorY = contentTop + offsetV;
272530
- else if (alignV === "bottom")
272531
- anchorY = contentBottom - imageHeight + offsetV;
272532
- else if (alignV === "center")
272533
- anchorY = contentTop + (contentHeight - imageHeight) / 2 + offsetV;
272534
- else
272535
- anchorY = contentTop + offsetV;
272536
- else if (vRelativeFrom === "page")
272537
- if (alignV === "top")
272538
- anchorY = offsetV;
272539
- else if (alignV === "bottom")
272540
- anchorY = contentBottom + (anchors.pageMargins.bottom ?? 0) - imageHeight + offsetV;
272541
- else if (alignV === "center")
272542
- anchorY = (contentBottom + (anchors.pageMargins.bottom ?? 0) - imageHeight) / 2 + offsetV;
272543
- else
272544
- anchorY = offsetV;
272545
- else if (vRelativeFrom === "paragraph") {
272546
- const baseAnchorY = state.cursorY;
272547
- const firstLineHeight = measure.lines?.[0]?.lineHeight ?? 0;
272548
- if (alignV === "top")
272549
- anchorY = baseAnchorY + offsetV;
272550
- else if (alignV === "bottom")
272551
- anchorY = baseAnchorY + firstLineHeight - imageHeight + offsetV;
272552
- else if (alignV === "center")
272553
- anchorY = baseAnchorY + (firstLineHeight - imageHeight) / 2 + offsetV;
272554
- else
272555
- anchorY = baseAnchorY + offsetV;
272556
- } else
272557
- anchorY = state.cursorY + offsetV;
272721
+ const anchorY = resolveAnchoredGraphicY({
272722
+ anchor: entry.block.anchor,
272723
+ objectHeight: entry.measure.height,
272724
+ contentTop,
272725
+ contentBottom,
272726
+ pageBottomMargin: anchors.pageMargins.bottom ?? 0,
272727
+ anchorParagraphY: paragraphContentStartY,
272728
+ firstLineHeight: measure.lines?.[0]?.lineHeight ?? 0
272729
+ });
272558
272730
  floatManager.registerDrawing(entry.block, entry.measure, anchorY, state.columnIndex, state.page.number);
272559
- const anchorX = entry.block.anchor ? computeAnchorX(entry.block.anchor, state.columnIndex, anchors.columns, entry.measure.width, {
272731
+ const anchorX = entry.block.anchor ? resolveAnchoredGraphicX(entry.block.anchor, state.columnIndex, anchors.columns, entry.measure.width, {
272560
272732
  left: anchors.pageMargins.left,
272561
272733
  right: anchors.pageMargins.right
272562
272734
  }, anchors.pageWidth) : columnX(state.columnIndex);
@@ -272628,40 +272800,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
272628
272800
  }
272629
272801
  anchors.placedAnchoredIds.add(entry.block.id);
272630
272802
  }
272631
- let lines = normalizeLines(measure);
272632
- const measurementWidth = lines[0]?.maxWidth;
272633
- const paraIndent = block.attrs?.indent;
272634
- const indentLeft = typeof paraIndent?.left === "number" && Number.isFinite(paraIndent.left) ? paraIndent.left : 0;
272635
- const indentRight = typeof paraIndent?.right === "number" && Number.isFinite(paraIndent.right) ? paraIndent.right : 0;
272636
- const negativeLeftIndent = indentLeft < 0 ? indentLeft : 0;
272637
- const negativeRightIndent = indentRight < 0 ? indentRight : 0;
272638
- const remeasureWidth = Math.max(1, columnWidth - indentLeft - indentRight);
272639
- let didRemeasureForColumnWidth = false;
272640
- let remeasuredMarkerInfo;
272641
- if (typeof remeasureParagraph$1 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
272642
- const newMeasure = remeasureParagraph$1(block, columnWidth, calculateFirstLineIndent(block, measure));
272643
- lines = normalizeLines(newMeasure);
272644
- didRemeasureForColumnWidth = true;
272645
- if (newMeasure.marker)
272646
- remeasuredMarkerInfo = newMeasure.marker;
272647
- }
272648
- let fromLine = 0;
272649
- const attrs = getParagraphAttrs(block);
272650
- const spacing = attrs?.spacing ?? {};
272651
- const spacingExplicit = attrs?.spacingExplicit;
272652
- const styleId$1 = asString2(attrs?.styleId);
272653
- const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
272654
- let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
272655
- let spacingAfter = ctx$1.overrideSpacingAfter ?? Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
272656
- if (isEmptyTextParagraph(block) && spacingExplicit) {
272657
- if (!spacingExplicit.before)
272658
- spacingBefore = 0;
272659
- if (!spacingExplicit.after)
272660
- spacingAfter = 0;
272661
- }
272662
- const baseSpacingBefore = spacingBefore;
272663
- let appliedSpacingBefore = spacingBefore === 0;
272664
- let lastState = null;
272803
+ };
272804
+ registerAnchoredDrawingsAt(paragraphAnchorBaseY);
272665
272805
  if (frame?.wrap === "none") {
272666
272806
  let state = ensurePage();
272667
272807
  if (state.cursorY >= state.contentBottom)
@@ -272703,12 +272843,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
272703
272843
  let didRemeasureForFloats = false;
272704
272844
  if (typeof remeasureParagraph$1 === "function") {
272705
272845
  const tempState = ensurePage();
272706
- let tempY = tempState.cursorY;
272707
- if (!appliedSpacingBefore && spacingBefore > 0) {
272708
- const prevTrailing = tempState.trailingSpacing ?? 0;
272709
- const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
272710
- tempY += neededSpacingBefore;
272711
- }
272846
+ let tempY = paragraphAnchorBaseY;
272712
272847
  for (let i4 = 0;i4 < lines.length; i4++) {
272713
272848
  const lineY = tempY;
272714
272849
  const lineHeight = lines[i4]?.lineHeight || 0;
@@ -272719,8 +272854,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
272719
272854
  }
272720
272855
  tempY += lineHeight;
272721
272856
  }
272722
- const narrowestRemeasureWidth = Math.max(1, narrowestWidth - indentLeft - indentRight);
272723
- if (narrowestRemeasureWidth < remeasureWidth) {
272857
+ const narrowestRemeasureWidth = narrowestWidth < columnWidth || narrowestOffsetX > 0 ? Math.max(1, narrowestWidth - Math.max(indentLeft, 0) - Math.max(indentRight, 0)) : Math.max(1, narrowestWidth - indentLeft - indentRight);
272858
+ if (narrowestRemeasureWidth < remeasureWidth || narrowestOffsetX > 0) {
272724
272859
  const newMeasure = remeasureParagraph$1(block, narrowestRemeasureWidth, calculateFirstLineIndent(block, measure));
272725
272860
  lines = normalizeLines(newMeasure);
272726
272861
  didRemeasureForFloats = true;
@@ -272728,13 +272863,6 @@ function layoutParagraphBlock(ctx$1, anchors) {
272728
272863
  remeasuredMarkerInfo = newMeasure.marker;
272729
272864
  }
272730
272865
  }
272731
- const rawBorderExpansion = computeBorderVerticalExpansion(attrs?.borders);
272732
- const currentBorderHash = hashBorders(attrs?.borders);
272733
- const inBorderGroup = currentBorderHash != null && currentBorderHash === ensurePage().lastParagraphBorderHash;
272734
- const borderExpansion = {
272735
- top: inBorderGroup ? 0 : rawBorderExpansion.top,
272736
- bottom: rawBorderExpansion.bottom
272737
- };
272738
272866
  while (fromLine < lines.length) {
272739
272867
  let state = ensurePage();
272740
272868
  if (state.trailingSpacing == null)
@@ -272746,13 +272874,12 @@ function layoutParagraphBlock(ctx$1, anchors) {
272746
272874
  if (shouldSuppressOwnSpacing(state.lastParagraphStyleId, state.lastParagraphContextualSpacing, styleId$1)) {
272747
272875
  const prevTrailing = asSafeNumber(state.trailingSpacing);
272748
272876
  if (prevTrailing > 0) {
272749
- state.cursorY -= prevTrailing;
272877
+ state.cursorY = rewindPreviousParagraphTrailing(state.cursorY, prevTrailing);
272750
272878
  state.trailingSpacing = 0;
272751
272879
  }
272752
272880
  }
272753
272881
  if (attrs?.keepLines === true && fromLine === 0) {
272754
- const prevTrailing = state.trailingSpacing ?? 0;
272755
- const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
272882
+ const neededSpacingBefore = collapseSpacingBefore(spacingBefore, state.trailingSpacing);
272756
272883
  const pageContentHeight = state.contentBottom - state.topMargin;
272757
272884
  const fullHeight = lines.reduce((sum, line) => sum + (line.lineHeight || 0), 0) + borderExpansion.top + borderExpansion.bottom;
272758
272885
  const fitsOnBlankPage = fullHeight + baseSpacingBefore <= pageContentHeight;
@@ -272766,8 +272893,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
272766
272893
  }
272767
272894
  if (!appliedSpacingBefore && spacingBefore > 0)
272768
272895
  while (!appliedSpacingBefore) {
272769
- const prevTrailing = state.trailingSpacing ?? 0;
272770
- const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
272896
+ state.trailingSpacing;
272897
+ const neededSpacingBefore = collapseSpacingBefore(spacingBefore, state.trailingSpacing);
272771
272898
  if (state.cursorY + neededSpacingBefore > state.contentBottom) {
272772
272899
  if (state.cursorY <= state.topMargin) {
272773
272900
  state.trailingSpacing = 0;
@@ -272889,8 +273016,12 @@ function layoutParagraphBlock(ctx$1, anchors) {
272889
273016
  state.footnoteAnchorsThisPage.push(a2);
272890
273017
  }
272891
273018
  }
272892
- const adjustedX = columnX(state.columnIndex) + offsetX + negativeLeftIndent;
272893
- const adjustedWidth = effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
273019
+ const floatAdjustedX = columnX(state.columnIndex) + offsetX;
273020
+ const adjustedX = didRemeasureForFloats ? floatAdjustedX + Math.max(negativeLeftIndent, 0) : floatAdjustedX + negativeLeftIndent;
273021
+ const columnRight = columnX(state.columnIndex) + columnWidth;
273022
+ let adjustedWidth = didRemeasureForFloats ? effectiveColumnWidth : effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
273023
+ if (didRemeasureForFloats)
273024
+ adjustedWidth = Math.min(adjustedWidth, Math.max(1, columnRight - adjustedX));
272894
273025
  const fragment2 = {
272895
273026
  kind: "para",
272896
273027
  blockId: block.id,
@@ -272902,7 +273033,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
272902
273033
  sourceAnchor: block.sourceAnchor,
272903
273034
  ...computeFragmentPmRange2(block, lines, fromLine, slice2.toLine)
272904
273035
  };
272905
- if (didRemeasureForColumnWidth)
273036
+ if (didRemeasureForColumnWidth || didRemeasureForFloats)
272906
273037
  fragment2.lines = lines.slice(fromLine, slice2.toLine);
272907
273038
  if ((measure.marker || remeasuredMarkerInfo) && fromLine === 0) {
272908
273039
  fragment2.markerWidth = (remeasuredMarkerInfo ?? measure.marker)?.markerWidth ?? measure.marker?.markerWidth ?? 0;
@@ -274753,13 +274884,19 @@ function getBalancingHeight(fragment2, measureMap, sectPrMarkerBlockIds) {
274753
274884
  return 0;
274754
274885
  return getFragmentHeight(fragment2, measureMap);
274755
274886
  }
274887
+ function allColumnWidthsEqual(widths) {
274888
+ if (widths.length <= 1)
274889
+ return true;
274890
+ const first$1 = widths[0];
274891
+ return widths.every((w) => Math.abs(w - first$1) <= 0.5);
274892
+ }
274756
274893
  function balanceSectionOnPage(args$1) {
274757
274894
  const { sectionColumns, sectionHasExplicitColumnBreak, sectionIndex, blockSectionMap, fragments } = args$1;
274758
274895
  if (sectionColumns.count <= 1)
274759
274896
  return null;
274760
274897
  if (sectionHasExplicitColumnBreak)
274761
274898
  return null;
274762
- if (sectionColumns.equalWidth === false && Array.isArray(sectionColumns.widths) && sectionColumns.widths.length > 0)
274899
+ if (sectionColumns.equalWidth === false && Array.isArray(sectionColumns.widths) && sectionColumns.widths.length > 0 && !allColumnWidthsEqual(sectionColumns.widths))
274763
274900
  return null;
274764
274901
  const sectionFragments = fragments.filter((f2) => blockSectionMap.get(f2.blockId) === sectionIndex);
274765
274902
  if (sectionFragments.length === 0)
@@ -275198,8 +275335,15 @@ function calculateChainHeight(chain, blocks2, measures, state) {
275198
275335
  const firstLineHeight = anchorMeasure.lines[0]?.lineHeight;
275199
275336
  const anchorHeight = typeof firstLineHeight === "number" && Number.isFinite(firstLineHeight) && firstLineHeight > 0 ? firstLineHeight : getMeasureHeight(anchorBlock, anchorMeasure);
275200
275337
  totalHeight += interParagraphSpacing + anchorHeight;
275201
- } else if (!(anchorBlock.kind === "table" && anchorBlock.anchor?.isAnchored === true))
275202
- totalHeight += prevSpacingAfter + getMeasureHeight(anchorBlock, anchorMeasure);
275338
+ } else if (!(anchorBlock.kind === "table" && anchorBlock.anchor?.isAnchored === true)) {
275339
+ let anchorHeight = getMeasureHeight(anchorBlock, anchorMeasure);
275340
+ if (anchorBlock.kind === "table" && anchorMeasure.kind === "table" && anchorMeasure.rows.length > 0) {
275341
+ const firstRowHeight = anchorMeasure.rows[0]?.height;
275342
+ if (typeof firstRowHeight === "number" && Number.isFinite(firstRowHeight) && firstRowHeight > 0)
275343
+ anchorHeight = firstRowHeight;
275344
+ }
275345
+ totalHeight += prevSpacingAfter + anchorHeight;
275346
+ }
275203
275347
  }
275204
275348
  }
275205
275349
  return totalHeight;
@@ -276012,58 +276156,28 @@ function layoutDocument(blocks2, measures, options = {}) {
276012
276156
  const resolveParagraphlessAnchoredTableY = (block, measure, state) => {
276013
276157
  const contentTop = state.topMargin;
276014
276158
  const contentBottom = state.contentBottom;
276015
- const contentHeight = Math.max(0, contentBottom - contentTop);
276016
276159
  const tableHeight = measure.totalHeight ?? 0;
276017
- const anchor = block.anchor;
276018
- const offsetV = anchor?.offsetV ?? 0;
276019
- const vRelativeFrom = anchor?.vRelativeFrom;
276020
- const alignV = anchor?.alignV;
276021
- if (vRelativeFrom === "margin") {
276022
- if (alignV === "bottom")
276023
- return contentBottom - tableHeight + offsetV;
276024
- if (alignV === "center")
276025
- return contentTop + (contentHeight - tableHeight) / 2 + offsetV;
276026
- return contentTop + offsetV;
276027
- }
276028
- if (vRelativeFrom === "page") {
276029
- if (alignV === "bottom")
276030
- return contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - tableHeight + offsetV;
276031
- if (alignV === "center")
276032
- return (contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - tableHeight) / 2 + offsetV;
276033
- return offsetV;
276034
- }
276035
- return contentTop + offsetV;
276160
+ return resolveAnchoredGraphicY({
276161
+ anchor: block.anchor,
276162
+ objectHeight: tableHeight,
276163
+ contentTop,
276164
+ contentBottom,
276165
+ pageBottomMargin: state.page.margins?.bottom ?? activeBottomMargin,
276166
+ preRegisteredFallbackToContentTop: true
276167
+ });
276036
276168
  };
276037
276169
  for (const entry of preRegisteredAnchors) {
276038
276170
  const state = paginator.ensurePage();
276039
- const vRelativeFrom = entry.block.anchor?.vRelativeFrom ?? "paragraph";
276040
- const alignV = entry.block.anchor?.alignV ?? "top";
276041
- const offsetV = entry.block.anchor?.offsetV ?? 0;
276042
- const imageHeight = entry.measure.height ?? 0;
276043
276171
  const contentTop = state.topMargin;
276044
276172
  const contentBottom = state.contentBottom;
276045
- const contentHeight = Math.max(0, contentBottom - contentTop);
276046
- let anchorY;
276047
- if (vRelativeFrom === "margin")
276048
- if (alignV === "top")
276049
- anchorY = contentTop + offsetV;
276050
- else if (alignV === "bottom")
276051
- anchorY = contentBottom - imageHeight + offsetV;
276052
- else if (alignV === "center")
276053
- anchorY = contentTop + (contentHeight - imageHeight) / 2 + offsetV;
276054
- else
276055
- anchorY = contentTop + offsetV;
276056
- else if (vRelativeFrom === "page")
276057
- if (alignV === "top")
276058
- anchorY = offsetV;
276059
- else if (alignV === "bottom")
276060
- anchorY = contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - imageHeight + offsetV;
276061
- else if (alignV === "center")
276062
- anchorY = (contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - imageHeight) / 2 + offsetV;
276063
- else
276064
- anchorY = offsetV;
276065
- else
276066
- anchorY = contentTop + offsetV;
276173
+ const anchorY = resolveAnchoredGraphicY({
276174
+ anchor: entry.block.anchor,
276175
+ objectHeight: entry.measure.height ?? 0,
276176
+ contentTop,
276177
+ contentBottom,
276178
+ pageBottomMargin: state.page.margins?.bottom ?? activeBottomMargin,
276179
+ preRegisteredFallbackToContentTop: true
276180
+ });
276067
276181
  const anchorX = entry.block.anchor ? computeAnchorX(entry.block.anchor, state.columnIndex, normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)), entry.measure.width, {
276068
276182
  left: activeLeftMargin,
276069
276183
  right: activeRightMargin
@@ -276374,7 +276488,6 @@ function layoutDocument(blocks2, measures, options = {}) {
276374
276488
  overrideSpacingAfter = 0;
276375
276489
  }
276376
276490
  }
276377
- const paragraphStartY = paginator.ensurePage().cursorY;
276378
276491
  layoutParagraphBlock({
276379
276492
  block,
276380
276493
  measure,
@@ -276404,7 +276517,12 @@ function layoutDocument(blocks2, measures, options = {}) {
276404
276517
  if (tablesForPara) {
276405
276518
  const state = paginator.ensurePage();
276406
276519
  const columnWidthForTable = getCurrentColumnWidth();
276520
+ let anchorParagraphTopY = state.cursorY;
276521
+ for (const fragment2 of state.page.fragments)
276522
+ if (fragment2.kind === "para" && fragment2.blockId === block.id)
276523
+ anchorParagraphTopY = Math.min(anchorParagraphTopY, fragment2.y);
276407
276524
  let tableBottomY = state.cursorY;
276525
+ let nextStackY = state.cursorY;
276408
276526
  for (const { block: tableBlock, measure: tableMeasure } of tablesForPara) {
276409
276527
  if (placedAnchoredTableIds.has(tableBlock.id))
276410
276528
  continue;
@@ -276412,15 +276530,17 @@ function layoutDocument(blocks2, measures, options = {}) {
276412
276530
  if (columnWidthForTable > 0 && totalWidth >= columnWidthForTable * 0.99)
276413
276531
  continue;
276414
276532
  const offsetV = tableBlock.anchor?.offsetV ?? 0;
276415
- const anchorY = Math.max(paragraphStartY, state.cursorY) + offsetV;
276533
+ const anchorY = Math.max(anchorParagraphTopY, nextStackY) + offsetV;
276416
276534
  floatManager.registerTable(tableBlock, tableMeasure, anchorY, state.columnIndex, state.page.number);
276417
276535
  const tableFragment = createAnchoredTableFragment(tableBlock, tableMeasure, tableBlock.anchor?.offsetH ?? columnX(state.columnIndex), anchorY);
276418
276536
  state.page.fragments.push(tableFragment);
276419
276537
  placedAnchoredTableIds.add(tableBlock.id);
276420
276538
  if ((tableBlock.wrap?.type ?? "None") !== "None") {
276421
276539
  const bottom$1 = anchorY + (tableMeasure.totalHeight ?? 0);
276540
+ const distBottom = tableBlock.wrap?.distBottom ?? 0;
276422
276541
  if (bottom$1 > tableBottomY)
276423
276542
  tableBottomY = bottom$1;
276543
+ nextStackY = bottom$1 + distBottom;
276424
276544
  }
276425
276545
  }
276426
276546
  state.cursorY = tableBottomY;
@@ -292188,28 +292308,61 @@ var Node$13 = class Node$14 {
292188
292308
  ranges
292189
292309
  };
292190
292310
  }, resolveCommentById = ({ commentId, importedId, state, tr, dispatch }) => {
292311
+ const converted = resolveCommentsInTr({
292312
+ items: [{
292313
+ commentId,
292314
+ importedId
292315
+ }],
292316
+ state,
292317
+ tr
292318
+ });
292319
+ if (converted)
292320
+ dispatch(tr);
292321
+ return converted;
292322
+ }, resolveCommentsInTr = ({ items = [], state, tr }) => {
292191
292323
  const { schema } = state;
292192
292324
  const markType = schema.marks?.[CommentMarkName];
292193
292325
  if (!markType)
292194
292326
  return false;
292195
- const { segments, ranges } = getCommentMarkRangesById(commentId, state.doc, importedId);
292196
- if (!segments.length)
292197
- return false;
292198
- segments.forEach(({ from: from$1, to, attrs }) => {
292199
- tr.removeMark(from$1, to, markType.create(attrs));
292200
- });
292201
292327
  const startType = schema.nodes?.commentRangeStart;
292202
292328
  const endType = schema.nodes?.commentRangeEnd;
292203
- if (startType && endType)
292204
- ranges.slice().sort((a2, b$1) => b$1.from - a2.from).forEach(({ from: from$1, to, internal }) => {
292205
- tr.insert(to, endType.create({ "w:id": commentId }));
292206
- tr.insert(from$1, startType.create({
292329
+ const insertions = [];
292330
+ const seen = /* @__PURE__ */ new Set;
292331
+ let converted = false;
292332
+ for (const item of items) {
292333
+ if (!item)
292334
+ continue;
292335
+ const { commentId, importedId } = item;
292336
+ if (commentId == null)
292337
+ continue;
292338
+ const key2 = `${commentId}:${importedId ?? ""}`;
292339
+ if (seen.has(key2))
292340
+ continue;
292341
+ seen.add(key2);
292342
+ const { segments, ranges } = getCommentMarkRangesById(commentId, state.doc, importedId);
292343
+ if (!segments.length)
292344
+ continue;
292345
+ converted = true;
292346
+ segments.forEach(({ from: from$1, to, attrs }) => {
292347
+ tr.removeMark(from$1, to, markType.create(attrs));
292348
+ });
292349
+ if (startType && endType && item.preserveAnchor !== false)
292350
+ ranges.forEach(({ from: from$1, to, internal }) => insertions.push({
292351
+ from: from$1,
292352
+ to,
292353
+ internal,
292354
+ commentId
292355
+ }));
292356
+ }
292357
+ if (startType && endType && insertions.length)
292358
+ insertions.sort((a2, b$1) => b$1.from - a2.from || b$1.to - a2.to).forEach(({ from: from$1, to, internal, commentId }) => {
292359
+ tr.insert(tr.mapping.map(to), endType.create({ "w:id": commentId }));
292360
+ tr.insert(tr.mapping.map(from$1), startType.create({
292207
292361
  "w:id": commentId,
292208
292362
  internal
292209
292363
  }));
292210
292364
  });
292211
- dispatch(tr);
292212
- return true;
292365
+ return converted;
292213
292366
  }, getCommentRangeAnchorsById = (commentId, doc$12, importedId) => {
292214
292367
  const anchors = [];
292215
292368
  doc$12.descendants((node3, pos) => {
@@ -292504,6 +292657,60 @@ var Node$13 = class Node$14 {
292504
292657
  });
292505
292658
  });
292506
292659
  }
292660
+ const nodeAnchorsById = /* @__PURE__ */ new Map;
292661
+ doc$12.descendants((node3, pos) => {
292662
+ const typeName = node3.type?.name;
292663
+ if (typeName !== "commentRangeStart" && typeName !== "commentRangeEnd")
292664
+ return;
292665
+ const anchorId = node3.attrs?.["w:id"];
292666
+ if (anchorId == null)
292667
+ return;
292668
+ const entry = nodeAnchorsById.get(anchorId) || {};
292669
+ if (typeName === "commentRangeStart")
292670
+ entry.startPos = pos;
292671
+ else
292672
+ entry.endPos = pos;
292673
+ nodeAnchorsById.set(anchorId, entry);
292674
+ });
292675
+ const isRepresented = (c) => seen.has(c.commentId) || c.importedId != null && seen.has(c.importedId) || nodeAnchorsById.has(c.commentId) || c.importedId != null && nodeAnchorsById.has(c.importedId);
292676
+ const findAncestorNodeAnchor = (comment2) => {
292677
+ let current = comment2;
292678
+ const visited = /* @__PURE__ */ new Set;
292679
+ while (current) {
292680
+ const parentId = getThreadingParentId(current);
292681
+ if (parentId == null || visited.has(parentId))
292682
+ return null;
292683
+ visited.add(parentId);
292684
+ const parent = commentMap.get(parentId) || comments.find((c) => c.importedId === parentId || c.commentId === parentId);
292685
+ const anchor = nodeAnchorsById.get(parentId) ?? (parent ? nodeAnchorsById.get(parent.commentId) ?? nodeAnchorsById.get(parent.importedId) : undefined);
292686
+ if (anchor?.startPos != null && anchor?.endPos != null)
292687
+ return anchor;
292688
+ current = parent;
292689
+ }
292690
+ return null;
292691
+ };
292692
+ comments.filter((c) => !c.trackedChange && c.commentId != null && !isRepresented(c)).sort((a2, b$1) => (a2.createdTime || 0) - (b$1.createdTime || 0)).forEach((c) => {
292693
+ const anchor = findAncestorNodeAnchor(c);
292694
+ if (!anchor)
292695
+ return;
292696
+ seen.add(c.commentId);
292697
+ const childAttrs = getPreparedComment({
292698
+ commentId: c.commentId,
292699
+ internal: c.isInternal
292700
+ });
292701
+ startNodes.push({
292702
+ pos: anchor.startPos + 1,
292703
+ node: schema.nodes.commentRangeStart.create(childAttrs),
292704
+ commentId: c.commentId,
292705
+ parentCommentId: getThreadingParentId(c)
292706
+ });
292707
+ endNodes.push({
292708
+ pos: anchor.endPos + 1,
292709
+ node: schema.nodes.commentRangeEnd.create(childAttrs),
292710
+ commentId: c.commentId,
292711
+ parentCommentId: getThreadingParentId(c)
292712
+ });
292713
+ });
292507
292714
  startNodes.sort((a2, b$1) => {
292508
292715
  if (a2.pos !== b$1.pos)
292509
292716
  return a2.pos - b$1.pos;
@@ -310060,6 +310267,45 @@ menclose::after {
310060
310267
  if (explicitSpec)
310061
310268
  return explicitSpec;
310062
310269
  return borderValueToSpec(fallback);
310270
+ }, BORDER_STYLE_NUMBER, BORDER_STYLE_LINES, isPresentBorder = (b$1) => !!b$1 && b$1.style !== undefined && b$1.style !== "none" && (b$1.width === undefined || b$1.width > 0), isExplicitNoneBorder = (b$1) => {
310271
+ if (!b$1 || typeof b$1 !== "object")
310272
+ return false;
310273
+ const r$1 = b$1;
310274
+ return r$1.style === "none" || r$1.none === true;
310275
+ }, borderWeight = (b$1) => (BORDER_STYLE_LINES[b$1.style] ?? 1) * (BORDER_STYLE_NUMBER[b$1.style] ?? 1), colorBrightness = (color2, formula) => {
310276
+ const hex = (color2 ?? "#000000").replace("#", "");
310277
+ if (hex.length < 6)
310278
+ return 0;
310279
+ return formula(parseInt(hex.slice(0, 2), 16), parseInt(hex.slice(2, 4), 16), parseInt(hex.slice(4, 6), 16));
310280
+ }, resolveBorderConflict = (a2, b$1) => {
310281
+ const pa = isPresentBorder(a2);
310282
+ const pb = isPresentBorder(b$1);
310283
+ if (!pa && !pb)
310284
+ return;
310285
+ if (!pa)
310286
+ return b$1;
310287
+ if (!pb)
310288
+ return a2;
310289
+ const wa = borderWeight(a2);
310290
+ const wb = borderWeight(b$1);
310291
+ if (wa !== wb)
310292
+ return wa > wb ? a2 : b$1;
310293
+ const na = BORDER_STYLE_NUMBER[a2.style] ?? 99;
310294
+ const nb = BORDER_STYLE_NUMBER[b$1.style] ?? 99;
310295
+ if (na !== nb)
310296
+ return na < nb ? a2 : b$1;
310297
+ const formulas = [
310298
+ (r$1, g$1, bl) => r$1 + bl + 2 * g$1,
310299
+ (_r, g$1, bl) => bl + 2 * g$1,
310300
+ (_r, g$1) => g$1
310301
+ ];
310302
+ for (const f2 of formulas) {
310303
+ const ba = colorBrightness(a2.color, f2);
310304
+ const bb = colorBrightness(b$1.color, f2);
310305
+ if (ba !== bb)
310306
+ return ba < bb ? a2 : b$1;
310307
+ }
310308
+ return a2;
310063
310309
  }, hasExplicitCellBorders = (cellBorders) => Boolean(cellBorders && (cellBorders.top !== undefined || cellBorders.right !== undefined || cellBorders.bottom !== undefined || cellBorders.left !== undefined)), resolveTableCellBorders = (tableBorders, cellPosition) => {
310064
310310
  const cellBounds = getTableCellGridBounds(cellPosition);
310065
310311
  return {
@@ -310139,7 +310385,7 @@ menclose::after {
310139
310385
  return;
310140
310386
  if (this.#overrides.get(key2) === physical)
310141
310387
  return;
310142
- if ((BUNDLED_SUBSTITUTES[key2] ?? logicalFamily.trim()) === physical) {
310388
+ if (key2 === normalizeFamilyKey$2(physical)) {
310143
310389
  if (this.#overrides.delete(key2)) {
310144
310390
  this.#version += 1;
310145
310391
  this.#cachedSignature = null;
@@ -310191,12 +310437,41 @@ menclose::after {
310191
310437
  reason: "as_requested"
310192
310438
  };
310193
310439
  }
310440
+ #resolveFaceLadder(primary, face, hasFace) {
310441
+ const key2 = normalizeFamilyKey$2(primary);
310442
+ const override = this.#overrides.get(key2);
310443
+ if (override && hasFace(override, face.weight, face.style))
310444
+ return {
310445
+ physical: override,
310446
+ reason: "custom_mapping"
310447
+ };
310448
+ if (hasFace(primary, face.weight, face.style))
310449
+ return {
310450
+ physical: primary,
310451
+ reason: "registered_face"
310452
+ };
310453
+ const bundled = BUNDLED_SUBSTITUTES[key2];
310454
+ if (bundled && hasFace(bundled, face.weight, face.style))
310455
+ return {
310456
+ physical: bundled,
310457
+ reason: "bundled_substitute"
310458
+ };
310459
+ if (override || bundled)
310460
+ return {
310461
+ physical: primary,
310462
+ reason: "fallback_face_absent"
310463
+ };
310464
+ return {
310465
+ physical: primary,
310466
+ reason: "as_requested"
310467
+ };
310468
+ }
310194
310469
  resolveFontFamily(logicalFamily) {
310195
310470
  const primary = splitStack(logicalFamily)[0] ?? logicalFamily;
310196
310471
  const { physical, reason } = this.#physicalFor(primary);
310197
310472
  return {
310198
310473
  logicalFamily,
310199
- physicalFamily: physical,
310474
+ physicalFamily: stripFamilyQuotes(physical),
310200
310475
  reason
310201
310476
  };
310202
310477
  }
@@ -310213,23 +310488,11 @@ menclose::after {
310213
310488
  }
310214
310489
  resolveFace(logicalFamily, face, hasFace) {
310215
310490
  const primary = splitStack(logicalFamily)[0] ?? logicalFamily;
310216
- const { physical, reason } = this.#physicalFor(primary);
310217
- if (reason === "as_requested")
310218
- return {
310219
- logicalFamily,
310220
- physicalFamily: physical,
310221
- reason
310222
- };
310223
- if (hasFace(physical, face.weight, face.style))
310224
- return {
310225
- logicalFamily,
310226
- physicalFamily: physical,
310227
- reason
310228
- };
310491
+ const { physical, reason } = this.#resolveFaceLadder(primary, face, hasFace);
310229
310492
  return {
310230
310493
  logicalFamily,
310231
- physicalFamily: primary,
310232
- reason: "fallback_face_absent"
310494
+ physicalFamily: stripFamilyQuotes(physical),
310495
+ reason
310233
310496
  };
310234
310497
  }
310235
310498
  resolvePhysicalFamilyForFace(cssFontFamily, face, hasFace) {
@@ -310238,12 +310501,10 @@ menclose::after {
310238
310501
  const parts = splitStack(cssFontFamily);
310239
310502
  if (parts.length === 0)
310240
310503
  return cssFontFamily;
310241
- const { physical, reason } = this.#physicalFor(parts[0]);
310242
- if (reason === "as_requested")
310243
- return cssFontFamily;
310244
- if (!hasFace(physical, face.weight, face.style))
310245
- return cssFontFamily;
310246
- return [physical, ...parts.slice(1)].join(", ");
310504
+ const { physical, reason } = this.#resolveFaceLadder(parts[0], face, hasFace);
310505
+ if (reason === "custom_mapping" || reason === "bundled_substitute")
310506
+ return [physical, ...parts.slice(1)].join(", ");
310507
+ return cssFontFamily;
310247
310508
  }
310248
310509
  resolvePrimaryPhysicalFamily(family$1) {
310249
310510
  const primary = splitStack(family$1)[0] ?? family$1;
@@ -310271,6 +310532,7 @@ menclose::after {
310271
310532
  #faceInflight = /* @__PURE__ */ new Map;
310272
310533
  #faceSources = /* @__PURE__ */ new Map;
310273
310534
  #facesByFamily = /* @__PURE__ */ new Map;
310535
+ #providerFaceKeys = /* @__PURE__ */ new Set;
310274
310536
  #warnedFaceFailures = /* @__PURE__ */ new Set;
310275
310537
  constructor(options = {}) {
310276
310538
  this.#fontSet = options.fontSet ?? null;
@@ -310282,7 +310544,9 @@ menclose::after {
310282
310544
  register(descriptor) {
310283
310545
  const { family: family$1, source, descriptors: descriptors2 } = descriptor;
310284
310546
  const identitySource = typeof source === "string" ? canonicalizeFontSource(source) : source;
310285
- const key2 = faceKeyOf$1(family$1, normalizeWeight(descriptors2?.weight), normalizeStyle$1(descriptors2?.style));
310547
+ const weight = normalizeWeight(descriptors2?.weight);
310548
+ const style2 = normalizeStyle$1(descriptors2?.style);
310549
+ const key2 = faceKeyOf$1(family$1, weight, style2);
310286
310550
  if (typeof identitySource === "string") {
310287
310551
  const existingSource = this.#faceSources.get(key2);
310288
310552
  if (existingSource === identitySource)
@@ -310295,7 +310559,11 @@ menclose::after {
310295
310559
  throw new Error(`[superdoc] font face "${key2}" is already registered from a different source ("${existingSource}"); a registered face's source cannot be replaced`);
310296
310560
  }
310297
310561
  if (this.#FontFaceCtor && this.#fontSet) {
310298
- const face = new this.#FontFaceCtor(family$1, source, descriptors2);
310562
+ const face = new this.#FontFaceCtor(family$1, source, {
310563
+ ...descriptors2,
310564
+ weight,
310565
+ style: style2
310566
+ });
310299
310567
  this.#fontSet.add(face);
310300
310568
  this.#managed.set(family$1, face);
310301
310569
  }
@@ -310307,6 +310575,7 @@ menclose::after {
310307
310575
  }
310308
310576
  if (!this.#status.has(family$1))
310309
310577
  this.#status.set(family$1, "unloaded");
310578
+ this.#providerFaceKeys.add(key2);
310310
310579
  this.#trackFace(family$1, key2);
310311
310580
  if (!this.#faceStatus.has(key2))
310312
310581
  this.#faceStatus.set(key2, "unloaded");
@@ -310351,7 +310620,8 @@ menclose::after {
310351
310620
  return "unloaded";
310352
310621
  }
310353
310622
  hasFace(family$1, weight, style2) {
310354
- return this.#facesByFamily.get(normalizeFamilyKey$1(family$1))?.has(faceKeyOf$1(family$1, weight, style2)) ?? false;
310623
+ const key2 = faceKeyOf$1(family$1, weight, style2);
310624
+ return this.#providerFaceKeys.has(key2) && this.#faceStatus.get(key2) !== "failed";
310355
310625
  }
310356
310626
  isAvailable(family$1) {
310357
310627
  if (!this.#fontSet)
@@ -311875,8 +312145,21 @@ menclose::after {
311875
312145
  }
311876
312146
  }
311877
312147
  return { cellElement: cellEl };
311878
- }, hasAnyResolvedBorder = (borders) => Boolean(borders.top || borders.right || borders.bottom || borders.left), resolveRenderedCellBorders = ({ cellBorders, hasBordersAttribute, tableBorders, cellPosition, cellSpacingPx, continuesFromPrev, continuesOnNext }) => {
312148
+ }, hasAnyResolvedBorder = (borders) => Boolean(borders.top || borders.right || borders.bottom || borders.left), resolveRenderedCellBorders = ({ cellBorders, hasBordersAttribute, tableBorders, cellPosition, cellSpacingPx, continuesFromPrev, continuesOnNext, aboveCellBorders, leftCellBorders, rightCellBorders, nextRowLeavesRightGap, deferTopToAboveCell, nextRowSuppressesSharedTop }) => {
311879
312149
  const hasExplicitBorders = hasExplicitCellBorders(cellBorders);
312150
+ const cellBounds = getTableCellGridBounds(cellPosition);
312151
+ const touchesTopBoundary = cellBounds.touchesTopEdge || continuesFromPrev;
312152
+ const touchesBottomBoundary = cellBounds.touchesBottomEdge || continuesOnNext || nextRowLeavesRightGap === true;
312153
+ const hasInteriorNeighborBorder = !touchesTopBoundary && !deferTopToAboveCell && isPresentBorder(aboveCellBorders?.bottom) || !cellBounds.touchesLeftEdge && isPresentBorder(leftCellBorders?.right);
312154
+ if (cellSpacingPx === 0 && (hasExplicitBorders || hasInteriorNeighborBorder)) {
312155
+ const cb = cellBorders ?? {};
312156
+ return {
312157
+ top: touchesTopBoundary ? resolveTableBorderValue(cb.top, tableBorders?.top) : deferTopToAboveCell ? undefined : resolveBorderConflict(cb.top, aboveCellBorders?.bottom) ?? (isExplicitNoneBorder(cb.top) && isExplicitNoneBorder(aboveCellBorders?.bottom) ? undefined : borderValueToSpec(tableBorders?.insideH)),
312158
+ left: cellBounds.touchesLeftEdge ? resolveTableBorderValue(cb.left, tableBorders?.left) : isPresentBorder(cb.left) ? resolveBorderConflict(cb.left, leftCellBorders?.right) ?? borderValueToSpec(tableBorders?.insideV) : isPresentBorder(leftCellBorders?.right) ? undefined : isExplicitNoneBorder(cb.left) && isExplicitNoneBorder(leftCellBorders?.right) ? undefined : borderValueToSpec(tableBorders?.insideV),
312159
+ right: cellBounds.touchesRightEdge ? resolveTableBorderValue(cb.right, tableBorders?.right) : isPresentBorder(cb.right) && !isPresentBorder(rightCellBorders?.left) ? cb.right : undefined,
312160
+ bottom: touchesBottomBoundary ? resolveTableBorderValue(cb.bottom, tableBorders?.bottom) : undefined
312161
+ };
312162
+ }
311880
312163
  if (hasBordersAttribute && !hasExplicitBorders)
311881
312164
  return;
311882
312165
  if (!tableBorders)
@@ -311886,24 +312169,13 @@ menclose::after {
311886
312169
  bottom: cellBorders.bottom,
311887
312170
  left: cellBorders.left
311888
312171
  } : undefined;
311889
- const cellBounds = getTableCellGridBounds(cellPosition);
311890
- const touchesTopBoundary = cellBounds.touchesTopEdge || continuesFromPrev;
311891
- const touchesBottomBoundary = cellBounds.touchesBottomEdge || continuesOnNext;
311892
- if (hasExplicitBorders) {
311893
- if (cellSpacingPx === 0)
311894
- return {
311895
- top: resolveTableBorderValue(cellBorders.top, touchesTopBoundary ? tableBorders.top : tableBorders.insideH),
311896
- right: cellBounds.touchesRightEdge ? resolveTableBorderValue(cellBorders.right, tableBorders.right) : undefined,
311897
- bottom: touchesBottomBoundary ? resolveTableBorderValue(cellBorders.bottom, tableBorders.bottom) : undefined,
311898
- left: resolveTableBorderValue(cellBorders.left, cellBounds.touchesLeftEdge ? tableBorders.left : tableBorders.insideV)
311899
- };
312172
+ if (hasExplicitBorders)
311900
312173
  return {
311901
312174
  top: resolveTableBorderValue(cellBorders.top, touchesTopBoundary ? tableBorders.top : tableBorders.insideH),
311902
312175
  right: resolveTableBorderValue(cellBorders.right, cellBounds.touchesRightEdge ? tableBorders.right : undefined),
311903
312176
  bottom: resolveTableBorderValue(cellBorders.bottom, touchesBottomBoundary ? tableBorders.bottom : undefined),
311904
312177
  left: resolveTableBorderValue(cellBorders.left, cellBounds.touchesLeftEdge ? tableBorders.left : tableBorders.insideV)
311905
312178
  };
311906
- }
311907
312179
  if (cellSpacingPx > 0) {
311908
312180
  const interiorBorders = {
311909
312181
  top: touchesTopBoundary ? undefined : borderValueToSpec(tableBorders.insideH),
@@ -311914,15 +312186,29 @@ menclose::after {
311914
312186
  return hasAnyResolvedBorder(interiorBorders) ? interiorBorders : undefined;
311915
312187
  }
311916
312188
  const baseBorders = resolveTableCellBorders(tableBorders, cellPosition);
312189
+ const insideHSpec = borderValueToSpec(tableBorders.insideH);
312190
+ const interiorBottom = nextRowSuppressesSharedTop && isPresentBorder(insideHSpec) ? insideHSpec : baseBorders.bottom;
311917
312191
  return {
311918
312192
  top: touchesTopBoundary ? borderValueToSpec(tableBorders.top) : baseBorders.top,
311919
312193
  right: baseBorders.right,
311920
- bottom: touchesBottomBoundary ? borderValueToSpec(tableBorders.bottom) : baseBorders.bottom,
312194
+ bottom: touchesBottomBoundary ? borderValueToSpec(tableBorders.bottom) : interiorBottom,
311921
312195
  left: baseBorders.left
311922
312196
  };
311923
312197
  }, renderTableRow = (deps) => {
311924
- const { doc: doc$12, container, rowIndex, y: y$1, rowMeasure, row: row2, totalRows, tableBorders, columnWidths, allRowHeights, tableIndent, isRtl, context, renderLine: renderLine$1, captureLineSnapshot, renderDrawingContent, applySdtDataset: applySdtDataset$1, ancestorContainerKey, ancestorContainerSdt, ancestorContainerKeys, ancestorContainerSdts, onSdtContainerChrome, continuesFromPrev, continuesOnNext, partialRow, cellSpacingPx = 0, chrome: chrome2, resolvePhysical } = deps;
312198
+ const { doc: doc$12, container, rowIndex, y: y$1, rowMeasure, row: row2, prevRow, prevRowMeasure, nextRow, nextRowMeasure, rowOccupiedRightCol, nextRowOccupiedRightCol, totalRows, tableBorders, columnWidths, allRowHeights, tableIndent, isRtl, context, renderLine: renderLine$1, captureLineSnapshot, renderDrawingContent, applySdtDataset: applySdtDataset$1, ancestorContainerKey, ancestorContainerSdt, ancestorContainerKeys, ancestorContainerSdts, onSdtContainerChrome, continuesFromPrev, continuesOnNext, partialRow, cellSpacingPx = 0, chrome: chrome2, resolvePhysical } = deps;
311925
312199
  const totalCols = columnWidths.length;
312200
+ const rowRightEdgeCol = rowOccupiedRightCol != null && rowOccupiedRightCol > 0 ? Math.min(totalCols, rowOccupiedRightCol) : rowMeasure.cells.length ? Math.min(totalCols, Math.max(...rowMeasure.cells.map((c) => (c.gridColumnStart ?? 0) + (c.colSpan ?? 1)))) : totalCols;
312201
+ const rowBorderOverride = row2?.attrs?.borders;
312202
+ const effectiveTableBorders = rowBorderOverride ? {
312203
+ ...tableBorders ?? {},
312204
+ ...rowBorderOverride
312205
+ } : tableBorders;
312206
+ const nextRowBorderOverride = nextRow?.attrs?.borders;
312207
+ const nextRowEffectiveInsideH = nextRowBorderOverride ? {
312208
+ ...tableBorders ?? {},
312209
+ ...nextRowBorderOverride
312210
+ }.insideH : undefined;
312211
+ const nextRowSuppressesSharedTop = nextRowBorderOverride !== undefined && !isPresentBorder(borderValueToSpec(nextRowEffectiveInsideH));
311926
312212
  const calculateXPosition = (gridColumnStart) => {
311927
312213
  let x = cellSpacingPx;
311928
312214
  for (let i4 = 0;i4 < gridColumnStart && i4 < columnWidths.length; i4++)
@@ -311947,6 +312233,27 @@ menclose::after {
311947
312233
  width += columnWidths[i4];
311948
312234
  return width;
311949
312235
  };
312236
+ const findCellBordersAtColumn = (cells, measureCells, gridCol) => {
312237
+ if (!cells || !measureCells)
312238
+ return;
312239
+ for (let i4 = 0;i4 < measureCells.length; i4++) {
312240
+ const start$1 = measureCells[i4].gridColumnStart ?? i4;
312241
+ const span = measureCells[i4].colSpan ?? 1;
312242
+ if (gridCol >= start$1 && gridCol < start$1 + span)
312243
+ return cells[i4]?.attrs?.borders;
312244
+ }
312245
+ };
312246
+ const findCellRightEdgeAtColumn = (measureCells, gridCol) => {
312247
+ if (!measureCells)
312248
+ return;
312249
+ for (let i4 = 0;i4 < measureCells.length; i4++) {
312250
+ const start$1 = measureCells[i4].gridColumnStart ?? i4;
312251
+ const span = measureCells[i4].colSpan ?? 1;
312252
+ if (gridCol >= start$1 && gridCol < start$1 + span)
312253
+ return start$1 + span;
312254
+ }
312255
+ };
312256
+ const nextRowMaxCol = nextRowOccupiedRightCol != null && nextRowOccupiedRightCol > 0 ? nextRowOccupiedRightCol : nextRowMeasure?.cells?.length ? Math.max(...nextRowMeasure.cells.map((c) => (c.gridColumnStart ?? 0) + (c.colSpan ?? 1))) : Infinity;
311950
312257
  for (let cellIndex = 0;cellIndex < rowMeasure.cells.length; cellIndex += 1) {
311951
312258
  const cellMeasure = rowMeasure.cells[cellIndex];
311952
312259
  const cell2 = row2?.cells?.[cellIndex];
@@ -311955,21 +312262,34 @@ menclose::after {
311955
312262
  const colSpan = cellMeasure.colSpan ?? 1;
311956
312263
  let x = calculateXPosition(gridColumnStart);
311957
312264
  const cellBordersAttr = cell2?.attrs?.borders;
312265
+ const hasBordersAttribute = cellBordersAttr !== undefined;
312266
+ const cellPosition = {
312267
+ rowIndex,
312268
+ rowSpan,
312269
+ gridColumnStart,
312270
+ colSpan,
312271
+ totalRows,
312272
+ totalCols: rowRightEdgeCol
312273
+ };
312274
+ const aboveCellBorders = findCellBordersAtColumn(prevRow?.cells, prevRowMeasure?.cells, gridColumnStart);
312275
+ const leftCellBorders = gridColumnStart > 0 ? findCellBordersAtColumn(row2?.cells, rowMeasure.cells, gridColumnStart - 1) : undefined;
312276
+ const rightCellBorders = findCellBordersAtColumn(row2?.cells, rowMeasure.cells, gridColumnStart + colSpan);
312277
+ const nextRowLeavesRightGap = gridColumnStart + colSpan > nextRowMaxCol;
312278
+ const aboveCellRightEdge = findCellRightEdgeAtColumn(prevRowMeasure?.cells, gridColumnStart);
311958
312279
  const resolvedBorders = resolveRenderedCellBorders({
311959
312280
  cellBorders: cellBordersAttr,
311960
- hasBordersAttribute: cellBordersAttr !== undefined,
311961
- tableBorders,
311962
- cellPosition: {
311963
- rowIndex,
311964
- rowSpan,
311965
- gridColumnStart,
311966
- colSpan,
311967
- totalRows,
311968
- totalCols
311969
- },
312281
+ hasBordersAttribute,
312282
+ tableBorders: effectiveTableBorders,
312283
+ cellPosition,
311970
312284
  cellSpacingPx,
311971
312285
  continuesFromPrev: continuesFromPrev === true,
311972
- continuesOnNext: continuesOnNext === true
312286
+ continuesOnNext: continuesOnNext === true,
312287
+ aboveCellBorders,
312288
+ leftCellBorders,
312289
+ rightCellBorders,
312290
+ nextRowLeavesRightGap,
312291
+ deferTopToAboveCell: aboveCellRightEdge !== undefined && aboveCellRightEdge > rowRightEdgeCol,
312292
+ nextRowSuppressesSharedTop
311973
312293
  });
311974
312294
  const finalBorders = isRtl && resolvedBorders ? swapCellBordersLR(resolvedBorders) : resolvedBorders;
311975
312295
  let cellHeight;
@@ -312102,12 +312422,22 @@ menclose::after {
312102
312422
  if (!rowMeasure)
312103
312423
  continue;
312104
312424
  const boundariesInRow = /* @__PURE__ */ new Set;
312425
+ const occupiedCols = /* @__PURE__ */ new Set;
312426
+ for (const cellMeasure of rowMeasure.cells) {
312427
+ const s2 = cellMeasure.gridColumnStart ?? 0;
312428
+ const sp = cellMeasure.colSpan ?? 1;
312429
+ for (let c = s2;c < s2 + sp; c++)
312430
+ occupiedCols.add(c);
312431
+ }
312432
+ const lastColIndex = columnCount - 1;
312433
+ const lastColMeta = fragment2.metadata.columnBoundaries[lastColIndex];
312434
+ const skipTrailingSpacerBoundary = lastColIndex > 0 && !occupiedCols.has(lastColIndex) && !!lastColMeta && typeof lastColMeta.width === "number" && typeof lastColMeta.minWidth === "number" && lastColMeta.width < lastColMeta.minWidth;
312105
312435
  for (const cellMeasure of rowMeasure.cells) {
312106
312436
  const startCol = cellMeasure.gridColumnStart ?? 0;
312107
312437
  const endCol = startCol + (cellMeasure.colSpan ?? 1);
312108
312438
  if (startCol > 0)
312109
312439
  boundariesInRow.add(startCol);
312110
- if (endCol < columnCount)
312440
+ if (endCol < columnCount && !(skipTrailingSpacerBoundary && endCol === lastColIndex))
312111
312441
  boundariesInRow.add(endCol);
312112
312442
  }
312113
312443
  for (const boundaryCol of boundariesInRow) {
@@ -312164,6 +312494,16 @@ menclose::after {
312164
312494
  return fragment2.partialRow.partialHeight;
312165
312495
  return r$1?.height ?? 0;
312166
312496
  });
312497
+ const rowOccupiedRightCols = new Array(measure.rows.length).fill(0);
312498
+ measure.rows.forEach((rowM, r$1) => {
312499
+ for (const c of rowM?.cells ?? []) {
312500
+ const right$1 = (c.gridColumnStart ?? 0) + (c.colSpan ?? 1);
312501
+ const lastRow = Math.min(measure.rows.length - 1, r$1 + (c.rowSpan ?? 1) - 1);
312502
+ for (let rr = r$1;rr <= lastRow; rr += 1)
312503
+ if (right$1 > rowOccupiedRightCols[rr])
312504
+ rowOccupiedRightCols[rr] = right$1;
312505
+ }
312506
+ });
312167
312507
  let y$1 = cellSpacingPx;
312168
312508
  if (fragment2.repeatHeaderCount && fragment2.repeatHeaderCount > 0)
312169
312509
  for (let r$1 = 0;r$1 < fragment2.repeatHeaderCount; r$1 += 1) {
@@ -312177,6 +312517,12 @@ menclose::after {
312177
312517
  y: y$1,
312178
312518
  rowMeasure,
312179
312519
  row: block.rows[r$1],
312520
+ prevRow: r$1 > 0 ? block.rows[r$1 - 1] : undefined,
312521
+ prevRowMeasure: r$1 > 0 ? measure.rows[r$1 - 1] : undefined,
312522
+ nextRow: r$1 < block.rows.length - 1 ? block.rows[r$1 + 1] : undefined,
312523
+ nextRowMeasure: r$1 < block.rows.length - 1 ? measure.rows[r$1 + 1] : undefined,
312524
+ rowOccupiedRightCol: rowOccupiedRightCols[r$1],
312525
+ nextRowOccupiedRightCol: rowOccupiedRightCols[r$1 + 1],
312180
312526
  totalRows: block.rows.length,
312181
312527
  tableBorders,
312182
312528
  columnWidths: effectiveColumnWidths,
@@ -312295,6 +312641,12 @@ menclose::after {
312295
312641
  y: y$1,
312296
312642
  rowMeasure,
312297
312643
  row: block.rows[r$1],
312644
+ prevRow: r$1 > 0 ? block.rows[r$1 - 1] : undefined,
312645
+ prevRowMeasure: r$1 > 0 ? measure.rows[r$1 - 1] : undefined,
312646
+ nextRow: r$1 < block.rows.length - 1 ? block.rows[r$1 + 1] : undefined,
312647
+ nextRowMeasure: r$1 < block.rows.length - 1 ? measure.rows[r$1 + 1] : undefined,
312648
+ rowOccupiedRightCol: rowOccupiedRightCols[r$1],
312649
+ nextRowOccupiedRightCol: rowOccupiedRightCols[r$1 + 1],
312298
312650
  totalRows: block.rows.length,
312299
312651
  tableBorders,
312300
312652
  columnWidths: effectiveColumnWidths,
@@ -325737,6 +326089,7 @@ menclose::after {
325737
326089
  #requiredFaceKeys = /* @__PURE__ */ new Set;
325738
326090
  #seenAvailable = /* @__PURE__ */ new Set;
325739
326091
  #seenAvailableFaces = /* @__PURE__ */ new Set;
326092
+ #seenFailedFaces = /* @__PURE__ */ new Set;
325740
326093
  #lastSummary = null;
325741
326094
  #loadingDoneHandler = null;
325742
326095
  #lateLoadScheduler;
@@ -325812,9 +326165,18 @@ menclose::after {
325812
326165
  } catch {
325813
326166
  results = [];
325814
326167
  }
325815
- for (const result of results)
326168
+ const failedKeys = [];
326169
+ for (const result of results) {
326170
+ const key2 = faceKeyOf(result.request.family, result.request.weight, result.request.style);
325816
326171
  if (result.status === "loaded")
325817
- this.#seenAvailableFaces.add(faceKeyOf(result.request.family, result.request.weight, result.request.style));
326172
+ this.#seenAvailableFaces.add(key2);
326173
+ else if (result.status === "failed" && !this.#seenFailedFaces.has(key2)) {
326174
+ this.#seenFailedFaces.add(key2);
326175
+ failedKeys.push(key2);
326176
+ }
326177
+ }
326178
+ if (failedKeys.length > 0)
326179
+ this.#scheduleAvailabilityReflow(failedKeys);
325818
326180
  this.#lastSummary = summarizeFaces(results);
325819
326181
  return this.#lastSummary;
325820
326182
  }
@@ -325871,6 +326233,7 @@ menclose::after {
325871
326233
  this.#requiredFamilies = /* @__PURE__ */ new Set;
325872
326234
  this.#seenAvailable.clear();
325873
326235
  this.#seenAvailableFaces.clear();
326236
+ this.#seenFailedFaces.clear();
325874
326237
  this.#lastSummary = null;
325875
326238
  }
325876
326239
  dispose() {
@@ -325936,6 +326299,9 @@ menclose::after {
325936
326299
  }
325937
326300
  if (changedKeys.length === 0)
325938
326301
  return;
326302
+ this.#scheduleAvailabilityReflow(changedKeys);
326303
+ }
326304
+ #scheduleAvailabilityReflow(changedKeys) {
325939
326305
  this.#fontConfigVersion += 1;
325940
326306
  bumpFontConfigVersion();
325941
326307
  this.#invalidateCaches();
@@ -326035,8 +326401,13 @@ menclose::after {
326035
326401
  const registry2 = this.#getGate()?.resolveRegistry();
326036
326402
  if (!registry2)
326037
326403
  throw new Error("[superdoc] fonts.preload: the font registry is not ready yet");
326404
+ const hasFace = (family$1, weight, style2) => registry2.hasFace(family$1, weight, style2);
326405
+ const face = {
326406
+ weight: "400",
326407
+ style: "normal"
326408
+ };
326038
326409
  const requests = families.map((logical) => ({
326039
- family: this.#resolver.resolvePrimaryPhysicalFamily(logical),
326410
+ family: this.#resolver.resolveFace(logical, face, hasFace).physicalFamily,
326040
326411
  weight: "400",
326041
326412
  style: "normal"
326042
326413
  }));
@@ -326153,19 +326524,19 @@ menclose::after {
326153
326524
  return;
326154
326525
  console.log(...args$1);
326155
326526
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions, TRACKED_MARK_NAMES;
326156
- var init_src_DvgAvHbj_es = __esm(() => {
326527
+ var init_src_DPx6wkCz_es = __esm(() => {
326157
326528
  init_rolldown_runtime_Bg48TavK_es();
326158
- init_SuperConverter_B9mZiCO9_es();
326529
+ init_SuperConverter_DBsJeu9t_es();
326159
326530
  init_jszip_C49i9kUs_es();
326160
326531
  init_xml_js_CqGKpaft_es();
326161
326532
  init_uuid_qzgm05fK_es();
326162
- init_create_headless_toolbar_pn_wKqsL_es();
326163
- init_constants_D_X7xF4s_es();
326533
+ init_create_headless_toolbar_BiY_0zZP_es();
326534
+ init_constants_D9qj59G2_es();
326164
326535
  init_dist_B8HfvhaK_es();
326165
326536
  init_unified_Dsuw2be5_es();
326166
326537
  init_remark_gfm_BhnWr3yf_es();
326167
326538
  init_remark_stringify_6MMJfY0k_es();
326168
- init_DocxZipper_VodIk8WL_es();
326539
+ init_DocxZipper_Bu2Fhqkw_es();
326169
326540
  init__plugin_vue_export_helper_5t5P5NuM_es();
326170
326541
  init_eventemitter3_BnGqBE_Q_es();
326171
326542
  init_errors_CNaD6vcg_es();
@@ -329240,6 +329611,17 @@ ${err.toString()}`);
329240
329611
  dispatch
329241
329612
  });
329242
329613
  },
329614
+ resolveCommentThread: ({ comments } = {}) => ({ tr, dispatch, state }) => {
329615
+ tr.setMeta(CommentsPluginKey, { event: "update" });
329616
+ const converted = resolveCommentsInTr({
329617
+ items: comments,
329618
+ state,
329619
+ tr
329620
+ });
329621
+ if (converted)
329622
+ dispatch(tr);
329623
+ return converted;
329624
+ },
329243
329625
  reopenComment: ({ commentId, importedId, internal }) => ({ tr, dispatch, state }) => {
329244
329626
  tr.setMeta(CommentsPluginKey, { event: "update" });
329245
329627
  return reopenCommentById({
@@ -353028,6 +353410,30 @@ function print() { __p += __j.call(arguments, '') }
353028
353410
  "wave",
353029
353411
  "doubleWave"
353030
353412
  ]);
353413
+ BORDER_STYLE_NUMBER = {
353414
+ single: 1,
353415
+ thick: 2,
353416
+ double: 3,
353417
+ dotted: 4,
353418
+ dashed: 5,
353419
+ dotDash: 6,
353420
+ dotDotDash: 7,
353421
+ triple: 8,
353422
+ wave: 18,
353423
+ doubleWave: 19
353424
+ };
353425
+ BORDER_STYLE_LINES = {
353426
+ single: 1,
353427
+ thick: 1,
353428
+ double: 2,
353429
+ dotted: 1,
353430
+ dashed: 1,
353431
+ dotDash: 1,
353432
+ dotDotDash: 1,
353433
+ triple: 3,
353434
+ wave: 1,
353435
+ doubleWave: 2
353436
+ };
353031
353437
  SETTLED_STATUSES = [
353032
353438
  "loaded",
353033
353439
  "failed",
@@ -360868,11 +361274,11 @@ function print() { __p += __j.call(arguments, '') }
360868
361274
  ]);
360869
361275
  });
360870
361276
 
360871
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CxQcY_QQ.es.js
361277
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-k5vyPmpN.es.js
360872
361278
  var MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS;
360873
- var init_create_super_doc_ui_CxQcY_QQ_es = __esm(() => {
360874
- init_SuperConverter_B9mZiCO9_es();
360875
- init_create_headless_toolbar_pn_wKqsL_es();
361279
+ var init_create_super_doc_ui_k5vyPmpN_es = __esm(() => {
361280
+ init_SuperConverter_DBsJeu9t_es();
361281
+ init_create_headless_toolbar_BiY_0zZP_es();
360876
361282
  MOD_ALIASES = new Set([
360877
361283
  "Mod",
360878
361284
  "Meta",
@@ -360914,16 +361320,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
360914
361320
 
360915
361321
  // ../../packages/superdoc/dist/super-editor.es.js
360916
361322
  var init_super_editor_es = __esm(() => {
360917
- init_src_DvgAvHbj_es();
360918
- init_SuperConverter_B9mZiCO9_es();
361323
+ init_src_DPx6wkCz_es();
361324
+ init_SuperConverter_DBsJeu9t_es();
360919
361325
  init_jszip_C49i9kUs_es();
360920
361326
  init_xml_js_CqGKpaft_es();
360921
- init_create_headless_toolbar_pn_wKqsL_es();
360922
- init_constants_D_X7xF4s_es();
361327
+ init_create_headless_toolbar_BiY_0zZP_es();
361328
+ init_constants_D9qj59G2_es();
360923
361329
  init_dist_B8HfvhaK_es();
360924
361330
  init_unified_Dsuw2be5_es();
360925
- init_DocxZipper_VodIk8WL_es();
360926
- init_create_super_doc_ui_CxQcY_QQ_es();
361331
+ init_DocxZipper_Bu2Fhqkw_es();
361332
+ init_create_super_doc_ui_k5vyPmpN_es();
360927
361333
  init_ui_C5PAS9hY_es();
360928
361334
  init_eventemitter3_BnGqBE_Q_es();
360929
361335
  init_errors_CNaD6vcg_es();