@beyondwork/docx-react-component 1.0.131 → 1.0.133

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 (100) hide show
  1. package/dist/api/public-types.cjs +837 -224
  2. package/dist/api/public-types.d.cts +2 -2
  3. package/dist/api/public-types.d.ts +2 -2
  4. package/dist/api/public-types.js +5 -3
  5. package/dist/api/v3.cjs +9679 -7492
  6. package/dist/api/v3.d.cts +3 -3
  7. package/dist/api/v3.d.ts +3 -3
  8. package/dist/api/v3.js +10 -10
  9. package/dist/{canonical-document-BMtONpgf.d.cts → canonical-document-CfZIc-fC.d.cts} +1 -1
  10. package/dist/{canonical-document-BMtONpgf.d.ts → canonical-document-CfZIc-fC.d.ts} +1 -1
  11. package/dist/{chunk-7G5GR3VV.js → chunk-224TSMEB.js} +635 -89
  12. package/dist/{chunk-YLL7MF5C.js → chunk-3JEE5RJU.js} +103 -135
  13. package/dist/{chunk-35RHOE6I.js → chunk-57HTKX3P.js} +10 -1162
  14. package/dist/{chunk-A66ZVUAT.js → chunk-5KTJKTNE.js} +236 -10
  15. package/dist/{chunk-THVM6EP5.js → chunk-CVSD3UNK.js} +1322 -102
  16. package/dist/{chunk-VRKK2CSZ.js → chunk-EFEW7BTT.js} +2 -2
  17. package/dist/{chunk-KNHMXKC6.js → chunk-INLRCC4N.js} +2 -2
  18. package/dist/{chunk-HYHCRMR7.js → chunk-KL4TZSZV.js} +1 -1
  19. package/dist/{chunk-T5YYFDZB.js → chunk-MQ5GAJ54.js} +68 -39
  20. package/dist/{chunk-CI2TD3T4.js → chunk-NJFKPDNG.js} +216 -2
  21. package/dist/{chunk-WZDKNF37.js → chunk-OTRVGNZQ.js} +2934 -1815
  22. package/dist/{chunk-4YCWECLZ.js → chunk-PZIEOEJZ.js} +1 -1
  23. package/dist/{chunk-PHMWH23E.js → chunk-QTRJLKR2.js} +1 -1
  24. package/dist/{chunk-QXKQPUOM.js → chunk-REFHJ2FN.js} +3 -3
  25. package/dist/{chunk-ZVC23LKV.js → chunk-RP76USJE.js} +1 -1
  26. package/dist/{chunk-3YCQM2RV.js → chunk-S3PEKX6H.js} +249 -45
  27. package/dist/{chunk-M7YRJX6V.js → chunk-T66OS7MN.js} +8 -3
  28. package/dist/{chunk-DGA7M77X.js → chunk-V2JF42SI.js} +2 -2
  29. package/dist/{chunk-Q7Y57KOK.js → chunk-WDDFU2N2.js} +2 -2
  30. package/dist/{chunk-A3GSNB4G.js → chunk-XBQFDBXE.js} +147 -13
  31. package/dist/{chunk-6TBLDBCL.js → chunk-ZFCZ7XXH.js} +1 -1
  32. package/dist/compare.d.cts +1 -1
  33. package/dist/compare.d.ts +1 -1
  34. package/dist/core/commands/formatting-commands.d.cts +2 -2
  35. package/dist/core/commands/formatting-commands.d.ts +2 -2
  36. package/dist/core/commands/image-commands.cjs +344 -20
  37. package/dist/core/commands/image-commands.d.cts +2 -2
  38. package/dist/core/commands/image-commands.d.ts +2 -2
  39. package/dist/core/commands/image-commands.js +5 -5
  40. package/dist/core/commands/section-layout-commands.d.cts +2 -2
  41. package/dist/core/commands/section-layout-commands.d.ts +2 -2
  42. package/dist/core/commands/style-commands.d.cts +2 -2
  43. package/dist/core/commands/style-commands.d.ts +2 -2
  44. package/dist/core/commands/table-structure-commands.cjs +344 -20
  45. package/dist/core/commands/table-structure-commands.d.cts +2 -2
  46. package/dist/core/commands/table-structure-commands.d.ts +2 -2
  47. package/dist/core/commands/table-structure-commands.js +4 -4
  48. package/dist/core/commands/text-commands.cjs +411 -58
  49. package/dist/core/commands/text-commands.d.cts +13 -2
  50. package/dist/core/commands/text-commands.d.ts +13 -2
  51. package/dist/core/commands/text-commands.js +5 -5
  52. package/dist/core/selection/mapping.d.cts +2 -2
  53. package/dist/core/selection/mapping.d.ts +2 -2
  54. package/dist/core/state/editor-state.d.cts +2 -2
  55. package/dist/core/state/editor-state.d.ts +2 -2
  56. package/dist/index.cjs +7199 -4004
  57. package/dist/index.d.cts +5 -5
  58. package/dist/index.d.ts +5 -5
  59. package/dist/index.js +814 -120
  60. package/dist/io/docx-session.cjs +7 -2
  61. package/dist/io/docx-session.d.cts +4 -4
  62. package/dist/io/docx-session.d.ts +4 -4
  63. package/dist/io/docx-session.js +4 -4
  64. package/dist/legal.d.cts +1 -1
  65. package/dist/legal.d.ts +1 -1
  66. package/dist/legal.js +3 -3
  67. package/dist/{loader-DiY_ZgKl.d.cts → loader-B2H99237.d.cts} +3 -3
  68. package/dist/{loader-B-aL5HGD.d.ts → loader-DfTjqVwn.d.ts} +3 -3
  69. package/dist/{public-types-gvubspUI.d.cts → public-types-B5lOUIrP.d.ts} +930 -338
  70. package/dist/{public-types-DyqnxxO9.d.ts → public-types-S8gTYwKo.d.cts} +930 -338
  71. package/dist/public-types.cjs +837 -224
  72. package/dist/public-types.d.cts +2 -2
  73. package/dist/public-types.d.ts +2 -2
  74. package/dist/public-types.js +5 -3
  75. package/dist/runtime/collab.d.cts +3 -3
  76. package/dist/runtime/collab.d.ts +3 -3
  77. package/dist/runtime/document-runtime.cjs +1403 -438
  78. package/dist/runtime/document-runtime.d.cts +2 -2
  79. package/dist/runtime/document-runtime.d.ts +2 -2
  80. package/dist/runtime/document-runtime.js +14 -14
  81. package/dist/{session-CDB0hohT.d.ts → session-CBDIOYXA.d.ts} +3 -3
  82. package/dist/{session-BUN6B-Vj.d.cts → session-CR2A1hGZ.d.cts} +3 -3
  83. package/dist/session.cjs +7 -2
  84. package/dist/session.d.cts +5 -5
  85. package/dist/session.d.ts +5 -5
  86. package/dist/session.js +5 -5
  87. package/dist/tailwind.cjs +905 -322
  88. package/dist/tailwind.d.cts +2 -2
  89. package/dist/tailwind.d.ts +2 -2
  90. package/dist/tailwind.js +7 -7
  91. package/dist/{types-VWH6CRvG.d.ts → types-B-90ywjU.d.ts} +2 -2
  92. package/dist/{types-C4bz3kDU.d.cts → types-yty2K-hk.d.cts} +2 -2
  93. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  94. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  95. package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
  96. package/dist/ui-tailwind.cjs +905 -322
  97. package/dist/ui-tailwind.d.cts +4 -3
  98. package/dist/ui-tailwind.d.ts +4 -3
  99. package/dist/ui-tailwind.js +7 -7
  100. package/package.json +1 -1
