pptx-react-viewer 3.15.0 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/{AiChatPanel-TBIAQSZ7.mjs → AiChatPanel-FAAO6JYZ.mjs} +3 -3
  3. package/dist/AiChatPanel-FAAO6JYZ.mjs.br +0 -0
  4. package/dist/AiChatPanel-FAAO6JYZ.mjs.gz +0 -0
  5. package/dist/{AiChatPanel-7CWOJ3PS.js → AiChatPanel-WSH2K7T4.js} +24 -24
  6. package/dist/AiChatPanel-WSH2K7T4.js.br +0 -0
  7. package/dist/AiChatPanel-WSH2K7T4.js.gz +0 -0
  8. package/dist/{Area3DChartScene-6FFBYPHF.mjs → Area3DChartScene-LGLVVQEB.mjs} +1 -1
  9. package/dist/Area3DChartScene-LGLVVQEB.mjs.br +0 -0
  10. package/dist/Area3DChartScene-LGLVVQEB.mjs.gz +0 -0
  11. package/dist/{Area3DChartScene-ZJYR6K66.js → Area3DChartScene-PTKML4PN.js} +2 -2
  12. package/dist/Area3DChartScene-PTKML4PN.js.br +0 -0
  13. package/dist/Area3DChartScene-PTKML4PN.js.gz +0 -0
  14. package/dist/{Bar3DChartScene-42MWINQX.mjs → Bar3DChartScene-HCP7MA3A.mjs} +1 -1
  15. package/dist/Bar3DChartScene-HCP7MA3A.mjs.br +0 -0
  16. package/dist/Bar3DChartScene-HCP7MA3A.mjs.gz +0 -0
  17. package/dist/{Bar3DChartScene-JP3BXEZW.js → Bar3DChartScene-UXC4LE44.js} +2 -2
  18. package/dist/Bar3DChartScene-UXC4LE44.js.br +0 -0
  19. package/dist/Bar3DChartScene-UXC4LE44.js.gz +0 -0
  20. package/dist/{Line3DChartScene-YVCSJMWK.mjs → Line3DChartScene-JF54KXMH.mjs} +1 -1
  21. package/dist/Line3DChartScene-JF54KXMH.mjs.br +0 -0
  22. package/dist/Line3DChartScene-JF54KXMH.mjs.gz +0 -0
  23. package/dist/{Line3DChartScene-JK3AELXZ.js → Line3DChartScene-Z2EVGX4C.js} +2 -2
  24. package/dist/Line3DChartScene-Z2EVGX4C.js.br +0 -0
  25. package/dist/Line3DChartScene-Z2EVGX4C.js.gz +0 -0
  26. package/dist/{Model3DScene-OXWSYHHK.mjs → Model3DScene-YWQBX477.mjs} +1 -1
  27. package/dist/Model3DScene-YWQBX477.mjs.br +0 -0
  28. package/dist/Model3DScene-YWQBX477.mjs.gz +0 -0
  29. package/dist/{Model3DScene-N6UIMN7T.js → Model3DScene-ZBOF56VV.js} +2 -2
  30. package/dist/Model3DScene-ZBOF56VV.js.br +0 -0
  31. package/dist/Model3DScene-ZBOF56VV.js.gz +0 -0
  32. package/dist/{PieChart3DScene-XK4ETZJC.mjs → PieChart3DScene-4TRQ4V3M.mjs} +1 -1
  33. package/dist/PieChart3DScene-4TRQ4V3M.mjs.br +0 -0
  34. package/dist/PieChart3DScene-4TRQ4V3M.mjs.gz +0 -0
  35. package/dist/{PieChart3DScene-Q2Z3ECL4.js → PieChart3DScene-JPQTAS34.js} +2 -2
  36. package/dist/PieChart3DScene-JPQTAS34.js.br +0 -0
  37. package/dist/PieChart3DScene-JPQTAS34.js.gz +0 -0
  38. package/dist/{SurfaceChart3DScene-KNWMKMOL.mjs → SurfaceChart3DScene-N76RNCUY.mjs} +1 -1
  39. package/dist/SurfaceChart3DScene-N76RNCUY.mjs.br +0 -0
  40. package/dist/SurfaceChart3DScene-N76RNCUY.mjs.gz +0 -0
  41. package/dist/{SurfaceChart3DScene-ULBUIF7T.js → SurfaceChart3DScene-P3LX35OP.js} +2 -2
  42. package/dist/SurfaceChart3DScene-P3LX35OP.js.br +0 -0
  43. package/dist/SurfaceChart3DScene-P3LX35OP.js.gz +0 -0
  44. package/dist/{chunk-6547ZWC7.mjs → chunk-6B7A5JNM.mjs} +12 -12
  45. package/dist/chunk-6B7A5JNM.mjs.br +0 -0
  46. package/dist/chunk-6B7A5JNM.mjs.gz +0 -0
  47. package/dist/{chunk-AT4BJKON.mjs → chunk-A6UVUZUX.mjs} +1 -1
  48. package/dist/chunk-A6UVUZUX.mjs.br +0 -0
  49. package/dist/chunk-A6UVUZUX.mjs.gz +0 -0
  50. package/dist/{chunk-C4Q4WYAJ.mjs → chunk-BNR6YPW5.mjs} +12 -34
  51. package/dist/chunk-BNR6YPW5.mjs.br +0 -0
  52. package/dist/chunk-BNR6YPW5.mjs.gz +0 -0
  53. package/dist/{chunk-J7Q7AGN7.mjs → chunk-ERCY52HH.mjs} +1 -1
  54. package/dist/chunk-ERCY52HH.mjs.br +0 -0
  55. package/dist/chunk-ERCY52HH.mjs.gz +0 -0
  56. package/dist/{chunk-5KAMDV37.js → chunk-L2MOKP3E.js} +1057 -375
  57. package/dist/chunk-L2MOKP3E.js.br +0 -0
  58. package/dist/chunk-L2MOKP3E.js.gz +0 -0
  59. package/dist/{chunk-YNTZCMRI.mjs → chunk-QVEPXTUB.mjs} +1056 -371
  60. package/dist/chunk-QVEPXTUB.mjs.br +0 -0
  61. package/dist/chunk-QVEPXTUB.mjs.gz +0 -0
  62. package/dist/{chunk-LAB7WX2N.js → chunk-TJ4L42RA.js} +456 -478
  63. package/dist/chunk-TJ4L42RA.js.br +0 -0
  64. package/dist/chunk-TJ4L42RA.js.gz +0 -0
  65. package/dist/{chunk-GLY4OPMY.js → chunk-W5W75MFP.js} +167 -167
  66. package/dist/chunk-W5W75MFP.js.br +0 -0
  67. package/dist/chunk-W5W75MFP.js.gz +0 -0
  68. package/dist/{chunk-Q6CSZ7VM.js → chunk-WYGPSCMS.js} +1289 -1289
  69. package/dist/chunk-WYGPSCMS.js.br +0 -0
  70. package/dist/chunk-WYGPSCMS.js.gz +0 -0
  71. package/dist/{chunk-VVJTEFGP.js → chunk-Y2UFUL7P.js} +5 -5
  72. package/dist/chunk-Y2UFUL7P.js.br +0 -0
  73. package/dist/chunk-Y2UFUL7P.js.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 +1 -1
  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.br +0 -0
  103. package/dist/Area3DChartScene-ZJYR6K66.js.gz +0 -0
  104. package/dist/Bar3DChartScene-42MWINQX.mjs.br +0 -0
  105. package/dist/Bar3DChartScene-42MWINQX.mjs.gz +0 -0
  106. package/dist/Bar3DChartScene-JP3BXEZW.js.br +0 -0
  107. package/dist/Bar3DChartScene-JP3BXEZW.js.gz +0 -0
  108. package/dist/Line3DChartScene-JK3AELXZ.js.br +0 -0
  109. package/dist/Line3DChartScene-JK3AELXZ.js.gz +0 -0
  110. package/dist/Line3DChartScene-YVCSJMWK.mjs.br +0 -0
  111. package/dist/Line3DChartScene-YVCSJMWK.mjs.gz +0 -0
  112. package/dist/Model3DScene-N6UIMN7T.js.br +0 -0
  113. package/dist/Model3DScene-N6UIMN7T.js.gz +0 -0
  114. package/dist/Model3DScene-OXWSYHHK.mjs.br +0 -0
  115. package/dist/Model3DScene-OXWSYHHK.mjs.gz +0 -0
  116. package/dist/PieChart3DScene-Q2Z3ECL4.js.br +0 -0
  117. package/dist/PieChart3DScene-Q2Z3ECL4.js.gz +0 -0
  118. package/dist/PieChart3DScene-XK4ETZJC.mjs.br +0 -0
  119. package/dist/PieChart3DScene-XK4ETZJC.mjs.gz +0 -0
  120. package/dist/SurfaceChart3DScene-KNWMKMOL.mjs.br +0 -0
  121. package/dist/SurfaceChart3DScene-KNWMKMOL.mjs.gz +0 -0
  122. package/dist/SurfaceChart3DScene-ULBUIF7T.js.br +0 -0
  123. package/dist/SurfaceChart3DScene-ULBUIF7T.js.gz +0 -0
  124. package/dist/chunk-5KAMDV37.js.br +0 -0
  125. package/dist/chunk-5KAMDV37.js.gz +0 -0
  126. package/dist/chunk-6547ZWC7.mjs.br +0 -0
  127. package/dist/chunk-6547ZWC7.mjs.gz +0 -0
  128. package/dist/chunk-AT4BJKON.mjs.br +0 -0
  129. package/dist/chunk-AT4BJKON.mjs.gz +0 -0
  130. package/dist/chunk-C4Q4WYAJ.mjs.br +0 -0
  131. package/dist/chunk-C4Q4WYAJ.mjs.gz +0 -0
  132. package/dist/chunk-GLY4OPMY.js.br +0 -0
  133. package/dist/chunk-GLY4OPMY.js.gz +0 -0
  134. package/dist/chunk-J7Q7AGN7.mjs.br +0 -0
  135. package/dist/chunk-J7Q7AGN7.mjs.gz +0 -0
  136. package/dist/chunk-LAB7WX2N.js.br +0 -0
  137. package/dist/chunk-LAB7WX2N.js.gz +0 -0
  138. package/dist/chunk-Q6CSZ7VM.js.br +0 -0
  139. package/dist/chunk-Q6CSZ7VM.js.gz +0 -0
  140. package/dist/chunk-VVJTEFGP.js.br +0 -0
  141. package/dist/chunk-VVJTEFGP.js.gz +0 -0
  142. package/dist/chunk-YNTZCMRI.mjs.br +0 -0
  143. 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({
@@ -99945,6 +100331,149 @@ var init_save_table_merge_helpers = __esm({
99945
100331
  ];
99946
100332
  }
99947
100333
  });
