pptx-react-viewer 3.15.0 → 3.16.1

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 (136) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/{AiChatPanel-7CWOJ3PS.js → AiChatPanel-BUKJCMUY.js} +24 -24
  3. package/dist/AiChatPanel-BUKJCMUY.js.br +0 -0
  4. package/dist/AiChatPanel-BUKJCMUY.js.gz +0 -0
  5. package/dist/{AiChatPanel-TBIAQSZ7.mjs → AiChatPanel-US56QZBD.mjs} +3 -3
  6. package/dist/AiChatPanel-US56QZBD.mjs.br +0 -0
  7. package/dist/AiChatPanel-US56QZBD.mjs.gz +0 -0
  8. package/dist/{Area3DChartScene-6FFBYPHF.mjs → Area3DChartScene-6E4QEVTU.mjs} +1 -1
  9. package/dist/Area3DChartScene-6E4QEVTU.mjs.br +0 -0
  10. package/dist/Area3DChartScene-6E4QEVTU.mjs.gz +0 -0
  11. package/dist/{Area3DChartScene-ZJYR6K66.js → Area3DChartScene-APGQOK5A.js} +2 -2
  12. package/dist/{Area3DChartScene-ZJYR6K66.js.br → Area3DChartScene-APGQOK5A.js.br} +0 -0
  13. package/dist/Area3DChartScene-APGQOK5A.js.gz +0 -0
  14. package/dist/{Bar3DChartScene-42MWINQX.mjs → Bar3DChartScene-5GRGZFE4.mjs} +1 -1
  15. package/dist/Bar3DChartScene-5GRGZFE4.mjs.br +0 -0
  16. package/dist/Bar3DChartScene-5GRGZFE4.mjs.gz +0 -0
  17. package/dist/{Bar3DChartScene-JP3BXEZW.js → Bar3DChartScene-F4B5TNJR.js} +2 -2
  18. package/dist/{Bar3DChartScene-JP3BXEZW.js.br → Bar3DChartScene-F4B5TNJR.js.br} +0 -0
  19. package/dist/Bar3DChartScene-F4B5TNJR.js.gz +0 -0
  20. package/dist/{Line3DChartScene-YVCSJMWK.mjs → Line3DChartScene-2VRLE5RI.mjs} +1 -1
  21. package/dist/Line3DChartScene-2VRLE5RI.mjs.br +0 -0
  22. package/dist/Line3DChartScene-2VRLE5RI.mjs.gz +0 -0
  23. package/dist/{Line3DChartScene-JK3AELXZ.js → Line3DChartScene-6FUMMX2T.js} +2 -2
  24. package/dist/{Line3DChartScene-JK3AELXZ.js.br → Line3DChartScene-6FUMMX2T.js.br} +0 -0
  25. package/dist/Line3DChartScene-6FUMMX2T.js.gz +0 -0
  26. package/dist/{Model3DScene-N6UIMN7T.js → Model3DScene-2MGI3CB6.js} +2 -2
  27. package/dist/Model3DScene-2MGI3CB6.js.br +0 -0
  28. package/dist/Model3DScene-2MGI3CB6.js.gz +0 -0
  29. package/dist/{Model3DScene-OXWSYHHK.mjs → Model3DScene-TCIKWJ7R.mjs} +1 -1
  30. package/dist/{Model3DScene-OXWSYHHK.mjs.br → Model3DScene-TCIKWJ7R.mjs.br} +0 -0
  31. package/dist/Model3DScene-TCIKWJ7R.mjs.gz +0 -0
  32. package/dist/{PieChart3DScene-XK4ETZJC.mjs → PieChart3DScene-O5NZKI4T.mjs} +1 -1
  33. package/dist/{PieChart3DScene-XK4ETZJC.mjs.br → PieChart3DScene-O5NZKI4T.mjs.br} +0 -0
  34. package/dist/PieChart3DScene-O5NZKI4T.mjs.gz +0 -0
  35. package/dist/{PieChart3DScene-Q2Z3ECL4.js → PieChart3DScene-OFZEEZRO.js} +2 -2
  36. package/dist/{PieChart3DScene-Q2Z3ECL4.js.br → PieChart3DScene-OFZEEZRO.js.br} +0 -0
  37. package/dist/PieChart3DScene-OFZEEZRO.js.gz +0 -0
  38. package/dist/{SurfaceChart3DScene-ULBUIF7T.js → SurfaceChart3DScene-EK7KFNUQ.js} +2 -2
  39. package/dist/{SurfaceChart3DScene-ULBUIF7T.js.br → SurfaceChart3DScene-EK7KFNUQ.js.br} +0 -0
  40. package/dist/SurfaceChart3DScene-EK7KFNUQ.js.gz +0 -0
  41. package/dist/{SurfaceChart3DScene-KNWMKMOL.mjs → SurfaceChart3DScene-WXPQGMT3.mjs} +1 -1
  42. package/dist/SurfaceChart3DScene-WXPQGMT3.mjs.br +0 -0
  43. package/dist/SurfaceChart3DScene-WXPQGMT3.mjs.gz +0 -0
  44. package/dist/{chunk-YNTZCMRI.mjs → chunk-2DZJJ3VO.mjs} +1145 -435
  45. package/dist/chunk-2DZJJ3VO.mjs.br +0 -0
  46. package/dist/chunk-2DZJJ3VO.mjs.gz +0 -0
  47. package/dist/{chunk-GLY4OPMY.js → chunk-2J64KPXY.js} +167 -167
  48. package/dist/chunk-2J64KPXY.js.br +0 -0
  49. package/dist/chunk-2J64KPXY.js.gz +0 -0
  50. package/dist/{chunk-C4Q4WYAJ.mjs → chunk-BDQBJ3AM.mjs} +12 -34
  51. package/dist/chunk-BDQBJ3AM.mjs.br +0 -0
  52. package/dist/chunk-BDQBJ3AM.mjs.gz +0 -0
  53. package/dist/{chunk-VVJTEFGP.js → chunk-C553GQRH.js} +5 -5
  54. package/dist/chunk-C553GQRH.js.br +0 -0
  55. package/dist/chunk-C553GQRH.js.gz +0 -0
  56. package/dist/{chunk-Q6CSZ7VM.js → chunk-CPWFKDGB.js} +1292 -1292
  57. package/dist/chunk-CPWFKDGB.js.br +0 -0
  58. package/dist/chunk-CPWFKDGB.js.gz +0 -0
  59. package/dist/{chunk-6547ZWC7.mjs → chunk-GQVOQPNT.mjs} +15 -15
  60. package/dist/chunk-GQVOQPNT.mjs.br +0 -0
  61. package/dist/chunk-GQVOQPNT.mjs.gz +0 -0
  62. package/dist/{chunk-5KAMDV37.js → chunk-LDFWF2KT.js} +1147 -439
  63. package/dist/chunk-LDFWF2KT.js.br +0 -0
  64. package/dist/chunk-LDFWF2KT.js.gz +0 -0
  65. package/dist/{chunk-LAB7WX2N.js → chunk-Q2EGTNCU.js} +456 -478
  66. package/dist/chunk-Q2EGTNCU.js.br +0 -0
  67. package/dist/chunk-Q2EGTNCU.js.gz +0 -0
  68. package/dist/{chunk-AT4BJKON.mjs → chunk-UISMOSNU.mjs} +1 -1
  69. package/dist/chunk-UISMOSNU.mjs.br +0 -0
  70. package/dist/chunk-UISMOSNU.mjs.gz +0 -0
  71. package/dist/{chunk-J7Q7AGN7.mjs → chunk-VK3ASDDP.mjs} +1 -1
  72. package/dist/chunk-VK3ASDDP.mjs.br +0 -0
  73. package/dist/chunk-VK3ASDDP.mjs.gz +0 -0
  74. package/dist/index.d.ts +2 -0
  75. package/dist/index.js +45 -45
  76. package/dist/index.js.br +0 -0
  77. package/dist/index.js.gz +0 -0
  78. package/dist/index.mjs +5 -5
  79. package/dist/index.mjs.br +0 -0
  80. package/dist/index.mjs.gz +0 -0
  81. package/dist/internals.d.ts +2 -0
  82. package/dist/internals.js +78 -78
  83. package/dist/internals.js.br +0 -0
  84. package/dist/internals.js.gz +0 -0
  85. package/dist/internals.mjs +3 -3
  86. package/dist/internals.mjs.br +0 -0
  87. package/dist/internals.mjs.gz +0 -0
  88. package/dist/viewer/index.d.ts +2 -0
  89. package/dist/viewer/index.js +26 -26
  90. package/dist/viewer/index.js.br +0 -0
  91. package/dist/viewer/index.js.gz +0 -0
  92. package/dist/viewer/index.mjs +5 -5
  93. package/dist/viewer/index.mjs.br +0 -0
  94. package/dist/viewer/index.mjs.gz +0 -0
  95. package/package.json +2 -2
  96. package/dist/AiChatPanel-7CWOJ3PS.js.br +0 -0
  97. package/dist/AiChatPanel-7CWOJ3PS.js.gz +0 -0
  98. package/dist/AiChatPanel-TBIAQSZ7.mjs.br +0 -0
  99. package/dist/AiChatPanel-TBIAQSZ7.mjs.gz +0 -0
  100. package/dist/Area3DChartScene-6FFBYPHF.mjs.br +0 -0
  101. package/dist/Area3DChartScene-6FFBYPHF.mjs.gz +0 -0
  102. package/dist/Area3DChartScene-ZJYR6K66.js.gz +0 -0
  103. package/dist/Bar3DChartScene-42MWINQX.mjs.br +0 -0
  104. package/dist/Bar3DChartScene-42MWINQX.mjs.gz +0 -0
  105. package/dist/Bar3DChartScene-JP3BXEZW.js.gz +0 -0
  106. package/dist/Line3DChartScene-JK3AELXZ.js.gz +0 -0
  107. package/dist/Line3DChartScene-YVCSJMWK.mjs.br +0 -0
  108. package/dist/Line3DChartScene-YVCSJMWK.mjs.gz +0 -0
  109. package/dist/Model3DScene-N6UIMN7T.js.br +0 -0
  110. package/dist/Model3DScene-N6UIMN7T.js.gz +0 -0
  111. package/dist/Model3DScene-OXWSYHHK.mjs.gz +0 -0
  112. package/dist/PieChart3DScene-Q2Z3ECL4.js.gz +0 -0
  113. package/dist/PieChart3DScene-XK4ETZJC.mjs.gz +0 -0
  114. package/dist/SurfaceChart3DScene-KNWMKMOL.mjs.br +0 -0
  115. package/dist/SurfaceChart3DScene-KNWMKMOL.mjs.gz +0 -0
  116. package/dist/SurfaceChart3DScene-ULBUIF7T.js.gz +0 -0
  117. package/dist/chunk-5KAMDV37.js.br +0 -0
  118. package/dist/chunk-5KAMDV37.js.gz +0 -0
  119. package/dist/chunk-6547ZWC7.mjs.br +0 -0
  120. package/dist/chunk-6547ZWC7.mjs.gz +0 -0
  121. package/dist/chunk-AT4BJKON.mjs.br +0 -0
  122. package/dist/chunk-AT4BJKON.mjs.gz +0 -0
  123. package/dist/chunk-C4Q4WYAJ.mjs.br +0 -0
  124. package/dist/chunk-C4Q4WYAJ.mjs.gz +0 -0
  125. package/dist/chunk-GLY4OPMY.js.br +0 -0
  126. package/dist/chunk-GLY4OPMY.js.gz +0 -0
  127. package/dist/chunk-J7Q7AGN7.mjs.br +0 -0
  128. package/dist/chunk-J7Q7AGN7.mjs.gz +0 -0
  129. package/dist/chunk-LAB7WX2N.js.br +0 -0
  130. package/dist/chunk-LAB7WX2N.js.gz +0 -0
  131. package/dist/chunk-Q6CSZ7VM.js.br +0 -0
  132. package/dist/chunk-Q6CSZ7VM.js.gz +0 -0
  133. package/dist/chunk-VVJTEFGP.js.br +0 -0
  134. package/dist/chunk-VVJTEFGP.js.gz +0 -0
  135. package/dist/chunk-YNTZCMRI.mjs.br +0 -0
  136. package/dist/chunk-YNTZCMRI.mjs.gz +0 -0
@@ -27574,20 +27574,20 @@ function ensureCell(sheetData, ref) {
27574
27574
  }
27575
27575
  sheetData["row"] = rows;
27576
27576
  }
27577
- const cells = toArray(row["c"]);
27578
- let cell = cells.find((c) => String(c["@_r"] ?? "") === ref);
27577
+ const cells2 = toArray(row["c"]);
27578
+ let cell = cells2.find((c) => String(c["@_r"] ?? "") === ref);
27579
27579
  if (!cell) {
27580
27580
  cell = { "@_r": ref };
27581
- const insertAt3 = cells.findIndex((c) => {
27581
+ const insertAt3 = cells2.findIndex((c) => {
27582
27582
  const existingAddress = parseCellAddress(String(c["@_r"] ?? ""));
27583
27583
  return existingAddress !== void 0 && existingAddress.col > address.col;
27584
27584
  });
27585
27585
  if (insertAt3 < 0) {
27586
- cells.push(cell);
27586
+ cells2.push(cell);
27587
27587
  } else {
27588
- cells.splice(insertAt3, 0, cell);
27588
+ cells2.splice(insertAt3, 0, cell);
27589
27589
  }
27590
- row["c"] = cells;
27590
+ row["c"] = cells2;
27591
27591
  }
27592
27592
  return cell;
27593
27593
  }
@@ -28455,6 +28455,9 @@ async function writeOleDocumentParagraphEdit(docxBytes, paragraphIndex, text22)
28455
28455
  };
28456
28456
  const pPr = xmlChild(paragraph, "w:pPr");
28457
28457
  for (const key2 of Object.keys(paragraph)) {
28458
+ if (key2 === "__proto__" || key2 === "constructor" || key2 === "prototype") {
28459
+ continue;
28460
+ }
28458
28461
  delete paragraph[key2];
28459
28462
  }
28460
28463
  if (pPr) {
@@ -33238,7 +33241,7 @@ var init_smartart_layout_interpreter_choose_composite = __esm({
33238
33241
  init_smartart_layout_interpreter_choose_branch();
33239
33242
  }
33240
33243
  });
