pptx-react-viewer 3.10.0 → 3.11.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 (136) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/{AiChatPanel-NSVSBJC7.js → AiChatPanel-A3ZMMVUA.js} +24 -24
  3. package/dist/AiChatPanel-A3ZMMVUA.js.br +0 -0
  4. package/dist/AiChatPanel-A3ZMMVUA.js.gz +0 -0
  5. package/dist/{AiChatPanel-BQSUE2OO.mjs → AiChatPanel-L5H455NZ.mjs} +3 -3
  6. package/dist/AiChatPanel-L5H455NZ.mjs.br +0 -0
  7. package/dist/AiChatPanel-L5H455NZ.mjs.gz +0 -0
  8. package/dist/{Area3DChartScene-2FQHPGNE.mjs → Area3DChartScene-OAD36KIX.mjs} +1 -1
  9. package/dist/{Area3DChartScene-2FQHPGNE.mjs.br → Area3DChartScene-OAD36KIX.mjs.br} +0 -0
  10. package/dist/Area3DChartScene-OAD36KIX.mjs.gz +0 -0
  11. package/dist/{Area3DChartScene-V3W2V7N5.js → Area3DChartScene-R2CKCYCB.js} +2 -2
  12. package/dist/{Area3DChartScene-V3W2V7N5.js.br → Area3DChartScene-R2CKCYCB.js.br} +0 -0
  13. package/dist/Area3DChartScene-R2CKCYCB.js.gz +0 -0
  14. package/dist/{Bar3DChartScene-55XMAUC7.js → Bar3DChartScene-CRRPMXGQ.js} +2 -2
  15. package/dist/Bar3DChartScene-CRRPMXGQ.js.br +0 -0
  16. package/dist/Bar3DChartScene-CRRPMXGQ.js.gz +0 -0
  17. package/dist/{Bar3DChartScene-PSJEVANA.mjs → Bar3DChartScene-XNNXF26T.mjs} +1 -1
  18. package/dist/{Bar3DChartScene-PSJEVANA.mjs.br → Bar3DChartScene-XNNXF26T.mjs.br} +0 -0
  19. package/dist/Bar3DChartScene-XNNXF26T.mjs.gz +0 -0
  20. package/dist/{Line3DChartScene-5KACYRSQ.js → Line3DChartScene-44PLZML2.js} +2 -2
  21. package/dist/Line3DChartScene-44PLZML2.js.br +0 -0
  22. package/dist/Line3DChartScene-44PLZML2.js.gz +0 -0
  23. package/dist/{Line3DChartScene-BUVNUFNO.mjs → Line3DChartScene-MNNPB3LZ.mjs} +1 -1
  24. package/dist/{Line3DChartScene-BUVNUFNO.mjs.br → Line3DChartScene-MNNPB3LZ.mjs.br} +0 -0
  25. package/dist/Line3DChartScene-MNNPB3LZ.mjs.gz +0 -0
  26. package/dist/{Model3DScene-REKMR2L6.mjs → Model3DScene-5MUREFLY.mjs} +1 -1
  27. package/dist/{Model3DScene-REKMR2L6.mjs.br → Model3DScene-5MUREFLY.mjs.br} +0 -0
  28. package/dist/Model3DScene-5MUREFLY.mjs.gz +0 -0
  29. package/dist/{Model3DScene-6U6TN36M.js → Model3DScene-RYPYQPJH.js} +2 -2
  30. package/dist/Model3DScene-RYPYQPJH.js.br +0 -0
  31. package/dist/Model3DScene-RYPYQPJH.js.gz +0 -0
  32. package/dist/{PieChart3DScene-MV3JF7EM.js → PieChart3DScene-GACYCSSQ.js} +2 -2
  33. package/dist/{PieChart3DScene-MV3JF7EM.js.br → PieChart3DScene-GACYCSSQ.js.br} +0 -0
  34. package/dist/PieChart3DScene-GACYCSSQ.js.gz +0 -0
  35. package/dist/{PieChart3DScene-4L2VVIUJ.mjs → PieChart3DScene-KYZSSG5X.mjs} +1 -1
  36. package/dist/PieChart3DScene-KYZSSG5X.mjs.br +0 -0
  37. package/dist/PieChart3DScene-KYZSSG5X.mjs.gz +0 -0
  38. package/dist/{SurfaceChart3DScene-SFIOK3G3.js → SurfaceChart3DScene-RI5G4BHS.js} +2 -2
  39. package/dist/{SurfaceChart3DScene-SFIOK3G3.js.br → SurfaceChart3DScene-RI5G4BHS.js.br} +0 -0
  40. package/dist/SurfaceChart3DScene-RI5G4BHS.js.gz +0 -0
  41. package/dist/{SurfaceChart3DScene-ARE7OBFI.mjs → SurfaceChart3DScene-ZUP4PRUZ.mjs} +1 -1
  42. package/dist/SurfaceChart3DScene-ZUP4PRUZ.mjs.br +0 -0
  43. package/dist/SurfaceChart3DScene-ZUP4PRUZ.mjs.gz +0 -0
  44. package/dist/{chunk-DZ3HWACD.js → chunk-4PL3GBSD.js} +1256 -1256
  45. package/dist/chunk-4PL3GBSD.js.br +0 -0
  46. package/dist/chunk-4PL3GBSD.js.gz +0 -0
  47. package/dist/{chunk-M6GIPAY4.mjs → chunk-5T4Y4QPV.mjs} +1 -1
  48. package/dist/chunk-5T4Y4QPV.mjs.br +0 -0
  49. package/dist/chunk-5T4Y4QPV.mjs.gz +0 -0
  50. package/dist/{chunk-UKPGYJ7G.mjs → chunk-6BNPHEEX.mjs} +998 -549
  51. package/dist/chunk-6BNPHEEX.mjs.br +0 -0
  52. package/dist/chunk-6BNPHEEX.mjs.gz +0 -0
  53. package/dist/{chunk-HYUPPQJW.js → chunk-BX4XVY5X.js} +5 -5
  54. package/dist/chunk-BX4XVY5X.js.br +0 -0
  55. package/dist/chunk-BX4XVY5X.js.gz +0 -0
  56. package/dist/{chunk-XW46A7DN.js → chunk-IK25LY4C.js} +167 -167
  57. package/dist/chunk-IK25LY4C.js.br +0 -0
  58. package/dist/chunk-IK25LY4C.js.gz +0 -0
  59. package/dist/{chunk-2Q2NFPXA.js → chunk-LY5535CF.js} +998 -549
  60. package/dist/chunk-LY5535CF.js.br +0 -0
  61. package/dist/chunk-LY5535CF.js.gz +0 -0
  62. package/dist/{chunk-FHOUTYMB.js → chunk-MRBHJ26I.js} +434 -434
  63. package/dist/chunk-MRBHJ26I.js.br +0 -0
  64. package/dist/chunk-MRBHJ26I.js.gz +0 -0
  65. package/dist/{chunk-KWHURCVT.mjs → chunk-N75WRHON.mjs} +12 -12
  66. package/dist/chunk-N75WRHON.mjs.br +0 -0
  67. package/dist/chunk-N75WRHON.mjs.gz +0 -0
  68. package/dist/{chunk-T4ZRSRQZ.mjs → chunk-SUEZMQRT.mjs} +1 -1
  69. package/dist/chunk-SUEZMQRT.mjs.br +0 -0
  70. package/dist/chunk-SUEZMQRT.mjs.gz +0 -0
  71. package/dist/{chunk-HJZA3O3S.mjs → chunk-VHFPZBUW.mjs} +2 -2
  72. package/dist/chunk-VHFPZBUW.mjs.br +0 -0
  73. package/dist/chunk-VHFPZBUW.mjs.gz +0 -0
  74. package/dist/index.d.ts +30 -17
  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 +30 -17
  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 +30 -17
  89. package/dist/viewer/index.js +26 -26
  90. package/dist/viewer/index.js.br +0 -0
  91. package/dist/viewer/index.js.gz +0 -0
  92. package/dist/viewer/index.mjs +5 -5
  93. package/dist/viewer/index.mjs.br +0 -0
  94. package/dist/viewer/index.mjs.gz +0 -0
  95. package/package.json +2 -2
  96. package/dist/AiChatPanel-BQSUE2OO.mjs.br +0 -0
  97. package/dist/AiChatPanel-BQSUE2OO.mjs.gz +0 -0
  98. package/dist/AiChatPanel-NSVSBJC7.js.br +0 -0
  99. package/dist/AiChatPanel-NSVSBJC7.js.gz +0 -0
  100. package/dist/Area3DChartScene-2FQHPGNE.mjs.gz +0 -0
  101. package/dist/Area3DChartScene-V3W2V7N5.js.gz +0 -0
  102. package/dist/Bar3DChartScene-55XMAUC7.js.br +0 -0
  103. package/dist/Bar3DChartScene-55XMAUC7.js.gz +0 -0
  104. package/dist/Bar3DChartScene-PSJEVANA.mjs.gz +0 -0
  105. package/dist/Line3DChartScene-5KACYRSQ.js.br +0 -0
  106. package/dist/Line3DChartScene-5KACYRSQ.js.gz +0 -0
  107. package/dist/Line3DChartScene-BUVNUFNO.mjs.gz +0 -0
  108. package/dist/Model3DScene-6U6TN36M.js.br +0 -0
  109. package/dist/Model3DScene-6U6TN36M.js.gz +0 -0
  110. package/dist/Model3DScene-REKMR2L6.mjs.gz +0 -0
  111. package/dist/PieChart3DScene-4L2VVIUJ.mjs.br +0 -0
  112. package/dist/PieChart3DScene-4L2VVIUJ.mjs.gz +0 -0
  113. package/dist/PieChart3DScene-MV3JF7EM.js.gz +0 -0
  114. package/dist/SurfaceChart3DScene-ARE7OBFI.mjs.br +0 -0
  115. package/dist/SurfaceChart3DScene-ARE7OBFI.mjs.gz +0 -0
  116. package/dist/SurfaceChart3DScene-SFIOK3G3.js.gz +0 -0
  117. package/dist/chunk-2Q2NFPXA.js.br +0 -0
  118. package/dist/chunk-2Q2NFPXA.js.gz +0 -0
  119. package/dist/chunk-DZ3HWACD.js.br +0 -0
  120. package/dist/chunk-DZ3HWACD.js.gz +0 -0
  121. package/dist/chunk-FHOUTYMB.js.br +0 -0
  122. package/dist/chunk-FHOUTYMB.js.gz +0 -0
  123. package/dist/chunk-HJZA3O3S.mjs.br +0 -0
  124. package/dist/chunk-HJZA3O3S.mjs.gz +0 -0
  125. package/dist/chunk-HYUPPQJW.js.br +0 -0
  126. package/dist/chunk-HYUPPQJW.js.gz +0 -0
  127. package/dist/chunk-KWHURCVT.mjs.br +0 -0
  128. package/dist/chunk-KWHURCVT.mjs.gz +0 -0
  129. package/dist/chunk-M6GIPAY4.mjs.br +0 -0
  130. package/dist/chunk-M6GIPAY4.mjs.gz +0 -0
  131. package/dist/chunk-T4ZRSRQZ.mjs.br +0 -0
  132. package/dist/chunk-T4ZRSRQZ.mjs.gz +0 -0
  133. package/dist/chunk-UKPGYJ7G.mjs.br +0 -0
  134. package/dist/chunk-UKPGYJ7G.mjs.gz +0 -0
  135. package/dist/chunk-XW46A7DN.js.br +0 -0
  136. package/dist/chunk-XW46A7DN.js.gz +0 -0
@@ -32086,6 +32086,39 @@ var init_smartart_interpreter_fold_text = __esm({
32086
32086
  init_smartart_node_text_projection();
32087
32087
  }
32088
32088
  });