@@ -808,6 +808,7 @@ __export(public_types_exports, {
808
808
  buildPagePreviewMaps: () => buildPagePreviewMaps,
809
809
  buildSearchPattern: () => buildSearchPattern,
810
810
  createCanvasBackend: () => createCanvasBackend,
811
+ createPagePatchPlan: () => createPagePatchPlan,
811
812
  createPublicNodeAnchor: () => createPublicNodeAnchor,
812
813
  createPublicRangeAnchor: () => createPublicRangeAnchor,
813
814
  createScopeTagRegistry: () => createScopeTagRegistry,
@@ -1202,6 +1203,372 @@ function storyTargetsEqual(left, right) {
1202
1203
  }
1203
1204
  var MAIN_STORY_TARGET = { kind: "main" };
1204
1205
 
1206
+ // src/runtime/story-context.ts
1207
+ function collectSectionContexts(document2) {
1208
+ const sections = [];
1209
+ let sectionIndex = 0;
1210
+ for (const block of document2.content.children) {
1211
+ if (block.type !== "section_break") {
1212
+ continue;
1213
+ }
1214
+ sections.push({
1215
+ index: sectionIndex,
1216
+ properties: block.sectionProperties
1217
+ });
1218
+ sectionIndex += 1;
1219
+ }
1220
+ sections.push({
1221
+ index: sectionIndex,
1222
+ properties: document2.subParts?.finalSectionProperties
1223
+ });
1224
+ return sections;
1225
+ }
1226
+ function resolveSectionVariants(kind, sectionIndex, explicitReferences, documents) {
1227
+ if (explicitReferences && explicitReferences.length > 0) {
1228
+ return explicitReferences.map((ref) => ({
1229
+ variant: ref.variant,
1230
+ relationshipId: ref.relationshipId
1231
+ }));
1232
+ }
1233
+ return documents.filter(
1234
+ (entry) => entry.sectionIndex === void 0 || entry.sectionIndex === sectionIndex
1235
+ ).map((entry) => ({
1236
+ variant: entry.variant,
1237
+ relationshipId: entry.relationshipId
1238
+ }));
1239
+ }
1240
+ function findHeaderFooterDocumentEntry(document2, target) {
1241
+ const documents = target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? [];
1242
+ const matches = documents.filter(
1243
+ (entry) => entry.relationshipId === target.relationshipId && entry.variant === target.variant
1244
+ );
1245
+ if (matches.length === 0) {
1246
+ return void 0;
1247
+ }
1248
+ if (target.sectionIndex !== void 0) {
1249
+ return matches.find((entry) => entry.sectionIndex === target.sectionIndex) ?? matches.find((entry) => entry.sectionIndex === void 0) ?? matches[0];
1250
+ }
1251
+ return matches[0];
1252
+ }
1253
+ function sectionSupportsStoryTarget(document2, sectionIndex, target) {
1254
+ if (!findHeaderFooterDocumentEntry(document2, target)) {
1255
+ return false;
1256
+ }
1257
+ const section = collectSectionContexts(document2).find(
1258
+ (candidate) => candidate.index === sectionIndex
1259
+ );
1260
+ if (!section) {
1261
+ return false;
1262
+ }
1263
+ const variants = resolveSectionVariants(
1264
+ target.kind,
1265
+ sectionIndex,
1266
+ target.kind === "header" ? section.properties?.headerReferences : section.properties?.footerReferences,
1267
+ target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? []
1268
+ );
1269
+ return variants.some(
1270
+ (variant) => variant.relationshipId === target.relationshipId && variant.variant === target.variant
1271
+ );
1272
+ }
1273
+ function normalizeHeaderFooterTarget(document2, target, preferredSectionIndex) {
1274
+ if (!findHeaderFooterDocumentEntry(document2, target)) {
1275
+ return void 0;
1276
+ }
1277
+ if (target.sectionIndex !== void 0) {
1278
+ return sectionSupportsStoryTarget(document2, target.sectionIndex, target) ? target : void 0;
1279
+ }
1280
+ const candidateIndexes = collectSectionContexts(document2).map((section) => section.index).filter(
1281
+ (sectionIndex) => sectionSupportsStoryTarget(document2, sectionIndex, target)
1282
+ );
1283
+ if (candidateIndexes.length === 0) {
1284
+ return void 0;
1285
+ }
1286
+ const resolvedSectionIndex = preferredSectionIndex !== void 0 && candidateIndexes.includes(preferredSectionIndex) ? preferredSectionIndex : candidateIndexes[0];
1287
+ return {
1288
+ ...target,
1289
+ sectionIndex: resolvedSectionIndex
1290
+ };
1291
+ }
1292
+
1293
+ // src/runtime/story-targeting.ts
1294
+ function storyTargetKey(target) {
1295
+ switch (target.kind) {
1296
+ case "main":
1297
+ return "main";
1298
+ case "header":
1299
+ return `header:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
1300
+ case "footer":
1301
+ return `footer:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
1302
+ case "footnote":
1303
+ return `footnote:${target.noteId}`;
1304
+ case "endnote":
1305
+ return `endnote:${target.noteId}`;
1306
+ }
1307
+ }
1308
+ function getStoryBlocks(document2, target) {
1309
+ if (target.kind === "main") {
1310
+ return document2.content.children;
1311
+ }
1312
+ const subParts = document2.subParts;
1313
+ if (!subParts) {
1314
+ return [];
1315
+ }
1316
+ switch (target.kind) {
1317
+ case "header": {
1318
+ const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
1319
+ return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
1320
+ }
1321
+ case "footer": {
1322
+ const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
1323
+ return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
1324
+ }
1325
+ case "footnote":
1326
+ return subParts.footnoteCollection?.footnotes[target.noteId]?.blocks ?? [];
1327
+ case "endnote":
1328
+ return subParts.footnoteCollection?.endnotes[target.noteId]?.blocks ?? [];
1329
+ }
1330
+ }
1331
+
1332
+ // src/runtime/render/render-frame-diff.ts
1333
+ function diffRenderFrames(prev, next) {
1334
+ if (!prev) {
1335
+ return {
1336
+ addedPages: next.pages.map((p) => p.page.pageIndex),
1337
+ removedPages: [],
1338
+ unchangedPages: [],
1339
+ changedPages: []
1340
+ };
1341
+ }
1342
+ const prevByIndex = /* @__PURE__ */ new Map();
1343
+ for (const page of prev.pages) {
1344
+ prevByIndex.set(page.page.pageIndex, page);
1345
+ }
1346
+ const nextIndices = /* @__PURE__ */ new Set();
1347
+ for (const page of next.pages) {
1348
+ nextIndices.add(page.page.pageIndex);
1349
+ }
1350
+ const addedPages = [];
1351
+ const removedPages = [];
1352
+ const unchangedPages = [];
1353
+ const changedPages = [];
1354
+ for (const nextPage of next.pages) {
1355
+ const pageIndex = nextPage.page.pageIndex;
1356
+ const prevPage = prevByIndex.get(pageIndex);
1357
+ if (!prevPage) {
1358
+ addedPages.push(pageIndex);
1359
+ continue;
1360
+ }
1361
+ const regions = diffPage(prevPage, nextPage, prev.decorationIndex, next.decorationIndex);
1362
+ const frameChanged = !rectEquals(prevPage.frame, nextPage.frame);
1363
+ const reservationsChanged = !reservationsEqual(
1364
+ prevPage.chromeReservations,
1365
+ nextPage.chromeReservations
1366
+ );
1367
+ if (regions.length === 0 && !frameChanged && !reservationsChanged) {
1368
+ unchangedPages.push(pageIndex);
1369
+ } else {
1370
+ changedPages.push({
1371
+ pageIndex,
1372
+ regions,
1373
+ ...frameChanged ? { pageFrameChanged: true } : {}
1374
+ });
1375
+ }
1376
+ }
1377
+ for (const prevPage of prev.pages) {
1378
+ if (!nextIndices.has(prevPage.page.pageIndex)) {
1379
+ removedPages.push(prevPage.page.pageIndex);
1380
+ }
1381
+ }
1382
+ return { addedPages, removedPages, unchangedPages, changedPages };
1383
+ }
1384
+ function createPagePatchPlan(prev, next, diff = diffRenderFrames(prev, next), options = {}) {
1385
+ const prevByIndex = indexPagesByIndex(prev?.pages ?? []);
1386
+ const nextByIndex = indexPagesByIndex(next.pages);
1387
+ const addedPages = diff.addedPages.map(
1388
+ (pageIndex) => pageIdForIndex(nextByIndex, pageIndex)
1389
+ );
1390
+ const removedPages = diff.removedPages.map(
1391
+ (pageIndex) => pageIdForIndex(prevByIndex, pageIndex)
1392
+ );
1393
+ const unchangedPages = diff.unchangedPages.map(
1394
+ (pageIndex) => pageIdForIndex(nextByIndex, pageIndex)
1395
+ );
1396
+ const changedPages = diff.changedPages.map(
1397
+ (entry) => createPagePatchEntry(entry, pageIdForIndex(nextByIndex, entry.pageIndex), options)
1398
+ );
1399
+ return {
1400
+ layoutRevision: options.layoutRevision ?? next.revision,
1401
+ geometryRevision: options.geometryRevision ?? next.revision,
1402
+ addedPages,
1403
+ removedPages,
1404
+ unchangedPages,
1405
+ changedPages,
1406
+ mountChanges: resolveMountChanges({
1407
+ addedPages,
1408
+ removedPages,
1409
+ mountedPageIds: options.mountedPageIds,
1410
+ requestedMountPageIds: options.requestedMountPageIds
1411
+ })
1412
+ };
1413
+ }
1414
+ function createPagePatchEntry(entry, pageId, options) {
1415
+ const regionChanges = entry.regions.map((region) => region.kind);
1416
+ const fragmentChanges = uniqueStrings(
1417
+ entry.regions.flatMap((region) => region.changedBlockIds)
1418
+ );
1419
+ const overlayLaneChanges = !entry.pageFrameChanged && entry.regions.length === 0 ? ["chrome-reservations"] : [];
1420
+ return {
1421
+ pageId,
1422
+ pageIndex: entry.pageIndex,
1423
+ frameChanged: entry.pageFrameChanged === true,
1424
+ regionChanges,
1425
+ fragmentChanges,
1426
+ lineBoxChanges: fragmentChanges,
1427
+ overlayLaneChanges,
1428
+ reason: options.reason ?? (overlayLaneChanges.length > 0 ? "overlay" : "layout")
1429
+ };
1430
+ }
1431
+ function resolveMountChanges(input) {
1432
+ if (!input.mountedPageIds || !input.requestedMountPageIds) {
1433
+ return {
1434
+ mountPageIds: input.addedPages,
1435
+ unmountPageIds: input.removedPages
1436
+ };
1437
+ }
1438
+ const mounted = new Set(input.mountedPageIds);
1439
+ const requested = new Set(input.requestedMountPageIds);
1440
+ return {
1441
+ mountPageIds: input.requestedMountPageIds.filter((pageId) => !mounted.has(pageId)),
1442
+ unmountPageIds: input.mountedPageIds.filter((pageId) => !requested.has(pageId))
1443
+ };
1444
+ }
1445
+ function indexPagesByIndex(pages) {
1446
+ return new Map(pages.map((page) => [page.page.pageIndex, page]));
1447
+ }
1448
+ function pageIdForIndex(pages, pageIndex) {
1449
+ return pages.get(pageIndex)?.page.pageId ?? `page:${pageIndex}`;
1450
+ }
1451
+ function uniqueStrings(values) {
1452
+ return [...new Set(values)];
1453
+ }
1454
+ function diffPage(prev, next, prevIndex, nextIndex) {
1455
+ const changed = [];
1456
+ const bodyChanges = diffRegion(prev.regions.body, next.regions.body, prevIndex, nextIndex);
1457
+ if (bodyChanges.length > 0) {
1458
+ changed.push({ kind: "body", changedBlockIds: bodyChanges });
1459
+ }
1460
+ const headerChanges = diffOptionalRegion(
1461
+ prev.regions.header,
1462
+ next.regions.header,
1463
+ prevIndex,
1464
+ nextIndex
1465
+ );
1466
+ if (headerChanges.length > 0) {
1467
+ changed.push({ kind: "header", changedBlockIds: headerChanges });
1468
+ }
1469
+ const footerChanges = diffOptionalRegion(
1470
+ prev.regions.footer,
1471
+ next.regions.footer,
1472
+ prevIndex,
1473
+ nextIndex
1474
+ );
1475
+ if (footerChanges.length > 0) {
1476
+ changed.push({ kind: "footer", changedBlockIds: footerChanges });
1477
+ }
1478
+ const prevFoot = prev.regions.footnotes ?? [];
1479
+ const nextFoot = next.regions.footnotes ?? [];
1480
+ if (prevFoot.length !== nextFoot.length) {
1481
+ changed.push({ kind: "footnote-area", changedBlockIds: ["<count-changed>"] });
1482
+ } else {
1483
+ for (let i = 0; i < prevFoot.length; i += 1) {
1484
+ const fChanges = diffRegion(prevFoot[i], nextFoot[i], prevIndex, nextIndex);
1485
+ if (fChanges.length > 0) {
1486
+ changed.push({ kind: "footnote-area", changedBlockIds: fChanges });
1487
+ }
1488
+ }
1489
+ }
1490
+ return changed;
1491
+ }
1492
+ function diffOptionalRegion(prev, next, prevIndex, nextIndex) {
1493
+ if (!prev && !next) return [];
1494
+ if (!prev && next) return ["<added>"];
1495
+ if (prev && !next) return ["<removed>"];
1496
+ return diffRegion(prev, next, prevIndex, nextIndex);
1497
+ }
1498
+ function diffRegion(prev, next, prevIndex, nextIndex) {
1499
+ const changed = [];
1500
+ if (!rectEquals(prev.frame, next.frame)) {
1501
+ changed.push("<region-frame>");
1502
+ }
1503
+ const prevBlocks = /* @__PURE__ */ new Map();
1504
+ for (const block of prev.blocks) {
1505
+ prevBlocks.set(block.fragment.blockId, block);
1506
+ }
1507
+ const nextIds = /* @__PURE__ */ new Set();
1508
+ for (const block of next.blocks) {
1509
+ nextIds.add(block.fragment.blockId);
1510
+ const prevBlock = prevBlocks.get(block.fragment.blockId);
1511
+ if (!prevBlock) {
1512
+ changed.push(block.fragment.blockId);
1513
+ continue;
1514
+ }
1515
+ if (!blocksStructurallyEqual(prevBlock, block, prevIndex, nextIndex)) {
1516
+ changed.push(block.fragment.blockId);
1517
+ }
1518
+ }
1519
+ for (const blockId of prevBlocks.keys()) {
1520
+ if (!nextIds.has(blockId)) changed.push(blockId);
1521
+ }
1522
+ return changed;
1523
+ }
1524
+ function blocksStructurallyEqual(a, b, aIndex, bIndex) {
1525
+ if (a.kind !== b.kind) return false;
1526
+ if (a.fragment.regionKind !== b.fragment.regionKind) return false;
1527
+ if (a.fragment.from !== b.fragment.from) return false;
1528
+ if (a.fragment.to !== b.fragment.to) return false;
1529
+ if (!rectEquals(a.frame, b.frame)) return false;
1530
+ if (a.lines.length !== b.lines.length) return false;
1531
+ for (let i = 0; i < a.lines.length; i += 1) {
1532
+ if (!rectEquals(a.lines[i].frame, b.lines[i].frame)) return false;
1533
+ }
1534
+ const aHash = decorationHashForBlock(a.frame, aIndex);
1535
+ const bHash = decorationHashForBlock(b.frame, bIndex);
1536
+ if (aHash !== bHash) return false;
1537
+ return true;
1538
+ }
1539
+ function decorationHashForBlock(blockFrame, index) {
1540
+ const tokens = [];
1541
+ for (const lane of [index.workflow, index.comments, index.revisions, index.search, index.locked]) {
1542
+ for (const entry of lane) {
1543
+ if (rectIntersects(entry.frame, blockFrame)) {
1544
+ tokens.push(`${entry.kind}:${entry.refId}`);
1545
+ }
1546
+ }
1547
+ }
1548
+ tokens.sort();
1549
+ return tokens.join("|");
1550
+ }
1551
+ function reservationsEqual(a, b) {
1552
+ return a.railLaneTwips === b.railLaneTwips && a.balloonLaneTwips === b.balloonLaneTwips && a.footnoteAreaTwips === b.footnoteAreaTwips && a.pageFrameWidthPx === b.pageFrameWidthPx && a.pageFrameHeightPx === b.pageFrameHeightPx;
1553
+ }
1554
+ var RECT_EPS = 0.1;
1555
+ function rectEquals(a, b) {
1556
+ return Math.abs(a.leftPx - b.leftPx) < RECT_EPS && Math.abs(a.topPx - b.topPx) < RECT_EPS && Math.abs(a.widthPx - b.widthPx) < RECT_EPS && Math.abs(a.heightPx - b.heightPx) < RECT_EPS;
1557
+ }
1558
+ function rectIntersects(a, b) {
1559
+ return !(a.leftPx + a.widthPx <= b.leftPx || b.leftPx + b.widthPx <= a.leftPx || a.topPx + a.heightPx <= b.topPx || b.topPx + b.heightPx <= a.topPx);
1560
+ }
1561
+
1562
+ // src/runtime/render/render-frame-types.ts
1563
+ var DEFAULT_PX_PER_TWIP = 96 / 1440;
1564
+ var EMPTY_DECORATION_INDEX = Object.freeze({
1565
+ workflow: Object.freeze([]),
1566
+ comments: Object.freeze([]),
1567
+ revisions: Object.freeze([]),
1568
+ search: Object.freeze([]),
1569
+ locked: Object.freeze([])
1570
+ });
1571
+
1205
1572
  // src/core/schema/text-schema.ts
1206
1573
  function parseTextStory(content) {
1207
1574
  const root = normalizeDocumentRoot(content);
@@ -2084,132 +2451,6 @@ function truncate(s) {
2084
2451
  // src/api/public-types.ts
2085
2452
  init_measurement_backend_canvas();
2086
2453
 
2087
- // src/runtime/story-context.ts
2088
- function collectSectionContexts(document2) {
2089
- const sections = [];
2090
- let sectionIndex = 0;
2091
- for (const block of document2.content.children) {
2092
- if (block.type !== "section_break") {
2093
- continue;
2094
- }
2095
- sections.push({
2096
- index: sectionIndex,
2097
- properties: block.sectionProperties
2098
- });
2099
- sectionIndex += 1;
2100
- }
2101
- sections.push({
2102
- index: sectionIndex,
2103
- properties: document2.subParts?.finalSectionProperties
2104
- });
2105
- return sections;
2106
- }
2107
- function resolveSectionVariants(kind, sectionIndex, explicitReferences, documents) {
2108
- if (explicitReferences && explicitReferences.length > 0) {
2109
- return explicitReferences.map((ref) => ({
2110
- variant: ref.variant,
2111
- relationshipId: ref.relationshipId
2112
- }));
2113
- }
2114
- return documents.filter(
2115
- (entry) => entry.sectionIndex === void 0 || entry.sectionIndex === sectionIndex
2116
- ).map((entry) => ({
2117
- variant: entry.variant,
2118
- relationshipId: entry.relationshipId
2119
- }));
2120
- }
2121
- function findHeaderFooterDocumentEntry(document2, target) {
2122
- const documents = target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? [];
2123
- const matches = documents.filter(
2124
- (entry) => entry.relationshipId === target.relationshipId && entry.variant === target.variant
2125
- );
2126
- if (matches.length === 0) {
2127
- return void 0;
2128
- }
2129
- if (target.sectionIndex !== void 0) {
2130
- return matches.find((entry) => entry.sectionIndex === target.sectionIndex) ?? matches.find((entry) => entry.sectionIndex === void 0) ?? matches[0];
2131
- }
2132
- return matches[0];
2133
- }
2134
- function sectionSupportsStoryTarget(document2, sectionIndex, target) {
2135
- if (!findHeaderFooterDocumentEntry(document2, target)) {
2136
- return false;
2137
- }
2138
- const section = collectSectionContexts(document2).find(
2139
- (candidate) => candidate.index === sectionIndex
2140
- );
2141
- if (!section) {
2142
- return false;
2143
- }
2144
- const variants = resolveSectionVariants(
2145
- target.kind,
2146
- sectionIndex,
2147
- target.kind === "header" ? section.properties?.headerReferences : section.properties?.footerReferences,
2148
- target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? []
2149
- );
2150
- return variants.some(
2151
- (variant) => variant.relationshipId === target.relationshipId && variant.variant === target.variant
2152
- );
2153
- }
2154
- function normalizeHeaderFooterTarget(document2, target, preferredSectionIndex) {
2155
- if (!findHeaderFooterDocumentEntry(document2, target)) {
2156
- return void 0;
2157
- }
2158
- if (target.sectionIndex !== void 0) {
2159
- return sectionSupportsStoryTarget(document2, target.sectionIndex, target) ? target : void 0;
2160
- }
2161
- const candidateIndexes = collectSectionContexts(document2).map((section) => section.index).filter(
2162
- (sectionIndex) => sectionSupportsStoryTarget(document2, sectionIndex, target)
2163
- );
2164
- if (candidateIndexes.length === 0) {
2165
- return void 0;
2166
- }
2167
- const resolvedSectionIndex = preferredSectionIndex !== void 0 && candidateIndexes.includes(preferredSectionIndex) ? preferredSectionIndex : candidateIndexes[0];
2168
- return {
2169
- ...target,
2170
- sectionIndex: resolvedSectionIndex
2171
- };
2172
- }
2173
-
2174
- // src/runtime/story-targeting.ts
2175
- function storyTargetKey(target) {
2176
- switch (target.kind) {
2177
- case "main":
2178
- return "main";
2179
- case "header":
2180
- return `header:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
2181
- case "footer":
2182
- return `footer:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
2183
- case "footnote":
2184
- return `footnote:${target.noteId}`;
2185
- case "endnote":
2186
- return `endnote:${target.noteId}`;
2187
- }
2188
- }
2189
- function getStoryBlocks(document2, target) {
2190
- if (target.kind === "main") {
2191
- return document2.content.children;
2192
- }
2193
- const subParts = document2.subParts;
2194
- if (!subParts) {
2195
- return [];
2196
- }
2197
- switch (target.kind) {
2198
- case "header": {
2199
- const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
2200
- return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
2201
- }
2202
- case "footer": {
2203
- const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
2204
- return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
2205
- }
2206
- case "footnote":
2207
- return subParts.footnoteCollection?.footnotes[target.noteId]?.blocks ?? [];
2208
- case "endnote":
2209
- return subParts.footnoteCollection?.endnotes[target.noteId]?.blocks ?? [];
2210
- }
2211
- }
2212
-
2213
2454
  // src/core/selection/anchor-conversion.ts
2214
2455
  var DEFAULT_PUBLIC_ASSOC = {
2215
2456
  start: -1,
@@ -2710,11 +2951,14 @@ function collectEditableTargetRefs(doc, cache) {
2710
2951
  collectEditableTargetsInBlocks(
2711
2952
  context.blocks,
2712
2953
  {
2954
+ doc,
2713
2955
  storyKey: context.storyKey,
2714
2956
  basePath: context.basePath,
2715
2957
  insideSdt: false,
2716
2958
  insideTextBox: false,
2717
- tableDepth: 0
2959
+ tableDepth: 0,
2960
+ numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
2961
+ numberingTargetRevisionHash: createNumberingTargetRevisionHash(doc)
2718
2962
  },
2719
2963
  targets,
2720
2964
  cache
@@ -2731,6 +2975,7 @@ function buildBlockCacheSignature(context, blockIndex) {
2731
2975
  const owner = tt?.editableOwnersByChildIndex?.get(blockIndex);
2732
2976
  return [
2733
2977
  context.storyKey,
2978
+ context.numberingTargetRevisionHash,
2734
2979
  context.insideSdt ? "1" : "0",
2735
2980
  context.insideTextBox ? "1" : "0",
2736
2981
  String(context.tableDepth),
@@ -2776,7 +3021,8 @@ function collectEditableTargetsInBlocks(blocks, context, targets, cache, blockIn
2776
3021
  editableParagraphTargetPosture(targetKind),
2777
3022
  context.contentControl,
2778
3023
  context.tableTarget,
2779
- context.tableTarget?.editableOwnersByChildIndex?.get(blockIndex)
3024
+ context.tableTarget?.editableOwnersByChildIndex?.get(blockIndex),
3025
+ resolveEditableParagraphListIdentity(block, context)
2780
3026
  )
2781
3027
  );
2782
3028
  }
@@ -3305,7 +3551,7 @@ function collectEditableTargetsInInlines(inlines, basePath, context, targets) {
3305
3551
  }
3306
3552
  }
3307
3553
  }
3308
- function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, targetPosture = { editability: "editable", posture: { blockers: [] } }, contentControl, tableTarget, editableOwner) {
3554
+ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, targetPosture = { editability: "editable", posture: { blockers: [] } }, contentControl, tableTarget, editableOwner, listIdentity) {
3309
3555
  const paragraphText = collectParagraphText(paragraph);
3310
3556
  const paragraphTextHash = hashText(paragraphText);
3311
3557
  const sourceRef = paragraph.sourceRef;
@@ -3316,19 +3562,39 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
3316
3562
  context: { storyKey, insideSdt: contentControl !== void 0 },
3317
3563
  ...tableTarget
3318
3564
  }) : void 0;
3319
- const listAddress = paragraph.numbering !== void 0 ? createCanonicalAddress({
3565
+ const listAddress = listIdentity !== void 0 ? createCanonicalAddress({
3320
3566
  addressKind: "list-item-text",
3321
3567
  storyKey,
3322
3568
  staleCheckKind: "paragraph",
3323
3569
  operationScope: "list-text",
3324
- sourceRefs: [sourceRef],
3570
+ sourceRefs: [
3571
+ sourceRef,
3572
+ listIdentity.paragraphNumberingSourceRef,
3573
+ listIdentity.instanceSourceRef,
3574
+ listIdentity.abstractSourceRef
3575
+ ],
3325
3576
  staleHash: paragraphTextHash,
3326
3577
  rangeBoundary: { boundaryKind: "list-item-text" },
3578
+ list: {
3579
+ numberingOrigin: listIdentity.numberingOrigin,
3580
+ numberingInstanceId: listIdentity.numberingInstanceId,
3581
+ ...listIdentity.abstractNumberingId !== void 0 ? { abstractNumberingId: listIdentity.abstractNumberingId } : {},
3582
+ level: listIdentity.level,
3583
+ ...listIdentity.overrideHash !== void 0 ? { overrideHash: listIdentity.overrideHash } : {},
3584
+ numberingCatalogHash: listIdentity.numberingCatalogHash
3585
+ },
3327
3586
  discriminator: {
3328
3587
  blockPath,
3329
- numberingInstanceId: paragraph.numbering.numberingInstanceId,
3330
- level: paragraph.numbering.level,
3588
+ numberingOrigin: listIdentity.numberingOrigin,
3589
+ numberingInstanceId: listIdentity.numberingInstanceId,
3590
+ abstractNumberingId: listIdentity.abstractNumberingId ?? null,
3591
+ level: listIdentity.level,
3592
+ overrideHash: listIdentity.overrideHash ?? null,
3593
+ numberingCatalogHash: listIdentity.numberingCatalogHash,
3331
3594
  sourceId: sourceRef?.sourceId ?? null,
3595
+ numberingSourceId: listIdentity.paragraphNumberingSourceRef?.sourceId ?? null,
3596
+ numberingInstanceSourceId: listIdentity.instanceSourceRef?.sourceId ?? null,
3597
+ abstractNumberingSourceId: listIdentity.abstractSourceRef?.sourceId ?? null,
3332
3598
  paraId: paragraph.wordExtensionIds?.paraId ?? null,
3333
3599
  textId: paragraph.wordExtensionIds?.textId ?? null
3334
3600
  }
@@ -3369,11 +3635,62 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
3369
3635
  blockType: "paragraph",
3370
3636
  ...paragraph.wordExtensionIds?.paraId !== void 0 ? { wordParaId: paragraph.wordExtensionIds.paraId } : {},
3371
3637
  ...paragraph.wordExtensionIds?.textId !== void 0 ? { wordTextId: paragraph.wordExtensionIds.textId } : {},
3372
- ...sourceRef !== void 0 ? { sourceRef } : {}
3638
+ ...sourceRef !== void 0 ? { sourceRef } : {},
3639
+ ...listIdentity !== void 0 ? {
3640
+ listNumberingOrigin: listIdentity.numberingOrigin,
3641
+ listNumberingInstanceId: listIdentity.numberingInstanceId,
3642
+ ...listIdentity.abstractNumberingId !== void 0 ? { listAbstractNumberingId: listIdentity.abstractNumberingId } : {},
3643
+ listLevel: listIdentity.level,
3644
+ ...listIdentity.overrideHash !== void 0 ? { listOverrideHash: listIdentity.overrideHash } : {},
3645
+ numberingCatalogHash: listIdentity.numberingCatalogHash
3646
+ } : {}
3373
3647
  },
3374
3648
  posture
3375
3649
  };
3376
3650
  }
3651
+ function resolveEditableParagraphListIdentity(paragraph, context) {
3652
+ const directNumbering = paragraph.numbering;
3653
+ const styleNumbering = directNumbering === void 0 && paragraph.styleId !== void 0 ? resolveParagraphStyleNumbering(context.doc, paragraph.styleId) : void 0;
3654
+ const numbering = directNumbering ?? styleNumbering;
3655
+ if (numbering === void 0) return void 0;
3656
+ const numberingCatalog = context.doc.numbering ?? { abstractDefinitions: {}, instances: {} };
3657
+ const instances = numberingCatalog.instances ?? {};
3658
+ const abstractDefinitions = numberingCatalog.abstractDefinitions ?? {};
3659
+ const instance = instances[numbering.numberingInstanceId];
3660
+ const abstractDefinition = instance !== void 0 ? abstractDefinitions[instance.abstractNumberingId] : void 0;
3661
+ const level = numbering.level ?? 0;
3662
+ const override = instance?.overrides.find((entry) => entry.level === level);
3663
+ const overrideHash = override !== void 0 ? hashText(JSON.stringify(numberingOverrideDiscriminator(override))) : void 0;
3664
+ return {
3665
+ numberingOrigin: directNumbering !== void 0 ? "paragraph" : "paragraph-style",
3666
+ numberingInstanceId: numbering.numberingInstanceId,
3667
+ ...instance?.abstractNumberingId !== void 0 ? { abstractNumberingId: instance.abstractNumberingId } : {},
3668
+ level,
3669
+ ...overrideHash !== void 0 ? { overrideHash } : {},
3670
+ numberingCatalogHash: context.numberingCatalogHash,
3671
+ ...directNumbering?.sourceRef !== void 0 ? { paragraphNumberingSourceRef: directNumbering.sourceRef } : {},
3672
+ ...instance?.sourceRef !== void 0 ? { instanceSourceRef: instance.sourceRef } : {},
3673
+ ...abstractDefinition?.sourceRef !== void 0 ? { abstractSourceRef: abstractDefinition.sourceRef } : {}
3674
+ };
3675
+ }
3676
+ function numberingOverrideDiscriminator(override) {
3677
+ return {
3678
+ level: override.level,
3679
+ startAt: override.startAt ?? null,
3680
+ sourceId: override.sourceRef?.sourceId ?? null,
3681
+ levelDefinition: override.levelDefinition === void 0 ? null : {
3682
+ sourceId: override.levelDefinition.sourceRef?.sourceId ?? null,
3683
+ format: override.levelDefinition.format ?? null,
3684
+ text: override.levelDefinition.text ?? null,
3685
+ startAt: override.levelDefinition.startAt ?? null,
3686
+ paragraphStyleId: override.levelDefinition.paragraphStyleId ?? null,
3687
+ isLegalNumbering: override.levelDefinition.isLegalNumbering ?? null,
3688
+ suffix: override.levelDefinition.suffix ?? null,
3689
+ restartAfterLevel: override.levelDefinition.restartAfterLevel ?? null,
3690
+ picBulletId: override.levelDefinition.picBulletId ?? null
3691
+ }
3692
+ };
3693
+ }
3377
3694
  function contentControlLocksContent(contentControl) {
3378
3695
  return contentControl?.lock !== void 0 && contentControl.lock !== "unlocked" && contentControl.lock !== "none";
3379
3696
  }
@@ -4142,6 +4459,7 @@ function createCanonicalAddress(input) {
4142
4459
  ...input.rowRange !== void 0 ? { rowRange: input.rowRange } : {},
4143
4460
  ...input.columnRange !== void 0 ? { columnRange: input.columnRange } : {},
4144
4461
  ...sourceHash !== void 0 ? { sourceJoinHash: sourceHash } : {},
4462
+ ...input.list !== void 0 ? { list: input.list } : {},
4145
4463
  ...input.secondaryStory === true ? { secondaryStory: true } : {},
4146
4464
  ...input.nestedTable === true ? { nestedTable: true } : {},
4147
4465
  ...input.insideSdt === true ? { insideSdt: true } : {},
@@ -4176,6 +4494,103 @@ function sourceJoinHash(refs) {
4176
4494
  if (sourceIds.length === 0) return void 0;
4177
4495
  return hashText(sourceIds.join("\0"));
4178
4496
  }
4497
+ var numberingCatalogHashCache = /* @__PURE__ */ new WeakMap();
4498
+ var numberingTargetHashCache = /* @__PURE__ */ new WeakMap();
4499
+ function createNumberingCatalogRevisionHash(doc) {
4500
+ const numbering = doc.numbering;
4501
+ if (numbering !== void 0) {
4502
+ const cached = numberingCatalogHashCache.get(numbering);
4503
+ if (cached !== void 0) return cached;
4504
+ const fresh = computeNumberingCatalogRevisionHash(doc);
4505
+ numberingCatalogHashCache.set(numbering, fresh);
4506
+ return fresh;
4507
+ }
4508
+ return computeNumberingCatalogRevisionHash(doc);
4509
+ }
4510
+ function computeNumberingCatalogRevisionHash(doc) {
4511
+ const catalog = doc.numbering ?? { abstractDefinitions: {}, instances: {} };
4512
+ const abstractDefinitions = catalog.abstractDefinitions ?? {};
4513
+ const instances = catalog.instances ?? {};
4514
+ const numPicBullets = catalog.numPicBullets ?? {};
4515
+ return hashText(JSON.stringify({
4516
+ abstractDefinitions: Object.keys(abstractDefinitions).sort().map((abstractNumberingId) => {
4517
+ const definition = abstractDefinitions[abstractNumberingId];
4518
+ return {
4519
+ abstractNumberingId,
4520
+ sourceId: definition.sourceRef?.sourceId ?? null,
4521
+ nsid: definition.nsid ?? null,
4522
+ tplc: definition.tplc ?? null,
4523
+ styleLink: definition.styleLink ?? null,
4524
+ numStyleLink: definition.numStyleLink ?? null,
4525
+ levels: definition.levels.map((level) => ({
4526
+ sourceId: level.sourceRef?.sourceId ?? null,
4527
+ level: level.level,
4528
+ format: level.format,
4529
+ text: level.text,
4530
+ startAt: level.startAt ?? null,
4531
+ paragraphStyleId: level.paragraphStyleId ?? null,
4532
+ isLegalNumbering: level.isLegalNumbering ?? null,
4533
+ suffix: level.suffix ?? null,
4534
+ restartAfterLevel: level.restartAfterLevel ?? null,
4535
+ picBulletId: level.picBulletId ?? null
4536
+ }))
4537
+ };
4538
+ }),
4539
+ instances: Object.keys(instances).sort().map((numberingInstanceId) => {
4540
+ const instance = instances[numberingInstanceId];
4541
+ return {
4542
+ numberingInstanceId,
4543
+ sourceId: instance.sourceRef?.sourceId ?? null,
4544
+ abstractNumberingId: instance.abstractNumberingId,
4545
+ overrides: instance.overrides.map(numberingOverrideDiscriminator)
4546
+ };
4547
+ }),
4548
+ numPicBullets: Object.keys(numPicBullets).sort().map((numPicBulletId) => {
4549
+ const picBullet = numPicBullets[numPicBulletId];
4550
+ return {
4551
+ numPicBulletId,
4552
+ sourceId: picBullet.sourceRef?.sourceId ?? null,
4553
+ mediaId: picBullet.mediaId ?? null,
4554
+ widthEmu: picBullet.widthEmu ?? null,
4555
+ heightEmu: picBullet.heightEmu ?? null
4556
+ };
4557
+ })
4558
+ }));
4559
+ }
4560
+ function createNumberingTargetRevisionHash(doc) {
4561
+ const numbering = doc.numbering;
4562
+ const styles = doc.styles;
4563
+ if (numbering !== void 0 && styles !== void 0) {
4564
+ let inner = numberingTargetHashCache.get(numbering);
4565
+ if (inner === void 0) {
4566
+ inner = /* @__PURE__ */ new WeakMap();
4567
+ numberingTargetHashCache.set(numbering, inner);
4568
+ }
4569
+ const cached = inner.get(styles);
4570
+ if (cached !== void 0) return cached;
4571
+ const fresh = computeNumberingTargetRevisionHash(doc);
4572
+ inner.set(styles, fresh);
4573
+ return fresh;
4574
+ }
4575
+ return computeNumberingTargetRevisionHash(doc);
4576
+ }
4577
+ function computeNumberingTargetRevisionHash(doc) {
4578
+ const paragraphStyles = doc.styles?.paragraphs ?? {};
4579
+ return hashText(JSON.stringify({
4580
+ // Reuses the memoized catalog hash on the hot path so a typing edit
4581
+ // pays for the catalog hash at most once across both helpers.
4582
+ numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
4583
+ paragraphStyleNumbering: Object.keys(paragraphStyles).sort().map((styleId) => {
4584
+ const style = paragraphStyles[styleId];
4585
+ return {
4586
+ styleId,
4587
+ basedOn: style.basedOn ?? null,
4588
+ numberingInstanceId: style.numbering?.numberingInstanceId ?? null,
4589
+ level: style.numbering?.level ?? null
4590
+ };
4591
+ })
4592
+ }));
4593
+ }
4179
4594
  function collectCanonicalStoryIdentities(doc) {
4180
4595
  const stories = [
4181
4596
  {
@@ -4307,7 +4722,7 @@ function resolveParagraphStyleNumbering(doc, styleId) {
4307
4722
  let currentStyleId = styleId;
4308
4723
  while (currentStyleId !== void 0 && !visited.has(currentStyleId)) {
4309
4724
  visited.add(currentStyleId);
4310
- const style = doc.styles.paragraphs[currentStyleId];
4725
+ const style = doc.styles?.paragraphs?.[currentStyleId];
4311
4726
  if (style === void 0) {
4312
4727
  return void 0;
4313
4728
  }
@@ -5863,6 +6278,10 @@ function createNumberingPrefixResolver(catalog) {
5863
6278
  ])
5864
6279
  ) : resolved.effectiveLevels;
5865
6280
  const picBulletId = resolved.effectiveLevel.picBulletId;
6281
+ const pictureBulletPosture = resolvePictureBulletRenderPosture(
6282
+ picBulletId,
6283
+ picBulletId != null ? catalog.numPicBullets?.[picBulletId] : void 0
6284
+ );
5866
6285
  const text = renderLevelText(
5867
6286
  resolved.effectiveLevel.text,
5868
6287
  workingState.counters,
@@ -5871,14 +6290,20 @@ function createNumberingPrefixResolver(catalog) {
5871
6290
  if (picBulletId == null && resolved.effectiveLevel.format !== "none" && text === null) {
5872
6291
  return null;
5873
6292
  }
5874
- const visibleText = resolved.effectiveLevel.format === "none" ? null : text;
6293
+ const visibleText = resolved.effectiveLevel.format === "none" ? null : text ?? pictureBulletPosture?.fallbackGlyph ?? null;
6294
+ const normalizedMarkerText = normalizeMarkerText(
6295
+ visibleText,
6296
+ resolved.effectiveLevel.format,
6297
+ resolved.geometry.markerRunProperties
6298
+ );
5875
6299
  const formatPosture = getNumberingFormatPosture(
5876
6300
  resolved.effectiveLevel.format,
5877
6301
  currentCounter
5878
6302
  );
5879
- const picBulletMediaId = picBulletId != null ? catalog.numPicBullets?.[picBulletId]?.mediaId : void 0;
6303
+ const picBulletMediaId = pictureBulletPosture?.mediaId;
5880
6304
  return {
5881
- text: visibleText,
6305
+ text: normalizedMarkerText.text,
6306
+ ...normalizedMarkerText.posture !== void 0 ? { markerTextPosture: normalizedMarkerText.posture } : {},
5882
6307
  level: resolved.effectiveLevel.level,
5883
6308
  format: resolved.effectiveLevel.format,
5884
6309
  ...formatPosture !== void 0 ? { formatPosture } : {},
@@ -5888,7 +6313,9 @@ function createNumberingPrefixResolver(catalog) {
5888
6313
  ...resolved.effectiveLevel.isLegalNumbering ? { isLegalNumbering: true } : {},
5889
6314
  ...resolved.geometry.markerRunProperties ? { markerRunProperties: resolved.geometry.markerRunProperties } : {},
5890
6315
  geometry: resolved.geometry,
5891
- ...picBulletMediaId != null ? { picBulletMediaId } : {}
6316
+ ...picBulletId != null ? { picBulletId } : {},
6317
+ ...picBulletMediaId != null ? { picBulletMediaId } : {},
6318
+ ...pictureBulletPosture !== void 0 ? { pictureBulletPosture } : {}
5892
6319
  };
5893
6320
  }
5894
6321
  return {
@@ -5904,6 +6331,69 @@ function createNumberingPrefixResolver(catalog) {
5904
6331
  }
5905
6332
  };
5906
6333
  }
6334
+ function normalizeMarkerText(text, format, markerRunProperties) {
6335
+ if (text === null || format !== "bullet") {
6336
+ return { text };
6337
+ }
6338
+ const fontFamily = getMarkerFontFamily(markerRunProperties);
6339
+ if (!isKnownSymbolBulletFont(fontFamily)) {
6340
+ return { text };
6341
+ }
6342
+ const renderedText = Array.from(text, (char) => SYMBOL_BULLET_GLYPH_MAP.get(char) ?? char).join("");
6343
+ if (renderedText === text) {
6344
+ return { text };
6345
+ }
6346
+ return {
6347
+ text: renderedText,
6348
+ posture: {
6349
+ status: "normalized",
6350
+ sourceText: text,
6351
+ renderedText,
6352
+ reason: "symbol-font-bullet-normalized",
6353
+ ...fontFamily ? { fontFamily } : {}
6354
+ }
6355
+ };
6356
+ }
6357
+ function getMarkerFontFamily(markerRunProperties) {
6358
+ return markerRunProperties?.fontFamilyAscii ?? markerRunProperties?.fontFamilyHAnsi ?? markerRunProperties?.fontFamilyEastAsia ?? markerRunProperties?.fontFamilyCs ?? markerRunProperties?.fontFamily;
6359
+ }
6360
+ function isKnownSymbolBulletFont(fontFamily) {
6361
+ return fontFamily !== void 0 && /^(?:symbol|wingdings|wingdings 2|wingdings 3|webdings)$/iu.test(
6362
+ fontFamily.trim()
6363
+ );
6364
+ }
6365
+ var SYMBOL_BULLET_GLYPH_MAP = /* @__PURE__ */ new Map([
6366
+ ["\uF0B7", "\u2022"],
6367
+ ["\uF0A7", "\u25AA"],
6368
+ ["\uF0FC", "\u2713"]
6369
+ ]);
6370
+ function resolvePictureBulletRenderPosture(picBulletId, picBullet) {
6371
+ if (picBulletId == null) return void 0;
6372
+ if (!picBullet) {
6373
+ return {
6374
+ status: "preserve-only",
6375
+ picBulletId,
6376
+ fallbackGlyph: "\u2022",
6377
+ reason: "picture-bullet-catalog-entry-missing"
6378
+ };
6379
+ }
6380
+ if (picBullet.mediaId) {
6381
+ return {
6382
+ status: "media-rendered",
6383
+ picBulletId,
6384
+ mediaId: picBullet.mediaId,
6385
+ ...picBullet.sourceRef ? { sourceRef: picBullet.sourceRef } : {},
6386
+ reason: "picture-bullet-media-rendered"
6387
+ };
6388
+ }
6389
+ return {
6390
+ status: "glyph-fallback",
6391
+ picBulletId,
6392
+ fallbackGlyph: "\u2022",
6393
+ ...picBullet.sourceRef ? { sourceRef: picBullet.sourceRef } : {},
6394
+ reason: "picture-bullet-media-unavailable"
6395
+ };
6396
+ }
5907
6397
  function getSequenceState(states, numberingInstanceId, options = { create: true }) {
5908
6398
  const existing = states.get(numberingInstanceId);
5909
6399
  if (existing) {
@@ -5966,7 +6456,7 @@ function getNumberingFormatPosture(format, value) {
5966
6456
  reason: registryEntry?.fallbackReason ?? "unsupported-numbering-format-decimal-fallback"
5967
6457
  };
5968
6458
  }
5969
- if (value !== void 0 && ((format === "upperRoman" || format === "lowerRoman") && (value <= 0 || value >= 4e3) || (format === "cardinalText" || format === "ordinalText") && (!Number.isInteger(value) || value < 1 || value > 999) || (format === "upperLetter" || format === "lowerLetter" || format === "chicago") && value < 1)) {
6459
+ if (value !== void 0 && (registryEntry.isInRange !== void 0 && !registryEntry.isInRange(value) || (format === "upperRoman" || format === "lowerRoman") && (value <= 0 || value >= 4e3) || (format === "cardinalText" || format === "ordinalText") && (!Number.isInteger(value) || value < 1 || value > 999) || (format === "upperLetter" || format === "lowerLetter" || format === "chicago") && value < 1)) {
5970
6460
  return {
5971
6461
  status: "approximated",
5972
6462
  requestedFormat: format,
@@ -6060,6 +6550,37 @@ var exactNumberingFormatEntries = [
6060
6550
  supportsMutation: true,
6061
6551
  render: toOrdinal2
6062
6552
  },
6553
+ {
6554
+ format: "decimalFullWidth",
6555
+ renderSupport: "supported",
6556
+ renderedFormat: "decimalFullWidth",
6557
+ supportsMutation: false,
6558
+ render: toFullWidthDecimal
6559
+ },
6560
+ {
6561
+ format: "decimalEnclosedCircle",
6562
+ renderSupport: "supported",
6563
+ renderedFormat: "decimalEnclosedCircle",
6564
+ supportsMutation: false,
6565
+ render: toCircledDecimal,
6566
+ isInRange: (value) => Number.isInteger(value) && value >= 0 && value <= 50
6567
+ },
6568
+ {
6569
+ format: "decimalEnclosedParen",
6570
+ renderSupport: "supported",
6571
+ renderedFormat: "decimalEnclosedParen",
6572
+ supportsMutation: false,
6573
+ render: (value) => Number.isInteger(value) && value > 0 ? `(${value})` : String(value),
6574
+ isInRange: (value) => Number.isInteger(value) && value > 0
6575
+ },
6576
+ {
6577
+ format: "decimalEnclosedFullstop",
6578
+ renderSupport: "supported",
6579
+ renderedFormat: "decimalEnclosedFullstop",
6580
+ supportsMutation: false,
6581
+ render: (value) => Number.isInteger(value) && value > 0 ? `${value}.` : String(value),
6582
+ isInRange: (value) => Number.isInteger(value) && value > 0
6583
+ },
6063
6584
  {
6064
6585
  format: "cardinalText",
6065
6586
  renderSupport: "supported",
@@ -6097,10 +6618,6 @@ var exactNumberingFormatEntries = [
6097
6618
  }
6098
6619
  ];
6099
6620
  var approximatedDecimalFormats = [
6100
- "decimalEnclosedCircle",
6101
- "decimalEnclosedFullstop",
6102
- "decimalEnclosedParen",
6103
- "decimalFullWidth",
6104
6621
  "decimalHalfWidth",
6105
6622
  "aiueo",
6106
6623
  "iroha",
@@ -6152,6 +6669,30 @@ function toOrdinal2(value) {
6152
6669
  return `${value}th`;
6153
6670
  }
6154
6671
  }
6672
+ function toFullWidthDecimal(value) {
6673
+ return String(value).replace(
6674
+ /[0-9]/g,
6675
+ (digit) => String.fromCharCode(65296 + Number.parseInt(digit, 10))
6676
+ );
6677
+ }
6678
+ var CIRCLED_DECIMAL_BY_VALUE = new Map([
6679
+ [0, "\u24EA"],
6680
+ ...Array.from({ length: 20 }, (_, index) => [
6681
+ index + 1,
6682
+ String.fromCodePoint(9312 + index)
6683
+ ]),
6684
+ ...Array.from({ length: 15 }, (_, index) => [
6685
+ index + 21,
6686
+ String.fromCodePoint(12881 + index)
6687
+ ]),
6688
+ ...Array.from({ length: 15 }, (_, index) => [
6689
+ index + 36,
6690
+ String.fromCodePoint(12977 + index)
6691
+ ])
6692
+ ]);
6693
+ function toCircledDecimal(value) {
6694
+ return CIRCLED_DECIMAL_BY_VALUE.get(value) ?? String(value);
6695
+ }
6155
6696
  function toAlphabetic2(value) {
6156
6697
  if (value <= 0) {
6157
6698
  return String(value);
@@ -6925,6 +7466,7 @@ function toNumberingLayoutInput(numbering) {
6925
7466
  const hangingTwips = textColumn?.hanging ?? numbering.geometry.indentation?.hanging ?? (typeof numbering.geometry.indentation?.firstLine === "number" && numbering.geometry.indentation.firstLine < 0 ? Math.abs(numbering.geometry.indentation.firstLine) : void 0);
6926
7467
  return {
6927
7468
  markerText: numbering.text,
7469
+ ...numbering.markerTextPosture ? { markerTextPosture: { ...numbering.markerTextPosture } } : {},
6928
7470
  ...numbering.markerRunProperties ? { markerRunFormatting: numbering.markerRunProperties } : {},
6929
7471
  markerSuffix: normalizeNumberingMarkerSuffix(numbering.suffix),
6930
7472
  ...markerLane ? { markerLaneStartTwips: markerLane.start } : {},
@@ -6937,7 +7479,9 @@ function toNumberingLayoutInput(numbering) {
6937
7479
  ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
6938
7480
  startAt: numbering.startAt,
6939
7481
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
6940
- ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {}
7482
+ ...numbering.picBulletId ? { pictureBulletId: numbering.picBulletId } : {},
7483
+ ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {},
7484
+ ...numbering.pictureBulletPosture ? { pictureBulletPosture: { ...numbering.pictureBulletPosture } } : {}
6941
7485
  };
6942
7486
  }
6943
7487
  function toFieldLayoutInput(entry, resolved, region) {
@@ -7449,6 +7993,7 @@ function buildEffectiveNumbering(detail) {
7449
7993
  const result = {
7450
7994
  level: detail.level,
7451
7995
  ...detail.text !== null ? { marker: detail.text } : {},
7996
+ ...detail.markerTextPosture ? { markerTextPosture: { ...detail.markerTextPosture } } : {},
7452
7997
  ...detail.markerRunProperties ? { markerRunFormatting: detail.markerRunProperties } : {},
7453
7998
  ...detail.geometry ? {
7454
7999
  indentation: {
@@ -7458,7 +8003,8 @@ function buildEffectiveNumbering(detail) {
7458
8003
  ...detail.geometry.tabStops && detail.geometry.tabStops.length > 0 ? { tab: detail.geometry.tabStops[0].position } : {}
7459
8004
  }
7460
8005
  } : {},
7461
- ...detail.picBulletMediaId ? { pictureBulletRef: detail.picBulletMediaId } : {}
8006
+ ...detail.picBulletMediaId ? { pictureBulletRef: detail.picBulletMediaId } : {},
8007
+ ...detail.pictureBulletPosture ? { pictureBulletPosture: { ...detail.pictureBulletPosture } } : {}
7462
8008
  };
7463
8009
  return result;
7464
8010
  }
@@ -9374,6 +9920,7 @@ function toSurfaceResolvedNumbering(numbering) {
9374
9920
  format: numbering.format,
9375
9921
  ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
9376
9922
  ...numbering.text !== null ? { text: numbering.text } : {},
9923
+ ...numbering.markerTextPosture !== void 0 ? { markerTextPosture: { ...numbering.markerTextPosture } } : {},
9377
9924
  startAt: numbering.startAt,
9378
9925
  ...numbering.paragraphStyleId ? { paragraphStyleId: numbering.paragraphStyleId } : {},
9379
9926
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
@@ -9386,7 +9933,9 @@ function toSurfaceResolvedNumbering(numbering) {
9386
9933
  ...numbering.geometry.markerLane ? { markerLane: { ...numbering.geometry.markerLane } } : {},
9387
9934
  ...numbering.geometry.textColumn ? { textColumn: { ...numbering.geometry.textColumn } } : {}
9388
9935
  },
9389
- ...numbering.picBulletMediaId ? { picBulletMediaId: numbering.picBulletMediaId } : {}
9936
+ ...numbering.picBulletId ? { picBulletId: numbering.picBulletId } : {},
9937
+ ...numbering.picBulletMediaId ? { picBulletMediaId: numbering.picBulletMediaId } : {},
9938
+ ...numbering.pictureBulletPosture ? { pictureBulletPosture: { ...numbering.pictureBulletPosture } } : {}
9390
9939
  };
9391
9940
  }
9392
9941
  function describePreservedInlinePreview(payloadReference) {
@@ -13458,6 +14007,11 @@ function freezeNumberingLayoutFacts(numbering) {
13458
14007
  if (numbering.numberingSourceRef) Object.freeze(numbering.numberingSourceRef);
13459
14008
  if (numbering.numberingInstanceSourceRef) Object.freeze(numbering.numberingInstanceSourceRef);
13460
14009
  if (numbering.abstractNumberingSourceRef) Object.freeze(numbering.abstractNumberingSourceRef);
14010
+ if (numbering.markerTextPosture) Object.freeze(numbering.markerTextPosture);
14011
+ if (numbering.pictureBulletPosture) {
14012
+ if (numbering.pictureBulletPosture.sourceRef) Object.freeze(numbering.pictureBulletPosture.sourceRef);
14013
+ Object.freeze(numbering.pictureBulletPosture);
14014
+ }
13461
14015
  if (numbering.markerLane) Object.freeze(numbering.markerLane);
13462
14016
  if (numbering.textColumn) Object.freeze(numbering.textColumn);
13463
14017
  if (numbering.tabStops) {
@@ -14410,8 +14964,17 @@ function collectNumberingLayoutFacts(block) {
14410
14964
  ...block.resolvedNumbering?.format !== void 0 ? { format: block.resolvedNumbering.format } : {},
14411
14965
  ...block.resolvedNumbering?.formatPosture !== void 0 ? { formatPosture: { ...block.resolvedNumbering.formatPosture } } : {},
14412
14966
  ...block.numberingPrefix !== void 0 ? { markerText: block.numberingPrefix } : {},
14967
+ ...block.resolvedNumbering?.markerTextPosture !== void 0 ? { markerTextPosture: { ...block.resolvedNumbering.markerTextPosture } } : {},
14413
14968
  ...block.numberingSuffix !== void 0 ? { markerSuffix: block.numberingSuffix } : {},
14414
14969
  ...block.resolvedNumbering?.geometry.markerJustification !== void 0 ? { markerJustification: block.resolvedNumbering.geometry.markerJustification } : {},
14970
+ ...block.resolvedNumbering?.picBulletId !== void 0 ? { picBulletId: block.resolvedNumbering.picBulletId } : {},
14971
+ ...block.resolvedNumbering?.picBulletMediaId !== void 0 ? { picBulletMediaId: block.resolvedNumbering.picBulletMediaId } : {},
14972
+ ...block.resolvedNumbering?.pictureBulletPosture !== void 0 ? {
14973
+ pictureBulletPosture: {
14974
+ ...block.resolvedNumbering.pictureBulletPosture,
14975
+ ...block.resolvedNumbering.pictureBulletPosture.sourceRef !== void 0 ? { sourceRef: { ...block.resolvedNumbering.pictureBulletPosture.sourceRef } } : {}
14976
+ }
14977
+ } : {},
14415
14978
  ...markerLane ? {
14416
14979
  markerLane: {
14417
14980
  startTwips: markerLane.start,
@@ -15200,7 +15763,7 @@ function fnv1a2(input) {
15200
15763
  }
15201
15764
 
15202
15765
  // src/runtime/layout/layout-engine-version.ts
15203
- var LAYOUT_ENGINE_VERSION = 93;
15766
+ var LAYOUT_ENGINE_VERSION = 94;
15204
15767
 
15205
15768
  // src/runtime/layout/layout-engine-instance.ts
15206
15769
  var FULL_VIEWPORT_WINDOW_KEY = "full";
@@ -15426,11 +15989,45 @@ function createLayoutEngine(options = {}) {
15426
15989
  const telemetryBus = options.telemetryBus;
15427
15990
  const dirtyFieldFamilies = /* @__PURE__ */ new Set();
15428
15991
  const listeners = /* @__PURE__ */ new Set();
15429
- let cachedKey = null;
15430
- let cachedGraph = null;
15431
- let cachedFormatting = null;
15432
- let cachedMapper = null;
15992
+ let cachedFull = null;
15993
+ let cachedWindowed = null;
15433
15994
  let previousPageCount = 0;
15995
+ function isFullViewportKey(key) {
15996
+ return key === FULL_VIEWPORT_WINDOW_KEY;
15997
+ }
15998
+ function getCachedSlot(viewportWindowKeyValue) {
15999
+ return isFullViewportKey(viewportWindowKeyValue) ? cachedFull : cachedWindowed;
16000
+ }
16001
+ function preferredCachedGraph() {
16002
+ return cachedFull?.graph ?? cachedWindowed?.graph ?? null;
16003
+ }
16004
+ function clearAllSlots() {
16005
+ cachedFull = null;
16006
+ cachedWindowed = null;
16007
+ }
16008
+ function clearWindowedSlot() {
16009
+ cachedWindowed = null;
16010
+ }
16011
+ function evictStaleSiblingSlot(freshKey) {
16012
+ const sibling = isFullViewportKey(freshKey.viewportWindowKey) ? cachedWindowed : cachedFull;
16013
+ if (sibling === null) return;
16014
+ if (sibling.key.content === freshKey.content && sibling.key.styles === freshKey.styles && sibling.key.subParts === freshKey.subParts) {
16015
+ return;
16016
+ }
16017
+ if (isFullViewportKey(freshKey.viewportWindowKey)) {
16018
+ cachedWindowed = null;
16019
+ } else {
16020
+ cachedFull = null;
16021
+ }
16022
+ }
16023
+ function commitSlot(slot) {
16024
+ if (isFullViewportKey(slot.key.viewportWindowKey)) {
16025
+ cachedFull = slot;
16026
+ } else {
16027
+ cachedWindowed = slot;
16028
+ }
16029
+ evictStaleSiblingSlot(slot.key);
16030
+ }
15434
16031
  let pendingInvalidation = null;
15435
16032
  function emit(event) {
15436
16033
  for (const listener of listeners) {
@@ -15576,27 +16173,31 @@ function createLayoutEngine(options = {}) {
15576
16173
  subParts: document2.subParts,
15577
16174
  anchors: layoutInputs.anchors
15578
16175
  });
16176
+ const priorGraphForMaterialization = preferredCachedGraph();
15579
16177
  const graph = applyViewportWindowMaterialization(
15580
16178
  measuredGraph,
15581
16179
  viewportWindow,
15582
- cachedGraph
16180
+ priorGraphForMaterialization
15583
16181
  );
15584
- const dirtyFamilies = computeFieldDirtiness(cachedGraph, graph);
16182
+ const priorGraphForFieldDirtiness = preferredCachedGraph();
16183
+ const dirtyFamilies = computeFieldDirtiness(priorGraphForFieldDirtiness, graph);
15585
16184
  for (const family of dirtyFamilies) {
15586
16185
  dirtyFieldFamilies.add(family);
15587
16186
  }
15588
16187
  const formatting = buildResolvedFormattingState(document2, mainSurface);
15589
16188
  const currentPageCount = graph.contentPageCount;
15590
16189
  const pageCountDelta = currentPageCount !== previousPageCount ? { previous: previousPageCount, current: currentPageCount } : void 0;
15591
- cachedKey = {
15592
- content: document2.content,
15593
- styles: document2.styles,
15594
- subParts: document2.subParts,
15595
- viewportWindowKey: viewportWindowKey(viewportWindow)
15596
- };
15597
- cachedGraph = graph;
15598
- cachedFormatting = formatting;
15599
- cachedMapper = createPageFragmentMapper(graph);
16190
+ commitSlot({
16191
+ key: {
16192
+ content: document2.content,
16193
+ styles: document2.styles,
16194
+ subParts: document2.subParts,
16195
+ viewportWindowKey: viewportWindowKey(viewportWindow)
16196
+ },
16197
+ graph,
16198
+ formatting,
16199
+ mapper: createPageFragmentMapper(graph)
16200
+ });
15600
16201
  if (pageCountDelta) {
15601
16202
  emit({
15602
16203
  kind: "page_count_changed",
@@ -15637,7 +16238,7 @@ function createLayoutEngine(options = {}) {
15637
16238
  return graph;
15638
16239
  }
15639
16240
  function incrementalRelayout(input, pending) {
15640
- const priorGraph = cachedGraph;
16241
+ const priorGraph = cachedFull?.graph ?? null;
15641
16242
  const range = pending.result.dirtyPageRange;
15642
16243
  if (!priorGraph || !range) return null;
15643
16244
  const telemetryOn = telemetryBus?.isEnabled("layout") ?? false;
@@ -15730,6 +16331,22 @@ function createLayoutEngine(options = {}) {
15730
16331
  deriveDocumentPageSnapshots(splicedGraph)
15731
16332
  );
15732
16333
  const pageCountDelta = currentPageCount !== previousPageCount ? { previous: previousPageCount, current: currentPageCount } : void 0;
16334
+ const priorMapper = cachedFull?.mapper ?? null;
16335
+ commitSlot({
16336
+ key: {
16337
+ content: document2.content,
16338
+ styles: document2.styles,
16339
+ subParts: document2.subParts,
16340
+ viewportWindowKey: FULL_VIEWPORT_WINDOW_KEY
16341
+ },
16342
+ graph: splicedGraph,
16343
+ formatting,
16344
+ mapper: rebuildMapper(
16345
+ priorMapper ?? createPageFragmentMapper(splicedGraph),
16346
+ splicedGraph,
16347
+ firstDirty
16348
+ )
16349
+ });
15733
16350
  if (pageCountDelta) {
15734
16351
  emit({
15735
16352
  kind: "page_count_changed",
@@ -15759,19 +16376,6 @@ function createLayoutEngine(options = {}) {
15759
16376
  ...dirtyFamilies.length > 0 ? { dirtyFieldFamilies: dirtyFamilies } : {},
15760
16377
  ...pageCountDelta ? { pageCountDelta } : {}
15761
16378
  });
15762
- cachedKey = {
15763
- content: document2.content,
15764
- styles: document2.styles,
15765
- subParts: document2.subParts,
15766
- viewportWindowKey: FULL_VIEWPORT_WINDOW_KEY
15767
- };
15768
- cachedGraph = splicedGraph;
15769
- cachedFormatting = formatting;
15770
- cachedMapper = rebuildMapper(
15771
- cachedMapper ?? createPageFragmentMapper(splicedGraph),
15772
- splicedGraph,
15773
- firstDirty
15774
- );
15775
16379
  if (telemetryOn) {
15776
16380
  emitRecomputeCompleted(
15777
16381
  "bounded",
@@ -15788,13 +16392,14 @@ function createLayoutEngine(options = {}) {
15788
16392
  const document2 = input.document;
15789
16393
  const normalizedWindow = normalizeViewportPageWindow(input.viewportPageWindow);
15790
16394
  const currentViewportWindowKey = viewportWindowKey(normalizedWindow);
15791
- const keyEqual = cachedGraph !== null && cachedKey !== null && cachedKey.content === document2.content && cachedKey.styles === document2.styles && cachedKey.subParts === document2.subParts && cachedKey.viewportWindowKey === currentViewportWindowKey;
16395
+ const slot = getCachedSlot(currentViewportWindowKey);
16396
+ const keyEqual = slot !== null && slot.key.content === document2.content && slot.key.styles === document2.styles && slot.key.subParts === document2.subParts && slot.key.viewportWindowKey === currentViewportWindowKey;
15792
16397
  if (keyEqual && pendingInvalidation === null) {
15793
- return cachedGraph;
16398
+ return slot.graph;
15794
16399
  }
15795
16400
  const pending = pendingInvalidation;
15796
16401
  pendingInvalidation = null;
15797
- if (pending !== null && pending.result.scope === "bounded" && cachedGraph !== null && normalizedWindow === void 0) {
16402
+ if (pending !== null && pending.result.scope === "bounded" && cachedFull !== null && normalizedWindow === void 0) {
15798
16403
  const spliced = incrementalRelayout(input, pending);
15799
16404
  if (spliced !== null) {
15800
16405
  return spliced;
@@ -15803,16 +16408,39 @@ function createLayoutEngine(options = {}) {
15803
16408
  }
15804
16409
  return fullRebuild(input, pending?.reason);
15805
16410
  }
16411
+ function ensureSlotMapperAndFormatting(slot, document2) {
16412
+ if (slot.mapper === null) {
16413
+ slot.mapper = createPageFragmentMapper(slot.graph);
16414
+ }
16415
+ if (slot.formatting === null) {
16416
+ const mainSurface = createEditorSurfaceSnapshot(
16417
+ document2,
16418
+ createSelectionSnapshot(0, 0),
16419
+ MAIN_STORY_TARGET
16420
+ );
16421
+ slot.formatting = buildResolvedFormattingState(document2, mainSurface);
16422
+ }
16423
+ }
15806
16424
  function getMapper(input) {
15807
16425
  getGraphInternal(input);
15808
- return cachedMapper;
16426
+ const currentViewportWindowKey = viewportWindowKey(
16427
+ normalizeViewportPageWindow(input.viewportPageWindow)
16428
+ );
16429
+ const slot = getCachedSlot(currentViewportWindowKey);
16430
+ ensureSlotMapperAndFormatting(slot, input.document);
16431
+ return slot.mapper;
15809
16432
  }
15810
16433
  function getFormatting(input) {
15811
16434
  getGraphInternal(input);
15812
- return cachedFormatting;
16435
+ const currentViewportWindowKey = viewportWindowKey(
16436
+ normalizeViewportPageWindow(input.viewportPageWindow)
16437
+ );
16438
+ const slot = getCachedSlot(currentViewportWindowKey);
16439
+ ensureSlotMapperAndFormatting(slot, input.document);
16440
+ return slot.formatting;
15813
16441
  }
15814
16442
  if (autoUpgradeToCanvas && options.measurementProvider === void 0 && typeof document !== "undefined" && typeof HTMLCanvasElement !== "undefined") {
15815
- const readCachedRevision = () => cachedGraph?.revision ?? 0;
16443
+ const readCachedRevision = () => preferredCachedGraph()?.revision ?? 0;
15816
16444
  void (async () => {
15817
16445
  try {
15818
16446
  const mod = await Promise.resolve().then(() => (init_measurement_backend_canvas(), measurement_backend_canvas_exports));
@@ -15822,10 +16450,7 @@ function createLayoutEngine(options = {}) {
15822
16450
  options.measurementCache,
15823
16451
  telemetryBus
15824
16452
  );
15825
- cachedKey = null;
15826
- cachedGraph = null;
15827
- cachedFormatting = null;
15828
- cachedMapper = null;
16453
+ clearAllSlots();
15829
16454
  emit({
15830
16455
  kind: "measurement_backend_ready",
15831
16456
  revision: readCachedRevision(),
@@ -15869,22 +16494,19 @@ function createLayoutEngine(options = {}) {
15869
16494
  return getMapper(input);
15870
16495
  },
15871
16496
  invalidate(reason) {
15872
- const result = analyzeInvalidation(reason, cachedGraph);
16497
+ const result = analyzeInvalidation(reason, preferredCachedGraph());
15873
16498
  for (const family of result.dirtyFieldFamilies) {
15874
16499
  dirtyFieldFamilies.add(family);
15875
16500
  }
15876
16501
  if (result.scope === "bounded") {
15877
16502
  pendingInvalidation = { reason, result };
15878
16503
  } else {
15879
- cachedKey = null;
15880
- cachedGraph = null;
15881
- cachedFormatting = null;
15882
- cachedMapper = null;
16504
+ clearAllSlots();
15883
16505
  pendingInvalidation = { reason, result };
15884
16506
  }
15885
16507
  },
15886
16508
  analyzeInvalidation(reason) {
15887
- return analyzeInvalidation(reason, cachedGraph);
16509
+ return analyzeInvalidation(reason, preferredCachedGraph());
15888
16510
  },
15889
16511
  getDirtyFieldFamilies() {
15890
16512
  return Array.from(dirtyFieldFamilies);
@@ -15912,14 +16534,11 @@ function createLayoutEngine(options = {}) {
15912
16534
  telemetryBus
15913
16535
  );
15914
16536
  if (previousFidelity !== provider.fidelity) {
15915
- cachedKey = null;
15916
- cachedGraph = null;
15917
- cachedFormatting = null;
15918
- cachedMapper = null;
16537
+ clearAllSlots();
15919
16538
  }
15920
16539
  emit({
15921
16540
  kind: "measurement_backend_ready",
15922
- revision: cachedGraph?.revision ?? 0,
16541
+ revision: preferredCachedGraph()?.revision ?? 0,
15923
16542
  fidelity: provider.fidelity
15924
16543
  });
15925
16544
  },
@@ -15934,30 +16553,33 @@ function createLayoutEngine(options = {}) {
15934
16553
  */
15935
16554
  invalidateMeasurementCache() {
15936
16555
  measurementProvider.invalidateCache();
15937
- cachedKey = null;
15938
- cachedGraph = null;
15939
- cachedFormatting = null;
15940
- cachedMapper = null;
16556
+ clearAllSlots();
15941
16557
  },
15942
16558
  getMeasurementCacheStats() {
15943
16559
  if (!isCachedLayoutMeasurementProvider(measurementProvider)) return null;
15944
16560
  return measurementProvider.measurementCacheStats();
15945
16561
  },
15946
16562
  /**
15947
- * L7 Phase 2.5 — seed the cached graph from a prerender envelope.
15948
- * Populates both `cachedGraph` and `cachedKey` (keyed on the provided
15949
- * document's identity-equal slots) so the next getPageGraph query
15950
- * returns the seeded graph directly. Any subsequent mutation
15951
- * invalidates normally through the existing path.
16563
+ * L7 Phase 2.5 — seed the full-slot cached graph from a prerender
16564
+ * envelope. Populates the full slot (graph + key, with formatting and
16565
+ * mapper computed lazily on first read) so the next viewport-
16566
+ * independent `getPageGraph` query returns the seeded graph directly.
16567
+ * Any subsequent mutation invalidates normally through the existing
16568
+ * path; sibling eviction in `commitSlot` clears `cachedWindowed` if
16569
+ * it carried a different document tuple.
15952
16570
  */
15953
16571
  seedCachedGraph(graph, document2) {
15954
- cachedGraph = graph;
15955
- cachedKey = {
15956
- content: document2.content,
15957
- styles: document2.styles,
15958
- subParts: document2.subParts,
15959
- viewportWindowKey: FULL_VIEWPORT_WINDOW_KEY
15960
- };
16572
+ commitSlot({
16573
+ key: {
16574
+ content: document2.content,
16575
+ styles: document2.styles,
16576
+ subParts: document2.subParts,
16577
+ viewportWindowKey: FULL_VIEWPORT_WINDOW_KEY
16578
+ },
16579
+ graph,
16580
+ formatting: null,
16581
+ mapper: null
16582
+ });
15961
16583
  previousPageCount = graph.contentPageCount;
15962
16584
  }
15963
16585
  };
@@ -16231,16 +16853,6 @@ function resolveProjectedRuntimeRange(offsetMap, from, to) {
16231
16853
  return { from: runtimeFrom, to: runtimeTo };
16232
16854
  }
16233
16855
 
16234
- // src/runtime/render/render-frame-types.ts
16235
- var DEFAULT_PX_PER_TWIP = 96 / 1440;
16236
- var EMPTY_DECORATION_INDEX = Object.freeze({
16237
- workflow: Object.freeze([]),
16238
- comments: Object.freeze([]),
16239
- revisions: Object.freeze([]),
16240
- search: Object.freeze([]),
16241
- locked: Object.freeze([])
16242
- });
16243
-
16244
16856
  // src/runtime/markdown-sanitizer.ts
16245
16857
  function sanitizeMarkdown(raw) {
16246
16858
  let sanitized = false;
@@ -16361,6 +16973,7 @@ var MetadataResolverMissingError = class extends Error {
16361
16973
  buildPagePreviewMaps,
16362
16974
  buildSearchPattern,
16363
16975
  createCanvasBackend,
16976
+ createPagePatchPlan,
16364
16977
  createPublicNodeAnchor,
16365
16978
  createPublicRangeAnchor,
16366
16979
  createScopeTagRegistry,