@superdoc-dev/cli 0.16.0-next.22 → 0.16.0-next.24

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 +572 -286
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -68342,7 +68342,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
68342
68342
  emptyOptions2 = {};
68343
68343
  });
68344
68344
 
68345
- // ../../packages/superdoc/dist/chunks/SuperConverter-B9mZiCO9.es.js
68345
+ // ../../packages/superdoc/dist/chunks/SuperConverter-BSMYiYJm.es.js
68346
68346
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
68347
68347
  const fieldValue = extension$1.config[field];
68348
68348
  if (typeof fieldValue === "function")
@@ -78291,6 +78291,70 @@ function computeFragmentPmRange(block, lines, fromLine, toLine) {
78291
78291
  pmEnd
78292
78292
  };
78293
78293
  }
78294
+ function resolveAnchoredGraphicY(input) {
78295
+ const { anchor, objectHeight, contentTop, contentBottom, pageBottomMargin = 0, anchorParagraphY = contentTop, firstLineHeight = 0, preRegisteredFallbackToContentTop = false } = input;
78296
+ const offsetV = anchor?.offsetV ?? 0;
78297
+ const vRelativeFrom = anchor?.vRelativeFrom;
78298
+ const alignV = anchor?.alignV;
78299
+ const contentHeight = Math.max(0, contentBottom - contentTop);
78300
+ if (vRelativeFrom === "margin") {
78301
+ if (alignV === "bottom")
78302
+ return contentBottom - objectHeight + offsetV;
78303
+ if (alignV === "center")
78304
+ return contentTop + (contentHeight - objectHeight) / 2 + offsetV;
78305
+ return contentTop + offsetV;
78306
+ }
78307
+ if (vRelativeFrom === "page") {
78308
+ const pageHeight = contentBottom + pageBottomMargin;
78309
+ if (alignV === "bottom")
78310
+ return pageHeight - objectHeight + offsetV;
78311
+ if (alignV === "center")
78312
+ return (pageHeight - objectHeight) / 2 + offsetV;
78313
+ return offsetV;
78314
+ }
78315
+ if (vRelativeFrom === "paragraph") {
78316
+ if (preRegisteredFallbackToContentTop)
78317
+ return contentTop + offsetV;
78318
+ const baseAnchorY = anchorParagraphY;
78319
+ if (alignV === "bottom")
78320
+ return baseAnchorY + firstLineHeight - objectHeight + offsetV;
78321
+ if (alignV === "center")
78322
+ return baseAnchorY + (firstLineHeight - objectHeight) / 2 + offsetV;
78323
+ return baseAnchorY + offsetV;
78324
+ }
78325
+ if (preRegisteredFallbackToContentTop)
78326
+ return contentTop + offsetV;
78327
+ return anchorParagraphY + offsetV;
78328
+ }
78329
+ function resolveAnchoredGraphicX(anchor, columnIndex, columns, objectWidth, margins, pageWidth) {
78330
+ const alignH = anchor.alignH ?? "left";
78331
+ const offsetH = anchor.offsetH ?? 0;
78332
+ const marginLeft = Math.max(0, margins?.left ?? 0);
78333
+ const marginRight = Math.max(0, margins?.right ?? 0);
78334
+ const contentWidth = pageWidth != null ? Math.max(1, pageWidth - (marginLeft + marginRight)) : columns.width;
78335
+ const contentLeft = marginLeft;
78336
+ const columnLeft = contentLeft + columnIndex * (columns.width + columns.gap);
78337
+ const relativeFrom = anchor.hRelativeFrom ?? "column";
78338
+ let baseX;
78339
+ let availableWidth;
78340
+ if (relativeFrom === "page") {
78341
+ baseX = 0;
78342
+ availableWidth = pageWidth != null ? pageWidth : contentWidth + marginLeft + marginRight;
78343
+ } else if (relativeFrom === "margin") {
78344
+ baseX = contentLeft;
78345
+ availableWidth = contentWidth;
78346
+ } else {
78347
+ baseX = columnLeft;
78348
+ availableWidth = columns.width;
78349
+ }
78350
+ if (alignH === "left")
78351
+ return baseX + offsetH;
78352
+ if (alignH === "right")
78353
+ return baseX + availableWidth - objectWidth - offsetH;
78354
+ if (alignH === "center")
78355
+ return baseX + (availableWidth - objectWidth) / 2 + offsetH;
78356
+ return baseX;
78357
+ }
78294
78358
  function widthsEqual(a, b) {
78295
78359
  if (!a && !b)
78296
78360
  return true;
@@ -78317,10 +78381,12 @@ function cloneColumnLayout(columns) {
78317
78381
  }
78318
78382
  function normalizeColumnLayout(input, contentWidth, epsilon = 0.0001) {
78319
78383
  const rawCount = input && Number.isFinite(input.count) ? Math.floor(input.count) : 1;
78320
- const count2 = Math.max(1, rawCount || 1);
78384
+ let count2 = Math.max(1, rawCount || 1);
78321
78385
  const gap = Math.max(0, input?.gap ?? 0);
78386
+ 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) : [];
78387
+ if (explicitWidths.length > 0 && explicitWidths.length < count2)
78388
+ count2 = explicitWidths.length;
78322
78389
  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
78390
  let widths = explicitWidths.length > 0 ? explicitWidths.slice(0, count2) : Array.from({ length: count2 }, () => availableWidth > 0 ? availableWidth / count2 : contentWidth);
78325
78391
  if (widths.length < count2) {
78326
78392
  const remaining = Math.max(0, availableWidth - widths.reduce((sum, width$1) => sum + width$1, 0));
@@ -83755,6 +83821,8 @@ function handleImageNode$1(node3, params3, isAnchor) {
83755
83821
  default:
83756
83822
  break;
83757
83823
  }
83824
+ if (wrap$1.type === "Square" || wrap$1.type === "Tight" || wrap$1.type === "Through" || wrap$1.type === "TopAndBottom")
83825
+ mergeAnchorPaddingIntoWrapDistances(wrap$1, padding);
83758
83826
  const docPr = node3.elements.find((el) => el.name === "wp:docPr");
83759
83827
  const isHidden = isDocPrHidden(docPr);
83760
83828
  let anchorData = null;
@@ -101825,18 +101893,22 @@ function extractColumns(elements) {
101825
101893
  const cols = elements.find((el) => el?.name === "w:cols");
101826
101894
  if (!cols?.attributes)
101827
101895
  return;
101828
- const count2 = parseColumnCount(cols.attributes["w:num"]);
101896
+ let count2 = parseColumnCount(cols.attributes["w:num"]);
101829
101897
  const withSeparator = parseColumnSeparator(cols.attributes["w:sep"]);
101830
101898
  const equalWidthRaw = cols.attributes["w:equalWidth"];
101831
101899
  const equalWidth = equalWidthRaw === "0" || equalWidthRaw === 0 || equalWidthRaw === false ? false : equalWidthRaw === "1" || equalWidthRaw === 1 || equalWidthRaw === true ? true : undefined;
101832
101900
  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"]);
101901
+ const isExplicit = equalWidth === false;
101902
+ const firstChildSpace = columnChildren.find((child) => child?.attributes?.["w:space"] != null)?.attributes?.["w:space"];
101903
+ const gapInches = parseColumnGap(isExplicit ? firstChildSpace ?? 0 : cols.attributes["w:space"]);
101834
101904
  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);
101905
+ if (isExplicit && widths.length > 0)
101906
+ count2 = Math.min(count2, widths.length);
101835
101907
  return {
101836
101908
  count: count2,
101837
101909
  gap: gapInches * PX_PER_INCH$1,
101838
101910
  withSeparator,
101839
- ...widths.length > 0 ? { widths } : {},
101911
+ ...isExplicit && widths.length > 0 ? { widths } : {},
101840
101912
  ...equalWidth !== undefined ? { equalWidth } : {}
101841
101913
  };
101842
101914
  }
@@ -104680,6 +104752,8 @@ function imageNodeToBlock(node3, nextBlockId, positions, _trackedMeta, _trackedC
104680
104752
  const height = typeof size2.height === "number" && Number.isFinite(size2.height) ? size2.height : undefined;
104681
104753
  const explicitDisplay = typeof attrs.display === "string" ? attrs.display : undefined;
104682
104754
  const normalizedWrap = normalizeWrap$1(attrs.wrap);
104755
+ if (normalizedWrap)
104756
+ mergeWrapDistancesFromPadding(normalizedWrap, toBoxSpacing$1(attrs.padding));
104683
104757
  let anchor = normalizeAnchorData(attrs.anchorData, attrs, normalizedWrap?.behindDoc);
104684
104758
  if (!anchor && normalizedWrap) {
104685
104759
  anchor = { isAnchored: true };
@@ -120153,6 +120227,17 @@ var isRegExp = (value) => {
120153
120227
  if (!hasValue || !hasPositive)
120154
120228
  return null;
120155
120229
  return `inset(${percentEdges.top ?? 0}% ${percentEdges.right ?? 0}% ${percentEdges.bottom ?? 0}% ${percentEdges.left ?? 0}%)`;
120230
+ }, mergeAnchorPaddingIntoWrapDistances = (wrap$1, padding) => {
120231
+ if (!wrap$1?.attrs || !padding)
120232
+ return;
120233
+ if (wrap$1.attrs.distTop == null && Number.isFinite(padding.top) && padding.top !== 0)
120234
+ wrap$1.attrs.distTop = padding.top;
120235
+ if (wrap$1.attrs.distBottom == null && Number.isFinite(padding.bottom) && padding.bottom !== 0)
120236
+ wrap$1.attrs.distBottom = padding.bottom;
120237
+ if (wrap$1.attrs.distLeft == null && Number.isFinite(padding.left) && padding.left !== 0)
120238
+ wrap$1.attrs.distLeft = padding.left;
120239
+ if (wrap$1.attrs.distRight == null && Number.isFinite(padding.right) && padding.right !== 0)
120240
+ wrap$1.attrs.distRight = padding.right;
120156
120241
  }, handleShapeDrawing = (params3, node3, graphicData, size2, padding, marginOffset, anchorData, wrap$1, isAnchor, isHidden) => {
120157
120242
  const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
120158
120243
  const textBoxContent = wsp.elements.find((el) => el.name === "wps:txbx")?.elements?.find((el) => el.name === "w:txbxContent");
@@ -128717,6 +128802,17 @@ var isRegExp = (value) => {
128717
128802
  const parsed = parseFloat(value);
128718
128803
  return Number.isFinite(parsed) ? parsed : undefined;
128719
128804
  }
128805
+ }, mergeWrapDistancesFromPadding = (wrap$1, padding) => {
128806
+ if (!padding || wrap$1.type === "None" || wrap$1.type === "Inline")
128807
+ return;
128808
+ if (wrap$1.distTop == null && padding.top != null)
128809
+ wrap$1.distTop = padding.top;
128810
+ if (wrap$1.distBottom == null && padding.bottom != null)
128811
+ wrap$1.distBottom = padding.bottom;
128812
+ if (wrap$1.distLeft == null && padding.left != null)
128813
+ wrap$1.distLeft = padding.left;
128814
+ if (wrap$1.distRight == null && padding.right != null)
128815
+ wrap$1.distRight = padding.right;
128720
128816
  }, normalizeColor = (value) => {
128721
128817
  if (typeof value !== "string")
128722
128818
  return;
@@ -130525,6 +130621,8 @@ var isRegExp = (value) => {
130525
130621
  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
130622
  }, buildDrawingBlock = (rawAttrs, nextBlockId, positions, node3, geometry, drawingKind, extraProps) => {
130527
130623
  const normalizedWrap = normalizeWrap$2(rawAttrs.wrap);
130624
+ if (normalizedWrap)
130625
+ mergeWrapDistancesFromPadding(normalizedWrap, toBoxSpacing(rawAttrs.padding));
130528
130626
  const sourceAnchor = isPlainObject3(rawAttrs.sourceAnchor) ? rawAttrs.sourceAnchor : undefined;
130529
130627
  const baseAnchor = normalizeAnchorData$1(rawAttrs.anchorData, rawAttrs, normalizedWrap?.behindDoc);
130530
130628
  const pos = positions.get(node3);
@@ -131579,7 +131677,7 @@ var isRegExp = (value) => {
131579
131677
  state.kern = kernNode.attributes["w:val"];
131580
131678
  }
131581
131679
  }, SuperConverter;
131582
- var init_SuperConverter_B9mZiCO9_es = __esm(() => {
131680
+ var init_SuperConverter_BSMYiYJm_es = __esm(() => {
131583
131681
  init_rolldown_runtime_Bg48TavK_es();
131584
131682
  init_jszip_C49i9kUs_es();
131585
131683
  init_xml_js_CqGKpaft_es();
@@ -170614,7 +170712,7 @@ var init_SuperConverter_B9mZiCO9_es = __esm(() => {
170614
170712
  };
170615
170713
  });
170616
170714
 
170617
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-pn-wKqsL.es.js
170715
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DeKyOdIi.es.js
170618
170716
  function parseSizeUnit(val = "0") {
170619
170717
  const length3 = val.toString() || "0";
170620
170718
  const value = Number.parseFloat(length3);
@@ -180947,8 +181045,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
180947
181045
  }
180948
181046
  };
180949
181047
  };
180950
- var init_create_headless_toolbar_pn_wKqsL_es = __esm(() => {
180951
- init_SuperConverter_B9mZiCO9_es();
181048
+ var init_create_headless_toolbar_DeKyOdIi_es = __esm(() => {
181049
+ init_SuperConverter_BSMYiYJm_es();
180952
181050
  init_uuid_qzgm05fK_es();
180953
181051
  init_constants_D_X7xF4s_es();
180954
181052
  init_dist_B8HfvhaK_es();
@@ -230111,7 +230209,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
230111
230209
  init_remark_gfm_BhnWr3yf_es();
230112
230210
  });
230113
230211
 
230114
- // ../../packages/superdoc/dist/chunks/src-B1aSE-tB.es.js
230212
+ // ../../packages/superdoc/dist/chunks/src-plIVvSkL.es.js
230115
230213
  function deleteProps(obj, propOrProps) {
230116
230214
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
230117
230215
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -270395,6 +270493,9 @@ function isSettled(status) {
270395
270493
  function normalizeFamilyKey$2(family$1) {
270396
270494
  return family$1.trim().replace(/^["']|["']$/g, "").toLowerCase();
270397
270495
  }
270496
+ function stripFamilyQuotes(family$1) {
270497
+ return family$1.trim().replace(/^["']|["']$/g, "");
270498
+ }
270398
270499
  function splitStack(cssFontFamily) {
270399
270500
  return cssFontFamily.split(",").map((part) => part.trim()).filter(Boolean);
270400
270501
  }
@@ -270407,8 +270508,8 @@ function resolveFontFamily2(logicalFamily) {
270407
270508
  function resolvePhysicalFamily(cssFontFamily) {
270408
270509
  return defaultResolver.resolvePhysicalFamily(cssFontFamily);
270409
270510
  }
270410
- function resolvePrimaryPhysicalFamily(family$1) {
270411
- return defaultResolver.resolvePrimaryPhysicalFamily(family$1);
270511
+ function resolveFace(logicalFamily, face, hasFace) {
270512
+ return defaultResolver.resolveFace(logicalFamily, face, hasFace);
270412
270513
  }
270413
270514
  function getFontConfigVersion() {
270414
270515
  return fontConfigVersion;
@@ -270518,6 +270619,40 @@ function buildFontReport(logicalFamilies, registry2, resolver2) {
270518
270619
  }
270519
270620
  return report;
270520
270621
  }
270622
+ function buildFaceReport(usedFaces, registry2, resolver2) {
270623
+ const hasFace = (family$1, weight, style2) => registry2.hasFace(family$1, weight, style2);
270624
+ const seen = /* @__PURE__ */ new Set;
270625
+ const report = [];
270626
+ for (const { logicalFamily, weight, style: style2 } of usedFaces) {
270627
+ if (!logicalFamily)
270628
+ continue;
270629
+ const key2 = `${logicalFamily.toLowerCase()}|${weight}|${style2}`;
270630
+ if (seen.has(key2))
270631
+ continue;
270632
+ seen.add(key2);
270633
+ const face = {
270634
+ weight,
270635
+ style: style2
270636
+ };
270637
+ const { physicalFamily, reason } = resolver2 ? resolver2.resolveFace(logicalFamily, face, hasFace) : resolveFace(logicalFamily, face, hasFace);
270638
+ const loadStatus = registry2.getFaceStatus({
270639
+ family: physicalFamily,
270640
+ weight,
270641
+ style: style2
270642
+ });
270643
+ const missing = reason === "fallback_face_absent" || isSettled(loadStatus) && loadStatus !== "loaded";
270644
+ report.push({
270645
+ logicalFamily,
270646
+ physicalFamily,
270647
+ reason,
270648
+ loadStatus,
270649
+ exportFamily: logicalFamily,
270650
+ missing,
270651
+ face
270652
+ });
270653
+ }
270654
+ return report;
270655
+ }
270521
270656
  function quoteFamily(family$1) {
270522
270657
  return `"${family$1.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
270523
270658
  }
@@ -271970,7 +272105,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
271970
272105
  let currentPageWidth = pageWidth;
271971
272106
  let marginLeft = Math.max(0, currentMargins?.left ?? 0);
271972
272107
  return {
271973
- registerDrawing(drawingBlock, measure, anchorY, columnIndex, pageNumber) {
272108
+ registerDrawing(drawingBlock, measure, resolvedAnchorY, columnIndex, pageNumber) {
271974
272109
  if (!drawingBlock.anchor?.isAnchored)
271975
272110
  return;
271976
272111
  const { wrap: wrap5, anchor } = drawingBlock;
@@ -271980,14 +272115,13 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
271980
272115
  const objectWidth = measure.width ?? 0;
271981
272116
  const objectHeight = measure.height ?? 0;
271982
272117
  const x = computeAnchorX(anchor, columnIndex, currentColumns, objectWidth, currentMargins, currentPageWidth);
271983
- const y$1 = anchorY + (anchor.offsetV ?? 0);
271984
272118
  const zone = {
271985
272119
  imageBlockId: drawingBlock.id,
271986
272120
  pageNumber,
271987
272121
  columnIndex,
271988
272122
  bounds: {
271989
272123
  x,
271990
- y: y$1,
272124
+ y: resolvedAnchorY,
271991
272125
  width: objectWidth,
271992
272126
  height: objectHeight
271993
272127
  },
@@ -272002,7 +272136,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
272002
272136
  };
272003
272137
  zones.push(zone);
272004
272138
  },
272005
- registerTable(tableBlock, measure, anchorY, columnIndex, pageNumber) {
272139
+ registerTable(tableBlock, measure, resolvedAnchorY, columnIndex, pageNumber) {
272006
272140
  if (!tableBlock.anchor?.isAnchored)
272007
272141
  return;
272008
272142
  const { wrap: wrap5, anchor } = tableBlock;
@@ -272011,14 +272145,13 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
272011
272145
  const tableWidth = measure.totalWidth ?? 0;
272012
272146
  const tableHeight = measure.totalHeight ?? 0;
272013
272147
  const x = computeTableAnchorX(anchor, columnIndex, currentColumns, tableWidth, currentMargins, currentPageWidth);
272014
- const y$1 = anchorY + (anchor.offsetV ?? 0);
272015
272148
  const zone = {
272016
272149
  imageBlockId: tableBlock.id,
272017
272150
  pageNumber,
272018
272151
  columnIndex,
272019
272152
  bounds: {
272020
272153
  x,
272021
- y: y$1,
272154
+ y: resolvedAnchorY,
272022
272155
  width: tableWidth,
272023
272156
  height: tableHeight
272024
272157
  },
@@ -272072,12 +272205,12 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
272072
272205
  rightFloats.push(zone);
272073
272206
  let leftBoundary = 0;
272074
272207
  for (const zone of leftFloats) {
272075
- const boundary = zone.bounds.x + zone.bounds.width + zone.distances.left + zone.distances.right;
272208
+ const boundary = zone.bounds.x + zone.bounds.width + zone.distances.right;
272076
272209
  leftBoundary = Math.max(leftBoundary, boundary);
272077
272210
  }
272078
272211
  let rightBoundary = columnOrigin + baseWidth;
272079
272212
  for (const zone of rightFloats) {
272080
- const boundary = zone.bounds.x - zone.distances.left - zone.distances.right;
272213
+ const boundary = zone.bounds.x - zone.distances.left;
272081
272214
  rightBoundary = Math.min(rightBoundary, boundary);
272082
272215
  }
272083
272216
  const availableWidth = rightBoundary - leftBoundary;
@@ -272107,27 +272240,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
272107
272240
  };
272108
272241
  }
272109
272242
  function computeAnchorX(anchor, columnIndex, columns, imageWidth, margins, pageWidth) {
272110
- const alignH = anchor.alignH ?? "left";
272111
- const offsetH = anchor.offsetH ?? 0;
272112
- const marginLeft = Math.max(0, margins?.left ?? 0);
272113
- const marginRight = Math.max(0, margins?.right ?? 0);
272114
- const contentWidth = pageWidth != null ? Math.max(1, pageWidth - (marginLeft + marginRight)) : columns.width;
272115
- const contentLeft = marginLeft;
272116
- const columnLeft = contentLeft + columnIndex * (columns.width + columns.gap);
272117
- const relativeFrom = anchor.hRelativeFrom ?? "column";
272118
- let baseX;
272119
- let availableWidth;
272120
- if (relativeFrom === "page") {
272121
- baseX = 0;
272122
- availableWidth = pageWidth != null ? pageWidth : contentWidth + marginLeft + marginRight;
272123
- } else if (relativeFrom === "margin") {
272124
- baseX = contentLeft;
272125
- availableWidth = contentWidth;
272126
- } else {
272127
- baseX = columnLeft;
272128
- availableWidth = columns.width;
272129
- }
272130
- return alignH === "left" ? baseX + offsetH : alignH === "right" ? baseX + availableWidth - imageWidth - offsetH : alignH === "center" ? baseX + (availableWidth - imageWidth) / 2 + offsetH : baseX;
272243
+ return resolveAnchoredGraphicX(anchor, columnIndex, columns, imageWidth, margins, pageWidth);
272131
272244
  }
272132
272245
  function computeWrapMode(wrap5, _anchor) {
272133
272246
  if (!wrap5)
@@ -272462,6 +272575,30 @@ function normalizeLines(measure) {
272462
272575
  function shouldSuppressOwnSpacing(ownStyleId, ownContextualSpacing, adjacentStyleId) {
272463
272576
  return ownContextualSpacing && !!ownStyleId && !!adjacentStyleId && ownStyleId === adjacentStyleId;
272464
272577
  }
272578
+ function collapseSpacingBefore(spacingBefore, trailingSpacing) {
272579
+ const prevTrailing = trailingSpacing ?? 0;
272580
+ return Math.max(spacingBefore - prevTrailing, 0);
272581
+ }
272582
+ function rewindPreviousParagraphTrailing(cursorY, trailingSpacing) {
272583
+ const prevTrailing = trailingSpacing ?? 0;
272584
+ return prevTrailing > 0 ? cursorY - prevTrailing : cursorY;
272585
+ }
272586
+ function computeParagraphContentStartY(cursorY, spacingBefore, appliedSpacingBefore, trailingSpacing) {
272587
+ if (appliedSpacingBefore || spacingBefore <= 0)
272588
+ return cursorY;
272589
+ return cursorY + collapseSpacingBefore(spacingBefore, trailingSpacing);
272590
+ }
272591
+ function computeParagraphLayoutStartY(input2) {
272592
+ let y$1 = input2.cursorY;
272593
+ let trailingForCollapse = input2.trailingSpacing;
272594
+ if (input2.rewindTrailingFromPrevious) {
272595
+ y$1 = rewindPreviousParagraphTrailing(y$1, input2.trailingSpacing);
272596
+ if ((input2.trailingSpacing ?? 0) > 0)
272597
+ trailingForCollapse = 0;
272598
+ }
272599
+ const effectiveSpacingBefore = input2.suppressSpacingBefore ? 0 : input2.spacingBefore;
272600
+ return computeParagraphContentStartY(y$1, effectiveSpacingBefore, effectiveSpacingBefore === 0, trailingForCollapse);
272601
+ }
272465
272602
  function calculateFirstLineIndent(block, measure) {
272466
272603
  const wordLayout = block.attrs?.wordLayout;
272467
272604
  if (!wordLayout?.firstLineIndentMode)
@@ -272477,52 +272614,75 @@ function layoutParagraphBlock(ctx$1, anchors) {
272477
272614
  const { block, measure, columnWidth, ensurePage, advanceColumn, columnX, floatManager } = ctx$1;
272478
272615
  const remeasureParagraph$1 = ctx$1.remeasureParagraph;
272479
272616
  const frame = getParagraphAttrs(block)?.frame;
272480
- if (anchors?.anchoredDrawings?.length)
272617
+ let lines = normalizeLines(measure);
272618
+ const measurementWidth = lines[0]?.maxWidth;
272619
+ const paraIndent = block.attrs?.indent;
272620
+ const indentLeft = typeof paraIndent?.left === "number" && Number.isFinite(paraIndent.left) ? paraIndent.left : 0;
272621
+ const indentRight = typeof paraIndent?.right === "number" && Number.isFinite(paraIndent.right) ? paraIndent.right : 0;
272622
+ const negativeLeftIndent = indentLeft < 0 ? indentLeft : 0;
272623
+ const negativeRightIndent = indentRight < 0 ? indentRight : 0;
272624
+ const remeasureWidth = Math.max(1, columnWidth - indentLeft - indentRight);
272625
+ let didRemeasureForColumnWidth = false;
272626
+ let remeasuredMarkerInfo;
272627
+ if (typeof remeasureParagraph$1 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
272628
+ const newMeasure = remeasureParagraph$1(block, columnWidth, calculateFirstLineIndent(block, measure));
272629
+ lines = normalizeLines(newMeasure);
272630
+ didRemeasureForColumnWidth = true;
272631
+ if (newMeasure.marker)
272632
+ remeasuredMarkerInfo = newMeasure.marker;
272633
+ }
272634
+ let fromLine = 0;
272635
+ const attrs = getParagraphAttrs(block);
272636
+ const spacing = attrs?.spacing ?? {};
272637
+ const spacingExplicit = attrs?.spacingExplicit;
272638
+ const styleId$1 = asString2(attrs?.styleId);
272639
+ const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
272640
+ let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
272641
+ let spacingAfter = ctx$1.overrideSpacingAfter ?? Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
272642
+ if (isEmptyTextParagraph(block) && spacingExplicit) {
272643
+ if (!spacingExplicit.before)
272644
+ spacingBefore = 0;
272645
+ if (!spacingExplicit.after)
272646
+ spacingAfter = 0;
272647
+ }
272648
+ const baseSpacingBefore = spacingBefore;
272649
+ let appliedSpacingBefore = spacingBefore === 0;
272650
+ let lastState = null;
272651
+ const previewState = ensurePage();
272652
+ const rawBorderExpansion = computeBorderVerticalExpansion(attrs?.borders);
272653
+ const currentBorderHash = hashBorders(attrs?.borders);
272654
+ const inBorderGroup = currentBorderHash != null && currentBorderHash === previewState.lastParagraphBorderHash;
272655
+ const borderExpansion = {
272656
+ top: inBorderGroup ? 0 : rawBorderExpansion.top,
272657
+ bottom: rawBorderExpansion.bottom
272658
+ };
272659
+ const paragraphAnchorBaseY = computeParagraphLayoutStartY({
272660
+ cursorY: previewState.cursorY,
272661
+ spacingBefore,
272662
+ trailingSpacing: previewState.trailingSpacing,
272663
+ suppressSpacingBefore: shouldSuppressOwnSpacing(styleId$1, contextualSpacing, previewState.lastParagraphStyleId),
272664
+ rewindTrailingFromPrevious: shouldSuppressOwnSpacing(previewState.lastParagraphStyleId, previewState.lastParagraphContextualSpacing, styleId$1)
272665
+ }) + borderExpansion.top - (inBorderGroup ? rawBorderExpansion.bottom : 0);
272666
+ const registerAnchoredDrawingsAt = (paragraphContentStartY) => {
272667
+ if (!anchors?.anchoredDrawings?.length)
272668
+ return;
272481
272669
  for (const entry of anchors.anchoredDrawings) {
272482
272670
  if (anchors.placedAnchoredIds.has(entry.block.id))
272483
272671
  continue;
272484
272672
  const state = ensurePage();
272485
- const vRelativeFrom = entry.block.anchor?.vRelativeFrom;
272486
- const alignV = entry.block.anchor?.alignV;
272487
- const offsetV = entry.block.anchor?.offsetV ?? 0;
272488
- const imageHeight = entry.measure.height;
272489
272673
  const contentTop = state.topMargin;
272490
272674
  const contentBottom = state.contentBottom;
272491
- const contentHeight = Math.max(0, contentBottom - contentTop);
272492
- let anchorY;
272493
- if (vRelativeFrom === "margin")
272494
- if (alignV === "top")
272495
- anchorY = contentTop + offsetV;
272496
- else if (alignV === "bottom")
272497
- anchorY = contentBottom - imageHeight + offsetV;
272498
- else if (alignV === "center")
272499
- anchorY = contentTop + (contentHeight - imageHeight) / 2 + offsetV;
272500
- else
272501
- anchorY = contentTop + offsetV;
272502
- else if (vRelativeFrom === "page")
272503
- if (alignV === "top")
272504
- anchorY = offsetV;
272505
- else if (alignV === "bottom")
272506
- anchorY = contentBottom + (anchors.pageMargins.bottom ?? 0) - imageHeight + offsetV;
272507
- else if (alignV === "center")
272508
- anchorY = (contentBottom + (anchors.pageMargins.bottom ?? 0) - imageHeight) / 2 + offsetV;
272509
- else
272510
- anchorY = offsetV;
272511
- else if (vRelativeFrom === "paragraph") {
272512
- const baseAnchorY = state.cursorY;
272513
- const firstLineHeight = measure.lines?.[0]?.lineHeight ?? 0;
272514
- if (alignV === "top")
272515
- anchorY = baseAnchorY + offsetV;
272516
- else if (alignV === "bottom")
272517
- anchorY = baseAnchorY + firstLineHeight - imageHeight + offsetV;
272518
- else if (alignV === "center")
272519
- anchorY = baseAnchorY + (firstLineHeight - imageHeight) / 2 + offsetV;
272520
- else
272521
- anchorY = baseAnchorY + offsetV;
272522
- } else
272523
- anchorY = state.cursorY + offsetV;
272675
+ const anchorY = resolveAnchoredGraphicY({
272676
+ anchor: entry.block.anchor,
272677
+ objectHeight: entry.measure.height,
272678
+ contentTop,
272679
+ contentBottom,
272680
+ pageBottomMargin: anchors.pageMargins.bottom ?? 0,
272681
+ anchorParagraphY: paragraphContentStartY,
272682
+ firstLineHeight: measure.lines?.[0]?.lineHeight ?? 0
272683
+ });
272524
272684
  floatManager.registerDrawing(entry.block, entry.measure, anchorY, state.columnIndex, state.page.number);
272525
- const anchorX = entry.block.anchor ? computeAnchorX(entry.block.anchor, state.columnIndex, anchors.columns, entry.measure.width, {
272685
+ const anchorX = entry.block.anchor ? resolveAnchoredGraphicX(entry.block.anchor, state.columnIndex, anchors.columns, entry.measure.width, {
272526
272686
  left: anchors.pageMargins.left,
272527
272687
  right: anchors.pageMargins.right
272528
272688
  }, anchors.pageWidth) : columnX(state.columnIndex);
@@ -272594,40 +272754,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
272594
272754
  }
272595
272755
  anchors.placedAnchoredIds.add(entry.block.id);
272596
272756
  }
272597
- let lines = normalizeLines(measure);
272598
- const measurementWidth = lines[0]?.maxWidth;
272599
- const paraIndent = block.attrs?.indent;
272600
- const indentLeft = typeof paraIndent?.left === "number" && Number.isFinite(paraIndent.left) ? paraIndent.left : 0;
272601
- const indentRight = typeof paraIndent?.right === "number" && Number.isFinite(paraIndent.right) ? paraIndent.right : 0;
272602
- const negativeLeftIndent = indentLeft < 0 ? indentLeft : 0;
272603
- const negativeRightIndent = indentRight < 0 ? indentRight : 0;
272604
- const remeasureWidth = Math.max(1, columnWidth - indentLeft - indentRight);
272605
- let didRemeasureForColumnWidth = false;
272606
- let remeasuredMarkerInfo;
272607
- if (typeof remeasureParagraph$1 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
272608
- const newMeasure = remeasureParagraph$1(block, columnWidth, calculateFirstLineIndent(block, measure));
272609
- lines = normalizeLines(newMeasure);
272610
- didRemeasureForColumnWidth = true;
272611
- if (newMeasure.marker)
272612
- remeasuredMarkerInfo = newMeasure.marker;
272613
- }
272614
- let fromLine = 0;
272615
- const attrs = getParagraphAttrs(block);
272616
- const spacing = attrs?.spacing ?? {};
272617
- const spacingExplicit = attrs?.spacingExplicit;
272618
- const styleId$1 = asString2(attrs?.styleId);
272619
- const contextualSpacing = asBoolean$1(attrs?.contextualSpacing);
272620
- let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
272621
- let spacingAfter = ctx$1.overrideSpacingAfter ?? Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
272622
- if (isEmptyTextParagraph(block) && spacingExplicit) {
272623
- if (!spacingExplicit.before)
272624
- spacingBefore = 0;
272625
- if (!spacingExplicit.after)
272626
- spacingAfter = 0;
272627
- }
272628
- const baseSpacingBefore = spacingBefore;
272629
- let appliedSpacingBefore = spacingBefore === 0;
272630
- let lastState = null;
272757
+ };
272758
+ registerAnchoredDrawingsAt(paragraphAnchorBaseY);
272631
272759
  if (frame?.wrap === "none") {
272632
272760
  let state = ensurePage();
272633
272761
  if (state.cursorY >= state.contentBottom)
@@ -272669,12 +272797,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
272669
272797
  let didRemeasureForFloats = false;
272670
272798
  if (typeof remeasureParagraph$1 === "function") {
272671
272799
  const tempState = ensurePage();
272672
- let tempY = tempState.cursorY;
272673
- if (!appliedSpacingBefore && spacingBefore > 0) {
272674
- const prevTrailing = tempState.trailingSpacing ?? 0;
272675
- const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
272676
- tempY += neededSpacingBefore;
272677
- }
272800
+ let tempY = paragraphAnchorBaseY;
272678
272801
  for (let i4 = 0;i4 < lines.length; i4++) {
272679
272802
  const lineY = tempY;
272680
272803
  const lineHeight = lines[i4]?.lineHeight || 0;
@@ -272685,8 +272808,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
272685
272808
  }
272686
272809
  tempY += lineHeight;
272687
272810
  }
272688
- const narrowestRemeasureWidth = Math.max(1, narrowestWidth - indentLeft - indentRight);
272689
- if (narrowestRemeasureWidth < remeasureWidth) {
272811
+ const narrowestRemeasureWidth = narrowestWidth < columnWidth || narrowestOffsetX > 0 ? Math.max(1, narrowestWidth - Math.max(indentLeft, 0) - Math.max(indentRight, 0)) : Math.max(1, narrowestWidth - indentLeft - indentRight);
272812
+ if (narrowestRemeasureWidth < remeasureWidth || narrowestOffsetX > 0) {
272690
272813
  const newMeasure = remeasureParagraph$1(block, narrowestRemeasureWidth, calculateFirstLineIndent(block, measure));
272691
272814
  lines = normalizeLines(newMeasure);
272692
272815
  didRemeasureForFloats = true;
@@ -272694,13 +272817,6 @@ function layoutParagraphBlock(ctx$1, anchors) {
272694
272817
  remeasuredMarkerInfo = newMeasure.marker;
272695
272818
  }
272696
272819
  }
272697
- const rawBorderExpansion = computeBorderVerticalExpansion(attrs?.borders);
272698
- const currentBorderHash = hashBorders(attrs?.borders);
272699
- const inBorderGroup = currentBorderHash != null && currentBorderHash === ensurePage().lastParagraphBorderHash;
272700
- const borderExpansion = {
272701
- top: inBorderGroup ? 0 : rawBorderExpansion.top,
272702
- bottom: rawBorderExpansion.bottom
272703
- };
272704
272820
  while (fromLine < lines.length) {
272705
272821
  let state = ensurePage();
272706
272822
  if (state.trailingSpacing == null)
@@ -272712,13 +272828,12 @@ function layoutParagraphBlock(ctx$1, anchors) {
272712
272828
  if (shouldSuppressOwnSpacing(state.lastParagraphStyleId, state.lastParagraphContextualSpacing, styleId$1)) {
272713
272829
  const prevTrailing = asSafeNumber(state.trailingSpacing);
272714
272830
  if (prevTrailing > 0) {
272715
- state.cursorY -= prevTrailing;
272831
+ state.cursorY = rewindPreviousParagraphTrailing(state.cursorY, prevTrailing);
272716
272832
  state.trailingSpacing = 0;
272717
272833
  }
272718
272834
  }
272719
272835
  if (attrs?.keepLines === true && fromLine === 0) {
272720
- const prevTrailing = state.trailingSpacing ?? 0;
272721
- const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
272836
+ const neededSpacingBefore = collapseSpacingBefore(spacingBefore, state.trailingSpacing);
272722
272837
  const pageContentHeight = state.contentBottom - state.topMargin;
272723
272838
  const fullHeight = lines.reduce((sum, line) => sum + (line.lineHeight || 0), 0) + borderExpansion.top + borderExpansion.bottom;
272724
272839
  const fitsOnBlankPage = fullHeight + baseSpacingBefore <= pageContentHeight;
@@ -272732,8 +272847,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
272732
272847
  }
272733
272848
  if (!appliedSpacingBefore && spacingBefore > 0)
272734
272849
  while (!appliedSpacingBefore) {
272735
- const prevTrailing = state.trailingSpacing ?? 0;
272736
- const neededSpacingBefore = Math.max(spacingBefore - prevTrailing, 0);
272850
+ state.trailingSpacing;
272851
+ const neededSpacingBefore = collapseSpacingBefore(spacingBefore, state.trailingSpacing);
272737
272852
  if (state.cursorY + neededSpacingBefore > state.contentBottom) {
272738
272853
  if (state.cursorY <= state.topMargin) {
272739
272854
  state.trailingSpacing = 0;
@@ -272855,8 +272970,12 @@ function layoutParagraphBlock(ctx$1, anchors) {
272855
272970
  state.footnoteAnchorsThisPage.push(a2);
272856
272971
  }
272857
272972
  }
272858
- const adjustedX = columnX(state.columnIndex) + offsetX + negativeLeftIndent;
272859
- const adjustedWidth = effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
272973
+ const floatAdjustedX = columnX(state.columnIndex) + offsetX;
272974
+ const adjustedX = didRemeasureForFloats ? floatAdjustedX + Math.max(negativeLeftIndent, 0) : floatAdjustedX + negativeLeftIndent;
272975
+ const columnRight = columnX(state.columnIndex) + columnWidth;
272976
+ let adjustedWidth = didRemeasureForFloats ? effectiveColumnWidth : effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
272977
+ if (didRemeasureForFloats)
272978
+ adjustedWidth = Math.min(adjustedWidth, Math.max(1, columnRight - adjustedX));
272860
272979
  const fragment2 = {
272861
272980
  kind: "para",
272862
272981
  blockId: block.id,
@@ -272868,7 +272987,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
272868
272987
  sourceAnchor: block.sourceAnchor,
272869
272988
  ...computeFragmentPmRange2(block, lines, fromLine, slice2.toLine)
272870
272989
  };
272871
- if (didRemeasureForColumnWidth)
272990
+ if (didRemeasureForColumnWidth || didRemeasureForFloats)
272872
272991
  fragment2.lines = lines.slice(fromLine, slice2.toLine);
272873
272992
  if ((measure.marker || remeasuredMarkerInfo) && fromLine === 0) {
272874
272993
  fragment2.markerWidth = (remeasuredMarkerInfo ?? measure.marker)?.markerWidth ?? measure.marker?.markerWidth ?? 0;
@@ -274719,13 +274838,19 @@ function getBalancingHeight(fragment2, measureMap, sectPrMarkerBlockIds) {
274719
274838
  return 0;
274720
274839
  return getFragmentHeight(fragment2, measureMap);
274721
274840
  }
274841
+ function allColumnWidthsEqual(widths) {
274842
+ if (widths.length <= 1)
274843
+ return true;
274844
+ const first$1 = widths[0];
274845
+ return widths.every((w) => Math.abs(w - first$1) <= 0.5);
274846
+ }
274722
274847
  function balanceSectionOnPage(args$1) {
274723
274848
  const { sectionColumns, sectionHasExplicitColumnBreak, sectionIndex, blockSectionMap, fragments } = args$1;
274724
274849
  if (sectionColumns.count <= 1)
274725
274850
  return null;
274726
274851
  if (sectionHasExplicitColumnBreak)
274727
274852
  return null;
274728
- if (sectionColumns.equalWidth === false && Array.isArray(sectionColumns.widths) && sectionColumns.widths.length > 0)
274853
+ if (sectionColumns.equalWidth === false && Array.isArray(sectionColumns.widths) && sectionColumns.widths.length > 0 && !allColumnWidthsEqual(sectionColumns.widths))
274729
274854
  return null;
274730
274855
  const sectionFragments = fragments.filter((f2) => blockSectionMap.get(f2.blockId) === sectionIndex);
274731
274856
  if (sectionFragments.length === 0)
@@ -275978,58 +276103,28 @@ function layoutDocument(blocks2, measures, options = {}) {
275978
276103
  const resolveParagraphlessAnchoredTableY = (block, measure, state) => {
275979
276104
  const contentTop = state.topMargin;
275980
276105
  const contentBottom = state.contentBottom;
275981
- const contentHeight = Math.max(0, contentBottom - contentTop);
275982
276106
  const tableHeight = measure.totalHeight ?? 0;
275983
- const anchor = block.anchor;
275984
- const offsetV = anchor?.offsetV ?? 0;
275985
- const vRelativeFrom = anchor?.vRelativeFrom;
275986
- const alignV = anchor?.alignV;
275987
- if (vRelativeFrom === "margin") {
275988
- if (alignV === "bottom")
275989
- return contentBottom - tableHeight + offsetV;
275990
- if (alignV === "center")
275991
- return contentTop + (contentHeight - tableHeight) / 2 + offsetV;
275992
- return contentTop + offsetV;
275993
- }
275994
- if (vRelativeFrom === "page") {
275995
- if (alignV === "bottom")
275996
- return contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - tableHeight + offsetV;
275997
- if (alignV === "center")
275998
- return (contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - tableHeight) / 2 + offsetV;
275999
- return offsetV;
276000
- }
276001
- return contentTop + offsetV;
276107
+ return resolveAnchoredGraphicY({
276108
+ anchor: block.anchor,
276109
+ objectHeight: tableHeight,
276110
+ contentTop,
276111
+ contentBottom,
276112
+ pageBottomMargin: state.page.margins?.bottom ?? activeBottomMargin,
276113
+ preRegisteredFallbackToContentTop: true
276114
+ });
276002
276115
  };
276003
276116
  for (const entry of preRegisteredAnchors) {
276004
276117
  const state = paginator.ensurePage();
276005
- const vRelativeFrom = entry.block.anchor?.vRelativeFrom ?? "paragraph";
276006
- const alignV = entry.block.anchor?.alignV ?? "top";
276007
- const offsetV = entry.block.anchor?.offsetV ?? 0;
276008
- const imageHeight = entry.measure.height ?? 0;
276009
276118
  const contentTop = state.topMargin;
276010
276119
  const contentBottom = state.contentBottom;
276011
- const contentHeight = Math.max(0, contentBottom - contentTop);
276012
- let anchorY;
276013
- if (vRelativeFrom === "margin")
276014
- if (alignV === "top")
276015
- anchorY = contentTop + offsetV;
276016
- else if (alignV === "bottom")
276017
- anchorY = contentBottom - imageHeight + offsetV;
276018
- else if (alignV === "center")
276019
- anchorY = contentTop + (contentHeight - imageHeight) / 2 + offsetV;
276020
- else
276021
- anchorY = contentTop + offsetV;
276022
- else if (vRelativeFrom === "page")
276023
- if (alignV === "top")
276024
- anchorY = offsetV;
276025
- else if (alignV === "bottom")
276026
- anchorY = contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - imageHeight + offsetV;
276027
- else if (alignV === "center")
276028
- anchorY = (contentBottom + (state.page.margins?.bottom ?? activeBottomMargin) - imageHeight) / 2 + offsetV;
276029
- else
276030
- anchorY = offsetV;
276031
- else
276032
- anchorY = contentTop + offsetV;
276120
+ const anchorY = resolveAnchoredGraphicY({
276121
+ anchor: entry.block.anchor,
276122
+ objectHeight: entry.measure.height ?? 0,
276123
+ contentTop,
276124
+ contentBottom,
276125
+ pageBottomMargin: state.page.margins?.bottom ?? activeBottomMargin,
276126
+ preRegisteredFallbackToContentTop: true
276127
+ });
276033
276128
  const anchorX = entry.block.anchor ? computeAnchorX(entry.block.anchor, state.columnIndex, normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)), entry.measure.width, {
276034
276129
  left: activeLeftMargin,
276035
276130
  right: activeRightMargin
@@ -276340,7 +276435,6 @@ function layoutDocument(blocks2, measures, options = {}) {
276340
276435
  overrideSpacingAfter = 0;
276341
276436
  }
276342
276437
  }
276343
- const paragraphStartY = paginator.ensurePage().cursorY;
276344
276438
  layoutParagraphBlock({
276345
276439
  block,
276346
276440
  measure,
@@ -276370,7 +276464,12 @@ function layoutDocument(blocks2, measures, options = {}) {
276370
276464
  if (tablesForPara) {
276371
276465
  const state = paginator.ensurePage();
276372
276466
  const columnWidthForTable = getCurrentColumnWidth();
276467
+ let anchorParagraphTopY = state.cursorY;
276468
+ for (const fragment2 of state.page.fragments)
276469
+ if (fragment2.kind === "para" && fragment2.blockId === block.id)
276470
+ anchorParagraphTopY = Math.min(anchorParagraphTopY, fragment2.y);
276373
276471
  let tableBottomY = state.cursorY;
276472
+ let nextStackY = state.cursorY;
276374
276473
  for (const { block: tableBlock, measure: tableMeasure } of tablesForPara) {
276375
276474
  if (placedAnchoredTableIds.has(tableBlock.id))
276376
276475
  continue;
@@ -276378,15 +276477,17 @@ function layoutDocument(blocks2, measures, options = {}) {
276378
276477
  if (columnWidthForTable > 0 && totalWidth >= columnWidthForTable * 0.99)
276379
276478
  continue;
276380
276479
  const offsetV = tableBlock.anchor?.offsetV ?? 0;
276381
- const anchorY = Math.max(paragraphStartY, state.cursorY) + offsetV;
276480
+ const anchorY = Math.max(anchorParagraphTopY, nextStackY) + offsetV;
276382
276481
  floatManager.registerTable(tableBlock, tableMeasure, anchorY, state.columnIndex, state.page.number);
276383
276482
  const tableFragment = createAnchoredTableFragment(tableBlock, tableMeasure, tableBlock.anchor?.offsetH ?? columnX(state.columnIndex), anchorY);
276384
276483
  state.page.fragments.push(tableFragment);
276385
276484
  placedAnchoredTableIds.add(tableBlock.id);
276386
276485
  if ((tableBlock.wrap?.type ?? "None") !== "None") {
276387
276486
  const bottom$1 = anchorY + (tableMeasure.totalHeight ?? 0);
276487
+ const distBottom = tableBlock.wrap?.distBottom ?? 0;
276388
276488
  if (bottom$1 > tableBottomY)
276389
276489
  tableBottomY = bottom$1;
276490
+ nextStackY = bottom$1 + distBottom;
276390
276491
  }
276391
276492
  }
276392
276493
  state.cursorY = tableBottomY;
@@ -286067,7 +286168,11 @@ function buildFontString$1(run2, fontContext) {
286067
286168
  if (run2.bold)
286068
286169
  parts.push("bold");
286069
286170
  parts.push(`${normalizeFontSize$1(run2.fontSize)}px`);
286070
- const physicalFamily = normalizeFontFamily$1(fontContext.resolvePhysical(normalizeFontFamily$1(run2.fontFamily)));
286171
+ const face = {
286172
+ weight: run2.bold ? "700" : "400",
286173
+ style: run2.italic ? "italic" : "normal"
286174
+ };
286175
+ const physicalFamily = normalizeFontFamily$1(fontContext.resolvePhysical(normalizeFontFamily$1(run2.fontFamily), face));
286071
286176
  parts.push(toCssFontFamily(physicalFamily) ?? physicalFamily);
286072
286177
  return parts.join(" ");
286073
286178
  }
@@ -286174,6 +286279,12 @@ function getCanvasContext() {
286174
286279
  }
286175
286280
  return canvasContext;
286176
286281
  }
286282
+ function faceOf(run2) {
286283
+ return {
286284
+ weight: run2.bold ? "700" : "400",
286285
+ style: run2.italic ? "italic" : "normal"
286286
+ };
286287
+ }
286177
286288
  function buildFontString(run2, fontContext) {
286178
286289
  const parts = [];
286179
286290
  if (run2.italic)
@@ -286181,7 +286292,7 @@ function buildFontString(run2, fontContext) {
286181
286292
  if (run2.bold)
286182
286293
  parts.push("bold");
286183
286294
  parts.push(`${run2.fontSize}px`);
286184
- const physicalFamily = fontContext.resolvePhysical(run2.fontFamily);
286295
+ const physicalFamily = fontContext.resolvePhysical(run2.fontFamily, faceOf(run2));
286185
286296
  if (measurementConfig.mode === "deterministic")
286186
286297
  parts.push(measurementConfig.fonts.fallbackStack.length > 0 ? measurementConfig.fonts.fallbackStack.join(", ") : measurementConfig.fonts.deterministicFamily);
286187
286298
  else
@@ -286248,7 +286359,7 @@ function lineHeightFontSize(run2) {
286248
286359
  }
286249
286360
  function getFontInfoFromRun(run2, fontContext) {
286250
286361
  return {
286251
- fontFamily: normalizeFontFamily(fontContext.resolvePhysical(run2.fontFamily)),
286362
+ fontFamily: normalizeFontFamily(fontContext.resolvePhysical(run2.fontFamily, faceOf(run2))),
286252
286363
  fontSize: normalizeFontSize2(lineHeightFontSize(run2)),
286253
286364
  bold: run2.bold,
286254
286365
  italic: run2.italic
@@ -287051,7 +287162,7 @@ async function measureParagraphBlock(block, maxWidth, fontContext) {
287051
287162
  if (isFieldAnnotationRun(run2)) {
287052
287163
  const displayText = applyTextTransform(run2.displayLabel || "", run2);
287053
287164
  const annotationFontSize = typeof run2.fontSize === "number" ? run2.fontSize : typeof run2.fontSize === "string" ? parseFloat(run2.fontSize) || DEFAULT_FIELD_ANNOTATION_FONT_SIZE : DEFAULT_FIELD_ANNOTATION_FONT_SIZE;
287054
- const annotationFontFamily = fontContext.resolvePhysical(run2.fontFamily || "Arial, sans-serif");
287165
+ const annotationFontFamily = fontContext.resolvePhysical(run2.fontFamily || "Arial, sans-serif", faceOf(run2));
287055
287166
  const fontWeight = run2.bold ? "bold" : "normal";
287056
287167
  ctx$1.font = `${run2.italic ? "italic" : "normal"} ${fontWeight} ${annotationFontSize}px ${annotationFontFamily}`;
287057
287168
  const textWidth = displayText ? ctx$1.measureText(displayText).width : 0;
@@ -288109,7 +288220,7 @@ async function measureListBlock(block, constraints, fontContext) {
288109
288220
  totalHeight
288110
288221
  };
288111
288222
  }
288112
- async function layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetadata, deps, fontResolver) {
288223
+ async function layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetadata, deps, fontResolver, hasFace, effectiveSignature) {
288113
288224
  deps.headerLayoutsByRId.clear();
288114
288225
  deps.footerLayoutsByRId.clear();
288115
288226
  if (!headerFooterInput)
@@ -288132,21 +288243,21 @@ async function layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetad
288132
288243
  };
288133
288244
  };
288134
288245
  if (sectionMetadata.length > 1 && sectionMetadata.some((s2) => s2.margins || s2.pageSize)) {
288135
- await layoutWithPerSectionConstraints("header", headerBlocksByRId, sectionMetadata, constraints, pageResolver, deps.headerLayoutsByRId, fontResolver);
288136
- await layoutWithPerSectionConstraints("footer", footerBlocksByRId, sectionMetadata, constraints, pageResolver, deps.footerLayoutsByRId, fontResolver);
288246
+ await layoutWithPerSectionConstraints("header", headerBlocksByRId, sectionMetadata, constraints, pageResolver, deps.headerLayoutsByRId, fontResolver, hasFace, effectiveSignature);
288247
+ await layoutWithPerSectionConstraints("footer", footerBlocksByRId, sectionMetadata, constraints, pageResolver, deps.footerLayoutsByRId, fontResolver, hasFace, effectiveSignature);
288137
288248
  } else {
288138
288249
  const effectiveHeaderRefsBySection = buildEffectiveHeaderFooterRefsBySection(sectionMetadata, "header");
288139
288250
  const effectiveFooterRefsBySection = buildEffectiveHeaderFooterRefsBySection(sectionMetadata, "footer");
288140
- await layoutBlocksByRId("header", headerBlocksByRId, collectReferencedHeaderFooterRIds(effectiveHeaderRefsBySection), constraints, pageResolver, deps.headerLayoutsByRId, fontResolver);
288141
- await layoutBlocksByRId("footer", footerBlocksByRId, collectReferencedHeaderFooterRIds(effectiveFooterRefsBySection), constraints, pageResolver, deps.footerLayoutsByRId, fontResolver);
288251
+ await layoutBlocksByRId("header", headerBlocksByRId, collectReferencedHeaderFooterRIds(effectiveHeaderRefsBySection), constraints, pageResolver, deps.headerLayoutsByRId, fontResolver, hasFace, effectiveSignature);
288252
+ await layoutBlocksByRId("footer", footerBlocksByRId, collectReferencedHeaderFooterRIds(effectiveFooterRefsBySection), constraints, pageResolver, deps.footerLayoutsByRId, fontResolver, hasFace, effectiveSignature);
288142
288253
  }
288143
288254
  }
288144
- async function layoutBlocksByRId(kind, blocksByRId, referencedRIds, constraints, pageResolver, layoutsByRId, fontResolver) {
288255
+ async function layoutBlocksByRId(kind, blocksByRId, referencedRIds, constraints, pageResolver, layoutsByRId, fontResolver, hasFace, effectiveSignature) {
288145
288256
  if (!blocksByRId || referencedRIds.size === 0)
288146
288257
  return;
288147
- const fontSignature = fontResolver?.signature ?? "";
288258
+ const fontSignature = effectiveSignature ?? "";
288148
288259
  const fontMeasureContext = fontResolver ? {
288149
- resolvePhysical: (css) => fontResolver.resolvePhysicalFamily(css),
288260
+ resolvePhysical: (css, face) => hasFace ? fontResolver.resolvePhysicalFamilyForFace(css, face, hasFace) : fontResolver.resolvePhysicalFamily(css),
288150
288261
  fontSignature
288151
288262
  } : undefined;
288152
288263
  for (const [rId, blocks2] of blocksByRId) {
@@ -288201,12 +288312,12 @@ function adjustFramePositionsForContentWidth(layout, blocks2, effectiveWidth, co
288201
288312
  fragment2.x -= widthDiff / 2;
288202
288313
  }
288203
288314
  }
288204
- async function layoutWithPerSectionConstraints(kind, blocksByRId, sectionMetadata, fallbackConstraints, pageResolver, layoutsByRId, fontResolver) {
288315
+ async function layoutWithPerSectionConstraints(kind, blocksByRId, sectionMetadata, fallbackConstraints, pageResolver, layoutsByRId, fontResolver, hasFace, effectiveSignature) {
288205
288316
  if (!blocksByRId)
288206
288317
  return;
288207
- const fontSignature = fontResolver?.signature ?? "";
288318
+ const fontSignature = effectiveSignature ?? "";
288208
288319
  const fontMeasureContext = fontResolver ? {
288209
- resolvePhysical: (css) => fontResolver.resolvePhysicalFamily(css),
288320
+ resolvePhysical: (css, face) => hasFace ? fontResolver.resolvePhysicalFamilyForFace(css, face, hasFace) : fontResolver.resolvePhysicalFamily(css),
288210
288321
  fontSignature
288211
288322
  } : undefined;
288212
288323
  const groups = buildSectionAwareHeaderFooterMeasurementGroups(kind, blocksByRId, sectionMetadata, fallbackConstraints);
@@ -288875,80 +288986,136 @@ function defaultScheduleMicrotask(callback) {
288875
288986
  }
288876
288987
  Promise.resolve().then(callback);
288877
288988
  }
288878
- function faceKey(req) {
288879
- return `${req.family.toLowerCase()}|${req.weight}|${req.style}`;
288989
+ function primaryFamily(css) {
288990
+ const comma = css.indexOf(",");
288991
+ return (comma === -1 ? css : css.slice(0, comma)).trim().replace(/^["']|["']$/g, "");
288880
288992
  }
288881
- function collect(out, node3, resolve3) {
288993
+ function makeResolveFace(resolver2, hasFace) {
288994
+ if (resolver2 && hasFace)
288995
+ return (logical, face) => {
288996
+ const r$1 = resolver2.resolveFace(logical, face, hasFace);
288997
+ return {
288998
+ physicalFamily: r$1.physicalFamily,
288999
+ reason: r$1.reason
289000
+ };
289001
+ };
289002
+ if (resolver2)
289003
+ return (logical) => {
289004
+ const r$1 = resolver2.resolveFontFamily(logical);
289005
+ return {
289006
+ physicalFamily: r$1.physicalFamily,
289007
+ reason: r$1.reason
289008
+ };
289009
+ };
289010
+ return (logical) => {
289011
+ const r$1 = resolveFontFamily2(logical);
289012
+ return {
289013
+ physicalFamily: r$1.physicalFamily,
289014
+ reason: r$1.reason
289015
+ };
289016
+ };
289017
+ }
289018
+ function collect(acc, node3, resolveFace$1) {
288882
289019
  if (!node3 || typeof node3.fontFamily !== "string" || !node3.fontFamily)
288883
289020
  return;
288884
- const family$1 = resolve3(node3.fontFamily);
288885
- if (!family$1)
289021
+ const weight = node3.bold === true ? "700" : "400";
289022
+ const style2 = node3.italic === true ? "italic" : "normal";
289023
+ const logicalPrimary = primaryFamily(node3.fontFamily);
289024
+ if (!logicalPrimary)
288886
289025
  return;
288887
- const req = {
288888
- family: family$1,
288889
- weight: node3.bold === true ? "700" : "400",
288890
- style: node3.italic === true ? "italic" : "normal"
288891
- };
288892
- const key2 = faceKey(req);
288893
- if (!out.has(key2))
288894
- out.set(key2, req);
289026
+ const usedKey = `${logicalPrimary.toLowerCase()}|${weight}|${style2}`;
289027
+ if (acc.usedFaces.has(usedKey))
289028
+ return;
289029
+ const { physicalFamily, reason } = resolveFace$1(node3.fontFamily, {
289030
+ weight,
289031
+ style: style2
289032
+ });
289033
+ acc.usedFaces.set(usedKey, {
289034
+ logicalFamily: logicalPrimary,
289035
+ weight,
289036
+ style: style2
289037
+ });
289038
+ acc.sigEntries.set(usedKey, [
289039
+ logicalPrimary.toLowerCase(),
289040
+ weight,
289041
+ style2,
289042
+ (physicalFamily || "").toLowerCase(),
289043
+ reason
289044
+ ]);
289045
+ if (physicalFamily) {
289046
+ const reqKey = `${physicalFamily.toLowerCase()}|${weight}|${style2}`;
289047
+ if (!acc.requiredFaces.has(reqKey))
289048
+ acc.requiredFaces.set(reqKey, {
289049
+ family: physicalFamily,
289050
+ weight,
289051
+ style: style2
289052
+ });
289053
+ }
288895
289054
  }
288896
- function collectRuns(out, runs2, resolve3) {
289055
+ function collectRuns(acc, runs2, resolveFace$1) {
288897
289056
  if (!runs2)
288898
289057
  return;
288899
289058
  for (const run2 of runs2) {
288900
289059
  const bearing = run2;
288901
289060
  if (run2.kind === "fieldAnnotation" && (typeof bearing.fontFamily !== "string" || !bearing.fontFamily))
288902
- collect(out, {
289061
+ collect(acc, {
288903
289062
  ...bearing,
288904
289063
  fontFamily: "Arial"
288905
- }, resolve3);
289064
+ }, resolveFace$1);
288906
289065
  else
288907
- collect(out, bearing, resolve3);
289066
+ collect(acc, bearing, resolveFace$1);
288908
289067
  }
288909
289068
  }
288910
- function collectParagraph(out, paragraph2, resolve3) {
289069
+ function collectParagraph(acc, paragraph2, resolveFace$1) {
288911
289070
  if (!paragraph2)
288912
289071
  return;
288913
- collectRuns(out, paragraph2.runs, resolve3);
288914
- collect(out, paragraph2.attrs?.wordLayout?.marker?.run, resolve3);
288915
- collect(out, paragraph2.attrs?.dropCapDescriptor?.run, resolve3);
289072
+ collectRuns(acc, paragraph2.runs, resolveFace$1);
289073
+ collect(acc, paragraph2.attrs?.wordLayout?.marker?.run, resolveFace$1);
289074
+ collect(acc, paragraph2.attrs?.dropCapDescriptor?.run, resolveFace$1);
288916
289075
  }
288917
- function collectTable(out, table2, resolve3) {
289076
+ function collectTable(acc, table2, resolveFace$1) {
288918
289077
  for (const row2 of table2.rows)
288919
289078
  for (const cell2 of row2.cells) {
288920
- collectParagraph(out, cell2.paragraph, resolve3);
289079
+ collectParagraph(acc, cell2.paragraph, resolveFace$1);
288921
289080
  if (cell2.blocks)
288922
289081
  for (const b$1 of cell2.blocks)
288923
- collectBlock(out, b$1, resolve3);
289082
+ collectBlock(acc, b$1, resolveFace$1);
288924
289083
  }
288925
289084
  }
288926
- function collectList(out, list5, resolve3) {
289085
+ function collectList(acc, list5, resolveFace$1) {
288927
289086
  for (const item of list5.items)
288928
- collectParagraph(out, item.paragraph, resolve3);
289087
+ collectParagraph(acc, item.paragraph, resolveFace$1);
288929
289088
  }
288930
- function collectBlock(out, block, resolve3) {
289089
+ function collectBlock(acc, block, resolveFace$1) {
288931
289090
  switch (block.kind) {
288932
289091
  case "paragraph":
288933
- collectParagraph(out, block, resolve3);
289092
+ collectParagraph(acc, block, resolveFace$1);
288934
289093
  break;
288935
289094
  case "table":
288936
- collectTable(out, block, resolve3);
289095
+ collectTable(acc, block, resolveFace$1);
288937
289096
  break;
288938
289097
  case "list":
288939
- collectList(out, block, resolve3);
289098
+ collectList(acc, block, resolveFace$1);
288940
289099
  break;
288941
289100
  default:
288942
289101
  break;
288943
289102
  }
288944
289103
  }
288945
- function planRequiredFontFaces(blocks2, resolver2) {
288946
- const resolve3 = resolver2 ? (family$1) => resolver2.resolvePrimaryPhysicalFamily(family$1) : resolvePrimaryPhysicalFamily;
288947
- const out = /* @__PURE__ */ new Map;
289104
+ function planFontFaces(blocks2, resolver2, hasFace) {
289105
+ const resolveFace$1 = makeResolveFace(resolver2, hasFace);
289106
+ const acc = {
289107
+ requiredFaces: /* @__PURE__ */ new Map,
289108
+ usedFaces: /* @__PURE__ */ new Map,
289109
+ sigEntries: /* @__PURE__ */ new Map
289110
+ };
288948
289111
  if (blocks2)
288949
289112
  for (const block of blocks2)
288950
- collectBlock(out, block, resolve3);
288951
- return [...out.values()];
289113
+ collectBlock(acc, block, resolveFace$1);
289114
+ return {
289115
+ requiredFaces: [...acc.requiredFaces.values()],
289116
+ usedFaces: [...acc.usedFaces.values()],
289117
+ effectiveSignature: acc.sigEntries.size === 0 ? "" : JSON.stringify([...acc.sigEntries.entries()].sort(([a2], [b$1]) => a2 < b$1 ? -1 : a2 > b$1 ? 1 : 0).map(([, tuple]) => tuple))
289118
+ };
288952
289119
  }
288953
289120
  function buildSemanticFootnoteBlocks(input2, footnotesMode) {
288954
289121
  if (!input2 || input2.refs.length === 0 || input2.blocksById.size === 0)
@@ -310039,7 +310206,7 @@ menclose::after {
310039
310206
  return;
310040
310207
  if (this.#overrides.get(key2) === physical)
310041
310208
  return;
310042
- if ((BUNDLED_SUBSTITUTES[key2] ?? logicalFamily.trim()) === physical) {
310209
+ if (key2 === normalizeFamilyKey$2(physical)) {
310043
310210
  if (this.#overrides.delete(key2)) {
310044
310211
  this.#version += 1;
310045
310212
  this.#cachedSignature = null;
@@ -310091,12 +310258,41 @@ menclose::after {
310091
310258
  reason: "as_requested"
310092
310259
  };
310093
310260
  }
310261
+ #resolveFaceLadder(primary, face, hasFace) {
310262
+ const key2 = normalizeFamilyKey$2(primary);
310263
+ const override = this.#overrides.get(key2);
310264
+ if (override && hasFace(override, face.weight, face.style))
310265
+ return {
310266
+ physical: override,
310267
+ reason: "custom_mapping"
310268
+ };
310269
+ if (hasFace(primary, face.weight, face.style))
310270
+ return {
310271
+ physical: primary,
310272
+ reason: "registered_face"
310273
+ };
310274
+ const bundled = BUNDLED_SUBSTITUTES[key2];
310275
+ if (bundled && hasFace(bundled, face.weight, face.style))
310276
+ return {
310277
+ physical: bundled,
310278
+ reason: "bundled_substitute"
310279
+ };
310280
+ if (override || bundled)
310281
+ return {
310282
+ physical: primary,
310283
+ reason: "fallback_face_absent"
310284
+ };
310285
+ return {
310286
+ physical: primary,
310287
+ reason: "as_requested"
310288
+ };
310289
+ }
310094
310290
  resolveFontFamily(logicalFamily) {
310095
310291
  const primary = splitStack(logicalFamily)[0] ?? logicalFamily;
310096
310292
  const { physical, reason } = this.#physicalFor(primary);
310097
310293
  return {
310098
310294
  logicalFamily,
310099
- physicalFamily: physical,
310295
+ physicalFamily: stripFamilyQuotes(physical),
310100
310296
  reason
310101
310297
  };
310102
310298
  }
@@ -310111,6 +310307,26 @@ menclose::after {
310111
310307
  return cssFontFamily;
310112
310308
  return [physical, ...parts.slice(1)].join(", ");
310113
310309
  }
310310
+ resolveFace(logicalFamily, face, hasFace) {
310311
+ const primary = splitStack(logicalFamily)[0] ?? logicalFamily;
310312
+ const { physical, reason } = this.#resolveFaceLadder(primary, face, hasFace);
310313
+ return {
310314
+ logicalFamily,
310315
+ physicalFamily: stripFamilyQuotes(physical),
310316
+ reason
310317
+ };
310318
+ }
310319
+ resolvePhysicalFamilyForFace(cssFontFamily, face, hasFace) {
310320
+ if (!cssFontFamily)
310321
+ return cssFontFamily;
310322
+ const parts = splitStack(cssFontFamily);
310323
+ if (parts.length === 0)
310324
+ return cssFontFamily;
310325
+ const { physical, reason } = this.#resolveFaceLadder(parts[0], face, hasFace);
310326
+ if (reason === "custom_mapping" || reason === "bundled_substitute")
310327
+ return [physical, ...parts.slice(1)].join(", ");
310328
+ return cssFontFamily;
310329
+ }
310114
310330
  resolvePrimaryPhysicalFamily(family$1) {
310115
310331
  const primary = splitStack(family$1)[0] ?? family$1;
310116
310332
  return this.#physicalFor(primary).physical;
@@ -310137,6 +310353,7 @@ menclose::after {
310137
310353
  #faceInflight = /* @__PURE__ */ new Map;
310138
310354
  #faceSources = /* @__PURE__ */ new Map;
310139
310355
  #facesByFamily = /* @__PURE__ */ new Map;
310356
+ #providerFaceKeys = /* @__PURE__ */ new Set;
310140
310357
  #warnedFaceFailures = /* @__PURE__ */ new Set;
310141
310358
  constructor(options = {}) {
310142
310359
  this.#fontSet = options.fontSet ?? null;
@@ -310148,7 +310365,9 @@ menclose::after {
310148
310365
  register(descriptor) {
310149
310366
  const { family: family$1, source, descriptors: descriptors2 } = descriptor;
310150
310367
  const identitySource = typeof source === "string" ? canonicalizeFontSource(source) : source;
310151
- const key2 = faceKeyOf$1(family$1, normalizeWeight(descriptors2?.weight), normalizeStyle$1(descriptors2?.style));
310368
+ const weight = normalizeWeight(descriptors2?.weight);
310369
+ const style2 = normalizeStyle$1(descriptors2?.style);
310370
+ const key2 = faceKeyOf$1(family$1, weight, style2);
310152
310371
  if (typeof identitySource === "string") {
310153
310372
  const existingSource = this.#faceSources.get(key2);
310154
310373
  if (existingSource === identitySource)
@@ -310161,7 +310380,11 @@ menclose::after {
310161
310380
  throw new Error(`[superdoc] font face "${key2}" is already registered from a different source ("${existingSource}"); a registered face's source cannot be replaced`);
310162
310381
  }
310163
310382
  if (this.#FontFaceCtor && this.#fontSet) {
310164
- const face = new this.#FontFaceCtor(family$1, source, descriptors2);
310383
+ const face = new this.#FontFaceCtor(family$1, source, {
310384
+ ...descriptors2,
310385
+ weight,
310386
+ style: style2
310387
+ });
310165
310388
  this.#fontSet.add(face);
310166
310389
  this.#managed.set(family$1, face);
310167
310390
  }
@@ -310173,6 +310396,7 @@ menclose::after {
310173
310396
  }
310174
310397
  if (!this.#status.has(family$1))
310175
310398
  this.#status.set(family$1, "unloaded");
310399
+ this.#providerFaceKeys.add(key2);
310176
310400
  this.#trackFace(family$1, key2);
310177
310401
  if (!this.#faceStatus.has(key2))
310178
310402
  this.#faceStatus.set(key2, "unloaded");
@@ -310216,6 +310440,10 @@ menclose::after {
310216
310440
  return s2;
310217
310441
  return "unloaded";
310218
310442
  }
310443
+ hasFace(family$1, weight, style2) {
310444
+ const key2 = faceKeyOf$1(family$1, weight, style2);
310445
+ return this.#providerFaceKeys.has(key2) && this.#faceStatus.get(key2) !== "failed";
310446
+ }
310219
310447
  isAvailable(family$1) {
310220
310448
  if (!this.#fontSet)
310221
310449
  return false;
@@ -310708,7 +310936,7 @@ menclose::after {
310708
310936
  if (typeof value !== "number" || !Number.isFinite(value) || value < 0)
310709
310937
  return;
310710
310938
  return value;
310711
- }, resolvePainterMarkerTextWidth = (markerTextWidthPx, marker) => getFiniteNonNegativeNumber(markerTextWidthPx) ?? getFiniteNonNegativeNumber(marker.glyphWidthPx) ?? getFiniteNonNegativeNumber(marker.markerBoxWidthPx) ?? 0, resolvePainterListMarkerGeometry = ({ wordLayout, indentLeftPx, hangingIndentPx, firstLineIndentPx, markerTextWidthPx }) => resolveListMarkerGeometry(wordLayout, indentLeftPx, firstLineIndentPx, hangingIndentPx, (_markerText, marker) => resolvePainterMarkerTextWidth(markerTextWidthPx, marker)), resolvePainterListTextStartPx = ({ wordLayout, indentLeftPx, hangingIndentPx, firstLineIndentPx, markerTextWidthPx }) => resolveListTextStartPx(wordLayout, indentLeftPx, firstLineIndentPx, hangingIndentPx, (_markerText, marker) => resolvePainterMarkerTextWidth(markerTextWidthPx, marker)), isMarkerSuffix = (suffix) => suffix === "tab" || suffix === "space" || suffix === "nothing", createListMarkerElement = (doc$12, markerText, run2, sourceAnchor, resolvePhysical = resolvePhysicalFamily) => {
310939
+ }, resolvePainterMarkerTextWidth = (markerTextWidthPx, marker) => getFiniteNonNegativeNumber(markerTextWidthPx) ?? getFiniteNonNegativeNumber(marker.glyphWidthPx) ?? getFiniteNonNegativeNumber(marker.markerBoxWidthPx) ?? 0, resolvePainterListMarkerGeometry = ({ wordLayout, indentLeftPx, hangingIndentPx, firstLineIndentPx, markerTextWidthPx }) => resolveListMarkerGeometry(wordLayout, indentLeftPx, firstLineIndentPx, hangingIndentPx, (_markerText, marker) => resolvePainterMarkerTextWidth(markerTextWidthPx, marker)), resolvePainterListTextStartPx = ({ wordLayout, indentLeftPx, hangingIndentPx, firstLineIndentPx, markerTextWidthPx }) => resolveListTextStartPx(wordLayout, indentLeftPx, firstLineIndentPx, hangingIndentPx, (_markerText, marker) => resolvePainterMarkerTextWidth(markerTextWidthPx, marker)), isMarkerSuffix = (suffix) => suffix === "tab" || suffix === "space" || suffix === "nothing", createListMarkerElement = (doc$12, markerText, run2, sourceAnchor, resolvePhysical = (css) => resolvePhysicalFamily(css)) => {
310712
310940
  const markerContainer = doc$12.createElement("span");
310713
310941
  markerContainer.classList.add(DOM_CLASS_NAMES.LIST_MARKER);
310714
310942
  markerContainer.style.display = "inline-block";
@@ -310718,7 +310946,10 @@ menclose::after {
310718
310946
  markerEl.textContent = markerText;
310719
310947
  markerEl.style.pointerEvents = "none";
310720
310948
  const cssFontFamily = toCssFontFamily(run2.fontFamily) ?? run2.fontFamily ?? "";
310721
- markerEl.style.fontFamily = resolvePhysical(cssFontFamily);
310949
+ markerEl.style.fontFamily = resolvePhysical(cssFontFamily, {
310950
+ weight: run2.bold ? "700" : "400",
310951
+ style: run2.italic ? "italic" : "normal"
310952
+ });
310722
310953
  if (run2.fontSize != null)
310723
310954
  markerEl.style.fontSize = `${run2.fontSize}px`;
310724
310955
  markerEl.style.fontWeight = run2.bold ? "bold" : "";
@@ -310736,7 +310967,7 @@ menclose::after {
310736
310967
  applySourceAnchorDataset(markerEl, sourceAnchor);
310737
310968
  return markerContainer;
310738
310969
  }, renderLegacyListMarker = (params$1) => {
310739
- const { doc: doc$12, lineEl, wordLayout, markerLayout, markerMeasure, markerTextWidthPx, indentLeftPx, hangingIndentPx, firstLineIndentPx, isRtl, sourceAnchor, resolvePhysical = resolvePhysicalFamily } = params$1;
310970
+ const { doc: doc$12, lineEl, wordLayout, markerLayout, markerMeasure, markerTextWidthPx, indentLeftPx, hangingIndentPx, firstLineIndentPx, isRtl, sourceAnchor, resolvePhysical = (css) => resolvePhysicalFamily(css) } = params$1;
310740
310971
  const markerTextWidth = markerTextWidthPx ?? markerMeasure?.markerTextWidth ?? 0;
310741
310972
  const markerGeometry = markerLayout?.justification === "left" && wordLayout?.firstLineIndentMode !== true && typeof markerTextWidth === "number" && Number.isFinite(markerTextWidth) && markerTextWidth >= 0 ? resolvePainterListMarkerGeometry({
310742
310973
  wordLayout,
@@ -310794,7 +311025,7 @@ menclose::after {
310794
311025
  prependMarkerSuffix(doc$12, lineEl, isMarkerSuffix(suffix) ? suffix : undefined, suffixWidthPx, markerLayout?.run?.fontSize);
310795
311026
  lineEl.prepend(markerContainer);
310796
311027
  }, renderResolvedListMarker = (params$1) => {
310797
- const { doc: doc$12, lineEl, marker, isRtl, sourceAnchor, resolvePhysical = resolvePhysicalFamily } = params$1;
311028
+ const { doc: doc$12, lineEl, marker, isRtl, sourceAnchor, resolvePhysical } = params$1;
310798
311029
  if (isRtl)
310799
311030
  lineEl.style.paddingRight = `${marker.firstLinePaddingLeftPx}px`;
310800
311031
  else
@@ -311069,7 +311300,7 @@ menclose::after {
311069
311300
  skipJustifyOverride: (resolvedLine?.skipJustify ?? false) || hasMultipleExplicitPositionedSegments
311070
311301
  }) ? Math.max(lineWidth, availableWidth) : lineWidth;
311071
311302
  }, renderResolvedLines = (params$1) => {
311072
- const { frameEl, block, resolvedContent: content3, markerTextWidth, renderLine: renderLine$1, captureLineSnapshot, convertFinalParagraphMark, lineTopOffset = 0, sourceAnchor, resolvePhysical = resolvePhysicalFamily } = params$1;
311303
+ const { frameEl, block, resolvedContent: content3, markerTextWidth, renderLine: renderLine$1, captureLineSnapshot, convertFinalParagraphMark, lineTopOffset = 0, sourceAnchor, resolvePhysical = (css) => resolvePhysicalFamily(css) } = params$1;
311073
311304
  const renderedLines = [];
311074
311305
  const resolvedMarker = content3.marker;
311075
311306
  const expandedRunsForBlock = expandRunsForInlineNewlines(block.runs);
@@ -311123,7 +311354,7 @@ menclose::after {
311123
311354
  renderedLines
311124
311355
  };
311125
311356
  }, renderMeasuredLines = (params$1) => {
311126
- const { doc: doc$12, frameEl, block, measure, containerKind, width, localStartLine, localEndLine, linesOverride, lineIndexOffset = 0, continuesFromPrev, continuesOnNext, markerWidth, markerTextWidth, wordLayout, renderLine: renderLine$1, captureLineSnapshot, convertFinalParagraphMark, lineTopOffset = 0, sourceAnchor, resolvePhysical = resolvePhysicalFamily } = params$1;
311357
+ const { doc: doc$12, frameEl, block, measure, containerKind, width, localStartLine, localEndLine, linesOverride, lineIndexOffset = 0, continuesFromPrev, continuesOnNext, markerWidth, markerTextWidth, wordLayout, renderLine: renderLine$1, captureLineSnapshot, convertFinalParagraphMark, lineTopOffset = 0, sourceAnchor, resolvePhysical = (css) => resolvePhysicalFamily(css) } = params$1;
311127
311358
  const lines = linesOverride ?? measure.lines ?? [];
311128
311359
  const paraIndent = block.attrs?.indent;
311129
311360
  const paraIndentLeft = paraIndent?.left ?? 0;
@@ -312394,7 +312625,7 @@ menclose::after {
312394
312625
  else
312395
312626
  delete el.dataset.continuesOnNext;
312396
312627
  }, isMinimalWordLayout$2 = (value) => isMinimalWordLayout(value), renderParagraphFragment = (params$1) => {
312397
- const { doc: doc$12, fragment: fragment2, sdtBoundary, betweenInfo, resolvedItem, applyStyles: applyStyles$3, applyResolvedFragmentFrame, applyFragmentFrame, applySdtDataset: applySdtDataset$1, applyContainerSdtDataset: applyContainerSdtDataset$1, renderLine: renderLine$1, captureLineSnapshot, createErrorPlaceholder, contentControlsChrome, resolvePhysical = resolvePhysicalFamily } = params$1;
312628
+ const { doc: doc$12, fragment: fragment2, sdtBoundary, betweenInfo, resolvedItem, applyStyles: applyStyles$3, applyResolvedFragmentFrame, applyFragmentFrame, applySdtDataset: applySdtDataset$1, applyContainerSdtDataset: applyContainerSdtDataset$1, renderLine: renderLine$1, captureLineSnapshot, createErrorPlaceholder, contentControlsChrome, resolvePhysical = (css) => resolvePhysicalFamily(css) } = params$1;
312398
312629
  try {
312399
312630
  if (!doc$12)
312400
312631
  throw new Error("DomPainter: document is not available");
@@ -312473,12 +312704,15 @@ menclose::after {
312473
312704
  });
312474
312705
  return createErrorPlaceholder(fragment2.blockId, error3);
312475
312706
  }
312476
- }, renderDropCap = (doc$12, descriptor, measure, resolvePhysical = resolvePhysicalFamily) => {
312707
+ }, renderDropCap = (doc$12, descriptor, measure, resolvePhysical = (css) => resolvePhysicalFamily(css)) => {
312477
312708
  const { run: run2, mode } = descriptor;
312478
312709
  const dropCapEl = doc$12.createElement("span");
312479
312710
  dropCapEl.classList.add("superdoc-drop-cap");
312480
312711
  dropCapEl.textContent = run2.text;
312481
- dropCapEl.style.fontFamily = resolvePhysical(run2.fontFamily);
312712
+ dropCapEl.style.fontFamily = resolvePhysical(run2.fontFamily, {
312713
+ weight: run2.bold ? "700" : "400",
312714
+ style: run2.italic ? "italic" : "normal"
312715
+ });
312482
312716
  dropCapEl.style.fontSize = `${run2.fontSize}px`;
312483
312717
  if (run2.bold)
312484
312718
  dropCapEl.style.fontWeight = "bold";
@@ -312594,7 +312828,10 @@ menclose::after {
312594
312828
  }, applyRunStyles = (element3, run2, _isLink = false, resolvePhysical = resolvePhysicalFamily) => {
312595
312829
  if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math")
312596
312830
  return;
312597
- element3.style.fontFamily = resolvePhysical(run2.fontFamily);
312831
+ element3.style.fontFamily = resolvePhysical(run2.fontFamily, {
312832
+ weight: run2.bold ? "700" : "400",
312833
+ style: run2.italic ? "italic" : "normal"
312834
+ });
312598
312835
  element3.style.fontSize = `${run2.fontSize}px`;
312599
312836
  if (run2.bold)
312600
312837
  element3.style.fontWeight = "bold";
@@ -312777,7 +313014,10 @@ menclose::after {
312777
313014
  }
312778
313015
  {
312779
313016
  const resolvePhysical = context.resolvePhysical ?? resolvePhysicalFamily;
312780
- annotation.style.fontFamily = resolvePhysical(run2.fontFamily || "Arial, sans-serif");
313017
+ annotation.style.fontFamily = resolvePhysical(run2.fontFamily || "Arial, sans-serif", {
313018
+ weight: run2.bold ? "700" : "400",
313019
+ style: run2.italic ? "italic" : "normal"
313020
+ });
312781
313021
  }
312782
313022
  {
312783
313023
  const fontSize = run2.fontSize ? typeof run2.fontSize === "number" ? `${run2.fontSize}pt` : run2.fontSize : BROWSER_DEFAULT_FONT_SIZE;
@@ -324709,11 +324949,11 @@ menclose::after {
324709
324949
  #resolveResult(result, storyId) {
324710
324950
  return resolveResult(result, storyId, this.#options.getFontSignature?.() ?? "");
324711
324951
  }
324712
- async layoutPerRId(headerFooterInput, layout, sectionMetadata, fontResolver) {
324952
+ async layoutPerRId(headerFooterInput, layout, sectionMetadata, fontResolver, hasFace, effectiveSignature) {
324713
324953
  await layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetadata, {
324714
324954
  headerLayoutsByRId: this.#headerLayoutsByRId,
324715
324955
  footerLayoutsByRId: this.#footerLayoutsByRId
324716
- }, fontResolver);
324956
+ }, fontResolver, hasFace, effectiveSignature);
324717
324957
  this.#resolvedHeaderByRId.clear();
324718
324958
  for (const [key2, result] of this.#headerLayoutsByRId)
324719
324959
  this.#resolvedHeaderByRId.set(key2, this.#resolveResult(result, storyIdFromHeaderFooterLayoutKey(key2)));
@@ -325571,6 +325811,7 @@ menclose::after {
325571
325811
  }, FontReadinessGate = class {
325572
325812
  #getDocumentFonts;
325573
325813
  #getRequiredFaces;
325814
+ #getUsedFaces;
325574
325815
  #resolveFamilies;
325575
325816
  #fontResolver;
325576
325817
  #requestReflow;
@@ -325580,18 +325821,21 @@ menclose::after {
325580
325821
  #timeoutMs;
325581
325822
  #invalidateCaches;
325582
325823
  #context = null;
325824
+ #packInstalledFor = null;
325583
325825
  #fontConfigVersion = 0;
325584
325826
  #requiredSignature = "";
325585
325827
  #requiredFamilies = /* @__PURE__ */ new Set;
325586
325828
  #requiredFaceKeys = /* @__PURE__ */ new Set;
325587
325829
  #seenAvailable = /* @__PURE__ */ new Set;
325588
325830
  #seenAvailableFaces = /* @__PURE__ */ new Set;
325831
+ #seenFailedFaces = /* @__PURE__ */ new Set;
325589
325832
  #lastSummary = null;
325590
325833
  #loadingDoneHandler = null;
325591
325834
  #lateLoadScheduler;
325592
325835
  constructor(options) {
325593
325836
  this.#getDocumentFonts = options.getDocumentFonts;
325594
325837
  this.#getRequiredFaces = options.getRequiredFaces ?? null;
325838
+ this.#getUsedFaces = options.getUsedFaces ?? null;
325595
325839
  this.#fontResolver = options.fontResolver ?? null;
325596
325840
  const resolver2 = this.#fontResolver;
325597
325841
  this.#resolveFamilies = options.resolveFamilies ?? (resolver2 ? (families) => resolver2.resolvePhysicalFamilies(families) : (families) => families);
@@ -325616,13 +325860,19 @@ menclose::after {
325616
325860
  return this.#lastSummary;
325617
325861
  }
325618
325862
  getReport() {
325619
- let logical = [];
325863
+ let declared = [];
325620
325864
  try {
325621
- logical = this.#getDocumentFonts();
325865
+ declared = this.#getDocumentFonts();
325622
325866
  } catch {
325623
325867
  return [];
325624
325868
  }
325625
- return buildFontReport(logical, this.#resolveContext().registry, this.#fontResolver ?? undefined);
325869
+ const registry2 = this.#resolveContext().registry;
325870
+ const resolver2 = this.#fontResolver ?? undefined;
325871
+ const usedFaces = this.#getUsedFaces?.() ?? [];
325872
+ const faceRows = buildFaceReport(usedFaces, registry2, resolver2);
325873
+ const usedFamilies = new Set(usedFaces.map((u) => u.logicalFamily.toLowerCase()));
325874
+ const declaredRows = buildFontReport(declared.filter((family$1) => family$1 && !usedFamilies.has(family$1.toLowerCase())), registry2, resolver2);
325875
+ return [...faceRows, ...declaredRows];
325626
325876
  }
325627
325877
  async ensureReadyForMeasure() {
325628
325878
  if (this.#getRequiredFaces)
@@ -325654,9 +325904,18 @@ menclose::after {
325654
325904
  } catch {
325655
325905
  results = [];
325656
325906
  }
325657
- for (const result of results)
325907
+ const failedKeys = [];
325908
+ for (const result of results) {
325909
+ const key2 = faceKeyOf(result.request.family, result.request.weight, result.request.style);
325658
325910
  if (result.status === "loaded")
325659
- this.#seenAvailableFaces.add(faceKeyOf(result.request.family, result.request.weight, result.request.style));
325911
+ this.#seenAvailableFaces.add(key2);
325912
+ else if (result.status === "failed" && !this.#seenFailedFaces.has(key2)) {
325913
+ this.#seenFailedFaces.add(key2);
325914
+ failedKeys.push(key2);
325915
+ }
325916
+ }
325917
+ if (failedKeys.length > 0)
325918
+ this.#scheduleAvailabilityReflow(failedKeys);
325660
325919
  this.#lastSummary = summarizeFaces(results);
325661
325920
  return this.#lastSummary;
325662
325921
  }
@@ -325713,6 +325972,7 @@ menclose::after {
325713
325972
  this.#requiredFamilies = /* @__PURE__ */ new Set;
325714
325973
  this.#seenAvailable.clear();
325715
325974
  this.#seenAvailableFaces.clear();
325975
+ this.#seenFailedFaces.clear();
325716
325976
  this.#lastSummary = null;
325717
325977
  }
325718
325978
  dispose() {
@@ -325732,10 +325992,12 @@ menclose::after {
325732
325992
  fontSet,
325733
325993
  registry: registry2
325734
325994
  };
325735
- if (fontSet && this.#onRegistryResolved)
325995
+ if (this.#onRegistryResolved && registry2 !== this.#packInstalledFor) {
325996
+ this.#packInstalledFor = registry2;
325736
325997
  try {
325737
325998
  this.#onRegistryResolved(registry2);
325738
325999
  } catch {}
326000
+ }
325739
326001
  return this.#context;
325740
326002
  }
325741
326003
  #ensureSubscribed() {
@@ -325776,6 +326038,9 @@ menclose::after {
325776
326038
  }
325777
326039
  if (changedKeys.length === 0)
325778
326040
  return;
326041
+ this.#scheduleAvailabilityReflow(changedKeys);
326042
+ }
326043
+ #scheduleAvailabilityReflow(changedKeys) {
325779
326044
  this.#fontConfigVersion += 1;
325780
326045
  bumpFontConfigVersion();
325781
326046
  this.#invalidateCaches();
@@ -325875,8 +326140,13 @@ menclose::after {
325875
326140
  const registry2 = this.#getGate()?.resolveRegistry();
325876
326141
  if (!registry2)
325877
326142
  throw new Error("[superdoc] fonts.preload: the font registry is not ready yet");
326143
+ const hasFace = (family$1, weight, style2) => registry2.hasFace(family$1, weight, style2);
326144
+ const face = {
326145
+ weight: "400",
326146
+ style: "normal"
326147
+ };
325878
326148
  const requests = families.map((logical) => ({
325879
- family: this.#resolver.resolvePrimaryPhysicalFamily(logical),
326149
+ family: this.#resolver.resolveFace(logical, face, hasFace).physicalFamily,
325880
326150
  weight: "400",
325881
326151
  style: "normal"
325882
326152
  }));
@@ -325993,13 +326263,13 @@ menclose::after {
325993
326263
  return;
325994
326264
  console.log(...args$1);
325995
326265
  }, 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;
325996
- var init_src_B1aSE_tB_es = __esm(() => {
326266
+ var init_src_plIVvSkL_es = __esm(() => {
325997
326267
  init_rolldown_runtime_Bg48TavK_es();
325998
- init_SuperConverter_B9mZiCO9_es();
326268
+ init_SuperConverter_BSMYiYJm_es();
325999
326269
  init_jszip_C49i9kUs_es();
326000
326270
  init_xml_js_CqGKpaft_es();
326001
326271
  init_uuid_qzgm05fK_es();
326002
- init_create_headless_toolbar_pn_wKqsL_es();
326272
+ init_create_headless_toolbar_DeKyOdIi_es();
326003
326273
  init_constants_D_X7xF4s_es();
326004
326274
  init_dist_B8HfvhaK_es();
326005
326275
  init_unified_Dsuw2be5_es();
@@ -352883,7 +353153,7 @@ function print() { __p += __j.call(arguments, '') }
352883
353153
  });
352884
353154
  defaultResolver = new FontResolver;
352885
353155
  DEFAULT_FONT_MEASURE_CONTEXT = Object.freeze({
352886
- resolvePhysical: resolvePhysicalFamily,
353156
+ resolvePhysical: (cssFontFamily, _face) => resolvePhysicalFamily(cssFontFamily),
352887
353157
  fontSignature: ""
352888
353158
  });
352889
353159
  BUNDLED_MANIFEST = Object.freeze([
@@ -354167,7 +354437,10 @@ function print() { __p += __j.call(arguments, '') }
354167
354437
  }
354168
354438
  });
354169
354439
  #fontPlanBlocks = null;
354440
+ #fontPlan = null;
354441
+ #hasFace = (family$1, weight, style2) => this.#fontGate ? this.#fontGate.resolveRegistry().hasFace(family$1, weight, style2) : false;
354170
354442
  #lastFontsChangedKey = null;
354443
+ #lastFontsChangedVersion = -1;
354171
354444
  #lastFontsChangedPayload = null;
354172
354445
  #shouldScrollSelectionIntoView = false;
354173
354446
  #suppressSelectionScrollUntilRaf = false;
@@ -354398,7 +354671,7 @@ function print() { __p += __j.call(arguments, '') }
354398
354671
  initBudgetMs: HEADER_FOOTER_INIT_BUDGET_MS,
354399
354672
  defaultPageSize: DEFAULT_PAGE_SIZE,
354400
354673
  defaultMargins: DEFAULT_MARGINS,
354401
- getFontSignature: () => this.#fontResolver.signature
354674
+ getFontSignature: () => this.#layoutFontSignature
354402
354675
  });
354403
354676
  this.#headerFooterSession.setHoverElements({
354404
354677
  hoverOverlay: this.#hoverOverlay,
@@ -354453,7 +354726,8 @@ function print() { __p += __j.call(arguments, '') }
354453
354726
  return this.#editor.converter?.getDocumentFonts?.() ?? [];
354454
354727
  },
354455
354728
  requestReflow: () => this.#requestFontReflow(),
354456
- getRequiredFaces: () => planRequiredFontFaces(this.#fontPlanBlocks, this.#fontResolver),
354729
+ getRequiredFaces: () => this.#fontPlan?.requiredFaces ?? [],
354730
+ getUsedFaces: () => this.#fontPlan?.usedFaces ?? [],
354457
354731
  fontResolver: this.#fontResolver,
354458
354732
  onRegistryResolved: (registry2) => installBundledSubstitutes(registry2, {
354459
354733
  assetBaseUrl: this.#options.fontAssets?.assetBaseUrl,
@@ -355428,7 +355702,7 @@ function print() { __p += __j.call(arguments, '') }
355428
355702
  return this.#fontGate?.getReport() ?? [];
355429
355703
  }
355430
355704
  getMissingFonts() {
355431
- return this.getFontReport().filter((record) => record.missing).map((record) => record.logicalFamily);
355705
+ return [...new Set(this.getFontReport().filter((record) => record.missing).map((record) => record.logicalFamily))];
355432
355706
  }
355433
355707
  mapFonts(mappings) {
355434
355708
  this.#fontController.map(mappings);
@@ -355457,14 +355731,17 @@ function print() { __p += __j.call(arguments, '') }
355457
355731
  if (!gate)
355458
355732
  return;
355459
355733
  const version$1 = gate.fontConfigVersion;
355460
- const key2 = `${version$1}|${summary ? summary.results.map((result) => `${result.family}:${result.status}`).sort().join(",") : ""}`;
355734
+ const statusKey = summary ? summary.results.map((result) => `${result.family}:${result.status}`).sort().join(",") : "";
355735
+ const key2 = `${version$1}|${this.#fontPlan?.effectiveSignature ?? ""}|${statusKey}`;
355461
355736
  if (key2 === this.#lastFontsChangedKey)
355462
355737
  return;
355463
355738
  const isInitial = this.#lastFontsChangedKey === null;
355739
+ const epochBumped = !isInitial && version$1 !== this.#lastFontsChangedVersion;
355464
355740
  this.#lastFontsChangedKey = key2;
355741
+ this.#lastFontsChangedVersion = version$1;
355465
355742
  const pendingSource = this.#nextFontsChangedSource;
355466
355743
  this.#nextFontsChangedSource = null;
355467
- const source = isInitial ? "initial" : pendingSource ?? "late-load";
355744
+ const source = isInitial ? "initial" : pendingSource ?? (epochBumped ? "late-load" : "render-change");
355468
355745
  let resolutions;
355469
355746
  try {
355470
355747
  resolutions = gate.getReport();
@@ -355472,9 +355749,9 @@ function print() { __p += __j.call(arguments, '') }
355472
355749
  return;
355473
355750
  }
355474
355751
  const payload = {
355475
- documentFonts: resolutions.map((record) => record.logicalFamily),
355752
+ documentFonts: [...new Set(resolutions.map((record) => record.logicalFamily))],
355476
355753
  resolutions,
355477
- missingFonts: resolutions.filter((record) => record.missing).map((record) => record.logicalFamily),
355754
+ missingFonts: [...new Set(resolutions.filter((record) => record.missing).map((record) => record.logicalFamily))],
355478
355755
  loadSummary: summary ?? {
355479
355756
  loaded: 0,
355480
355757
  failed: 0,
@@ -355496,7 +355773,10 @@ function print() { __p += __j.call(arguments, '') }
355496
355773
  #resetFontReportStateForDocumentChange() {
355497
355774
  this.#nextFontsChangedSource = null;
355498
355775
  this.#lastFontsChangedKey = null;
355776
+ this.#lastFontsChangedVersion = -1;
355499
355777
  this.#lastFontsChangedPayload = null;
355778
+ this.#fontPlan = null;
355779
+ this.#fontPlanBlocks = null;
355500
355780
  }
355501
355781
  getLayoutOptions() {
355502
355782
  return { ...this.#layoutOptions };
@@ -355646,7 +355926,7 @@ function print() { __p += __j.call(arguments, '') }
355646
355926
  flowMode: this.#layoutOptions.flowMode ?? "paginated",
355647
355927
  blocks: blocks2,
355648
355928
  measures,
355649
- fontSignature: this.#fontResolver.signature
355929
+ fontSignature: this.#layoutFontSignature
355650
355930
  });
355651
355931
  const isSemanticFlow = this.#layoutOptions.flowMode === "semantic";
355652
355932
  this.#ensurePainter();
@@ -357855,10 +358135,10 @@ function print() { __p += __j.call(arguments, '') }
357855
358135
  const previousBlocks = this.#layoutState.blocks;
357856
358136
  const previousLayout = this.#layoutState.layout;
357857
358137
  const previousMeasures = this.#layoutState.measures;
357858
- const resolvePhysical = (css) => this.#fontResolver.resolvePhysicalFamily(css);
357859
- const fontSignature = this.#fontResolver.signature;
358138
+ const resolvePhysical = (css, face) => this.#fontResolver.resolvePhysicalFamilyForFace(css, face, this.#hasFace);
358139
+ let fontSignature = "";
357860
358140
  const previousFontSignature = this.#layoutFontSignature;
357861
- const fontMeasureContext = {
358141
+ let fontMeasureContext = {
357862
358142
  resolvePhysical,
357863
358143
  fontSignature
357864
358144
  };
@@ -357880,6 +358160,12 @@ function print() { __p += __j.call(arguments, '') }
357880
358160
  ...headerFooterInput ? this.#collectHeaderFooterFaceBlocks(headerFooterInput) : [],
357881
358161
  ...!isSemanticFlow && footnotesLayoutInput?.blocksById ? [...footnotesLayoutInput.blocksById.values()].flat() : []
357882
358162
  ];
358163
+ this.#fontPlan = planFontFaces(this.#fontPlanBlocks, this.#fontResolver, this.#hasFace);
358164
+ fontSignature = this.#fontPlan.effectiveSignature;
358165
+ fontMeasureContext = {
358166
+ resolvePhysical,
358167
+ fontSignature
358168
+ };
357883
358169
  const fontSummary = await this.#fontGate?.ensureReadyForMeasure() ?? null;
357884
358170
  this.#emitFontsChangedIfChanged(fontSummary);
357885
358171
  } catch {}
@@ -358039,7 +358325,7 @@ function print() { __p += __j.call(arguments, '') }
358039
358325
  pageGap: this.#layoutState.layout?.pageGap ?? effectiveGap,
358040
358326
  showFormattingMarks: this.#layoutOptions.showFormattingMarks ?? false,
358041
358327
  contentControlsChrome: this.#layoutOptions.contentControlsChrome ?? "default",
358042
- resolvePhysical: (css) => this.#fontResolver.resolvePhysicalFamily(css)
358328
+ resolvePhysical: (css, face) => this.#fontResolver.resolvePhysicalFamilyForFace(css, face, this.#hasFace)
358043
358329
  });
358044
358330
  const currentZoom = this.#layoutOptions.zoom ?? 1;
358045
358331
  if (currentZoom !== 1)
@@ -358791,7 +359077,7 @@ function print() { __p += __j.call(arguments, '') }
358791
359077
  }
358792
359078
  async#layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetadata) {
358793
359079
  if (this.#headerFooterSession)
358794
- await this.#headerFooterSession.layoutPerRId(headerFooterInput, layout, sectionMetadata, this.#fontResolver);
359080
+ await this.#headerFooterSession.layoutPerRId(headerFooterInput, layout, sectionMetadata, this.#fontResolver, this.#hasFace, this.#fontPlan?.effectiveSignature ?? "");
358795
359081
  }
358796
359082
  #updateDecorationProviders(resolvedLayout) {
358797
359083
  this.#headerFooterSession?.updateDecorationProviders(resolvedLayout);
@@ -360692,11 +360978,11 @@ function print() { __p += __j.call(arguments, '') }
360692
360978
  ]);
360693
360979
  });
360694
360980
 
360695
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CxQcY_QQ.es.js
360981
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CJMIa98h.es.js
360696
360982
  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;
360697
- var init_create_super_doc_ui_CxQcY_QQ_es = __esm(() => {
360698
- init_SuperConverter_B9mZiCO9_es();
360699
- init_create_headless_toolbar_pn_wKqsL_es();
360983
+ var init_create_super_doc_ui_CJMIa98h_es = __esm(() => {
360984
+ init_SuperConverter_BSMYiYJm_es();
360985
+ init_create_headless_toolbar_DeKyOdIi_es();
360700
360986
  MOD_ALIASES = new Set([
360701
360987
  "Mod",
360702
360988
  "Meta",
@@ -360738,16 +361024,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
360738
361024
 
360739
361025
  // ../../packages/superdoc/dist/super-editor.es.js
360740
361026
  var init_super_editor_es = __esm(() => {
360741
- init_src_B1aSE_tB_es();
360742
- init_SuperConverter_B9mZiCO9_es();
361027
+ init_src_plIVvSkL_es();
361028
+ init_SuperConverter_BSMYiYJm_es();
360743
361029
  init_jszip_C49i9kUs_es();
360744
361030
  init_xml_js_CqGKpaft_es();
360745
- init_create_headless_toolbar_pn_wKqsL_es();
361031
+ init_create_headless_toolbar_DeKyOdIi_es();
360746
361032
  init_constants_D_X7xF4s_es();
360747
361033
  init_dist_B8HfvhaK_es();
360748
361034
  init_unified_Dsuw2be5_es();
360749
361035
  init_DocxZipper_VodIk8WL_es();
360750
- init_create_super_doc_ui_CxQcY_QQ_es();
361036
+ init_create_super_doc_ui_CJMIa98h_es();
360751
361037
  init_ui_C5PAS9hY_es();
360752
361038
  init_eventemitter3_BnGqBE_Q_es();
360753
361039
  init_errors_CNaD6vcg_es();