@uipath/flow-tool 1.202.2 → 1.203.0-preview.180

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 (150) hide show
  1. package/dist/THIRD-PARTY-NOTICES.md +48 -49
  2. package/dist/{authoring-cyybnqy9.js → authoring-tv4dh80p.js} +31 -9
  3. package/dist/{binding-service-xq110a7q.js → binding-service-1hjkvp7f.js} +37 -29
  4. package/dist/{connector-service-1jp3gvb1.js → connector-service-f50vt5ar.js} +225 -57
  5. package/dist/{conversion-FQTRFHRX-j8vsrk1c.js → conversion-FQTRFHRX-5bww6cg9.js} +11 -10
  6. package/dist/de-FGHEJRCI-gn4cf5gh.js +2697 -0
  7. package/dist/de-MUJPA4EB-dpg7t2rw.js +173 -0
  8. package/dist/{debug-conversation-trigger-q5jwq1x7.js → debug-conversation-trigger-nmd9v41y.js} +21 -18
  9. package/dist/{debug-http-client-4ev9xna7.js → debug-http-client-53qk6pc5.js} +2 -2
  10. package/dist/{debug-service-2skv6t3q.js → debug-service-nyk0s6mc.js} +3 -3
  11. package/dist/{edge-service-crgn8x3q.js → edge-service-qs0fmj4c.js} +19 -16
  12. package/dist/{index-4b8634za.js → embedded-file-reader-0sjt4nkj.js} +96 -16641
  13. package/dist/{en-TBNO2WUV-rfe87pgh.js → en-BWGKA5OE-1qkvb9rn.js} +2 -2
  14. package/dist/en-FBPVNKFN-dqt573xn.js +138 -0
  15. package/dist/en-TBNO2WUV-9nan43e5.js +1936 -0
  16. package/dist/es-7SE7HX2X-8yh1aj2y.js +173 -0
  17. package/dist/es-KR3ZSNMP-0cszm2n3.js +2697 -0
  18. package/dist/es-MX-2MYFZU7X-3rek4r73.js +173 -0
  19. package/dist/es-MX-XXZJGC4R-b4fbwe9d.js +2697 -0
  20. package/dist/first-party-service-srxaftkn.js +27 -0
  21. package/dist/{flow-api-p1jy8t6k.js → flow-api-f49qbvf6.js} +8 -8
  22. package/dist/{flow-debug-service-gtz48pcs.js → flow-debug-service-nvx6c5fm.js} +65 -40
  23. package/dist/{flow-eval-node-target-d4q72qzz.js → flow-eval-node-target-rv41h6g2.js} +24 -17
  24. package/dist/flow-eval-run-api-1bw5e0k4.js +13 -0
  25. package/dist/{flow-eval-run-service-bteardyh.js → flow-eval-run-service-bnpf0zhb.js} +105 -220
  26. package/dist/{flow-eval-service-8wn40enf.js → flow-eval-service-p0fbctsk.js} +350 -306
  27. package/dist/flow-init-service-6c5tj22g.js +42 -0
  28. package/dist/{flow-io-91tv36v5.js → flow-io-c05c9hc7.js} +18 -15
  29. package/dist/{flow-migrate-service-4mxge029.js → flow-migrate-service-6dky7rrg.js} +27 -23
  30. package/dist/{flow-pack-service-9s7wmwpf.js → flow-pack-service-3ms1t8nv.js} +44 -36
  31. package/dist/flow-validate-service-hq93ye0w.js +65 -0
  32. package/dist/fr-MDFKNZ4C-h4a122k9.js +173 -0
  33. package/dist/fr-Y6NPVODW-q5ef3htr.js +2697 -0
  34. package/dist/{governance-fetcher-kn29e4eb.js → governance-fetcher-7b0a301w.js} +6 -5
  35. package/dist/{headless-my7j1typ.js → headless-rkxtgwts.js} +42909 -1756
  36. package/dist/{hitl-service-fmrkamr4.js → hitl-service-fpdb3tf5.js} +18 -15
  37. package/dist/{index-1kgxzh8x.js → index-3ts7y9d3.js} +15 -3
  38. package/dist/{index-gbfvfhkw.js → index-4hhb8jhe.js} +6 -4
  39. package/dist/{index-apf8q9y0.js → index-51z10z84.js} +4 -4
  40. package/dist/{index-d1yqqk6q.js → index-55cym5j7.js} +6 -4
  41. package/dist/index-kmp9fmhb.js +25 -0
  42. package/dist/index-sc7ddh21.js +16742 -0
  43. package/dist/{index-acd6bpqc.js → index-ymsd3pyx.js} +12 -15
  44. package/dist/index.js +13 -24
  45. package/dist/init.js +23 -19
  46. package/dist/{input-reader-mm2ydeh5.js → input-reader-tw0j373f.js} +1 -1
  47. package/dist/ja-Q5PXKJ2V-tzf2rvz2.js +2697 -0
  48. package/dist/ja-UTQEAP34-8e0q6swp.js +173 -0
  49. package/dist/known-types-8dhhqk35.js +19 -0
  50. package/dist/ko-AXCHW2OK-askct7f6.js +173 -0
  51. package/dist/ko-AYBDSRZG-am0h0m2r.js +2697 -0
  52. package/dist/{maestro-automate-entry-6bxz7zxn.js → maestro-automate-entry-pqy9xqm3.js} +2 -2
  53. package/dist/{node-2ja52fbg.js → node-98psr4wc.js} +2344 -376
  54. package/dist/{node-service-1ygyqaed.js → node-service-yfyzjg1s.js} +37 -29
  55. package/dist/{node-sync-service-a4grwf1e.js → node-sync-service-zq2ptsep.js} +15 -15
  56. package/dist/{packager-tool-nnm6kw3x.js → packager-tool-0egkaa38.js} +1 -1
  57. package/dist/{packager-tool-0hrz9qfd.js → packager-tool-10t52r3c.js} +7 -7
  58. package/dist/{packager-tool-eb48j42f.js → packager-tool-13xbv18n.js} +100 -127
  59. package/dist/{packager-tool-nq4rcqqg.js → packager-tool-1frs4sr4.js} +32 -2
  60. package/dist/{packager-tool-bddj2zb4.js → packager-tool-1r5dnt9q.js} +1 -1
  61. package/dist/{packager-tool-f0kd5kq4.js → packager-tool-26ydwf12.js} +130 -15
  62. package/dist/{packager-tool-9ydywwp2.js → packager-tool-321a1806.js} +1 -1
  63. package/dist/packager-tool-35hg551a.js +1889 -0
  64. package/dist/{packager-tool-2csx1z2z.js → packager-tool-3j8sdsc2.js} +31 -30
  65. package/dist/{packager-tool-kscf0zaz.js → packager-tool-4rvnss1x.js} +15 -56
  66. package/dist/{packager-tool-t6exvxxr.js → packager-tool-5060zp48.js} +2 -2
  67. package/dist/packager-tool-53w8skv5.js +262 -0
  68. package/dist/{packager-tool-rew0hp2h.js → packager-tool-6k8s7pt9.js} +269 -23
  69. package/dist/{packager-tool-29eg86w6.js → packager-tool-6rsegsby.js} +6 -7
  70. package/dist/packager-tool-795gzq9k.js +208 -0
  71. package/dist/packager-tool-7q6z6npd.js +1937 -0
  72. package/dist/{packager-tool-h1mds3r4.js → packager-tool-8dj442ex.js} +5 -4
  73. package/dist/packager-tool-8qp60s20.js +12 -0
  74. package/dist/{packager-tool-114a3x6s.js → packager-tool-9kx94sj5.js} +16 -6
  75. package/dist/packager-tool-asvprb1k.js +3513 -0
  76. package/dist/{packager-tool-0d7tcvg1.js → packager-tool-b1xs6aty.js} +4 -1
  77. package/dist/{packager-tool-nmqwgqp7.js → packager-tool-bzry3t7v.js} +9 -9
  78. package/dist/{packager-tool-nt7g81h7.js → packager-tool-carzh1jy.js} +10 -10
  79. package/dist/packager-tool-d88rqwk8.js +135 -0
  80. package/dist/{packager-tool-pm3qh1hy.js → packager-tool-dh5nppv4.js} +1 -1
  81. package/dist/{packager-tool-r87gxwqa.js → packager-tool-e87tzg4y.js} +2 -2
  82. package/dist/{packager-tool-d0w3423x.js → packager-tool-e9yc5m6b.js} +1 -1
  83. package/dist/packager-tool-fvm2dddf.js +6297 -0
  84. package/dist/{packager-tool-3bra2c4j.js → packager-tool-gctpkdzs.js} +1 -1
  85. package/dist/packager-tool-gdtpsdn7.js +342 -0
  86. package/dist/{packager-tool-aa481g36.js → packager-tool-gpwec9sp.js} +6 -6
  87. package/dist/{packager-tool-a1hbfmws.js → packager-tool-gzpvdcnw.js} +124 -2
  88. package/dist/{packager-tool-03hjxcd7.js → packager-tool-h9d8c9rf.js} +1 -1
  89. package/dist/packager-tool-j78fwwhq.js +16 -0
  90. package/dist/packager-tool-jysvpt8p.js +11 -0
  91. package/dist/{packager-tool-5kd7msdf.js → packager-tool-nsmy7aap.js} +5 -5
  92. package/dist/packager-tool-paq9c70w.js +1332 -0
  93. package/dist/{packager-tool-tv33t02p.js → packager-tool-pszx10r5.js} +310 -13
  94. package/dist/{packager-tool-7qzyj26r.js → packager-tool-r45r9gk6.js} +209 -199
  95. package/dist/{packager-tool-sc5tddfj.js → packager-tool-s0mzv3sx.js} +1 -1
  96. package/dist/{packager-tool-pdg7hwvw.js → packager-tool-t9c77psy.js} +3098 -3179
  97. package/dist/{packager-tool-0880myh2.js → packager-tool-v31s32s4.js} +23 -5
  98. package/dist/{packager-tool-vfb74f9p.js → packager-tool-vbser1d9.js} +7 -7
  99. package/dist/packager-tool-vcjq9xkc.js +1895 -0
  100. package/dist/{packager-tool-w20r6n9v.js → packager-tool-vck7ct1e.js} +2877 -2221
  101. package/dist/{packager-tool-e8td7b01.js → packager-tool-vdc8r21p.js} +10328 -16610
  102. package/dist/{packager-tool-yr3bws42.js → packager-tool-vqcnvaae.js} +15 -15
  103. package/dist/{packager-tool-n7x6kxph.js → packager-tool-w22107ex.js} +8 -8
  104. package/dist/packager-tool-w5a1hhyj.js +13 -0
  105. package/dist/{packager-tool-rmh1jea6.js → packager-tool-xsta8jfz.js} +4 -3
  106. package/dist/packager-tool-yvva2vc5.js +261 -0
  107. package/dist/{packager-tool-9y5am147.js → packager-tool-z185rq2a.js} +4 -4
  108. package/dist/{packager-tool-gbzpz3qn.js → packager-tool-z894s8rx.js} +10 -13
  109. package/dist/packager-tool.js +17 -14
  110. package/dist/pt-3DIO5QWG-59b3f4bc.js +173 -0
  111. package/dist/pt-BR-TKHNHMET-dn6zxk1d.js +2697 -0
  112. package/dist/pt-BR-Y6K6XHXK-mp3hwhw1.js +173 -0
  113. package/dist/pt-ROXU257Y-yd80gx6s.js +2697 -0
  114. package/dist/ro-AVAWPKOO-42m6am1w.js +2697 -0
  115. package/dist/ro-BWR3ONRR-vzx3hy8a.js +173 -0
  116. package/dist/ru-GSCT4ARZ-jrxwev63.js +10 -0
  117. package/dist/ru-WBLQ5B2U-s4em88p0.js +10 -0
  118. package/dist/{serialization-BXU6AKAN-n5b0v0kd.js → serialization-BXU6AKAN-z0vcrhpz.js} +13 -12
  119. package/dist/services/connector-binding-validator.d.ts +10 -1
  120. package/dist/services/definitions-lookup.d.ts +27 -0
  121. package/dist/services/flow-debug-service.d.ts +290 -0
  122. package/dist/services/flow-eval-types.d.ts +2 -2
  123. package/dist/services/flow-eval-utils.d.ts +29 -0
  124. package/dist/services/flow-validate-service.d.ts +39 -0
  125. package/dist/services/node-validators/connector-validator.d.ts +8 -0
  126. package/dist/services/vars-reference-rule.d.ts +113 -13
  127. package/dist/{shared-utils-ka4xn0nn.js → shared-utils-wv356cvj.js} +1 -1
  128. package/dist/tidy-service-cxpm6pcy.js +39 -0
  129. package/dist/tool.js +13 -24
  130. package/dist/tr-5IIHSFW5-hw4cewew.js +173 -0
  131. package/dist/tr-JMIP7ZSL-fb67ft9w.js +2696 -0
  132. package/dist/utils/handle-expansion.d.ts +34 -0
  133. package/dist/utils/write-resolved-flow.d.ts +7 -0
  134. package/dist/validation.js +46 -39
  135. package/dist/{variable-service-caa9axmz.js → variable-service-c1f91388.js} +22 -19
  136. package/dist/{wait-for-flow-job-xtnb6zfc.js → wait-for-flow-job-yp3mhy43.js} +8 -8
  137. package/dist/zh-CN-IFFXSEJS-tke4mzty.js +2697 -0
  138. package/dist/zh-CN-R2KU4U5L-tc1hat59.js +173 -0
  139. package/dist/zh-TW-GNKMELBF-j674515r.js +173 -0
  140. package/dist/zh-TW-IYBNYAMG-wcan0qpb.js +2697 -0
  141. package/package.json +3 -2
  142. package/dist/flow-init-service-a4td40wm.js +0 -38
  143. package/dist/flow-validate-service-bd4zxhfx.js +0 -59
  144. package/dist/known-types-eq32py2n.js +0 -20
  145. package/dist/packager-tool-2wefykg9.js +0 -106
  146. package/dist/packager-tool-7t3rgb7f.js +0 -4945
  147. package/dist/packager-tool-8j92afwp.js +0 -58
  148. package/dist/packager-tool-jjpc0yka.js +0 -304
  149. package/dist/tidy-service-44n8x2mn.js +0 -36
  150. /package/dist/{localization-w8ada88j.js → localization-y790z9vm.js} +0 -0
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  enableErrorHandlingForErrorEdges,
3
3
  expandHandleIds
