@uipath/apollo-react 4.17.0 → 4.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/canvas/components/AddNodePanel/AddNodeManager.cjs +35 -21
  2. package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
  3. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.cjs +208 -0
  4. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts +20 -0
  5. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts.map +1 -0
  6. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.js +168 -0
  7. package/dist/canvas/components/AddNodePanel/AddNodeManager.js +35 -21
  8. package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +34 -4
  9. package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts +5 -1
  10. package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +1 -1
  11. package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +34 -4
  12. package/dist/canvas/components/AddNodePanel/index.d.ts +1 -1
  13. package/dist/canvas/components/AddNodePanel/index.d.ts.map +1 -1
  14. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +23 -1
  15. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
  16. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +23 -1
  17. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.cjs +0 -14
  18. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.d.ts.map +1 -1
  19. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.js +2 -16
  20. package/dist/canvas/components/LoopNode/LoopNode.cjs +38 -32
  21. package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -1
  22. package/dist/canvas/components/LoopNode/LoopNode.helpers.cjs +33 -42
  23. package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +9 -10
  24. package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +1 -1
  25. package/dist/canvas/components/LoopNode/LoopNode.helpers.js +25 -31
  26. package/dist/canvas/components/LoopNode/LoopNode.js +30 -24
  27. package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +20 -5
  28. package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +1 -1
  29. package/dist/canvas/components/LoopNode/LoopNodePreview.js +20 -5
  30. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +26 -14
  31. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
  32. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +26 -14
  33. package/dist/canvas/constants.cjs +0 -8
  34. package/dist/canvas/constants.d.ts +0 -2
  35. package/dist/canvas/constants.d.ts.map +1 -1
  36. package/dist/canvas/constants.js +1 -3
  37. package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +4 -2
  38. package/dist/canvas/hooks/useAddNodeOnConnectEnd.d.ts.map +1 -1
  39. package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +4 -2
  40. package/dist/canvas/storybook-utils/hooks/useCanvasStory.d.ts.map +1 -1
  41. package/dist/canvas/storybook-utils/manifests/node-definitions.d.ts.map +1 -1
  42. package/dist/canvas/storybook-utils/mocks/nodes.d.ts +6 -6
  43. package/dist/canvas/storybook-utils/mocks/nodes.d.ts.map +1 -1
  44. package/dist/canvas/utils/NodeUtils.cjs +41 -13
  45. package/dist/canvas/utils/NodeUtils.d.ts +12 -1
  46. package/dist/canvas/utils/NodeUtils.d.ts.map +1 -1
  47. package/dist/canvas/utils/NodeUtils.js +28 -9
  48. package/dist/canvas/utils/collapse.cjs +3 -3
  49. package/dist/canvas/utils/collapse.d.ts.map +1 -1
  50. package/dist/canvas/utils/collapse.js +1 -1
  51. package/dist/canvas/utils/container.cjs +670 -0
  52. package/dist/canvas/utils/container.d.ts +110 -0
  53. package/dist/canvas/utils/container.d.ts.map +1 -0
  54. package/dist/canvas/utils/container.js +591 -0
  55. package/dist/canvas/utils/createPreviewGraph.cjs +25 -15
  56. package/dist/canvas/utils/createPreviewGraph.d.ts +11 -7
  57. package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -1
  58. package/dist/canvas/utils/createPreviewGraph.js +25 -15
  59. package/dist/canvas/utils/createPreviewNode.cjs +24 -15
  60. package/dist/canvas/utils/createPreviewNode.d.ts +21 -7
  61. package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
  62. package/dist/canvas/utils/createPreviewNode.js +24 -15
  63. package/dist/canvas/utils/index.cjs +29 -22
  64. package/dist/canvas/utils/index.d.ts +1 -0
  65. package/dist/canvas/utils/index.d.ts.map +1 -1
  66. package/dist/canvas/utils/index.js +1 -0
  67. package/package.json +3 -3
  68. package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +0 -56
  69. package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +0 -7
  70. package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +0 -1
  71. package/dist/canvas/components/LoopNode/LoopNode.constants.js +0 -7