33241
- function branchAlg(raw, nodeCount, context) {
33244
+ function branchAlg(raw, nodeCount, context, allowedTypes = CHOOSE_ALG_TYPES) {
33242
33245
  if (!raw) {
33243
33246
  return void 0;
33244
33247
  }
@@ -33262,7 +33265,7 @@ function branchAlg(raw, nodeCount, context) {
33262
33265
  if (name === "alg") {
33263
33266
  for (const candidate of Array.isArray(entry2) ? entry2 : [entry2]) {
33264
33267
  const type = candidate && typeof candidate === "object" ? String(candidate["@_type"] ?? "") : "";
33265
- if (CHOOSE_ALG_TYPES.has(type)) {
33268
+ if (allowedTypes.has(type)) {
33266
33269
  found = { type, raw: candidate };
33267
33270
  return;
33268
33271
  }
@@ -33343,6 +33346,24 @@ function chooseAlgorithm(node, nodeCount, context = {}) {
33343
33346
  }
33344
33347
  return void 0;
33345
33348
  }
33349
+ function chooseAlgorithmOfType(node, nodeCount, allowedTypes, context = {}) {
33350
+ if (!node.choose || node.choose.length === 0) {
33351
+ return void 0;
33352
+ }
33353
+ for (const choose of node.choose) {
33354
+ const found = branchAlg(
33355
+ activeBranch(choose, nodeCount, context),
33356
+ nodeCount,
33357
+ context,
33358
+ allowedTypes
33359
+ );
33360
+ if (found) {
33361
+ const parameters = parseBranchAlgParams(found.raw);
33362
+ return { type: found.type, ...parameters ? { parameters } : {} };
33363
+ }
33364
+ }
33365
+ return void 0;
33366
+ }
33346
33367
  var CHOOSE_ALG_TYPES;
33347
33368
  var init_smartart_layout_interpreter_choose_algorithm = __esm({
33348
33369
  "src/core/utils/smartart-layout-interpreter-choose-algorithm.ts"() {
@@ -34432,6 +34453,41 @@ var init_smartart_constraint_declared_by = __esm({
34432
34453
  init_smartart_constraint_solver();
34433
34454
  }
34434
34455
  });
34456
+ function readAlgorithmAspectRatio(node) {
34457
+ const raw = node?.algorithm?.parameters?.find((param) => param.type === "ar")?.value;
34458
+ if (raw === void 0) {
34459
+ return void 0;
34460
+ }
34461
+ const ar = Number.parseFloat(raw);
34462
+ return Number.isFinite(ar) && ar > 0 ? ar : void 0;
34463
+ }
34464
+ function fitAspectRatioBox(box, ar) {
34465
+ if (ar === void 0 || box.height <= 0 || box.width <= 0) {
34466
+ return box;
34467
+ }
34468
+ const boxAr = box.width / box.height;
34469
+ if (boxAr > ar) {
34470
+ return { width: box.height * ar, height: box.height };
34471
+ }
34472
+ if (boxAr < ar) {
34473
+ return { width: box.width, height: box.width / ar };
34474
+ }
34475
+ return box;
34476
+ }
34477
+ function isUserSizeHubRole(role, index) {
34478
+ for (const entries of index.entries.values()) {
34479
+ for (const { constraint } of entries) {
34480
+ if (constraint.type === "userS" && constraint.referenceForName === role) {
34481
+ return true;
34482
+ }
34483
+ }
34484
+ }
34485
+ return false;
34486
+ }
34487
+ var init_smartart_layout_interpreter_composite_aspect = __esm({
34488
+ "src/core/utils/smartart-layout-interpreter-composite-aspect.ts"() {
34489
+ }
34490
+ });
34435
34491
  function finiteFactor(value) {
34436
34492
  return typeof value === "number" && Number.isFinite(value) && value > 0;
34437
34493
  }
@@ -34449,7 +34505,8 @@ function resolveHubToNodeRatioViaUserSize(ringItem, arrangerConstraints, index,
34449
34505
  if (userSizeDecl) {
34450
34506
  return {
34451
34507
  hubName: userSizeDecl.referenceForName,
34452
- factor: userSizeDecl.factor
34508
+ factor: userSizeDecl.factor,
34509
+ viaUserSize: true
34453
34510
  };
34454
34511
  }
34455
34512
  if (index && declaringRoleChain && declaringRoleChain.length > 0) {
@@ -34462,15 +34519,27 @@ function resolveHubToNodeRatioViaUserSize(ringItem, arrangerConstraints, index,
34462
34519
  if (ancestorDecl) {
34463
34520
  return {
34464
34521
  hubName: ancestorDecl.constraint.referenceForName,
34465
- factor: ancestorDecl.constraint.factor
34522
+ factor: ancestorDecl.constraint.factor,
34523
+ viaUserSize: true
34466
34524
  };
34467
34525
  }
34468
34526
  }
34469
34527
  return void 0;
34470
34528
  }
34529
+ function resolveViaUserSizeNodeWidthPx(ratio, index, box, sizeBox) {
34530
+ const hubW = resolveConstraint(index, ratio.hubName, "w");
34531
+ if (hubW === void 0) {
34532
+ return void 0;
34533
+ }
34534
+ const hubExtent = isUserSizeHubRole(ratio.hubName, index) ? sizeBox.width : box.width;
34535
+ const side = ratio.factor * hubW * hubExtent;
34536
+ return side > 0 ? side : void 0;
34537
+ }
34471
34538
  var init_smartart_layout_interpreter_cycle_hub_ratio_usersize = __esm({
34472
34539
  "src/core/utils/smartart-layout-interpreter-cycle-hub-ratio-usersize.ts"() {
34473
34540
  init_smartart_constraint_declared_by();
34541
+ init_smartart_constraint_solver();
34542
+ init_smartart_layout_interpreter_composite_aspect();
34474
34543
  }
34475
34544
  });
34476
34545
  function resolveHubToNodeRatio(ringItem, arrangerConstraints, index, arrangerRuleCandidates, satelliteCount, declaringRoleChain) {
@@ -34515,12 +34584,12 @@ function resolveHubGapRatio(itemName, hubRatio, arrangerConstraints) {
34515
34584
  return void 0;
34516
34585
  }
34517
34586
  const sp = (arrangerConstraints ?? []).find(
34518
- (c) => c.type === "sp" && typeof c.factor === "number" && typeof c.referenceForName === "string"
34587
+ (c) => c.type === "sp" && typeof c.factor === "number"
34519
34588
  );
34520
34589
  if (!sp || typeof sp.factor !== "number") {
34521
34590
  return void 0;
34522
34591
  }
34523
- if (sp.referenceForName === itemName) {
34592
+ if (sp.referenceForName === void 0 || sp.referenceForName === itemName) {
34524
34593
  return sp.factor;
34525
34594
  }
34526
34595
  if (sp.referenceForName === hubRatio.hubName) {
@@ -36175,6 +36244,20 @@ var init_smartart_layout_interpreter_cycle_fontfit = __esm({
36175
36244
  init_smartart_layout_item_font_tier();
36176
36245
  }
36177
36246
  });
36247
+ function resolveHubExpansion(nodes, plan, hubAlreadyStripped, hubRatio, hubGapRatio, absoluteHubGapPx, index, box, sizeBox) {
36248
+ const hasHub = !hubAlreadyStripped && (!hubRatio || hubRatio.viaUserSize === true) && algorithmParam(plan.node, "ctrShpMap") === "fNode" && nodes.length > 0;
36249
+ const hubNode = hasHub ? nodes[0] : void 0;
36250
+ const ringNodes = hasHub ? nodes.slice(1) : nodes;
36251
+ const hubGeometry = hubRatio && (hubGapRatio !== void 0 || absoluteHubGapPx !== void 0) ? { factor: hubRatio.viaUserSize ? 1 : hubRatio.factor, gapRatio: hubGapRatio ?? 0 } : void 0;
36252
+ const knownNodeWidthPx = ringNodes.length === 1 && hubRatio?.viaUserSize ? resolveViaUserSizeNodeWidthPx(hubRatio, index, box, sizeBox ?? box) : void 0;
36253
+ return { hasHub, hubNode, ringNodes, hubGeometry, knownNodeWidthPx };
36254
+ }
36255
+ var init_smartart_layout_interpreter_cycle_hub_detect = __esm({
36256
+ "src/core/utils/smartart-layout-interpreter-cycle-hub-detect.ts"() {
36257
+ init_smartart_layout_interpreter_cycle_hub_ratio_usersize();
36258
+ init_smartart_layout_interpreter_model();
36259
+ }
36260
+ });
36178
36261
  function computeRingBulgeBounds(xs, ys, halfW, halfH, sibTransBulgeRatio) {
36179
36262
  const minX = Math.min(...xs) - halfW;
36180
36263
  const maxX = Math.max(...xs) + halfW;
@@ -36198,6 +36281,32 @@ var init_smartart_layout_interpreter_cycle_ring_bulge = __esm({
36198
36281
  "src/core/utils/smartart-layout-interpreter-cycle-ring-bulge.ts"() {
36199
36282
  }
36200
36283
  });
36284
+ function nestedHubSatelliteRingLayout(stAngDeg, heightOverWidth, box, hubGeometry, nodeWidthPx) {
36285
+ const boxCentre = { x: box.width / 2, y: box.height / 2 };
36286
+ const halfH = Math.max(0.01, heightOverWidth) / 2;
36287
+ const hubHalfWidthNat = 0.5 / Math.max(1e-6, hubGeometry.factor);
36288
+ const r0Nat = hubHalfWidthNat + Math.max(0, hubGeometry.gapRatio) + 0.5;
36289
+ const angleRad = (stAngDeg - 90) * DEG_TO_RAD2;
36290
+ const r0Px = r0Nat * nodeWidthPx;
36291
+ const satellite = {
36292
+ x: boxCentre.x + r0Px * Math.cos(angleRad),
36293
+ y: boxCentre.y + r0Px * Math.sin(angleRad)
36294
+ };
36295
+ return {
36296
+ centers: [satellite],
36297
+ nodeWidth: nodeWidthPx,
36298
+ nodeHeight: nodeWidthPx * Math.max(0.01, heightOverWidth),
36299
+ hubCenter: boxCentre,
36300
+ hubHalfWidth: hubHalfWidthNat * nodeWidthPx,
36301
+ hubHalfHeight: hubHalfWidthNat * (halfH / 0.5) * nodeWidthPx
36302
+ };
36303
+ }
36304
+ var DEG_TO_RAD2;
36305
+ var init_smartart_layout_interpreter_cycle_ring_nested_hub = __esm({
36306
+ "src/core/utils/smartart-layout-interpreter-cycle-ring-nested-hub.ts"() {
36307
+ DEG_TO_RAD2 = Math.PI / 180;
36308
+ }
36309
+ });
36201
36310
  function resolveRingAxisOffset(dimension, boundSize, scale2, values) {
36202
36311
  const span = Math.max(1e-9, Math.max(...values) - Math.min(...values));
36203
36312
  const epsilon = span * TIE_EPSILON_FRACTION;
@@ -36245,14 +36354,23 @@ function degenerateRingLayout(n, heightOverWidth, box) {
36245
36354
  }
36246
36355
  return void 0;
36247
36356
  }
36248
- function ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth, box, hubGeometry, sibTransBulgeRatio) {
36357
+ function ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth, box, hubGeometry, sibTransBulgeRatio, knownNodeWidthPx) {
36358
+ if (n === 1 && hubGeometry && knownNodeWidthPx !== void 0 && knownNodeWidthPx > 0) {
36359
+ return nestedHubSatelliteRingLayout(
36360
+ stAngDeg,
36361
+ heightOverWidth,
36362
+ box,
36363
+ hubGeometry,
36364
+ knownNodeWidthPx
36365
+ );
36366
+ }
36249
36367
  const degenerate = degenerateRingLayout(n, heightOverWidth, box);
36250
36368
  if (degenerate) {
36251
36369
  return degenerate;
36252
36370
  }
36253
36371
  const full = Math.abs(spanDeg) >= 360;
36254
36372
  const step = full ? spanDeg / n : spanDeg / (n - 1);
36255
- const halfStepRad = Math.abs(step) * DEG_TO_RAD2 / 2;
36373
+ const halfStepRad = Math.abs(step) * DEG_TO_RAD3 / 2;
36256
36374
  const clampedGap = Math.max(0, gapFactor);
36257
36375
  const sinHalf = Math.sin(halfStepRad);
36258
36376
  let r0 = sinHalf > 1e-6 ? (1 + clampedGap) / (2 * sinHalf) : 0;
@@ -36262,7 +36380,7 @@ function ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth
36262
36380
  r0 = Math.max(r0, r0Hub);
36263
36381
  }
36264
36382
  const natural = Array.from({ length: n }, (_, i2) => {
36265
- const angleRad = (stAngDeg + i2 * step - 90) * DEG_TO_RAD2;
36383
+ const angleRad = (stAngDeg + i2 * step - 90) * DEG_TO_RAD3;
36266
36384
  return { x: r0 * Math.cos(angleRad), y: r0 * Math.sin(angleRad) };
36267
36385
  });
36268
36386
  const halfW = 0.5;
@@ -36290,10 +36408,13 @@ function ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth
36290
36408
  hubHalfHeight: naturalHubRadius * scaleY
36291
36409
  };
36292
36410
  }
36293
- function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWidth, box, absoluteGapPx, hubGeometry, absoluteHubGapPx, sibTransBulgeRatio) {
36294
- const degenerate = degenerateRingLayout(n, heightOverWidth, box);
36295
- if (degenerate) {
36296
- return degenerate;
36411
+ function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWidth, box, absoluteGapPx, hubGeometry, absoluteHubGapPx, sibTransBulgeRatio, knownNodeWidthPx) {
36412
+ const nestedHubSatellite = n === 1 && hubGeometry && knownNodeWidthPx !== void 0 && knownNodeWidthPx > 0;
36413
+ if (!nestedHubSatellite) {
36414
+ const degenerate = degenerateRingLayout(n, heightOverWidth, box);
36415
+ if (degenerate) {
36416
+ return degenerate;
36417
+ }
36297
36418
  }
36298
36419
  const needsGapIteration = absoluteGapPx !== void 0 && absoluteGapPx > 0;
36299
36420
  const needsHubGapIteration = absoluteHubGapPx !== void 0 && absoluteHubGapPx > 0 && hubGeometry !== void 0;
@@ -36306,7 +36427,8 @@ function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWid
36306
36427
  heightOverWidth,
36307
36428
  box,
36308
36429
  hubGeometry,
36309
- sibTransBulgeRatio
36430
+ sibTransBulgeRatio,
36431
+ knownNodeWidthPx
36310
36432
  );
36311
36433
  }
36312
36434
  let gapFactor = minGapRatio;
@@ -36345,15 +36467,16 @@ function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWid
36345
36467
  sibTransBulgeRatio
36346
36468
  );
36347
36469
  }
36348
- var DEG_TO_RAD2;
36470
+ var DEG_TO_RAD3;
36349
36471
  var init_smartart_layout_interpreter_cycle_ring = __esm({
36350
36472
  "src/core/utils/smartart-layout-interpreter-cycle-ring.ts"() {
36351
36473
  init_smartart_layout_interpreter_cycle_ring_bulge();
36474
+ init_smartart_layout_interpreter_cycle_ring_nested_hub();
36352
36475
  init_smartart_layout_interpreter_cycle_ring_offset();
36353
- DEG_TO_RAD2 = Math.PI / 180;
36476
+ DEG_TO_RAD3 = Math.PI / 180;
36354
36477
  }
36355
36478
  });
36356
- function arrangeCycle(plan, nodes, box, palette, style, elementId, index = EMPTY_CONSTRAINT_INDEX, hubAlreadyStripped = false, childrenOf, fontName, declaringRoleChain) {
36479
+ function arrangeCycle(plan, nodes, box, palette, style, elementId, index = EMPTY_CONSTRAINT_INDEX, hubAlreadyStripped = false, childrenOf, fontName, declaringRoleChain, sizeBox) {
36357
36480
  const { width: w, height: h2 } = box;
36358
36481
  const ctx = styleContext(style);
36359
36482
  const {
@@ -36370,13 +36493,20 @@ function arrangeCycle(plan, nodes, box, palette, style, elementId, index = EMPTY
36370
36493
  hubAlreadyStripped ? nodes.length : void 0,
36371
36494
  declaringRoleChain
36372
36495
  );
36373
- const hasHub = !hubAlreadyStripped && !hubRatio && algorithmParam(plan.node, "ctrShpMap") === "fNode" && nodes.length > 0;
36374
- const hubNode = hasHub ? nodes[0] : void 0;
36375
- const ringNodes = hasHub ? nodes.slice(1) : nodes;
36496
+ const { hubNode, ringNodes, hubGeometry, knownNodeWidthPx } = resolveHubExpansion(
36497
+ nodes,
36498
+ plan,
36499
+ hubAlreadyStripped,
36500
+ hubRatio,
36501
+ hubGapRatio,
36502
+ absoluteHubGapPx,
36503
+ index,
36504
+ box,
36505
+ sizeBox
36506
+ );
36376
36507
  const n = ringNodes.length;
36377
36508
  const startDeg = numericParam(plan.node, "stAng", 0);
36378
36509
  const spanDeg = numericParam(plan.node, "spanAng", 360);
36379
- const hubGeometry = hubRatio && (hubGapRatio !== void 0 || absoluteHubGapPx !== void 0) ? { factor: hubRatio.factor, gapRatio: hubGapRatio ?? 0 } : void 0;
36380
36510
  const ring = computeCycleRingLayout(
36381
36511
  n,
36382
36512
  startDeg,
@@ -36387,7 +36517,8 @@ function arrangeCycle(plan, nodes, box, palette, style, elementId, index = EMPTY
36387
36517
  absoluteGapPx,
36388
36518
  hubGeometry,
36389
36519
  absoluteHubGapPx,
36390
- sibTransBulgeRatio
36520
+ sibTransBulgeRatio,
36521
+ knownNodeWidthPx
36391
36522
  );
36392
36523
  const full = Math.abs(spanDeg) >= 360;
36393
36524
  const connectorCount = n > 0 ? full ? n : Math.max(0, n - 1) : 0;
@@ -36456,6 +36587,7 @@ var init_smartart_layout_interpreter_cycle = __esm({
36456
36587
  init_smartart_layout_interpreter_cycle_constraints();
36457
36588
  init_smartart_layout_interpreter_cycle_extension();
36458
36589
  init_smartart_layout_interpreter_cycle_fontfit();
36590
+ init_smartart_layout_interpreter_cycle_hub_detect();
36459
36591
  init_smartart_layout_interpreter_cycle_ring();
36460
36592
  init_smartart_layout_interpreter_model();
36461
36593
  init_smartart_layout_interpreter_render();
@@ -37516,18 +37648,18 @@ function arrangeSnake(plan, nodes, box, palette, style, elementId, index = EMPTY
37516
37648
  naturalAspect,
37517
37649
  cornerInset
37518
37650
  );
37519
- const cells = nodes.map((_node, i2) => snakeCell(i2, dims, flowDir, sameDir, grDir));
37651
+ const cells2 = nodes.map((_node, i2) => snakeCell(i2, dims, flowDir, sameDir, grDir));
37520
37652
  const centerIncompleteLines = algorithmParam(plan.node, "off") === "ctr";
37521
37653
  const fullLineCount = flowDir === "row" ? dims.cols : dims.rows;
37522
37654
  const lineCounts = /* @__PURE__ */ new Map();
37523
37655
  if (centerIncompleteLines) {
37524
- for (const cell of cells) {
37656
+ for (const cell of cells2) {
37525
37657
  const key2 = flowDir === "row" ? cell.row : cell.col;
37526
37658
  lineCounts.set(key2, (lineCounts.get(key2) ?? 0) + 1);
37527
37659
  }
37528
37660
  }
37529
37661
  const renderedNodes = nodes.map((node, i2) => {
37530
- const { col, row } = cells[i2];
37662
+ const { col, row } = cells2[i2];
37531
37663
  let x = INSET + col * (cellW + gapX);
37532
37664
  let y = INSET + row * (cellH + gapY);
37533
37665
  if (centerIncompleteLines) {
@@ -37813,41 +37945,6 @@ var init_smartart_layout_interpreter_aux = __esm({
37813
37945
  INSET2 = 6;
37814
37946
  }
37815
37947
  });
37816
- function readAlgorithmAspectRatio(node) {
37817
- const raw = node?.algorithm?.parameters?.find((param) => param.type === "ar")?.value;
37818
- if (raw === void 0) {
37819
- return void 0;
37820
- }
37821
- const ar = Number.parseFloat(raw);
37822
- return Number.isFinite(ar) && ar > 0 ? ar : void 0;
37823
- }
37824
- function fitAspectRatioBox(box, ar) {
37825
- if (ar === void 0 || box.height <= 0 || box.width <= 0) {
37826
- return box;
37827
- }
37828
- const boxAr = box.width / box.height;
37829
- if (boxAr > ar) {
37830
- return { width: box.height * ar, height: box.height };
37831
- }
37832
- if (boxAr < ar) {
37833
- return { width: box.width, height: box.width / ar };
37834
- }
37835
- return box;
37836
- }
37837
- function isUserSizeHubRole(role, index) {
37838
- for (const entries of index.entries.values()) {
37839
- for (const { constraint } of entries) {
37840
- if (constraint.type === "userS" && constraint.referenceForName === role) {
37841
- return true;
37842
- }
37843
- }
37844
- }
37845
- return false;
37846
- }
37847
- var init_smartart_layout_interpreter_composite_aspect = __esm({
37848
- "src/core/utils/smartart-layout-interpreter-composite-aspect.ts"() {
37849
- }
37850
- });
37851
37948
  function resolveOrigin(node, flat) {
37852
37949
  const origin = node.forEachOrigin;
37853
37950
  if (!origin?.axis || origin.axis.length === 0) {
@@ -38534,6 +38631,36 @@ var init_smartart_hierarchy_pitch = __esm({
38534
38631
  GENERATION_MARGIN_RATIO = 0.1675;
38535
38632
  }
38536
38633
  });
38634
+ function isSquareHeightConstraint(constraints) {
38635
+ const h2 = findConstraint(constraints, "h");
38636
+ return h2?.referenceType === "w" && h2.factor === void 0 && h2.value === void 0 && h2.referenceForName === void 0;
38637
+ }
38638
+ function resolveUserSizeItemBoxPx(wrapper, index, box, sizeBox, declaringRoleChain) {
38639
+ for (const template of wrapper.children ?? []) {
38640
+ if (!isSquareHeightConstraint(template.constraints)) {
38641
+ continue;
38642
+ }
38643
+ const ratio = resolveHubToNodeRatioViaUserSize(
38644
+ template,
38645
+ wrapper.constraints,
38646
+ index,
38647
+ declaringRoleChain
38648
+ );
38649
+ if (!ratio) {
38650
+ continue;
38651
+ }
38652
+ const hubRatio = resolveConstraint(index, ratio.hubName, "w");
38653
+ if (hubRatio === void 0) {
38654
+ continue;
38655
+ }
38656
+ const hubExtent = isUserSizeHubRole(ratio.hubName, index) ? sizeBox.width : box.width;
38657
+ const side = ratio.factor * hubRatio * hubExtent;
38658
+ if (side > 0) {
38659
+ return { width: side, height: side };
38660
+ }
38661
+ }
38662
+ return void 0;
38663
+ }
38537
38664
  function childAxisSpec(template, childCount) {
38538
38665
  const axis = template.presentationOf?.axis;
38539
38666
  if (!axis || axis.length === 0) {
@@ -38573,7 +38700,7 @@ function collectChildRepeaterItems(wrapper, anchorChildren) {
38573
38700
  items.sort((a, b) => a.position - b.position);
38574
38701
  return items;
38575
38702
  }
38576
- function renderChildRepeaterSlot(wrapperSlot, anchor, anchorIndex, box, absX, absY, childrenOf, ctx) {
38703
+ function renderChildRepeaterSlot(wrapperSlot, anchor, anchorIndex, box, absX, absY, childrenOf, ctx, sizingCtx) {
38577
38704
  const anchorChildren = childrenOf.get(anchor.id) ?? [];
38578
38705
  const items = collectChildRepeaterItems(wrapperSlot.node, anchorChildren);
38579
38706
  if (items.length === 0) {
@@ -38581,15 +38708,27 @@ function renderChildRepeaterSlot(wrapperSlot, anchor, anchorIndex, box, absX, ab
38581
38708
  }
38582
38709
  const rect22 = resolveSlot(wrapperSlot.dims, box, absX, absY);
38583
38710
  const columnWidth = rect22.width / items.length;
38711
+ const userSize = sizingCtx ? resolveUserSizeItemBoxPx(
38712
+ wrapperSlot.node,
38713
+ sizingCtx.index,
38714
+ box,
38715
+ sizingCtx.sizeBox,
38716
+ sizingCtx.declaringRoleChain
38717
+ ) : void 0;
38584
38718
  return items.map((item, i2) => {
38585
38719
  const folded = item.fold ? smartArtDescendantsWithText(item.child, childrenOf) : [];
38720
+ const columnX = rect22.x + columnWidth * i2;
38721
+ const width = userSize ? Math.min(userSize.width, columnWidth) : columnWidth;
38722
+ const height = userSize ? Math.min(userSize.height, rect22.height) : rect22.height;
38723
+ const x = userSize ? columnX + (columnWidth - width) / 2 : columnX;
38724
+ const y = userSize ? rect22.y + (rect22.height - height) / 2 : rect22.y;
38586
38725
  const rendered = {
38587
38726
  ...rectNode({
38588
38727
  key: `${ctx.elementId}-comp-child-${item.child.id}-${anchorIndex}-${i2}`,
38589
- x: rect22.x + columnWidth * i2,
38590
- y: rect22.y,
38591
- width: columnWidth,
38592
- height: rect22.height,
38728
+ x,
38729
+ y,
38730
+ width,
38731
+ height,
38593
38732
  node: item.child,
38594
38733
  index: i2,
38595
38734
  total: items.length,
@@ -38604,8 +38743,12 @@ function renderChildRepeaterSlot(wrapperSlot, anchor, anchorIndex, box, absX, ab
38604
38743
  }
38605
38744
  var init_smartart_layout_interpreter_composite_children = __esm({
38606
38745
  "src/core/utils/smartart-layout-interpreter-composite-children.ts"() {
38746
+ init_smartart_constraint_solver();
38607
38747
  init_smartart_layout_interpreter_axis_range();
38748
+ init_smartart_layout_interpreter_composite_aspect();
38608
38749
  init_smartart_layout_interpreter_composite_slots();
38750
+ init_smartart_layout_interpreter_constraints();
38751
+ init_smartart_layout_interpreter_cycle_hub_ratio_usersize();
38609
38752
  init_smartart_layout_interpreter_render();
38610
38753
  init_smartart_node_tree_axis();
38611
38754
  }
@@ -38619,7 +38762,7 @@ function resolveNestedCycleAnchor(wrapper, anchor, childrenOf) {
38619
38762
  const resolved = items[0].child;
38620
38763
  return (childrenOf.get(resolved.id)?.length ?? 0) > 0 ? resolved : void 0;
38621
38764
  }
38622
- function arrangeNestedCycleSlot(wrapperSlot, anchor, box, absX, absY, childrenOf, nodeCount, flat, presLayoutVars, index, palette, style, elementId, fontName, declaringRoleChain) {
38765
+ function arrangeNestedCycleSlot(wrapperSlot, anchor, box, absX, absY, childrenOf, nodeCount, flat, presLayoutVars, index, palette, style, elementId, fontName, declaringRoleChain, sizeBox) {
38623
38766
  const wrapper = wrapperSlot.node;
38624
38767
  const nestedAnchor = resolveNestedCycleAnchor(wrapper, anchor, childrenOf);
38625
38768
  if (!nestedAnchor) {
@@ -38647,11 +38790,12 @@ function arrangeNestedCycleSlot(wrapperSlot, anchor, box, absX, absY, childrenOf
38647
38790
  false,
38648
38791
  childrenOf,
38649
38792
  fontName,
38650
- declaringRoleChain
38793
+ declaringRoleChain,
38794
+ sizeBox
38651
38795
  );
38652
38796
  return translateResult(result, rect22.x, rect22.y).nodes;
38653
38797
  }
38654
- function renderChildRepeaterOrNestedCycle(wrapperSlot, anchor, anchorIndex, box, absX, absY, childrenOf, flat, presLayoutVars, index, ctx, fontName, declaringRoleChain) {
38798
+ function renderChildRepeaterOrNestedCycle(wrapperSlot, anchor, anchorIndex, box, absX, absY, childrenOf, flat, presLayoutVars, index, ctx, fontName, declaringRoleChain, sizeBox) {
38655
38799
  const nested = arrangeNestedCycleSlot(
38656
38800
  wrapperSlot,
38657
38801
  anchor,
@@ -38667,9 +38811,24 @@ function renderChildRepeaterOrNestedCycle(wrapperSlot, anchor, anchorIndex, box,
38667
38811
  ctx.style,
38668
38812
  ctx.elementId,
38669
38813
  fontName,
38670
- declaringRoleChain
38814
+ declaringRoleChain,
38815
+ sizeBox
38816
+ );
38817
+ if (nested) {
38818
+ return nested;
38819
+ }
38820
+ const sizingCtx = declaringRoleChain && sizeBox ? { index, sizeBox, declaringRoleChain } : void 0;
38821
+ return renderChildRepeaterSlot(
38822
+ wrapperSlot,
38823
+ anchor,
38824
+ anchorIndex,
38825
+ box,
38826
+ absX,
38827
+ absY,
38828
+ childrenOf,
38829
+ ctx,
38830
+ sizingCtx
38671
38831
  );
38672
- return nested ?? renderChildRepeaterSlot(wrapperSlot, anchor, anchorIndex, box, absX, absY, childrenOf, ctx);
38673
38832
  }
38674
38833
  var init_smartart_layout_interpreter_composite_nested_cycle = __esm({
38675
38834
  "src/core/utils/smartart-layout-interpreter-composite-nested-cycle.ts"() {
@@ -38858,7 +39017,7 @@ var init_smartart_layout_interpreter_composite_render = __esm({
38858
39017
  function slotsWithAxis(slotted, axis) {
38859
39018
  return slotted.filter((slot) => slot.node.presentationOf?.axis?.[0] === axis);
38860
39019
  }
38861
- function arrangeByPresentationOf(slotted, allChildren, nodes, flat, box, absX, absY, childrenOf, ctx, fontCtx, index, presLayoutVars, declaringRoleChain) {
39020
+ function arrangeByPresentationOf(slotted, allChildren, nodes, flat, box, absX, absY, childrenOf, ctx, fontCtx, index, presLayoutVars, declaringRoleChain, sizeBox) {
38862
39021
  const selfSlots = slotsWithAxis(slotted, "self");
38863
39022
  if (selfSlots.length === 0) {
38864
39023
  return void 0;
@@ -38899,7 +39058,8 @@ function arrangeByPresentationOf(slotted, allChildren, nodes, flat, box, absX, a
38899
39058
  index,
38900
39059
  ctx,
38901
39060
  fontCtx?.fontName,
38902
- declaringRoleChain
39061
+ declaringRoleChain,
39062
+ sizeBox
38903
39063
  )
38904
39064
  );
38905
39065
  }
@@ -38948,7 +39108,8 @@ function arrangeComposite(plan, nodes, box, palette, style, elementId, index = E
38948
39108
  fontCtx,
38949
39109
  index,
38950
39110
  presLayoutVars,
38951
- [declaringRole]
39111
+ [declaringRole],
39112
+ sizeBox
38952
39113
  ) ?? arrangeByChooseAwareSlots(plan.node, flat, box, index, ctx, fontCtx) ?? arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx);
38953
39114
  return {
38954
39115
  nodes: renderedNodes,
@@ -39317,12 +39478,13 @@ function computeHierarchyAxisPitches(effectiveBox, orientation, boxW, boxH, tota
39317
39478
  const fanWidth = tailedPitch ? effectiveBox.width - (cascadeReserveOffsetPx ?? hangShape.maxHangDepth * HIER_TAIL_OFFSET_RATIO * boxW) : effectiveBox.width;
39318
39479
  const hangHeightRatio = orientation.hangHeightRatio ?? HANG_HEIGHT_RATIO;
39319
39480
  const fanHeight = tailedPitch ? effectiveBox.height - hangShape.maxHangRows * (1 + hangHeightRatio) * boxH : effectiveBox.height;
39481
+ const fanSibSpRatio = tailedPitch && orientation.transposed ? orientation.sibSpRatio + hangShape.maxHangDepth * HIER_TAIL_OFFSET_RATIO * (totalLeaves > 0 ? hangShape.hangingColumns / totalLeaves : 0) : orientation.sibSpRatio;
39320
39482
  const xPitch = compositeFanPitch(
39321
39483
  fanWidth,
39322
39484
  boxW,
39323
39485
  orientation.compositeWidthFactor,
39324
39486
  orientation.cardOffsetXRatio,
39325
- orientation.sibSpRatio,
39487
+ fanSibSpRatio,
39326
39488
  totalLeaves
39327
39489
  );
39328
39490
  const fixedGenerationGapRatio = orientation.transposed ? void 0 : tailedPitch ? orientation.generationGapRatio : orientation.compositeGenerationGapRatio;
@@ -39452,16 +39614,17 @@ var init_smartart_hierarchy_dispatch_lindir = __esm({
39452
39614
  init_smartart_layout_interpreter_choose_algorithm();
39453
39615
  }
39454
39616
  });
39455
- function collectScoped(node, crossedHierChild, out) {
39617
+ function collectScoped(node, crossedHierChild, out, nodeCount, presLayoutVars) {
39456
39618
  if (!node) {
39457
39619
  return;
39458
39620
  }
39459
- if (node.algorithm?.type === "tx" && node.shape) {
39621
+ const effectiveType = node.algorithm?.type ?? (node.choose ? chooseAlgorithmOfType(node, nodeCount, TX_ALG_TYPES, { presLayoutVars })?.type : void 0);
39622
+ if (effectiveType === "tx" && node.shape) {
39460
39623
  out.push({ node, descendantScope: crossedHierChild });
39461
39624
  }
39462
39625
  const nextCrossed = crossedHierChild || node.algorithm?.type === "hierChild";
39463
39626
  for (const child262 of node.children ?? []) {
39464
- collectScoped(child262, nextCrossed, out);
39627
+ collectScoped(child262, nextCrossed, out, nodeCount, presLayoutVars);
39465
39628
  }
39466
39629
  }
39467
39630
  function resolvedSize(index, name) {
@@ -39472,14 +39635,14 @@ function resolvedSize(index, name) {
39472
39635
  }
39473
39636
  return { w, h: h2 };
39474
39637
  }
39475
- function resolveHierarchyGenerationTemplates(algorithmNode, index) {
39638
+ function resolveHierarchyGenerationTemplates(algorithmNode, index, nodeCount, presLayoutVars) {
39476
39639
  if (!algorithmNode) {
39477
39640
  return void 0;
39478
39641
  }
39479
39642
  const fallbackNode = resolveHierarchyItemNode(algorithmNode);
39480
39643
  const scoped = [];
39481
39644
  for (const child262 of algorithmNode.children ?? []) {
39482
- collectScoped(child262, false, scoped);
39645
+ collectScoped(child262, false, scoped, nodeCount, presLayoutVars);
39483
39646
  }
39484
39647
  const rootScoped = scoped.filter((c) => !c.descendantScope);
39485
39648
  const descendantScoped = scoped.filter((c) => c.descendantScope);
@@ -39507,10 +39670,13 @@ function resolveHierarchyGenerationTemplates(algorithmNode, index) {
39507
39670
  root: { node: rootMatch.node, name: rootMatch.node.name, widthFactor, heightFactor }
39508
39671
  };
39509
39672
  }
39673
+ var TX_ALG_TYPES;
39510
39674
  var init_smartart_hierarchy_generation_templates = __esm({
39511
39675
  "src/core/utils/smartart-hierarchy-generation-templates.ts"() {
39512
39676
  init_smartart_constraint_solver();
39513
39677
  init_smartart_hierarchy_item_template();
39678
+ init_smartart_layout_interpreter_choose_algorithm();
39679
+ TX_ALG_TYPES = /* @__PURE__ */ new Set(["tx"]);
39514
39680
  }
39515
39681
  });
39516
39682
  function resolveCornerHangPlan(algorithmNode, nodeCount, presLayoutVars, index) {
@@ -39525,7 +39691,12 @@ function resolveCornerHangPlan(algorithmNode, nodeCount, presLayoutVars, index)
39525
39691
  if (!linDir || !VERTICAL_LIN_DIR.has(linDir)) {
39526
39692
  return void 0;
39527
39693
  }
39528
- const templates = resolveHierarchyGenerationTemplates(algorithmNode, index);
39694
+ const templates = resolveHierarchyGenerationTemplates(
39695
+ algorithmNode,
39696
+ index,
39697
+ nodeCount,
39698
+ presLayoutVars
39699
+ );
39529
39700
  if (!templates?.root) {
39530
39701
  return void 0;
39531
39702
  }
@@ -39756,6 +39927,188 @@ var init_smartart_hierarchy_fold_depth = __esm({
39756
39927
  "src/core/utils/smartart-hierarchy-fold-depth.ts"() {
39757
39928
  }
39758
39929
  });
39930
+ function resolveSibSpRatio(algorithmNode) {
39931
+ const constraints = algorithmNode.allConstraints ?? algorithmNode.constraints ?? [];
39932
+ const sibSp = constraints.find((c) => c.type === "sibSp" && typeof c.factor === "number");
39933
+ return sibSp?.factor ?? DEFAULT_SIB_SP_RATIO;
39934
+ }
39935
+ function resolveFannedHangGeometry(algorithmNode, index, nodeCount, presLayoutVars, branchCount, box) {
39936
+ if (!algorithmNode || branchCount < 1) {
39937
+ return void 0;
39938
+ }
39939
+ const templates = resolveHierarchyGenerationTemplates(
39940
+ algorithmNode,
39941
+ index,
39942
+ nodeCount,
39943
+ presLayoutVars
39944
+ );
39945
+ if (!templates?.root) {
39946
+ return void 0;
39947
+ }
39948
+ const rootW_ = resolveConstraint(index, templates.root.name, "w");
39949
+ const rootH_ = resolveConstraint(index, templates.root.name, "h");
39950
+ if (rootW_ === void 0 || rootH_ === void 0 || !(rootW_ > 0) || !(rootH_ > 0)) {
39951
+ return void 0;
39952
+ }
39953
+ const rootAspect = rootW_ / rootH_;
39954
+ if (!(rootAspect > 0)) {
39955
+ return void 0;
39956
+ }
39957
+ const sibSpRatio = resolveSibSpRatio(algorithmNode);
39958
+ const rootW = box.width / (branchCount + (branchCount - 1) * sibSpRatio);
39959
+ const rootH = rootW / rootAspect;
39960
+ if (!(rootW > 0) || !(rootH > 0)) {
39961
+ return void 0;
39962
+ }
39963
+ const heightFactor = templates.root.heightFactor;
39964
+ const descH = heightFactor > 0 ? rootH / heightFactor : rootH;
39965
+ const descWidthFraction = resolveConstraint(index, templates.descendant.name, "w");
39966
+ const descW = (descWidthFraction !== void 0 && descWidthFraction > 0 && descWidthFraction <= 1.5 ? descWidthFraction : DEFAULT_DESC_WIDTH_FRACTION) * rootW;
39967
+ const chAlign = resolveHierarchyDispatchChAlign(algorithmNode, nodeCount, presLayoutVars);
39968
+ const linDir = algorithmNode.algorithm?.parameters?.find((p) => p.type === "linDir")?.value;
39969
+ return {
39970
+ rootW,
39971
+ rootH,
39972
+ descW,
39973
+ descH,
39974
+ gap: sibSpRatio * rootW,
39975
+ side: chAlign === "r" ? "right" : "left",
39976
+ reversed: linDir === "fromR"
39977
+ };
39978
+ }
39979
+ var DEFAULT_SIB_SP_RATIO;
39980
+ var DEFAULT_DESC_WIDTH_FRACTION;
39981
+ var init_smartart_hierarchy_fanned_hang_geometry = __esm({
39982
+ "src/core/utils/smartart-hierarchy-fanned-hang-geometry.ts"() {
39983
+ init_smartart_constraint_solver();
39984
+ init_smartart_hierarchy_dispatch_lindir();
39985
+ init_smartart_hierarchy_generation_templates();
39986
+ DEFAULT_SIB_SP_RATIO = 0.05;
39987
+ DEFAULT_DESC_WIDTH_FRACTION = 0.85;
39988
+ }
39989
+ });
39990
+ function resolveHierarchyItemFontSizePx(nodes, algorithmNode, index, boxW, boxH, fontName) {
39991
+ if (!algorithmNode) {
39992
+ return void 0;
39993
+ }
39994
+ const textNodes = nodes.filter((node) => node.text && node.text.trim().length > 0);
39995
+ if (textNodes.length === 0) {
39996
+ return void 0;
39997
+ }
39998
+ const plan = { node: algorithmNode };
39999
+ const { rootSizePx } = resolveTieredItemFontSize(
40000
+ plan,
40001
+ index,
40002
+ textNodes.map((node) => ({
40003
+ rootText: node.text,
40004
+ descendantTexts: [],
40005
+ width: boxW,
40006
+ height: boxH
40007
+ })),
40008
+ fontName,
40009
+ void 0,
40010
+ 0,
40011
+ algorithmNode
40012
+ );
40013
+ return rootSizePx;
40014
+ }
40015
+ var init_smartart_layout_interpreter_hierarchy_fontfit = __esm({
40016
+ "src/core/utils/smartart-layout-interpreter-hierarchy-fontfit.ts"() {
40017
+ init_smartart_layout_item_font_tier();
40018
+ }
40019
+ });
40020
+ function placeDescendantColumn(hc, node, edgeX, side, y, descW, descH, stackGapPx, parentId, parentCenterX, parentBottom) {
40021
+ const x = side === "right" ? edgeX - descW : edgeX;
40022
+ pushNode(hc, node.node, x, y, descW, descH);
40023
+ elbowConnector(hc, parentId, parentCenterX, parentBottom, x + descW / 2, y, node.node.id);
40024
+ let nextY = y + descH + stackGapPx;
40025
+ for (const child262 of node.children) {
40026
+ nextY = placeDescendantColumn(
40027
+ hc,
40028
+ child262,
40029
+ edgeX,
40030
+ side,
40031
+ nextY,
40032
+ descW,
40033
+ descH,
40034
+ stackGapPx,
40035
+ node.node.id,
40036
+ x + descW / 2,
40037
+ y + descH
40038
+ );
40039
+ }
40040
+ return nextY;
40041
+ }
40042
+ function arrangeFannedHangingForest(nodes, box, palette, style, elementId, roots, itemShape, connectorLabels, algorithmNode, index, fontName, presLayoutVars, orgChart) {
40043
+ if (orgChart) {
40044
+ return void 0;
40045
+ }
40046
+ const geometry = resolveFannedHangGeometry(
40047
+ algorithmNode,
40048
+ index,
40049
+ nodes.length,
40050
+ presLayoutVars,
40051
+ roots.length,
40052
+ box
40053
+ );
40054
+ if (!geometry) {
40055
+ return void 0;
40056
+ }
40057
+ const { rootW, rootH, descW, descH, gap, side, reversed } = geometry;
40058
+ const hc = baseContext(
40059
+ nodes.length,
40060
+ elementId,
40061
+ palette,
40062
+ style,
40063
+ descW,
40064
+ descH,
40065
+ connectorLabels,
40066
+ itemShape,
40067
+ resolveHierarchyItemFontSizePx(nodes, algorithmNode, index, descW, descH, fontName)
40068
+ );
40069
+ const rootChildGap = ROOT_CHILD_GAP_RATIO * descH;
40070
+ const branchCount = roots.length;
40071
+ roots.forEach((root, i2) => {
40072
+ const columnIndex = reversed ? branchCount - 1 - i2 : i2;
40073
+ const branchX = columnIndex * (rootW + gap);
40074
+ pushNode(hc, root.node, branchX, 0, rootW, rootH);
40075
+ const edgeX = side === "right" ? branchX + rootW : branchX;
40076
+ let y = rootH + rootChildGap;
40077
+ for (const child262 of root.children) {
40078
+ y = placeDescendantColumn(
40079
+ hc,
40080
+ child262,
40081
+ edgeX,
40082
+ side,
40083
+ y,
40084
+ descW,
40085
+ descH,
40086
+ DESCENDANT_STACK_GAP_RATIO * descH,
40087
+ root.node.id,
40088
+ branchX + rootW / 2,
40089
+ rootH
40090
+ );
40091
+ }
40092
+ });
40093
+ return {
40094
+ nodes: hc.nodes,
40095
+ connectors: hc.connectors,
40096
+ shadowFilter: hc.ctx.shadow,
40097
+ viewBox: `0 0 ${box.width} ${box.height}`,
40098
+ family: "hierarchy"
40099
+ };
40100
+ }
40101
+ var ROOT_CHILD_GAP_RATIO;
40102
+ var DESCENDANT_STACK_GAP_RATIO;
40103
+ var init_smartart_hierarchy_fanned_hang = __esm({
40104
+ "src/core/utils/smartart-hierarchy-fanned-hang.ts"() {
40105
+ init_smartart_hierarchy_fanned_hang_geometry();
40106
+ init_smartart_hierarchy_shared();
40107
+ init_smartart_layout_interpreter_hierarchy_fontfit();
40108
+ ROOT_CHILD_GAP_RATIO = 0.98;
40109
+ DESCENDANT_STACK_GAP_RATIO = 0;
40110
+ }
40111
+ });
39759
40112
  function placeAssistants(hc, x, parentBottom, assistants, options, cursor) {
39760
40113
  for (const assistant of assistants) {
39761
40114
  const y = cursor.y;
@@ -39815,7 +40168,7 @@ function resolveRowGapRatio(constraints, descendantName) {
39815
40168
  );
39816
40169
  return sibSp?.factor;
39817
40170
  }
39818
- function fitHangingBox(algorithmNode, index, w, h2, rows) {
40171
+ function fitHangingBox(algorithmNode, index, w, h2, rows, nodeCount, presLayoutVars) {
39819
40172
  const fallbackBoxH = Math.min(h2 * FALLBACK_BOX_H_RATIO, FALLBACK_BOX_H_MAX);
39820
40173
  const fallback = {
39821
40174
  boxW: Math.min(w * FALLBACK_BOX_W_RATIO, FALLBACK_BOX_W_MAX),
@@ -39825,7 +40178,12 @@ function fitHangingBox(algorithmNode, index, w, h2, rows) {
39825
40178
  if (!algorithmNode || rows < 1) {
39826
40179
  return fallback;
39827
40180
  }
39828
- const templates = resolveHierarchyGenerationTemplates(algorithmNode, index);
40181
+ const templates = resolveHierarchyGenerationTemplates(
40182
+ algorithmNode,
40183
+ index,
40184
+ nodeCount,
40185
+ presLayoutVars
40186
+ );
39829
40187
  if (!templates) {
39830
40188
  return fallback;
39831
40189
  }
@@ -39896,41 +40254,11 @@ var init_smartart_hierarchy_hanging_fold = __esm({
39896
40254
  init_smartart_hierarchy_orgchart_tree();
39897
40255
  }
39898
40256
  });
39899
- function resolveHierarchyItemFontSizePx(nodes, algorithmNode, index, boxW, boxH, fontName) {
39900
- if (!algorithmNode) {
39901
- return void 0;
39902
- }
39903
- const textNodes = nodes.filter((node) => node.text && node.text.trim().length > 0);
39904
- if (textNodes.length === 0) {
39905
- return void 0;
39906
- }
39907
- const plan = { node: algorithmNode };
39908
- const { rootSizePx } = resolveTieredItemFontSize(
39909
- plan,
39910
- index,
39911
- textNodes.map((node) => ({
39912
- rootText: node.text,
39913
- descendantTexts: [],
39914
- width: boxW,
39915
- height: boxH
39916
- })),
39917
- fontName,
39918
- void 0,
39919
- 0,
39920
- algorithmNode
39921
- );
39922
- return rootSizePx;
39923
- }
39924
- var init_smartart_layout_interpreter_hierarchy_fontfit = __esm({
39925
- "src/core/utils/smartart-layout-interpreter-hierarchy-fontfit.ts"() {
39926
- init_smartart_layout_item_font_tier();
39927
- }
39928
- });
39929
- function arrangeFullyHangingTree(nodes, box, palette, style, elementId, roots, itemShape, connectorLabels, algorithmNode, index, fontName, linDir, orgChart, cornerSide) {
40257
+ function arrangeFullyHangingTree(nodes, box, palette, style, elementId, roots, itemShape, connectorLabels, algorithmNode, index, fontName, linDir, orgChart, presLayoutVars, cornerSide) {
39930
40258
  const { width: w, height: h2 } = box;
39931
40259
  const foldDeeperGenerations = algorithmNode ? hierarchyLeafFoldsDescendants(algorithmNode) : false;
39932
40260
  const rows = countHangingRows(roots, orgChart, foldDeeperGenerations);
39933
- const fit = fitHangingBox(algorithmNode, index, w, h2, rows);
40261
+ const fit = fitHangingBox(algorithmNode, index, w, h2, rows, nodes.length, presLayoutVars);
39934
40262
  const { boxW, boxH, vGap } = fit;
39935
40263
  const indent = boxW * 0.35;
39936
40264
  const hc = baseContext(
@@ -39986,6 +40314,51 @@ var init_smartart_hierarchy_hanging_arrange = __esm({
39986
40314
  HANGING_MODE_INSET = 6;
39987
40315
  }
39988
40316
  });
40317
+ function dispatchHangingMode(nodes, box, palette, style, elementId, roots, itemShape, connectorLabels, algorithmNode, index, fontName, presLayoutVars, orgChart, cornerPlan) {
40318
+ if (roots.length > 1) {
40319
+ const fanned = arrangeFannedHangingForest(
40320
+ nodes,
40321
+ box,
40322
+ palette,
40323
+ style,
40324
+ elementId,
40325
+ roots,
40326
+ itemShape,
40327
+ connectorLabels,
40328
+ algorithmNode,
40329
+ index,
40330
+ fontName,
40331
+ presLayoutVars,
40332
+ orgChart
40333
+ );
40334
+ if (fanned) {
40335
+ return fanned;
40336
+ }
40337
+ }
40338
+ return arrangeFullyHangingTree(
40339
+ nodes,
40340
+ box,
40341
+ palette,
40342
+ style,
40343
+ elementId,
40344
+ roots,
40345
+ itemShape,
40346
+ connectorLabels,
40347
+ algorithmNode,
40348
+ index,
40349
+ fontName,
40350
+ cornerPlan?.linDir,
40351
+ orgChart,
40352
+ presLayoutVars,
40353
+ cornerPlan?.side
40354
+ );
40355
+ }
40356
+ var init_smartart_hierarchy_hang_dispatch = __esm({
40357
+ "src/core/utils/smartart-hierarchy-hang-dispatch.ts"() {
40358
+ init_smartart_hierarchy_fanned_hang();
40359
+ init_smartart_hierarchy_hanging_arrange();
40360
+ }
40361
+ });
39989
40362
  function findCompositeDescendant(node) {
39990
40363
  if (!node) {
39991
40364
  return void 0;
@@ -40342,7 +40715,7 @@ function resolveHierarchyOrientation(algorithmNode, index, mode = "std", itemSha
40342
40715
  index,
40343
40716
  roleOf(algorithmNode),
40344
40717
  ["sibSp"],
40345
- DEFAULT_SIB_SP_RATIO,
40718
+ DEFAULT_SIB_SP_RATIO2,
40346
40719
  algorithmNode?.rules
40347
40720
  );
40348
40721
  if (sibSpReferencesHeight || tailedTransposed) {
@@ -40406,7 +40779,7 @@ function resolveHierarchyOrientation(algorithmNode, index, mode = "std", itemSha
40406
40779
  cardOffsetXRatio: compositeChild?.offsetXRatio ?? 0
40407
40780
  };
40408
40781
  }
40409
- var DEFAULT_SIB_SP_RATIO;
40782
+ var DEFAULT_SIB_SP_RATIO2;
40410
40783
  var OUTER_MARGIN_X_RATIO;
40411
40784
  var OUTER_MARGIN_Y_RATIO;
40412
40785
  var init_smartart_hierarchy_orientation = __esm({
@@ -40422,7 +40795,7 @@ var init_smartart_hierarchy_orientation = __esm({
40422
40795
  init_smartart_hierarchy_transpose();
40423
40796
  init_smartart_hierarchy_fit_item_box();
40424
40797
  init_smartart_hierarchy_child_order();
40425
- DEFAULT_SIB_SP_RATIO = 0.1;
40798
+ DEFAULT_SIB_SP_RATIO2 = 0.1;
40426
40799
  OUTER_MARGIN_X_RATIO = 0.0491;
40427
40800
  OUTER_MARGIN_Y_RATIO = 0.0707;
40428
40801
  }
@@ -40848,7 +41221,7 @@ function arrangeHierarchy(nodes, box, palette, style, elementId, presLayoutVars,
40848
41221
  const mode = branchMode(presLayoutVars, cornerPlan?.linDir);
40849
41222
  const itemShape = algorithmNode ? findHierarchyItemShape(algorithmNode) : void 0;
40850
41223
  if (mode === "hanging") {
40851
- return arrangeFullyHangingTree(
41224
+ return dispatchHangingMode(
40852
41225
  nodes,
40853
41226
  box,
40854
41227
  palette,
@@ -40860,9 +41233,9 @@ function arrangeHierarchy(nodes, box, palette, style, elementId, presLayoutVars,
40860
41233
  algorithmNode,
40861
41234
  index,
40862
41235
  fontName,
40863
- cornerPlan?.linDir,
41236
+ presLayoutVars,
40864
41237
  orgChart,
40865
- cornerPlan?.side
41238
+ cornerPlan
40866
41239
  );
40867
41240
  }
40868
41241
  const { orientation, swapAxes, effectiveBox } = resolveHierarchyEffectiveOrientation(
@@ -40972,7 +41345,7 @@ var init_smartart_layout_interpreter_hierarchy = __esm({
40972
41345
  init_smartart_hierarchy_fan_aware_width();
40973
41346
  init_smartart_hierarchy_fold_depth();
40974
41347
  init_smartart_hierarchy_hang_depth();
40975
- init_smartart_hierarchy_hanging_arrange();
41348
+ init_smartart_hierarchy_hang_dispatch();
40976
41349
  init_smartart_hierarchy_orgchart_tree();
40977
41350
  init_smartart_hierarchy_orientation();
40978
41351
  init_smartart_hierarchy_orientation_resolve();
@@ -46531,16 +46904,29 @@ function parseChartUniqueId(node, localName28) {
46531
46904
  const val2 = uniqueIdNode?.["@_val"];
46532
46905
  return typeof val2 === "string" && val2.length > 0 ? val2 : void 0;
46533
46906
  }
46907
+ function randomBytes(length) {
46908
+ const cryptoObj = typeof crypto === "undefined" ? void 0 : crypto;
46909
+ if (cryptoObj && typeof cryptoObj.getRandomValues === "function") {
46910
+ return cryptoObj.getRandomValues(new Uint8Array(length));
46911
+ }
46912
+ const bytes = new Uint8Array(length);
46913
+ for (let i2 = 0; i2 < length; i2++) {
46914
+ bytes[i2] = Math.floor(Math.random() * 256);
46915
+ }
46916
+ return bytes;
46917
+ }
46534
46918
  function randomHex(length) {
46919
+ const bytes = randomBytes(Math.ceil(length / 2));
46535
46920
  let out = "";
46536
- for (let i2 = 0; i2 < length; i2++) {
46537
- out += Math.floor(Math.random() * 16).toString(16);
46921
+ for (const b of bytes) {
46922
+ out += b.toString(16).padStart(2, "0");
46538
46923
  }
46539
- return out;
46924
+ return out.slice(0, length);
46540
46925
  }
46541
46926
  function generateChartUniqueId() {
46542
46927
  const cryptoObj = typeof crypto === "undefined" ? void 0 : crypto;
46543
- const uuid = cryptoObj && typeof cryptoObj.randomUUID === "function" ? cryptoObj.randomUUID() : `${randomHex(8)}-${randomHex(4)}-4${randomHex(3)}-${(8 + Math.floor(Math.random() * 4)).toString(16)}${randomHex(3)}-${randomHex(12)}`;
46928
+ const variantNibble = (8 + randomBytes(1)[0] % 4).toString(16);
46929
+ const uuid = cryptoObj && typeof cryptoObj.randomUUID === "function" ? cryptoObj.randomUUID() : `${randomHex(8)}-${randomHex(4)}-4${randomHex(3)}-${variantNibble}${randomHex(3)}-${randomHex(12)}`;
46544
46930
  return `{${uuid.toUpperCase()}}`;
46545
46931
  }
46546
46932
  function buildChartUniqueIdExtLst(uniqueId) {
@@ -49300,7 +49686,7 @@ function parseWorksheetCells(xml) {
49300
49686
  return [];
49301
49687
  }
49302
49688
  const rows = getChildArray(sheetData, "row");
49303
- const cells = [];
49689
+ const cells2 = [];
49304
49690
  for (const row of rows) {
49305
49691
  const cellNodes = getChildArray(row, "c");
49306
49692
  for (const cell of cellNodes) {
@@ -49314,7 +49700,7 @@ function parseWorksheetCells(xml) {
49314
49700
  if (rawValue === void 0) {
49315
49701
  continue;
49316
49702
  }
49317
- cells.push({
49703
+ cells2.push({
49318
49704
  col,
49319
49705
  row: rowIdx,
49320
49706
  type: cellType,
@@ -49322,7 +49708,7 @@ function parseWorksheetCells(xml) {
49322
49708
  });
49323
49709
  }
49324
49710
  }
49325
- return cells;
49711
+ return cells2;
49326
49712
  }
49327
49713
  function findByLocalName2(obj, localName28) {
49328
49714
  for (const key2 of Object.keys(obj)) {
@@ -49423,13 +49809,13 @@ async function parseEmbeddedXlsx(xlsxData) {
49423
49809
  }
49424
49810
  const sheet1Xml = await sheet1File.async("string");
49425
49811
  const parsedSheet = xmlParser.parse(sheet1Xml);
49426
- const cells = parseWorksheetCells(parsedSheet);
49427
- if (cells.length === 0) {
49812
+ const cells2 = parseWorksheetCells(parsedSheet);
49813
+ if (cells2.length === 0) {
49428
49814
  return void 0;
49429
49815
  }
49430
49816
  let maxRow = 0;
49431
49817
  let maxCol = 0;
49432
- for (const cell of cells) {
49818
+ for (const cell of cells2) {
49433
49819
  if (cell.row > maxRow) {
49434
49820
  maxRow = cell.row;
49435
49821
  }
@@ -49441,7 +49827,7 @@ async function parseEmbeddedXlsx(xlsxData) {
49441
49827
  for (let r = 0; r <= maxRow; r++) {
49442
49828
  grid[r] = Array.from({ length: maxCol + 1 }).fill(void 0);
49443
49829
  }
49444
- for (const cell of cells) {
49830
+ for (const cell of cells2) {
49445
49831
  grid[cell.row][cell.col] = resolveCellValue(cell, sharedStrings);
49446
49832
  }
49447
49833
  if (maxRow === 0 && maxCol === 0) {
@@ -67383,11 +67769,11 @@ function annotateParagraphSiblingOrder(xml, parsed) {
67383
67769
  }
67384
67770
  }
67385
67771
  }
67386
- function paragraphContentEntries(paragraph, contentTags, ensureArray20) {
67772
+ function paragraphContentEntries(paragraph, contentTags) {
67387
67773
  const order = childOrder2.get(paragraph);
67388
67774
  if (!order) {
67389
67775
  const entries2 = Object.keys(paragraph).flatMap(
67390
- (key2) => contentTags.has(key2) ? ensureArray20(paragraph[key2]).map((item) => [key2, item]) : []
67776
+ (key2) => contentTags.has(key2) ? ensureItems(paragraph[key2]).map((item) => [key2, item]) : []
67391
67777
  );
67392
67778
  return { entries: entries2, authored: false };
67393
67779
  }
@@ -67399,7 +67785,7 @@ function paragraphContentEntries(paragraph, contentTags, ensureArray20) {
67399
67785
  if (!contentTags.has(tag)) {
67400
67786
  continue;
67401
67787
  }
67402
- const item = ensureArray20(paragraph[tag])[index];
67788
+ const item = ensureItems(paragraph[tag])[index];
67403
67789
  if (item !== void 0) {
67404
67790
  entries.push([tag, item]);
67405
67791
  }
@@ -67465,29 +67851,29 @@ function extractTableCellTextRuns(tableCell, context) {
67465
67851
  return void 0;
67466
67852
  }
67467
67853
  const runs = [];
67468
- let textRunCount = 0;
67854
+ let contentRunCount = 0;
67469
67855
  paragraphs.forEach((paragraph, paragraphIndex) => {
67470
67856
  if (paragraphIndex > 0) {
67471
67857
  runs.push({ text: "", isParagraphBreak: true });
67472
67858
  }
67473
- const { entries } = paragraphContentEntries(
67474
- paragraph,
67475
- CELL_CONTENT_TAGS,
67476
- (value) => context.ensureArray(value)
67477
- );
67859
+ const { entries } = paragraphContentEntries(paragraph, CELL_CONTENT_TAGS);
67478
67860
  for (const [tag, item] of entries) {
67479
67861
  if (tag === "a:br") {
67480
67862
  runs.push({ text: "", isLineBreak: true });
67863
+ contentRunCount++;
67481
67864
  continue;
67482
67865
  }
67483
67866
  const node = item;
67484
67867
  const run = { text: String(node?.["a:t"] ?? "") };
67868
+ if (tag === "a:fld") {
67869
+ run.isField = true;
67870
+ }
67485
67871
  applyRunProperties(run, node?.["a:rPr"], context);
67486
67872
  runs.push(run);
67487
- textRunCount++;
67873
+ contentRunCount++;
67488
67874
  }
67489
67875
  });
67490
- return textRunCount > 0 ? runs : void 0;
67876
+ return contentRunCount > 0 ? runs : void 0;
67491
67877
  }
67492
67878
  var CELL_CONTENT_TAGS;
67493
67879
  var init_table_cell_runs = __esm({
@@ -99445,6 +99831,46 @@ var init_table_cell_save_helpers = __esm({
99445
99831
  init_color_xml_preservation();
99446
99832
  }
99447
99833
  });
99834
+ function ensureArray19(value) {
99835
+ if (value === void 0 || value === null) {
99836
+ return [];
99837
+ }
99838
+ return Array.isArray(value) ? value : [value];
99839
+ }
99840
+ function createDefaultXmlCell() {
99841
+ return {
99842
+ "a:txBody": {
99843
+ "a:bodyPr": {},
99844
+ "a:lstStyle": {},
99845
+ "a:p": {
99846
+ // Match PowerPoint's "Insert Table" default: every paragraph-end
99847
+ // run carries `lang="en-US" dirty="0"`.
99848
+ "a:endParaRPr": { "@_lang": "en-US", "@_dirty": "0" }
99849
+ }
99850
+ },
99851
+ "a:tcPr": {}
99852
+ };
99853
+ }
99854
+ function createDefaultXmlRow(colCount, heightEmu) {
99855
+ const cells2 = Array.from({ length: colCount }, () => createDefaultXmlCell());
99856
+ return {
99857
+ "@_h": String(DEFAULT_ROW_HEIGHT_EMU),
99858
+ "a:tc": cells2.length === 1 ? cells2[0] : cells2
99859
+ };
99860
+ }
99861
+ function getTblFromRawXml(rawXml) {
99862
+ const graphicData = rawXml["a:graphic"]?.["a:graphicData"];
99863
+ return graphicData?.["a:tbl"];
99864
+ }
99865
+ var DEFAULT_ROW_HEIGHT_PX;
99866
+ var DEFAULT_ROW_HEIGHT_EMU;
99867
+ var init_table_structural_helpers = __esm({
99868
+ "src/core/core/runtime/table-structural-helpers.ts"() {
99869
+ init_constants();
99870
+ DEFAULT_ROW_HEIGHT_PX = 40;
99871
+ DEFAULT_ROW_HEIGHT_EMU = DEFAULT_ROW_HEIGHT_PX * EMU_PER_PX;
99872
+ }
99873
+ });
99448
99874
  function flattenCellTxBodyText(txBody, ensureArray20) {
99449
99875
  if (!txBody) {
99450
99876
  return "";
@@ -99465,6 +99891,45 @@ function flattenCellTxBodyText(txBody, ensureArray20) {
99465
99891
  }
99466
99892
  return lines.join("\n");
99467
99893
  }
99894
+ function tableCellTextBodyMatches(txBody, text22, ensureArray20 = xmlArray) {
99895
+ return Boolean(
99896
+ txBody && ensureArray20(txBody["a:p"]).length > 0 && flattenCellTxBodyText(txBody, ensureArray20) === text22
99897
+ );
99898
+ }
99899
+ function rebuildCellTextBody(existingTxBody, text22) {
99900
+ const existingParagraphs = ensureArray19(
99901
+ existingTxBody?.["a:p"]
99902
+ );
99903
+ const firstParagraph = existingParagraphs.length > 0 ? existingParagraphs[0] : void 0;
99904
+ const existingRuns = firstParagraph ? ensureArray19(firstParagraph["a:r"]) : [];
99905
+ const firstRunProps = existingRuns.length > 0 ? existingRuns[0]["a:rPr"] : void 0;
99906
+ const newRun = {};
99907
+ if (firstRunProps !== void 0) {
99908
+ newRun["a:rPr"] = firstRunProps;
99909
+ }
99910
+ newRun["a:t"] = text22;
99911
+ const newParagraph = {};
99912
+ if (firstParagraph?.["a:pPr"] !== void 0) {
99913
+ newParagraph["a:pPr"] = firstParagraph["a:pPr"];
99914
+ }
99915
+ newParagraph["a:r"] = newRun;
99916
+ const newTxBody = {};
99917
+ if (existingTxBody?.["a:bodyPr"] !== void 0) {
99918
+ newTxBody["a:bodyPr"] = existingTxBody["a:bodyPr"];
99919
+ }
99920
+ if (existingTxBody?.["a:lstStyle"] !== void 0) {
99921
+ newTxBody["a:lstStyle"] = existingTxBody["a:lstStyle"];
99922
+ }
99923
+ newTxBody["a:p"] = newParagraph;
99924
+ return newTxBody;
99925
+ }
99926
+ var xmlArray;
99927
+ var init_table_cell_text_xml = __esm({
99928
+ "src/core/core/runtime/table-cell-text-xml.ts"() {
99929
+ init_table_structural_helpers();
99930
+ xmlArray = (value) => ensureArray19(value);
99931
+ }
99932
+ });
99468
99933
  function isRichCellTxBody(txBody, ensureArray20) {
99469
99934
  if (!txBody) {
99470
99935
  return false;
@@ -99495,6 +99960,8 @@ var init_PptxHandlerRuntimeSaveTableStyles = __esm({
99495
99960
  init_xml_reorder();
99496
99961
  init_PptxHandlerRuntimeLayoutSwitching();
99497
99962
  init_table_cell_save_helpers();
99963
+ init_table_cell_text_xml();
99964
+ init_table_cell_text_xml();
99498
99965
  PptxHandlerRuntime22 = class _PptxHandlerRuntime extends PptxHandlerRuntime21 {
99499
99966
  /**
99500
99967
  * Write plain text into a table cell's txBody, preserving
@@ -99503,10 +99970,8 @@ var init_PptxHandlerRuntimeSaveTableStyles = __esm({
99503
99970
  writeTableCellText(xmlCell, text22) {
99504
99971
  const ensureArray20 = this.ensureArray.bind(this);
99505
99972
  const existingTxBody = xmlCell["a:txBody"];
99506
- if (existingTxBody && ensureArray20(existingTxBody["a:p"]).length > 0) {
99507
- if (flattenCellTxBodyText(existingTxBody, ensureArray20) === text22) {
99508
- return;
99509
- }
99973
+ if (tableCellTextBodyMatches(existingTxBody, text22, ensureArray20)) {
99974
+ return;
99510
99975
  }
99511
99976
  if (!xmlCell["a:txBody"]) {
99512
99977
  xmlCell["a:txBody"] = { "a:bodyPr": {}, "a:p": {} };
@@ -99945,37 +100410,147 @@ var init_save_table_merge_helpers = __esm({
99945
100410
  ];
99946
100411
  }
99947
100412
  });
99948
- function ensureArray19(value) {
99949
- if (value === void 0 || value === null) {
99950
- return [];
100413
+ function runTag(run) {
100414
+ return run.isLineBreak ? "a:br" : run.isField ? "a:fld" : "a:r";
100415
+ }
100416
+ function supportsOrder(paragraph, tags) {
100417
+ for (const [key2, value] of Object.entries(paragraph)) {
100418
+ if (key2.startsWith("@_") || key2 === "a:pPr" || key2 === "a:endParaRPr") {
100419
+ continue;
100420
+ }
100421
+ if (key2 === "#text" && String(value).trim() === "") {
100422
+ continue;
100423
+ }
100424
+ if (!CONTENT_TAGS.has(key2)) {
100425
+ return false;
100426
+ }
99951
100427
  }
99952
- return Array.isArray(value) ? value : [value];
100428
+ return [...CONTENT_TAGS].every(
100429
+ (tag) => tags.filter((candidate) => candidate === tag).length === ensureItems(paragraph[tag]).length
100430
+ );
99953
100431
  }
99954
- function createDefaultXmlCell() {
99955
- return {
99956
- "a:txBody": {
99957
- "a:bodyPr": {},
99958
- "a:lstStyle": {},
99959
- "a:p": {
99960
- // Match PowerPoint's "Insert Table" default: every paragraph-end
99961
- // run carries `lang="en-US" dirty="0"`.
99962
- "a:endParaRPr": { "@_lang": "en-US", "@_dirty": "0" }
99963
- }
99964
- },
99965
- "a:tcPr": {}
99966
- };
100432
+ function matchesParagraph(paragraph, runs) {
100433
+ if (!supportsOrder(paragraph, runs.map(runTag))) {
100434
+ return false;
100435
+ }
100436
+ const consumed = /* @__PURE__ */ new Map();
100437
+ for (const run of runs) {
100438
+ const tag = runTag(run);
100439
+ const index = consumed.get(tag) ?? 0;
100440
+ const node = ensureItems(paragraph[tag])[index];
100441
+ if (node === void 0) {
100442
+ return false;
100443
+ }
100444
+ if (tag !== "a:br" && (!isXmlObject3(node) || String(node["a:t"] ?? "") !== run.text)) {
100445
+ return false;
100446
+ }
100447
+ consumed.set(tag, index + 1);
100448
+ }
100449
+ return true;
99967
100450
  }
99968
- function getTblFromRawXml(rawXml) {
99969
- const graphicData = rawXml["a:graphic"]?.["a:graphicData"];
99970
- return graphicData?.["a:tbl"];
100451
+ function recordTableParagraphOrder(xmlCell, textRuns) {
100452
+ const txBody = xmlCell["a:txBody"];
100453
+ const paragraphs = isXmlObject3(txBody) ? ensureItems(txBody["a:p"]) : [];
100454
+ for (const paragraph of paragraphs) {
100455
+ if (isXmlObject3(paragraph)) {
100456
+ paragraphOrders.delete(paragraph);
100457
+ }
100458
+ }
100459
+ if (!textRuns) {
100460
+ return;
100461
+ }
100462
+ const runsByParagraph = [[]];
100463
+ for (const run of textRuns) {
100464
+ if (run.isParagraphBreak) {
100465
+ runsByParagraph.push([]);
100466
+ } else {
100467
+ runsByParagraph.at(-1).push(run);
100468
+ }
100469
+ }
100470
+ if (runsByParagraph.length !== paragraphs.length) {
100471
+ return;
100472
+ }
100473
+ paragraphs.forEach((paragraph, index) => {
100474
+ const runs = runsByParagraph[index];
100475
+ const tags = runs.map(runTag);
100476
+ if (isXmlObject3(paragraph) && !isGroupedByTag(tags) && matchesParagraph(paragraph, runs)) {
100477
+ paragraphOrders.set(paragraph, tags);
100478
+ }
100479
+ });
99971
100480
  }
99972
- var DEFAULT_ROW_HEIGHT_PX;
99973
- var DEFAULT_ROW_HEIGHT_EMU;
99974
- var init_table_structural_helpers = __esm({
99975
- "src/core/core/runtime/table-structural-helpers.ts"() {
99976
- init_constants();
99977
- DEFAULT_ROW_HEIGHT_PX = 40;
99978
- DEFAULT_ROW_HEIGHT_EMU = DEFAULT_ROW_HEIGHT_PX * EMU_PER_PX;
100481
+ function orderedParagraph(paragraph, tags) {
100482
+ const result = {};
100483
+ for (const [key2, value] of Object.entries(paragraph)) {
100484
+ if (!CONTENT_TAGS.has(key2) && key2 !== "a:pPr" && key2 !== "a:endParaRPr") {
100485
+ setOwnXmlProperty(result, key2, value);
100486
+ }
100487
+ }
100488
+ if (paragraph["a:pPr"] !== void 0) {
100489
+ result["a:pPr"] = paragraph["a:pPr"];
100490
+ }
100491
+ const consumed = /* @__PURE__ */ new Map();
100492
+ assignOrderedXmlChildren(
100493
+ result,
100494
+ tags.map((tag) => {
100495
+ const index = consumed.get(tag) ?? 0;
100496
+ consumed.set(tag, index + 1);
100497
+ return { tag, node: ensureItems(paragraph[tag])[index] };
100498
+ })
100499
+ );
100500
+ if (paragraph["a:endParaRPr"] !== void 0) {
100501
+ result["a:endParaRPr"] = paragraph["a:endParaRPr"];
100502
+ }
100503
+ return result;
100504
+ }
100505
+ function withOrderedTableParagraphs(value, insideTable = false) {
100506
+ if (Array.isArray(value)) {
100507
+ let result2 = value;
100508
+ value.forEach((item, index) => {
100509
+ const next = withOrderedTableParagraphs(item, insideTable);
100510
+ if (next !== item) {
100511
+ if (result2 === value) {
100512
+ result2 = [...value];
100513
+ }
100514
+ result2[index] = next;
100515
+ }
100516
+ });
100517
+ return result2;
100518
+ }
100519
+ if (!isXmlObject3(value)) {
100520
+ return value;
100521
+ }
100522
+ let result = value;
100523
+ for (const [key2, item] of Object.entries(value)) {
100524
+ if (key2.startsWith("@_") || key2 === "#text") {
100525
+ continue;
100526
+ }
100527
+ const next = withOrderedTableParagraphs(item, insideTable || key2 === "a:tbl");
100528
+ if (next !== item) {
100529
+ if (result === value) {
100530
+ result = { ...value };
100531
+ }
100532
+ setOwnXmlProperty(result, key2, next);
100533
+ }
100534
+ }
100535
+ let tags = paragraphOrders.get(value);
100536
+ if (!tags && insideTable) {
100537
+ const { entries, authored } = paragraphContentEntries(value, CONTENT_TAGS);
100538
+ const sourceTags = entries.map(([tag]) => tag);
100539
+ if (authored && supportsOrder(value, sourceTags)) {
100540
+ tags = sourceTags;
100541
+ }
100542
+ }
100543
+ return tags ? orderedParagraph(result, tags) : result;
100544
+ }
100545
+ var CONTENT_TAGS;
100546
+ var paragraphOrders;
100547
+ var init_table_paragraph_save_order = __esm({
100548
+ "src/core/core/runtime/table-paragraph-save-order.ts"() {
100549
+ init_ordered_xml_children();
100550
+ init_paragraph_sibling_order();
100551
+ init_xml_child_scan();
100552
+ CONTENT_TAGS = /* @__PURE__ */ new Set(["a:r", "a:br", "a:fld"]);
100553
+ paragraphOrders = /* @__PURE__ */ new WeakMap();
99979
100554
  }
99980
100555
  });
99981
100556
  var init_table_row_ops = __esm({
@@ -100163,6 +100738,157 @@ var init_table_create_xml = __esm({
100163
100738
  init_table_style_defaults();
100164
100739
  }
100165
100740
  });
100741
+ function cells(row) {
100742
+ return ensureArray19(row["a:tc"]);
100743
+ }
100744
+ function promoteTextBody(source, next, removed, survivor, axis) {
100745
+ const span = axis === "row" ? "rowSpan" : "gridSpan";
100746
+ const continuation = axis === "row" ? "vMerge" : "hMerge";
100747
+ if (!source?.text || !next || !removed || !survivor || source[continuation] || (source[span] ?? 1) <= 1 || next[continuation] || (next[span] ?? 1) !== (source[span] ?? 1) - 1) {
100748
+ return;
100749
+ }
100750
+ if (removed["a:txBody"] !== void 0) {
100751
+ survivor["a:txBody"] = removed["a:txBody"];
100752
+ }
100753
+ }
100754
+ function applyTableStructureEditXml(table2, source, next, edit) {
100755
+ const rows = ensureArray19(table2["a:tr"]);
100756
+ const grid = table2["a:tblGrid"];
100757
+ const columns = ensureArray19(grid?.["a:gridCol"]);
100758
+ const { axis, action, index } = edit;
100759
+ if (axis !== "row" && axis !== "column" || action !== "insert" && action !== "delete") {
100760
+ return false;
100761
+ }
100762
+ const count = axis === "row" ? rows.length : columns.length;
100763
+ const delta = action === "insert" ? 1 : -1;
100764
+ if (!grid || !Number.isInteger(index) || index < 0 || index > count - (action === "delete" ? 1 : 0) || action === "delete" && count <= 1 || next.rows.length !== rows.length + (axis === "row" ? delta : 0) || next.columnWidths.length !== columns.length + (axis === "column" ? delta : 0)) {
100765
+ return false;
100766
+ }
100767
+ if (axis === "row") {
100768
+ if (action === "insert") {
100769
+ rows.splice(index, 0, createDefaultXmlRow(columns.length));
100770
+ } else {
100771
+ const removedCells = cells(rows[index]);
100772
+ const nextCells = rows[index + 1] ? cells(rows[index + 1]) : [];
100773
+ removedCells.forEach(
100774
+ (removed, column) => promoteTextBody(
100775
+ source?.rows[index]?.cells[column],
100776
+ next.rows[index]?.cells[column],
100777
+ removed,
100778
+ nextCells[column],
100779
+ axis
100780
+ )
100781
+ );
100782
+ rows.splice(index, 1);
100783
+ }
100784
+ table2["a:tr"] = rows.length === 1 ? rows[0] : rows;
100785
+ } else {
100786
+ if (action === "insert") {
100787
+ columns.splice(index, 0, { "@_w": "0" });
100788
+ } else {
100789
+ columns.splice(index, 1);
100790
+ }
100791
+ grid["a:gridCol"] = columns.length === 1 ? columns[0] : columns;
100792
+ rows.forEach((row, rowIndex) => {
100793
+ const rowCells = cells(row);
100794
+ if (action === "insert") {
100795
+ rowCells.splice(index, 0, createDefaultXmlCell());
100796
+ } else {
100797
+ promoteTextBody(
100798
+ source?.rows[rowIndex]?.cells[index],
100799
+ next.rows[rowIndex]?.cells[index],
100800
+ rowCells[index],
100801
+ rowCells[index + 1],
100802
+ axis
100803
+ );
100804
+ rowCells.splice(index, 1);
100805
+ }
100806
+ row["a:tc"] = rowCells.length === 1 ? rowCells[0] : rowCells;
100807
+ });
100808
+ }
100809
+ return true;
100810
+ }
100811
+ var init_table_structure_edit_xml = __esm({
100812
+ "src/core/core/runtime/table-structure-edit-xml.ts"() {
100813
+ init_table_structural_helpers();
100814
+ }
100815
+ });
100816
+ function createDefaultRebuildXmlCell() {
100817
+ return {
100818
+ "a:txBody": {
100819
+ "a:bodyPr": {},
100820
+ "a:lstStyle": {},
100821
+ "a:p": {
100822
+ "a:endParaRPr": { "@_lang": "en-US" }
100823
+ }
100824
+ },
100825
+ "a:tcPr": {}
100826
+ };
100827
+ }
100828
+ function rebuildTableStructureInRawXml(element, tableData, edit) {
100829
+ if (!element.rawXml) {
100830
+ return void 0;
100831
+ }
100832
+ const newRawXml = structuredClone(element.rawXml);
100833
+ const table2 = getTblFromRawXml(newRawXml);
100834
+ if (!table2) {
100835
+ return void 0;
100836
+ }
100837
+ const existingGridCols = ensureArray19(
100838
+ table2["a:tblGrid"]?.["a:gridCol"]
100839
+ );
100840
+ const totalWidthEmu = existingGridCols.reduce((sum, col) => {
100841
+ return sum + (parseInt(String(col?.["@_w"] || "0"), 10) || 0);
100842
+ }, 0) || 9144e3;
100843
+ const appliedEdit = edit ? applyTableStructureEditXml(
100844
+ table2,
100845
+ element.type === "table" ? element.tableData : void 0,
100846
+ tableData,
100847
+ edit
100848
+ ) : false;
100849
+ const alignedGridCols = ensureArray19(
100850
+ table2["a:tblGrid"]?.["a:gridCol"]
100851
+ );
100852
+ const newGridCols = tableData.columnWidths.map((w, index) => ({
100853
+ ...appliedEdit ? alignedGridCols[index] : {},
100854
+ "@_w": String(Math.round(w * totalWidthEmu))
100855
+ }));
100856
+ if (!table2["a:tblGrid"]) {
100857
+ table2["a:tblGrid"] = {};
100858
+ }
100859
+ table2["a:tblGrid"]["a:gridCol"] = newGridCols.length === 1 ? newGridCols[0] : newGridCols;
100860
+ const existingXmlRows = ensureArray19(table2["a:tr"]);
100861
+ const newXmlRows = tableData.rows.map((dataRow, ri) => {
100862
+ const existingRow = ri < existingXmlRows.length ? existingXmlRows[ri] : void 0;
100863
+ const existingCells = existingRow ? ensureArray19(existingRow["a:tc"]) : [];
100864
+ const heightEmu = dataRow.height ? Math.round(dataRow.height * EMU_PER_PX) : existingRow?.["@_h"] ? parseInt(String(existingRow["@_h"]), 10) : DEFAULT_ROW_HEIGHT_EMU;
100865
+ const newXmlCells = dataRow.cells.map((cell, ci) => {
100866
+ let xmlCell;
100867
+ if (ci < existingCells.length) {
100868
+ xmlCell = existingCells[ci];
100869
+ } else {
100870
+ xmlCell = createDefaultRebuildXmlCell();
100871
+ }
100872
+ serializeCellMergeAttributes(xmlCell, cell);
100873
+ return xmlCell;
100874
+ });
100875
+ return {
100876
+ ...appliedEdit ? existingRow : {},
100877
+ "@_h": String(heightEmu),
100878
+ "a:tc": newXmlCells.length === 1 ? newXmlCells[0] : newXmlCells
100879
+ };
100880
+ });
100881
+ table2["a:tr"] = newXmlRows.length === 1 ? newXmlRows[0] : newXmlRows;
100882
+ return newRawXml;
100883
+ }
100884
+ var init_table_structure_rawxml = __esm({
100885
+ "src/core/core/runtime/table-structure-rawxml.ts"() {
100886
+ init_constants();
100887
+ init_save_table_merge_helpers();
100888
+ init_table_structural_helpers();
100889
+ init_table_structure_edit_xml();
100890
+ }
100891
+ });
100166
100892
  function updateCellTextInRawXml(element, rowIndex, colIndex, text22) {
100167
100893
  if (!element.rawXml) {
100168
100894
  return void 0;
@@ -100176,43 +100902,16 @@ function updateCellTextInRawXml(element, rowIndex, colIndex, text22) {
100176
100902
  if (rowIndex < 0 || rowIndex >= rows.length) {
100177
100903
  return void 0;
100178
100904
  }
100179
- const cells = ensureArray19(rows[rowIndex]["a:tc"]);
100180
- if (colIndex < 0 || colIndex >= cells.length) {
100905
+ const cells2 = ensureArray19(rows[rowIndex]["a:tc"]);
100906
+ if (colIndex < 0 || colIndex >= cells2.length) {
100181
100907
  return void 0;
100182
100908
  }
100183
- cells[colIndex]["a:txBody"] = rebuildCellTextBody(
100184
- cells[colIndex]["a:txBody"],
100909
+ cells2[colIndex]["a:txBody"] = rebuildCellTextBody(
100910
+ cells2[colIndex]["a:txBody"],
100185
100911
  text22
100186
100912
  );
100187
100913
  return newRawXml;
100188
100914
  }
100189
- function rebuildCellTextBody(existingTxBody, text22) {
100190
- const existingParagraphs = ensureArray19(
100191
- existingTxBody?.["a:p"]
100192
- );
100193
- const firstParagraph = existingParagraphs.length > 0 ? existingParagraphs[0] : void 0;
100194
- const existingRuns = firstParagraph ? ensureArray19(firstParagraph["a:r"]) : [];
100195
- const firstRunProps = existingRuns.length > 0 ? existingRuns[0]["a:rPr"] : void 0;
100196
- const newRun = {};
100197
- if (firstRunProps !== void 0) {
100198
- newRun["a:rPr"] = firstRunProps;
100199
- }
100200
- newRun["a:t"] = text22;
100201
- const newParagraph = {};
100202
- if (firstParagraph?.["a:pPr"] !== void 0) {
100203
- newParagraph["a:pPr"] = firstParagraph["a:pPr"];
100204
- }
100205
- newParagraph["a:r"] = newRun;
100206
- const newTxBody = {};
100207
- if (existingTxBody?.["a:bodyPr"] !== void 0) {
100208
- newTxBody["a:bodyPr"] = existingTxBody["a:bodyPr"];
100209
- }
100210
- if (existingTxBody?.["a:lstStyle"] !== void 0) {
100211
- newTxBody["a:lstStyle"] = existingTxBody["a:lstStyle"];
100212
- }
100213
- newTxBody["a:p"] = newParagraph;
100214
- return newTxBody;
100215
- }
100216
100915
  function updateCellTextStyleInRawXml(element, rowIndex, colIndex, styleUpdates) {
100217
100916
  if (!element.rawXml) {
100218
100917
  return void 0;
@@ -100226,11 +100925,11 @@ function updateCellTextStyleInRawXml(element, rowIndex, colIndex, styleUpdates)
100226
100925
  if (rowIndex < 0 || rowIndex >= rows.length) {
100227
100926
  return void 0;
100228
100927
  }
100229
- const cells = ensureArray19(rows[rowIndex]["a:tc"]);
100230
- if (colIndex < 0 || colIndex >= cells.length) {
100928
+ const cells2 = ensureArray19(rows[rowIndex]["a:tc"]);
100929
+ if (colIndex < 0 || colIndex >= cells2.length) {
100231
100930
  return void 0;
100232
100931
  }
100233
- const cell = cells[colIndex];
100932
+ const cell = cells2[colIndex];
100234
100933
  const txBody = cell["a:txBody"];
100235
100934
  if (!txBody) {
100236
100935
  return void 0;
@@ -100351,97 +101050,20 @@ function updateMergeAttrsInRawXml(element, tableData) {
100351
101050
  } else {
100352
101051
  delete xmlCell["@_vMerge"];
100353
101052
  }
100354
- if (cell.text !== void 0) {
100355
- xmlCell["a:txBody"] = rebuildCellTextBody(
100356
- xmlCell["a:txBody"],
100357
- cell.text
100358
- );
101053
+ const txBody = xmlCell["a:txBody"];
101054
+ if (cell.text !== void 0 && !tableCellTextBodyMatches(txBody, cell.text)) {
101055
+ xmlCell["a:txBody"] = rebuildCellTextBody(txBody, cell.text);
100359
101056
  }
100360
101057
  }
100361
101058
  }
100362
101059
  return newRawXml;
100363
101060
  }
100364
- function createDefaultRebuildXmlCell() {
100365
- return {
100366
- "a:txBody": {
100367
- "a:bodyPr": {},
100368
- "a:lstStyle": {},
100369
- "a:p": {
100370
- "a:endParaRPr": { "@_lang": "en-US" }
100371
- }
100372
- },
100373
- "a:tcPr": {}
100374
- };
100375
- }
100376
- function rebuildTableStructureInRawXml(element, tableData) {
100377
- if (!element.rawXml) {
100378
- return void 0;
100379
- }
100380
- const newRawXml = structuredClone(element.rawXml);
100381
- const table2 = getTblFromRawXml(newRawXml);
100382
- if (!table2) {
100383
- return void 0;
100384
- }
100385
- const existingGridCols = ensureArray19(
100386
- table2["a:tblGrid"]?.["a:gridCol"]
100387
- );
100388
- const totalWidthEmu = existingGridCols.reduce((sum, col) => {
100389
- return sum + (parseInt(String(col?.["@_w"] || "0"), 10) || 0);
100390
- }, 0) || 9144e3;
100391
- const newGridCols = tableData.columnWidths.map((w) => ({
100392
- "@_w": String(Math.round(w * totalWidthEmu))
100393
- }));
100394
- if (!table2["a:tblGrid"]) {
100395
- table2["a:tblGrid"] = {};
100396
- }
100397
- table2["a:tblGrid"]["a:gridCol"] = newGridCols.length === 1 ? newGridCols[0] : newGridCols;
100398
- const existingXmlRows = ensureArray19(table2["a:tr"]);
100399
- const newXmlRows = tableData.rows.map((dataRow, ri) => {
100400
- const existingRow = ri < existingXmlRows.length ? existingXmlRows[ri] : void 0;
100401
- const existingCells = existingRow ? ensureArray19(existingRow["a:tc"]) : [];
100402
- const heightEmu = dataRow.height ? Math.round(dataRow.height * EMU_PER_PX) : existingRow?.["@_h"] ? parseInt(String(existingRow["@_h"]), 10) : DEFAULT_ROW_HEIGHT_EMU;
100403
- const newXmlCells = dataRow.cells.map((cell, ci) => {
100404
- let xmlCell;
100405
- if (ci < existingCells.length) {
100406
- xmlCell = structuredClone(existingCells[ci]);
100407
- } else {
100408
- xmlCell = createDefaultRebuildXmlCell();
100409
- }
100410
- if (cell.gridSpan !== void 0 && cell.gridSpan > 1) {
100411
- xmlCell["@_gridSpan"] = String(cell.gridSpan);
100412
- } else {
100413
- delete xmlCell["@_gridSpan"];
100414
- }
100415
- if (cell.rowSpan !== void 0 && cell.rowSpan > 1) {
100416
- xmlCell["@_rowSpan"] = String(cell.rowSpan);
100417
- } else {
100418
- delete xmlCell["@_rowSpan"];
100419
- }
100420
- if (cell.hMerge) {
100421
- xmlCell["@_hMerge"] = "1";
100422
- } else {
100423
- delete xmlCell["@_hMerge"];
100424
- }
100425
- if (cell.vMerge) {
100426
- xmlCell["@_vMerge"] = "1";
100427
- } else {
100428
- delete xmlCell["@_vMerge"];
100429
- }
100430
- return xmlCell;
100431
- });
100432
- return {
100433
- "@_h": String(heightEmu),
100434
- "a:tc": newXmlCells.length === 1 ? newXmlCells[0] : newXmlCells
100435
- };
100436
- });
100437
- table2["a:tr"] = newXmlRows.length === 1 ? newXmlRows[0] : newXmlRows;
100438
- return newRawXml;
100439
- }
100440
101061
  var init_table_cell_rawxml_ops = __esm({
100441
101062
  "src/core/core/runtime/table-cell-rawxml-ops.ts"() {
100442
- init_constants();
100443
101063
  init_xml_access();
101064
+ init_table_cell_text_xml();
100444
101065
  init_table_structural_helpers();
101066
+ init_table_structure_rawxml();
100445
101067
  }
100446
101068
  });
100447
101069
  var init_table_structural_ops = __esm({
@@ -100672,6 +101294,7 @@ var init_PptxHandlerRuntimeSaveDataSerialization = __esm({
100672
101294
  init_chart_part_family_switch();
100673
101295
  init_PptxHandlerRuntimeChartUserShapes();
100674
101296
  init_save_table_merge_helpers();
101297
+ init_table_paragraph_save_order();
100675
101298
  init_table_structural_ops();
100676
101299
  init_table_tblpr_save();
100677
101300
  CHART_DATA_DISPLAY_OPTIONS_EXT_URI = "{56B9EC1D-385E-4148-901F-78D8002777C0}";
@@ -100749,6 +101372,7 @@ var init_PptxHandlerRuntimeSaveDataSerialization = __esm({
100749
101372
  this.writeTableCellStyle(xmlCell, cell.style);
100750
101373
  }
100751
101374
  serializeCellExtraAttributes(xmlCell, cell.extraAttributes);
101375
+ recordTableParagraphOrder(xmlCell, cell.textRuns);
100752
101376
  }
100753
101377
  }
100754
101378
  } catch (e) {
@@ -102425,6 +103049,7 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
102425
103049
  init_smartart_save_chrome();
102426
103050
  init_smartart_save_geometry();
102427
103051
  init_smartart_xml_builders();
103052
+ init_table_paragraph_save_order();
102428
103053
  PptxHandlerRuntime25 = class _PptxHandlerRuntime extends PptxHandlerRuntime24 {
102429
103054
  /** Pending SmartArt data updates to process during save. */
102430
103055
  pendingSmartArtUpdates;
@@ -102701,7 +103326,7 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
102701
103326
  );
102702
103327
  root["p:cSld"] = cSld;
102703
103328
  data["p:notesMaster"] = root;
102704
- this.zip.file(notesMaster.path, this.builder.build(data));
103329
+ this.zip.file(notesMaster.path, this.builder.build(withOrderedTableParagraphs(data)));
102705
103330
  } catch (e) {
102706
103331
  console.warn("Failed to save notes master changes:", e);
102707
103332
  }
@@ -102736,7 +103361,7 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
102736
103361
  );
102737
103362
  root["p:cSld"] = cSld;
102738
103363
  data["p:handoutMaster"] = root;
102739
- this.zip.file(handoutMaster.path, this.builder.build(data));
103364
+ this.zip.file(handoutMaster.path, this.builder.build(withOrderedTableParagraphs(data)));
102740
103365
  } catch (e) {
102741
103366
  console.warn("Failed to save handout master changes:", e);
102742
103367
  }
@@ -106983,7 +107608,7 @@ function buildOrderedSlideXml(options) {
106983
107608
  }
106984
107609
  }
106985
107610
  nextSlide = orderSlideRootChildren(nextSlide, getLocalName2);
106986
- return { ...xmlObj, "p:sld": nextSlide };
107611
+ return withOrderedTableParagraphs({ ...xmlObj, "p:sld": nextSlide });
106987
107612
  }
106988
107613
  var ALTERNATE_CONTENT_TAG;
106989
107614
  var UNRANKED;
@@ -106995,6 +107620,7 @@ var init_slide_save_xml_order = __esm({
106995
107620
  "src/core/core/runtime/slide-save-xml-order.ts"() {
106996
107621
  init_utils();
106997
107622
  init_ordered_xml_children();
107623
+ init_table_paragraph_save_order();
106998
107624
  ALTERNATE_CONTENT_TAG = "mc:AlternateContent";
106999
107625
  UNRANKED = Number.MAX_SAFE_INTEGER;
107000
107626
  COLLECTOR_KEYS = [
@@ -108489,12 +109115,12 @@ function orderedTemplatePartXml(options) {
108489
109115
  const rebuilt = positionsByRuntime.get(runtime)?.get(partPath);
108490
109116
  const ordered4 = rebuilt ? orderShapeTreeChildren(rewrapped, (node) => rebuilt.get(node), getLocalName2) : orderContainer(rewrapped, sourceXml ? scanSpTreeDocumentOrder(sourceXml) : [], getLocalName2);
108491
109117
  if (ordered4 === spTree) {
108492
- return xmlObj;
109118
+ return withOrderedTableParagraphs(xmlObj);
108493
109119
  }
108494
109120
  const nextRoot = { ...root, "p:cSld": { ...commonSlideData, "p:spTree": ordered4 } };
108495
109121
  const nextPart = { ...xmlObj };
108496
109122
  setOwnXmlProperty(nextPart, rootTag2, nextRoot);
108497
- return nextPart;
109123
+ return withOrderedTableParagraphs(nextPart);
108498
109124
  }
108499
109125
  var ALTERNATE_CONTENT_TAG3;
108500
109126
  var positionsByRuntime;
@@ -108504,6 +109130,7 @@ var init_template_sp_tree_order = __esm({
108504
109130
  init_ordered_xml_children();
108505
109131
  init_slide_save_xml_order();
108506
109132
  init_sp_tree_document_order_scan();
109133
+ init_table_paragraph_save_order();
108507
109134
  ALTERNATE_CONTENT_TAG3 = "mc:AlternateContent";
108508
109135
  positionsByRuntime = /* @__PURE__ */ new WeakMap();
108509
109136
  }
@@ -112497,11 +113124,7 @@ var init_PptxHandlerRuntimeShapeParagraphContentParsing = __esm({
112497
113124
  processField(f6);
112498
113125
  }
112499
113126
  };
112500
- const { entries, authored } = paragraphContentEntries(
112501
- p,
112502
- PARAGRAPH_CONTENT_TAGS,
112503
- (value) => this.ensureArray(value)
112504
- );
113127
+ const { entries, authored } = paragraphContentEntries(p, PARAGRAPH_CONTENT_TAGS);
112505
113128
  const runCount = this.ensureArray(p["a:r"]).length;
112506
113129
  const breakCount = this.ensureArray(p["a:br"]).length;
112507
113130
  const insertCollapsedBreaks = !authored && runCount > 1 && breakCount > 0;
@@ -136248,8 +136871,8 @@ var ChartElementProcessor = class {
136248
136871
  widths[widths.length - 1] = Math.max(widths[widths.length - 1], pct2.length);
136249
136872
  }
136250
136873
  }
136251
- const formatRow = (cells) => {
136252
- const padded = cells.map((cell, index) => cell.padEnd(widths[index]));
136874
+ const formatRow = (cells2) => {
136875
+ const padded = cells2.map((cell, index) => cell.padEnd(widths[index]));
136253
136876
  return `| ${padded.join(" | ")} |`;
136254
136877
  };
136255
136878
  const separator = `| ${widths.map((width) => "-".repeat(width)).join(" | ")} |`;
@@ -136809,7 +137432,7 @@ var TableElementProcessor = class {
136809
137432
  const row = tableData.rows[ri];
136810
137433
  const isHeader = ri === 0 && tableData.firstRowHeader !== false;
136811
137434
  const tag = isHeader ? "th" : "td";
136812
- const cells = [];
137435
+ const cells2 = [];
136813
137436
  let ci = 0;
136814
137437
  for (const cell of row.cells) {
136815
137438
  while (this.isOccupied(rowSpanOccupancy, ri, ci)) {
@@ -136830,11 +137453,11 @@ var TableElementProcessor = class {
136830
137453
  }
136831
137454
  const attrs3 = this.buildCellAttrs(cell, gridSpan, rowSpan, isHeader);
136832
137455
  const content = this.renderCellContent(cell);
136833
- cells.push(`<${tag}${attrs3}>${content}</${tag}>`);
137456
+ cells2.push(`<${tag}${attrs3}>${content}</${tag}>`);
136834
137457
  ci += gridSpan;
136835
137458
  }
136836
- if (cells.length > 0) {
136837
- htmlRows.push(`<tr>${cells.join("")}</tr>`);
137459
+ if (cells2.length > 0) {
137460
+ htmlRows.push(`<tr>${cells2.join("")}</tr>`);
136838
137461
  }
136839
137462
  }
136840
137463
  if (htmlRows.length === 0) {
@@ -137050,14 +137673,14 @@ ${htmlRows.join("\n")}
137050
137673
  const mdRows = [];
137051
137674
  const hasHeader = tableData.firstRowHeader !== false;
137052
137675
  for (let ri = 0; ri < rows.length; ri++) {
137053
- const cells = rows[ri].cells.map((cell) => {
137676
+ const cells2 = rows[ri].cells.map((cell) => {
137054
137677
  const text22 = this.getCellFormattedText(cell);
137055
137678
  return this.escapeMarkdownTableCell(text22);
137056
137679
  });
137057
- while (cells.length < columnCount) {
137058
- cells.push("");
137680
+ while (cells2.length < columnCount) {
137681
+ cells2.push("");
137059
137682
  }
137060
- mdRows.push(`| ${cells.join(" | ")} |`);
137683
+ mdRows.push(`| ${cells2.join(" | ")} |`);
137061
137684
  if (ri === 0 && hasHeader) {
137062
137685
  const divider = Array.from({ length: columnCount }, () => "---");
137063
137686
  mdRows.push(`| ${divider.join(" | ")} |`);
@@ -138378,8 +139001,8 @@ var OmmlLatexConverter = class {
138378
139001
  return null;
138379
139002
  }
138380
139003
  const rows = this.toRecordArray(m["m:mr"]).map((row) => {
138381
- const cells = this.toRecordArray(row["m:e"]).map((entry2) => this.renderNode(entry2).trim()).filter((entry2) => entry2.length > 0);
138382
- return cells.join(" & ");
139004
+ const cells2 = this.toRecordArray(row["m:e"]).map((entry2) => this.renderNode(entry2).trim()).filter((entry2) => entry2.length > 0);
139005
+ return cells2.join(" & ");
138383
139006
  }).filter((row) => row.length > 0);
138384
139007
  if (rows.length === 0) {
138385
139008
  return null;
@@ -143829,6 +144452,60 @@ var NOMINAL_ENVELOPE_BAND = {
143829
144452
  top: TOP_MARGIN,
143830
144453
  bottom: BOTTOM_MARGIN
143831
144454
  };
144455
+ var measureCtx;
144456
+ function getMeasureCtx() {
144457
+ if (measureCtx !== void 0) {
144458
+ return measureCtx;
144459
+ }
144460
+ if (typeof document === "undefined") {
144461
+ measureCtx = null;
144462
+ return null;
144463
+ }
144464
+ measureCtx = document.createElement("canvas").getContext("2d");
144465
+ return measureCtx;
144466
+ }
144467
+ function toCanvasFont(font) {
144468
+ const size = font.fontSizePx && font.fontSizePx > 0 ? font.fontSizePx : DEFAULT_TEXT_FONT_SIZE2;
144469
+ const family = font.fontFamily || DEFAULT_FONT_FAMILY2;
144470
+ return `${font.italic ? "italic " : ""}${font.bold ? "bold " : ""}${size}px ${family}`;
144471
+ }
144472
+ function measureGlyphAdvances(text22, font) {
144473
+ const chars = [...text22];
144474
+ const ctx = getMeasureCtx();
144475
+ if (!ctx) {
144476
+ const size = font.fontSizePx && font.fontSizePx > 0 ? font.fontSizePx : DEFAULT_TEXT_FONT_SIZE2;
144477
+ return chars.map(() => size * 0.55);
144478
+ }
144479
+ ctx.font = toCanvasFont(font);
144480
+ const advances = [];
144481
+ let previous = 0;
144482
+ let prefix = "";
144483
+ for (const char of chars) {
144484
+ prefix += char;
144485
+ const width = ctx.measureText(prefix).width;
144486
+ advances.push(Math.max(0, width - previous));
144487
+ previous = width;
144488
+ }
144489
+ return advances;
144490
+ }
144491
+ function measureLineAscent(segments) {
144492
+ const ctx = getMeasureCtx();
144493
+ if (!ctx) {
144494
+ return void 0;
144495
+ }
144496
+ let maxAscent = 0;
144497
+ for (const segment of segments) {
144498
+ if (!segment.text) {
144499
+ continue;
144500
+ }
144501
+ ctx.font = toCanvasFont(segment.font);
144502
+ const ascent = ctx.measureText(segment.text).actualBoundingBoxAscent;
144503
+ if (Number.isFinite(ascent) && ascent > maxAscent) {
144504
+ maxAscent = ascent;
144505
+ }
144506
+ }
144507
+ return maxAscent > 0 ? maxAscent : void 0;
144508
+ }
143832
144509
  function sliceBand(top, bottom, index, count) {
143833
144510
  const span = bottom - top;
143834
144511
  return {
@@ -143836,11 +144513,31 @@ function sliceBand(top, bottom, index, count) {
143836
144513
  bottom: top + (index + 1) / count * span
143837
144514
  };
143838
144515
  }
143839
- function edgeBandAt(preset, u, adj, adj2, height, lineIndex, lineCount) {
144516
+ function deformedBandAt(preset, u, adj, adj2, height) {
143840
144517
  const curve = envelopeCurveAt(preset, u, adj, adj2);
143841
- const bandTop = (curve?.top ?? NOMINAL_ENVELOPE_BAND.top) * height;
143842
- const bandBottom = (curve?.bottom ?? NOMINAL_ENVELOPE_BAND.bottom) * height;
143843
- return sliceBand(bandTop, bandBottom, lineIndex, lineCount);
144518
+ return {
144519
+ top: (curve?.top ?? NOMINAL_ENVELOPE_BAND.top) * height,
144520
+ bottom: (curve?.bottom ?? NOMINAL_ENVELOPE_BAND.bottom) * height
144521
+ };
144522
+ }
144523
+ var ROW_BOUNDARY_REFERENCE_U = 0.5;
144524
+ function edgeBandAt(preset, u, adj, adj2, height, lineIndex, lineCount) {
144525
+ const actual = deformedBandAt(preset, u, adj, adj2, height);
144526
+ if (lineCount <= 1) {
144527
+ return sliceBand(actual.top, actual.bottom, 0, 1);
144528
+ }
144529
+ const reference = deformedBandAt(preset, ROW_BOUNDARY_REFERENCE_U, adj, adj2, height);
144530
+ const fixedSlice = sliceBand(reference.top, reference.bottom, lineIndex, lineCount);
144531
+ const isFirstRow = lineIndex <= 0;
144532
+ const isLastRow = lineIndex >= lineCount - 1;
144533
+ const flatTop = NOMINAL_ENVELOPE_BAND.top * height;
144534
+ const flatBottom = NOMINAL_ENVELOPE_BAND.bottom * height;
144535
+ const dampedOuterTop = flatTop + (actual.top - flatTop) / lineCount;
144536
+ const dampedOuterBottom = flatBottom + (actual.bottom - flatBottom) / lineCount;
144537
+ return {
144538
+ top: isFirstRow ? dampedOuterTop : fixedSlice.top,
144539
+ bottom: isLastRow ? dampedOuterBottom : fixedSlice.bottom
144540
+ };
143844
144541
  }
143845
144542
  function glyphEnvelopeMatrix(x0, x1, edge0, edge1, nomTop, nomBottom) {
143846
144543
  const nominalSpan = nomBottom - nomTop;
@@ -143853,6 +144550,34 @@ function glyphEnvelopeMatrix(x0, x1, edge0, edge1, nomTop, nomBottom) {
143853
144550
  const f6 = grandMean - b * meanX - d * meanY;
143854
144551
  return `matrix(1 ${b} 0 ${d} 0 ${f6})`;
143855
144552
  }
144553
+ function scaleOutlineCommandsX(commands, originX, scale2) {
144554
+ if (scale2 === 1) {
144555
+ return commands;
144556
+ }
144557
+ const sx = (x) => originX + (x - originX) * scale2;
144558
+ return commands.map((cmd) => {
144559
+ switch (cmd.type) {
144560
+ case "M":
144561
+ case "L":
144562
+ return { type: cmd.type, x: sx(cmd.x), y: cmd.y };
144563
+ case "Q":
144564
+ return { type: "Q", x1: sx(cmd.x1), y1: cmd.y1, x: sx(cmd.x), y: cmd.y };
144565
+ case "C":
144566
+ return {
144567
+ type: "C",
144568
+ x1: sx(cmd.x1),
144569
+ y1: cmd.y1,
144570
+ x2: sx(cmd.x2),
144571
+ y2: cmd.y2,
144572
+ x: sx(cmd.x),
144573
+ y: cmd.y
144574
+ };
144575
+ case "Z":
144576
+ default:
144577
+ return cmd;
144578
+ }
144579
+ });
144580
+ }
143856
144581
  function mapYThroughEnvelopeBand(y, nomTop, nomBottom, edgeTop, edgeBottom) {
143857
144582
  const nominalSpan = nomBottom - nomTop;
143858
144583
  if (nominalSpan <= 0) {
@@ -143982,75 +144707,16 @@ function buildGlyphSlices(preset, x0, x1, u0, u1, adj, adj2, height, lineIndex,
143982
144707
  const sliceX1 = x0 + (x1 - x0) * (i2 + 1) / n;
143983
144708
  const sliceU0 = u0 + (u1 - u0) * i2 / n;
143984
144709
  const sliceU1 = u0 + (u1 - u0) * (i2 + 1) / n;
144710
+ const e0 = edgeAt(sliceU0);
144711
+ const e1 = edgeAt(sliceU1);
143985
144712
  slices.push({
143986
144713
  clipX0: sliceX0 - (i2 === 0 ? 0 : SEAM_OVERLAP_PX),
143987
144714
  clipX1: sliceX1 + (i2 === n - 1 ? 0 : SEAM_OVERLAP_PX),
143988
- transform: glyphEnvelopeMatrix(
143989
- sliceX0,
143990
- sliceX1,
143991
- edgeAt(sliceU0),
143992
- edgeAt(sliceU1),
143993
- nomTop,
143994
- nomBottom
143995
- )
144715
+ transform: glyphEnvelopeMatrix(sliceX0, sliceX1, e0, e1, nomTop, nomBottom)
143996
144716
  });
143997
144717
  }
143998
144718
  return slices;
143999
144719
  }
144000
- var measureCtx;
144001
- function getMeasureCtx() {
144002
- if (measureCtx !== void 0) {
144003
- return measureCtx;
144004
- }
144005
- if (typeof document === "undefined") {
144006
- measureCtx = null;
144007
- return null;
144008
- }
144009
- measureCtx = document.createElement("canvas").getContext("2d");
144010
- return measureCtx;
144011
- }
144012
- function toCanvasFont(font) {
144013
- const size = font.fontSizePx && font.fontSizePx > 0 ? font.fontSizePx : DEFAULT_TEXT_FONT_SIZE2;
144014
- const family = font.fontFamily || DEFAULT_FONT_FAMILY2;
144015
- return `${font.italic ? "italic " : ""}${font.bold ? "bold " : ""}${size}px ${family}`;
144016
- }
144017
- function measureGlyphAdvances(text22, font) {
144018
- const chars = [...text22];
144019
- const ctx = getMeasureCtx();
144020
- if (!ctx) {
144021
- const size = font.fontSizePx && font.fontSizePx > 0 ? font.fontSizePx : DEFAULT_TEXT_FONT_SIZE2;
144022
- return chars.map(() => size * 0.55);
144023
- }
144024
- ctx.font = toCanvasFont(font);
144025
- const advances = [];
144026
- let previous = 0;
144027
- let prefix = "";
144028
- for (const char of chars) {
144029
- prefix += char;
144030
- const width = ctx.measureText(prefix).width;
144031
- advances.push(Math.max(0, width - previous));
144032
- previous = width;
144033
- }
144034
- return advances;
144035
- }
144036
- function measureLineAscent(segments) {
144037
- const ctx = getMeasureCtx();
144038
- if (!ctx) {
144039
- return void 0;
144040
- }
144041
- let maxAscent = 0;
144042
- for (const segment of segments) {
144043
- if (!segment.text) {
144044
- continue;
144045
- }
144046
- ctx.font = toCanvasFont(segment.font);
144047
- const ascent = ctx.measureText(segment.text).actualBoundingBoxAscent;
144048
- if (Number.isFinite(ascent) && ascent > maxAscent) {
144049
- maxAscent = ascent;
144050
- }
144051
- }
144052
- return maxAscent > 0 ? maxAscent : void 0;
144053
- }
144054
144720
  function startX(align, width, lineWidth) {
144055
144721
  if (align === "right") {
144056
144722
  return width - lineWidth;
@@ -144079,20 +144745,25 @@ function buildGlyphEnvelope(preset, segments, width, height, align, adj, adj2, l
144079
144745
  );
144080
144746
  const realAscent = measureLineAscent(segments);
144081
144747
  const nomTop = realAscent !== void 0 ? Math.max(fixedBandTop, nomBottom - realAscent) : fixedBandTop;
144748
+ const isCanFamily = preset === "textCanUp" || preset === "textCanDown";
144749
+ const stretch = width > 0 && lineWidth > 0 ? width / lineWidth : 1;
144750
+ const shapeScale = isCanFamily ? 1 : stretch;
144082
144751
  const placements = [];
144083
- let x = startX(align, width, lineWidth);
144752
+ let x = lineWidth > 0 ? 0 : startX(align, width, lineWidth);
144084
144753
  segments.forEach((segment, segIdx) => {
144085
144754
  const chars = [...segment.text];
144086
144755
  const advances = perSegmentAdvances[segIdx];
144087
144756
  chars.forEach((char, i2) => {
144088
- const glyphWidth = advances[i2] ?? 0;
144757
+ const naturalGlyphWidth = advances[i2] ?? 0;
144758
+ const pitch = naturalGlyphWidth * stretch;
144089
144759
  const x0 = x;
144090
- const x1 = x + glyphWidth;
144760
+ const x1 = x0 + naturalGlyphWidth;
144091
144761
  const u0 = width > 0 ? x0 / width : 0.5;
144092
144762
  const u1 = width > 0 ? x1 / width : 0.5;
144093
144763
  const edge0 = edgeBandAt(preset, u0, adj, adj2, height, safeLineIndex, safeLineCount);
144094
144764
  const edge1 = edgeBandAt(preset, u1, adj, adj2, height, safeLineIndex, safeLineCount);
144095
- const outlineCommands = getGlyphOutline?.(char, segment.font, x, nomBottom);
144765
+ const rawOutline = getGlyphOutline?.(char, segment.font, x0, nomBottom);
144766
+ const outlineCommands = rawOutline ? scaleOutlineCommandsX(rawOutline, x0, shapeScale) : void 0;
144096
144767
  const outlinePath = outlineCommands ? buildWarpedGlyphOutlinePathD(
144097
144768
  outlineCommands,
144098
144769
  preset,
@@ -144109,7 +144780,7 @@ function buildGlyphEnvelope(preset, segments, width, height, align, adj, adj2, l
144109
144780
  placements.push({
144110
144781
  char,
144111
144782
  segmentIndex: segment.segmentIndex,
144112
- x,
144783
+ x: x0,
144113
144784
  y: nomBottom,
144114
144785
  transform: glyphEnvelopeMatrix(x0, x1, edge0, edge1, nomTop, nomBottom),
144115
144786
  slices: sliceCount > 1 ? buildGlyphSlices(
@@ -144129,7 +144800,7 @@ function buildGlyphEnvelope(preset, segments, width, height, align, adj, adj2, l
144129
144800
  ) : void 0,
144130
144801
  outlinePath
144131
144802
  });
144132
- x += glyphWidth;
144803
+ x += pitch;
144133
144804
  });
144134
144805
  });
144135
144806
  return placements;
@@ -146745,9 +147416,9 @@ function convertMatrix(node, cc) {
146745
147416
  const rows = ensureArray6(node["m:mr"]);
146746
147417
  const tableRows = [];
146747
147418
  for (const row of rows) {
146748
- const cells = ensureArray6(row["m:e"]);
147419
+ const cells2 = ensureArray6(row["m:e"]);
146749
147420
  const tdParts = [];
146750
- for (const cell of cells) {
147421
+ for (const cell of cells2) {
146751
147422
  tdParts.push(`<mtd><mrow>${cc(cell)}</mrow></mtd>`);
146752
147423
  }
146753
147424
  tableRows.push(`<mtr>${tdParts.join("")}</mtr>`);
@@ -147472,16 +148143,16 @@ function parseEnvBody(ctx) {
147472
148143
  function buildMatrix(ctx, rows) {
147473
148144
  return {
147474
148145
  "m:m": {
147475
- "m:mr": rows.map((cells) => ({
147476
- "m:e": cells.map((cell) => ctx.wrapE(cell))
148146
+ "m:mr": rows.map((cells2) => ({
148147
+ "m:e": cells2.map((cell) => ctx.wrapE(cell))
147477
148148
  }))
147478
148149
  }
147479
148150
  };
147480
148151
  }
147481
148152
  function buildEqArr(ctx, rows) {
147482
- const lines = rows.map((cells) => {
148153
+ const lines = rows.map((cells2) => {
147483
148154
  const nodes = [];
147484
- cells.forEach((cell, index) => {
148155
+ cells2.forEach((cell, index) => {
147485
148156
  if (index > 0) {
147486
148157
  nodes.push(ctx.makeRun("&"));
147487
148158
  }
@@ -154319,13 +154990,13 @@ function buildIsometricSurfaceViewModel(element, chartData, categoryLabels) {
154319
154990
  const projH = maxSY - minSY;
154320
154991
  const offsetX = layout.plotLeft + layout.plotWidth / 2 - (minSX + projW / 2);
154321
154992
  const offsetY = layout.plotTop + layout.plotHeight / 2 - (minSY + projH / 2);
154322
- const cells = [];
154993
+ const cells2 = [];
154323
154994
  for (let r = 0; r < rows; r++) {
154324
154995
  for (let c = 0; c < cols; c++) {
154325
- cells.push({ row: r, col: c, depth: r + c });
154996
+ cells2.push({ row: r, col: c, depth: r + c });
154326
154997
  }
154327
154998
  }
154328
- cells.sort((a, b) => a.depth - b.depth);
154999
+ cells2.sort((a, b) => a.depth - b.depth);
154329
155000
  const primitives = [];
154330
155001
  primitives.push(
154331
155002
  ...buildSurfaceWallPanels(cols, rows, cellSize, zScale, offsetX, offsetY, {
@@ -154334,7 +155005,7 @@ function buildIsometricSurfaceViewModel(element, chartData, categoryLabels) {
154334
155005
  backWall: chartData.backWall
154335
155006
  })
154336
155007
  );
154337
- for (const { row, col } of cells) {
155008
+ for (const { row, col } of cells2) {
154338
155009
  const corners = [
154339
155010
  [col, row],
154340
155011
  [col + 1, row],
@@ -167671,15 +168342,15 @@ function setCellText(element, rowIndex, colIndex, text22) {
167671
168342
  });
167672
168343
  return { ...element, tableData: { ...tableData, rows } };
167673
168344
  }
167674
- function computeBoundingRect(cells) {
167675
- if (cells.length === 0) {
168345
+ function computeBoundingRect(cells2) {
168346
+ if (cells2.length === 0) {
167676
168347
  return void 0;
167677
168348
  }
167678
- let startRow = cells[0].row;
167679
- let startCol = cells[0].col;
167680
- let endRow = cells[0].row;
167681
- let endCol = cells[0].col;
167682
- for (const { row, col } of cells) {
168349
+ let startRow = cells2[0].row;
168350
+ let startCol = cells2[0].col;
168351
+ let endRow = cells2[0].row;
168352
+ let endCol = cells2[0].col;
168353
+ for (const { row, col } of cells2) {
167683
168354
  if (row < startRow) {
167684
168355
  startRow = row;
167685
168356
  }
@@ -167765,8 +168436,8 @@ function expandRectForExistingMerges(rect22, tableData) {
167765
168436
  }
167766
168437
  return { startRow, startCol, endRow, endCol };
167767
168438
  }
167768
- function mergeCells(cells, tableData) {
167769
- const rawRect = computeBoundingRect(cells);
168439
+ function mergeCells(cells2, tableData) {
168440
+ const rawRect = computeBoundingRect(cells2);
167770
168441
  if (!rawRect) {
167771
168442
  return tableData;
167772
168443
  }
@@ -167803,7 +168474,7 @@ function mergeCells(cells, tableData) {
167803
168474
  }
167804
168475
  if (ri === rect22.startRow && ci === rect22.startCol) {
167805
168476
  return {
167806
- ...withCellText(cell, combinedText),
168477
+ ...cell.text === combinedText ? cell : withCellText(cell, combinedText),
167807
168478
  gridSpan: colCount > 1 ? colCount : void 0,
167808
168479
  rowSpan: rowCount > 1 ? rowCount : void 0,
167809
168480
  hMerge: void 0,
@@ -167956,7 +168627,7 @@ function deleteTableRow(tableData, rowIdx) {
167956
168627
  }
167957
168628
  const removedRow = tableData.rows[rowIdx];
167958
168629
  const adjustedRows = [...tableData.rows];
167959
- const updateCellRowSpan = (cells, colIdx, newRowSpan) => cells.map((cc, ci) => ci === colIdx ? { ...cc, rowSpan: newRowSpan } : cc);
168630
+ const updateCellRowSpan = (cells2, colIdx, newRowSpan) => cells2.map((cc, ci) => ci === colIdx ? { ...cc, rowSpan: newRowSpan } : cc);
167960
168631
  for (let c = 0; c < removedRow.cells.length; c++) {
167961
168632
  const cell = removedRow.cells[c];
167962
168633
  if (cell.vMerge) {
@@ -167991,6 +168662,7 @@ function deleteTableRow(tableData, rowIdx) {
167991
168662
  return {
167992
168663
  ...cc,
167993
168664
  text: cell.text || cc.text,
168665
+ textRuns: cell.text ? cell.textRuns : cc.textRuns,
167994
168666
  style: cc.style || cell.style,
167995
168667
  rowSpan: newRs > 1 ? newRs : void 0,
167996
168668
  vMerge: void 0,
@@ -168090,6 +168762,7 @@ function deleteTableColumn(tableData, colIdx) {
168090
168762
  adjustedCells[nextColIdx] = {
168091
168763
  ...nextCell,
168092
168764
  text: cell.text || nextCell.text,
168765
+ textRuns: cell.text ? cell.textRuns : nextCell.textRuns,
168093
168766
  style: nextCell.style || cell.style,
168094
168767
  gridSpan: gs - 1 > 1 ? gs - 1 : void 0,
168095
168768
  hMerge: void 0,
@@ -168129,7 +168802,7 @@ function buildTableDataGrid(element) {
168129
168802
  canRemoveColumn: colCount > 1
168130
168803
  };
168131
168804
  }
168132
- function withTableData(element, transform6) {
168805
+ function withTableData(element, transform6, edit) {
168133
168806
  const tableData = element.tableData;
168134
168807
  if (!tableData) {
168135
168808
  return element;
@@ -168140,7 +168813,7 @@ function withTableData(element, transform6) {
168140
168813
  }
168141
168814
  const updated = { ...element, tableData: next };
168142
168815
  if (element.rawXml) {
168143
- const rawXml = rebuildTableStructureInRawXml(element, next);
168816
+ const rawXml = rebuildTableStructureInRawXml(element, next, edit);
168144
168817
  if (rawXml) {
168145
168818
  updated.rawXml = rawXml;
168146
168819
  }
@@ -168156,16 +168829,32 @@ function setTableElementCellText(element, rowIndex, colIndex, text22) {
168156
168829
  return rawXml ? { ...updated, rawXml } : updated;
168157
168830
  }
168158
168831
  function insertTableElementRow(element, rowIdx, position2) {
168159
- return withTableData(element, (data) => insertTableRow(data, rowIdx, position2));
168832
+ return withTableData(element, (data) => insertTableRow(data, rowIdx, position2), {
168833
+ axis: "row",
168834
+ action: "insert",
168835
+ index: position2 === "above" ? rowIdx : rowIdx + 1
168836
+ });
168160
168837
  }
168161
168838
  function removeTableElementRow(element, rowIdx) {
168162
- return withTableData(element, (data) => deleteTableRow(data, rowIdx));
168839
+ return withTableData(element, (data) => deleteTableRow(data, rowIdx), {
168840
+ axis: "row",
168841
+ action: "delete",
168842
+ index: rowIdx
168843
+ });
168163
168844
  }
168164
168845
  function insertTableElementColumn(element, colIdx, position2) {
168165
- return withTableData(element, (data) => insertTableColumn(data, colIdx, position2));
168846
+ return withTableData(element, (data) => insertTableColumn(data, colIdx, position2), {
168847
+ axis: "column",
168848
+ action: "insert",
168849
+ index: position2 === "left" ? colIdx : colIdx + 1
168850
+ });
168166
168851
  }
168167
168852
  function removeTableElementColumn(element, colIdx) {
168168
- return withTableData(element, (data) => deleteTableColumn(data, colIdx));
168853
+ return withTableData(element, (data) => deleteTableColumn(data, colIdx), {
168854
+ axis: "column",
168855
+ action: "delete",
168856
+ index: colIdx
168857
+ });
168169
168858
  }
168170
168859
  function appendTableElementRow(element) {
168171
168860
  const rowCount = element.tableData?.rows.length ?? 0;
@@ -168644,7 +169333,7 @@ function distributeElements(elements, axis, options) {
168644
169333
  }
168645
169334
  return result;
168646
169335
  }
168647
- var DEG_TO_RAD3 = Math.PI / 180;
169336
+ var DEG_TO_RAD4 = Math.PI / 180;
168648
169337
  function rotationOf(box) {
168649
169338
  return box.rotation ?? 0;
168650
169339
  }
@@ -168652,7 +169341,7 @@ function rotateDelta(dx, dy, rotationDeg) {
168652
169341
  if (!rotationDeg) {
168653
169342
  return { x: dx, y: dy };
168654
169343
  }
168655
- const rad = -rotationDeg * DEG_TO_RAD3;
169344
+ const rad = -rotationDeg * DEG_TO_RAD4;
168656
169345
  const cos = Math.cos(rad);
168657
169346
  const sin = Math.sin(rad);
168658
169347
  return {
@@ -168982,7 +169671,7 @@ function computeShadeToTitleFillToRect(title, slideWidthPx, slideHeightPx) {
168982
169671
  b: clampUnit3(1 - (title.y + title.height) / slideHeightPx)
168983
169672
  };
168984
169673
  }
168985
- var GRADIENT_STOP_TOKEN = /(rgba?\([^)]*\)|#[0-9a-fA-F]{3,8})\s+(-?[\d.]+)%/gu;
169674
+ var GRADIENT_STOP_TOKEN = /(rgba?\([^()]*\)|#[0-9a-fA-F]{3,8})\s+(-?[\d.]+)%/gu;
168986
169675
  function toHexChannel2(value) {
168987
169676
  return Math.min(255, Math.max(0, Math.round(value))).toString(16).padStart(2, "0");
168988
169677
  }
@@ -169173,7 +169862,7 @@ function newTableElement(rows = 3, cols = 3, x = DEFAULT_X, y = TABLE_DEFAULT_Y)
169173
169862
  const columnWidths = Array.from({ length: cols }).fill(colWidth);
169174
169863
  const tableRows = Array.from({ length: rows }, (_, rowIdx) => {
169175
169864
  const isHeader = rowIdx === 0;
169176
- const cells = Array.from({ length: cols }, (__, colIdx) => ({
169865
+ const cells2 = Array.from({ length: cols }, (__, colIdx) => ({
169177
169866
  text: isHeader ? `Header ${colIdx + 1}` : "",
169178
169867
  style: {
169179
169868
  borderTopWidth: 1,
@@ -169191,7 +169880,7 @@ function newTableElement(rows = 3, cols = 3, x = DEFAULT_X, y = TABLE_DEFAULT_Y)
169191
169880
  } : {}
169192
169881
  }
169193
169882
  }));
169194
- return { cells, height: isHeader ? 40 : 36 };
169883
+ return { cells: cells2, height: isHeader ? 40 : 36 };
169195
169884
  });
169196
169885
  return {
169197
169886
  type: "table",
@@ -184267,7 +184956,7 @@ var TRANSITION_DIR_GRID_POSITIONS = {
184267
184956
  rd: [2, 2]
184268
184957
  };
184269
184958
  function buildDirectionGrid(directions) {
184270
- const cells = [
184959
+ const cells2 = [
184271
184960
  [null, null, null],
184272
184961
  [null, null, null],
184273
184962
  [null, null, null]
@@ -184275,10 +184964,10 @@ function buildDirectionGrid(directions) {
184275
184964
  for (const dir of directions) {
184276
184965
  const pos2 = TRANSITION_DIR_GRID_POSITIONS[dir];
184277
184966
  if (pos2) {
184278
- cells[pos2[0]][pos2[1]] = dir;
184967
+ cells2[pos2[0]][pos2[1]] = dir;
184279
184968
  }
184280
184969
  }
184281
- return cells;
184970
+ return cells2;
184282
184971
  }
184283
184972
  function mergeSlideTransition(current, changes) {
184284
184973
  return { type: "none", ...current, ...changes };
@@ -192039,6 +192728,20 @@ function resolveSelectionPaneRename(seed, value) {
192039
192728
  }
192040
192729
  return { name: trimmed };
192041
192730
  }
192731
+ function hasMultipleSelectedTableCells(cells2, tableData) {
192732
+ const selected = /* @__PURE__ */ new Set();
192733
+ for (const { row, col } of cells2 ?? []) {
192734
+ const cell = tableData?.rows[row]?.cells[col];
192735
+ if (tableData && (!cell || cell.hMerge || cell.vMerge)) {
192736
+ continue;
192737
+ }
192738
+ selected.add(`${row},${col}`);
192739
+ if (selected.size > 1) {
192740
+ return true;
192741
+ }
192742
+ }
192743
+ return false;
192744
+ }
192042
192745
  var LABEL_KEYS = {
192043
192746
  copy: "pptx.contextMenu.copy",
192044
192747
  cut: "pptx.contextMenu.cut",
@@ -199606,12 +200309,12 @@ async function fetchTextIfCrossOriginSafe(url) {
199606
200309
  return null;
199607
200310
  }
199608
200311
  }
199609
- var FONT_FACE_URL_PATTERN = /url\(\s*["']?([^"')]+)["']?\s*\)/gu;
200312
+ var FONT_FACE_URL_PATTERN = /url\(\s*(?:"([^"]*)"|'([^']*)'|([^"')\s]+))\s*\)/gu;
199610
200313
  async function inlineFontFaceUrls(css, fetchDataUrl) {
199611
200314
  const urls = /* @__PURE__ */ new Set();
199612
200315
  for (const match of css.matchAll(FONT_FACE_URL_PATTERN)) {
199613
- const raw = match[1];
199614
- if (raw.startsWith("http:") || raw.startsWith("https:")) {
200316
+ const raw = match[1] ?? match[2] ?? match[3];
200317
+ if (raw && (raw.startsWith("http:") || raw.startsWith("https:"))) {
199615
200318
  urls.add(raw);
199616
200319
  }
199617
200320
  }
@@ -199671,9 +200374,13 @@ async function fetchAsDataUrl(url) {
199671
200374
  return null;
199672
200375
  }
199673
200376
  }
200377
+ var CSS_URL_PATTERN = /url\(\s*(?:"([^"]*)"|'([^']*)'|([^"')\s]+))\s*\)/u;
199674
200378
  function extractCssUrl(value) {
199675
- const match = /url\(\s*["']?([^"')]+)["']?\s*\)/u.exec(value);
199676
- return match ? match[1] : null;
200379
+ const match = CSS_URL_PATTERN.exec(value);
200380
+ if (!match) {
200381
+ return null;
200382
+ }
200383
+ return match[1] ?? match[2] ?? match[3] ?? null;
199677
200384
  }
199678
200385
  function needsEmbedding(url) {
199679
200386
  return url.startsWith("blob:") || url.startsWith("http:") || url.startsWith("https:");
@@ -200143,13 +200850,13 @@ function computePageCells(pageIndex, slidesPerPage, totalSlides, startSlideIndex
200143
200850
  const printableWidth = page.width - page.marginLeft - page.marginRight;
200144
200851
  const printableHeight = page.height - page.marginTop - page.marginBottom;
200145
200852
  const isThreePerPage = slidesPerPage === 3;
200146
- const cells = [];
200853
+ const cells2 = [];
200147
200854
  if (isThreePerPage) {
200148
200855
  const slideAreaWidth = printableWidth * THREE_PER_PAGE_SLIDE_FRACTION;
200149
200856
  const cellHeight = (printableHeight - CELL_GAP * (grid.rows - 1)) / grid.rows;
200150
200857
  for (let row = 0; row < grid.rows; row++) {
200151
200858
  const slideIdx = startSlideIndex + row;
200152
- cells.push({
200859
+ cells2.push({
200153
200860
  slideIndex: slideIdx < totalSlides ? slideIdx : -1,
200154
200861
  row,
200155
200862
  col: 0,
@@ -200166,7 +200873,7 @@ function computePageCells(pageIndex, slidesPerPage, totalSlides, startSlideIndex
200166
200873
  for (let row = 0; row < grid.rows; row++) {
200167
200874
  for (let col = 0; col < grid.columns; col++) {
200168
200875
  const slideIdx = startSlideIndex + cellIndex;
200169
- cells.push({
200876
+ cells2.push({
200170
200877
  slideIndex: slideIdx < totalSlides ? slideIdx : -1,
200171
200878
  row,
200172
200879
  col,
@@ -200181,7 +200888,7 @@ function computePageCells(pageIndex, slidesPerPage, totalSlides, startSlideIndex
200181
200888
  }
200182
200889
  return {
200183
200890
  pageIndex,
200184
- cells,
200891
+ cells: cells2,
200185
200892
  hasNoteLines: isThreePerPage
200186
200893
  };
200187
200894
  }
@@ -201934,6 +202641,9 @@ function groupTilesByRow(tiles) {
201934
202641
  const rowCount = tiles.reduce((max, t) => Math.max(max, t.row), 0) + 1;
201935
202642
  const rows = Array.from({ length: rowCount }, () => []);
201936
202643
  for (const tile of tiles) {
202644
+ if (!Number.isInteger(tile.row) || !Number.isInteger(tile.col) || tile.row < 0 || tile.col < 0) {
202645
+ continue;
202646
+ }
201937
202647
  rows[tile.row][tile.col] = tile;
201938
202648
  }
201939
202649
  return rows;
@@ -202587,8 +203297,6 @@ exports.defaultRadius = defaultRadius;
202587
203297
  exports.defaultThemeColors = defaultThemeColors;
202588
203298
  exports.deleteAutosaveSnapshot = deleteAutosaveSnapshot;
202589
203299
  exports.deleteSection = deleteSection;
202590
- exports.deleteTableColumn = deleteTableColumn;
202591
- exports.deleteTableRow = deleteTableRow;
202592
203300
  exports.deleteTableStyleFromMap = deleteTableStyleFromMap;
202593
203301
  exports.deleteTagFromCollections = deleteTagFromCollections;
202594
203302
  exports.demote = demote;
@@ -202730,6 +203438,7 @@ exports.handleReadingViewKey = handleReadingViewKey;
202730
203438
  exports.hasCopyableFormat = hasCopyableFormat;
202731
203439
  exports.hasDistinctScriptFonts = hasDistinctScriptFonts;
202732
203440
  exports.hasGlyphEnvelope = hasGlyphEnvelope;
203441
+ exports.hasMultipleSelectedTableCells = hasMultipleSelectedTableCells;
202733
203442
  exports.hasShapeProperties = hasShapeProperties;
202734
203443
  exports.hasShowSlideAfter = hasShowSlideAfter;
202735
203444
  exports.hasTextProperties = hasTextProperties;
@@ -202740,8 +203449,8 @@ exports.hideChartSeries = hideChartSeries;
202740
203449
  exports.hollowTextFillStyle = hollowTextFillStyle;
202741
203450
  exports.inlineElementPointerEvents = inlineElementPointerEvents;
202742
203451
  exports.insertCommentMention = insertCommentMention;
202743
- exports.insertTableColumn = insertTableColumn;
202744
- exports.insertTableRow = insertTableRow;
203452
+ exports.insertTableElementColumn = insertTableElementColumn;
203453
+ exports.insertTableElementRow = insertTableElementRow;
202745
203454
  exports.isActionHidden = isActionHidden;
202746
203455
  exports.isBlackboardActive = isBlackboardActive;
202747
203456
  exports.isBrowserOpenableMime = isBrowserOpenableMime;
@@ -202909,7 +203618,6 @@ exports.readStoredViewerPrefs = readStoredViewerPrefs;
202909
203618
  exports.readViewportMetrics = readViewportMetrics;
202910
203619
  exports.readingViewFitScale = readingViewFitScale;
202911
203620
  exports.rebuildDrawingShapesIfCleared = rebuildDrawingShapesIfCleared;
202912
- exports.rebuildTableStructureInRawXml = rebuildTableStructureInRawXml;
202913
203621
  exports.reconcileSlidesInYDoc = reconcileSlidesInYDoc;
202914
203622
  exports.recordProgressPercent = recordProgressPercent;
202915
203623
  exports.rectToCells = rectToCells;