4
- } from "./packager-tool-nq4rcqqg.js";
4
+ } from "./packager-tool-1frs4sr4.js";
5
5
  import {
6
6
  readFlowWorkflow,
7
7
  writeFlowWorkflow
8
- } from "./packager-tool-n7x6kxph.js";
8
+ } from "./packager-tool-w22107ex.js";
9
9
  import {
10
10
  DEFAULT_LAYOUT_OPTIONS,
11
11
  GRID_SPACING,
12
12
  resolveHeight,
13
13
  resolveWidth,
14
14
  snapToGrid
15
- } from "./packager-tool-29eg86w6.js";
15
+ } from "./packager-tool-6rsegsby.js";
16
16
  import {
17
17
  generateNodeVariables
18
- } from "./packager-tool-jjpc0yka.js";
18
+ } from "./packager-tool-vcjq9xkc.js";
19
19
  import {
20
20
  __require,
21
21
  __toESM
@@ -437,11 +437,187 @@ var ElkLayoutEngine = class {
437
437
  return { totalWidth: maxX - minX, totalHeight: maxY - minY, executionTime };
438
438
  }
439
439
  };
440
+ var SPINE_STRAIGHTNESS_PRIORITY = "1";
441
+ function findSpineEdgeIds(childIds, edges) {
442
+ if (childIds.length === 0 || edges.length === 0)
443
+ return /* @__PURE__ */ new Set;
444
+ const idSet = new Set(childIds);
445
+ const outDegree = new Map(childIds.map((id) => [id, 0]));
446
+ const inDegree = new Map(childIds.map((id) => [id, 0]));
447
+ for (const e of edges) {
448
+ const src = e.sources[0];
449
+ const tgt = e.targets[0];
450
+ if (!idSet.has(src) || !idSet.has(tgt) || src === tgt)
451
+ continue;
452
+ outDegree.set(src, (outDegree.get(src) ?? 0) + 1);
453
+ inDegree.set(tgt, (inDegree.get(tgt) ?? 0) + 1);
454
+ }
455
+ const spine = /* @__PURE__ */ new Set;
456
+ for (const e of edges) {
457
+ const src = e.sources[0];
458
+ const tgt = e.targets[0];
459
+ if (!idSet.has(src) || !idSet.has(tgt) || src === tgt)
460
+ continue;
461
+ if ((outDegree.get(src) ?? 0) === 1 && (inDegree.get(tgt) ?? 0) === 1) {
462
+ spine.add(e.id);
463
+ }
464
+ }
465
+ return spine;
466
+ }
467
+ function buildTidyElkContainer(containerId, params) {
468
+ const directChildren = params.childrenByParent.get(containerId) ?? [];
469
+ const localEdges = params.edgesByParent.get(containerId) ?? [];
470
+ const elkChildren = directChildren.map((child) => {
471
+ if (child.isContainer)
472
+ return buildTidyElkContainer(child.id, params);
473
+ const oh = params.overhangById?.get(child.id);
474
+ return {
475
+ id: child.id,
476
+ width: child.width + (oh?.left ?? 0) + (oh?.right ?? 0),
477
+ height: child.height + (oh?.top ?? 0) + (oh?.bottom ?? 0)
478
+ };
479
+ });
480
+ const spineEdgeIds = findSpineEdgeIds(directChildren.map((c) => c.id), localEdges);
481
+ const annotatedEdges = localEdges.map((e) => spineEdgeIds.has(e.id) ? { ...e, layoutOptions: { ...e.layoutOptions, "org.eclipse.elk.layered.priority.straightness": SPINE_STRAIGHTNESS_PRIORITY } } : e);
482
+ return {
483
+ id: containerId,
484
+ width: params.fit.minWidth,
485
+ height: params.fit.minHeight,
486
+ layoutOptions: {
487
+ "elk.algorithm": "layered",
488
+ "elk.direction": params.direction,
489
+ "elk.padding": params.fit.elkPadding,
490
+ "elk.spacing.nodeNode": String(params.nodeSpacing),
491
+ "elk.layered.spacing.nodeNodeBetweenLayers": String(params.layerSpacing),
492
+ "elk.layered.nodePlacement.strategy": "BRANDES_KOEPF",
493
+ "elk.layered.nodePlacement.bk.fixedAlignment": "BALANCED",
494
+ "elk.layered.considerModelOrder.strategy": "NODES_AND_EDGES",
495
+ "elk.layered.crossingMinimization.forceNodeModelOrder": "true",
496
+ ...params.orthogonalRouting ? { "elk.edgeRouting": "ORTHOGONAL" } : {},
497
+ "elk.hierarchyHandling": "SEPARATE_CHILDREN",
498
+ "elk.nodeSize.constraints": "MINIMUM_SIZE",
499
+ "elk.nodeSize.minimum": `(${params.fit.minWidth},${params.fit.minHeight})`
500
+ },
501
+ children: elkChildren,
502
+ edges: annotatedEdges
503
+ };
504
+ }
505
+ function clamp(value, lo, hi) {
506
+ if (hi < lo)
507
+ return lo;
508
+ return Math.min(hi, Math.max(lo, value));
509
+ }
510
+ function applyTidyContainerLayout(node, updates, containerOffsets, params) {
511
+ const { fit } = params;
512
+ const horizontal = params.direction === "RIGHT" || params.direction === "LEFT";
513
+ const children = node.children ?? [];
514
+ const isContainerElkNode = node.layoutOptions !== undefined;
515
+ if (children.length === 0) {
516
+ if (isContainerElkNode) {
517
+ const w = params.snapUp(Math.max(fit.minWidth, node.width ?? 0));
518
+ const h = params.snapUp(Math.max(fit.minHeight, node.height ?? 0));
519
+ updates.set(node.id, { width: w, height: h });
520
+ return { width: w, height: h };
521
+ }
522
+ return { width: node.width ?? params.defaultNodeSize, height: node.height ?? params.defaultNodeSize };
523
+ }
524
+ const childSizes = /* @__PURE__ */ new Map;
525
+ for (const child of children) {
526
+ childSizes.set(child.id, applyTidyContainerLayout(child, updates, containerOffsets, params));
527
+ }
528
+ const childAnchorAdjustments = horizontal && params.hooks?.resolveChildAnchorAdjustments ? params.hooks.resolveChildAnchorAdjustments(node.id, children, childSizes) : /* @__PURE__ */ new Map;
529
+ let minX = Number.POSITIVE_INFINITY;
530
+ let minY = Number.POSITIVE_INFINITY;
531
+ let maxX = 0;
532
+ let maxY = 0;
533
+ for (const child of children) {
534
+ const x = child.x ?? 0;
535
+ const y = (child.y ?? 0) + (childAnchorAdjustments.get(child.id) ?? 0);
536
+ const { width: w, height: h } = childSizes.get(child.id);
537
+ if (x < minX)
538
+ minX = x;
539
+ if (y < minY)
540
+ minY = y;
541
+ if (x + w > maxX)
542
+ maxX = x + w;
543
+ if (y + h > maxY)
544
+ maxY = y + h;
545
+ }
546
+ const bboxWidth = maxX - minX;
547
+ const bboxHeight = maxY - minY;
548
+ const finalWidth = params.snapUp(Math.max(fit.minWidth, bboxWidth + fit.paddingLeft + fit.paddingRight));
549
+ const baseHeight = params.snapUp(Math.max(fit.minHeight, bboxHeight + fit.paddingTop + fit.paddingBottom));
550
+ const dxTarget = (finalWidth - bboxWidth) / 2 - minX;
551
+ const dx = clamp(dxTarget, fit.paddingLeft - minX, finalWidth - fit.paddingRight - maxX);
552
+ const entryRailY = horizontal && params.hooks?.resolveEntryRail ? params.hooks.resolveEntryRail(node.id, children, childSizes, childAnchorAdjustments) : undefined;
553
+ let finalHeight = baseHeight;
554
+ let dy = clamp((finalHeight - bboxHeight) / 2 - minY, fit.paddingTop - minY, finalHeight - fit.paddingBottom - maxY);
555
+ if (typeof entryRailY === "number") {
556
+ finalHeight = params.snapUp(Math.max(baseHeight, 2 * (fit.paddingTop - minY + entryRailY), 2 * (maxY - entryRailY + fit.paddingBottom)));
557
+ dy = finalHeight / 2 - entryRailY;
558
+ }
559
+ containerOffsets.set(node.id, { dx, dy });
560
+ updates.set(node.id, { width: finalWidth, height: finalHeight });
561
+ for (const child of children) {
562
+ const size = childSizes.get(child.id);
563
+ const oh = params.overhangById?.get(child.id);
564
+ const offsetX = oh?.left ?? 0;
565
+ const offsetY = oh?.top ?? 0;
566
+ const realWidth = size.width - offsetX - (oh?.right ?? 0);
567
+ const realHeight = size.height - offsetY - (oh?.bottom ?? 0);
568
+ updates.set(child.id, {
569
+ position: {
570
+ x: snapToGrid((child.x ?? 0) + dx + offsetX),
571
+ y: snapToGrid((child.y ?? 0) + (childAnchorAdjustments.get(child.id) ?? 0) + dy + offsetY)
572
+ },
573
+ width: realWidth,
574
+ height: realHeight
575
+ });
576
+ }
577
+ return { width: finalWidth, height: finalHeight };
578
+ }
579
+ async function tidyContainerHierarchy(params) {
580
+ const root = buildTidyElkContainer(params.containerId, params);
581
+ const layouted = await params.layout(root);
582
+ const updates = /* @__PURE__ */ new Map;
583
+ const containerOffsets = /* @__PURE__ */ new Map;
584
+ applyTidyContainerLayout(layouted, updates, containerOffsets, params);
585
+ return { layouted, updates, containerOffsets };
586
+ }
587
+ function snapUpToGrid(value, gridSize = GRID_SPACING) {
588
+ return Math.ceil(value / gridSize) * gridSize;
589
+ }
590
+ var DEFAULT_INTERIOR_NODE_SPACING = 32;
591
+ var DEFAULT_INTERIOR_LAYER_SPACING = 64;
592
+ var DEFAULT_MIN_WIDTH = 560;
593
+ var DEFAULT_MIN_HEIGHT = 320;
594
+ var DEFAULT_PADDING_TOP = 96;
595
+ var DEFAULT_PADDING_BOTTOM = 48;
596
+ var DEFAULT_PADDING_LEFT = 144;
597
+ var DEFAULT_PADDING_RIGHT = 144;
598
+ function defaultContainerFit() {
599
+ return {
600
+ minWidth: DEFAULT_MIN_WIDTH,
601
+ minHeight: DEFAULT_MIN_HEIGHT,
602
+ paddingTop: DEFAULT_PADDING_TOP,
603
+ paddingBottom: DEFAULT_PADDING_BOTTOM,
604
+ paddingLeft: DEFAULT_PADDING_LEFT,
605
+ paddingRight: DEFAULT_PADDING_RIGHT,
606
+ elkPadding: `[top=${DEFAULT_PADDING_TOP},left=${DEFAULT_PADDING_LEFT},bottom=${DEFAULT_PADDING_BOTTOM},right=${DEFAULT_PADDING_RIGHT}]`
607
+ };
608
+ }
440
609
 