@@ -0,0 +1,670 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ CONTAINER_SEQUENCE_GAP_PX: ()=>CONTAINER_SEQUENCE_GAP_PX,
28
+ collectLinearDownstreamSiblings: ()=>collectLinearDownstreamSiblings,
29
+ DEFAULT_CONTAINER_HEIGHT: ()=>DEFAULT_CONTAINER_HEIGHT,
30
+ getContainerSafeArea: ()=>container_getContainerSafeArea,
31
+ DEFAULT_CONTAINER_WIDTH: ()=>DEFAULT_CONTAINER_WIDTH,
32
+ isContainerNodeManifest: ()=>isContainerNodeManifest,
33
+ DEFAULT_CONTAINER_MIN_HEIGHT: ()=>DEFAULT_CONTAINER_MIN_HEIGHT,
34
+ placeContainerNode: ()=>placeContainerNode,
35
+ getContainerNodeForEdge: ()=>getContainerNodeForEdge,
36
+ resolveContainerPreview: ()=>resolveContainerPreview,
37
+ getContainerFitGeometry: ()=>container_getContainerFitGeometry,
38
+ CONTAINER_FRAME_INSET_PX: ()=>CONTAINER_FRAME_INSET_PX,
39
+ ensureContainersFitChildren: ()=>ensureContainersFitChildren,
40
+ getNodeDimensions: ()=>container_getNodeDimensions,
41
+ DEFAULT_CONTAINER_MIN_WIDTH: ()=>DEFAULT_CONTAINER_MIN_WIDTH,
42
+ getContainerPlacement: ()=>getContainerPlacement
43
+ });
44
+ const external_constants_cjs_namespaceObject = require("../constants.cjs");
45
+ const external_NodeUtils_cjs_namespaceObject = require("./NodeUtils.cjs");
46
+ const DEFAULT_CONTAINER_WIDTH = 35 * external_constants_cjs_namespaceObject.GRID_SPACING;
47
+ const DEFAULT_CONTAINER_HEIGHT = 20 * external_constants_cjs_namespaceObject.GRID_SPACING;
48
+ const DEFAULT_CONTAINER_MIN_WIDTH = 25 * external_constants_cjs_namespaceObject.GRID_SPACING;
49
+ const DEFAULT_CONTAINER_MIN_HEIGHT = 14 * external_constants_cjs_namespaceObject.GRID_SPACING;
50
+ const CONTAINER_FRAME_INSET_PX = 10;
51
+ const CONTAINER_BODY_PADDING_PX = 2 * external_constants_cjs_namespaceObject.GRID_SPACING;
52
+ const CONTAINER_INNER_HANDLE_RAIL_WIDTH_PX = 5 * external_constants_cjs_namespaceObject.GRID_SPACING;
53
+ const CONTAINER_CHILD_SAFE_GAP_PX = external_constants_cjs_namespaceObject.GRID_SPACING;
54
+ const DEFAULT_CONTAINER_HEADER_HEIGHT_PX = 40;
55
+ const CONTAINER_SEQUENCE_GAP_PX = 3 * external_constants_cjs_namespaceObject.GRID_SPACING;
56
+ const PLACEMENT_DATA_KEY = 'placement';
57
+ function readNumericDimension(...values) {
58
+ for (const value of values){
59
+ if ('number' == typeof value && Number.isFinite(value)) return value;
60
+ if ('string' == typeof value) {
61
+ const parsedValue = Number.parseFloat(value);
62
+ if (Number.isFinite(parsedValue)) return parsedValue;
63
+ }
64
+ }
65
+ }
66
+ function container_getNodeDimensions(node, fallback = {
67
+ width: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE,
68
+ height: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE
69
+ }) {
70
+ return {
71
+ width: readNumericDimension(node.width, node.measured?.width, node.style?.width) ?? fallback.width,
72
+ height: readNumericDimension(node.height, node.measured?.height, node.style?.height) ?? fallback.height
73
+ };
74
+ }
75
+ function container_getContainerSafeArea(containerNode, fallback = {
76
+ width: DEFAULT_CONTAINER_WIDTH,
77
+ height: DEFAULT_CONTAINER_HEIGHT
78
+ }) {
79
+ const size = container_getNodeDimensions(containerNode, fallback);
80
+ const horizontalPadding = (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(CONTAINER_FRAME_INSET_PX + CONTAINER_BODY_PADDING_PX + CONTAINER_INNER_HANDLE_RAIL_WIDTH_PX + CONTAINER_CHILD_SAFE_GAP_PX);
81
+ const verticalPadding = (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(CONTAINER_FRAME_INSET_PX + CONTAINER_BODY_PADDING_PX);
82
+ const padding = {
83
+ left: horizontalPadding,
84
+ right: horizontalPadding,
85
+ top: (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(DEFAULT_CONTAINER_HEADER_HEIGHT_PX + verticalPadding),
86
+ bottom: verticalPadding
87
+ };
88
+ return {
89
+ x: padding.left,
90
+ y: padding.top,
91
+ width: Math.max(0, size.width - padding.left - padding.right),
92
+ height: Math.max(0, size.height - padding.top - padding.bottom),
93
+ padding
94
+ };
95
+ }
96
+ function container_getContainerFitGeometry() {
97
+ const padding = container_getContainerSafeArea({
98
+ width: DEFAULT_CONTAINER_WIDTH,
99
+ height: DEFAULT_CONTAINER_HEIGHT
100
+ }).padding;
101
+ return {
102
+ minWidth: DEFAULT_CONTAINER_MIN_WIDTH,
103
+ minHeight: DEFAULT_CONTAINER_MIN_HEIGHT,
104
+ padding: {
105
+ right: padding.right,
106
+ bottom: padding.bottom
107
+ }
108
+ };
109
+ }
110
+ function isContainerNodeManifest(manifest) {
111
+ return manifest?.display.shape === 'container';
112
+ }
113
+ function getAncestorContainerIds(containerId, nodesById) {
114
+ const ancestors = [];
115
+ let parentId = nodesById.get(containerId)?.parentId;
116
+ while(parentId){
117
+ ancestors.push(parentId);
118
+ parentId = nodesById.get(parentId)?.parentId;
119
+ }
120
+ return ancestors;
121
+ }
122
+ function getContainerDepth(containerId, nodesById) {
123
+ let depth = 0;
124
+ let parentId = nodesById.get(containerId)?.parentId;
125
+ while(parentId){
126
+ depth += 1;
127
+ parentId = nodesById.get(parentId)?.parentId;
128
+ }
129
+ return depth;
130
+ }
131
+ function withNodeDimensions(node, size) {
132
+ return {
133
+ ...node,
134
+ width: size.width,
135
+ height: size.height,
136
+ style: {
137
+ ...node.style,
138
+ width: size.width,
139
+ height: size.height
140
+ }
141
+ };
142
+ }
143
+ function ensureContainersFitChildren(nodes, { containerIds, getContainerFitGeometry: resolveContainerFitGeometry, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions, ignoredNodeTypes = [], includeAncestors = true } = {}) {
144
+ let nextNodes = nodes;
145
+ const changes = [];
146
+ const ignoredTypes = new Set(ignoredNodeTypes);
147
+ const nodesById = new Map(nextNodes.map((node)=>[
148
+ node.id,
149
+ node
150
+ ]));
151
+ const idsToFit = new Set();
152
+ if (containerIds) for (const id of containerIds)idsToFit.add(id);
153
+ else for (const node of nextNodes)if (node.parentId) idsToFit.add(node.parentId);
154
+ if (includeAncestors) for (const id of Array.from(idsToFit))for (const ancestorId of getAncestorContainerIds(id, nodesById))idsToFit.add(ancestorId);
155
+ const orderedContainerIds = Array.from(idsToFit).sort((left, right)=>getContainerDepth(right, nodesById) - getContainerDepth(left, nodesById));
156
+ for (const containerId of orderedContainerIds){
157
+ const containerNode = nextNodes.find((node)=>node.id === containerId);
158
+ if (!containerNode) continue;
159
+ const geometry = resolveContainerFitGeometry?.(containerNode);
160
+ if (!geometry) continue;
161
+ const currentSize = resolveNodeDimensions(containerNode);
162
+ const padding = geometry.padding ?? {};
163
+ let requiredWidth = geometry.minWidth;
164
+ let requiredHeight = geometry.minHeight;
165
+ for (const childNode of nextNodes){
166
+ if (childNode.id === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID || childNode.hidden || childNode.parentId !== containerId || ignoredTypes.has(childNode.type ?? '')) continue;
167
+ const childSize = resolveNodeDimensions(childNode);
168
+ requiredWidth = Math.max(requiredWidth, childNode.position.x + childSize.width + (padding.right ?? 0));
169
+ requiredHeight = Math.max(requiredHeight, childNode.position.y + childSize.height + (padding.bottom ?? 0));
170
+ }
171
+ const nextSize = {
172
+ width: Math.max(currentSize.width, (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(requiredWidth)),
173
+ height: Math.max(currentSize.height, (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(requiredHeight))
174
+ };
175
+ if (nextSize.width !== currentSize.width || nextSize.height !== currentSize.height) {
176
+ nextNodes = nextNodes.map((node)=>node.id === containerId ? withNodeDimensions(node, nextSize) : node);
177
+ nodesById.set(containerId, nextNodes.find((node)=>node.id === containerId));
178
+ changes.push({
179
+ containerId,
180
+ previousSize: currentSize,
181
+ nextSize
182
+ });
183
+ }
184
+ }
185
+ return {
186
+ nodes: nextNodes,
187
+ changes
188
+ };
189
+ }
190
+ function getSafeArea(containerNode, safeArea) {
191
+ return safeArea ?? container_getContainerSafeArea(containerNode);
192
+ }
193
+ function clampTopLeftToSafeArea(position, safeArea, nodeSize) {
194
+ const maxX = safeArea.x + Math.max(0, safeArea.width - nodeSize.width);
195
+ const maxY = safeArea.y + Math.max(0, safeArea.height - nodeSize.height);
196
+ return {
197
+ x: (0, external_NodeUtils_cjs_namespaceObject.clamp)(position.x, safeArea.x, maxX),
198
+ y: (0, external_NodeUtils_cjs_namespaceObject.clamp)(position.y, safeArea.y, maxY)
199
+ };
200
+ }
201
+ function clampTopToSafeArea(top, safeArea, nodeSize) {
202
+ const maxY = safeArea.y + Math.max(0, safeArea.height - nodeSize.height);
203
+ return (0, external_NodeUtils_cjs_namespaceObject.clamp)(top, safeArea.y, maxY);
204
+ }
205
+ function rangesOverlap(startA, endA, startB, endB) {
206
+ return startA < endB && endA > startB;
207
+ }
208
+ function centerOnContainerRail(containerSize, safeArea, nodeSize) {
209
+ const railY = (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(containerSize.height / 2 - nodeSize.height / 2);
210
+ const maxY = safeArea.y + Math.max(0, safeArea.height - nodeSize.height);
211
+ return {
212
+ x: Math.max(safeArea.x, (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(safeArea.x + (safeArea.width - nodeSize.width) / 2)),
213
+ y: (0, external_NodeUtils_cjs_namespaceObject.clamp)(railY, safeArea.y, maxY)
214
+ };
215
+ }
216
+ function getLocalNodePosition(node, containerNode, nodes) {
217
+ if (!node || node.id === containerNode.id) return null;
218
+ if (node.parentId === containerNode.id) return node.position;
219
+ const containerPosition = (0, external_NodeUtils_cjs_namespaceObject.getAbsolutePosition)(containerNode, nodes);
220
+ const nodePosition = node.parentId ? (0, external_NodeUtils_cjs_namespaceObject.getAbsolutePosition)(node, nodes) : node.position;
221
+ return {
222
+ x: nodePosition.x - containerPosition.x,
223
+ y: nodePosition.y - containerPosition.y
224
+ };
225
+ }
226
+ function getPlacementDirection(sourcePosition, targetPosition) {
227
+ if (!sourcePosition || !targetPosition) return sourcePosition ? 'right' : 'left';
228
+ return targetPosition.x >= sourcePosition.x ? 'right' : 'left';
229
+ }
230
+ function getSiblingNodes(containerId, nodes, insertedNodeId) {
231
+ return nodes.filter((node)=>node.id !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID && node.id !== insertedNodeId && node.parentId === containerId);
232
+ }
233
+ function resolveSequenceTopLeft({ sourceNode, targetNode, containerNode, nodes, safeArea, previewNodeSize, gap, getNodeDimensions }) {
234
+ const sourcePosition = getLocalNodePosition(sourceNode, containerNode, nodes);
235
+ const targetPosition = getLocalNodePosition(targetNode, containerNode, nodes);
236
+ const sourceSize = sourceNode ? getNodeDimensions(sourceNode) : void 0;
237
+ const targetSize = targetNode ? getNodeDimensions(targetNode) : void 0;
238
+ if (sourcePosition && sourceSize && targetPosition) {
239
+ const sourceRight = sourcePosition.x + sourceSize.width;
240
+ const targetLeft = targetPosition.x;
241
+ const centerX = targetLeft - sourceRight >= previewNodeSize.width + 2 * gap ? sourceRight + (targetLeft - sourceRight) / 2 : sourceRight + gap + previewNodeSize.width / 2;
242
+ return {
243
+ x: centerX - previewNodeSize.width / 2,
244
+ y: sourcePosition.y + sourceSize.height / 2 - previewNodeSize.height / 2
245
+ };
246
+ }
247
+ if (sourcePosition && sourceSize) return {
248
+ x: sourcePosition.x + sourceSize.width + gap,
249
+ y: sourcePosition.y + sourceSize.height / 2 - previewNodeSize.height / 2
250
+ };
251
+ if (targetPosition && targetSize) return {
252
+ x: targetPosition.x - previewNodeSize.width - gap,
253
+ y: targetPosition.y + targetSize.height / 2 - previewNodeSize.height / 2
254
+ };
255
+ return {
256
+ x: safeArea.x + safeArea.width / 2 - previewNodeSize.width / 2,
257
+ y: safeArea.y + safeArea.height / 2 - previewNodeSize.height / 2
258
+ };
259
+ }
260
+ function getContainerNodeForEdge(sourceNode, targetNode, nodes) {
261
+ if (sourceNode.parentId === targetNode.id) return targetNode;
262
+ if (targetNode.parentId === sourceNode.id) return sourceNode;
263
+ if (sourceNode.parentId && sourceNode.parentId === targetNode.parentId) return nodes.find((node)=>node.id === sourceNode.parentId) ?? null;
264
+ return null;
265
+ }
266
+ function handleMatches(edgeHandleId, handleId) {
267
+ return (edgeHandleId ?? external_constants_cjs_namespaceObject.DEFAULT_SOURCE_HANDLE_ID) === handleId;
268
+ }
269
+ function getOutgoingEdges(sourceNodeId, sourceHandleId, edges) {
270
+ return edges.filter((edge)=>edge.source !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID && edge.target !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID && edge.source === sourceNodeId && handleMatches(edge.sourceHandle, sourceHandleId));
271
+ }
272
+ function getSingleOutgoingEdge(sourceNodeId, sourceHandleId, edges) {
273
+ const outgoingEdges = getOutgoingEdges(sourceNodeId, sourceHandleId, edges);
274
+ return 1 === outgoingEdges.length ? outgoingEdges[0] : null;
275
+ }
276
+ function isPreviewGraphEdge(edge) {
277
+ return edge.source === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID || edge.target === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID;
278
+ }
279
+ function bucketInScopeEdgesBySource({ edges, nodesById, parentId, isSequenceEdge }) {
280
+ const bySource = new Map();
281
+ for (const edge of edges){
282
+ if (isPreviewGraphEdge(edge)) continue;
283
+ if (isSequenceEdge && !isSequenceEdge(edge)) continue;
284
+ const targetIsParent = void 0 !== parentId && edge.target === parentId;
285
+ const targetIsSibling = nodesById.get(edge.target)?.parentId === parentId;
286
+ if (!targetIsParent && !targetIsSibling) continue;
287
+ const bucket = bySource.get(edge.source);
288
+ if (bucket) bucket.push(edge);
289
+ else bySource.set(edge.source, [
290
+ edge
291
+ ]);
292
+ }
293
+ return bySource;
294
+ }
295
+ function collectLinearDownstreamSiblings({ startNodeId, parentId, nodes, edges, isSequenceEdge, getNextNodeId }) {
296
+ if (!startNodeId || startNodeId === parentId) return [];
297
+ const nodesById = new Map(nodes.map((node)=>[
298
+ node.id,
299
+ node
300
+ ]));
301
+ const inScopeEdgesBySource = bucketInScopeEdgesBySource({
302
+ edges,
303
+ nodesById,
304
+ parentId,
305
+ isSequenceEdge
306
+ });
307
+ const collectedIds = [];
308
+ const visitedIds = new Set();
309
+ let currentNodeId = startNodeId;
310
+ while(!visitedIds.has(currentNodeId)){
311
+ const currentNode = nodesById.get(currentNodeId);
312
+ if (!currentNode || currentNode.parentId !== parentId) break;
313
+ collectedIds.push(currentNodeId);
314
+ visitedIds.add(currentNodeId);
315
+ let next = getNextNodeId ? getNextNodeId({
316
+ nodeId: currentNodeId,
317
+ edges,
318
+ nodesById,
319
+ parentId
320
+ }) : void 0;
321
+ if (void 0 === next) {
322
+ const outgoing = inScopeEdgesBySource.get(currentNodeId) ?? [];
323
+ next = 1 === outgoing.length ? outgoing[0].target : null;
324
+ }
325
+ if (!next || next === parentId) break;
326
+ currentNodeId = next;
327
+ }
328
+ return collectedIds;
329
+ }
330
+ function resolveInsertPreview({ source, sourceHandleType, reactFlowInstance, isContainerNode, getContainerSafeArea, previewNodeSize, gap, getNodeDimensions }) {
331
+ if ('source' !== sourceHandleType || !source.handleId) return null;
332
+ const replacedEdge = getSingleOutgoingEdge(source.nodeId, source.handleId, reactFlowInstance.getEdges());
333
+ if (!replacedEdge) return null;
334
+ const sourceNode = reactFlowInstance.getNode(replacedEdge.source);
335
+ const targetNode = reactFlowInstance.getNode(replacedEdge.target);
336
+ const nodes = reactFlowInstance.getNodes();
337
+ const containerNode = getContainerNodeForEdge(sourceNode, targetNode, nodes);
338
+ if (!containerNode) return null;
339
+ if (isContainerNode && !isContainerNode(containerNode)) return null;
340
+ const containerPlacement = getPreviewPlacement({
341
+ sourceNode,
342
+ targetNode,
343
+ containerNode,
344
+ nodes,
345
+ safeArea: getContainerSafeArea?.(containerNode),
346
+ previewNodeSize,
347
+ gap,
348
+ getNodeDimensions
349
+ });
350
+ const placement = {
351
+ containerId: containerPlacement.containerId,
352
+ sourceNodeId: sourceNode.id,
353
+ targetNodeId: targetNode.id,
354
+ mode: 'sequence'
355
+ };
356
+ return {
357
+ position: containerPlacement.centerPosition,
358
+ positionMode: 'center',
359
+ data: {
360
+ originalEdge: replacedEdge,
361
+ [PLACEMENT_DATA_KEY]: placement
362
+ },
363
+ target: {
364
+ nodeId: replacedEdge.target,
365
+ handleId: replacedEdge.targetHandle
366
+ },
367
+ containerId: containerPlacement.containerId
368
+ };
369
+ }
370
+ function resolveAppendPreview({ source, sourceHandleType, reactFlowInstance, ...options }) {
371
+ if ('source' !== sourceHandleType || !source.handleId) return null;
372
+ const sourceNode = reactFlowInstance.getNode(source.nodeId);
373
+ if (!sourceNode?.parentId) return null;
374
+ const outgoingEdges = getOutgoingEdges(source.nodeId, source.handleId, reactFlowInstance.getEdges());
375
+ if (outgoingEdges.length > 0) return null;
376
+ const nodes = reactFlowInstance.getNodes();
377
+ const containerNode = nodes.find((node)=>node.id === sourceNode.parentId);
378
+ if (options.isContainerNode && !options.isContainerNode(containerNode)) return null;
379
+ const continuationTarget = options.getContainerContinuationTarget?.({
380
+ containerNode,
381
+ sourceNode,
382
+ source,
383
+ reactFlowInstance
384
+ });
385
+ if (!continuationTarget) return null;
386
+ const targetNode = continuationTarget.nodeId === containerNode.id ? containerNode : reactFlowInstance.getNode(continuationTarget.nodeId);
387
+ const containerPlacement = getPreviewPlacement({
388
+ sourceNode,
389
+ targetNode,
390
+ containerNode,
391
+ nodes,
392
+ safeArea: options.getContainerSafeArea?.(containerNode),
393
+ previewNodeSize: options.previewNodeSize,
394
+ gap: options.gap,
395
+ avoidSiblings: options.avoidSiblings ?? true,
396
+ getNodeDimensions: options.getNodeDimensions
397
+ });
398
+ const placement = {
399
+ containerId: containerPlacement.containerId,
400
+ sourceNodeId: sourceNode.id,
401
+ targetNodeId: continuationTarget.nodeId,
402
+ mode: 'sequence'
403
+ };
404
+ return {
405
+ position: containerPlacement.centerPosition,
406
+ positionMode: 'center',
407
+ data: {
408
+ [PLACEMENT_DATA_KEY]: placement
409
+ },
410
+ target: continuationTarget,
411
+ containerId: containerPlacement.containerId
412
+ };
413
+ }
414
+ function resolveContainerPreview({ source, sourceHandleType, reactFlowInstance, ...options }) {
415
+ return resolveInsertPreview({
416
+ source,
417
+ sourceHandleType,
418
+ reactFlowInstance,
419
+ ...options
420
+ }) ?? resolveAppendPreview({
421
+ source,
422
+ sourceHandleType,
423
+ reactFlowInstance,
424
+ ...options
425
+ });
426
+ }
427
+ function getPreviewPlacement({ sourceNode, targetNode, containerNode, nodes, containerAbsolutePosition = (0, external_NodeUtils_cjs_namespaceObject.getAbsolutePosition)(containerNode, nodes), safeArea, previewNodeSize = {
428
+ width: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE,
429
+ height: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE
430
+ }, gap = CONTAINER_SEQUENCE_GAP_PX, avoidSiblings = false, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions }) {
431
+ const resolvedSafeArea = getSafeArea(containerNode, safeArea);
432
+ const sourcePosition = getLocalNodePosition(sourceNode, containerNode, nodes);
433
+ const targetPosition = getLocalNodePosition(targetNode, containerNode, nodes);
434
+ const direction = getPlacementDirection(sourcePosition, targetPosition);
435
+ const initialPosition = resolveSequenceTopLeft({
436
+ sourceNode,
437
+ targetNode,
438
+ containerNode,
439
+ nodes,
440
+ safeArea: resolvedSafeArea,
441
+ previewNodeSize,
442
+ gap,
443
+ getNodeDimensions: resolveNodeDimensions
444
+ });
445
+ const collisionPosition = avoidSiblings ? (0, external_NodeUtils_cjs_namespaceObject.getNonOverlappingPositionForDirection)(getSiblingNodes(containerNode.id, nodes), initialPosition, previewNodeSize, direction, gap) : initialPosition;
446
+ const position = clampTopLeftToSafeArea(collisionPosition, resolvedSafeArea, previewNodeSize);
447
+ return {
448
+ containerId: containerNode.id,
449
+ centerPosition: {
450
+ x: containerAbsolutePosition.x + position.x + previewNodeSize.width / 2,
451
+ y: containerAbsolutePosition.y + position.y + previewNodeSize.height / 2
452
+ }
453
+ };
454
+ }
455
+ function getNodeCenterY(position, nodeSize) {
456
+ return position.y + nodeSize.height / 2;
457
+ }
458
+ function getInsertedPosition({ sourceNode, targetNode, insertedNode, containerNode, nodes, safeArea, insertedNodeSize, gap, getNodeDimensions }) {
459
+ const sourcePosition = getLocalNodePosition(sourceNode, containerNode, nodes);
460
+ const targetPosition = getLocalNodePosition(targetNode, containerNode, nodes);
461
+ const sourceSize = sourceNode ? getNodeDimensions(sourceNode) : void 0;
462
+ const targetSize = targetNode ? getNodeDimensions(targetNode) : void 0;
463
+ const sourceIsContainer = sourceNode?.id === containerNode.id;
464
+ const targetIsContainer = targetNode?.id === containerNode.id;
465
+ if (sourcePosition && sourceSize && !sourceIsContainer) return {
466
+ x: Math.max(safeArea.x, (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(sourcePosition.x + sourceSize.width + gap)),
467
+ y: clampTopToSafeArea((0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(getNodeCenterY(sourcePosition, sourceSize) - insertedNodeSize.height / 2), safeArea, insertedNodeSize)
468
+ };
469
+ if (targetPosition && targetSize && !targetIsContainer) return {
470
+ x: Math.max(safeArea.x, (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(targetPosition.x - insertedNodeSize.width - gap)),
471
+ y: clampTopToSafeArea((0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(getNodeCenterY(targetPosition, targetSize) - insertedNodeSize.height / 2), safeArea, insertedNodeSize)
472
+ };
473
+ return {
474
+ x: Math.max(safeArea.x, (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(insertedNode.position.x)),
475
+ y: clampTopToSafeArea((0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(insertedNode.position.y), safeArea, insertedNodeSize)
476
+ };
477
+ }
478
+ function getNodeDepth(node, nodesById) {
479
+ let depth = 0;
480
+ let parentId = node?.parentId;
481
+ while(parentId){
482
+ depth += 1;
483
+ parentId = nodesById.get(parentId)?.parentId;
484
+ }
485
+ return depth;
486
+ }
487
+ function sortContainerSizeChanges(changes, nodes) {
488
+ const nodesById = new Map(nodes.map((node)=>[
489
+ node.id,
490
+ node
491
+ ]));
492
+ return [
493
+ ...changes
494
+ ].sort((left, right)=>{
495
+ const leftNode = nodesById.get(left.containerId);
496
+ const rightNode = nodesById.get(right.containerId);
497
+ const depthDifference = getNodeDepth(rightNode, nodesById) - getNodeDepth(leftNode, nodesById);
498
+ if (0 !== depthDifference) return depthDifference;
499
+ if (leftNode.parentId === rightNode.parentId) return leftNode.position.x - rightNode.position.x;
500
+ return 0;
501
+ });
502
+ }
503
+ function pushSiblingsAfterContainerGrowth({ nodes, changes, getNodeDimensions, gap }) {
504
+ let shifted = false;
505
+ let nextNodes = nodes;
506
+ for (const change of sortContainerSizeChanges(changes, nextNodes)){
507
+ const widthDelta = change.nextSize.width - change.previousSize.width;
508
+ const heightDelta = change.nextSize.height - change.previousSize.height;
509
+ if (widthDelta <= 0 && heightDelta <= 0) continue;
510
+ const containerNode = nextNodes.find((node)=>node.id === change.containerId);
511
+ const oldRight = containerNode.position.x + change.previousSize.width;
512
+ const newRight = containerNode.position.x + change.nextSize.width;
513
+ const oldBottom = containerNode.position.y + change.previousSize.height;
514
+ const newBottom = containerNode.position.y + change.nextSize.height;
515
+ const containerLeft = containerNode.position.x;
516
+ const containerRight = containerNode.position.x + Math.max(change.previousSize.width, change.nextSize.width);
517
+ const containerTop = containerNode.position.y;
518
+ const containerBottom = containerNode.position.y + Math.max(change.previousSize.height, change.nextSize.height);
519
+ nextNodes = nextNodes.map((node)=>{
520
+ if (node.id === containerNode.id || node.parentId !== containerNode.parentId) return node;
521
+ const nodeSize = getNodeDimensions(node);
522
+ let nextX = node.position.x;
523
+ let nextY = node.position.y;
524
+ if (widthDelta > 0 && node.position.x >= oldRight) {
525
+ const verticallyOverlaps = rangesOverlap(node.position.y, node.position.y + nodeSize.height, containerTop, containerBottom);
526
+ if (verticallyOverlaps) nextX = Math.max(node.position.x + widthDelta, (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(newRight + gap));
527
+ }
528
+ if (heightDelta > 0 && node.position.y >= oldBottom) {
529
+ const horizontallyOverlaps = rangesOverlap(node.position.x, node.position.x + nodeSize.width, containerLeft, containerRight);
530
+ if (horizontallyOverlaps) nextY = Math.max(node.position.y + heightDelta, (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(newBottom + gap));
531
+ }
532
+ if (nextX === node.position.x && nextY === node.position.y) return node;
533
+ shifted = true;
534
+ return {
535
+ ...node,
536
+ position: {
537
+ x: nextX,
538
+ y: nextY
539
+ }
540
+ };
541
+ });
542
+ }
543
+ return {
544
+ nodes: nextNodes,
545
+ shifted
546
+ };
547
+ }
548
+ function fitContainersAndPushSiblings({ nodes, containerIds, getContainerFitGeometry, getNodeDimensions, gap }) {
549
+ let nextNodes = nodes;
550
+ for(let iteration = 0; iteration < 10; iteration += 1){
551
+ const fitResult = ensureContainersFitChildren(nextNodes, {
552
+ containerIds,
553
+ getContainerFitGeometry,
554
+ getNodeDimensions,
555
+ includeAncestors: true
556
+ });
557
+ nextNodes = fitResult.nodes;
558
+ if (0 === fitResult.changes.length) break;
559
+ const pushResult = pushSiblingsAfterContainerGrowth({
560
+ nodes: nextNodes,
561
+ changes: fitResult.changes,
562
+ getNodeDimensions,
563
+ gap
564
+ });
565
+ nextNodes = pushResult.nodes;
566
+ if (!pushResult.shifted) break;
567
+ }
568
+ return nextNodes;
569
+ }
570
+ function getContainerPlacement(previewNode) {
571
+ const placement = previewNode.data?.[PLACEMENT_DATA_KEY];
572
+ if (!placement) return null;
573
+ if (previewNode.parentId && placement.containerId !== previewNode.parentId) return null;
574
+ return placement;
575
+ }
576
+ function placeContainerNode({ nodes, insertedNode, placement, safeArea, getContainerFitGeometry: resolveContainerFitGeometry = container_getContainerFitGeometry, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions, gap = CONTAINER_SEQUENCE_GAP_PX, downstreamNodeIds, edges }) {
577
+ const containerNode = nodes.find((node)=>node.id === placement.containerId);
578
+ const nodesById = new Map(nodes.map((node)=>[
579
+ node.id,
580
+ node
581
+ ]));
582
+ const insertedSize = resolveNodeDimensions(insertedNode);
583
+ const resolvedSafeArea = getSafeArea(containerNode, safeArea);
584
+ const positionedNode = 'first-child' === placement.mode ? {
585
+ ...insertedNode,
586
+ position: centerOnContainerRail(resolveNodeDimensions(containerNode), resolvedSafeArea, insertedSize)
587
+ } : {
588
+ ...insertedNode,
589
+ position: getInsertedPosition({
590
+ sourceNode: placement.sourceNodeId ? nodesById.get(placement.sourceNodeId) : void 0,
591
+ targetNode: placement.targetNodeId ? nodesById.get(placement.targetNodeId) : void 0,
592
+ insertedNode,
593
+ containerNode,
594
+ nodes,
595
+ safeArea: resolvedSafeArea,
596
+ insertedNodeSize: insertedSize,
597
+ gap,
598
+ getNodeDimensions: resolveNodeDimensions
599
+ })
600
+ };
601
+ const targetNode = placement.targetNodeId && placement.targetNodeId !== placement.containerId ? nodesById.get(placement.targetNodeId) : void 0;
602
+ const fallbackTargetIds = placement.targetNodeId && placement.targetNodeId !== placement.containerId ? [
603
+ placement.targetNodeId
604
+ ] : [];
605
+ const idsToShift = new Set(downstreamNodeIds ?? (edges ? collectLinearDownstreamSiblings({
606
+ startNodeId: placement.targetNodeId,
607
+ parentId: placement.containerId,
608
+ nodes,
609
+ edges
610
+ }) : fallbackTargetIds));
611
+ const requiredTargetLeft = positionedNode.position.x + insertedSize.width + gap;
612
+ const downstreamShift = targetNode && targetNode.position.x < requiredTargetLeft ? (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(requiredTargetLeft - targetNode.position.x) : 0;
613
+ const positionedNodes = nodes.map((node)=>{
614
+ if (node.id === insertedNode.id) return positionedNode;
615
+ if (downstreamShift > 0 && idsToShift.has(node.id)) return {
616
+ ...node,
617
+ position: {
618
+ ...node.position,
619
+ x: node.position.x + downstreamShift
620
+ }
621
+ };
622
+ return node;
623
+ });
624
+ return fitContainersAndPushSiblings({
625
+ nodes: positionedNodes,
626
+ containerIds: [
627
+ placement.containerId
628
+ ],
629
+ getContainerFitGeometry: resolveContainerFitGeometry,
630
+ getNodeDimensions: resolveNodeDimensions,
631
+ gap
632
+ });
633
+ }
634
+ exports.CONTAINER_FRAME_INSET_PX = __webpack_exports__.CONTAINER_FRAME_INSET_PX;
635
+ exports.CONTAINER_SEQUENCE_GAP_PX = __webpack_exports__.CONTAINER_SEQUENCE_GAP_PX;
636
+ exports.DEFAULT_CONTAINER_HEIGHT = __webpack_exports__.DEFAULT_CONTAINER_HEIGHT;
637
+ exports.DEFAULT_CONTAINER_MIN_HEIGHT = __webpack_exports__.DEFAULT_CONTAINER_MIN_HEIGHT;
638
+ exports.DEFAULT_CONTAINER_MIN_WIDTH = __webpack_exports__.DEFAULT_CONTAINER_MIN_WIDTH;
639
+ exports.DEFAULT_CONTAINER_WIDTH = __webpack_exports__.DEFAULT_CONTAINER_WIDTH;
640
+ exports.collectLinearDownstreamSiblings = __webpack_exports__.collectLinearDownstreamSiblings;
641
+ exports.ensureContainersFitChildren = __webpack_exports__.ensureContainersFitChildren;
642
+ exports.getContainerFitGeometry = __webpack_exports__.getContainerFitGeometry;
643
+ exports.getContainerNodeForEdge = __webpack_exports__.getContainerNodeForEdge;
644
+ exports.getContainerPlacement = __webpack_exports__.getContainerPlacement;
645
+ exports.getContainerSafeArea = __webpack_exports__.getContainerSafeArea;
646
+ exports.getNodeDimensions = __webpack_exports__.getNodeDimensions;
647
+ exports.isContainerNodeManifest = __webpack_exports__.isContainerNodeManifest;
648
+ exports.placeContainerNode = __webpack_exports__.placeContainerNode;
649
+ exports.resolveContainerPreview = __webpack_exports__.resolveContainerPreview;
650
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
651
+ "CONTAINER_FRAME_INSET_PX",
652
+ "CONTAINER_SEQUENCE_GAP_PX",
653
+ "DEFAULT_CONTAINER_HEIGHT",
654
+ "DEFAULT_CONTAINER_MIN_HEIGHT",
655
+ "DEFAULT_CONTAINER_MIN_WIDTH",
656
+ "DEFAULT_CONTAINER_WIDTH",
657
+ "collectLinearDownstreamSiblings",
658
+ "ensureContainersFitChildren",
659
+ "getContainerFitGeometry",
660
+ "getContainerNodeForEdge",
661
+ "getContainerPlacement",
662
+ "getContainerSafeArea",
663
+ "getNodeDimensions",
664
+ "isContainerNodeManifest",
665
+ "placeContainerNode",
666
+ "resolveContainerPreview"
667
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
668
+ Object.defineProperty(exports, '__esModule', {
669
+ value: true
670
+ });