100334
+ function runTag(run) {
100335
+ return run.isLineBreak ? "a:br" : run.isField ? "a:fld" : "a:r";
100336
+ }
100337
+ function supportsOrder(paragraph, tags) {
100338
+ for (const [key2, value] of Object.entries(paragraph)) {
100339
+ if (key2.startsWith("@_") || key2 === "a:pPr" || key2 === "a:endParaRPr") {
100340
+ continue;
100341
+ }
100342
+ if (key2 === "#text" && String(value).trim() === "") {
100343
+ continue;
100344
+ }
100345
+ if (!CONTENT_TAGS.has(key2)) {
100346
+ return false;
100347
+ }
100348
+ }
100349
+ return [...CONTENT_TAGS].every(
100350
+ (tag) => tags.filter((candidate) => candidate === tag).length === ensureItems(paragraph[tag]).length
100351
+ );
100352
+ }
100353
+ function matchesParagraph(paragraph, runs) {
100354
+ if (!supportsOrder(paragraph, runs.map(runTag))) {
100355
+ return false;
100356
+ }
100357
+ const consumed = /* @__PURE__ */ new Map();
100358
+ for (const run of runs) {
100359
+ const tag = runTag(run);
100360
+ const index = consumed.get(tag) ?? 0;
100361
+ const node = ensureItems(paragraph[tag])[index];
100362
+ if (node === void 0) {
100363
+ return false;
100364
+ }
100365
+ if (tag !== "a:br" && (!isXmlObject3(node) || String(node["a:t"] ?? "") !== run.text)) {
100366
+ return false;
100367
+ }
100368
+ consumed.set(tag, index + 1);
100369
+ }
100370
+ return true;
100371
+ }
100372
+ function recordTableParagraphOrder(xmlCell, textRuns) {
100373
+ const txBody = xmlCell["a:txBody"];
100374
+ const paragraphs = isXmlObject3(txBody) ? ensureItems(txBody["a:p"]) : [];
100375
+ for (const paragraph of paragraphs) {
100376
+ if (isXmlObject3(paragraph)) {
100377
+ paragraphOrders.delete(paragraph);
100378
+ }
100379
+ }
100380
+ if (!textRuns) {
100381
+ return;
100382
+ }
100383
+ const runsByParagraph = [[]];
100384
+ for (const run of textRuns) {
100385
+ if (run.isParagraphBreak) {
100386
+ runsByParagraph.push([]);
100387
+ } else {
100388
+ runsByParagraph.at(-1).push(run);
100389
+ }
100390
+ }
100391
+ if (runsByParagraph.length !== paragraphs.length) {
100392
+ return;
100393
+ }
100394
+ paragraphs.forEach((paragraph, index) => {
100395
+ const runs = runsByParagraph[index];
100396
+ const tags = runs.map(runTag);
100397
+ if (isXmlObject3(paragraph) && !isGroupedByTag(tags) && matchesParagraph(paragraph, runs)) {
100398
+ paragraphOrders.set(paragraph, tags);
100399
+ }
100400
+ });
100401
+ }
100402
+ function orderedParagraph(paragraph, tags) {
100403
+ const result = {};
100404
+ for (const [key2, value] of Object.entries(paragraph)) {
100405
+ if (!CONTENT_TAGS.has(key2) && key2 !== "a:pPr" && key2 !== "a:endParaRPr") {
100406
+ setOwnXmlProperty(result, key2, value);
100407
+ }
100408
+ }
100409
+ if (paragraph["a:pPr"] !== void 0) {
100410
+ result["a:pPr"] = paragraph["a:pPr"];
100411
+ }
100412
+ const consumed = /* @__PURE__ */ new Map();
100413
+ assignOrderedXmlChildren(
100414
+ result,
100415
+ tags.map((tag) => {
100416
+ const index = consumed.get(tag) ?? 0;
100417
+ consumed.set(tag, index + 1);
100418
+ return { tag, node: ensureItems(paragraph[tag])[index] };
100419
+ })
100420
+ );
100421
+ if (paragraph["a:endParaRPr"] !== void 0) {
100422
+ result["a:endParaRPr"] = paragraph["a:endParaRPr"];
100423
+ }
100424
+ return result;
100425
+ }
100426
+ function withOrderedTableParagraphs(value, insideTable = false) {
100427
+ if (Array.isArray(value)) {
100428
+ let result2 = value;
100429
+ value.forEach((item, index) => {
100430
+ const next = withOrderedTableParagraphs(item, insideTable);
100431
+ if (next !== item) {
100432
+ if (result2 === value) {
100433
+ result2 = [...value];
100434
+ }
100435
+ result2[index] = next;
100436
+ }
100437
+ });
100438
+ return result2;
100439
+ }
100440
+ if (!isXmlObject3(value)) {
100441
+ return value;
100442
+ }
100443
+ let result = value;
100444
+ for (const [key2, item] of Object.entries(value)) {
100445
+ if (key2.startsWith("@_") || key2 === "#text") {
100446
+ continue;
100447
+ }
100448
+ const next = withOrderedTableParagraphs(item, insideTable || key2 === "a:tbl");
100449
+ if (next !== item) {
100450
+ if (result === value) {
100451
+ result = { ...value };
100452
+ }
100453
+ setOwnXmlProperty(result, key2, next);
100454
+ }
100455
+ }
100456
+ let tags = paragraphOrders.get(value);
100457
+ if (!tags && insideTable) {
100458
+ const { entries, authored } = paragraphContentEntries(value, CONTENT_TAGS);
100459
+ const sourceTags = entries.map(([tag]) => tag);
100460
+ if (authored && supportsOrder(value, sourceTags)) {
100461
+ tags = sourceTags;
100462
+ }
100463
+ }
100464
+ return tags ? orderedParagraph(result, tags) : result;
100465
+ }
100466
+ var CONTENT_TAGS;
100467
+ var paragraphOrders;
100468
+ var init_table_paragraph_save_order = __esm({
100469
+ "src/core/core/runtime/table-paragraph-save-order.ts"() {
100470
+ init_ordered_xml_children();
100471
+ init_paragraph_sibling_order();
100472
+ init_xml_child_scan();
100473
+ CONTENT_TAGS = /* @__PURE__ */ new Set(["a:r", "a:br", "a:fld"]);
100474
+ paragraphOrders = /* @__PURE__ */ new WeakMap();
100475
+ }
100476
+ });
99948
100477
  function ensureArray19(value) {
99949
100478
  if (value === void 0 || value === null) {
99950
100479
  return [];
@@ -99965,6 +100494,13 @@ function createDefaultXmlCell() {
99965
100494
  "a:tcPr": {}
99966
100495
  };
99967
100496
  }
100497
+ function createDefaultXmlRow(colCount, heightEmu) {
100498
+ const cells2 = Array.from({ length: colCount }, () => createDefaultXmlCell());
100499
+ return {
100500
+ "@_h": String(DEFAULT_ROW_HEIGHT_EMU),
100501
+ "a:tc": cells2.length === 1 ? cells2[0] : cells2
100502
+ };
100503
+ }
99968
100504
  function getTblFromRawXml(rawXml) {
99969
100505
  const graphicData = rawXml["a:graphic"]?.["a:graphicData"];
99970
100506
  return graphicData?.["a:tbl"];
@@ -100163,6 +100699,157 @@ var init_table_create_xml = __esm({
100163
100699
  init_table_style_defaults();
100164
100700
  }
100165
100701
  });
100702
+ function cells(row) {
100703
+ return ensureArray19(row["a:tc"]);
100704
+ }
100705
+ function promoteTextBody(source, next, removed, survivor, axis) {
100706
+ const span = axis === "row" ? "rowSpan" : "gridSpan";
100707
+ const continuation = axis === "row" ? "vMerge" : "hMerge";
100708
+ if (!source?.text || !next || !removed || !survivor || source[continuation] || (source[span] ?? 1) <= 1 || next[continuation] || (next[span] ?? 1) !== (source[span] ?? 1) - 1) {
100709
+ return;
100710
+ }
100711
+ if (removed["a:txBody"] !== void 0) {
100712
+ survivor["a:txBody"] = removed["a:txBody"];
100713
+ }
100714
+ }
100715
+ function applyTableStructureEditXml(table2, source, next, edit) {
100716
+ const rows = ensureArray19(table2["a:tr"]);
100717
+ const grid = table2["a:tblGrid"];
100718
+ const columns = ensureArray19(grid?.["a:gridCol"]);
100719
+ const { axis, action, index } = edit;
100720
+ if (axis !== "row" && axis !== "column" || action !== "insert" && action !== "delete") {
100721
+ return false;
100722
+ }
100723
+ const count = axis === "row" ? rows.length : columns.length;
100724
+ const delta = action === "insert" ? 1 : -1;
100725
+ 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)) {
100726
+ return false;
100727
+ }
100728
+ if (axis === "row") {
100729
+ if (action === "insert") {
100730
+ rows.splice(index, 0, createDefaultXmlRow(columns.length));
100731
+ } else {
100732
+ const removedCells = cells(rows[index]);
100733
+ const nextCells = rows[index + 1] ? cells(rows[index + 1]) : [];
100734
+ removedCells.forEach(
100735
+ (removed, column) => promoteTextBody(
100736
+ source?.rows[index]?.cells[column],
100737
+ next.rows[index]?.cells[column],
100738
+ removed,
100739
+ nextCells[column],
100740
+ axis
100741
+ )
100742
+ );
100743
+ rows.splice(index, 1);
100744
+ }
100745
+ table2["a:tr"] = rows.length === 1 ? rows[0] : rows;
100746
+ } else {
100747
+ if (action === "insert") {
100748
+ columns.splice(index, 0, { "@_w": "0" });
100749
+ } else {
100750
+ columns.splice(index, 1);
100751
+ }
100752
+ grid["a:gridCol"] = columns.length === 1 ? columns[0] : columns;
100753
+ rows.forEach((row, rowIndex) => {
100754
+ const rowCells = cells(row);
100755
+ if (action === "insert") {
100756
+ rowCells.splice(index, 0, createDefaultXmlCell());
100757
+ } else {
100758
+ promoteTextBody(
100759
+ source?.rows[rowIndex]?.cells[index],
100760
+ next.rows[rowIndex]?.cells[index],
100761
+ rowCells[index],
100762
+ rowCells[index + 1],
100763
+ axis
100764
+ );
100765
+ rowCells.splice(index, 1);
100766
+ }
100767
+ row["a:tc"] = rowCells.length === 1 ? rowCells[0] : rowCells;
100768
+ });
100769
+ }
100770
+ return true;
100771
+ }
100772
+ var init_table_structure_edit_xml = __esm({
100773
+ "src/core/core/runtime/table-structure-edit-xml.ts"() {
100774
+ init_table_structural_helpers();
100775
+ }
100776
+ });
100777
+ function createDefaultRebuildXmlCell() {
100778
+ return {
100779
+ "a:txBody": {
100780
+ "a:bodyPr": {},
100781
+ "a:lstStyle": {},
100782
+ "a:p": {
100783
+ "a:endParaRPr": { "@_lang": "en-US" }
100784
+ }
100785
+ },
100786
+ "a:tcPr": {}
100787
+ };
100788
+ }
100789
+ function rebuildTableStructureInRawXml(element, tableData, edit) {
100790
+ if (!element.rawXml) {
100791
+ return void 0;
100792
+ }
100793
+ const newRawXml = structuredClone(element.rawXml);
100794
+ const table2 = getTblFromRawXml(newRawXml);
100795
+ if (!table2) {
100796
+ return void 0;
100797
+ }
100798
+ const existingGridCols = ensureArray19(
100799
+ table2["a:tblGrid"]?.["a:gridCol"]
100800
+ );
100801
+ const totalWidthEmu = existingGridCols.reduce((sum, col) => {
100802
+ return sum + (parseInt(String(col?.["@_w"] || "0"), 10) || 0);
100803
+ }, 0) || 9144e3;
100804
+ const appliedEdit = edit ? applyTableStructureEditXml(
100805
+ table2,
100806
+ element.type === "table" ? element.tableData : void 0,
100807
+ tableData,
100808
+ edit
100809
+ ) : false;
100810
+ const alignedGridCols = ensureArray19(
100811
+ table2["a:tblGrid"]?.["a:gridCol"]
100812
+ );
100813
+ const newGridCols = tableData.columnWidths.map((w, index) => ({
100814
+ ...appliedEdit ? alignedGridCols[index] : {},
100815
+ "@_w": String(Math.round(w * totalWidthEmu))
100816
+ }));
100817
+ if (!table2["a:tblGrid"]) {
100818
+ table2["a:tblGrid"] = {};
100819
+ }
100820
+ table2["a:tblGrid"]["a:gridCol"] = newGridCols.length === 1 ? newGridCols[0] : newGridCols;
100821
+ const existingXmlRows = ensureArray19(table2["a:tr"]);
100822
+ const newXmlRows = tableData.rows.map((dataRow, ri) => {
100823
+ const existingRow = ri < existingXmlRows.length ? existingXmlRows[ri] : void 0;
100824
+ const existingCells = existingRow ? ensureArray19(existingRow["a:tc"]) : [];
100825
+ const heightEmu = dataRow.height ? Math.round(dataRow.height * EMU_PER_PX) : existingRow?.["@_h"] ? parseInt(String(existingRow["@_h"]), 10) : DEFAULT_ROW_HEIGHT_EMU;
100826
+ const newXmlCells = dataRow.cells.map((cell, ci) => {
100827
+ let xmlCell;
100828
+ if (ci < existingCells.length) {
100829
+ xmlCell = existingCells[ci];
100830
+ } else {
100831
+ xmlCell = createDefaultRebuildXmlCell();
100832
+ }
100833
+ serializeCellMergeAttributes(xmlCell, cell);
100834
+ return xmlCell;
100835
+ });
100836
+ return {
100837
+ ...appliedEdit ? existingRow : {},
100838
+ "@_h": String(heightEmu),
100839
+ "a:tc": newXmlCells.length === 1 ? newXmlCells[0] : newXmlCells
100840
+ };
100841
+ });
100842
+ table2["a:tr"] = newXmlRows.length === 1 ? newXmlRows[0] : newXmlRows;
100843
+ return newRawXml;
100844
+ }
100845
+ var init_table_structure_rawxml = __esm({
100846
+ "src/core/core/runtime/table-structure-rawxml.ts"() {
100847
+ init_constants();
100848
+ init_save_table_merge_helpers();
100849
+ init_table_structural_helpers();
100850
+ init_table_structure_edit_xml();
100851
+ }
100852
+ });
100166
100853
  function updateCellTextInRawXml(element, rowIndex, colIndex, text22) {
100167
100854
  if (!element.rawXml) {
100168
100855
  return void 0;
@@ -100176,12 +100863,12 @@ function updateCellTextInRawXml(element, rowIndex, colIndex, text22) {
100176
100863
  if (rowIndex < 0 || rowIndex >= rows.length) {
100177
100864
  return void 0;
100178
100865
  }
100179
- const cells = ensureArray19(rows[rowIndex]["a:tc"]);
100180
- if (colIndex < 0 || colIndex >= cells.length) {
100866
+ const cells2 = ensureArray19(rows[rowIndex]["a:tc"]);
100867
+ if (colIndex < 0 || colIndex >= cells2.length) {
100181
100868
  return void 0;
100182
100869
  }
100183
- cells[colIndex]["a:txBody"] = rebuildCellTextBody(
100184
- cells[colIndex]["a:txBody"],
100870
+ cells2[colIndex]["a:txBody"] = rebuildCellTextBody(
100871
+ cells2[colIndex]["a:txBody"],
100185
100872
  text22
100186
100873
  );
100187
100874
  return newRawXml;
@@ -100226,11 +100913,11 @@ function updateCellTextStyleInRawXml(element, rowIndex, colIndex, styleUpdates)
100226
100913
  if (rowIndex < 0 || rowIndex >= rows.length) {
100227
100914
  return void 0;
100228
100915
  }
100229
- const cells = ensureArray19(rows[rowIndex]["a:tc"]);
100230
- if (colIndex < 0 || colIndex >= cells.length) {
100916
+ const cells2 = ensureArray19(rows[rowIndex]["a:tc"]);
100917
+ if (colIndex < 0 || colIndex >= cells2.length) {
100231
100918
  return void 0;
100232
100919
  }
100233
- const cell = cells[colIndex];
100920
+ const cell = cells2[colIndex];
100234
100921
  const txBody = cell["a:txBody"];
100235
100922
  if (!txBody) {
100236
100923
  return void 0;
@@ -100361,87 +101048,11 @@ function updateMergeAttrsInRawXml(element, tableData) {
100361
101048
  }
100362
101049
  return newRawXml;
100363
101050
  }
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
101051
  var init_table_cell_rawxml_ops = __esm({
100441
101052
  "src/core/core/runtime/table-cell-rawxml-ops.ts"() {
100442
- init_constants();
100443
101053
  init_xml_access();
100444
101054
  init_table_structural_helpers();
101055
+ init_table_structure_rawxml();
100445
101056
  }
100446
101057
  });
100447
101058
  var init_table_structural_ops = __esm({
@@ -100672,6 +101283,7 @@ var init_PptxHandlerRuntimeSaveDataSerialization = __esm({
100672
101283
  init_chart_part_family_switch();
100673
101284
  init_PptxHandlerRuntimeChartUserShapes();
100674
101285
  init_save_table_merge_helpers();
101286
+ init_table_paragraph_save_order();
100675
101287
  init_table_structural_ops();
100676
101288
  init_table_tblpr_save();
100677
101289
  CHART_DATA_DISPLAY_OPTIONS_EXT_URI = "{56B9EC1D-385E-4148-901F-78D8002777C0}";
@@ -100749,6 +101361,7 @@ var init_PptxHandlerRuntimeSaveDataSerialization = __esm({
100749
101361
  this.writeTableCellStyle(xmlCell, cell.style);
100750
101362
  }
100751
101363
  serializeCellExtraAttributes(xmlCell, cell.extraAttributes);
101364
+ recordTableParagraphOrder(xmlCell, cell.textRuns);
100752
101365
  }
100753
101366
  }
100754
101367
  } catch (e) {
@@ -102425,6 +103038,7 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
102425
103038
  init_smartart_save_chrome();
102426
103039
  init_smartart_save_geometry();
102427
103040
  init_smartart_xml_builders();
103041
+ init_table_paragraph_save_order();
102428
103042
  PptxHandlerRuntime25 = class _PptxHandlerRuntime extends PptxHandlerRuntime24 {
102429
103043
  /** Pending SmartArt data updates to process during save. */
102430
103044
  pendingSmartArtUpdates;
@@ -102701,7 +103315,7 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
102701
103315
  );
102702
103316
  root["p:cSld"] = cSld;
102703
103317
  data["p:notesMaster"] = root;
102704
- this.zip.file(notesMaster.path, this.builder.build(data));
103318
+ this.zip.file(notesMaster.path, this.builder.build(withOrderedTableParagraphs(data)));
102705
103319
  } catch (e) {
102706
103320
  console.warn("Failed to save notes master changes:", e);
102707
103321
  }
@@ -102736,7 +103350,7 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
102736
103350
  );
102737
103351
  root["p:cSld"] = cSld;
102738
103352
  data["p:handoutMaster"] = root;
102739
- this.zip.file(handoutMaster.path, this.builder.build(data));
103353
+ this.zip.file(handoutMaster.path, this.builder.build(withOrderedTableParagraphs(data)));
102740
103354
  } catch (e) {
102741
103355
  console.warn("Failed to save handout master changes:", e);
102742
103356
  }
@@ -106983,7 +107597,7 @@ function buildOrderedSlideXml(options) {
106983
107597
  }
106984
107598
  }
106985
107599
  nextSlide = orderSlideRootChildren(nextSlide, getLocalName2);
106986
- return { ...xmlObj, "p:sld": nextSlide };
107600
+ return withOrderedTableParagraphs({ ...xmlObj, "p:sld": nextSlide });
106987
107601
  }
106988
107602
  var ALTERNATE_CONTENT_TAG;
106989
107603
  var UNRANKED;
@@ -106995,6 +107609,7 @@ var init_slide_save_xml_order = __esm({
106995
107609
  "src/core/core/runtime/slide-save-xml-order.ts"() {
106996
107610
  init_utils();
106997
107611
  init_ordered_xml_children();
107612
+ init_table_paragraph_save_order();
106998
107613
  ALTERNATE_CONTENT_TAG = "mc:AlternateContent";
106999
107614
  UNRANKED = Number.MAX_SAFE_INTEGER;
107000
107615
  COLLECTOR_KEYS = [
@@ -108489,12 +109104,12 @@ function orderedTemplatePartXml(options) {
108489
109104
  const rebuilt = positionsByRuntime.get(runtime)?.get(partPath);
108490
109105
  const ordered4 = rebuilt ? orderShapeTreeChildren(rewrapped, (node) => rebuilt.get(node), getLocalName2) : orderContainer(rewrapped, sourceXml ? scanSpTreeDocumentOrder(sourceXml) : [], getLocalName2);
108491
109106
  if (ordered4 === spTree) {
108492
- return xmlObj;
109107
+ return withOrderedTableParagraphs(xmlObj);
108493
109108
  }
108494
109109
  const nextRoot = { ...root, "p:cSld": { ...commonSlideData, "p:spTree": ordered4 } };
108495
109110
  const nextPart = { ...xmlObj };
108496
109111
  setOwnXmlProperty(nextPart, rootTag2, nextRoot);
108497
- return nextPart;
109112
+ return withOrderedTableParagraphs(nextPart);
108498
109113
  }
108499
109114
  var ALTERNATE_CONTENT_TAG3;
108500
109115
  var positionsByRuntime;
@@ -108504,6 +109119,7 @@ var init_template_sp_tree_order = __esm({
108504
109119
  init_ordered_xml_children();
108505
109120
  init_slide_save_xml_order();
108506
109121
  init_sp_tree_document_order_scan();
109122
+ init_table_paragraph_save_order();
108507
109123
  ALTERNATE_CONTENT_TAG3 = "mc:AlternateContent";
108508
109124
  positionsByRuntime = /* @__PURE__ */ new WeakMap();
108509
109125
  }
@@ -112497,11 +113113,7 @@ var init_PptxHandlerRuntimeShapeParagraphContentParsing = __esm({
112497
113113
  processField(f6);
112498
113114
  }
112499
113115
  };
112500
- const { entries, authored } = paragraphContentEntries(
112501
- p,
112502
- PARAGRAPH_CONTENT_TAGS,
112503
- (value) => this.ensureArray(value)
112504
- );
113116
+ const { entries, authored } = paragraphContentEntries(p, PARAGRAPH_CONTENT_TAGS);
112505
113117
  const runCount = this.ensureArray(p["a:r"]).length;
112506
113118
  const breakCount = this.ensureArray(p["a:br"]).length;
112507
113119
  const insertCollapsedBreaks = !authored && runCount > 1 && breakCount > 0;
@@ -136248,8 +136860,8 @@ var ChartElementProcessor = class {
136248
136860
  widths[widths.length - 1] = Math.max(widths[widths.length - 1], pct2.length);
136249
136861
  }
136250
136862
  }
136251
- const formatRow = (cells) => {
136252
- const padded = cells.map((cell, index) => cell.padEnd(widths[index]));
136863
+ const formatRow = (cells2) => {
136864
+ const padded = cells2.map((cell, index) => cell.padEnd(widths[index]));
136253
136865
  return `| ${padded.join(" | ")} |`;
136254
136866
  };
136255
136867
  const separator = `| ${widths.map((width) => "-".repeat(width)).join(" | ")} |`;
@@ -136809,7 +137421,7 @@ var TableElementProcessor = class {
136809
137421
  const row = tableData.rows[ri];
136810
137422
  const isHeader = ri === 0 && tableData.firstRowHeader !== false;
136811
137423
  const tag = isHeader ? "th" : "td";
136812
- const cells = [];
137424
+ const cells2 = [];
136813
137425
  let ci = 0;
136814
137426
  for (const cell of row.cells) {
136815
137427
  while (this.isOccupied(rowSpanOccupancy, ri, ci)) {
@@ -136830,11 +137442,11 @@ var TableElementProcessor = class {
136830
137442
  }
136831
137443
  const attrs3 = this.buildCellAttrs(cell, gridSpan, rowSpan, isHeader);
136832
137444
  const content = this.renderCellContent(cell);
136833
- cells.push(`<${tag}${attrs3}>${content}</${tag}>`);
137445
+ cells2.push(`<${tag}${attrs3}>${content}</${tag}>`);
136834
137446
  ci += gridSpan;
136835
137447
  }
136836
- if (cells.length > 0) {
136837
- htmlRows.push(`<tr>${cells.join("")}</tr>`);
137448
+ if (cells2.length > 0) {
137449
+ htmlRows.push(`<tr>${cells2.join("")}</tr>`);
136838
137450
  }
136839
137451
  }
136840
137452
  if (htmlRows.length === 0) {
@@ -137050,14 +137662,14 @@ ${htmlRows.join("\n")}
137050
137662
  const mdRows = [];
137051
137663
  const hasHeader = tableData.firstRowHeader !== false;
137052
137664
  for (let ri = 0; ri < rows.length; ri++) {
137053
- const cells = rows[ri].cells.map((cell) => {
137665
+ const cells2 = rows[ri].cells.map((cell) => {
137054
137666
  const text22 = this.getCellFormattedText(cell);
137055
137667
  return this.escapeMarkdownTableCell(text22);
137056
137668
  });
137057
- while (cells.length < columnCount) {
137058
- cells.push("");
137669
+ while (cells2.length < columnCount) {
137670
+ cells2.push("");
137059
137671
  }
137060
- mdRows.push(`| ${cells.join(" | ")} |`);
137672
+ mdRows.push(`| ${cells2.join(" | ")} |`);
137061
137673
  if (ri === 0 && hasHeader) {
137062
137674
  const divider = Array.from({ length: columnCount }, () => "---");
137063
137675
  mdRows.push(`| ${divider.join(" | ")} |`);
@@ -138378,8 +138990,8 @@ var OmmlLatexConverter = class {
138378
138990
  return null;
138379
138991
  }
138380
138992
  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(" & ");
138993
+ const cells2 = this.toRecordArray(row["m:e"]).map((entry2) => this.renderNode(entry2).trim()).filter((entry2) => entry2.length > 0);
138994
+ return cells2.join(" & ");
138383
138995
  }).filter((row) => row.length > 0);
138384
138996
  if (rows.length === 0) {
138385
138997
  return null;
@@ -143829,6 +144441,60 @@ var NOMINAL_ENVELOPE_BAND = {
143829
144441
  top: TOP_MARGIN,
143830
144442
  bottom: BOTTOM_MARGIN
143831
144443
  };
144444
+ var measureCtx;
144445
+ function getMeasureCtx() {
144446
+ if (measureCtx !== void 0) {
144447
+ return measureCtx;
144448
+ }
144449
+ if (typeof document === "undefined") {
144450
+ measureCtx = null;
144451
+ return null;
144452
+ }
144453
+ measureCtx = document.createElement("canvas").getContext("2d");
144454
+ return measureCtx;
144455
+ }
144456
+ function toCanvasFont(font) {
144457
+ const size = font.fontSizePx && font.fontSizePx > 0 ? font.fontSizePx : DEFAULT_TEXT_FONT_SIZE2;
144458
+ const family = font.fontFamily || DEFAULT_FONT_FAMILY2;
144459
+ return `${font.italic ? "italic " : ""}${font.bold ? "bold " : ""}${size}px ${family}`;
144460
+ }
144461
+ function measureGlyphAdvances(text22, font) {
144462
+ const chars = [...text22];
144463
+ const ctx = getMeasureCtx();
144464
+ if (!ctx) {
144465
+ const size = font.fontSizePx && font.fontSizePx > 0 ? font.fontSizePx : DEFAULT_TEXT_FONT_SIZE2;
144466
+ return chars.map(() => size * 0.55);
144467
+ }
144468
+ ctx.font = toCanvasFont(font);
144469
+ const advances = [];
144470
+ let previous = 0;
144471
+ let prefix = "";
144472
+ for (const char of chars) {
144473
+ prefix += char;
144474
+ const width = ctx.measureText(prefix).width;
144475
+ advances.push(Math.max(0, width - previous));
144476
+ previous = width;
144477
+ }
144478
+ return advances;
144479
+ }
144480
+ function measureLineAscent(segments) {
144481
+ const ctx = getMeasureCtx();
144482
+ if (!ctx) {
144483
+ return void 0;
144484
+ }
144485
+ let maxAscent = 0;
144486
+ for (const segment of segments) {
144487
+ if (!segment.text) {
144488
+ continue;
144489
+ }
144490
+ ctx.font = toCanvasFont(segment.font);
144491
+ const ascent = ctx.measureText(segment.text).actualBoundingBoxAscent;
144492
+ if (Number.isFinite(ascent) && ascent > maxAscent) {
144493
+ maxAscent = ascent;
144494
+ }
144495
+ }
144496
+ return maxAscent > 0 ? maxAscent : void 0;
144497
+ }
143832
144498
  function sliceBand(top, bottom, index, count) {
143833
144499
  const span = bottom - top;
143834
144500
  return {
@@ -143836,11 +144502,31 @@ function sliceBand(top, bottom, index, count) {
143836
144502
  bottom: top + (index + 1) / count * span
143837
144503
  };
143838
144504
  }
143839
- function edgeBandAt(preset, u, adj, adj2, height, lineIndex, lineCount) {
144505
+ function deformedBandAt(preset, u, adj, adj2, height) {
143840
144506
  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);
144507
+ return {
144508
+ top: (curve?.top ?? NOMINAL_ENVELOPE_BAND.top) * height,
144509
+ bottom: (curve?.bottom ?? NOMINAL_ENVELOPE_BAND.bottom) * height
144510
+ };
144511
+ }
144512
+ var ROW_BOUNDARY_REFERENCE_U = 0.5;
144513
+ function edgeBandAt(preset, u, adj, adj2, height, lineIndex, lineCount) {
144514
+ const actual = deformedBandAt(preset, u, adj, adj2, height);
144515
+ if (lineCount <= 1) {
144516
+ return sliceBand(actual.top, actual.bottom, 0, 1);
144517
+ }
144518
+ const reference = deformedBandAt(preset, ROW_BOUNDARY_REFERENCE_U, adj, adj2, height);
144519
+ const fixedSlice = sliceBand(reference.top, reference.bottom, lineIndex, lineCount);
144520
+ const isFirstRow = lineIndex <= 0;
144521
+ const isLastRow = lineIndex >= lineCount - 1;
144522
+ const flatTop = NOMINAL_ENVELOPE_BAND.top * height;
144523
+ const flatBottom = NOMINAL_ENVELOPE_BAND.bottom * height;
144524
+ const dampedOuterTop = flatTop + (actual.top - flatTop) / lineCount;
144525
+ const dampedOuterBottom = flatBottom + (actual.bottom - flatBottom) / lineCount;
144526
+ return {
144527
+ top: isFirstRow ? dampedOuterTop : fixedSlice.top,
144528
+ bottom: isLastRow ? dampedOuterBottom : fixedSlice.bottom
144529
+ };
143844
144530
  }
143845
144531
  function glyphEnvelopeMatrix(x0, x1, edge0, edge1, nomTop, nomBottom) {
143846
144532
  const nominalSpan = nomBottom - nomTop;
@@ -143853,6 +144539,34 @@ function glyphEnvelopeMatrix(x0, x1, edge0, edge1, nomTop, nomBottom) {
143853
144539
  const f6 = grandMean - b * meanX - d * meanY;
143854
144540
  return `matrix(1 ${b} 0 ${d} 0 ${f6})`;
143855
144541
  }
144542
+ function scaleOutlineCommandsX(commands, originX, scale2) {
144543
+ if (scale2 === 1) {
144544
+ return commands;
144545
+ }
144546
+ const sx = (x) => originX + (x - originX) * scale2;
144547
+ return commands.map((cmd) => {
144548
+ switch (cmd.type) {
144549
+ case "M":
144550
+ case "L":
144551
+ return { type: cmd.type, x: sx(cmd.x), y: cmd.y };
144552
+ case "Q":
144553
+ return { type: "Q", x1: sx(cmd.x1), y1: cmd.y1, x: sx(cmd.x), y: cmd.y };
144554
+ case "C":
144555
+ return {
144556
+ type: "C",
144557
+ x1: sx(cmd.x1),
144558
+ y1: cmd.y1,
144559
+ x2: sx(cmd.x2),
144560
+ y2: cmd.y2,
144561
+ x: sx(cmd.x),
144562
+ y: cmd.y
144563
+ };
144564
+ case "Z":
144565
+ default:
144566
+ return cmd;
144567
+ }
144568
+ });
144569
+ }
143856
144570
  function mapYThroughEnvelopeBand(y, nomTop, nomBottom, edgeTop, edgeBottom) {
143857
144571
  const nominalSpan = nomBottom - nomTop;
143858
144572
  if (nominalSpan <= 0) {
@@ -143982,75 +144696,16 @@ function buildGlyphSlices(preset, x0, x1, u0, u1, adj, adj2, height, lineIndex,
143982
144696
  const sliceX1 = x0 + (x1 - x0) * (i2 + 1) / n;
143983
144697
  const sliceU0 = u0 + (u1 - u0) * i2 / n;
143984
144698
  const sliceU1 = u0 + (u1 - u0) * (i2 + 1) / n;
144699
+ const e0 = edgeAt(sliceU0);
144700
+ const e1 = edgeAt(sliceU1);
143985
144701
  slices.push({
143986
144702
  clipX0: sliceX0 - (i2 === 0 ? 0 : SEAM_OVERLAP_PX),
143987
144703
  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
- )
144704
+ transform: glyphEnvelopeMatrix(sliceX0, sliceX1, e0, e1, nomTop, nomBottom)
143996
144705
  });
143997
144706
  }
143998
144707
  return slices;
143999
144708
  }
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
144709
  function startX(align, width, lineWidth) {
144055
144710
  if (align === "right") {
144056
144711
  return width - lineWidth;
@@ -144079,20 +144734,25 @@ function buildGlyphEnvelope(preset, segments, width, height, align, adj, adj2, l
144079
144734
  );
144080
144735
  const realAscent = measureLineAscent(segments);
144081
144736
  const nomTop = realAscent !== void 0 ? Math.max(fixedBandTop, nomBottom - realAscent) : fixedBandTop;
144737
+ const isCanFamily = preset === "textCanUp" || preset === "textCanDown";
144738
+ const stretch = width > 0 && lineWidth > 0 ? width / lineWidth : 1;
144739
+ const shapeScale = isCanFamily ? 1 : stretch;
144082
144740
  const placements = [];
144083
- let x = startX(align, width, lineWidth);
144741
+ let x = lineWidth > 0 ? 0 : startX(align, width, lineWidth);
144084
144742
  segments.forEach((segment, segIdx) => {
144085
144743
  const chars = [...segment.text];
144086
144744
  const advances = perSegmentAdvances[segIdx];
144087
144745
  chars.forEach((char, i2) => {
144088
- const glyphWidth = advances[i2] ?? 0;
144746
+ const naturalGlyphWidth = advances[i2] ?? 0;
144747
+ const pitch = naturalGlyphWidth * stretch;
144089
144748
  const x0 = x;
144090
- const x1 = x + glyphWidth;
144749
+ const x1 = x0 + naturalGlyphWidth;
144091
144750
  const u0 = width > 0 ? x0 / width : 0.5;
144092
144751
  const u1 = width > 0 ? x1 / width : 0.5;
144093
144752
  const edge0 = edgeBandAt(preset, u0, adj, adj2, height, safeLineIndex, safeLineCount);
144094
144753
  const edge1 = edgeBandAt(preset, u1, adj, adj2, height, safeLineIndex, safeLineCount);
144095
- const outlineCommands = getGlyphOutline?.(char, segment.font, x, nomBottom);
144754
+ const rawOutline = getGlyphOutline?.(char, segment.font, x0, nomBottom);
144755
+ const outlineCommands = rawOutline ? scaleOutlineCommandsX(rawOutline, x0, shapeScale) : void 0;
144096
144756
  const outlinePath = outlineCommands ? buildWarpedGlyphOutlinePathD(
144097
144757
  outlineCommands,
144098
144758
  preset,
@@ -144109,7 +144769,7 @@ function buildGlyphEnvelope(preset, segments, width, height, align, adj, adj2, l
144109
144769
  placements.push({
144110
144770
  char,
144111
144771
  segmentIndex: segment.segmentIndex,
144112
- x,
144772
+ x: x0,
144113
144773
  y: nomBottom,
144114
144774
  transform: glyphEnvelopeMatrix(x0, x1, edge0, edge1, nomTop, nomBottom),
144115
144775
  slices: sliceCount > 1 ? buildGlyphSlices(
@@ -144129,7 +144789,7 @@ function buildGlyphEnvelope(preset, segments, width, height, align, adj, adj2, l
144129
144789
  ) : void 0,
144130
144790
  outlinePath
144131
144791
  });
144132
- x += glyphWidth;
144792
+ x += pitch;
144133
144793
  });
144134
144794
  });
144135
144795
  return placements;
@@ -146745,9 +147405,9 @@ function convertMatrix(node, cc) {
146745
147405
  const rows = ensureArray6(node["m:mr"]);
146746
147406
  const tableRows = [];
146747
147407
  for (const row of rows) {
146748
- const cells = ensureArray6(row["m:e"]);
147408
+ const cells2 = ensureArray6(row["m:e"]);
146749
147409
  const tdParts = [];
146750
- for (const cell of cells) {
147410
+ for (const cell of cells2) {
146751
147411
  tdParts.push(`<mtd><mrow>${cc(cell)}</mrow></mtd>`);
146752
147412
  }
146753
147413
  tableRows.push(`<mtr>${tdParts.join("")}</mtr>`);
@@ -147472,16 +148132,16 @@ function parseEnvBody(ctx) {
147472
148132
  function buildMatrix(ctx, rows) {
147473
148133
  return {
147474
148134
  "m:m": {
147475
- "m:mr": rows.map((cells) => ({
147476
- "m:e": cells.map((cell) => ctx.wrapE(cell))
148135
+ "m:mr": rows.map((cells2) => ({
148136
+ "m:e": cells2.map((cell) => ctx.wrapE(cell))
147477
148137
  }))
147478
148138
  }
147479
148139
  };
147480
148140
  }
147481
148141
  function buildEqArr(ctx, rows) {
147482
- const lines = rows.map((cells) => {
148142
+ const lines = rows.map((cells2) => {
147483
148143
  const nodes = [];
147484
- cells.forEach((cell, index) => {
148144
+ cells2.forEach((cell, index) => {
147485
148145
  if (index > 0) {
147486
148146
  nodes.push(ctx.makeRun("&"));
147487
148147
  }
@@ -154319,13 +154979,13 @@ function buildIsometricSurfaceViewModel(element, chartData, categoryLabels) {
154319
154979
  const projH = maxSY - minSY;
154320
154980
  const offsetX = layout.plotLeft + layout.plotWidth / 2 - (minSX + projW / 2);
154321
154981
  const offsetY = layout.plotTop + layout.plotHeight / 2 - (minSY + projH / 2);
154322
- const cells = [];
154982
+ const cells2 = [];
154323
154983
  for (let r = 0; r < rows; r++) {
154324
154984
  for (let c = 0; c < cols; c++) {
154325
- cells.push({ row: r, col: c, depth: r + c });
154985
+ cells2.push({ row: r, col: c, depth: r + c });
154326
154986
  }
154327
154987
  }
154328
- cells.sort((a, b) => a.depth - b.depth);
154988
+ cells2.sort((a, b) => a.depth - b.depth);
154329
154989
  const primitives = [];
154330
154990
  primitives.push(
154331
154991
  ...buildSurfaceWallPanels(cols, rows, cellSize, zScale, offsetX, offsetY, {
@@ -154334,7 +154994,7 @@ function buildIsometricSurfaceViewModel(element, chartData, categoryLabels) {
154334
154994
  backWall: chartData.backWall
154335
154995
  })
154336
154996
  );
154337
- for (const { row, col } of cells) {
154997
+ for (const { row, col } of cells2) {
154338
154998
  const corners = [
154339
154999
  [col, row],
154340
155000
  [col + 1, row],
@@ -167671,15 +168331,15 @@ function setCellText(element, rowIndex, colIndex, text22) {
167671
168331
  });
167672
168332
  return { ...element, tableData: { ...tableData, rows } };
167673
168333
  }
167674
- function computeBoundingRect(cells) {
167675
- if (cells.length === 0) {
168334
+ function computeBoundingRect(cells2) {
168335
+ if (cells2.length === 0) {
167676
168336
  return void 0;
167677
168337
  }
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) {
168338
+ let startRow = cells2[0].row;
168339
+ let startCol = cells2[0].col;
168340
+ let endRow = cells2[0].row;
168341
+ let endCol = cells2[0].col;
168342
+ for (const { row, col } of cells2) {
167683
168343
  if (row < startRow) {
167684
168344
  startRow = row;
167685
168345
  }
@@ -167765,8 +168425,8 @@ function expandRectForExistingMerges(rect22, tableData) {
167765
168425
  }
167766
168426
  return { startRow, startCol, endRow, endCol };
167767
168427
  }
167768
- function mergeCells(cells, tableData) {
167769
- const rawRect = computeBoundingRect(cells);
168428
+ function mergeCells(cells2, tableData) {
168429
+ const rawRect = computeBoundingRect(cells2);
167770
168430
  if (!rawRect) {
167771
168431
  return tableData;
167772
168432
  }
@@ -167956,7 +168616,7 @@ function deleteTableRow(tableData, rowIdx) {
167956
168616
  }
167957
168617
  const removedRow = tableData.rows[rowIdx];
167958
168618
  const adjustedRows = [...tableData.rows];
167959
- const updateCellRowSpan = (cells, colIdx, newRowSpan) => cells.map((cc, ci) => ci === colIdx ? { ...cc, rowSpan: newRowSpan } : cc);
168619
+ const updateCellRowSpan = (cells2, colIdx, newRowSpan) => cells2.map((cc, ci) => ci === colIdx ? { ...cc, rowSpan: newRowSpan } : cc);
167960
168620
  for (let c = 0; c < removedRow.cells.length; c++) {
167961
168621
  const cell = removedRow.cells[c];
167962
168622
  if (cell.vMerge) {
@@ -167991,6 +168651,7 @@ function deleteTableRow(tableData, rowIdx) {
167991
168651
  return {
167992
168652
  ...cc,
167993
168653
  text: cell.text || cc.text,
168654
+ textRuns: cell.text ? cell.textRuns : cc.textRuns,
167994
168655
  style: cc.style || cell.style,
167995
168656
  rowSpan: newRs > 1 ? newRs : void 0,
167996
168657
  vMerge: void 0,
@@ -168090,6 +168751,7 @@ function deleteTableColumn(tableData, colIdx) {
168090
168751
  adjustedCells[nextColIdx] = {
168091
168752
  ...nextCell,
168092
168753
  text: cell.text || nextCell.text,
168754
+ textRuns: cell.text ? cell.textRuns : nextCell.textRuns,
168093
168755
  style: nextCell.style || cell.style,
168094
168756
  gridSpan: gs - 1 > 1 ? gs - 1 : void 0,
168095
168757
  hMerge: void 0,
@@ -168129,7 +168791,7 @@ function buildTableDataGrid(element) {
168129
168791
  canRemoveColumn: colCount > 1
168130
168792
  };
168131
168793
  }
168132
- function withTableData(element, transform6) {
168794
+ function withTableData(element, transform6, edit) {
168133
168795
  const tableData = element.tableData;
168134
168796
  if (!tableData) {
168135
168797
  return element;
@@ -168140,7 +168802,7 @@ function withTableData(element, transform6) {
168140
168802
  }
168141
168803
  const updated = { ...element, tableData: next };
168142
168804
  if (element.rawXml) {
168143
- const rawXml = rebuildTableStructureInRawXml(element, next);
168805
+ const rawXml = rebuildTableStructureInRawXml(element, next, edit);
168144
168806
  if (rawXml) {
168145
168807
  updated.rawXml = rawXml;
168146
168808
  }
@@ -168156,16 +168818,32 @@ function setTableElementCellText(element, rowIndex, colIndex, text22) {
168156
168818
  return rawXml ? { ...updated, rawXml } : updated;
168157
168819
  }
168158
168820
  function insertTableElementRow(element, rowIdx, position2) {
168159
- return withTableData(element, (data) => insertTableRow(data, rowIdx, position2));
168821
+ return withTableData(element, (data) => insertTableRow(data, rowIdx, position2), {
168822
+ axis: "row",
168823
+ action: "insert",
168824
+ index: position2 === "above" ? rowIdx : rowIdx + 1
168825
+ });
168160
168826
  }
168161
168827
  function removeTableElementRow(element, rowIdx) {
168162
- return withTableData(element, (data) => deleteTableRow(data, rowIdx));
168828
+ return withTableData(element, (data) => deleteTableRow(data, rowIdx), {
168829
+ axis: "row",
168830
+ action: "delete",
168831
+ index: rowIdx
168832
+ });
168163
168833
  }
168164
168834
  function insertTableElementColumn(element, colIdx, position2) {
168165
- return withTableData(element, (data) => insertTableColumn(data, colIdx, position2));
168835
+ return withTableData(element, (data) => insertTableColumn(data, colIdx, position2), {
168836
+ axis: "column",
168837
+ action: "insert",
168838
+ index: position2 === "left" ? colIdx : colIdx + 1
168839
+ });
168166
168840
  }
168167
168841
  function removeTableElementColumn(element, colIdx) {
168168
- return withTableData(element, (data) => deleteTableColumn(data, colIdx));
168842
+ return withTableData(element, (data) => deleteTableColumn(data, colIdx), {
168843
+ axis: "column",
168844
+ action: "delete",
168845
+ index: colIdx
168846
+ });
168169
168847
  }
168170
168848
  function appendTableElementRow(element) {
168171
168849
  const rowCount = element.tableData?.rows.length ?? 0;
@@ -168644,7 +169322,7 @@ function distributeElements(elements, axis, options) {
168644
169322
  }
168645
169323
  return result;
168646
169324
  }
168647
- var DEG_TO_RAD3 = Math.PI / 180;
169325
+ var DEG_TO_RAD4 = Math.PI / 180;
168648
169326
  function rotationOf(box) {
168649
169327
  return box.rotation ?? 0;
168650
169328
  }
@@ -168652,7 +169330,7 @@ function rotateDelta(dx, dy, rotationDeg) {
168652
169330
  if (!rotationDeg) {
168653
169331
  return { x: dx, y: dy };
168654
169332
  }
168655
- const rad = -rotationDeg * DEG_TO_RAD3;
169333
+ const rad = -rotationDeg * DEG_TO_RAD4;
168656
169334
  const cos = Math.cos(rad);
168657
169335
  const sin = Math.sin(rad);
168658
169336
  return {
@@ -168982,7 +169660,7 @@ function computeShadeToTitleFillToRect(title, slideWidthPx, slideHeightPx) {
168982
169660
  b: clampUnit3(1 - (title.y + title.height) / slideHeightPx)
168983
169661
  };
168984
169662
  }
168985
- var GRADIENT_STOP_TOKEN = /(rgba?\([^)]*\)|#[0-9a-fA-F]{3,8})\s+(-?[\d.]+)%/gu;
169663
+ var GRADIENT_STOP_TOKEN = /(rgba?\([^()]*\)|#[0-9a-fA-F]{3,8})\s+(-?[\d.]+)%/gu;
168986
169664
  function toHexChannel2(value) {
168987
169665
  return Math.min(255, Math.max(0, Math.round(value))).toString(16).padStart(2, "0");
168988
169666
  }
@@ -169173,7 +169851,7 @@ function newTableElement(rows = 3, cols = 3, x = DEFAULT_X, y = TABLE_DEFAULT_Y)
169173
169851
  const columnWidths = Array.from({ length: cols }).fill(colWidth);
169174
169852
  const tableRows = Array.from({ length: rows }, (_, rowIdx) => {
169175
169853
  const isHeader = rowIdx === 0;
169176
- const cells = Array.from({ length: cols }, (__, colIdx) => ({
169854
+ const cells2 = Array.from({ length: cols }, (__, colIdx) => ({
169177
169855
  text: isHeader ? `Header ${colIdx + 1}` : "",
169178
169856
  style: {
169179
169857
  borderTopWidth: 1,
@@ -169191,7 +169869,7 @@ function newTableElement(rows = 3, cols = 3, x = DEFAULT_X, y = TABLE_DEFAULT_Y)
169191
169869
  } : {}
169192
169870
  }
169193
169871
  }));
169194
- return { cells, height: isHeader ? 40 : 36 };
169872
+ return { cells: cells2, height: isHeader ? 40 : 36 };
169195
169873
  });
169196
169874
  return {
169197
169875
  type: "table",
@@ -184267,7 +184945,7 @@ var TRANSITION_DIR_GRID_POSITIONS = {
184267
184945
  rd: [2, 2]
184268
184946
  };
184269
184947
  function buildDirectionGrid(directions) {
184270
- const cells = [
184948
+ const cells2 = [
184271
184949
  [null, null, null],
184272
184950
  [null, null, null],
184273
184951
  [null, null, null]
@@ -184275,10 +184953,10 @@ function buildDirectionGrid(directions) {
184275
184953
  for (const dir of directions) {
184276
184954
  const pos2 = TRANSITION_DIR_GRID_POSITIONS[dir];
184277
184955
  if (pos2) {
184278
- cells[pos2[0]][pos2[1]] = dir;
184956
+ cells2[pos2[0]][pos2[1]] = dir;
184279
184957
  }
184280
184958
  }
184281
- return cells;
184959
+ return cells2;
184282
184960
  }
184283
184961
  function mergeSlideTransition(current, changes) {
184284
184962
  return { type: "none", ...current, ...changes };
@@ -199606,12 +200284,12 @@ async function fetchTextIfCrossOriginSafe(url) {
199606
200284
  return null;
199607
200285
  }
199608
200286
  }
199609
- var FONT_FACE_URL_PATTERN = /url\(\s*["']?([^"')]+)["']?\s*\)/gu;
200287
+ var FONT_FACE_URL_PATTERN = /url\(\s*(?:"([^"]*)"|'([^']*)'|([^"')\s]+))\s*\)/gu;
199610
200288
  async function inlineFontFaceUrls(css, fetchDataUrl) {
199611
200289
  const urls = /* @__PURE__ */ new Set();
199612
200290
  for (const match of css.matchAll(FONT_FACE_URL_PATTERN)) {
199613
- const raw = match[1];
199614
- if (raw.startsWith("http:") || raw.startsWith("https:")) {
200291
+ const raw = match[1] ?? match[2] ?? match[3];
200292
+ if (raw && (raw.startsWith("http:") || raw.startsWith("https:"))) {
199615
200293
  urls.add(raw);
199616
200294
  }
199617
200295
  }
@@ -199671,9 +200349,13 @@ async function fetchAsDataUrl(url) {
199671
200349
  return null;
199672
200350
  }
199673
200351
  }
200352
+ var CSS_URL_PATTERN = /url\(\s*(?:"([^"]*)"|'([^']*)'|([^"')\s]+))\s*\)/u;
199674
200353
  function extractCssUrl(value) {
199675
- const match = /url\(\s*["']?([^"')]+)["']?\s*\)/u.exec(value);
199676
- return match ? match[1] : null;
200354
+ const match = CSS_URL_PATTERN.exec(value);
200355
+ if (!match) {
200356
+ return null;
200357
+ }
200358
+ return match[1] ?? match[2] ?? match[3] ?? null;
199677
200359
  }
199678
200360
  function needsEmbedding(url) {
199679
200361
  return url.startsWith("blob:") || url.startsWith("http:") || url.startsWith("https:");
@@ -200143,13 +200825,13 @@ function computePageCells(pageIndex, slidesPerPage, totalSlides, startSlideIndex
200143
200825
  const printableWidth = page.width - page.marginLeft - page.marginRight;
200144
200826
  const printableHeight = page.height - page.marginTop - page.marginBottom;
200145
200827
  const isThreePerPage = slidesPerPage === 3;
200146
- const cells = [];
200828
+ const cells2 = [];
200147
200829
  if (isThreePerPage) {
200148
200830
  const slideAreaWidth = printableWidth * THREE_PER_PAGE_SLIDE_FRACTION;
200149
200831
  const cellHeight = (printableHeight - CELL_GAP * (grid.rows - 1)) / grid.rows;
200150
200832
  for (let row = 0; row < grid.rows; row++) {
200151
200833
  const slideIdx = startSlideIndex + row;
200152
- cells.push({
200834
+ cells2.push({
200153
200835
  slideIndex: slideIdx < totalSlides ? slideIdx : -1,
200154
200836
  row,
200155
200837
  col: 0,
@@ -200166,7 +200848,7 @@ function computePageCells(pageIndex, slidesPerPage, totalSlides, startSlideIndex
200166
200848
  for (let row = 0; row < grid.rows; row++) {
200167
200849
  for (let col = 0; col < grid.columns; col++) {
200168
200850
  const slideIdx = startSlideIndex + cellIndex;
200169
- cells.push({
200851
+ cells2.push({
200170
200852
  slideIndex: slideIdx < totalSlides ? slideIdx : -1,
200171
200853
  row,
200172
200854
  col,
@@ -200181,7 +200863,7 @@ function computePageCells(pageIndex, slidesPerPage, totalSlides, startSlideIndex
200181
200863
  }
200182
200864
  return {
200183
200865
  pageIndex,
200184
- cells,
200866
+ cells: cells2,
200185
200867
  hasNoteLines: isThreePerPage
200186
200868
  };
200187
200869
  }
@@ -201934,6 +202616,9 @@ function groupTilesByRow(tiles) {
201934
202616
  const rowCount = tiles.reduce((max, t) => Math.max(max, t.row), 0) + 1;
201935
202617
  const rows = Array.from({ length: rowCount }, () => []);
201936
202618
  for (const tile of tiles) {
202619
+ if (!Number.isInteger(tile.row) || !Number.isInteger(tile.col) || tile.row < 0 || tile.col < 0) {
202620
+ continue;
202621
+ }
201937
202622
  rows[tile.row][tile.col] = tile;
201938
202623
  }
201939
202624
  return rows;
@@ -202587,8 +203272,6 @@ exports.defaultRadius = defaultRadius;
202587
203272
  exports.defaultThemeColors = defaultThemeColors;
202588
203273
  exports.deleteAutosaveSnapshot = deleteAutosaveSnapshot;
202589
203274
  exports.deleteSection = deleteSection;
202590
- exports.deleteTableColumn = deleteTableColumn;
202591
- exports.deleteTableRow = deleteTableRow;
202592
203275
  exports.deleteTableStyleFromMap = deleteTableStyleFromMap;
202593
203276
  exports.deleteTagFromCollections = deleteTagFromCollections;
202594
203277
  exports.demote = demote;
@@ -202740,8 +203423,8 @@ exports.hideChartSeries = hideChartSeries;
202740
203423
  exports.hollowTextFillStyle = hollowTextFillStyle;
202741
203424
  exports.inlineElementPointerEvents = inlineElementPointerEvents;
202742
203425
  exports.insertCommentMention = insertCommentMention;
202743
- exports.insertTableColumn = insertTableColumn;
202744
- exports.insertTableRow = insertTableRow;
203426
+ exports.insertTableElementColumn = insertTableElementColumn;
203427
+ exports.insertTableElementRow = insertTableElementRow;
202745
203428
  exports.isActionHidden = isActionHidden;
202746
203429
  exports.isBlackboardActive = isBlackboardActive;
202747
203430
  exports.isBrowserOpenableMime = isBrowserOpenableMime;
@@ -202909,7 +203592,6 @@ exports.readStoredViewerPrefs = readStoredViewerPrefs;
202909
203592
  exports.readViewportMetrics = readViewportMetrics;
202910
203593
  exports.readingViewFitScale = readingViewFitScale;
202911
203594
  exports.rebuildDrawingShapesIfCleared = rebuildDrawingShapesIfCleared;
202912
- exports.rebuildTableStructureInRawXml = rebuildTableStructureInRawXml;
202913
203595
  exports.reconcileSlidesInYDoc = reconcileSlidesInYDoc;
202914
203596
  exports.recordProgressPercent = recordProgressPercent;
202915
203597
  exports.rectToCells = rectToCells;