32089
+ function buildConnectorLabels(connections) {
32090
+ if (!connections || connections.length === 0) {
32091
+ return void 0;
32092
+ }
32093
+ const labels = /* @__PURE__ */ new Map();
32094
+ for (const connection of connections) {
32095
+ if (!connection.label) {
32096
+ continue;
32097
+ }
32098
+ const isParentChildEdge = !connection.type || connection.type === "parOf";
32099
+ if (isParentChildEdge) {
32100
+ labels.set(`${connection.sourceId}>${connection.destId}`, connection.label);
32101
+ }
32102
+ }
32103
+ return labels.size > 0 ? labels : void 0;
32104
+ }
32105
+ function buildChildOrder(connections) {
32106
+ if (!connections || connections.length === 0) {
32107
+ return void 0;
32108
+ }
32109
+ const order = /* @__PURE__ */ new Map();
32110
+ for (const connection of connections) {
32111
+ const isParentChildEdge = !connection.type || connection.type === "parOf";
32112
+ if (isParentChildEdge && typeof connection.srcOrd === "number") {
32113
+ order.set(connection.destId, connection.srcOrd);
32114
+ }
32115
+ }
32116
+ return order.size > 0 ? order : void 0;
32117
+ }
32118
+ var init_smartart_layout_interpreter_connector_order = __esm({
32119
+ "src/core/utils/smartart-layout-interpreter-connector-order.ts"() {
32120
+ }
32121
+ });
32089
32122
  function topLevelSmartArtNodes(nodes) {
32090
32123
  const hasNestedChildren = nodes.some((n) => n.children !== void 0 && n.children.length > 0);
32091
32124
  if (hasNestedChildren) {
@@ -32098,16 +32131,22 @@ function smartArtDescendantsWithText(node, childrenOf) {
32098
32131
  const out = [];
32099
32132
  const walk2 = (current) => {
32100
32133
  for (const child262 of childrenOf.get(current.id) ?? []) {
32101
- if (child262.text.trim().length > 0) {
32102
- out.push(child262);
32103
- }
32134
+ out.push(child262);
32104
32135
  walk2(child262);
32105
32136
  }
32106
32137
  };
32107
32138
  walk2(node);
32108
- return out;
32139
+ let start = 0;
32140
+ while (start < out.length && out[start].text.trim().length === 0) {
32141
+ start++;
32142
+ }
32143
+ let end = out.length - 1;
32144
+ while (end >= start && out[end].text.trim().length === 0) {
32145
+ end--;
32146
+ }
32147
+ return out.slice(start, end + 1);
32109
32148
  }
32110
- function smartArtChildrenOf(nodes) {
32149
+ function smartArtChildrenOf(nodes, connections) {
32111
32150
  const map = /* @__PURE__ */ new Map();
32112
32151
  for (const n of nodes) {
32113
32152
  if (n.children && n.children.length > 0) {
@@ -32121,10 +32160,24 @@ function smartArtChildrenOf(nodes) {
32121
32160
  }
32122
32161
  }
32123
32162
  }
32163
+ const childOrder3 = connections ? buildChildOrder(connections) : void 0;
32164
+ if (childOrder3) {
32165
+ for (const [parentId, list] of map) {
32166
+ if (list.length > 1 && list.some((child262) => childOrder3.has(child262.id))) {
32167
+ map.set(
32168
+ parentId,
32169
+ list.map((node, originalIndex) => ({ node, originalIndex })).sort(
32170
+ (a, b) => (childOrder3.get(a.node.id) ?? a.originalIndex) - (childOrder3.get(b.node.id) ?? b.originalIndex)
32171
+ ).map((entry2) => entry2.node)
32172
+ );
32173
+ }
32174
+ }
32175
+ }
32124
32176
  return map;
32125
32177
  }
32126
32178
  var init_smartart_node_tree_axis = __esm({
32127
32179
  "src/core/utils/smartart-node-tree-axis.ts"() {
32180
+ init_smartart_layout_interpreter_connector_order();
32128
32181
  }
32129
32182
  });
32130
32183
  function polygonBoundingBox(points4) {
@@ -32137,9 +32190,9 @@ function polygonBoundingBox(points4) {
32137
32190
  const maxY = Math.max(...ys);
32138
32191
  return { x: minX, y: minY, width: Math.max(1, maxX - minX), height: Math.max(1, maxY - minY) };
32139
32192
  }
32140
- function interpretedLayoutToElements(result, nodes, containerBounds, bulletEnabled = false) {
32193
+ function interpretedLayoutToElements(result, nodes, containerBounds, bulletEnabled = false, connections) {
32141
32194
  const nodeById = new Map(nodes.map((n) => [n.id, n]));
32142
- const childrenOf = smartArtChildrenOf(nodes);
32195
+ const childrenOf = smartArtChildrenOf(nodes, connections);
32143
32196
  const renderedIds = new Set(
32144
32197
  result.nodes.flatMap((r) => [r.nodeId, ...r.foldedNodeIds ?? []]).filter((id) => Boolean(id))
32145
32198
  );
@@ -32365,39 +32418,6 @@ var init_smartart_hierarchy_child_order = __esm({
32365
32418
  "src/core/utils/smartart-hierarchy-child-order.ts"() {
32366
32419
  }
32367
32420
  });
32368
- function buildConnectorLabels(connections) {
32369
- if (!connections || connections.length === 0) {
32370
- return void 0;
32371
- }
32372
- const labels = /* @__PURE__ */ new Map();
32373
- for (const connection of connections) {
32374
- if (!connection.label) {
32375
- continue;
32376
- }
32377
- const isParentChildEdge = !connection.type || connection.type === "parOf";
32378
- if (isParentChildEdge) {
32379
- labels.set(`${connection.sourceId}>${connection.destId}`, connection.label);
32380
- }
32381
- }
32382
- return labels.size > 0 ? labels : void 0;
32383
- }
32384
- function buildChildOrder(connections) {
32385
- if (!connections || connections.length === 0) {
32386
- return void 0;
32387
- }
32388
- const order = /* @__PURE__ */ new Map();
32389
- for (const connection of connections) {
32390
- const isParentChildEdge = !connection.type || connection.type === "parOf";
32391
- if (isParentChildEdge && typeof connection.srcOrd === "number") {
32392
- order.set(connection.destId, connection.srcOrd);
32393
- }
32394
- }
32395
- return order.size > 0 ? order : void 0;
32396
- }
32397
- var init_smartart_layout_interpreter_connector_order = __esm({
32398
- "src/core/utils/smartart-layout-interpreter-connector-order.ts"() {
32399
- }
32400
- });
32401
32421
  function parsePoints(points4) {
32402
32422
  return points4.trim().split(/\s+/u).filter((pair) => pair.length > 0).map((pair) => {
32403
32423
  const [x, y] = pair.split(",").map(Number);
@@ -32508,163 +32528,6 @@ var init_smartart_layout_interpreter_custom = __esm({
32508
32528
  "src/core/utils/smartart-layout-interpreter-custom.ts"() {
32509
32529
  }
32510
32530
  });
32511
- function arrowHeadPath(tipX, tipY, ux, uy) {
32512
- const bx = tipX - ux * ARROW_HEAD;
32513
- const by = tipY - uy * ARROW_HEAD;
32514
- const px3 = -uy;
32515
- const py = ux;
32516
- const w1x = bx + px3 * ARROW_WING;
32517
- const w1y = by + py * ARROW_WING;
32518
- const w2x = bx - px3 * ARROW_WING;
32519
- const w2y = by - py * ARROW_WING;
32520
- return ` M${w1x},${w1y} L${tipX},${tipY} L${w2x},${w2y}`;
32521
- }
32522
- function endHeads(x0, y0, x1, y1, begSty, endSty) {
32523
- const dx = x1 - x0;
32524
- const dy = y1 - y0;
32525
- const len = Math.hypot(dx, dy);
32526
- if (len < 1e-6) {
32527
- return "";
32528
- }
32529
- const ux = dx / len;
32530
- const uy = dy / len;
32531
- let heads = "";
32532
- if (endSty === "arr") {
32533
- heads += arrowHeadPath(x1, y1, ux, uy);
32534
- }
32535
- if (begSty === "arr") {
32536
- heads += arrowHeadPath(x0, y0, -ux, -uy);
32537
- }
32538
- return heads;
32539
- }
32540
- function straightPath(x0, y0, x1, y1) {
32541
- return `M${x0},${y0} L${x1},${y1}`;
32542
- }
32543
- function elbowPath(x0, y0, x1, y1) {
32544
- if (Math.abs(x1 - x0) >= Math.abs(y1 - y0)) {
32545
- const midX = (x0 + x1) / 2;
32546
- return `M${x0},${y0} L${midX},${y0} L${midX},${y1} L${x1},${y1}`;
32547
- }
32548
- const midY = (y0 + y1) / 2;
32549
- return `M${x0},${y0} L${x0},${midY} L${x1},${midY} L${x1},${y1}`;
32550
- }
32551
- function curvePath(x0, y0, x1, y1, centre) {
32552
- const midX = (x0 + x1) / 2;
32553
- const midY = (y0 + y1) / 2;
32554
- const pull = 1 + 30 / Math.max(1, Math.hypot(midX - centre.x, midY - centre.y));
32555
- const controlX = centre.x + (midX - centre.x) * pull;
32556
- const controlY = centre.y + (midY - centre.y) * pull;
32557
- return `M${x0},${y0} Q${controlX},${controlY} ${x1},${y1}`;
32558
- }
32559
- function connectorPath(x0, y0, x1, y1, centre, routing, begSty, endSty) {
32560
- const body = routing === "bend" ? elbowPath(x0, y0, x1, y1) : routing === "curve" ? curvePath(x0, y0, x1, y1, centre) : straightPath(x0, y0, x1, y1);
32561
- return body + endHeads(x0, y0, x1, y1, begSty, endSty);
32562
- }
32563
- function connectorEndpoints(from, to, horizontal, dim) {
32564
- const fromCx = from.x + from.width / 2;
32565
- const fromCy = from.y + from.height / 2;
32566
- const toCx = to.x + to.width / 2;
32567
- const toCy = to.y + to.height / 2;
32568
- if (dim === "2D") {
32569
- return { x0: fromCx, y0: fromCy, x1: toCx, y1: toCy };
32570
- }
32571
- if (horizontal) {
32572
- const leftFirst = fromCx <= toCx;
32573
- return leftFirst ? { x0: from.x + from.width, y0: fromCy, x1: to.x, y1: toCy } : { x0: from.x, y0: fromCy, x1: to.x + to.width, y1: toCy };
32574
- }
32575
- const topFirst = fromCy <= toCy;
32576
- return topFirst ? { x0: fromCx, y0: from.y + from.height, x1: toCx, y1: to.y } : { x0: fromCx, y0: from.y, x1: toCx, y1: to.y + to.height };
32577
- }
32578
- var ARROW_WING;
32579
- var ARROW_HEAD;
32580
- var init_smartart_layout_interpreter_conn_path = __esm({
32581
- "src/core/utils/smartart-layout-interpreter-conn-path.ts"() {
32582
- ARROW_WING = 4;
32583
- ARROW_HEAD = 7;
32584
- }
32585
- });
32586
- function resolveConstraintDeclaredBy(index, role, type, declaringRole) {
32587
- const candidates = index.entries.get(entryKey(role, type));
32588
- const fromArranger = candidates?.filter(
32589
- (c) => c.declaringRole === declaringRole
32590
- );
32591
- if (!fromArranger || fromArranger.length === 0) {
32592
- return void 0;
32593
- }
32594
- const visiting = /* @__PURE__ */ new Set([entryKey(role, type)]);
32595
- for (const candidate of fromArranger) {
32596
- const value = resolveEntry(index, candidate, visiting);
32597
- if (value !== void 0) {
32598
- return value;
32599
- }
32600
- }
32601
- return void 0;
32602
- }
32603
- function firstConstraintDeclaredBy(index, role, type, declaringRole) {
32604
- const candidates = index.entries.get(entryKey(role, type));
32605
- return candidates?.find((candidate) => candidate.declaringRole === declaringRole)?.constraint;
32606
- }
32607
- var init_smartart_constraint_declared_by = __esm({
32608
- "src/core/utils/smartart-constraint-declared-by.ts"() {
32609
- init_smartart_constraint_solver();
32610
- }
32611
- });
32612
- function isTransitionOnlyChild(node) {
32613
- const origin = node.forEachOrigin;
32614
- if (!origin) {
32615
- return false;
32616
- }
32617
- if (origin.axis?.includes("followSib") || origin.axis?.includes("follow")) {
32618
- return true;
32619
- }
32620
- const pointTypes = origin.pointTypes;
32621
- return (pointTypes?.length ?? 0) > 0 && (pointTypes?.every((type) => type === "sibTrans" || type === "parTrans") ?? false);
32622
- }
32623
- function isContinuationForEach(node) {
32624
- const forEach = node.forEach ?? [];
32625
- if (forEach.length === 0) {
32626
- return false;
32627
- }
32628
- return forEach.every(
32629
- (each) => each.axis?.length === 1 && each.axis[0] === "ch" && (each.start?.[0] ?? 1) > 1
32630
- );
32631
- }
32632
- function hasStructuralDescendant(node) {
32633
- return (node.children ?? []).some(
32634
- (child262) => STRUCTURAL_ALG_TYPES.has(child262.algorithm?.type ?? "") && !isContinuationForEach(child262) || hasStructuralDescendant(child262)
32635
- );
32636
- }
32637
- function mapsSlots(node) {
32638
- const declaredByArranger = (node.allConstraints ?? node.constraints ?? []).some(
32639
- (constraint) => constraint.for === "ch" && SLOT_CONSTRAINTS.has(constraint.type)
32640
- );
32641
- if (declaredByArranger) {
32642
- return true;
32643
- }
32644
- return (node.children ?? []).some(
32645
- (child262) => (child262.constraints ?? []).some((constraint) => SLOT_CONSTRAINTS.has(constraint.type))
32646
- );
32647
- }
32648
- function itemTemplateNodes(node, out) {
32649
- const drivesPoints = node.forEach?.some(
32650
- (each) => each.axis?.length === 1 && each.axis[0] === "ch" && (!each.pointTypes || each.pointTypes.includes("node"))
32651
- );
32652
- const item = node.children?.[0];
32653
- if (drivesPoints && item) {
32654
- out.add(item);
32655
- }
32656
- for (const child262 of node.children ?? []) {
32657
- itemTemplateNodes(child262, out);
32658
- }
32659
- }
32660
- var SLOT_CONSTRAINTS;
32661
- var STRUCTURAL_ALG_TYPES;
32662
- var init_smartart_layout_interpreter_composite_detect = __esm({
32663
- "src/core/utils/smartart-layout-interpreter-composite-detect.ts"() {
32664
- SLOT_CONSTRAINTS = /* @__PURE__ */ new Set(["l", "t", "w", "h", "ctrX", "ctrY"]);
32665
- STRUCTURAL_ALG_TYPES = /* @__PURE__ */ new Set(["lin", "cycle", "pyra", "snake", "hierRoot", "hierChild"]);
32666
- }
32667
- });
32668
32531
  function children2(node, name, localName28) {
32669
32532
  const key2 = Object.keys(node).find((candidate) => localName28(candidate) === name);
32670
32533
  const value = key2 ? node[key2] : void 0;
@@ -32974,11 +32837,19 @@ function selectRange(nodes, start, count) {
32974
32837
  const take = count !== void 0 && count > 0 ? count : nodes.length - zeroBasedStart;
32975
32838
  return nodes.slice(zeroBasedStart, zeroBasedStart + take);
32976
32839
  }
32840
+ function applyPointTypeAndRange(nodes, pointType2, start, count) {
32841
+ const filtered = pointType2 ? nodes.filter((n) => pointTypeMatches(n, pointType2)) : nodes;
32842
+ return selectRange(filtered, start, count);
32843
+ }
32977
32844
  function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
32978
32845
  if (axis.length === 0) {
32979
32846
  return void 0;
32980
32847
  }
32981
- if (context === void 0 && axis[0] !== "ch" && axis[0] !== "self") {
32848
+ const rootRelative = context === void 0;
32849
+ if (rootRelative && axis[0] !== "ch" && axis[0] !== "self" && axis[0] !== "root") {
32850
+ return void 0;
32851
+ }
32852
+ if (rootRelative && axis[0] === "root" && axis.length > 1 && axis[1] !== "ch") {
32982
32853
  return void 0;
32983
32854
  }
32984
32855
  const byId = new Map(nodes.map((n) => [n.id, n]));
@@ -32997,16 +32868,30 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
32997
32868
  }
32998
32869
  }
32999
32870
  const roots = nodes.filter((n) => !n.parentId || !byId.has(n.parentId));
33000
- let current = context !== void 0 ? navigateAxisHop(context, axis[0], nodes, childrenOf, parentOf, roots) : roots;
33001
- for (let hop = 0; hop < axis.length; hop += 1) {
33002
- if (hop > 0) {
33003
- current = navigateAxisHop(current, axis[hop], nodes, childrenOf, parentOf, roots);
33004
- }
33005
- const pointType2 = pointTypes?.[hop];
33006
- if (pointType2) {
33007
- current = current.filter((n) => pointTypeMatches(n, pointType2));
33008
- }
33009
- current = selectRange(current, start?.[hop], count?.[hop]);
32871
+ let current;
32872
+ let nextHop;
32873
+ if (context !== void 0) {
32874
+ current = applyPointTypeAndRange(
32875
+ navigateAxisHop(context, axis[0], nodes, childrenOf, parentOf, roots),
32876
+ pointTypes?.[0],
32877
+ start?.[0],
32878
+ count?.[0]
32879
+ );
32880
+ nextHop = 1;
32881
+ } else if (axis[0] === "root" && axis.length > 1) {
32882
+ current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count?.[1]);
32883
+ nextHop = 2;
32884
+ } else {
32885
+ current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
32886
+ nextHop = 1;
32887
+ }
32888
+ for (let hop = nextHop; hop < axis.length; hop += 1) {
32889
+ current = applyPointTypeAndRange(
32890
+ navigateAxisHop(current, axis[hop], nodes, childrenOf, parentOf, roots),
32891
+ pointTypes?.[hop],
32892
+ start?.[hop],
32893
+ count?.[hop]
32894
+ );
33010
32895
  }
33011
32896
  return current;
33012
32897
  }
@@ -33201,14 +33086,178 @@ var init_smartart_layout_interpreter_choose_branch = __esm({
33201
33086
  localName6 = (key2) => key2.split(":").pop() ?? key2;
33202
33087
  }
33203
33088
  });
33204
- function boundedCompositeAlg(raw, nodeCount, context) {
33205
- if (!raw) {
33206
- return void 0;
33089
+ function isTransitionOnlyChild(node) {
33090
+ const origin = node.forEachOrigin;
33091
+ if (!origin) {
33092
+ return false;
33207
33093
  }
33208
- let found;
33209
- const visit = (value) => {
33210
- if (found !== void 0 || !value || typeof value !== "object") {
33211
- return;
33094
+ if (origin.axis?.includes("followSib") || origin.axis?.includes("follow")) {
33095
+ return true;
33096
+ }
33097
+ const pointTypes = origin.pointTypes;
33098
+ return (pointTypes?.length ?? 0) > 0 && (pointTypes?.every((type) => type === "sibTrans" || type === "parTrans") ?? false);
33099
+ }
33100
+ function isContinuationForEach(node) {
33101
+ const forEach = node.forEach ?? [];
33102
+ if (forEach.length === 0) {
33103
+ return false;
33104
+ }
33105
+ return forEach.every(
33106
+ (each) => each.axis?.length === 1 && each.axis[0] === "ch" && (each.start?.[0] ?? 1) > 1
33107
+ );
33108
+ }
33109
+ function hasStructuralDescendant(node) {
33110
+ return (node.children ?? []).some(
33111
+ (child262) => STRUCTURAL_ALG_TYPES.has(child262.algorithm?.type ?? "") && !isContinuationForEach(child262) || hasStructuralDescendant(child262)
33112
+ );
33113
+ }
33114
+ function mapsSlots(node) {
33115
+ const declaredByArranger = (node.allConstraints ?? node.constraints ?? []).some(
33116
+ (constraint) => constraint.for === "ch" && SLOT_CONSTRAINTS.has(constraint.type)
33117
+ );
33118
+ if (declaredByArranger) {
33119
+ return true;
33120
+ }
33121
+ return (node.children ?? []).some(
33122
+ (child262) => (child262.constraints ?? []).some((constraint) => SLOT_CONSTRAINTS.has(constraint.type))
33123
+ );
33124
+ }
33125
+ function itemTemplateNodes(node, out) {
33126
+ const drivesPoints = node.forEach?.some(
33127
+ (each) => each.axis?.length === 1 && each.axis[0] === "ch" && (!each.pointTypes || each.pointTypes.includes("node"))
33128
+ );
33129
+ const item = node.children?.[0];
33130
+ if (drivesPoints && item) {
33131
+ out.add(item);
33132
+ }
33133
+ for (const child262 of node.children ?? []) {
33134
+ itemTemplateNodes(child262, out);
33135
+ }
33136
+ }
33137
+ function isLayoutNodeOrDescendantOf(ancestor, node) {
33138
+ if (ancestor === node) {
33139
+ return true;
33140
+ }
33141
+ return (ancestor.children ?? []).some((child262) => isLayoutNodeOrDescendantOf(child262, node));
33142
+ }
33143
+ var SLOT_CONSTRAINTS;
33144
+ var STRUCTURAL_ALG_TYPES;
33145
+ var init_smartart_layout_interpreter_composite_detect = __esm({
33146
+ "src/core/utils/smartart-layout-interpreter-composite-detect.ts"() {
33147
+ SLOT_CONSTRAINTS = /* @__PURE__ */ new Set(["l", "t", "w", "h", "ctrX", "ctrY"]);
33148
+ STRUCTURAL_ALG_TYPES = /* @__PURE__ */ new Set(["lin", "cycle", "pyra", "snake", "hierRoot", "hierChild"]);
33149
+ }
33150
+ });
33151
+ function findStructuralAlgDepth(raw, crossedNames, nodeCount, context) {
33152
+ if (!raw || typeof raw !== "object") {
33153
+ return void 0;
33154
+ }
33155
+ if (Array.isArray(raw)) {
33156
+ for (const item of raw) {
33157
+ const found = findStructuralAlgDepth(item, crossedNames, nodeCount, context);
33158
+ if (found) {
33159
+ return found;
33160
+ }
33161
+ }
33162
+ return void 0;
33163
+ }
33164
+ for (const [key2, entry2] of Object.entries(raw)) {
33165
+ if (key2.startsWith("@_")) {
33166
+ continue;
33167
+ }
33168
+ const name = localName6(key2);
33169
+ if (name === "alg") {
33170
+ for (const candidate of Array.isArray(entry2) ? entry2 : [entry2]) {
33171
+ const type = candidate && typeof candidate === "object" ? String(candidate["@_type"] ?? "") : "";
33172
+ if (STRUCTURAL_CHOOSE_ALG_TYPES.has(type)) {
33173
+ return { depth: crossedNames.length, crossedNames: [...crossedNames] };
33174
+ }
33175
+ }
33176
+ } else if (name === "layoutNode") {
33177
+ for (const candidate of Array.isArray(entry2) ? entry2 : [entry2]) {
33178
+ if (!candidate || typeof candidate !== "object") {
33179
+ continue;
33180
+ }
33181
+ const crossedName = String(candidate["@_name"] ?? "");
33182
+ const found = findStructuralAlgDepth(
33183
+ candidate,
33184
+ [...crossedNames, crossedName],
33185
+ nodeCount,
33186
+ context
33187
+ );
33188
+ if (found) {
33189
+ return found;
33190
+ }
33191
+ }
33192
+ } else if (name === "choose") {
33193
+ for (const candidate of Array.isArray(entry2) ? entry2 : [entry2]) {
33194
+ if (!candidate || typeof candidate !== "object") {
33195
+ continue;
33196
+ }
33197
+ const winningBranch = nestedChooseBranch(candidate, nodeCount, context);
33198
+ if (winningBranch) {
33199
+ const found = findStructuralAlgDepth(winningBranch, crossedNames, nodeCount, context);
33200
+ if (found) {
33201
+ return found;
33202
+ }
33203
+ }
33204
+ }
33205
+ } else if (entry2 && typeof entry2 === "object") {
33206
+ const found = findStructuralAlgDepth(entry2, crossedNames, nodeCount, context);
33207
+ if (found) {
33208
+ return found;
33209
+ }
33210
+ }
33211
+ }
33212
+ return void 0;
33213
+ }
33214
+ function structuralChooseAlgDepth(node, nodeCount, context) {
33215
+ if (!node.choose || node.choose.length === 0) {
33216
+ return void 0;
33217
+ }
33218
+ for (const choose of node.choose) {
33219
+ const branch = activeBranch(choose, nodeCount, context);
33220
+ if (branch === void 0) {
33221
+ continue;
33222
+ }
33223
+ const found = findStructuralAlgDepth(branch, [], nodeCount, context);
33224
+ if (found) {
33225
+ return found;
33226
+ }
33227
+ }
33228
+ return void 0;
33229
+ }
33230
+ function tunnelsPastOwnCompositeSlot(node, nodeCount, context, itemTemplates) {
33231
+ const looksLikeOwnComposite = node.algorithm?.type === "composite" && !itemTemplates.has(node) && !hasStructuralDescendant(node) && mapsSlots(node);
33232
+ if (!looksLikeOwnComposite) {
33233
+ return false;
33234
+ }
33235
+ const found = structuralChooseAlgDepth(node, nodeCount, context);
33236
+ return found !== void 0 && found.depth >= 2;
33237
+ }
33238
+ var STRUCTURAL_CHOOSE_ALG_TYPES;
33239
+ var init_smartart_layout_interpreter_choose_depth = __esm({
33240
+ "src/core/utils/smartart-layout-interpreter-choose-depth.ts"() {
33241
+ init_smartart_layout_interpreter_choose_branch();
33242
+ init_smartart_layout_interpreter_composite_detect();
33243
+ STRUCTURAL_CHOOSE_ALG_TYPES = /* @__PURE__ */ new Set([
33244
+ "lin",
33245
+ "cycle",
33246
+ "pyra",
33247
+ "snake",
33248
+ "hierChild",
33249
+ "hierRoot"
33250
+ ]);
33251
+ }
33252
+ });
33253
+ function boundedCompositeAlg(raw, nodeCount, context) {
33254
+ if (!raw) {
33255
+ return void 0;
33256
+ }
33257
+ let found;
33258
+ const visit = (value) => {
33259
+ if (found !== void 0 || !value || typeof value !== "object") {
33260
+ return;
33212
33261
  }
33213
33262
  if (Array.isArray(value)) {
33214
33263
  value.forEach(visit);
@@ -33434,6 +33483,13 @@ var init_smartart_layout_interpreter_flow = __esm({
33434
33483
  NODE_POINT_TYPES = /* @__PURE__ */ new Set(["node", "norm", "nonNorm", "asst", "nonAsst", "doc", "all"]);
33435
33484
  }
33436
33485
  });
33486
+ function hasPositionGuard(node) {
33487
+ return node.chooseGuard?.some((guard) => guard.function === "pos") ?? false;
33488
+ }
33489
+ var init_smartart_layout_interpreter_position_family = __esm({
33490
+ "src/core/utils/smartart-layout-interpreter-position-family.ts"() {
33491
+ }
33492
+ });
33437
33493
  function walkWithTreeLocation(node, visit, location = { position: 1, total: 1, depth: 0 }) {
33438
33494
  visit(node, location);
33439
33495
  const children12 = node.children ?? [];
@@ -33497,6 +33553,33 @@ var init_smartart_layout_interpreter_constraints = __esm({
33497
33553
  "src/core/utils/smartart-layout-interpreter-constraints.ts"() {
33498
33554
  }
33499
33555
  });
33556
+ function itemNode(arranger) {
33557
+ return arranger.children?.[0];
33558
+ }
33559
+ function algorithmParam(node, type) {
33560
+ return node.algorithm?.parameters?.find((param) => param.type === type)?.value;
33561
+ }
33562
+ function numericParam(node, type, fallback) {
33563
+ const raw = algorithmParam(node, type);
33564
+ if (raw === void 0) {
33565
+ return fallback;
33566
+ }
33567
+ const parsed = Number(raw);
33568
+ return Number.isFinite(parsed) ? parsed : fallback;
33569
+ }
33570
+ function resolveFlowDirection(arranger, presLayoutVars) {
33571
+ const linDir = algorithmParam(arranger, "linDir");
33572
+ const vertical = linDir === "fromT" || linDir === "fromB";
33573
+ let reverse = linDir === "fromR" || linDir === "fromB";
33574
+ if (presLayoutVars?.direction === "rev") {
33575
+ reverse = !reverse;
33576
+ }
33577
+ return { orientation: vertical ? "vertical" : "horizontal", reverse };
33578
+ }
33579
+ var init_smartart_layout_interpreter_flow_direction = __esm({
33580
+ "src/core/utils/smartart-layout-interpreter-flow-direction.ts"() {
33581
+ }
33582
+ });
33500
33583
  function isMeaningfulAux(node) {
33501
33584
  return (node.constraints?.length ?? 0) > 0 || (node.children?.length ?? 0) > 0;
33502
33585
  }
@@ -33509,26 +33592,38 @@ function discoverArrangement(definition, nodeCount, presLayoutVars, flatNodes) {
33509
33592
  const maxDepth = treeMaxDepth(definition.rootNode);
33510
33593
  const itemTemplates = /* @__PURE__ */ new Set();
33511
33594
  itemTemplateNodes(definition.rootNode, itemTemplates);
33595
+ const blockedSubtreeRoots = [];
33512
33596
  walkWithTreeLocation(definition.rootNode, (node, location) => {
33513
- if (!hierarchy && !chosen && nodeCount !== void 0 && node.choose && node.choose.length > 0 && !isContinuationForEach(node)) {
33514
- const resolvedAlg = chooseAlgorithm(node, nodeCount, {
33597
+ if (!hierarchy && !chosen && nodeCount !== void 0 && node.choose && node.choose.length > 0 && !isContinuationForEach(node) && !blockedSubtreeRoots.some((root) => isLayoutNodeOrDescendantOf(root, node))) {
33598
+ const whenContext = {
33515
33599
  presLayoutVars,
33516
33600
  position: location.position,
33517
33601
  total: location.total,
33518
33602
  depth: location.depth,
33519
33603
  maxDepth,
33520
33604
  nodes: flatNodes
33521
- });
33605
+ };
33606
+ const resolvedAlg = chooseAlgorithm(node, nodeCount, whenContext);
33522
33607
  const type2 = resolvedAlg?.type;
33523
33608
  if (type2 === "hierRoot" || type2 === "hierChild") {
33524
33609
  hierarchy = node.children?.find((child262) => child262.algorithm?.type === type2) ?? node;
33525
33610
  } else {
33526
33611
  const withResolvedAlg = resolvedAlg ? { ...node, algorithm: resolvedAlg } : node;
33527
33612
  const kind2 = type2 ? PRIMARY_ALG[type2] : void 0;
33528
- const arranger = node.children?.find(
33613
+ const rawArranger = node.children?.find(
33529
33614
  (child262) => child262.algorithm?.type === type2 && !isTransitionOnlyChild(child262) && !isContinuationForEach(child262)
33530
- ) ?? withResolvedAlg;
33531
- if (kind2 && STRUCTURAL_ARRANGEMENT_KINDS.has(kind2)) {
33615
+ );
33616
+ const arranger = rawArranger && !hasPositionGuard(rawArranger) ? rawArranger : withResolvedAlg;
33617
+ const tunnelledPastOwnSlot = tunnelsPastOwnCompositeSlot(
33618
+ node,
33619
+ nodeCount,
33620
+ whenContext,
33621
+ itemTemplates
33622
+ );
33623
+ if (tunnelledPastOwnSlot) {
33624
+ blockedSubtreeRoots.push(node);
33625
+ }
33626
+ if (kind2 && STRUCTURAL_ARRANGEMENT_KINDS.has(kind2) && !tunnelledPastOwnSlot) {
33532
33627
  chosen = { kind: kind2, node: arranger };
33533
33628
  } else if (kind2 === "composite" && !itemTemplates.has(arranger) && mapsSlots(arranger)) {
33534
33629
  chosen = { kind: kind2, node: arranger };
@@ -33553,101 +33648,400 @@ function discoverArrangement(definition, nodeCount, presLayoutVars, flatNodes) {
33553
33648
  }
33554
33649
  return;
33555
33650
  }
33556
- if (STRUCTURAL_ARRANGEMENT_KINDS.has(kind)) {
33557
- if (!isContinuationForEach(node)) {
33558
- structural ??= { kind, node };
33559
- }
33560
- return;
33651
+ if (STRUCTURAL_ARRANGEMENT_KINDS.has(kind)) {
33652
+ if (!isContinuationForEach(node)) {
33653
+ structural ??= { kind, node };
33654
+ }
33655
+ return;
33656
+ }
33657
+ if (!aux && isMeaningfulAux(node)) {
33658
+ aux = { kind, node };
33659
+ }
33660
+ });
33661
+ if (hierarchy) {
33662
+ return { kind: "hierarchy", node: hierarchy };
33663
+ }
33664
+ if (chosen) {
33665
+ return chosen;
33666
+ }
33667
+ if (compositeSlot) {
33668
+ return { kind: "composite", node: compositeSlot };
33669
+ }
33670
+ return structural ?? aux;
33671
+ }
33672
+ var PRIMARY_ALG;
33673
+ var STRUCTURAL_ARRANGEMENT_KINDS;
33674
+ var init_smartart_layout_interpreter_model = __esm({
33675
+ "src/core/utils/smartart-layout-interpreter-model.ts"() {
33676
+ init_smartart_layout_interpreter_choose_depth();
33677
+ init_smartart_layout_interpreter_composite_detect();
33678
+ init_smartart_layout_interpreter_flow();
33679
+ init_smartart_layout_interpreter_position_family();
33680
+ init_smartart_layout_interpreter_tree_location();
33681
+ init_smartart_layout_interpreter_constraints();
33682
+ init_smartart_layout_interpreter_position_family();
33683
+ init_smartart_layout_interpreter_flow_direction();
33684
+ PRIMARY_ALG = {
33685
+ lin: "linear",
33686
+ cycle: "cycle",
33687
+ pyra: "pyramid",
33688
+ snake: "snake",
33689
+ composite: "composite",
33690
+ conn: "conn",
33691
+ sp: "spacer",
33692
+ tx: "text"
33693
+ };
33694
+ STRUCTURAL_ARRANGEMENT_KINDS = /* @__PURE__ */ new Set([
33695
+ "linear",
33696
+ "cycle",
33697
+ "pyramid",
33698
+ "snake"
33699
+ ]);
33700
+ }
33701
+ });
33702
+ function resolveReferencedRatio(index, role, types, rules) {
33703
+ for (const type of types) {
33704
+ const candidates = index.entries.get(entryKey(role, type));
33705
+ if (!candidates?.some((entry2) => hasReference(entry2.constraint))) {
33706
+ continue;
33707
+ }
33708
+ const resolved = resolveConstraint(index, role, type);
33709
+ if (resolved !== void 0) {
33710
+ return clampByRules(resolved, rules, type);
33711
+ }
33712
+ }
33713
+ return void 0;
33714
+ }
33715
+ function resolveRatioConstraint(constraints, index, role, types, fallback, rules) {
33716
+ const literal = ratioConstraint(constraints, types, Number.NaN, rules);
33717
+ if (!Number.isNaN(literal)) {
33718
+ return literal;
33719
+ }
33720
+ const relative = resolveReferencedRatio(index, role, types, rules);
33721
+ return relative ?? fallback;
33722
+ }
33723
+ var init_smartart_constraint_ratio_fallback = __esm({
33724
+ "src/core/utils/smartart-constraint-ratio-fallback.ts"() {
33725
+ init_smartart_constraint_solver();
33726
+ init_smartart_layout_interpreter_model();
33727
+ }
33728
+ });
33729
+ function resolveHubToNodeRatio(ringItem, arrangerConstraints) {
33730
+ if (!ringItem?.name) {
33731
+ return void 0;
33732
+ }
33733
+ const match = (arrangerConstraints ?? []).find(
33734
+ (c) => c.type === "w" && c.forName === ringItem.name && c.referenceType === "w" && (c.factor === void 0 || typeof c.factor === "number" && c.factor > 0) && typeof c.referenceForName === "string"
33735
+ );
33736
+ if (!match) {
33737
+ return void 0;
33738
+ }
33739
+ return { hubName: match.referenceForName, factor: match.factor ?? 1 };
33740
+ }
33741
+ function resolveHubGapRatio(itemName, hubRatio, arrangerConstraints) {
33742
+ if (!hubRatio) {
33743
+ return void 0;
33744
+ }
33745
+ const sp = (arrangerConstraints ?? []).find(
33746
+ (c) => c.type === "sp" && typeof c.factor === "number" && typeof c.referenceForName === "string"
33747
+ );
33748
+ if (!sp || typeof sp.factor !== "number") {
33749
+ return void 0;
33750
+ }
33751
+ if (sp.referenceForName === itemName) {
33752
+ return sp.factor;
33753
+ }
33754
+ if (sp.referenceForName === hubRatio.hubName) {
33755
+ return sp.factor / hubRatio.factor;
33756
+ }
33757
+ return void 0;
33758
+ }
33759
+ var init_smartart_layout_interpreter_cycle_hub_ratio = __esm({
33760
+ "src/core/utils/smartart-layout-interpreter-cycle-hub-ratio.ts"() {
33761
+ }
33762
+ });
33763
+ function deriveCompositeSelfChildLayout(item) {
33764
+ if (!item || item.algorithm?.type !== "composite") {
33765
+ return void 0;
33766
+ }
33767
+ const constraints = item.allConstraints ?? item.constraints ?? [];
33768
+ for (const width of constraints) {
33769
+ if (width.type !== "w" || width.for !== "ch" || !width.forName || width.referenceForName !== void 0 || typeof width.factor !== "number" || width.factor <= 0) {
33770
+ continue;
33771
+ }
33772
+ const selfName = width.forName;
33773
+ const isSelfSquare = constraints.some(
33774
+ (c) => c.type === "h" && c.for === "ch" && c.forName === selfName && c.referenceType === "w" && c.referenceFor === "ch" && c.referenceForName === selfName
33775
+ );
33776
+ if (!isSelfSquare) {
33777
+ continue;
33778
+ }
33779
+ const childLeft = constraints.find(
33780
+ (c) => c.type === "l" && c.for === "ch" && c.forName !== void 0 && c.forName !== selfName && c.referenceType === "w" && c.referenceFor === "ch" && c.referenceForName === selfName && typeof c.factor === "number"
33781
+ );
33782
+ const childName = childLeft?.forName;
33783
+ const childWidth = childName ? constraints.find(
33784
+ (c) => c.type === "w" && c.for === "ch" && c.forName === childName && c.referenceForName === void 0 && typeof c.factor === "number"
33785
+ ) : void 0;
33786
+ return {
33787
+ selfName,
33788
+ selfWidthFactor: width.factor,
33789
+ childName,
33790
+ childLeftFactor: childLeft?.factor,
33791
+ childWidthFactor: childWidth?.factor
33792
+ };
33793
+ }
33794
+ return void 0;
33795
+ }
33796
+ function resolveGraphAspectRatio(item, index) {
33797
+ if (!item) {
33798
+ return void 0;
33799
+ }
33800
+ const role = roleOf(item);
33801
+ const resolvedH = resolveConstraint(index, role, "h");
33802
+ const resolvedW = resolveConstraint(index, role, "w");
33803
+ if (resolvedH === void 0 || resolvedW === void 0 || resolvedW <= 0) {
33804
+ return void 0;
33805
+ }
33806
+ return resolvedH / resolvedW;
33807
+ }
33808
+ var init_smartart_layout_interpreter_cycle_item_aspect = __esm({
33809
+ "src/core/utils/smartart-layout-interpreter-cycle-item-aspect.ts"() {
33810
+ init_smartart_constraint_solver();
33811
+ }
33812
+ });
33813
+ function absoluteConstraintPoints(constraint) {
33814
+ if (constraint === void 0 || constraint.factor !== void 0 || constraint.referenceType !== void 0 || typeof constraint.value !== "number" || !Number.isFinite(constraint.value) || constraint.value < 1) {
33815
+ return void 0;
33816
+ }
33817
+ return constraint.value;
33818
+ }
33819
+ function resolveCycleConstraintNode(arrangerNode) {
33820
+ if (arrangerNode.name === "cycle") {
33821
+ return arrangerNode;
33822
+ }
33823
+ for (const child262 of arrangerNode.children ?? []) {
33824
+ if (child262.name === "cycle") {
33825
+ return child262;
33826
+ }
33827
+ }
33828
+ return arrangerNode;
33829
+ }
33830
+ function resolveRingItemNode(constraintNode, arrangerConstraints) {
33831
+ const sibSpName = (arrangerConstraints ?? []).find(
33832
+ (c) => c.type === "sibSp" && typeof c.referenceForName === "string"
33833
+ )?.referenceForName;
33834
+ const named = sibSpName ? (constraintNode.children ?? []).find((child262) => child262.name === sibSpName) : void 0;
33835
+ if (named?.forEachOrigin) {
33836
+ return named;
33837
+ }
33838
+ const repeating = (constraintNode.children ?? []).find((child262) => child262.forEachOrigin);
33839
+ return repeating ?? named ?? itemNode(constraintNode);
33840
+ }
33841
+ function resolveCycleRingParams(arrangerNode, index) {
33842
+ const constraintNode = resolveCycleConstraintNode(arrangerNode);
33843
+ const arrangerConstraints = constraintNode.allConstraints ?? constraintNode.constraints;
33844
+ const item = resolveRingItemNode(constraintNode, arrangerConstraints);
33845
+ const itemConstraints = item?.allConstraints ?? item?.constraints;
33846
+ const literalHeightOverWidth = ratioConstraint(
33847
+ itemConstraints ?? [],
33848
+ ["h"],
33849
+ Number.NaN,
33850
+ item?.rules
33851
+ );
33852
+ const contentLayout = deriveCompositeSelfChildLayout(item);
33853
+ const heightOverWidth = !Number.isNaN(literalHeightOverWidth) ? literalHeightOverWidth : resolveGraphAspectRatio(item, index) ?? resolveRatioConstraint(itemConstraints, index, roleOf(item), ["h"], 1, item?.rules);
33854
+ const hubRatio = resolveHubToNodeRatio(item, arrangerConstraints);
33855
+ const hubGapRatio = resolveHubGapRatio(item?.name, hubRatio, arrangerConstraints);
33856
+ const absoluteHubGap = absoluteConstraintPoints(findConstraint(arrangerConstraints, "sp"));
33857
+ const absolutePoints = absoluteConstraintPoints(findConstraint(arrangerConstraints, "sibSp"));
33858
+ if (absolutePoints !== void 0) {
33859
+ return {
33860
+ minGapRatio: DEFAULT_MIN_GAP_RATIO,
33861
+ heightOverWidth,
33862
+ absoluteGapPx: absolutePoints * POINTS_TO_PIXELS,
33863
+ hubRatio,
33864
+ hubGapRatio,
33865
+ absoluteHubGapPx: absoluteHubGap !== void 0 ? absoluteHubGap * POINTS_TO_PIXELS : void 0,
33866
+ contentLayout
33867
+ };
33868
+ }
33869
+ const minGapRatio = resolveRatioConstraint(
33870
+ arrangerConstraints,
33871
+ index,
33872
+ roleOf(constraintNode),
33873
+ ["sibSp"],
33874
+ DEFAULT_MIN_GAP_RATIO,
33875
+ constraintNode.rules
33876
+ );
33877
+ return {
33878
+ minGapRatio: Math.max(DEFAULT_MIN_GAP_RATIO, minGapRatio),
33879
+ heightOverWidth,
33880
+ hubRatio,
33881
+ absoluteHubGapPx: absoluteHubGap !== void 0 ? absoluteHubGap * POINTS_TO_PIXELS : void 0,
33882
+ contentLayout,
33883
+ hubGapRatio
33884
+ };
33885
+ }
33886
+ var POINTS_TO_PIXELS;
33887
+ var DEFAULT_MIN_GAP_RATIO;
33888
+ var init_smartart_layout_interpreter_cycle_constraints = __esm({
33889
+ "src/core/utils/smartart-layout-interpreter-cycle-constraints.ts"() {
33890
+ init_smartart_constraint_ratio_fallback();
33891
+ init_smartart_constraint_solver();
33892
+ init_smartart_layout_interpreter_constraints();
33893
+ init_smartart_layout_interpreter_cycle_hub_ratio();
33894
+ init_smartart_layout_interpreter_cycle_item_aspect();
33895
+ init_smartart_layout_interpreter_model();
33896
+ init_smartart_layout_interpreter_cycle_hub_ratio();
33897
+ POINTS_TO_PIXELS = 96 / 72;
33898
+ DEFAULT_MIN_GAP_RATIO = 0.5;
33899
+ }
33900
+ });
33901
+ function repositionCycleRingContent(result, contentLayout, flatNodes) {
33902
+ if (!contentLayout?.childName || contentLayout.childLeftFactor === void 0 || contentLayout.childWidthFactor === void 0 || contentLayout.selfWidthFactor <= 0) {
33903
+ return result;
33904
+ }
33905
+ const { selfName, childName, childLeftFactor, childWidthFactor, selfWidthFactor } = contentLayout;
33906
+ const parentIdById = new Map(flatNodes.map((node) => [node.id, node.parentId]));
33907
+ const selfByNodeId = /* @__PURE__ */ new Map();
33908
+ for (const node of result.nodes) {
33909
+ if (node.kind === "circle" && node.itemRoleName === selfName && node.nodeId) {
33910
+ selfByNodeId.set(node.nodeId, node);
33911
+ }
33912
+ }
33913
+ const nodes = result.nodes.map((rendered) => {
33914
+ if (rendered.kind !== "circle" || rendered.itemRoleName !== childName || !rendered.nodeId) {
33915
+ return rendered;
33561
33916
  }
33562
- if (!aux && isMeaningfulAux(node)) {
33563
- aux = { kind, node };
33917
+ const parentId = parentIdById.get(rendered.nodeId);
33918
+ const self = parentId ? selfByNodeId.get(parentId) : void 0;
33919
+ if (!self) {
33920
+ return rendered;
33564
33921
  }
33922
+ const selfW = 2 * (self.rx ?? self.r);
33923
+ const selfH = 2 * (self.ry ?? self.r);
33924
+ const selfLeft = self.cx - selfW / 2;
33925
+ const childW = childWidthFactor / selfWidthFactor * selfW;
33926
+ const childLeft = selfLeft + childLeftFactor * selfW;
33927
+ const cx = childLeft + childW / 2;
33928
+ const cy = self.cy;
33929
+ return {
33930
+ ...rendered,
33931
+ cx,
33932
+ cy,
33933
+ r: Math.min(childW, selfH) / 2,
33934
+ rx: childW / 2,
33935
+ ry: selfH / 2,
33936
+ textX: cx,
33937
+ textY: cy
33938
+ };
33565
33939
  });
33566
- if (hierarchy) {
33567
- return { kind: "hierarchy", node: hierarchy };
33940
+ return { ...result, nodes };
33941
+ }
33942
+ var init_smartart_layout_interpreter_cycle_ring_item = __esm({
33943
+ "src/core/utils/smartart-layout-interpreter-cycle-ring-item.ts"() {
33568
33944
  }
33569
- if (chosen) {
33570
- return chosen;
33945
+ });
33946
+ function arrowHeadPath(tipX, tipY, ux, uy) {
33947
+ const bx = tipX - ux * ARROW_HEAD;
33948
+ const by = tipY - uy * ARROW_HEAD;
33949
+ const px3 = -uy;
33950
+ const py = ux;
33951
+ const w1x = bx + px3 * ARROW_WING;
33952
+ const w1y = by + py * ARROW_WING;
33953
+ const w2x = bx - px3 * ARROW_WING;
33954
+ const w2y = by - py * ARROW_WING;
33955
+ return ` M${w1x},${w1y} L${tipX},${tipY} L${w2x},${w2y}`;
33956
+ }
33957
+ function endHeads(x0, y0, x1, y1, begSty, endSty) {
33958
+ const dx = x1 - x0;
33959
+ const dy = y1 - y0;
33960
+ const len = Math.hypot(dx, dy);
33961
+ if (len < 1e-6) {
33962
+ return "";
33571
33963
  }
33572
- if (compositeSlot) {
33573
- return { kind: "composite", node: compositeSlot };
33964
+ const ux = dx / len;
33965
+ const uy = dy / len;
33966
+ let heads = "";
33967
+ if (endSty === "arr") {
33968
+ heads += arrowHeadPath(x1, y1, ux, uy);
33574
33969
  }
33575
- return structural ?? aux;
33576
- }
33577
- function itemNode(arranger) {
33578
- return arranger.children?.[0];
33970
+ if (begSty === "arr") {
33971
+ heads += arrowHeadPath(x0, y0, -ux, -uy);
33972
+ }
33973
+ return heads;
33579
33974
  }
33580
- function algorithmParam(node, type) {
33581
- return node.algorithm?.parameters?.find((param) => param.type === type)?.value;
33975
+ function straightPath(x0, y0, x1, y1) {
33976
+ return `M${x0},${y0} L${x1},${y1}`;
33582
33977
  }
33583
- function numericParam(node, type, fallback) {
33584
- const raw = algorithmParam(node, type);
33585
- if (raw === void 0) {
33586
- return fallback;
33978
+ function elbowPath(x0, y0, x1, y1) {
33979
+ if (Math.abs(x1 - x0) >= Math.abs(y1 - y0)) {
33980
+ const midX = (x0 + x1) / 2;
33981
+ return `M${x0},${y0} L${midX},${y0} L${midX},${y1} L${x1},${y1}`;
33587
33982
  }
33588
- const parsed = Number(raw);
33589
- return Number.isFinite(parsed) ? parsed : fallback;
33983
+ const midY = (y0 + y1) / 2;
33984
+ return `M${x0},${y0} L${x0},${midY} L${x1},${midY} L${x1},${y1}`;
33590
33985
  }
33591
- function resolveFlowDirection(arranger, presLayoutVars) {
33592
- const linDir = algorithmParam(arranger, "linDir");
33593
- const vertical = linDir === "fromT" || linDir === "fromB";
33594
- let reverse = linDir === "fromR" || linDir === "fromB";
33595
- if (presLayoutVars?.direction === "rev") {
33596
- reverse = !reverse;
33986
+ function curvePath(x0, y0, x1, y1, centre) {
33987
+ const midX = (x0 + x1) / 2;
33988
+ const midY = (y0 + y1) / 2;
33989
+ const pull = 1 + 30 / Math.max(1, Math.hypot(midX - centre.x, midY - centre.y));
33990
+ const controlX = centre.x + (midX - centre.x) * pull;
33991
+ const controlY = centre.y + (midY - centre.y) * pull;
33992
+ return `M${x0},${y0} Q${controlX},${controlY} ${x1},${y1}`;
33993
+ }
33994
+ function connectorPath(x0, y0, x1, y1, centre, routing, begSty, endSty) {
33995
+ const body = routing === "bend" ? elbowPath(x0, y0, x1, y1) : routing === "curve" ? curvePath(x0, y0, x1, y1, centre) : straightPath(x0, y0, x1, y1);
33996
+ return body + endHeads(x0, y0, x1, y1, begSty, endSty);
33997
+ }
33998
+ function connectorEndpoints(from, to, horizontal, dim) {
33999
+ const fromCx = from.x + from.width / 2;
34000
+ const fromCy = from.y + from.height / 2;
34001
+ const toCx = to.x + to.width / 2;
34002
+ const toCy = to.y + to.height / 2;
34003
+ if (dim === "2D") {
34004
+ return { x0: fromCx, y0: fromCy, x1: toCx, y1: toCy };
33597
34005
  }
33598
- return { orientation: vertical ? "vertical" : "horizontal", reverse };
34006
+ if (horizontal) {
34007
+ const leftFirst = fromCx <= toCx;
34008
+ return leftFirst ? { x0: from.x + from.width, y0: fromCy, x1: to.x, y1: toCy } : { x0: from.x, y0: fromCy, x1: to.x + to.width, y1: toCy };
34009
+ }
34010
+ const topFirst = fromCy <= toCy;
34011
+ return topFirst ? { x0: fromCx, y0: from.y + from.height, x1: toCx, y1: to.y } : { x0: fromCx, y0: from.y, x1: toCx, y1: to.y + to.height };
33599
34012
  }
33600
- var PRIMARY_ALG;
33601
- var STRUCTURAL_ARRANGEMENT_KINDS;
33602
- var init_smartart_layout_interpreter_model = __esm({
33603
- "src/core/utils/smartart-layout-interpreter-model.ts"() {
33604
- init_smartart_layout_interpreter_composite_detect();
33605
- init_smartart_layout_interpreter_flow();
33606
- init_smartart_layout_interpreter_tree_location();
33607
- init_smartart_layout_interpreter_constraints();
33608
- PRIMARY_ALG = {
33609
- lin: "linear",
33610
- cycle: "cycle",
33611
- pyra: "pyramid",
33612
- snake: "snake",
33613
- composite: "composite",
33614
- conn: "conn",
33615
- sp: "spacer",
33616
- tx: "text"
33617
- };
33618
- STRUCTURAL_ARRANGEMENT_KINDS = /* @__PURE__ */ new Set([
33619
- "linear",
33620
- "cycle",
33621
- "pyramid",
33622
- "snake"
33623
- ]);
34013
+ var ARROW_WING;
34014
+ var ARROW_HEAD;
34015
+ var init_smartart_layout_interpreter_conn_path = __esm({
34016
+ "src/core/utils/smartart-layout-interpreter-conn-path.ts"() {
34017
+ ARROW_WING = 4;
34018
+ ARROW_HEAD = 7;
33624
34019
  }
33625
34020
  });
33626
- function resolveReferencedRatio(index, role, types, rules) {
33627
- for (const type of types) {
33628
- const candidates = index.entries.get(entryKey(role, type));
33629
- if (!candidates?.some((entry2) => hasReference(entry2.constraint))) {
33630
- continue;
33631
- }
33632
- const resolved = resolveConstraint(index, role, type);
33633
- if (resolved !== void 0) {
33634
- return clampByRules(resolved, rules, type);
34021
+ function resolveConstraintDeclaredBy(index, role, type, declaringRole) {
34022
+ const candidates = index.entries.get(entryKey(role, type));
34023
+ const fromArranger = candidates?.filter(
34024
+ (c) => c.declaringRole === declaringRole
34025
+ );
34026
+ if (!fromArranger || fromArranger.length === 0) {
34027
+ return void 0;
34028
+ }
34029
+ const visiting = /* @__PURE__ */ new Set([entryKey(role, type)]);
34030
+ for (const candidate of fromArranger) {
34031
+ const value = resolveEntry(index, candidate, visiting);
34032
+ if (value !== void 0) {
34033
+ return value;
33635
34034
  }
33636
34035
  }
33637
34036
  return void 0;
33638
34037
  }
33639
- function resolveRatioConstraint(constraints, index, role, types, fallback, rules) {
33640
- const literal = ratioConstraint(constraints, types, Number.NaN, rules);
33641
- if (!Number.isNaN(literal)) {
33642
- return literal;
33643
- }
33644
- const relative = resolveReferencedRatio(index, role, types, rules);
33645
- return relative ?? fallback;
34038
+ function firstConstraintDeclaredBy(index, role, type, declaringRole) {
34039
+ const candidates = index.entries.get(entryKey(role, type));
34040
+ return candidates?.find((candidate) => candidate.declaringRole === declaringRole)?.constraint;
33646
34041
  }
33647
- var init_smartart_constraint_ratio_fallback = __esm({
33648
- "src/core/utils/smartart-constraint-ratio-fallback.ts"() {
34042
+ var init_smartart_constraint_declared_by = __esm({
34043
+ "src/core/utils/smartart-constraint-declared-by.ts"() {
33649
34044
  init_smartart_constraint_solver();
33650
- init_smartart_layout_interpreter_model();
33651
34045
  }
33652
34046
  });
33653
34047
  var INSET;
@@ -33932,7 +34326,7 @@ function presetCornerRadiusFraction(shape) {
33932
34326
  }
33933
34327
  const raw = shape?.adjustments?.find((adjustment) => adjustment.index === 1)?.value;
33934
34328
  if (raw === void 0) {
33935
- return 0.15;
34329
+ return DEFAULT_ROUND_RECT_ADJ_FRACTION;
33936
34330
  }
33937
34331
  return raw > 1 ? raw / 1e5 : raw;
33938
34332
  }
@@ -33946,6 +34340,7 @@ function roundRectCornerInsetPx(shape, widthPx, heightPx) {
33946
34340
  var CIRCLE_PRESETS;
33947
34341
  var POLYGON_PRESETS;
33948
34342
  var ROUND_RECT_PRESETS;
34343
+ var DEFAULT_ROUND_RECT_ADJ_FRACTION;
33949
34344
  var CORNER_ARC_INSET_FACTOR;
33950
34345
  var init_smartart_layout_shape_preset = __esm({
33951
34346
  "src/core/utils/smartart-layout-shape-preset.ts"() {
@@ -33973,6 +34368,7 @@ var init_smartart_layout_shape_preset = __esm({
33973
34368
  "snip2DiagRect",
33974
34369
  "snipRoundRect"
33975
34370
  ]);
34371
+ DEFAULT_ROUND_RECT_ADJ_FRACTION = 16667 / 1e5;
33976
34372
  CORNER_ARC_INSET_FACTOR = 1 - Math.SQRT2 / 2;
33977
34373
  }
33978
34374
  });
@@ -34989,9 +35385,9 @@ function nodeFontBounds(fontRoleCandidate, arranger, index) {
34989
35385
  const fontRoleNode = findFontRoleNode(fontRoleCandidate) ?? fontRoleCandidate;
34990
35386
  const role = fontRoleNode ? roleOf(fontRoleNode) : roleOf(arranger);
34991
35387
  const declared = resolveConstraint(index, role, "primFontSz");
34992
- const ceilingPx = typeof declared === "number" && declared > 0 ? declared * POINTS_TO_PIXELS : DEFAULT_CEILING_PX;
35388
+ const ceilingPx = typeof declared === "number" && declared > 0 ? declared * POINTS_TO_PIXELS2 : DEFAULT_CEILING_PX;
34993
35389
  const floorRuleValues = primFontSzFloorRuleValues(fontRoleNode, arranger, role);
34994
- const floorPx = floorRuleValues.length > 0 ? Math.min(...floorRuleValues) * POINTS_TO_PIXELS : DEFAULT_FLOOR_PX;
35390
+ const floorPx = floorRuleValues.length > 0 ? Math.min(...floorRuleValues) * POINTS_TO_PIXELS2 : DEFAULT_FLOOR_PX;
34995
35391
  return { ceilingPx, floorPx: Math.min(floorPx, ceilingPx), role };
34996
35392
  }
34997
35393
  function itemFontBoundsPx(plan, index) {
@@ -35000,7 +35396,7 @@ function itemFontBoundsPx(plan, index) {
35000
35396
  function primFontSzCeilingPx(plan, index) {
35001
35397
  return itemFontBoundsPx(plan, index).ceilingPx;
35002
35398
  }
35003
- var POINTS_TO_PIXELS;
35399
+ var POINTS_TO_PIXELS2;
35004
35400
  var DEFAULT_CEILING_PX;
35005
35401
  var DEFAULT_FLOOR_PX;
35006
35402
  var DECORATIVE_FONT_ALGORITHM_TYPES;
@@ -35008,7 +35404,7 @@ var init_smartart_layout_item_font_role = __esm({
35008
35404
  "src/core/utils/smartart-layout-item-font-role.ts"() {
35009
35405
  init_smartart_constraint_solver();
35010
35406
  init_smartart_layout_interpreter_model();
35011
- POINTS_TO_PIXELS = 96 / 72;
35407
+ POINTS_TO_PIXELS2 = 96 / 72;
35012
35408
  DEFAULT_CEILING_PX = 12;
35013
35409
  DEFAULT_FLOOR_PX = 6;
35014
35410
  DECORATIVE_FONT_ALGORITHM_TYPES = /* @__PURE__ */ new Set(["sp", "composite", "conn"]);
@@ -35024,12 +35420,13 @@ function measureTextWidth(text22, fontSize, table) {
35024
35420
  }
35025
35421
  return widthPx;
35026
35422
  }
35027
- function wrappedLineCount(text22, maxWidth, fontSize, table) {
35423
+ function greedyWrap(text22, maxWidth, fontSize, table) {
35028
35424
  if (maxWidth <= 0) {
35029
- return Number.POSITIVE_INFINITY;
35425
+ return { lines: Number.POSITIVE_INFINITY, widestLineWidth: 0 };
35030
35426
  }
35031
35427
  const spaceWidth = measureTextWidth(" ", fontSize, table);
35032
35428
  let lines = 0;
35429
+ let widestLineWidth = 0;
35033
35430
  for (const paragraph of text22.split("\n")) {
35034
35431
  const words = paragraph.split(/\s+/u).filter((word) => word.length > 0);
35035
35432
  if (words.length === 0) {
@@ -35042,15 +35439,23 @@ function wrappedLineCount(text22, maxWidth, fontSize, table) {
35042
35439
  const wordWidth = measureTextWidth(word, fontSize, table);
35043
35440
  const extended = lineWidth === 0 ? wordWidth : lineWidth + spaceWidth + wordWidth;
35044
35441
  if (extended > maxWidth && lineWidth > 0) {
35442
+ widestLineWidth = Math.max(widestLineWidth, lineWidth);
35045
35443
  paragraphLines += 1;
35046
35444
  lineWidth = wordWidth;
35047
35445
  } else {
35048
35446
  lineWidth = extended;
35049
35447
  }
35050
35448
  }
35449
+ widestLineWidth = Math.max(widestLineWidth, lineWidth);
35051
35450
  lines += paragraphLines;
35052
35451
  }
35053
- return Math.max(1, lines);
35452
+ return { lines: Math.max(1, lines), widestLineWidth };
35453
+ }
35454
+ function wrappedLineCount(text22, maxWidth, fontSize, table) {
35455
+ return greedyWrap(text22, maxWidth, fontSize, table).lines;
35456
+ }
35457
+ function wrappedWidestLineWidth(text22, maxWidth, fontSize, table) {
35458
+ return greedyWrap(text22, maxWidth, fontSize, table).widestLineWidth;
35054
35459
  }
35055
35460
  function fitsAt(text22, maxWidth, maxHeight, size, table, lineSpacingFactor) {
35056
35461
  return wrappedLineCount(text22, maxWidth, size, table) * size * table.lineHeightRatio * lineSpacingFactor <= maxHeight;
@@ -35101,8 +35506,8 @@ function itemMarginsPx(index, role, table) {
35101
35506
  const topPt = typeof top === "number" ? top : table.marginTopPt;
35102
35507
  const bottomPt = typeof bottom === "number" ? bottom : table.marginBottomPt;
35103
35508
  return {
35104
- horizontal: (leftPt + rightPt) * POINTS_TO_PIXELS2,
35105
- vertical: (topPt + bottomPt) * POINTS_TO_PIXELS2
35509
+ horizontal: (leftPt + rightPt) * POINTS_TO_PIXELS3,
35510
+ vertical: (topPt + bottomPt) * POINTS_TO_PIXELS3
35106
35511
  };
35107
35512
  }
35108
35513
  function proportionalMarginFraction(index, role) {
@@ -35120,7 +35525,7 @@ function proportionalMarginFraction(index, role) {
35120
35525
  return { horizontal: (left ?? 0) + (right ?? 0), vertical: (top ?? 0) + (bottom ?? 0) };
35121
35526
  }
35122
35527
  function snapToWholePoint(sizePx2) {
35123
- return Math.round(sizePx2 / POINTS_TO_PIXELS2) * POINTS_TO_PIXELS2;
35528
+ return Math.round(sizePx2 / POINTS_TO_PIXELS3) * POINTS_TO_PIXELS3;
35124
35529
  }
35125
35530
  function resolveRoleFontSize(roleNode, index, items, fontName) {
35126
35531
  return fitSharedFontSize(
@@ -35175,7 +35580,7 @@ function fitSharedFontSize(bounds, index, items, fontName, naturalAspect) {
35175
35580
  }
35176
35581
  return snapToWholePoint(shared);
35177
35582
  }
35178
- var POINTS_TO_PIXELS2;
35583
+ var POINTS_TO_PIXELS3;
35179
35584
  var init_smartart_layout_item_font_size = __esm({
35180
35585
  "src/core/utils/smartart-layout-item-font-size.ts"() {
35181
35586
  init_font_advance_widths_generated();
@@ -35183,15 +35588,31 @@ var init_smartart_layout_item_font_size = __esm({
35183
35588
  init_smartart_layout_item_font_role();
35184
35589
  init_smartart_text_wrap_fit();
35185
35590
  init_smartart_layout_item_font_role();
35186
- POINTS_TO_PIXELS2 = 96 / 72;
35591
+ POINTS_TO_PIXELS3 = 96 / 72;
35187
35592
  }
35188
35593
  });
35594
+ function extrapolatedIndentPt(descendantSizePt) {
35595
+ const last = DESCENDANT_INDENT_STEPS_PT[DESCENDANT_INDENT_STEPS_PT.length - 1];
35596
+ const tiersBeyond = Math.floor((descendantSizePt - last.maxSz - 1) / 13) + 1;
35597
+ return last.indentPt + tiersBeyond * 4.5;
35598
+ }
35599
+ function descendantIndentPt(descendantSizePt) {
35600
+ for (const step of DESCENDANT_INDENT_STEPS_PT) {
35601
+ if (descendantSizePt <= step.maxSz) {
35602
+ return step.indentPt;
35603
+ }
35604
+ }
35605
+ return extrapolatedIndentPt(descendantSizePt);
35606
+ }
35189
35607
  function paragraphBlockPx(lines, sizePx2, ratio, lineSpacingFactor, spcAftFactor, isLastParagraph) {
35190
35608
  const content = lines * sizePx2 * ratio * lineSpacingFactor;
35191
35609
  return isLastParagraph ? content : content + spcAftFactor * sizePx2 * ratio;
35192
35610
  }
35193
35611
  function itemFits(item, availWidthPx, availHeightPx, rootPx, descendantPx, table, lineSpacingFactor) {
35194
35612
  const hasDescendants = item.descendantTexts.length > 0;
35613
+ if (wrappedWidestLineWidth(item.rootText, availWidthPx, rootPx, table) > availWidthPx) {
35614
+ return false;
35615
+ }
35195
35616
  const rootLines = wrappedLineCount(item.rootText, availWidthPx, rootPx, table);
35196
35617
  let totalPx = paragraphBlockPx(
35197
35618
  rootLines,
@@ -35201,9 +35622,15 @@ function itemFits(item, availWidthPx, availHeightPx, rootPx, descendantPx, table
35201
35622
  ROOT_SPCAFT_FACTOR,
35202
35623
  !hasDescendants
35203
35624
  );
35625
+ const descendantIndentPx = descendantIndentPt(descendantPx / PX_PER_PT) * PX_PER_PT;
35626
+ const descendantWidthPx = Math.max(1, availWidthPx - descendantIndentPx);
35204
35627
  for (let i2 = 0; i2 < item.descendantTexts.length; i2++) {
35205
35628
  const isLast = i2 === item.descendantTexts.length - 1;
35206
- const lines = wrappedLineCount(item.descendantTexts[i2], availWidthPx, descendantPx, table);
35629
+ const text22 = item.descendantTexts[i2];
35630
+ if (wrappedWidestLineWidth(text22, descendantWidthPx, descendantPx, table) > descendantWidthPx) {
35631
+ return false;
35632
+ }
35633
+ const lines = wrappedLineCount(text22, descendantWidthPx, descendantPx, table);
35207
35634
  totalPx += paragraphBlockPx(
35208
35635
  lines,
35209
35636
  descendantPx,
@@ -35217,11 +35644,21 @@ function itemFits(item, availWidthPx, availHeightPx, rootPx, descendantPx, table
35217
35644
  }
35218
35645
  var ROOT_SPCAFT_FACTOR;
35219
35646
  var DESCENDANT_SPCAFT_FACTOR;
35647
+ var PX_PER_PT;
35648
+ var DESCENDANT_INDENT_STEPS_PT;
35220
35649
  var init_smartart_layout_item_font_tier_fit = __esm({
35221
35650
  "src/core/utils/smartart-layout-item-font-tier-fit.ts"() {
35222
35651
  init_smartart_text_wrap_fit();
35223
35652
  ROOT_SPCAFT_FACTOR = 0.35;
35224
35653
  DESCENDANT_SPCAFT_FACTOR = 0.15;
35654
+ PX_PER_PT = 96 / 72;
35655
+ DESCENDANT_INDENT_STEPS_PT = [
35656
+ { maxSz: 11, indentPt: 4.5 },
35657
+ { maxSz: 15, indentPt: 9 },
35658
+ { maxSz: 19, indentPt: 13.5 },
35659
+ { maxSz: 27, indentPt: 18 },
35660
+ { maxSz: 40, indentPt: 22.5 }
35661
+ ];
35225
35662
  }
35226
35663
  });
35227
35664
  function resolveTieredItemFontSize(plan, index, items, fontName, naturalAspect, cornerInsetPx = 0) {
@@ -35232,7 +35669,7 @@ function resolveTieredItemFontSize(plan, index, items, fontName, naturalAspect,
35232
35669
  const table = resolveFontTable(fontName);
35233
35670
  const fixedMargins = itemMarginsPx(index, role, table);
35234
35671
  const proportional = proportionalMarginFraction(index, role);
35235
- const lineSpacingFactor = typeof naturalAspect === "number" ? 1 : SMARTART_LINE_SPACING_FACTOR;
35672
+ const lineSpacingFactor = SMARTART_LINE_SPACING_FACTOR;
35236
35673
  const fitsAtMarginBasis = (rootPx2, marginBasisPx) => {
35237
35674
  const margins = proportional ? {
35238
35675
  horizontal: proportional.horizontal * marginBasisPx,
@@ -35241,8 +35678,7 @@ function resolveTieredItemFontSize(plan, index, items, fontName, naturalAspect,
35241
35678
  for (const item of items) {
35242
35679
  const naturalHeight = typeof naturalAspect === "number" ? Math.min(item.height, item.width * naturalAspect) : item.height;
35243
35680
  const availWidthPx = Math.max(1, item.width - margins.horizontal - 2 * cornerInsetPx);
35244
- const hasDescendants = item.descendantTexts.length > 0;
35245
- const verticalReduction = hasDescendants || cornerInsetPx === 0 ? margins.vertical + cornerInsetPx : 2 * cornerInsetPx;
35681
+ const verticalReduction = margins.vertical + 2 * cornerInsetPx;
35246
35682
  const availHeightPx = Math.max(1, naturalHeight - verticalReduction);
35247
35683
  const descendantPx = rootPx2 * SMARTART_DESCENDANT_FONT_SCALE;
35248
35684
  const fits = itemFits(
@@ -35293,12 +35729,12 @@ function resolveTieredItemFontSize(plan, index, items, fontName, naturalAspect,
35293
35729
  }
35294
35730
  const rounded = snapToWholePoint(rootPx);
35295
35731
  const roundedUp = rounded > rootPx;
35296
- const rootSizePx = roundedUp && !fitsAtMarginBasis(rounded, rootPx) ? Math.floor(rootPx / PX_PER_PT) * PX_PER_PT : rounded;
35732
+ const rootSizePx = roundedUp && !fitsAtMarginBasis(rounded, rootPx) ? Math.floor(rootPx / PX_PER_PT2) * PX_PER_PT2 : rounded;
35297
35733
  const descendantSizePx = snapToWholePoint(rootSizePx * SMARTART_DESCENDANT_FONT_SCALE);
35298
35734
  return { rootSizePx, descendantSizePx };
35299
35735
  }
35300
35736
  var SMARTART_DESCENDANT_FONT_SCALE;
35301
- var PX_PER_PT;
35737
+ var PX_PER_PT2;
35302
35738
  var init_smartart_layout_item_font_tier = __esm({
35303
35739
  "src/core/utils/smartart-layout-item-font-tier.ts"() {
35304
35740
  init_smartart_layout_item_font_role();
@@ -35306,7 +35742,7 @@ var init_smartart_layout_item_font_tier = __esm({
35306
35742
  init_smartart_layout_item_font_tier_fit();
35307
35743
  init_smartart_text_wrap_fit();
35308
35744
  SMARTART_DESCENDANT_FONT_SCALE = 0.78;
35309
- PX_PER_PT = 96 / 72;
35745
+ PX_PER_PT2 = 96 / 72;
35310
35746
  }
35311
35747
  });
35312
35748
  function snakeGridDims(plan, n, w, h2, flowDir) {
@@ -35542,14 +35978,17 @@ function arrangeLinear(plan, flow, nodes, box, palette, style, elementId, index
35542
35978
  n,
35543
35979
  clampRatio
35544
35980
  );
35545
- const crossExtent = aspect ? Math.min(usableCross, Math.max(12, mainExtent * aspect)) : usableCross;
35546
- const crossPos = INSET + (usableCross - crossExtent) / 2;
35547
- const start = INSET + begPad * mainExtent;
35548
35981
  const itemTemplate = itemNode(plan.node);
35549
35982
  const itemShape = findCompositeItemShape(itemTemplate);
35983
+ const naturalAspect = resolveItemSelfAspect(itemTemplate);
35984
+ const crossExtent = aspect ? Math.min(usableCross, Math.max(12, mainExtent * aspect)) : typeof naturalAspect === "number" ? Math.min(
35985
+ usableCross,
35986
+ Math.max(12, mainExtent * (horizontal ? naturalAspect : 1 / naturalAspect))
35987
+ ) : usableCross;
35988
+ const crossPos = INSET + (usableCross - crossExtent) / 2;
35989
+ const start = INSET + begPad * mainExtent;
35550
35990
  const itemW = horizontal ? mainExtent : crossExtent;
35551
35991
  const itemH = horizontal ? crossExtent : mainExtent;
35552
- const naturalAspect = resolveItemSelfAspect(itemTemplate);
35553
35992
  const renderedIds = new Set(flow2.map((node) => node.id));
35554
35993
  const descendantTextsFor = (node) => childrenOf ? foldedDescendantTexts(node, renderedIds, childrenOf) : [];
35555
35994
  const naturalHeightForInset = typeof naturalAspect === "number" ? Math.min(itemH, itemW * naturalAspect) : itemH;
@@ -35933,50 +36372,70 @@ var init_smartart_layout_interpreter_composite_children = __esm({
35933
36372
  init_smartart_node_tree_axis();
35934
36373
  }
35935
36374
  });
36375
+ function resolveOrigin(node, flat) {
36376
+ const origin = node.forEachOrigin;
36377
+ if (!origin?.axis || origin.axis.length === 0) {
36378
+ return [];
36379
+ }
36380
+ return resolveAxisNodes(flat, origin.axis, origin.pointTypes, origin.start, origin.count) ?? [];
36381
+ }
35936
36382
  function resolveAnchoredContent(node, flat) {
35937
36383
  const presOf = node.presentationOf;
35938
36384
  if (!presOf?.axis || presOf.axis.length === 0) {
35939
36385
  return [];
35940
36386
  }
35941
- const origin = node.forEachOrigin;
35942
- if (!origin?.axis || origin.axis.length === 0) {
36387
+ const anchors = resolveOrigin(node, flat);
36388
+ if (!node.forEachOrigin?.axis || node.forEachOrigin.axis.length === 0) {
35943
36389
  return resolveAxisNodes(flat, presOf.axis, presOf.pointTypes, presOf.start, presOf.count) ?? [];
35944
36390
  }
35945
- const anchors = resolveAxisNodes(flat, origin.axis, origin.pointTypes, origin.start, origin.count) ?? [];
35946
36391
  if (anchors.length === 0) {
35947
36392
  return [];
35948
36393
  }
35949
36394
  return resolveAxisNodes(flat, presOf.axis, presOf.pointTypes, presOf.start, presOf.count, anchors) ?? [];
35950
36395
  }
36396
+ function resolveAnchoredContentPerAnchor(node, flat) {
36397
+ const presOf = node.presentationOf;
36398
+ if (!presOf?.axis || presOf.axis.length === 0) {
36399
+ return [];
36400
+ }
36401
+ if (!node.forEachOrigin?.axis || node.forEachOrigin.axis.length === 0) {
36402
+ const content = resolveAnchoredContent(node, flat);
36403
+ return content.length > 0 ? [content] : [];
36404
+ }
36405
+ const anchors = resolveOrigin(node, flat);
36406
+ const groups = [];
36407
+ for (const anchor of anchors) {
36408
+ const content = resolveAxisNodes(flat, presOf.axis, presOf.pointTypes, presOf.start, presOf.count, [
36409
+ anchor
36410
+ ]) ?? [];
36411
+ if (content.length > 0) {
36412
+ groups.push(content);
36413
+ }
36414
+ }
36415
+ return groups;
36416
+ }
35951
36417
  var init_smartart_layout_interpreter_composite_anchor = __esm({
35952
36418
  "src/core/utils/smartart-layout-interpreter-composite-anchor.ts"() {
35953
36419
  init_smartart_layout_interpreter_axis_count();
35954
36420
  }
35955
36421
  });
35956
- function guardAllows(node, flat) {
35957
- if (!node.chooseGuard) {
35958
- return true;
36422
+ function resolveIterationRect(dims, box, iteration, iterationCount) {
36423
+ const container = resolveSlot(dims, box, 1, 1);
36424
+ if (iterationCount <= 1) {
36425
+ return container;
35959
36426
  }
35960
- return evaluateWhen(node.chooseGuard, flat.length, { nodes: flat }) !== false;
35961
- }
35962
- function collectRawCandidates(node, flat, declaringRole, out = []) {
35963
- if (!guardAllows(node, flat)) {
35964
- return out;
35965
- }
35966
- const axis = node.presentationOf?.axis;
35967
- if (axis && axis.length > 0) {
35968
- const content = resolveAnchoredContent(node, flat);
35969
- if (content.length > 0) {
35970
- out.push({ node, declaringRole, content });
35971
- }
35972
- return out;
35973
- }
35974
- const nextRole = roleOf(node);
35975
- for (const child262 of node.children ?? []) {
35976
- collectRawCandidates(child262, flat, nextRole, out);
36427
+ if (container.width >= container.height) {
36428
+ const width = container.width / iterationCount;
36429
+ return { x: container.x + width * iteration, y: container.y, width, height: container.height };
35977
36430
  }
35978
- return out;
36431
+ const height = container.height / iterationCount;
36432
+ return { x: container.x, y: container.y + height * iteration, width: container.width, height };
35979
36433
  }
36434
+ var init_smartart_layout_interpreter_composite_iteration = __esm({
36435
+ "src/core/utils/smartart-layout-interpreter-composite-iteration.ts"() {
36436
+ init_smartart_layout_interpreter_composite_slots();
36437
+ }
36438
+ });
35980
36439
  function contentSignature(content) {
35981
36440
  return content.map((n) => n.id).sort().join(" ");
35982
36441
  }
@@ -36001,13 +36460,59 @@ function resolveGroupedSlots(candidates, box, index) {
36001
36460
  for (const candidate of ordered4) {
36002
36461
  const [slotted] = readSlots([candidate.node], box, index, candidate.declaringRole);
36003
36462
  if (slotted) {
36004
- out.push({ rect: resolveSlot(slotted.dims, box, 1, 1), content: candidate.content });
36463
+ const rect22 = resolveIterationRect(
36464
+ slotted.dims,
36465
+ box,
36466
+ candidate.iteration,
36467
+ candidate.iterationCount
36468
+ );
36469
+ out.push({ rect: rect22, content: candidate.content });
36005
36470
  break;
36006
36471
  }
36007
36472
  }
36008
36473
  }
36009
36474
  return out;
36010
36475
  }
36476
+ var init_smartart_layout_interpreter_composite_group_slots = __esm({
36477
+ "src/core/utils/smartart-layout-interpreter-composite-group-slots.ts"() {
36478
+ init_smartart_layout_interpreter_composite_iteration();
36479
+ init_smartart_layout_interpreter_composite_slots();
36480
+ }
36481
+ });
36482
+ function guardAllows(node, flat, iterationPosition) {
36483
+ if (!node.chooseGuard) {
36484
+ return true;
36485
+ }
36486
+ return node.chooseGuard.every(
36487
+ (guard) => evaluateWhen(guard, flat.length, {
36488
+ nodes: flat,
36489
+ position: iterationPosition?.position,
36490
+ total: iterationPosition?.total
36491
+ }) !== false
36492
+ );
36493
+ }
36494
+ function collectRawCandidates(node, flat, declaringRole, out = []) {
36495
+ const axis = node.presentationOf?.axis;
36496
+ if (axis && axis.length > 0) {
36497
+ const groups = resolveAnchoredContentPerAnchor(node, flat);
36498
+ const iterationPosition = (iteration) => groups.length > 1 ? { position: iteration + 1, total: groups.length } : void 0;
36499
+ groups.forEach((content, iteration) => {
36500
+ if (!guardAllows(node, flat, iterationPosition(iteration))) {
36501
+ return;
36502
+ }
36503
+ out.push({ node, declaringRole, content, iteration, iterationCount: groups.length });
36504
+ });
36505
+ return out;
36506
+ }
36507
+ if (!guardAllows(node, flat, void 0)) {
36508
+ return out;
36509
+ }
36510
+ const nextRole = roleOf(node);
36511
+ for (const child262 of node.children ?? []) {
36512
+ collectRawCandidates(child262, flat, nextRole, out);
36513
+ }
36514
+ return out;
36515
+ }
36011
36516
  function collectChooseAwareSlots(node, flat, box, index, declaringRole) {
36012
36517
  const candidates = collectRawCandidates(node, flat, declaringRole);
36013
36518
  return resolveGroupedSlots(candidates, box, index);
@@ -36042,7 +36547,7 @@ var init_smartart_layout_interpreter_composite_choose = __esm({
36042
36547
  "src/core/utils/smartart-layout-interpreter-composite-choose.ts"() {
36043
36548
  init_smartart_constraint_solver();
36044
36549
  init_smartart_layout_interpreter_composite_anchor();
36045
- init_smartart_layout_interpreter_composite_slots();
36550
+ init_smartart_layout_interpreter_composite_group_slots();
36046
36551
  init_smartart_layout_interpreter_render();
36047
36552
  init_smartart_layout_interpreter_when();
36048
36553
  }
@@ -36280,165 +36785,6 @@ var init_smartart_layout_interpreter_composite = __esm({
36280
36785
  init_smartart_node_tree_axis();
36281
36786
  }
36282
36787
  });
36283
- function resolveHubToNodeRatio(ringItem, arrangerConstraints) {
36284
- if (!ringItem?.name) {
36285
- return void 0;
36286
- }
36287
- const match = (arrangerConstraints ?? []).find(
36288
- (c) => c.type === "w" && c.forName === ringItem.name && c.referenceType === "w" && (c.factor === void 0 || typeof c.factor === "number" && c.factor > 0) && typeof c.referenceForName === "string"
36289
- );
36290
- if (!match) {
36291
- return void 0;
36292
- }
36293
- return { hubName: match.referenceForName, factor: match.factor ?? 1 };
36294
- }
36295
- function resolveHubGapRatio(itemName, hubRatio, arrangerConstraints) {
36296
- if (!hubRatio) {
36297
- return void 0;
36298
- }
36299
- const sp = (arrangerConstraints ?? []).find(
36300
- (c) => c.type === "sp" && typeof c.factor === "number" && typeof c.referenceForName === "string"
36301
- );
36302
- if (!sp || typeof sp.factor !== "number") {
36303
- return void 0;
36304
- }
36305
- if (sp.referenceForName === itemName) {
36306
- return sp.factor;
36307
- }
36308
- if (sp.referenceForName === hubRatio.hubName) {
36309
- return sp.factor / hubRatio.factor;
36310
- }
36311
- return void 0;
36312
- }
36313
- var init_smartart_layout_interpreter_cycle_hub_ratio = __esm({
36314
- "src/core/utils/smartart-layout-interpreter-cycle-hub-ratio.ts"() {
36315
- }
36316
- });
36317
- function deriveCompositeSquareChildAspect(item) {
36318
- if (!item || item.algorithm?.type !== "composite") {
36319
- return void 0;
36320
- }
36321
- const constraints = item.allConstraints ?? item.constraints ?? [];
36322
- for (const width of constraints) {
36323
- if (width.type !== "w" || width.for !== "ch" || !width.forName || width.referenceForName !== void 0 || typeof width.factor !== "number" || width.factor <= 0) {
36324
- continue;
36325
- }
36326
- const childName = width.forName;
36327
- const isSelfSquare = constraints.some(
36328
- (c) => c.type === "h" && c.for === "ch" && c.forName === childName && c.referenceType === "w" && c.referenceFor === "ch" && c.referenceForName === childName
36329
- );
36330
- if (isSelfSquare) {
36331
- return width.factor;
36332
- }
36333
- }
36334
- return void 0;
36335
- }
36336
- function resolveGraphAspectRatio(item, index) {
36337
- if (!item) {
36338
- return void 0;
36339
- }
36340
- const role = roleOf(item);
36341
- const resolvedH = resolveConstraint(index, role, "h");
36342
- const resolvedW = resolveConstraint(index, role, "w");
36343
- if (resolvedH === void 0 || resolvedW === void 0 || resolvedW <= 0) {
36344
- return void 0;
36345
- }
36346
- return resolvedH / resolvedW;
36347
- }
36348
- var init_smartart_layout_interpreter_cycle_item_aspect = __esm({
36349
- "src/core/utils/smartart-layout-interpreter-cycle-item-aspect.ts"() {
36350
- init_smartart_constraint_solver();
36351
- }
36352
- });
36353
- function absoluteConstraintPoints(constraint) {
36354
- if (constraint === void 0 || constraint.factor !== void 0 || constraint.referenceType !== void 0 || typeof constraint.value !== "number" || !Number.isFinite(constraint.value) || constraint.value < 1) {
36355
- return void 0;
36356
- }
36357
- return constraint.value;
36358
- }
36359
- function resolveCycleConstraintNode(arrangerNode) {
36360
- if (arrangerNode.name === "cycle") {
36361
- return arrangerNode;
36362
- }
36363
- for (const child262 of arrangerNode.children ?? []) {
36364
- if (child262.name === "cycle") {
36365
- return child262;
36366
- }
36367
- }
36368
- return arrangerNode;
36369
- }
36370
- function resolveRingItemNode(constraintNode, arrangerConstraints) {
36371
- const sibSpName = (arrangerConstraints ?? []).find(
36372
- (c) => c.type === "sibSp" && typeof c.referenceForName === "string"
36373
- )?.referenceForName;
36374
- const named = sibSpName ? (constraintNode.children ?? []).find((child262) => child262.name === sibSpName) : void 0;
36375
- if (named?.forEachOrigin) {
36376
- return named;
36377
- }
36378
- const repeating = (constraintNode.children ?? []).find((child262) => child262.forEachOrigin);
36379
- return repeating ?? named ?? itemNode(constraintNode);
36380
- }
36381
- function resolveCycleRingParams(arrangerNode, index) {
36382
- const constraintNode = resolveCycleConstraintNode(arrangerNode);
36383
- const arrangerConstraints = constraintNode.allConstraints ?? constraintNode.constraints;
36384
- const item = resolveRingItemNode(constraintNode, arrangerConstraints);
36385
- const itemConstraints = item?.allConstraints ?? item?.constraints;
36386
- const literalHeightOverWidth = ratioConstraint(
36387
- itemConstraints ?? [],
36388
- ["h"],
36389
- Number.NaN,
36390
- item?.rules
36391
- );
36392
- const heightOverWidth = !Number.isNaN(literalHeightOverWidth) ? literalHeightOverWidth : resolveGraphAspectRatio(item, index) ?? resolveRatioConstraint(
36393
- itemConstraints,
36394
- index,
36395
- roleOf(item),
36396
- ["h"],
36397
- deriveCompositeSquareChildAspect(item) ?? 1,
36398
- item?.rules
36399
- );
36400
- const hubRatio = resolveHubToNodeRatio(item, arrangerConstraints);
36401
- const hubGapRatio = resolveHubGapRatio(item?.name, hubRatio, arrangerConstraints);
36402
- const absolutePoints = absoluteConstraintPoints(findConstraint(arrangerConstraints, "sibSp"));
36403
- if (absolutePoints !== void 0) {
36404
- return {
36405
- minGapRatio: DEFAULT_MIN_GAP_RATIO,
36406
- heightOverWidth,
36407
- absoluteGapPx: absolutePoints * POINTS_TO_PIXELS3,
36408
- hubRatio,
36409
- hubGapRatio
36410
- };
36411
- }
36412
- const minGapRatio = resolveRatioConstraint(
36413
- arrangerConstraints,
36414
- index,
36415
- roleOf(constraintNode),
36416
- ["sibSp"],
36417
- DEFAULT_MIN_GAP_RATIO,
36418
- constraintNode.rules
36419
- );
36420
- return {
36421
- minGapRatio: Math.max(DEFAULT_MIN_GAP_RATIO, minGapRatio),
36422
- heightOverWidth,
36423
- hubRatio,
36424
- hubGapRatio
36425
- };
36426
- }
36427
- var POINTS_TO_PIXELS3;
36428
- var DEFAULT_MIN_GAP_RATIO;
36429
- var init_smartart_layout_interpreter_cycle_constraints = __esm({
36430
- "src/core/utils/smartart-layout-interpreter-cycle-constraints.ts"() {
36431
- init_smartart_constraint_ratio_fallback();
36432
- init_smartart_constraint_solver();
36433
- init_smartart_layout_interpreter_constraints();
36434
- init_smartart_layout_interpreter_cycle_hub_ratio();
36435
- init_smartart_layout_interpreter_cycle_item_aspect();
36436
- init_smartart_layout_interpreter_model();
36437
- init_smartart_layout_interpreter_cycle_hub_ratio();
36438
- POINTS_TO_PIXELS3 = 96 / 72;
36439
- DEFAULT_MIN_GAP_RATIO = 0.5;
36440
- }
36441
- });
36442
36788
  function degenerateRingLayout(n, heightOverWidth, box) {
36443
36789
  const boxCentre = { x: box.width / 2, y: box.height / 2 };
36444
36790
  if (n <= 0) {
@@ -36493,22 +36839,18 @@ function ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth
36493
36839
  const maxX = Math.max(...xs) + halfW;
36494
36840
  const minY = Math.min(...ys) - halfH;
36495
36841
  const maxY = Math.max(...ys) + halfH;
36496
- const spreadX = Math.max(...xs) - Math.min(...xs);
36497
- const spreadY = Math.max(...ys) - Math.min(...ys);
36498
36842
  const naturalBoundW = Math.max(1e-6, maxX - minX);
36499
36843
  const naturalBoundH = Math.max(1e-6, maxY - minY);
36500
- let scaleX = box.width / naturalBoundW;
36501
- let scaleY = box.height / naturalBoundH;
36502
- if (spreadX < 1e-6 && spreadY >= 1e-6) {
36503
- scaleX = scaleY;
36504
- } else if (spreadY < 1e-6 && spreadX >= 1e-6) {
36505
- scaleY = scaleX;
36506
- }
36844
+ const scale2 = Math.min(box.width / naturalBoundW, box.height / naturalBoundH);
36845
+ const scaleX = scale2;
36846
+ const scaleY = scale2;
36847
+ const offsetX = (box.width - naturalBoundW * scale2) / 2;
36848
+ const offsetY = (box.height - naturalBoundH * scale2) / 2;
36507
36849
  const centers = natural.map((p) => ({
36508
- x: (p.x - minX) * scaleX,
36509
- y: (p.y - minY) * scaleY
36850
+ x: (p.x - minX) * scaleX + offsetX,
36851
+ y: (p.y - minY) * scaleY + offsetY
36510
36852
  }));
36511
- const hubCenter = { x: (0 - minX) * scaleX, y: (0 - minY) * scaleY };
36853
+ const hubCenter = { x: (0 - minX) * scaleX + offsetX, y: (0 - minY) * scaleY + offsetY };
36512
36854
  const naturalHubRadius = Math.max(0, r0 - Math.max(halfW, halfH));
36513
36855
  return {
36514
36856
  centers,
@@ -36519,12 +36861,14 @@ function ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth
36519
36861
  hubHalfHeight: naturalHubRadius * scaleY
36520
36862
  };
36521
36863
  }
36522
- function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWidth, box, absoluteGapPx, hubGeometry) {
36864
+ function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWidth, box, absoluteGapPx, hubGeometry, absoluteHubGapPx) {
36523
36865
  const degenerate = degenerateRingLayout(n, heightOverWidth, box);
36524
36866
  if (degenerate) {
36525
36867
  return degenerate;
36526
36868
  }
36527
- if (absoluteGapPx === void 0 || absoluteGapPx <= 0) {
36869
+ const needsGapIteration = absoluteGapPx !== void 0 && absoluteGapPx > 0;
36870
+ const needsHubGapIteration = absoluteHubGapPx !== void 0 && absoluteHubGapPx > 0 && hubGeometry !== void 0;
36871
+ if (!needsGapIteration && !needsHubGapIteration) {
36528
36872
  return ringLayoutForGapFactor(
36529
36873
  n,
36530
36874
  stAngDeg,
@@ -36536,6 +36880,7 @@ function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWid
36536
36880
  );
36537
36881
  }
36538
36882
  let gapFactor = minGapRatio;
36883
+ let hub = hubGeometry;
36539
36884
  for (let iteration = 0; iteration < 20; iteration += 1) {
36540
36885
  const candidate = ringLayoutForGapFactor(
36541
36886
  n,
@@ -36544,16 +36889,21 @@ function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWid
36544
36889
  gapFactor,
36545
36890
  heightOverWidth,
36546
36891
  box,
36547
- hubGeometry
36892
+ hub
36548
36893
  );
36549
- const nextGapFactor = candidate.nodeWidth > 1e-6 ? absoluteGapPx / candidate.nodeWidth : gapFactor;
36550
- if (Math.abs(nextGapFactor - gapFactor) < 1e-9) {
36551
- gapFactor = nextGapFactor;
36894
+ const nextGapFactor = needsGapIteration && candidate.nodeWidth > 1e-6 ? absoluteGapPx / candidate.nodeWidth : gapFactor;
36895
+ const nextHubGapRatio = needsHubGapIteration && candidate.nodeWidth > 1e-6 ? absoluteHubGapPx / candidate.nodeWidth : hub?.gapRatio;
36896
+ const gapConverged = Math.abs(nextGapFactor - gapFactor) < 1e-9;
36897
+ const hubGapConverged = !needsHubGapIteration || Math.abs((nextHubGapRatio ?? 0) - (hub?.gapRatio ?? 0)) < 1e-9;
36898
+ gapFactor = nextGapFactor;
36899
+ if (needsHubGapIteration && hub) {
36900
+ hub = { ...hub, gapRatio: nextHubGapRatio ?? hub.gapRatio };
36901
+ }
36902
+ if (gapConverged && hubGapConverged) {
36552
36903
  break;
36553
36904
  }
36554
- gapFactor = nextGapFactor;
36555
36905
  }
36556
- return ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth, box, hubGeometry);
36906
+ return ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth, box, hub);
36557
36907
  }
36558
36908
  var DEG_TO_RAD;
36559
36909
  var init_smartart_layout_interpreter_cycle_ring = __esm({
@@ -36564,14 +36914,14 @@ var init_smartart_layout_interpreter_cycle_ring = __esm({
36564
36914
  function arrangeCycle(plan, nodes, box, palette, style, elementId, index = EMPTY_CONSTRAINT_INDEX, hubAlreadyStripped = false) {
36565
36915
  const { width: w, height: h2 } = box;
36566
36916
  const ctx = styleContext(style);
36567
- const { minGapRatio, heightOverWidth, absoluteGapPx, hubRatio, hubGapRatio } = resolveCycleRingParams(plan.node, index);
36917
+ const { minGapRatio, heightOverWidth, absoluteGapPx, hubRatio, hubGapRatio, absoluteHubGapPx } = resolveCycleRingParams(plan.node, index);
36568
36918
  const hasHub = !hubAlreadyStripped && !hubRatio && algorithmParam(plan.node, "ctrShpMap") === "fNode" && nodes.length > 0;
36569
36919
  const hubNode = hasHub ? nodes[0] : void 0;
36570
36920
  const ringNodes = hasHub ? nodes.slice(1) : nodes;
36571
36921
  const n = ringNodes.length;
36572
36922
  const startDeg = numericParam(plan.node, "stAng", 0);
36573
36923
  const spanDeg = numericParam(plan.node, "spanAng", 360);
36574
- const hubGeometry = hubRatio && hubGapRatio !== void 0 ? { factor: hubRatio.factor, gapRatio: hubGapRatio } : void 0;
36924
+ const hubGeometry = hubRatio && (hubGapRatio !== void 0 || absoluteHubGapPx !== void 0) ? { factor: hubRatio.factor, gapRatio: hubGapRatio ?? 0 } : void 0;
36575
36925
  const ring = computeCycleRingLayout(
36576
36926
  n,
36577
36927
  startDeg,
@@ -36580,7 +36930,8 @@ function arrangeCycle(plan, nodes, box, palette, style, elementId, index = EMPTY
36580
36930
  heightOverWidth,
36581
36931
  box,
36582
36932
  absoluteGapPx,
36583
- hubGeometry
36933
+ hubGeometry,
36934
+ absoluteHubGapPx
36584
36935
  );
36585
36936
  const full = Math.abs(spanDeg) >= 360;
36586
36937
  const connectorCount = n > 0 ? full ? n : Math.max(0, n - 1) : 0;
@@ -37094,6 +37445,58 @@ var init_smartart_hierarchy_hanging = __esm({
37094
37445
  init_smartart_hierarchy_shared();
37095
37446
  }
37096
37447
  });
37448
+ function findCompositeDescendant(node) {
37449
+ if (!node) {
37450
+ return void 0;
37451
+ }
37452
+ if (node.algorithm?.type === "composite") {
37453
+ return node;
37454
+ }
37455
+ for (const child262 of node.children ?? []) {
37456
+ const found = findCompositeDescendant(child262);
37457
+ if (found) {
37458
+ return found;
37459
+ }
37460
+ }
37461
+ return void 0;
37462
+ }
37463
+ function findTextBearingChild(compositeNode) {
37464
+ return (compositeNode.children ?? []).find(
37465
+ (child262) => (child262.presentationOf?.axis ?? []).includes("self")
37466
+ );
37467
+ }
37468
+ function resolveCompositeChildGeometry(algorithmNode) {
37469
+ const compositeNode = findCompositeDescendant(algorithmNode);
37470
+ if (!compositeNode) {
37471
+ return void 0;
37472
+ }
37473
+ const child262 = findTextBearingChild(compositeNode);
37474
+ if (!child262?.name) {
37475
+ return void 0;
37476
+ }
37477
+ const constraints = compositeNode.allConstraints ?? compositeNode.constraints ?? [];
37478
+ const widthConstr = constraints.find(
37479
+ (c) => c.type === "w" && c.for === "ch" && c.forName === child262.name && c.referenceType === "w" && c.referenceForName === void 0 && typeof c.factor === "number"
37480
+ );
37481
+ const heightConstr = constraints.find(
37482
+ (c) => c.type === "h" && c.for === "ch" && c.forName === child262.name && c.referenceType === "w" && c.referenceFor === "ch" && c.referenceForName === child262.name && typeof c.factor === "number"
37483
+ );
37484
+ const leftConstr = constraints.find(
37485
+ (c) => c.type === "l" && c.for === "ch" && c.forName === child262.name && c.referenceType === "w" && c.referenceForName === void 0 && typeof c.factor === "number"
37486
+ );
37487
+ if (!widthConstr || !heightConstr || widthConstr.factor === void 0 || widthConstr.factor <= 0) {
37488
+ return void 0;
37489
+ }
37490
+ return {
37491
+ aspectRatio: heightConstr.factor,
37492
+ widthFactor: widthConstr.factor,
37493
+ offsetXRatio: leftConstr?.factor ?? 0
37494
+ };
37495
+ }
37496
+ var init_smartart_hierarchy_composite_child = __esm({
37497
+ "src/core/utils/smartart-hierarchy-composite-child.ts"() {
37498
+ }
37499
+ });
37097
37500
  function transposeNode(node) {
37098
37501
  switch (node.kind) {
37099
37502
  case "rect":
@@ -37158,7 +37561,8 @@ function fitItemBox(box, columns, levels, sibSpRatio, aspectRatio, generationGap
37158
37561
  const heightFit = usableH / (generations + maxHangDepth + Math.max(0, generations - 1) * generationGapRatio + maxHangDepth * HANG_HEIGHT_RATIO);
37159
37562
  const naturalHeight = widthFit * aspectRatio;
37160
37563
  const boxH = clampToNaturalAspect ? Math.min(naturalHeight, heightFit) : heightFit;
37161
- return { boxW: Math.max(1, widthFit), boxH: Math.max(1, boxH) };
37564
+ const boxW = clampToNaturalAspect ? boxH / aspectRatio : widthFit;
37565
+ return { boxW: Math.max(1, boxW), boxH: Math.max(1, boxH) };
37162
37566
  }
37163
37567
  var init_smartart_hierarchy_fit_item_box = __esm({
37164
37568
  "src/core/utils/smartart-hierarchy-fit-item-box.ts"() {
@@ -37182,7 +37586,7 @@ function resolveAspectRatio(constraints) {
37182
37586
  }
37183
37587
  return DEFAULT_ASPECT_RATIO;
37184
37588
  }
37185
- function resolveGenerationGapRatio(constraints, stackingAxis, aspectRatio) {
37589
+ function resolveGenerationGapRatio(constraints, stackingAxis, aspectRatio, compositeChild, compositeAspect) {
37186
37590
  const onStackingAxis = findByReference(constraints, "sp", stackingAxis);
37187
37591
  if (onStackingAxis !== void 0) {
37188
37592
  return onStackingAxis;
@@ -37217,10 +37621,15 @@ function resolveHierarchyOrientation(algorithmNode, index, mode = "std") {
37217
37621
  // See `OUTER_MARGIN_X_RATIO`'s doc comment: a transposed hierarchy
37218
37622
  // needs no outer margin at all on either axis, COM-verified.
37219
37623
  marginXRatio: 0,
37220
- marginYRatio: 0
37624
+ marginYRatio: 0,
37625
+ // A transposed hierarchy declares no `composite` wrapper (see
37626
+ // `smartart-hierarchy-composite-child.ts`'s own module doc comment) -
37627
+ // nothing to correct or offset from.
37628
+ cardOffsetXRatio: 0
37221
37629
  };
37222
37630
  }
37223
- const aspectRatio = resolveAspectRatio(constraints);
37631
+ const compositeChild = resolveCompositeChildGeometry(algorithmNode);
37632
+ const aspectRatio = compositeChild?.aspectRatio ?? resolveAspectRatio(constraints);
37224
37633
  const tailedMargin = mode === "tailed";
37225
37634
  return {
37226
37635
  transposed: false,
@@ -37228,7 +37637,9 @@ function resolveHierarchyOrientation(algorithmNode, index, mode = "std") {
37228
37637
  aspectRatio,
37229
37638
  generationGapRatio: resolveGenerationGapRatio(constraints, "h", aspectRatio),
37230
37639
  marginXRatio: tailedMargin ? 0 : OUTER_MARGIN_X_RATIO,
37231
- marginYRatio: tailedMargin ? 0 : OUTER_MARGIN_Y_RATIO
37640
+ marginYRatio: tailedMargin ? 0 : OUTER_MARGIN_Y_RATIO,
37641
+ compositeWidthFactor: compositeChild?.widthFactor,
37642
+ cardOffsetXRatio: compositeChild?.offsetXRatio ?? 0
37232
37643
  };
37233
37644
  }
37234
37645
  var DEFAULT_ASPECT_RATIO;
@@ -37240,6 +37651,7 @@ var init_smartart_hierarchy_orientation = __esm({
37240
37651
  "src/core/utils/smartart-hierarchy-orientation.ts"() {
37241
37652
  init_smartart_constraint_ratio_fallback();
37242
37653
  init_smartart_constraint_solver();
37654
+ init_smartart_hierarchy_composite_child();
37243
37655
  init_smartart_hierarchy_transpose();
37244
37656
  init_smartart_hierarchy_fit_item_box();
37245
37657
  init_smartart_hierarchy_child_order();
@@ -37258,6 +37670,21 @@ function computeAxisPitch(dimension, margin, itemSize, count) {
37258
37670
  const maxShift = dimension - n * itemSize - gap * (n - 0.5);
37259
37671
  return { pitch, shift: Math.min(rawShift, maxShift) };
37260
37672
  }
37673
+ function centeredAxisPitch(dimension, itemSize, gapRatio, count) {
37674
+ const n = Math.max(1, count);
37675
+ const gap = n > 1 ? itemSize * Math.max(0, gapRatio) : 0;
37676
+ const pitch = itemSize + gap;
37677
+ const span = n * itemSize + Math.max(0, n - 1) * gap;
37678
+ const shift = (dimension - span) / 2;
37679
+ return { pitch, shift };
37680
+ }
37681
+ function compositeFanPitch(dimension, boxW, compositeWidthFactor, cardOffsetXRatio, sibSpRatio, count) {
37682
+ const compositeW = compositeWidthFactor ? boxW / compositeWidthFactor : boxW;
37683
+ const cardOffsetX = cardOffsetXRatio * compositeW;
37684
+ const centred = centeredAxisPitch(dimension, compositeW, sibSpRatio, count);
37685
+ const correction = cardOffsetX + boxW / 2 - centred.pitch / 2;
37686
+ return { pitch: centred.pitch, shift: centred.shift + correction };
37687
+ }
37261
37688
  function translateNode(node, dx, dy) {
37262
37689
  switch (node.kind) {
37263
37690
  case "rect":
@@ -37309,11 +37736,9 @@ function translateResult(result, dx, dy) {
37309
37736
  return { ...result, nodes, connectors };
37310
37737
  }
37311
37738
  var GENERATION_MARGIN_RATIO;
37312
- var FAN_MARGIN_RATIO;
37313
37739
  var init_smartart_hierarchy_pitch = __esm({
37314
37740
  "src/core/utils/smartart-hierarchy-pitch.ts"() {
37315
37741
  GENERATION_MARGIN_RATIO = 0.1675;
37316
- FAN_MARGIN_RATIO = 0.1115;
37317
37742
  }
37318
37743
  });
37319
37744
  function planFan(childCount, perRow, siblingCxs) {
@@ -37672,11 +38097,17 @@ function arrangeHierarchy(nodes, box, palette, style, elementId, presLayoutVars,
37672
38097
  mode !== "tailed"
37673
38098
  );
37674
38099
  const tailedPitch = mode === "tailed";
37675
- const fanMargin = orientation.transposed || tailedPitch ? 0 : boxW * FAN_MARGIN_RATIO;
37676
38100
  const generationMargin = orientation.transposed || tailedPitch ? 0 : boxH * GENERATION_MARGIN_RATIO;
37677
38101
  const fanWidth = tailedPitch ? effectiveBox.width - hangShape.maxHangDepth * HIER_TAIL_OFFSET_RATIO * boxW : effectiveBox.width;
37678
38102
  const fanHeight = tailedPitch ? effectiveBox.height - hangShape.maxHangDepth * (1 + HANG_HEIGHT_RATIO) * boxH : effectiveBox.height;
37679
- const xPitch = computeAxisPitch(fanWidth, fanMargin, boxW, totalLeaves);
38103
+ const xPitch = compositeFanPitch(
38104
+ fanWidth,
38105
+ boxW,
38106
+ orientation.compositeWidthFactor,
38107
+ orientation.cardOffsetXRatio,
38108
+ orientation.sibSpRatio,
38109
+ totalLeaves
38110
+ );
37680
38111
  const yPitch = computeAxisPitch(fanHeight, generationMargin, boxH, depth);
37681
38112
  const cellW = xPitch.pitch;
37682
38113
  const cellH = yPitch.pitch;
@@ -38056,15 +38487,24 @@ function stackRoleContent(content, arrangerRole, original, index) {
38056
38487
  if (original.kind === "rect") {
38057
38488
  return stackAsRect(content, arrangerRole, original, boundingBoxOf(original), index);
38058
38489
  }
38059
- if (original.kind !== "polygon" && (everyRoleIsRect || hasMixedExplicitKinds)) {
38490
+ if (everyRoleIsRect) {
38060
38491
  return stackAsRect(content, arrangerRole, original, boundingBoxOf(original), index);
38061
38492
  }
38062
- if (original.kind !== "polygon") {
38063
- return void 0;
38493
+ if (original.kind === "polygon") {
38494
+ return splitAsUnchangedCopy(content, original);
38495
+ }
38496
+ if (original.kind === "circle") {
38497
+ return hasMixedExplicitKinds ? splitAsUnchangedCopy(content, original) : void 0;
38498
+ }
38499
+ if (hasMixedExplicitKinds) {
38500
+ return stackAsRect(content, arrangerRole, original, boundingBoxOf(original), index);
38064
38501
  }
38502
+ return void 0;
38503
+ }
38504
+ function splitAsUnchangedCopy(content, original) {
38065
38505
  return content.map((entry2, i2) => {
38066
38506
  const fields = splitEntryFields(entry2, `${original.key}-role${i2}`, original);
38067
- const isSelfRole = entry2.role.presentationOf?.axis?.includes("self") ?? false;
38507
+ const isSelfRole = original.kind === "polygon" && (entry2.role.presentationOf?.axis?.includes("self") ?? false);
38068
38508
  const presetOverride = isSelfRole ? original.presetOverride : fields.presetOverride;
38069
38509
  return { ...original, ...fields, presetOverride };
38070
38510
  });
@@ -38496,7 +38936,7 @@ function runArrangement(input) {
38496
38936
  );
38497
38937
  }
38498
38938
  const roots = topLevelSmartArtNodes(nodes);
38499
- const childrenOf = smartArtChildrenOf(nodes);
38939
+ const childrenOf = smartArtChildrenOf(nodes, input.connections);
38500
38940
  const preArranged = plan.kind === "composite" ? roots.length > 0 ? roots : flat : selectArrangedNodes(plan.node, flat, roots);
38501
38941
  const hub = detectHubExpansion(plan.node, preArranged, childrenOf);
38502
38942
  const arranged = hub ? applyChildOrder(hub.satellites, buildChildOrder(input.connections)) : preArranged;
@@ -38544,8 +38984,13 @@ function runArrangement(input) {
38544
38984
  hasAccentSomewhere,
38545
38985
  constraintIndex
38546
38986
  ) : withItemRoles;
38987
+ const withCycleRingContent = plan.kind === "cycle" ? repositionCycleRingContent(
38988
+ withPyramidBands,
38989
+ resolveCycleRingParams(plan.node, constraintIndex).contentLayout,
38990
+ flat
38991
+ ) : withPyramidBands;
38547
38992
  if (!hub) {
38548
- return withPyramidBands;
38993
+ return withCycleRingContent;
38549
38994
  }
38550
38995
  const hubNode = buildHubRenderedNode(
38551
38996
  plan.node,
@@ -38557,7 +39002,7 @@ function runArrangement(input) {
38557
39002
  hub.satellites.length,
38558
39003
  constraintIndex
38559
39004
  );
38560
- return { ...withPyramidBands, nodes: [hubNode, ...withPyramidBands.nodes] };
39005
+ return { ...withCycleRingContent, nodes: [hubNode, ...withCycleRingContent.nodes] };
38561
39006
  }
38562
39007
  function interpretSmartArtLayout(input) {
38563
39008
  const result = runArrangement(input);
@@ -38574,6 +39019,8 @@ var init_smartart_layout_interpreter = __esm({
38574
39019
  init_smartart_hierarchy_child_order();
38575
39020
  init_smartart_layout_interpreter_connector_order();
38576
39021
  init_smartart_layout_interpreter_custom();
39022
+ init_smartart_layout_interpreter_cycle_constraints();
39023
+ init_smartart_layout_interpreter_cycle_ring_item();
38577
39024
  init_smartart_layout_interpreter_dispatch();
38578
39025
  init_smartart_layout_interpreter_flow();
38579
39026
  init_smartart_layout_interpreter_hierarchy();
@@ -38926,7 +39373,8 @@ function computeSmartArtElementsWithoutCache(smartArtData, containerBounds, them
38926
39373
  interpreted,
38927
39374
  nodes,
38928
39375
  containerBounds,
38929
- smartArtData.presLayoutVars?.bulletEnabled
39376
+ smartArtData.presLayoutVars?.bulletEnabled,
39377
+ smartArtData.connections
38930
39378
  );
38931
39379
  }
38932
39380
  }
@@ -50124,13 +50572,14 @@ function nestedLayoutNodes(node, localName28) {
50124
50572
  } else if (name === "if") {
50125
50573
  for (const ifNode of Array.isArray(entry2) ? entry2 : [entry2]) {
50126
50574
  if (ifNode && typeof ifNode === "object") {
50127
- visit(ifNode, origin, parseWhen(ifNode));
50575
+ const when = parseWhen(ifNode);
50576
+ visit(ifNode, origin, when ? [...guard, when] : guard);
50128
50577
  }
50129
50578
  }
50130
50579
  } else if (name === "else") {
50131
50580
  for (const elseNode of Array.isArray(entry2) ? entry2 : [entry2]) {
50132
50581
  if (elseNode && typeof elseNode === "object") {
50133
- visit(elseNode, origin, void 0);
50582
+ visit(elseNode, origin, guard);
50134
50583
  }
50135
50584
  }
50136
50585
  } else {
@@ -50140,7 +50589,7 @@ function nestedLayoutNodes(node, localName28) {
50140
50589
  };
50141
50590
  for (const [key2, value] of Object.entries(node)) {
50142
50591
  if (!key2.startsWith("@_") && localName28(key2) !== "extLst") {
50143
- visit({ [key2]: value }, void 0, void 0);
50592
+ visit({ [key2]: value }, void 0, []);
50144
50593
  }
50145
50594
  }
50146
50595
  return found;
@@ -50311,7 +50760,7 @@ function parseNode(node, localName28) {
50311
50760
  const nested = nestedLayoutNodes(node, localName28).map((entry2) => ({
50312
50761
  ...parseNode(entry2.xml, localName28),
50313
50762
  forEachOrigin: entry2.origin,
50314
- chooseGuard: entry2.guard
50763
+ chooseGuard: entry2.guard.length > 0 ? entry2.guard : void 0
50315
50764
  }));
50316
50765
  const childOrder3 = optionalString4(node["@_chOrder"]);
50317
50766
  const presOf = choosePresentationOf(node, localName28);