441
610
  // src/services/tidy-service.ts
442
611
  var COLLAPSED_NODE_SIZE = 96;
443
612
  var EXPANDED_RECTANGLE_WIDTH = 288;
444
- var CONTAINER_SIZE = { width: 560, height: 320 };
613
+ var CONTAINER_SIZE = {
614
+ width: defaultContainerFit().minWidth,
615
+ height: defaultContainerFit().minHeight
616
+ };
617
+ function parentIdOf(node) {
618
+ const pid = node?.parentId;
619
+ return typeof pid === "string" && pid.length > 0 ? pid : undefined;
620
+ }
445
621
  function expandedSizeForShape(shape) {
446
622
  if (shape === "container") {
447
623
  return { ...CONTAINER_SIZE };
@@ -625,6 +801,9 @@ function applyLayoutToNodes(nodes, layoutedNodes, shapeOf) {
625
801
  let repositioned = 0;
626
802
  let resized = 0;
627
803
  for (const node of nodes) {
804
+ if (UI_ONLY_NODE_TYPES.has(node.type)) {
805
+ continue;
806
+ }
628
807
  const newPos = positionMap.get(node.id);
629
808
  if (!newPos)
630
809
  continue;
@@ -634,9 +813,6 @@ function applyLayoutToNodes(nodes, layoutedNodes, shapeOf) {
634
813
  node.ui.position = { x: newPos.x, y: newPos.y };
635
814
  repositioned++;
636
815
  }
637
- if (UI_ONLY_NODE_TYPES.has(node.type)) {
638
- continue;
639
- }
640
816
  const targetSize = expandedSizeForShape(shapeOf(node));
641
817
  const currentSize = node.ui.size;
642
818
  const sizeNeedsUpdate = currentSize?.width !== targetSize.width || currentSize?.height !== targetSize.height;
@@ -647,23 +823,140 @@ function applyLayoutToNodes(nodes, layoutedNodes, shapeOf) {
647
823
  }
648
824
  return { repositioned, resized };
649
825
  }
826
+ function applyContainerLayout(nodes, childRelPositions, nodeSizes) {
827
+ let repositioned = 0;
828
+ let resized = 0;
829
+ for (const node of nodes) {
830
+ const rel = childRelPositions.get(node.id);
831
+ if (rel && (node.ui.position.x !== rel.x || node.ui.position.y !== rel.y)) {
832
+ node.ui.position = { x: rel.x, y: rel.y };
833
+ repositioned++;
834
+ }
835
+ const size = nodeSizes.get(node.id);
836
+ if (size && (node.ui.size?.width !== size.width || node.ui.size?.height !== size.height)) {
837
+ node.ui.size = size;
838
+ resized++;
839
+ }
840
+ }
841
+ return { repositioned, resized };
842
+ }
650
843
  async function tidyNodesAndEdges(engine, nodes, edges, portResolver, shapeOf) {
651
844
  if (nodes.length === 0) {
652
845
  return { repositioned: 0, resized: 0 };
653
846
  }
654
847
  const allNodes = nodesToLayoutNodes(nodes, shapeOf);
655
848
  const allEdges = edgesToLayoutEdges(edges);
849
+ const nodeIds = new Set(allNodes.map((n) => n.id));
850
+ const layoutNodeById = new Map(allNodes.map((n) => [n.id, n]));
851
+ const nodeInstanceOf = (id) => id === undefined ? undefined : layoutNodeById.get(id)?.data;
852
+ const isContainerId = (id) => {
853
+ const inst = nodeInstanceOf(id);
854
+ return inst !== undefined && shapeOf(inst) === "container";
855
+ };
856
+ const chainTerminates = (id) => {
857
+ const seen = new Set;
858
+ let cur = id;
859
+ while (cur !== undefined) {
860
+ if (seen.has(cur))
861
+ return false;
862
+ seen.add(cur);
863
+ const p = parentIdOf(nodeInstanceOf(cur));
864
+ if (p === undefined || !nodeIds.has(p))
865
+ return true;
866
+ cur = p;
867
+ }
868
+ return true;
869
+ };
870
+ const childrenByParent = new Map;
871
+ for (const n of allNodes) {
872
+ if (UI_ONLY_NODE_TYPES.has(n.type))
873
+ continue;
874
+ const pid = parentIdOf(n.data);
875
+ if (pid && pid !== n.id && nodeIds.has(pid) && isContainerId(pid) && chainTerminates(n.id)) {
876
+ const group = childrenByParent.get(pid);
877
+ if (group)
878
+ group.push(n);
879
+ else
880
+ childrenByParent.set(pid, [n]);
881
+ }
882
+ }
883
+ const containerChildIds = new Set([...childrenByParent.values()].flat().map((n) => n.id));
884
+ const interiorEdgesByParent = new Map;
885
+ for (const e of allEdges) {
886
+ const sp = parentIdOf(nodeInstanceOf(e.source));
887
+ const tp = parentIdOf(nodeInstanceOf(e.target));
888
+ if (sp && sp === tp) {
889
+ const list = interiorEdgesByParent.get(sp);
890
+ if (list)
891
+ list.push(e);
892
+ else
893
+ interiorEdgesByParent.set(sp, [e]);
894
+ }
895
+ }
896
+ const tidyChildrenByParent = new Map;
897
+ for (const [pid, kids] of childrenByParent) {
898
+ tidyChildrenByParent.set(pid, kids.map((k) => ({
899
+ id: k.id,
900
+ width: k.width ?? COLLAPSED_NODE_SIZE,
901
+ height: k.height ?? COLLAPSED_NODE_SIZE,
902
+ isContainer: childrenByParent.has(k.id)
903
+ })));
904
+ }
905
+ const elkEdgesByParent = new Map;
906
+ for (const [pid, es] of interiorEdgesByParent) {
907
+ elkEdgesByParent.set(pid, es.map((e) => ({
908
+ id: e.id,
909
+ sources: [e.source],
910
+ targets: [e.target]
911
+ })));
912
+ }
913
+ const childRelPositions = new Map;
914
+ const nodeSizes = new Map;
915
+ const topLevelContainerIds = [...childrenByParent.keys()].filter((id) => !containerChildIds.has(id));
916
+ for (const containerId of topLevelContainerIds) {
917
+ const { updates } = await tidyContainerHierarchy({
918
+ containerId,
919
+ childrenByParent: tidyChildrenByParent,
920
+ edgesByParent: elkEdgesByParent,
921
+ fit: defaultContainerFit(),
922
+ direction: "RIGHT",
923
+ nodeSpacing: DEFAULT_INTERIOR_NODE_SPACING,
924
+ layerSpacing: DEFAULT_INTERIOR_LAYER_SPACING,
925
+ orthogonalRouting: true,
926
+ snapUp: snapUpToGrid,
927
+ defaultNodeSize: COLLAPSED_NODE_SIZE,
928
+ layout: (root) => engine.layoutHierarchical(root)
929
+ });
930
+ for (const [id, upd] of updates) {
931
+ if (upd.position) {
932
+ childRelPositions.set(id, upd.position);
933
+ }
934
+ if (upd.width !== undefined && upd.height !== undefined) {
935
+ nodeSizes.set(id, { width: upd.width, height: upd.height });
936
+ }
937
+ }
938
+ }
656
939
  const artifactChildIds = identifyArtifactChildIds(allEdges, portResolver, allNodes);
657
940
  const collapsedIds = new Set(allNodes.filter((n) => n.data?.ui?.isCollapsed).map((n) => n.id));
658
941
  const hiddenIds = collectArtifactDescendants(collapsedIds, allEdges, artifactChildIds);
659
- const layoutNodes = allNodes.filter((n) => !hiddenIds.has(n.id));
660
- const layoutEdges = allEdges.filter((e) => !hiddenIds.has(e.source) && !hiddenIds.has(e.target));
942
+ const excludedIds = new Set([...hiddenIds, ...containerChildIds]);
943
+ const layoutNodes = allNodes.filter((n) => !excludedIds.has(n.id));
944
+ const layoutEdges = allEdges.filter((e) => !excludedIds.has(e.source) && !excludedIds.has(e.target));
661
945
  const hiddenNodes = allNodes.filter((n) => hiddenIds.has(n.id));
946
+ for (const n of layoutNodes) {
947
+ const grown = nodeSizes.get(n.id);
948
+ if (grown) {
949
+ n.width = grown.width;
950
+ n.height = grown.height;
951
+ }
952
+ }
662
953
  if (layoutNodes.length === 0) {
663
954
  return { repositioned: 0, resized: 0 };
664
955
  }
665
956
  const preLayoutPositions = new Map(layoutNodes.map((n) => [n.id, { ...n.position }]));
666
- const leftmostNode = layoutNodes.reduce((left, node) => node.position.x < left.position.x ? node : left);
957
+ const anchorCandidates = layoutNodes.filter((node) => !UI_ONLY_NODE_TYPES.has(node.type ?? ""));
958
+ const anchorPool = anchorCandidates.length > 0 ? anchorCandidates : layoutNodes;
959
+ const leftmostNode = anchorPool.reduce((left, node) => node.position.x < left.position.x ? node : left, anchorPool[0]);
667
960
  const originalLeftX = leftmostNode.position.x;
668
961
  const originalLeftY = leftmostNode.position.y;
669
962
  const { nodes: layoutedNodes } = await engine.layout(layoutNodes, layoutEdges, { ...DEFAULT_LAYOUT_OPTIONS, animate: false }, portResolver);
@@ -678,7 +971,11 @@ async function tidyNodesAndEdges(engine, nodes, edges, portResolver, shapeOf) {
678
971
  }
679
972
  const hiddenUpdates = propagateHiddenArtifactPositions(layoutedNodes, preLayoutPositions, hiddenNodes, allEdges, artifactChildIds);
680
973
  const allUpdated = [...layoutedNodes, ...hiddenUpdates];
681
- return applyLayoutToNodes(nodes, allUpdated, shapeOf);
974
+ const result = applyLayoutToNodes(nodes, allUpdated, shapeOf);
975
+ const nested = applyContainerLayout(nodes, childRelPositions, nodeSizes);
976
+ result.repositioned += nested.repositioned;
977
+ result.resized += nested.resized;
978
+ return result;
682
979
  }
683
980
  async function tidyFlow(filePath) {
684
981
  const { workflow, refMap } = await readFlowWorkflow(filePath);
@@ -754,4 +1051,4 @@ function regenerateNodeVariables(workflow) {
754
1051
 
755
1052
  export { UI_ONLY_NODE_TYPES, tidyFlow };
756
1053
 
757
- //# debugId=61782660AAF1BE9364756E2164756E21
1054
+ //# debugId=DEA00C408BBCA7A764756E2164756E21