@html-graph/html-graph 8.5.0 → 8.6.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.
@@ -1,20 +1,20 @@
1
- var Ye = Object.defineProperty;
2
- var Xe = (r, e, t) => e in r ? Ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var i = (r, e, t) => Xe(r, typeof e != "symbol" ? e + "" : e, t);
1
+ var Ke = Object.defineProperty;
2
+ var Qe = (r, e, t) => e in r ? Ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var i = (r, e, t) => Qe(r, typeof e != "symbol" ? e + "" : e, t);
4
4
  var D = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(D || {});
5
- const Ge = () => {
5
+ const Ze = () => {
6
6
  const r = document.createElement("div");
7
7
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
8
- }, je = () => {
8
+ }, Je = () => {
9
9
  const r = document.createElement("div");
10
10
  return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
11
- }, qe = (r) => {
11
+ }, _e = (r) => {
12
12
  r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden";
13
13
  };
14
- class xe {
14
+ class Ee {
15
15
  constructor(e, t, s) {
16
- i(this, "host", Ge());
17
- i(this, "container", je());
16
+ i(this, "host", Ze());
17
+ i(this, "container", Je());
18
18
  i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
19
19
  i(this, "attachedNodeIds", /* @__PURE__ */ new Set());
20
20
  i(this, "applyTransform", () => {
@@ -25,7 +25,7 @@ class xe {
25
25
  }
26
26
  attachNode(e) {
27
27
  const t = this.graphStore.getNode(e);
28
- qe(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
28
+ _e(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
29
29
  }
30
30
  detachNode(e) {
31
31
  const t = this.graphStore.getNode(e);
@@ -91,7 +91,7 @@ class xe {
91
91
  };
92
92
  }
93
93
  }
94
- class Ke {
94
+ class et {
95
95
  constructor(e) {
96
96
  i(this, "xFrom", 1 / 0);
97
97
  i(this, "yFrom", 1 / 0);
@@ -111,7 +111,7 @@ class Ke {
111
111
  return h <= this.xTo && d >= this.xFrom && c <= this.yTo && g >= this.yFrom;
112
112
  }
113
113
  }
114
- class Qe {
114
+ class tt {
115
115
  constructor(e, t, s, o) {
116
116
  i(this, "attachedNodes", /* @__PURE__ */ new Set());
117
117
  i(this, "attachedEdges", /* @__PURE__ */ new Set());
@@ -135,7 +135,7 @@ class Qe {
135
135
  this.handleAttachEdge(a);
136
136
  });
137
137
  });
138
- this.htmlView = e, this.graphStore = t, this.trigger = s, this.params = o, this.renderingBox = new Ke(this.graphStore), this.trigger.subscribe(this.updateViewport);
138
+ this.htmlView = e, this.graphStore = t, this.trigger = s, this.params = o, this.renderingBox = new et(this.graphStore), this.trigger.subscribe(this.updateViewport);
139
139
  }
140
140
  attachNode(e) {
141
141
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -189,7 +189,7 @@ class Qe {
189
189
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
190
190
  }
191
191
  }
192
- class Ze {
192
+ class rt {
193
193
  constructor(e, t) {
194
194
  i(this, "deferredNodes", /* @__PURE__ */ new Set());
195
195
  i(this, "deferredEdges", /* @__PURE__ */ new Set());
@@ -243,7 +243,7 @@ class Ze {
243
243
  this.isEdgeValid(e) && (this.deferredEdges.delete(e), this.htmlView.attachEdge(e));
244
244
  }
245
245
  }
246
- class Q {
246
+ class K {
247
247
  constructor() {
248
248
  i(this, "callbacks", /* @__PURE__ */ new Set());
249
249
  }
@@ -259,215 +259,64 @@ class Q {
259
259
  });
260
260
  }
261
261
  }
262
- const E = () => {
263
- const r = new Q();
262
+ const S = () => {
263
+ const r = new K();
264
264
  return [r, r];
265
265
  };
266
- class G {
267
- constructor(e) {
268
- i(this, "counter", 0);
269
- this.checkExists = e;
270
- }
271
- create(e) {
272
- if (e !== void 0)
273
- return e;
274
- for (; this.checkExists(this.counter); )
275
- this.counter++;
276
- return this.counter;
277
- }
278
- reset() {
279
- this.counter = 0;
280
- }
281
- }
282
- class Ee {
283
- constructor(e, t, s, o, n, a) {
284
- i(this, "nodeIdGenerator", new G(
285
- (e) => this.graphStore.hasNode(e)
286
- ));
287
- i(this, "portIdGenerator", new G(
288
- (e) => this.graphStore.hasPort(e)
289
- ));
290
- i(this, "edgeIdGenerator", new G(
291
- (e) => this.graphStore.hasEdge(e)
292
- ));
293
- i(this, "onAfterNodeAdded", (e) => {
294
- this.htmlView.attachNode(e);
295
- });
296
- i(this, "onAfterNodeUpdated", (e) => {
297
- this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((t) => {
298
- this.htmlView.renderEdge(t);
299
- });
300
- });
301
- i(this, "onAfterNodePriorityUpdated", (e) => {
302
- this.htmlView.updateNodePriority(e);
303
- });
304
- i(this, "onBeforeNodeRemoved", (e) => {
305
- this.graphStore.getNodePortIds(e).forEach((t) => {
306
- this.unmarkPort(t);
307
- }), this.htmlView.detachNode(e);
308
- });
309
- i(this, "onAfterPortUpdated", (e) => {
310
- this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
311
- this.htmlView.renderEdge(t);
312
- });
313
- });
314
- i(this, "onBeforePortUnmarked", (e) => {
315
- this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
316
- this.removeEdge(t);
317
- });
318
- });
319
- i(this, "onAfterEdgeAdded", (e) => {
320
- this.htmlView.attachEdge(e);
321
- });
322
- i(this, "onAfterEdgeShapeUpdated", (e) => {
323
- this.htmlView.updateEdgeShape(e);
324
- });
325
- i(this, "onAfterEdgeUpdated", (e) => {
326
- this.htmlView.renderEdge(e);
327
- });
328
- i(this, "onAfterEdgePriorityUpdated", (e) => {
329
- this.htmlView.updateEdgePriority(e);
330
- });
331
- i(this, "onBeforeEdgeRemoved", (e) => {
332
- this.htmlView.detachEdge(e);
333
- });
334
- i(this, "onBeforeClear", () => {
335
- this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
336
- });
337
- i(this, "onBeforeDestroyEmitter");
266
+ class Se {
267
+ constructor(e, t, s, o) {
268
+ i(this, "beforeDestroyEmitter");
338
269
  i(this, "destroyed", !1);
339
- /**
340
- * emits event just before destruction of canvas
341
- */
342
270
  i(this, "onBeforeDestroy");
343
- this.graph = e, this.viewport = t, this.graphStore = s, this.viewportStore = o, this.htmlView = n, this.params = a, this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
344
- this.onAfterNodePriorityUpdated
345
- ), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
346
- this.onAfterEdgeShapeUpdated
347
- ), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
348
- this.onAfterEdgePriorityUpdated
349
- ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = E();
271
+ this.graph = e, this.viewport = t, this.graphController = s, this.viewportController = o, [this.beforeDestroyEmitter, this.onBeforeDestroy] = S();
350
272
  }
351
- /**
352
- * adds new node
353
- */
354
273
  addNode(e) {
355
- const t = this.nodeIdGenerator.create(e.id);
356
- if (this.graphStore.addNode({
357
- id: t,
358
- element: e.element,
359
- x: e.x ?? null,
360
- y: e.y ?? null,
361
- centerFn: e.centerFn ?? this.params.nodes.centerFn,
362
- priority: e.priority ?? this.params.nodes.priorityFn()
363
- }), e.ports !== void 0)
364
- for (const s of e.ports)
365
- this.markPort({
366
- id: s.id,
367
- element: s.element,
368
- nodeId: t,
369
- direction: s.direction
370
- });
371
- return this;
274
+ return this.graphController.addNode(e), this;
372
275
  }
373
- /**
374
- * updates node parameters
375
- */
376
276
  updateNode(e, t) {
377
- return this.graphStore.updateNode(e, t ?? {}), this;
277
+ return this.graphController.updateNode(e, t), this;
378
278
  }
379
- /**
380
- * removes specified node
381
- * all the ports of node get unmarked
382
- * all the edges adjacent to node get removed
383
- */
384
279
  removeNode(e) {
385
- return this.graphStore.removeNode(e), this;
280
+ return this.graphController.removeNode(e), this;
386
281
  }
387
- /**
388
- * marks specified element as a port for specified node
389
- */
390
282
  markPort(e) {
391
- const t = this.portIdGenerator.create(e.id);
392
- return this.graphStore.addPort({
393
- id: t,
394
- element: e.element,
395
- nodeId: e.nodeId,
396
- direction: e.direction ?? this.params.ports.direction
397
- }), this;
283
+ return this.graphController.markPort(e), this;
398
284
  }
399
- /**
400
- * updates port and edges attached to it
401
- */
402
285
  updatePort(e, t) {
403
- return this.graphStore.updatePort(e, t ?? {}), this;
286
+ return this.graphController.updatePort(e, t), this;
404
287
  }
405
- /**
406
- * unmarks specified port
407
- * all the edges adjacent to the port get removed
408
- */
409
288
  unmarkPort(e) {
410
- return this.graphStore.removePort(e), this;
289
+ return this.graphController.unmarkPort(e), this;
411
290
  }
412
- /**
413
- * adds new edge
414
- */
415
291
  addEdge(e) {
416
- const t = this.edgeIdGenerator.create(e.id);
417
- return this.graphStore.addEdge({
418
- id: t,
419
- from: e.from,
420
- to: e.to,
421
- shape: e.shape ?? this.params.edges.shapeFactory(t),
422
- priority: e.priority ?? this.params.edges.priorityFn()
423
- }), this;
292
+ return this.graphController.addEdge(e), this;
424
293
  }
425
- /**
426
- * updates specified edge
427
- */
428
294
  updateEdge(e, t) {
429
- return this.graphStore.updateEdge(e, t ?? {}), this;
295
+ return this.graphController.updateEdge(e, t), this;
430
296
  }
431
- /**
432
- * removes specified edge
433
- */
434
297
  removeEdge(e) {
435
- return this.graphStore.removeEdge(e), this;
298
+ return this.graphController.removeEdge(e), this;
436
299
  }
437
- /**
438
- * clears canvas from nodes and edges
439
- * canvas gets rolled back to initial state and can be reused
440
- */
441
300
  clear() {
442
- return this.graphStore.clear(), this;
301
+ return this.graphController.clear(), this;
302
+ }
303
+ focus(e) {
304
+ return this.viewportController.focus(e), this;
305
+ }
306
+ center(e, t) {
307
+ return this.viewportController.center(e, t), this;
443
308
  }
444
- /**
445
- * applies transformation for viewport matrix
446
- */
447
309
  patchViewportMatrix(e) {
448
- return this.viewportStore.patchViewportMatrix(e), this;
310
+ return this.viewportController.patchViewportMatrix(e), this;
449
311
  }
450
- /**
451
- * applies transformation for content matrix
452
- */
453
312
  patchContentMatrix(e) {
454
- return this.viewportStore.patchContentMatrix(e), this;
313
+ return this.viewportController.patchContentMatrix(e), this;
455
314
  }
456
- /**
457
- * destroys canvas
458
- * canvas element gets rolled back to initial state, and can not be reused
459
- */
460
315
  destroy() {
461
- this.destroyed || (this.clear(), this.onBeforeDestroyEmitter.emit(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
462
- this.onAfterNodePriorityUpdated
463
- ), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
464
- this.onAfterEdgeShapeUpdated
465
- ), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
466
- this.onAfterEdgePriorityUpdated
467
- ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.viewportStore.destroy(), this.destroyed = !0);
316
+ this.destroyed || (this.destroyed = !0, this.beforeDestroyEmitter.emit(), this.graphController.destroy(), this.viewportController.destroy());
468
317
  }
469
318
  }
470
- class Je {
319
+ class st {
471
320
  constructor() {
472
321
  i(this, "singleToMultiMap", /* @__PURE__ */ new Map());
473
322
  i(this, "multiToSingleMap", /* @__PURE__ */ new Map());
@@ -507,22 +356,22 @@ class Je {
507
356
  return this.multiToSingleMap.get(e) !== void 0;
508
357
  }
509
358
  }
510
- class x extends Error {
359
+ class E extends Error {
511
360
  constructor() {
512
361
  super(...arguments);
513
362
  i(this, "name", "CanvasError");
514
363
  }
515
364
  }
516
- class Se {
365
+ class be {
517
366
  constructor() {
518
367
  i(this, "nodes", /* @__PURE__ */ new Map());
519
368
  i(this, "ports", /* @__PURE__ */ new Map());
520
369
  i(this, "edges", /* @__PURE__ */ new Map());
521
370
  i(this, "nodesElementsMap", /* @__PURE__ */ new Map());
522
371
  i(this, "portIncomingEdges", /* @__PURE__ */ new Map());
523
- i(this, "portOutcomingEdges", /* @__PURE__ */ new Map());
372
+ i(this, "portOutgoingEdges", /* @__PURE__ */ new Map());
524
373
  i(this, "portCycleEdges", /* @__PURE__ */ new Map());
525
- i(this, "elementPorts", new Je());
374
+ i(this, "elementPorts", new st());
526
375
  i(this, "afterNodeAddedEmitter");
527
376
  i(this, "onAfterNodeAdded");
528
377
  i(this, "afterNodeUpdatedEmitter");
@@ -549,7 +398,7 @@ class Se {
549
398
  i(this, "onBeforeEdgeRemoved");
550
399
  i(this, "beforeClearEmitter");
551
400
  i(this, "onBeforeClear");
552
- [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = E(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = E(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = E(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = E(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = E(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = E(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = E(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = E(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = E(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = E(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = E(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = E(), [this.beforeClearEmitter, this.onBeforeClear] = E();
401
+ [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = S(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = S(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = S(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = S(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = S(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = S(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = S(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = S(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = S(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = S(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = S(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = S(), [this.beforeClearEmitter, this.onBeforeClear] = S();
553
402
  }
554
403
  hasNode(e) {
555
404
  return this.nodes.has(e);
@@ -557,14 +406,14 @@ class Se {
557
406
  getNode(e) {
558
407
  const t = this.nodes.get(e);
559
408
  if (t === void 0)
560
- throw new x("failed to access nonexistent node");
409
+ throw new E("failed to access nonexistent node");
561
410
  return t;
562
411
  }
563
412
  addNode(e) {
564
413
  if (this.hasNode(e.id))
565
- throw new x("failed to add node with existing id");
414
+ throw new E("failed to add node with existing id");
566
415
  if (this.findNodeIdByElement(e.element) !== void 0)
567
- throw new x(
416
+ throw new E(
568
417
  "failed to add node with html element already in use by another node"
569
418
  );
570
419
  const t = /* @__PURE__ */ new Map(), s = {
@@ -587,13 +436,13 @@ class Se {
587
436
  }
588
437
  updateNode(e, t) {
589
438
  if (!this.hasNode(e))
590
- throw new x("failed to update nonexistent node");
439
+ throw new E("failed to update nonexistent node");
591
440
  const { payload: s } = this.nodes.get(e);
592
441
  s.x = t.x ?? s.x, s.y = t.y ?? s.y, s.centerFn = t.centerFn ?? s.centerFn, t.priority !== void 0 && (s.priority = t.priority, this.afterNodePriorityUpdatedEmitter.emit(e)), this.afterNodeUpdatedEmitter.emit(e);
593
442
  }
594
443
  removeNode(e) {
595
444
  if (!this.hasNode(e))
596
- throw new x("failed to remove nonexistent node");
445
+ throw new E("failed to remove nonexistent node");
597
446
  this.beforeNodeRemovedEmitter.emit(e);
598
447
  const t = this.nodes.get(e);
599
448
  this.nodesElementsMap.delete(t.element), this.nodes.delete(e);
@@ -604,25 +453,25 @@ class Se {
604
453
  getPort(e) {
605
454
  const t = this.ports.get(e);
606
455
  if (t === void 0)
607
- throw new x("failed to access nonexistent port");
456
+ throw new E("failed to access nonexistent port");
608
457
  return t;
609
458
  }
610
459
  addPort(e) {
611
460
  if (this.hasPort(e.id))
612
- throw new x("failed to add port with existing id");
461
+ throw new E("failed to add port with existing id");
613
462
  if (!this.hasNode(e.nodeId))
614
- throw new x("failed to add port to nonexistent node");
463
+ throw new E("failed to add port to nonexistent node");
615
464
  this.ports.set(e.id, {
616
465
  element: e.element,
617
466
  payload: {
618
467
  direction: e.direction
619
468
  },
620
469
  nodeId: e.nodeId
621
- }), this.elementPorts.addRecord(e.element, e.id), this.portCycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.portIncomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.portOutcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
470
+ }), this.elementPorts.addRecord(e.element, e.id), this.portCycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.portIncomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.portOutgoingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
622
471
  }
623
472
  updatePort(e, t) {
624
473
  if (!this.hasPort(e))
625
- throw new x("failed to update nonexistent port");
474
+ throw new E("failed to update nonexistent port");
626
475
  const s = this.ports.get(e).payload;
627
476
  s.direction = t.direction ?? s.direction, this.afterPortUpdatedEmitter.emit(e);
628
477
  }
@@ -635,12 +484,12 @@ class Se {
635
484
  getNodePortIds(e) {
636
485
  const t = this.nodes.get(e);
637
486
  if (t === void 0)
638
- throw new x("failed to access port ids of nonexistent node");
487
+ throw new E("failed to access port ids of nonexistent node");
639
488
  return Array.from(t.ports.keys());
640
489
  }
641
490
  removePort(e) {
642
491
  if (!this.hasPort(e))
643
- throw new x("failed to remove nonexistent port");
492
+ throw new E("failed to remove nonexistent port");
644
493
  const t = this.ports.get(e).nodeId;
645
494
  this.beforePortRemovedEmitter.emit(e), this.nodes.get(t).ports.delete(e), this.ports.delete(e), this.elementPorts.removeByMulti(e);
646
495
  }
@@ -650,21 +499,21 @@ class Se {
650
499
  getEdge(e) {
651
500
  const t = this.edges.get(e);
652
501
  if (t === void 0)
653
- throw new x("failed to access nonexistent edge");
502
+ throw new E("failed to access nonexistent edge");
654
503
  return t;
655
504
  }
656
505
  addEdge(e) {
657
506
  if (this.hasEdge(e.id))
658
- throw new x("failed to add edge with existing id");
507
+ throw new E("failed to add edge with existing id");
659
508
  if (!this.hasPort(e.from))
660
- throw new x("failed to add edge from nonexistent port");
509
+ throw new E("failed to add edge from nonexistent port");
661
510
  if (!this.hasPort(e.to))
662
- throw new x("failed to add edge to nonexistent port");
511
+ throw new E("failed to add edge to nonexistent port");
663
512
  this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
664
513
  }
665
514
  updateEdge(e, t) {
666
515
  if (!this.hasEdge(e))
667
- throw new x("failed to update nonexistent edge");
516
+ throw new E("failed to update nonexistent edge");
668
517
  if (t.from !== void 0 || t.to !== void 0) {
669
518
  const o = this.edges.get(e), n = o.payload;
670
519
  this.removeEdgeInternal(e), this.addEdgeInternal({
@@ -683,28 +532,28 @@ class Se {
683
532
  }
684
533
  removeEdge(e) {
685
534
  if (!this.hasEdge(e))
686
- throw new x("failed to remove nonexistent edge");
535
+ throw new E("failed to remove nonexistent edge");
687
536
  this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
688
537
  }
689
538
  clear() {
690
- this.beforeClearEmitter.emit(), this.portIncomingEdges.clear(), this.portOutcomingEdges.clear(), this.portCycleEdges.clear(), this.elementPorts.clear(), this.nodesElementsMap.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
539
+ this.beforeClearEmitter.emit(), this.portIncomingEdges.clear(), this.portOutgoingEdges.clear(), this.portCycleEdges.clear(), this.elementPorts.clear(), this.nodesElementsMap.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
691
540
  }
692
541
  getPortIncomingEdgeIds(e) {
693
542
  const t = this.portIncomingEdges.get(e);
694
543
  if (t === void 0)
695
- throw new x("failed to access edges for nonexistent port");
544
+ throw new E("failed to access edges for nonexistent port");
696
545
  return Array.from(t);
697
546
  }
698
547
  getPortOutgoingEdgeIds(e) {
699
- const t = this.portOutcomingEdges.get(e);
548
+ const t = this.portOutgoingEdges.get(e);
700
549
  if (t === void 0)
701
- throw new x("failed to access edges for nonexistent port");
550
+ throw new E("failed to access edges for nonexistent port");
702
551
  return Array.from(t);
703
552
  }
704
553
  getPortCycleEdgeIds(e) {
705
554
  const t = this.portCycleEdges.get(e);
706
555
  if (t === void 0)
707
- throw new x("failed to access edges for nonexistent port");
556
+ throw new E("failed to access edges for nonexistent port");
708
557
  return Array.from(t);
709
558
  }
710
559
  getPortAdjacentEdgeIds(e) {
@@ -769,29 +618,29 @@ class Se {
769
618
  shape: e.shape,
770
619
  priority: e.priority
771
620
  }
772
- }), e.from !== e.to ? (this.portOutcomingEdges.get(e.from).add(e.id), this.portIncomingEdges.get(e.to).add(e.id)) : this.portCycleEdges.get(e.from).add(e.id);
621
+ }), e.from !== e.to ? (this.portOutgoingEdges.get(e.from).add(e.id), this.portIncomingEdges.get(e.to).add(e.id)) : this.portCycleEdges.get(e.from).add(e.id);
773
622
  }
774
623
  removeEdgeInternal(e) {
775
624
  const t = this.edges.get(e), s = t.from, o = t.to;
776
- this.portCycleEdges.get(s).delete(e), this.portCycleEdges.get(o).delete(e), this.portIncomingEdges.get(s).delete(e), this.portIncomingEdges.get(o).delete(e), this.portOutcomingEdges.get(s).delete(e), this.portOutcomingEdges.get(o).delete(e), this.edges.delete(e);
625
+ this.portCycleEdges.get(s).delete(e), this.portCycleEdges.get(o).delete(e), this.portIncomingEdges.get(s).delete(e), this.portIncomingEdges.get(o).delete(e), this.portOutgoingEdges.get(s).delete(e), this.portOutgoingEdges.get(o).delete(e), this.edges.delete(e);
777
626
  }
778
627
  }
779
- const ge = (r) => ({
628
+ const ue = (r) => ({
780
629
  scale: 1 / r.scale,
781
630
  x: -r.x / r.scale,
782
631
  y: -r.y / r.scale
783
- }), ue = {
632
+ }), pe = {
784
633
  scale: 1,
785
634
  x: 0,
786
635
  y: 0
787
- }, pe = (r, e) => ({
636
+ }, we = (r, e) => ({
788
637
  x: r.scale * e.x + r.x,
789
638
  y: r.scale * e.y + r.y
790
639
  });
791
- class _e {
640
+ class ot {
792
641
  constructor(e) {
793
- i(this, "viewportMatrix", ue);
794
- i(this, "contentMatrix", ue);
642
+ i(this, "viewportMatrix", pe);
643
+ i(this, "contentMatrix", pe);
795
644
  i(this, "beforeUpdateEmitter");
796
645
  i(this, "onBeforeUpdated");
797
646
  i(this, "afterUpdateEmitter");
@@ -801,7 +650,7 @@ class _e {
801
650
  i(this, "observer", new ResizeObserver(() => {
802
651
  this.afterResizeEmitter.emit();
803
652
  }));
804
- this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E(), [this.afterResizeEmitter, this.onAfterResize] = E(), this.observer.observe(this.host);
653
+ this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] = S(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = S(), [this.afterResizeEmitter, this.onAfterResize] = S(), this.observer.observe(this.host);
805
654
  }
806
655
  getViewportMatrix() {
807
656
  return this.viewportMatrix;
@@ -814,30 +663,30 @@ class _e {
814
663
  scale: e.scale ?? this.viewportMatrix.scale,
815
664
  x: e.x ?? this.viewportMatrix.x,
816
665
  y: e.y ?? this.viewportMatrix.y
817
- }, this.beforeUpdateEmitter.emit(), this.contentMatrix = ge(this.viewportMatrix), this.afterUpdateEmitter.emit();
666
+ }, this.beforeUpdateEmitter.emit(), this.contentMatrix = ue(this.viewportMatrix), this.afterUpdateEmitter.emit();
818
667
  }
819
668
  patchContentMatrix(e) {
820
669
  this.contentMatrix = {
821
670
  scale: e.scale ?? this.contentMatrix.scale,
822
671
  x: e.x ?? this.contentMatrix.x,
823
672
  y: e.y ?? this.contentMatrix.y
824
- }, this.beforeUpdateEmitter.emit(), this.viewportMatrix = ge(this.contentMatrix), this.afterUpdateEmitter.emit();
673
+ }, this.beforeUpdateEmitter.emit(), this.viewportMatrix = ue(this.contentMatrix), this.afterUpdateEmitter.emit();
825
674
  }
826
675
  getDimensions() {
827
676
  const { width: e, height: t } = this.host.getBoundingClientRect();
828
677
  return { width: e, height: t };
829
678
  }
830
679
  createContentCoords(e) {
831
- return pe(this.viewportMatrix, e);
680
+ return we(this.viewportMatrix, e);
832
681
  }
833
682
  createViewportCoords(e) {
834
- return pe(this.contentMatrix, e);
683
+ return we(this.contentMatrix, e);
835
684
  }
836
685
  destroy() {
837
686
  this.observer.disconnect();
838
687
  }
839
688
  }
840
- class Z {
689
+ class Q {
841
690
  constructor(e) {
842
691
  i(this, "elementToNodeId", /* @__PURE__ */ new Map());
843
692
  i(this, "nodesResizeObserver");
@@ -860,17 +709,17 @@ class Z {
860
709
  }), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
861
710
  }
862
711
  static configure(e) {
863
- new Z(e);
712
+ new Q(e);
864
713
  }
865
714
  handleNodeResize(e) {
866
715
  const t = this.elementToNodeId.get(e);
867
716
  this.canvas.updateNode(t);
868
717
  }
869
718
  }
870
- const et = (r, e, t) => {
719
+ const it = (r, e, t) => {
871
720
  const { x: s, y: o, width: n, height: a } = r.getBoundingClientRect();
872
721
  return e >= s && e <= s + n && t >= o && t <= o + a;
873
- }, tt = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, R = (r, e, t, s) => et(e, t, s) && tt(r, t, s), U = (r, e) => {
722
+ }, nt = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, R = (r, e, t, s) => it(e, t, s) && nt(r, t, s), U = (r, e) => {
874
723
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
875
724
  }, O = (r) => {
876
725
  const e = document.createElement("div");
@@ -887,7 +736,7 @@ const et = (r, e, t) => {
887
736
  }
888
737
  ]
889
738
  };
890
- }, rt = (r, e) => {
739
+ }, at = (r, e) => {
891
740
  let t = e;
892
741
  for (; t !== null; ) {
893
742
  const s = r.findPortIdsByElement(t)[0] ?? null;
@@ -906,21 +755,21 @@ const et = (r, e, t) => {
906
755
  status: "notFound"
907
756
  };
908
757
  };
909
- function* be(r, e) {
758
+ function* Pe(r, e) {
910
759
  const t = r.elementsFromPoint(e.x, e.y);
911
760
  for (const s of t) {
912
761
  if (s.shadowRoot !== null) {
913
- const o = be(s.shadowRoot, e);
762
+ const o = Pe(s.shadowRoot, e);
914
763
  for (const n of o)
915
764
  yield n;
916
765
  }
917
766
  yield s;
918
767
  }
919
768
  }
920
- const Pe = (r, e) => {
921
- const t = be(document, e);
769
+ const Ce = (r, e) => {
770
+ const t = Pe(document, e);
922
771
  for (const s of t) {
923
- const o = rt(r, s);
772
+ const o = at(r, s);
924
773
  if (o.status === "portFound")
925
774
  return o.portId;
926
775
  if (o.status === "nodeEncountered")
@@ -932,7 +781,7 @@ var N = /* @__PURE__ */ ((r) => (r.StaticNodeId = "static", r.DraggingNodeId = "
932
781
  const Ne = (r, e) => ({
933
782
  x: r / 2,
934
783
  y: e / 2
935
- }), p = {
784
+ }), w = {
936
785
  x: 0,
937
786
  y: 0
938
787
  }, m = (r, e, t) => ({
@@ -954,11 +803,11 @@ const Ne = (r, e) => ({
954
803
  flipX: d,
955
804
  flipY: c
956
805
  };
957
- }, k = (r, e, t, s) => ({
806
+ }, z = (r, e, t, s) => ({
958
807
  x: e * r.x + (1 - e) / 2 * s.x,
959
808
  y: t * r.y + (1 - t) / 2 * s.y
960
809
  });
961
- class st {
810
+ class ht {
962
811
  constructor(e) {
963
812
  i(this, "path");
964
813
  i(this, "midpoint");
@@ -966,9 +815,9 @@ class st {
966
815
  const t = this.params.to;
967
816
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
968
817
  const s = m(
969
- { x: this.params.arrowLength, y: p.y },
818
+ { x: this.params.arrowLength, y: w.y },
970
819
  this.params.sourceDirection,
971
- p
820
+ w
972
821
  ), o = m(
973
822
  { x: this.params.to.x - this.params.arrowLength, y: this.params.to.y },
974
823
  this.params.targetDirection,
@@ -979,20 +828,20 @@ class st {
979
828
  }, a = {
980
829
  x: o.x - this.params.targetDirection.x * this.params.curvature,
981
830
  y: o.y - this.params.targetDirection.y * this.params.curvature
982
- }, h = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${a.x} ${a.y}, ${o.x} ${o.y}`, d = this.params.hasSourceArrow ? "" : `M ${p.x} ${p.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${this.params.to.x} ${this.params.to.y}`;
831
+ }, h = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${a.x} ${a.y}, ${o.x} ${o.y}`, d = this.params.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${this.params.to.x} ${this.params.to.y}`;
983
832
  this.path = `${d}${h}${c}`;
984
833
  }
985
834
  }
986
- class ot {
835
+ class dt {
987
836
  constructor(e) {
988
837
  i(this, "path");
989
838
  i(this, "midpoint");
990
839
  this.params = e;
991
840
  const t = this.params.hasSourceArrow ? m(
992
- { x: this.params.arrowLength, y: p.y },
841
+ { x: this.params.arrowLength, y: w.y },
993
842
  this.params.sourceDirection,
994
- p
995
- ) : p, s = this.params.hasTargetArrow ? m(
843
+ w
844
+ ) : w, s = this.params.hasTargetArrow ? m(
996
845
  {
997
846
  x: this.params.to.x - this.params.arrowLength,
998
847
  y: this.params.to.y
@@ -1000,9 +849,9 @@ class ot {
1000
849
  this.params.targetDirection,
1001
850
  this.params.to
1002
851
  ) : this.params.to, o = this.params.arrowLength, n = Math.cos(this.params.detourDirection) * this.params.detourDistance, a = Math.sin(this.params.detourDirection) * this.params.detourDistance, h = n * this.params.flipX, d = a * this.params.flipY, c = m(
1003
- { x: o, y: p.y },
852
+ { x: o, y: w.y },
1004
853
  this.params.sourceDirection,
1005
- p
854
+ w
1006
855
  ), g = {
1007
856
  x: c.x + h,
1008
857
  y: c.y + d
@@ -1013,7 +862,7 @@ class ot {
1013
862
  ), u = {
1014
863
  x: l.x + h,
1015
864
  y: l.y + d
1016
- }, w = {
865
+ }, p = {
1017
866
  x: (g.x + u.x) / 2,
1018
867
  y: (g.y + u.y) / 2
1019
868
  }, f = {
@@ -1022,7 +871,7 @@ class ot {
1022
871
  }, v = {
1023
872
  x: l.x - this.params.curvature * this.params.targetDirection.x,
1024
873
  y: l.y - this.params.curvature * this.params.targetDirection.y
1025
- }, S = {
874
+ }, x = {
1026
875
  x: c.x + h,
1027
876
  y: c.y + d
1028
877
  }, b = {
@@ -1032,27 +881,27 @@ class ot {
1032
881
  this.path = [
1033
882
  `M ${t.x} ${t.y}`,
1034
883
  `L ${c.x} ${c.y}`,
1035
- `C ${f.x} ${f.y} ${S.x} ${S.y} ${w.x} ${w.y}`,
884
+ `C ${f.x} ${f.y} ${x.x} ${x.y} ${p.x} ${p.y}`,
1036
885
  `C ${b.x} ${b.y} ${v.x} ${v.y} ${l.x} ${l.y}`,
1037
886
  `L ${s.x} ${s.y}`
1038
- ].join(" "), this.midpoint = k(w, e.flipX, e.flipY, e.to);
887
+ ].join(" "), this.midpoint = z(p, e.flipX, e.flipY, e.to);
1039
888
  }
1040
889
  }
1041
- const J = Object.freeze({
890
+ const Z = Object.freeze({
1042
891
  edgeColor: "--edge-color"
1043
- }), Ce = (r) => {
892
+ }), Me = (r) => {
1044
893
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1045
- return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(J.edgeColor, r), e;
1046
- }, Me = (r) => {
894
+ return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(Z.edgeColor, r), e;
895
+ }, De = (r) => {
1047
896
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1048
- return e.setAttribute("stroke", `var(${J.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
897
+ return e.setAttribute("stroke", `var(${Z.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
1049
898
  }, W = () => {
1050
899
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
1051
- return r.setAttribute("fill", `var(${J.edgeColor})`), r;
1052
- }, De = () => {
900
+ return r.setAttribute("fill", `var(${Z.edgeColor})`), r;
901
+ }, Re = () => {
1053
902
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
1054
903
  return r.style.transformOrigin = "50% 50%", r;
1055
- }, Re = (r, e) => {
904
+ }, Le = (r, e) => {
1056
905
  r.style.transform = `translate(${e.x}px, ${e.y}px)`, r.style.width = `${Math.max(e.width, 1)}px`, r.style.height = `${Math.max(e.height, 1)}px`;
1057
906
  }, M = (r, e) => {
1058
907
  const t = [];
@@ -1061,12 +910,12 @@ const J = Object.freeze({
1061
910
  let o = 0, n = 0, a = 0;
1062
911
  r.forEach((h, d) => {
1063
912
  let c = 0, g = 0, l = 0;
1064
- const u = d > 0, w = d < s, f = u && w;
1065
- if (u && (c = -o, g = -n, l = a), w) {
913
+ const u = d > 0, p = d < s, f = u && p;
914
+ if (u && (c = -o, g = -n, l = a), p) {
1066
915
  const V = r[d + 1];
1067
916
  o = V.x - h.x, n = V.y - h.y, a = Math.sqrt(o * o + n * n);
1068
917
  }
1069
- const S = a !== 0 ? Math.min((f ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, b = f ? { x: h.x + o * S, y: h.y + n * S } : h, P = l !== 0 ? Math.min((f ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, L = f ? { x: h.x + c * P, y: h.y + g * P } : h;
918
+ const x = a !== 0 ? Math.min((f ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, b = f ? { x: h.x + o * x, y: h.y + n * x } : h, C = l !== 0 ? Math.min((f ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, L = f ? { x: h.x + c * C, y: h.y + g * C } : h;
1070
919
  d > 0 && t.push(`L ${L.x} ${L.y}`), f && t.push(
1071
920
  `C ${h.x} ${h.y} ${h.x} ${h.y} ${b.x} ${b.y}`
1072
921
  );
@@ -1074,7 +923,7 @@ const J = Object.freeze({
1074
923
  }
1075
924
  return t.join(" ");
1076
925
  };
1077
- class it {
926
+ class ct {
1078
927
  constructor(e) {
1079
928
  i(this, "path");
1080
929
  i(this, "midpoint");
@@ -1082,10 +931,10 @@ class it {
1082
931
  const t = this.params.to;
1083
932
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
1084
933
  const s = this.params.hasSourceArrow ? m(
1085
- { x: this.params.arrowLength, y: p.y },
934
+ { x: this.params.arrowLength, y: w.y },
1086
935
  this.params.sourceDirection,
1087
- p
1088
- ) : p, o = this.params.hasTargetArrow ? m(
936
+ w
937
+ ) : w, o = this.params.hasTargetArrow ? m(
1089
938
  {
1090
939
  x: this.params.to.x - this.params.arrowLength,
1091
940
  y: this.params.to.y
@@ -1093,9 +942,9 @@ class it {
1093
942
  this.params.targetDirection,
1094
943
  this.params.to
1095
944
  ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = n - this.params.roundness, h = m(
1096
- { x: a, y: p.y },
945
+ { x: a, y: w.y },
1097
946
  this.params.sourceDirection,
1098
- p
947
+ w
1099
948
  ), d = m(
1100
949
  { x: this.params.to.x - a, y: this.params.to.y },
1101
950
  this.params.targetDirection,
@@ -1103,26 +952,26 @@ class it {
1103
952
  ), c = Math.max((h.x + d.x) / 2, n), g = this.params.to.y / 2, l = {
1104
953
  x: this.params.flipX > 0 ? c : -n,
1105
954
  y: h.y
1106
- }, u = { x: l.x, y: g }, w = {
955
+ }, u = { x: l.x, y: g }, p = {
1107
956
  x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
1108
957
  y: d.y
1109
- }, f = { x: w.x, y: g };
958
+ }, f = { x: p.x, y: g };
1110
959
  this.path = M(
1111
- [s, h, l, u, f, w, d, o],
960
+ [s, h, l, u, f, p, d, o],
1112
961
  this.params.roundness
1113
962
  );
1114
963
  }
1115
964
  }
1116
- class nt {
965
+ class lt {
1117
966
  constructor(e) {
1118
967
  i(this, "path");
1119
968
  i(this, "midpoint");
1120
969
  this.params = e;
1121
970
  const t = this.params.hasSourceArrow ? m(
1122
- { x: this.params.arrowLength, y: p.y },
971
+ { x: this.params.arrowLength, y: w.y },
1123
972
  this.params.sourceDirection,
1124
- p
1125
- ) : p, s = this.params.hasTargetArrow ? m(
973
+ w
974
+ ) : w, s = this.params.hasTargetArrow ? m(
1126
975
  {
1127
976
  x: this.params.to.x - this.params.arrowLength,
1128
977
  y: this.params.to.y
@@ -1130,21 +979,21 @@ class nt {
1130
979
  this.params.targetDirection,
1131
980
  this.params.to
1132
981
  ) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
1133
- { x: o, y: p.y },
982
+ { x: o, y: w.y },
1134
983
  this.params.sourceDirection,
1135
- p
984
+ w
1136
985
  ), a = Math.cos(this.params.detourDirection) * this.params.detourDistance, h = Math.sin(this.params.detourDirection) * this.params.detourDistance, d = a * this.params.flipX, c = h * this.params.flipY, g = { x: n.x + d, y: n.y + c }, l = m(
1137
986
  { x: this.params.to.x - o, y: this.params.to.y },
1138
987
  this.params.targetDirection,
1139
988
  this.params.to
1140
- ), u = { x: l.x + d, y: l.y + c }, w = { x: (g.x + u.x) / 2, y: (g.y + u.y) / 2 };
1141
- this.midpoint = k(w, e.flipX, e.flipY, e.to), this.path = M(
989
+ ), u = { x: l.x + d, y: l.y + c }, p = { x: (g.x + u.x) / 2, y: (g.y + u.y) / 2 };
990
+ this.midpoint = z(p, e.flipX, e.flipY, e.to), this.path = M(
1142
991
  [t, n, g, u, l, s],
1143
992
  this.params.roundness
1144
993
  );
1145
994
  }
1146
995
  }
1147
- class at {
996
+ class gt {
1148
997
  constructor(e) {
1149
998
  i(this, "path");
1150
999
  i(this, "midpoint");
@@ -1152,10 +1001,10 @@ class at {
1152
1001
  const t = this.params.to;
1153
1002
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
1154
1003
  const s = this.params.hasSourceArrow ? m(
1155
- { x: this.params.arrowLength, y: p.y },
1004
+ { x: this.params.arrowLength, y: w.y },
1156
1005
  this.params.sourceDirection,
1157
- p
1158
- ) : p, o = this.params.hasTargetArrow ? m(
1006
+ w
1007
+ ) : w, o = this.params.hasTargetArrow ? m(
1159
1008
  {
1160
1009
  x: this.params.to.x - this.params.arrowLength,
1161
1010
  y: this.params.to.y
@@ -1163,9 +1012,9 @@ class at {
1163
1012
  this.params.targetDirection,
1164
1013
  this.params.to
1165
1014
  ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = m(
1166
- { x: n, y: p.y },
1015
+ { x: n, y: w.y },
1167
1016
  this.params.sourceDirection,
1168
- p
1017
+ w
1169
1018
  ), h = m(
1170
1019
  { x: this.params.to.x - n, y: this.params.to.y },
1171
1020
  this.params.targetDirection,
@@ -1174,7 +1023,7 @@ class at {
1174
1023
  this.path = M([s, a, h, o], this.params.roundness);
1175
1024
  }
1176
1025
  }
1177
- class ht {
1026
+ class ut {
1178
1027
  constructor(e) {
1179
1028
  i(this, "path");
1180
1029
  i(this, "midpoint");
@@ -1182,10 +1031,10 @@ class ht {
1182
1031
  const t = this.params.to;
1183
1032
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
1184
1033
  const s = this.params.hasSourceArrow ? m(
1185
- { x: this.params.arrowLength, y: p.y },
1034
+ { x: this.params.arrowLength, y: w.y },
1186
1035
  this.params.sourceDirection,
1187
- p
1188
- ) : p, o = this.params.hasTargetArrow ? m(
1036
+ w
1037
+ ) : w, o = this.params.hasTargetArrow ? m(
1189
1038
  {
1190
1039
  x: this.params.to.x - this.params.arrowLength,
1191
1040
  y: this.params.to.y
@@ -1193,9 +1042,9 @@ class ht {
1193
1042
  this.params.targetDirection,
1194
1043
  this.params.to
1195
1044
  ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = n - this.params.roundness, h = m(
1196
- { x: a, y: p.y },
1045
+ { x: a, y: w.y },
1197
1046
  this.params.sourceDirection,
1198
- p
1047
+ w
1199
1048
  ), d = m(
1200
1049
  { x: this.params.to.x - a, y: this.params.to.y },
1201
1050
  this.params.targetDirection,
@@ -1203,58 +1052,58 @@ class ht {
1203
1052
  ), c = Math.max((h.y + d.y) / 2, n), g = this.params.to.x / 2, l = {
1204
1053
  x: h.x,
1205
1054
  y: this.params.flipY > 0 ? c : -n
1206
- }, u = { x: g, y: l.y }, w = {
1055
+ }, u = { x: g, y: l.y }, p = {
1207
1056
  x: d.x,
1208
1057
  y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
1209
- }, f = { x: g, y: w.y };
1058
+ }, f = { x: g, y: p.y };
1210
1059
  this.path = M(
1211
- [s, h, l, u, f, w, d, o],
1060
+ [s, h, l, u, f, p, d, o],
1212
1061
  this.params.roundness
1213
1062
  );
1214
1063
  }
1215
1064
  }
1216
- class _ {
1065
+ class J {
1217
1066
  constructor(e) {
1218
1067
  i(this, "path");
1219
1068
  i(this, "midpoint");
1220
1069
  this.params = e;
1221
1070
  const t = this.params.arrowOffset, s = this.params.side, o = this.params.arrowLength + t, n = o + 2 * s, h = [
1222
- { x: this.params.arrowLength, y: p.y },
1223
- { x: o, y: p.y },
1071
+ { x: this.params.arrowLength, y: w.y },
1072
+ { x: o, y: w.y },
1224
1073
  { x: o, y: this.params.side },
1225
1074
  { x: n, y: this.params.side },
1226
1075
  { x: n, y: -this.params.side },
1227
1076
  { x: o, y: -this.params.side },
1228
- { x: o, y: p.y },
1229
- { x: this.params.arrowLength, y: p.y }
1077
+ { x: o, y: w.y },
1078
+ { x: this.params.arrowLength, y: w.y }
1230
1079
  ].map(
1231
- (c) => m(c, this.params.sourceDirection, p)
1232
- ), d = `M ${p.x} ${p.y} L ${h[0].x} ${h[0].y} `;
1080
+ (c) => m(c, this.params.sourceDirection, w)
1081
+ ), d = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
1233
1082
  this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${M(h, this.params.roundness)}`, this.midpoint = { x: (h[3].x + h[4].x) / 2, y: (h[3].y + h[4].y) / 2 };
1234
1083
  }
1235
1084
  }
1236
- class dt {
1085
+ class pt {
1237
1086
  constructor(e) {
1238
1087
  i(this, "path");
1239
1088
  i(this, "midpoint");
1240
1089
  this.params = e;
1241
1090
  const t = this.params.smallRadius, s = this.params.radius, o = t + s, n = t * s / o, a = Math.sqrt(o * o - t * t), h = a * t / o, d = a + s + this.params.arrowLength, c = this.params.arrowLength + h, l = [
1242
- { x: this.params.arrowLength, y: p.y },
1091
+ { x: this.params.arrowLength, y: w.y },
1243
1092
  { x: c, y: n },
1244
1093
  { x: c, y: -n },
1245
1094
  { x: d, y: 0 }
1246
1095
  ].map(
1247
- (f) => m(f, this.params.sourceDirection, p)
1096
+ (f) => m(f, this.params.sourceDirection, w)
1248
1097
  ), u = [
1249
1098
  `M ${l[0].x} ${l[0].y}`,
1250
1099
  `A ${t} ${t} 0 0 1 ${l[1].x} ${l[1].y}`,
1251
1100
  `A ${s} ${s} 0 1 0 ${l[2].x} ${l[2].y}`,
1252
1101
  `A ${t} ${t} 0 0 1 ${l[0].x} ${l[0].y}`
1253
- ].join(" "), w = `M 0 0 L ${l[0].x} ${l[0].y} `;
1254
- this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : w}${u}`, this.midpoint = l[3];
1102
+ ].join(" "), p = `M 0 0 L ${l[0].x} ${l[0].y} `;
1103
+ this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : p}${u}`, this.midpoint = l[3];
1255
1104
  }
1256
1105
  }
1257
- class ct {
1106
+ class wt {
1258
1107
  constructor(e) {
1259
1108
  i(this, "path");
1260
1109
  i(this, "midpoint");
@@ -1273,7 +1122,7 @@ class ct {
1273
1122
  offset: this.params.sourceOffset,
1274
1123
  hasArrow: this.params.hasSourceArrow,
1275
1124
  flip: 1,
1276
- shift: p
1125
+ shift: w
1277
1126
  }), n = this.createDirectLinePoint({
1278
1127
  offset: this.params.targetOffset,
1279
1128
  hasArrow: this.params.hasTargetArrow,
@@ -1290,16 +1139,16 @@ class ct {
1290
1139
  };
1291
1140
  }
1292
1141
  }
1293
- class lt {
1142
+ class ft {
1294
1143
  constructor(e) {
1295
1144
  i(this, "path");
1296
1145
  i(this, "midpoint");
1297
1146
  this.params = e;
1298
1147
  const t = this.params.hasSourceArrow ? m(
1299
- { x: this.params.arrowLength, y: p.y },
1148
+ { x: this.params.arrowLength, y: w.y },
1300
1149
  this.params.sourceDirection,
1301
- p
1302
- ) : p, s = this.params.hasTargetArrow ? m(
1150
+ w
1151
+ ) : w, s = this.params.hasTargetArrow ? m(
1303
1152
  {
1304
1153
  x: this.params.to.x - this.params.arrowLength,
1305
1154
  y: this.params.to.y
@@ -1307,9 +1156,9 @@ class lt {
1307
1156
  this.params.targetDirection,
1308
1157
  this.params.to
1309
1158
  ) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
1310
- { x: o, y: p.y },
1159
+ { x: o, y: w.y },
1311
1160
  this.params.sourceDirection,
1312
- p
1161
+ w
1313
1162
  ), a = m(
1314
1163
  { x: this.params.to.x - o, y: this.params.to.y },
1315
1164
  this.params.targetDirection,
@@ -1318,7 +1167,7 @@ class lt {
1318
1167
  x: (n.x + a.x) / 2,
1319
1168
  y: g
1320
1169
  };
1321
- this.midpoint = k(l, e.flipX, e.flipY, e.to), this.path = M(
1170
+ this.midpoint = z(l, e.flipX, e.flipY, e.to), this.path = M(
1322
1171
  [
1323
1172
  t,
1324
1173
  n,
@@ -1331,16 +1180,16 @@ class lt {
1331
1180
  );
1332
1181
  }
1333
1182
  }
1334
- class gt {
1183
+ class yt {
1335
1184
  constructor(e) {
1336
1185
  i(this, "path");
1337
1186
  i(this, "midpoint");
1338
1187
  this.params = e;
1339
1188
  const t = this.params.hasSourceArrow ? m(
1340
- { x: this.params.arrowLength, y: p.y },
1189
+ { x: this.params.arrowLength, y: w.y },
1341
1190
  this.params.sourceDirection,
1342
- p
1343
- ) : p, s = this.params.hasTargetArrow ? m(
1191
+ w
1192
+ ) : w, s = this.params.hasTargetArrow ? m(
1344
1193
  {
1345
1194
  x: this.params.to.x - this.params.arrowLength,
1346
1195
  y: this.params.to.y
@@ -1348,9 +1197,9 @@ class gt {
1348
1197
  this.params.targetDirection,
1349
1198
  this.params.to
1350
1199
  ) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
1351
- { x: o, y: p.y },
1200
+ { x: o, y: w.y },
1352
1201
  this.params.sourceDirection,
1353
- p
1202
+ w
1354
1203
  ), a = m(
1355
1204
  { x: this.params.to.x - o, y: this.params.to.y },
1356
1205
  this.params.targetDirection,
@@ -1359,7 +1208,7 @@ class gt {
1359
1208
  x: g,
1360
1209
  y: (n.y + a.y) / 2
1361
1210
  };
1362
- this.midpoint = k(l, e.flipX, e.flipY, e.to), this.path = M(
1211
+ this.midpoint = z(l, e.flipX, e.flipY, e.to), this.path = M(
1363
1212
  [
1364
1213
  t,
1365
1214
  n,
@@ -1394,30 +1243,30 @@ const y = Object.freeze({
1394
1243
  curvature: 90,
1395
1244
  interactiveWidth: 10,
1396
1245
  preOffset: 0
1397
- }), we = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
1398
- class H {
1246
+ }), fe = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
1247
+ class k {
1399
1248
  constructor(e) {
1400
1249
  i(this, "svg");
1401
- i(this, "group", De());
1250
+ i(this, "group", Re());
1402
1251
  i(this, "line");
1403
1252
  i(this, "sourceArrow", null);
1404
1253
  i(this, "targetArrow", null);
1405
1254
  i(this, "onAfterRender");
1406
1255
  i(this, "afterRenderEmitter");
1407
1256
  i(this, "arrowRenderer");
1408
- this.params = e, [this.afterRenderEmitter, this.onAfterRender] = E(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Ce(e.color), this.svg.appendChild(this.group), this.line = Me(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1257
+ this.params = e, [this.afterRenderEmitter, this.onAfterRender] = S(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Me(e.color), this.svg.appendChild(this.group), this.line = De(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1409
1258
  }
1410
1259
  render(e) {
1411
1260
  const { x: t, y: s, width: o, height: n, flipX: a, flipY: h } = Te(
1412
1261
  e.from,
1413
1262
  e.to
1414
1263
  );
1415
- Re(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1416
- const d = we(
1264
+ Le(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1265
+ const d = fe(
1417
1266
  e.from.direction,
1418
1267
  a,
1419
1268
  h
1420
- ), c = we(
1269
+ ), c = fe(
1421
1270
  e.to.direction,
1422
1271
  a,
1423
1272
  h
@@ -1427,18 +1276,18 @@ class H {
1427
1276
  };
1428
1277
  let l = { x: -c.x, y: -c.y }, u;
1429
1278
  e.category === D.PortCycle ? (u = this.params.createCyclePath, l = d) : e.category === D.NodeCycle ? u = this.params.createDetourPath : u = this.params.createLinePath;
1430
- const w = u(
1279
+ const p = u(
1431
1280
  d,
1432
1281
  c,
1433
1282
  g,
1434
1283
  a,
1435
1284
  h
1436
1285
  );
1437
- this.line.setAttribute("d", w.path);
1286
+ this.line.setAttribute("d", p.path);
1438
1287
  let f = null;
1439
1288
  this.sourceArrow && (f = this.arrowRenderer({
1440
1289
  direction: d,
1441
- shift: p,
1290
+ shift: w,
1442
1291
  arrowLength: this.params.arrowLength
1443
1292
  }), this.sourceArrow.setAttribute("d", f));
1444
1293
  let v = null;
@@ -1447,33 +1296,33 @@ class H {
1447
1296
  shift: g,
1448
1297
  arrowLength: this.params.arrowLength
1449
1298
  }), this.targetArrow.setAttribute("d", v)), this.afterRenderEmitter.emit({
1450
- edgePath: w,
1299
+ edgePath: p,
1451
1300
  sourceArrowPath: f,
1452
1301
  targetArrowPath: v
1453
1302
  });
1454
1303
  }
1455
1304
  }
1456
- const ut = (r) => (e) => {
1305
+ const mt = (r) => (e) => {
1457
1306
  const s = [
1458
- p,
1307
+ w,
1459
1308
  { x: e.arrowLength, y: r.radius },
1460
1309
  { x: e.arrowLength, y: -r.radius }
1461
1310
  ].map(
1462
- (h) => m(h, e.direction, p)
1311
+ (h) => m(h, e.direction, w)
1463
1312
  ).map((h) => ({
1464
1313
  x: h.x + e.shift.x,
1465
1314
  y: h.y + e.shift.y
1466
1315
  })), o = `M ${s[0].x} ${s[0].y}`, n = `L ${s[1].x} ${s[1].y}`, a = `L ${s[2].x} ${s[2].y}`;
1467
1316
  return `${o} ${n} ${a} Z`;
1468
- }, pt = (r) => (e) => {
1469
- const t = r.radius, s = e.arrowLength, o = (s * s + 2 * s * t) / (2 * t), n = o + t, a = s + t - t * (s + t) / n, h = t * o / n, c = [p, { x: a, y: -h }, { x: a, y: h }].map(
1470
- (f) => m(f, e.direction, p)
1317
+ }, vt = (r) => (e) => {
1318
+ const t = r.radius, s = e.arrowLength, o = (s * s + 2 * s * t) / (2 * t), n = o + t, a = s + t - t * (s + t) / n, h = t * o / n, c = [w, { x: a, y: -h }, { x: a, y: h }].map(
1319
+ (f) => m(f, e.direction, w)
1471
1320
  ).map((f) => ({
1472
1321
  x: f.x + e.shift.x,
1473
1322
  y: f.y + e.shift.y
1474
- })), g = `M ${c[0].x} ${c[0].y}`, l = `A ${o} ${o} 0 0 0 ${c[1].x} ${c[1].y}`, u = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, w = `A ${o} ${o} 0 0 0 ${c[0].x} ${c[0].y}`;
1475
- return `${g} ${l} ${u} ${w}`;
1476
- }, wt = (r) => (e) => {
1323
+ })), g = `M ${c[0].x} ${c[0].y}`, l = `A ${o} ${o} 0 0 0 ${c[1].x} ${c[1].y}`, u = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, p = `A ${o} ${o} 0 0 0 ${c[0].x} ${c[0].y}`;
1324
+ return `${g} ${l} ${u} ${p}`;
1325
+ }, At = (r) => (e) => {
1477
1326
  const t = r.smallRadius, s = r.radius, o = m(
1478
1327
  {
1479
1328
  x: e.arrowLength,
@@ -1487,8 +1336,8 @@ const ut = (r) => (e) => {
1487
1336
  x: e.arrowLength + r.smallRadius,
1488
1337
  y: 0
1489
1338
  }
1490
- ), a = [p, { x: o.x, y: -o.y }, o].map(
1491
- (l) => m(l, e.direction, p)
1339
+ ), a = [w, { x: o.x, y: -o.y }, o].map(
1340
+ (l) => m(l, e.direction, w)
1492
1341
  ).map((l) => ({
1493
1342
  x: l.x + e.shift.x,
1494
1343
  y: l.y + e.shift.y
@@ -1499,22 +1348,22 @@ const ut = (r) => (e) => {
1499
1348
  return r;
1500
1349
  switch (r.type) {
1501
1350
  case "triangle":
1502
- return ut({
1351
+ return mt({
1503
1352
  radius: r.radius ?? y.polygonArrowRadius
1504
1353
  });
1505
1354
  case "arc":
1506
- return pt({
1355
+ return vt({
1507
1356
  radius: r.radius ?? y.circleArrowRadius
1508
1357
  });
1509
1358
  default:
1510
- return wt({
1359
+ return At({
1511
1360
  smallRadius: r.smallRadius ?? y.wedgeArrowSmallRadius,
1512
1361
  angle: r.angle ?? y.wedgeArrowAngle,
1513
1362
  radius: r.radius ?? y.wedgeArrowRadius
1514
1363
  });
1515
1364
  }
1516
1365
  };
1517
- class ft {
1366
+ class xt {
1518
1367
  constructor(e) {
1519
1368
  i(this, "svg");
1520
1369
  i(this, "group");
@@ -1531,7 +1380,7 @@ class ft {
1531
1380
  i(this, "hasSourceArrow");
1532
1381
  i(this, "hasTargetArrow");
1533
1382
  i(this, "pathShape");
1534
- i(this, "createCyclePath", (e) => new dt({
1383
+ i(this, "createCyclePath", (e) => new pt({
1535
1384
  sourceDirection: e,
1536
1385
  radius: this.portCycleRadius,
1537
1386
  smallRadius: this.portCycleSmallRadius,
@@ -1539,7 +1388,7 @@ class ft {
1539
1388
  hasSourceArrow: this.hasSourceArrow,
1540
1389
  hasTargetArrow: this.hasTargetArrow
1541
1390
  }));
1542
- i(this, "createDetourPath", (e, t, s, o, n) => new ot({
1391
+ i(this, "createDetourPath", (e, t, s, o, n) => new dt({
1543
1392
  to: s,
1544
1393
  sourceDirection: e,
1545
1394
  targetDirection: t,
@@ -1552,7 +1401,7 @@ class ft {
1552
1401
  hasSourceArrow: this.hasSourceArrow,
1553
1402
  hasTargetArrow: this.hasTargetArrow
1554
1403
  }));
1555
- i(this, "createLinePath", (e, t, s) => new st({
1404
+ i(this, "createLinePath", (e, t, s) => new ht({
1556
1405
  to: s,
1557
1406
  sourceDirection: e,
1558
1407
  targetDirection: t,
@@ -1561,7 +1410,7 @@ class ft {
1561
1410
  hasSourceArrow: this.hasSourceArrow,
1562
1411
  hasTargetArrow: this.hasTargetArrow
1563
1412
  }));
1564
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? y.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? y.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? y.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? y.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new H({
1413
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? y.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? y.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? y.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? y.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new k({
1565
1414
  color: (e == null ? void 0 : e.color) ?? y.color,
1566
1415
  width: (e == null ? void 0 : e.width) ?? y.width,
1567
1416
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1577,7 +1426,7 @@ class ft {
1577
1426
  this.pathShape.render(e);
1578
1427
  }
1579
1428
  }
1580
- class yt {
1429
+ class Et {
1581
1430
  constructor(e) {
1582
1431
  i(this, "svg");
1583
1432
  i(this, "group");
@@ -1593,7 +1442,7 @@ class yt {
1593
1442
  i(this, "hasSourceArrow");
1594
1443
  i(this, "hasTargetArrow");
1595
1444
  i(this, "pathShape");
1596
- i(this, "createCyclePath", (e) => new _({
1445
+ i(this, "createCyclePath", (e) => new J({
1597
1446
  sourceDirection: e,
1598
1447
  arrowLength: this.arrowLength,
1599
1448
  side: this.cycleSquareSide,
@@ -1602,7 +1451,7 @@ class yt {
1602
1451
  hasSourceArrow: this.hasSourceArrow,
1603
1452
  hasTargetArrow: this.hasTargetArrow
1604
1453
  }));
1605
- i(this, "createDetourPath", (e, t, s, o, n) => new lt({
1454
+ i(this, "createDetourPath", (e, t, s, o, n) => new ft({
1606
1455
  to: s,
1607
1456
  sourceDirection: e,
1608
1457
  targetDirection: t,
@@ -1615,7 +1464,7 @@ class yt {
1615
1464
  hasSourceArrow: this.hasSourceArrow,
1616
1465
  hasTargetArrow: this.hasTargetArrow
1617
1466
  }));
1618
- i(this, "createLinePath", (e, t, s, o) => new it({
1467
+ i(this, "createLinePath", (e, t, s, o) => new ct({
1619
1468
  to: s,
1620
1469
  sourceDirection: e,
1621
1470
  targetDirection: t,
@@ -1632,7 +1481,7 @@ class yt {
1632
1481
  t,
1633
1482
  this.arrowOffset,
1634
1483
  this.cycleSquareSide / 2
1635
- ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new H({
1484
+ ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new k({
1636
1485
  color: (e == null ? void 0 : e.color) ?? y.color,
1637
1486
  width: (e == null ? void 0 : e.width) ?? y.width,
1638
1487
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1648,7 +1497,7 @@ class yt {
1648
1497
  this.pathShape.render(e);
1649
1498
  }
1650
1499
  }
1651
- class mt {
1500
+ class St {
1652
1501
  constructor(e) {
1653
1502
  i(this, "svg");
1654
1503
  i(this, "group");
@@ -1665,7 +1514,7 @@ class mt {
1665
1514
  i(this, "hasSourceArrow");
1666
1515
  i(this, "hasTargetArrow");
1667
1516
  i(this, "pathShape");
1668
- i(this, "createCyclePath", (e) => new _({
1517
+ i(this, "createCyclePath", (e) => new J({
1669
1518
  sourceDirection: e,
1670
1519
  arrowLength: this.arrowLength,
1671
1520
  side: this.cycleSquareSide,
@@ -1674,7 +1523,7 @@ class mt {
1674
1523
  hasSourceArrow: this.hasSourceArrow,
1675
1524
  hasTargetArrow: this.hasTargetArrow
1676
1525
  }));
1677
- i(this, "createDetourPath", (e, t, s, o, n) => new nt({
1526
+ i(this, "createDetourPath", (e, t, s, o, n) => new lt({
1678
1527
  to: s,
1679
1528
  sourceDirection: e,
1680
1529
  targetDirection: t,
@@ -1688,7 +1537,7 @@ class mt {
1688
1537
  hasSourceArrow: this.hasSourceArrow,
1689
1538
  hasTargetArrow: this.hasTargetArrow
1690
1539
  }));
1691
- i(this, "createLinePath", (e, t, s) => new at({
1540
+ i(this, "createLinePath", (e, t, s) => new gt({
1692
1541
  to: s,
1693
1542
  sourceDirection: e,
1694
1543
  targetDirection: t,
@@ -1704,7 +1553,7 @@ class mt {
1704
1553
  t,
1705
1554
  this.arrowOffset,
1706
1555
  this.cycleSquareSide / 2
1707
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? y.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new H({
1556
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? y.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new k({
1708
1557
  color: (e == null ? void 0 : e.color) ?? y.color,
1709
1558
  width: (e == null ? void 0 : e.width) ?? y.width,
1710
1559
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1720,7 +1569,7 @@ class mt {
1720
1569
  this.pathShape.render(e);
1721
1570
  }
1722
1571
  }
1723
- class vt {
1572
+ class bt {
1724
1573
  constructor(e) {
1725
1574
  i(this, "svg");
1726
1575
  i(this, "group");
@@ -1736,7 +1585,7 @@ class vt {
1736
1585
  i(this, "hasSourceArrow");
1737
1586
  i(this, "hasTargetArrow");
1738
1587
  i(this, "pathShape");
1739
- i(this, "createCyclePath", (e) => new _({
1588
+ i(this, "createCyclePath", (e) => new J({
1740
1589
  sourceDirection: e,
1741
1590
  arrowLength: this.arrowLength,
1742
1591
  side: this.cycleSquareSide,
@@ -1745,7 +1594,7 @@ class vt {
1745
1594
  hasSourceArrow: this.hasSourceArrow,
1746
1595
  hasTargetArrow: this.hasTargetArrow
1747
1596
  }));
1748
- i(this, "createDetourPath", (e, t, s, o, n) => new gt({
1597
+ i(this, "createDetourPath", (e, t, s, o, n) => new yt({
1749
1598
  to: s,
1750
1599
  sourceDirection: e,
1751
1600
  targetDirection: t,
@@ -1758,7 +1607,7 @@ class vt {
1758
1607
  hasSourceArrow: this.hasSourceArrow,
1759
1608
  hasTargetArrow: this.hasTargetArrow
1760
1609
  }));
1761
- i(this, "createLinePath", (e, t, s, o, n) => new ht({
1610
+ i(this, "createLinePath", (e, t, s, o, n) => new ut({
1762
1611
  to: s,
1763
1612
  sourceDirection: e,
1764
1613
  targetDirection: t,
@@ -1775,7 +1624,7 @@ class vt {
1775
1624
  t,
1776
1625
  this.arrowOffset,
1777
1626
  this.cycleSquareSide / 2
1778
- ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new H({
1627
+ ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new k({
1779
1628
  color: (e == null ? void 0 : e.color) ?? y.color,
1780
1629
  width: (e == null ? void 0 : e.width) ?? y.width,
1781
1630
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1791,10 +1640,10 @@ class vt {
1791
1640
  this.pathShape.render(e);
1792
1641
  }
1793
1642
  }
1794
- class Le {
1643
+ class Ve {
1795
1644
  constructor(e) {
1796
1645
  i(this, "svg");
1797
- i(this, "group", De());
1646
+ i(this, "group", Re());
1798
1647
  i(this, "line");
1799
1648
  i(this, "sourceArrow", null);
1800
1649
  i(this, "targetArrow", null);
@@ -1806,15 +1655,15 @@ class Le {
1806
1655
  i(this, "onAfterRender");
1807
1656
  i(this, "afterRenderEmitter");
1808
1657
  i(this, "arrowRenderer");
1809
- [this.afterRenderEmitter, this.onAfterRender] = E(), this.color = (e == null ? void 0 : e.color) ?? y.color, this.width = (e == null ? void 0 : e.width) ?? y.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.arrowRenderer = I((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? y.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? y.preOffset, this.svg = Ce(this.color), this.svg.appendChild(this.group), this.line = Me(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1658
+ [this.afterRenderEmitter, this.onAfterRender] = S(), this.color = (e == null ? void 0 : e.color) ?? y.color, this.width = (e == null ? void 0 : e.width) ?? y.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.arrowRenderer = I((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? y.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? y.preOffset, this.svg = Me(this.color), this.svg.appendChild(this.group), this.line = De(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1810
1659
  }
1811
1660
  render(e) {
1812
1661
  const { x: t, y: s, width: o, height: n, flipX: a, flipY: h } = Te(
1813
1662
  e.from,
1814
1663
  e.to
1815
1664
  );
1816
- Re(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1817
- const d = { x: o, y: n }, c = new ct({
1665
+ Le(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1666
+ const d = { x: o, y: n }, c = new wt({
1818
1667
  to: d,
1819
1668
  sourceOffset: this.sourceOffset,
1820
1669
  targetOffset: this.targetOffset,
@@ -1828,28 +1677,28 @@ class Le {
1828
1677
  if (u === 0)
1829
1678
  this.sourceArrow !== null && (g = "", this.sourceArrow.setAttribute("d", g)), this.targetArrow !== null && (l = "", this.targetArrow.setAttribute("d", l));
1830
1679
  else {
1831
- const w = {
1680
+ const p = {
1832
1681
  x: d.x / u,
1833
1682
  y: d.y / u
1834
1683
  };
1835
1684
  if (this.sourceArrow) {
1836
1685
  const f = {
1837
- x: w.x * this.sourceOffset,
1838
- y: w.y * this.sourceOffset
1686
+ x: p.x * this.sourceOffset,
1687
+ y: p.y * this.sourceOffset
1839
1688
  };
1840
1689
  g = this.arrowRenderer({
1841
- direction: w,
1690
+ direction: p,
1842
1691
  shift: f,
1843
1692
  arrowLength: this.arrowLength
1844
1693
  }), this.sourceArrow.setAttribute("d", g);
1845
1694
  }
1846
1695
  if (this.targetArrow) {
1847
1696
  const f = {
1848
- x: w.x * this.targetOffset,
1849
- y: w.y * this.targetOffset
1697
+ x: p.x * this.targetOffset,
1698
+ y: p.y * this.targetOffset
1850
1699
  };
1851
1700
  l = this.arrowRenderer({
1852
- direction: { x: -w.x, y: -w.y },
1701
+ direction: { x: -p.x, y: -p.y },
1853
1702
  shift: {
1854
1703
  x: d.x - f.x,
1855
1704
  y: d.y - f.y
@@ -1865,40 +1714,40 @@ class Le {
1865
1714
  });
1866
1715
  }
1867
1716
  }
1868
- const At = () => {
1717
+ const Pt = () => {
1869
1718
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
1870
1719
  return r.style.pointerEvents = "auto", r.style.cursor = "pointer", r;
1871
- }, xt = (r) => {
1720
+ }, Ct = (r) => {
1872
1721
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1873
1722
  return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
1874
- }, fe = (r) => {
1723
+ }, ye = (r) => {
1875
1724
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1876
1725
  return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
1877
1726
  };
1878
- class Et extends Error {
1727
+ class Nt extends Error {
1879
1728
  constructor(e) {
1880
1729
  super(e), this.name = "InteractiveEdgeError";
1881
1730
  }
1882
1731
  }
1883
- class Ve {
1732
+ class Fe {
1884
1733
  constructor(e, t) {
1885
1734
  i(this, "svg");
1886
1735
  i(this, "group");
1887
1736
  i(this, "line");
1888
1737
  i(this, "sourceArrow");
1889
1738
  i(this, "targetArrow");
1890
- i(this, "handle", At());
1739
+ i(this, "handle", Pt());
1891
1740
  i(this, "onAfterRender");
1892
1741
  i(this, "interactiveLine");
1893
1742
  i(this, "interactiveSourceArrow", null);
1894
1743
  i(this, "interactiveTargetArrow", null);
1895
- if (this.baseEdge = e, e instanceof Ve)
1896
- throw new Et(
1744
+ if (this.baseEdge = e, e instanceof Fe)
1745
+ throw new Nt(
1897
1746
  "interactive edge can be configured only once"
1898
1747
  );
1899
1748
  this.svg = this.baseEdge.svg, this.group = this.baseEdge.group, this.line = this.baseEdge.line, this.sourceArrow = this.baseEdge.sourceArrow, this.targetArrow = this.baseEdge.targetArrow, this.onAfterRender = this.baseEdge.onAfterRender;
1900
1749
  const s = (t == null ? void 0 : t.distance) ?? y.interactiveWidth;
1901
- this.interactiveLine = xt(s), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = fe(s), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = fe(s), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((o) => {
1750
+ this.interactiveLine = Ct(s), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = ye(s), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = ye(s), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((o) => {
1902
1751
  this.interactiveLine.setAttribute("d", o.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", o.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", o.targetArrowPath);
1903
1752
  });
1904
1753
  }
@@ -1906,7 +1755,7 @@ class Ve {
1906
1755
  this.baseEdge.render(e);
1907
1756
  }
1908
1757
  }
1909
- class yr {
1758
+ class Pr {
1910
1759
  constructor(e, t) {
1911
1760
  i(this, "group");
1912
1761
  i(this, "line");
@@ -1923,7 +1772,7 @@ class yr {
1923
1772
  this.baseShape.render(e);
1924
1773
  }
1925
1774
  }
1926
- class Fe {
1775
+ class Ie {
1927
1776
  constructor(e) {
1928
1777
  i(this, "onAfterNodeAdded");
1929
1778
  i(this, "onAfterNodeUpdated");
@@ -2019,7 +1868,165 @@ class Fe {
2019
1868
  return this.graphStore.getNodeAdjacentEdgeIds(e);
2020
1869
  }
2021
1870
  }
2022
- class Ie {
1871
+ class X {
1872
+ constructor(e) {
1873
+ i(this, "counter", 0);
1874
+ this.checkExists = e;
1875
+ }
1876
+ create(e) {
1877
+ if (e !== void 0)
1878
+ return e;
1879
+ for (; this.checkExists(this.counter); )
1880
+ this.counter++;
1881
+ return this.counter;
1882
+ }
1883
+ reset() {
1884
+ this.counter = 0;
1885
+ }
1886
+ }
1887
+ class Be {
1888
+ constructor(e, t, s) {
1889
+ i(this, "nodeIdGenerator", new X(
1890
+ (e) => this.graphStore.hasNode(e)
1891
+ ));
1892
+ i(this, "portIdGenerator", new X(
1893
+ (e) => this.graphStore.hasPort(e)
1894
+ ));
1895
+ i(this, "edgeIdGenerator", new X(
1896
+ (e) => this.graphStore.hasEdge(e)
1897
+ ));
1898
+ i(this, "onAfterNodeAdded", (e) => {
1899
+ this.htmlView.attachNode(e);
1900
+ });
1901
+ i(this, "onAfterNodeUpdated", (e) => {
1902
+ this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((t) => {
1903
+ this.htmlView.renderEdge(t);
1904
+ });
1905
+ });
1906
+ i(this, "onAfterNodePriorityUpdated", (e) => {
1907
+ this.htmlView.updateNodePriority(e);
1908
+ });
1909
+ i(this, "onBeforeNodeRemoved", (e) => {
1910
+ this.graphStore.getNodePortIds(e).forEach((t) => {
1911
+ this.unmarkPort(t);
1912
+ }), this.htmlView.detachNode(e);
1913
+ });
1914
+ i(this, "onAfterPortUpdated", (e) => {
1915
+ this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
1916
+ this.htmlView.renderEdge(t);
1917
+ });
1918
+ });
1919
+ i(this, "onBeforePortUnmarked", (e) => {
1920
+ this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
1921
+ this.removeEdge(t);
1922
+ });
1923
+ });
1924
+ i(this, "onAfterEdgeAdded", (e) => {
1925
+ this.htmlView.attachEdge(e);
1926
+ });
1927
+ i(this, "onAfterEdgeShapeUpdated", (e) => {
1928
+ this.htmlView.updateEdgeShape(e);
1929
+ });
1930
+ i(this, "onAfterEdgeUpdated", (e) => {
1931
+ this.htmlView.renderEdge(e);
1932
+ });
1933
+ i(this, "onAfterEdgePriorityUpdated", (e) => {
1934
+ this.htmlView.updateEdgePriority(e);
1935
+ });
1936
+ i(this, "onBeforeEdgeRemoved", (e) => {
1937
+ this.htmlView.detachEdge(e);
1938
+ });
1939
+ i(this, "onBeforeClear", () => {
1940
+ this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
1941
+ });
1942
+ this.graphStore = e, this.htmlView = t, this.params = s, this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
1943
+ this.onAfterNodePriorityUpdated
1944
+ ), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
1945
+ this.onAfterEdgeShapeUpdated
1946
+ ), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
1947
+ this.onAfterEdgePriorityUpdated
1948
+ ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear);
1949
+ }
1950
+ addNode(e) {
1951
+ const t = this.nodeIdGenerator.create(e.id);
1952
+ if (this.graphStore.addNode({
1953
+ id: t,
1954
+ element: e.element,
1955
+ x: e.x ?? null,
1956
+ y: e.y ?? null,
1957
+ centerFn: e.centerFn ?? this.params.nodes.centerFn,
1958
+ priority: e.priority ?? this.params.nodes.priorityFn()
1959
+ }), e.ports !== void 0)
1960
+ for (const s of e.ports)
1961
+ this.markPort({
1962
+ id: s.id,
1963
+ element: s.element,
1964
+ nodeId: t,
1965
+ direction: s.direction
1966
+ });
1967
+ }
1968
+ updateNode(e, t) {
1969
+ this.graphStore.updateNode(e, t ?? {});
1970
+ }
1971
+ removeNode(e) {
1972
+ this.graphStore.removeNode(e);
1973
+ }
1974
+ markPort(e) {
1975
+ const t = this.portIdGenerator.create(e.id);
1976
+ this.graphStore.addPort({
1977
+ id: t,
1978
+ element: e.element,
1979
+ nodeId: e.nodeId,
1980
+ direction: e.direction ?? this.params.ports.direction
1981
+ });
1982
+ }
1983
+ updatePort(e, t) {
1984
+ this.graphStore.updatePort(e, t ?? {});
1985
+ }
1986
+ unmarkPort(e) {
1987
+ this.graphStore.removePort(e);
1988
+ }
1989
+ addEdge(e) {
1990
+ const t = this.edgeIdGenerator.create(e.id);
1991
+ this.graphStore.addEdge({
1992
+ id: t,
1993
+ from: e.from,
1994
+ to: e.to,
1995
+ shape: e.shape ?? this.params.edges.shapeFactory(t),
1996
+ priority: e.priority ?? this.params.edges.priorityFn()
1997
+ });
1998
+ }
1999
+ updateEdge(e, t) {
2000
+ this.graphStore.updateEdge(e, t ?? {});
2001
+ }
2002
+ removeEdge(e) {
2003
+ this.graphStore.removeEdge(e);
2004
+ }
2005
+ clear() {
2006
+ this.graphStore.clear();
2007
+ }
2008
+ destroy() {
2009
+ this.clear(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
2010
+ this.onAfterNodePriorityUpdated
2011
+ ), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
2012
+ this.onAfterEdgeShapeUpdated
2013
+ ), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
2014
+ this.onAfterEdgePriorityUpdated
2015
+ ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
2016
+ }
2017
+ }
2018
+ const Tt = (r) => {
2019
+ setTimeout(() => {
2020
+ r();
2021
+ });
2022
+ }, Mt = (r) => {
2023
+ queueMicrotask(() => {
2024
+ r();
2025
+ });
2026
+ }, _ = (r) => {
2027
+ r();
2028
+ };
2029
+ class $e {
2023
2030
  constructor(e) {
2024
2031
  i(this, "onBeforeUpdated");
2025
2032
  i(this, "onAfterUpdated");
@@ -2029,43 +2036,122 @@ class Ie {
2029
2036
  getViewportMatrix() {
2030
2037
  return { ...this.viewportStore.getViewportMatrix() };
2031
2038
  }
2032
- getContentMatrix() {
2033
- return { ...this.viewportStore.getContentMatrix() };
2039
+ getContentMatrix() {
2040
+ return { ...this.viewportStore.getContentMatrix() };
2041
+ }
2042
+ getDimensions() {
2043
+ return this.viewportStore.getDimensions();
2044
+ }
2045
+ createContentCoords(e) {
2046
+ return this.viewportStore.createContentCoords(e);
2047
+ }
2048
+ createViewportCoords(e) {
2049
+ return this.viewportStore.createViewportCoords(e);
2050
+ }
2051
+ }
2052
+ const Dt = (r, e) => Symbol.iterator in r ? {
2053
+ minContentScale: e.focus.minContentScale,
2054
+ nodes: r,
2055
+ contentOffset: e.focus.contentOffset
2056
+ } : {
2057
+ minContentScale: r.minContentScale ?? e.focus.minContentScale,
2058
+ nodes: r.nodes ?? [],
2059
+ contentOffset: r.contentOffset ?? e.focus.contentOffset
2060
+ }, Ue = (r, e, t) => ({
2061
+ scale: r.scale,
2062
+ x: r.x + r.scale * e,
2063
+ y: r.y + r.scale * t
2064
+ }), Oe = (r, e, t, s) => ({
2065
+ scale: r.scale * e,
2066
+ x: r.scale * (1 - e) * t + r.x,
2067
+ y: r.scale * (1 - e) * s + r.y
2068
+ });
2069
+ class We {
2070
+ constructor(e, t, s) {
2071
+ this.graphStore = e, this.viewportStore = t, this.params = s;
2072
+ }
2073
+ patchViewportMatrix(e) {
2074
+ this.viewportStore.patchViewportMatrix(e);
2034
2075
  }
2035
- getDimensions() {
2036
- return this.viewportStore.getDimensions();
2076
+ patchContentMatrix(e) {
2077
+ this.viewportStore.patchContentMatrix(e);
2078
+ }
2079
+ center(e, t) {
2080
+ const { width: s, height: o } = this.viewportStore.getDimensions(), n = { x: s / 2, y: o / 2 }, a = this.viewportStore.getViewportMatrix(), h = this.viewportStore.createViewportCoords(e), d = h.x - n.x, c = h.y - n.y;
2081
+ let g = Ue(a, d, c);
2082
+ const l = t == null ? void 0 : t.contentScale;
2083
+ if (l !== void 0) {
2084
+ const u = 1 / l;
2085
+ g = Oe(
2086
+ g,
2087
+ u / a.scale,
2088
+ n.x,
2089
+ n.y
2090
+ );
2091
+ }
2092
+ this.viewportStore.patchViewportMatrix(g);
2037
2093
  }
2038
- createContentCoords(e) {
2039
- return this.viewportStore.createContentCoords(e);
2094
+ focus(e) {
2095
+ const t = Dt(e ?? {}, this.params);
2096
+ this.params.focus.schedule(() => {
2097
+ this.navigate(t);
2098
+ });
2040
2099
  }
2041
- createViewportCoords(e) {
2042
- return this.viewportStore.createViewportCoords(e);
2100
+ destroy() {
2101
+ this.viewportStore.destroy();
2102
+ }
2103
+ navigate(e) {
2104
+ let t = 1 / 0, s = -1 / 0, o = 1 / 0, n = -1 / 0, a = 0;
2105
+ const h = /* @__PURE__ */ new Set();
2106
+ for (const d of e.nodes)
2107
+ h.add(d);
2108
+ if (this.graphStore.getAllNodeIds().forEach((d) => {
2109
+ const { payload: c } = this.graphStore.getNode(d);
2110
+ c.x !== null && c.y !== null && (h.size === 0 || h.has(d)) && (t = Math.min(c.x, t), s = Math.max(c.x, s), o = Math.min(c.y, o), n = Math.max(c.y, n), a++);
2111
+ }), a > 0) {
2112
+ t -= e.contentOffset, o -= e.contentOffset, s += e.contentOffset, n += e.contentOffset;
2113
+ const d = {
2114
+ x: (t + s) / 2,
2115
+ y: (o + n) / 2
2116
+ }, c = (s - t) / 2, g = (n - o) / 2, { width: l, height: u } = this.viewportStore.getDimensions(), p = l / 2, f = u / 2, v = Math.max(
2117
+ c / p,
2118
+ g / f
2119
+ ), { scale: x } = this.viewportStore.getContentMatrix(), b = v > 1 ? x / v : x, P = Math.max(b, e.minContentScale);
2120
+ this.center(d, { contentScale: P });
2121
+ }
2043
2122
  }
2044
2123
  }
2045
- const Be = (r, e) => {
2046
- const t = new Se(), s = new Fe(t), o = new Ie(e), n = new xe(t, e, r), a = {
2124
+ const ze = (r, e) => {
2125
+ const t = new be(), s = new Ie(t), o = new $e(e), n = new Ee(t, e, r), a = {
2047
2126
  nodes: {
2048
2127
  centerFn: Ne,
2049
2128
  priorityFn: () => 0
2050
2129
  },
2051
2130
  edges: {
2052
- shapeFactory: () => new Le(),
2131
+ shapeFactory: () => new Ve(),
2053
2132
  priorityFn: () => 0
2054
2133
  },
2055
2134
  ports: {
2056
2135
  direction: 0
2057
2136
  }
2058
- };
2059
- return new Ee(
2060
- s,
2061
- o,
2137
+ }, h = new Be(
2062
2138
  t,
2063
- e,
2064
2139
  n,
2065
2140
  a
2141
+ ), d = {
2142
+ focus: {
2143
+ contentOffset: 0,
2144
+ minContentScale: 0,
2145
+ schedule: _
2146
+ }
2147
+ }, c = new We(
2148
+ t,
2149
+ e,
2150
+ d
2066
2151
  );
2152
+ return new Se(s, o, h, c);
2067
2153
  };
2068
- class Y {
2154
+ class H {
2069
2155
  constructor(e, t, s, o) {
2070
2156
  i(this, "onAfterPortMarked", (e) => {
2071
2157
  const t = this.canvas.graph.getPort(e);
@@ -2149,7 +2235,7 @@ class Y {
2149
2235
  this.canvas = e, this.element = t, this.window = s, this.params = o, this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2150
2236
  }
2151
2237
  static configure(e, t, s, o) {
2152
- new Y(e, t, s, o);
2238
+ new H(e, t, s, o);
2153
2239
  }
2154
2240
  hookPortEvents(e) {
2155
2241
  e.addEventListener("mousedown", this.onPortMouseDown, {
@@ -2174,7 +2260,7 @@ class Y {
2174
2260
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
2175
2261
  }
2176
2262
  }
2177
- class St {
2263
+ class Rt {
2178
2264
  constructor(e, t, s) {
2179
2265
  this.canvas = e, this.layoutAlgorithm = t, this.params = s;
2180
2266
  }
@@ -2188,7 +2274,7 @@ class St {
2188
2274
  }), this.params.onAfterApplied();
2189
2275
  }
2190
2276
  }
2191
- class bt {
2277
+ class Lt {
2192
2278
  constructor(e, t, s) {
2193
2279
  this.canvas = e, this.layoutAlgorithm = t, this.params = s;
2194
2280
  }
@@ -2395,15 +2481,7 @@ class ee {
2395
2481
  return e;
2396
2482
  }
2397
2483
  }
2398
- const Pt = (r, e, t) => ({
2399
- scale: r.scale,
2400
- x: r.x + r.scale * e,
2401
- y: r.y + r.scale * t
2402
- }), Nt = (r, e, t, s) => ({
2403
- scale: r.scale * e,
2404
- x: r.scale * (1 - e) * t + r.x,
2405
- y: r.scale * (1 - e) * s + r.y
2406
- }), B = (r) => {
2484
+ const B = (r) => {
2407
2485
  const e = [], t = r.touches.length;
2408
2486
  for (let h = 0; h < t; h++)
2409
2487
  e.push([r.touches[h].clientX, r.touches[h].clientY]);
@@ -2422,7 +2500,7 @@ const Pt = (r, e, t) => ({
2422
2500
  touches: e
2423
2501
  };
2424
2502
  };
2425
- class X {
2503
+ class Y {
2426
2504
  constructor(e, t, s, o) {
2427
2505
  i(this, "viewport");
2428
2506
  i(this, "prevTouches", null);
@@ -2512,10 +2590,10 @@ class X {
2512
2590
  }), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2513
2591
  }
2514
2592
  static configure(e, t, s, o) {
2515
- new X(e, t, s, o);
2593
+ new Y(e, t, s, o);
2516
2594
  }
2517
2595
  moveViewport(e, t) {
2518
- const s = this.viewport.getViewportMatrix(), o = Pt(s, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
2596
+ const s = this.viewport.getViewportMatrix(), o = Ue(s, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
2519
2597
  prevTransform: s,
2520
2598
  nextTransform: o,
2521
2599
  canvasWidth: n,
@@ -2524,7 +2602,7 @@ class X {
2524
2602
  this.performTransform(h);
2525
2603
  }
2526
2604
  scaleViewport(e, t, s) {
2527
- const o = this.canvas.viewport.getViewportMatrix(), n = Nt(o, e, t, s), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
2605
+ const o = this.canvas.viewport.getViewportMatrix(), n = Oe(o, e, t, s), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
2528
2606
  prevTransform: o,
2529
2607
  nextTransform: n,
2530
2608
  canvasWidth: a,
@@ -2610,7 +2688,7 @@ class te {
2610
2688
  this.scheduleLoadAreaAroundViewport(), o.onTransformFinished();
2611
2689
  }
2612
2690
  };
2613
- X.configure(
2691
+ Y.configure(
2614
2692
  e,
2615
2693
  this.element,
2616
2694
  this.window,
@@ -2648,13 +2726,13 @@ class te {
2648
2726
  });
2649
2727
  }
2650
2728
  }
2651
- const Tt = () => {
2729
+ const Vt = () => {
2652
2730
  const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2653
2731
  return r.style.position = "absolute", r.style.inset = "0", r;
2654
- }, Ct = () => {
2732
+ }, Ft = () => {
2655
2733
  const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2656
2734
  return r.setAttribute("fill", "url(#pattern)"), r;
2657
- }, Mt = () => {
2735
+ }, It = () => {
2658
2736
  const r = document.createElementNS(
2659
2737
  "http://www.w3.org/2000/svg",
2660
2738
  "pattern"
@@ -2663,9 +2741,9 @@ const Tt = () => {
2663
2741
  };
2664
2742
  class re {
2665
2743
  constructor(e, t, s) {
2666
- i(this, "svg", Tt());
2667
- i(this, "patternRenderingRectangle", Ct());
2668
- i(this, "pattern", Mt());
2744
+ i(this, "svg", Vt());
2745
+ i(this, "patternRenderingRectangle", Ft());
2746
+ i(this, "pattern", It());
2669
2747
  i(this, "patternContent");
2670
2748
  i(this, "tileWidth");
2671
2749
  i(this, "tileHeight");
@@ -2707,10 +2785,10 @@ class se {
2707
2785
  i(this, "onEdgeCreated", (e) => {
2708
2786
  this.params.onAfterEdgeCreated(e);
2709
2787
  });
2710
- this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Be(
2788
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = ze(
2711
2789
  this.overlayLayer,
2712
2790
  this.viewportStore
2713
- ), Y.configure(
2791
+ ), H.configure(
2714
2792
  this.canvas,
2715
2793
  this.overlayLayer,
2716
2794
  this.window,
@@ -2761,9 +2839,9 @@ class se {
2761
2839
  portDirection: this.params.dragPortDirection
2762
2840
  };
2763
2841
  this.isTargetDragging = s === "direct";
2764
- const [w, f] = this.isTargetDragging ? [l, u] : [u, l];
2765
- this.overlayCanvas.addNode(O(w)), this.overlayCanvas.addNode(O(f)), this.overlayCanvas.addEdge({
2766
- from: w.overlayNodeId,
2842
+ const [p, f] = this.isTargetDragging ? [l, u] : [u, l];
2843
+ this.overlayCanvas.addNode(O(p)), this.overlayCanvas.addNode(O(f)), this.overlayCanvas.addEdge({
2844
+ from: p.overlayNodeId,
2767
2845
  to: f.overlayNodeId,
2768
2846
  shape: this.params.edgeShapeFactory(N.EdgeId)
2769
2847
  });
@@ -2772,7 +2850,7 @@ class se {
2772
2850
  this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
2773
2851
  }
2774
2852
  tryCreateConnection(e) {
2775
- const t = Pe(this.canvas.graph, e), s = this.staticPortId;
2853
+ const t = Ce(this.canvas.graph, e), s = this.staticPortId;
2776
2854
  if (t === null) {
2777
2855
  this.params.onEdgeCreationInterrupted({
2778
2856
  staticPortId: s,
@@ -2803,10 +2881,10 @@ class oe {
2803
2881
  i(this, "onEdgeReattached", (e) => {
2804
2882
  this.params.onAfterEdgeReattached(e);
2805
2883
  });
2806
- this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Be(
2884
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = ze(
2807
2885
  this.overlayLayer,
2808
2886
  this.viewportStore
2809
- ), Y.configure(
2887
+ ), H.configure(
2810
2888
  this.canvas,
2811
2889
  this.overlayLayer,
2812
2890
  this.window,
@@ -2844,7 +2922,7 @@ class oe {
2844
2922
  const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(h), g = c.element.getBoundingClientRect(), l = {
2845
2923
  x: g.x + g.width / 2,
2846
2924
  y: g.y + g.height / 2
2847
- }, u = this.overlayLayer.getBoundingClientRect(), w = this.canvas.viewport.createContentCoords({
2925
+ }, u = this.overlayLayer.getBoundingClientRect(), p = this.canvas.viewport.createContentCoords({
2848
2926
  x: l.x - u.x,
2849
2927
  y: l.y - u.y
2850
2928
  }), f = this.canvas.viewport.createContentCoords({
@@ -2860,20 +2938,20 @@ class oe {
2860
2938
  }, this.canvas.removeEdge(s);
2861
2939
  const v = {
2862
2940
  overlayNodeId: N.StaticNodeId,
2863
- portCoords: w,
2941
+ portCoords: p,
2864
2942
  portDirection: c.direction
2865
- }, S = {
2943
+ }, x = {
2866
2944
  overlayNodeId: N.DraggingNodeId,
2867
2945
  portCoords: f,
2868
2946
  portDirection: d.direction
2869
- }, [b, T] = this.isTargetDragging ? [v, S] : [S, v];
2870
- this.overlayCanvas.addNode(O(b)), this.overlayCanvas.addNode(O(T));
2871
- const P = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(N.EdgeId) : o.shape;
2947
+ }, [b, P] = this.isTargetDragging ? [v, x] : [x, v];
2948
+ this.overlayCanvas.addNode(O(b)), this.overlayCanvas.addNode(O(P));
2949
+ const C = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(N.EdgeId) : o.shape;
2872
2950
  return this.overlayCanvas.addEdge({
2873
2951
  id: N.EdgeId,
2874
2952
  from: b.overlayNodeId,
2875
- to: T.overlayNodeId,
2876
- shape: P
2953
+ to: P.overlayNodeId,
2954
+ shape: C
2877
2955
  }), !0;
2878
2956
  }
2879
2957
  resetDragState() {
@@ -2890,7 +2968,7 @@ class oe {
2890
2968
  });
2891
2969
  }
2892
2970
  tryCreateConnection(e) {
2893
- const t = Pe(this.canvas.graph, e);
2971
+ const t = Ce(this.canvas.graph, e);
2894
2972
  if (this.overlayCanvas.removeEdge(N.EdgeId), t === null) {
2895
2973
  const d = this.draggingEdgePayload;
2896
2974
  this.params.onEdgeReattachInterrupted({
@@ -2933,7 +3011,7 @@ class ie {
2933
3011
  new ie(e, t);
2934
3012
  }
2935
3013
  }
2936
- class z {
3014
+ class ne {
2937
3015
  constructor(e, t, s) {
2938
3016
  i(this, "applyScheduled", !1);
2939
3017
  i(this, "apply", () => {
@@ -2950,7 +3028,7 @@ class z {
2950
3028
  });
2951
3029
  }
2952
3030
  static configure(e, t, s) {
2953
- new z(
3031
+ new ne(
2954
3032
  e,
2955
3033
  t,
2956
3034
  s
@@ -2960,49 +3038,33 @@ class z {
2960
3038
  this.applyScheduled || (this.applyScheduled = !0, this.defererFn(this.apply));
2961
3039
  }
2962
3040
  }
2963
- class Dt {
3041
+ class Bt {
2964
3042
  static configure(e, t) {
2965
- const s = t.applyOn, o = new St(e, t.algorithm, {
3043
+ const s = t.applyOn, o = new Rt(e, t.algorithm, {
2966
3044
  staticNodeResolver: t.staticNodeResolver,
2967
3045
  onBeforeApplied: t.onBeforeApplied,
2968
3046
  onAfterApplied: t.onAfterApplied
2969
3047
  });
2970
3048
  switch (s.type) {
2971
- case "manual": {
3049
+ case "trigger": {
2972
3050
  ie.configure(
2973
3051
  o,
2974
3052
  s.trigger
2975
3053
  );
2976
3054
  break;
2977
3055
  }
2978
- case "topologyChangeMacrotask": {
2979
- z.configure(
3056
+ case "topologyChangeSchedule": {
3057
+ ne.configure(
2980
3058
  e.graph,
2981
3059
  o,
2982
- (n) => {
2983
- setTimeout(() => {
2984
- n();
2985
- });
2986
- }
2987
- );
2988
- break;
2989
- }
2990
- case "topologyChangeMicrotask": {
2991
- z.configure(
2992
- e.graph,
2993
- o,
2994
- (n) => {
2995
- queueMicrotask(() => {
2996
- n();
2997
- });
2998
- }
3060
+ s.schedule
2999
3061
  );
3000
3062
  break;
3001
3063
  }
3002
3064
  }
3003
3065
  }
3004
3066
  }
3005
- class Rt {
3067
+ class $t {
3006
3068
  constructor(e, t) {
3007
3069
  i(this, "previousTimeStamp");
3008
3070
  i(this, "step", (e) => {
@@ -3017,150 +3079,51 @@ class Rt {
3017
3079
  this.win = e, this.callback = t, this.win.requestAnimationFrame(this.step);
3018
3080
  }
3019
3081
  }
3020
- class ne {
3082
+ class ae {
3021
3083
  constructor(e, t, s) {
3022
3084
  i(this, "applier");
3023
3085
  i(this, "step", (e) => {
3024
3086
  this.applier.apply(e);
3025
3087
  });
3026
- this.win = s, this.applier = new bt(e, t.algorithm, {
3088
+ this.win = s, this.applier = new Lt(e, t.algorithm, {
3027
3089
  staticNodeResolver: t.staticNodeResolver,
3028
3090
  onBeforeApplied: t.onBeforeApplied,
3029
3091
  onAfterApplied: t.onAfterApplied
3030
- }), new Rt(this.win, this.step);
3092
+ }), new $t(this.win, this.step);
3031
3093
  }
3032
3094
  static configure(e, t, s) {
3033
- new ne(e, t, s);
3095
+ new ae(e, t, s);
3034
3096
  }
3035
3097
  }
3036
- const Lt = () => {
3098
+ const Ut = () => {
3037
3099
  const r = document.createElement("div");
3038
3100
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
3039
- }, q = () => {
3101
+ }, j = () => {
3040
3102
  const r = document.createElement("div");
3041
3103
  return r.style.position = "absolute", r.style.inset = "0", r;
3042
- }, ye = () => {
3043
- const r = q();
3104
+ }, me = () => {
3105
+ const r = j();
3044
3106
  return r.style.pointerEvents = "none", r;
3045
3107
  };
3046
- class Vt {
3108
+ class Ot {
3047
3109
  constructor(e) {
3048
- i(this, "background", q());
3049
- i(this, "main", q());
3050
- i(this, "overlayConnectablePorts", ye());
3051
- i(this, "overlayDraggableEdges", ye());
3052
- i(this, "host", Lt());
3110
+ i(this, "background", j());
3111
+ i(this, "main", j());
3112
+ i(this, "overlayConnectablePorts", me());
3113
+ i(this, "overlayDraggableEdges", me());
3114
+ i(this, "host", Ut());
3053
3115
  this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.host.appendChild(this.overlayConnectablePorts), this.host.appendChild(this.overlayDraggableEdges);
3054
3116
  }
3055
3117
  destroy() {
3056
3118
  this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlayConnectablePorts), this.host.removeChild(this.overlayDraggableEdges), this.element.removeChild(this.host);
3057
3119
  }
3058
3120
  }
3059
- const K = (r) => () => r, me = K(0), Ft = () => {
3060
- let r = 0;
3061
- return () => r++;
3062
- }, It = (r, e) => {
3063
- let t = me, s = me;
3064
- const o = Ft();
3065
- return r === "incremental" && (t = o), e === "incremental" && (s = o), typeof r == "number" && (t = K(r)), typeof e == "number" && (s = K(e)), typeof r == "function" && (t = r), typeof e == "function" && (s = e), {
3066
- nodesPriorityFn: t,
3067
- edgesPriorityFn: s
3068
- };
3069
- }, ae = (r) => {
3070
- if (typeof r == "function")
3071
- return r;
3072
- switch (r.type) {
3073
- case "straight":
3074
- return () => new mt({
3075
- color: r.color,
3076
- width: r.width,
3077
- arrowLength: r.arrowLength,
3078
- arrowOffset: r.arrowOffset,
3079
- arrowRenderer: r.arrowRenderer,
3080
- hasSourceArrow: r.hasSourceArrow,
3081
- hasTargetArrow: r.hasTargetArrow,
3082
- cycleSquareSide: r.cycleSquareSide,
3083
- roundness: r.roundness,
3084
- detourDistance: r.detourDistance,
3085
- detourDirection: r.detourDirection
3086
- });
3087
- case "horizontal":
3088
- return () => new yt({
3089
- color: r.color,
3090
- width: r.width,
3091
- arrowLength: r.arrowLength,
3092
- arrowOffset: r.arrowOffset,
3093
- arrowRenderer: r.arrowRenderer,
3094
- hasSourceArrow: r.hasSourceArrow,
3095
- hasTargetArrow: r.hasTargetArrow,
3096
- cycleSquareSide: r.cycleSquareSide,
3097
- roundness: r.roundness,
3098
- detourDistance: r.detourDistance
3099
- });
3100
- case "vertical":
3101
- return () => new vt({
3102
- color: r.color,
3103
- width: r.width,
3104
- arrowLength: r.arrowLength,
3105
- arrowOffset: r.arrowOffset,
3106
- arrowRenderer: r.arrowRenderer,
3107
- hasSourceArrow: r.hasSourceArrow,
3108
- hasTargetArrow: r.hasTargetArrow,
3109
- cycleSquareSide: r.cycleSquareSide,
3110
- roundness: r.roundness,
3111
- detourDistance: r.detourDistance
3112
- });
3113
- case "direct":
3114
- return () => new Le({
3115
- color: r.color,
3116
- width: r.width,
3117
- arrowLength: r.arrowLength,
3118
- arrowRenderer: r.arrowRenderer,
3119
- hasSourceArrow: r.hasSourceArrow,
3120
- hasTargetArrow: r.hasTargetArrow,
3121
- sourceOffset: r.sourceOffset,
3122
- targetOffset: r.targetOffset
3123
- });
3124
- default:
3125
- return () => new ft({
3126
- color: r.color,
3127
- width: r.width,
3128
- arrowLength: r.arrowLength,
3129
- arrowRenderer: r.arrowRenderer,
3130
- hasSourceArrow: r.hasSourceArrow,
3131
- hasTargetArrow: r.hasTargetArrow,
3132
- cycleRadius: r.cycleRadius,
3133
- smallCycleRadius: r.smallCycleRadius,
3134
- curvature: r.curvature,
3135
- detourDistance: r.detourDistance,
3136
- detourDirection: r.detourDirection
3137
- });
3138
- }
3139
- }, Bt = (r) => {
3140
- var t, s, o, n, a;
3141
- const e = It(
3142
- (t = r.nodes) == null ? void 0 : t.priority,
3143
- (s = r.edges) == null ? void 0 : s.priority
3144
- );
3145
- return {
3146
- nodes: {
3147
- centerFn: ((o = r.nodes) == null ? void 0 : o.centerFn) ?? Ne,
3148
- priorityFn: e.nodesPriorityFn
3149
- },
3150
- ports: {
3151
- direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
3152
- },
3153
- edges: {
3154
- shapeFactory: ae(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
3155
- priorityFn: e.edgesPriorityFn
3156
- }
3157
- };
3158
- }, $t = (r) => {
3159
- var w, f, v, S, b, T;
3160
- const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
3121
+ const Wt = (r) => {
3122
+ var p, f, v, x, b, P;
3123
+ const e = ((p = r.events) == null ? void 0 : p.onNodeDragStarted) ?? (() => {
3161
3124
  }), t = ((f = r.events) == null ? void 0 : f.onNodeDrag) ?? (() => {
3162
3125
  }), s = r.nodeDragVerifier ?? (() => !0), o = ((v = r.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
3163
- }), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (S = r.mouse) == null ? void 0 : S.dragCursor, d = h !== void 0 ? h : "grab", c = (b = r.mouse) == null ? void 0 : b.mouseDownEventVerifier, g = c !== void 0 ? c : (P) => P.button === 0, l = (T = r.mouse) == null ? void 0 : T.mouseUpEventVerifier, u = l !== void 0 ? l : (P) => P.button === 0;
3126
+ }), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (x = r.mouse) == null ? void 0 : x.dragCursor, d = h !== void 0 ? h : "grab", c = (b = r.mouse) == null ? void 0 : b.mouseDownEventVerifier, g = c !== void 0 ? c : (C) => C.button === 0, l = (P = r.mouse) == null ? void 0 : P.mouseUpEventVerifier, u = l !== void 0 ? l : (C) => C.button === 0;
3164
3127
  return {
3165
3128
  moveOnTop: n,
3166
3129
  moveEdgesOnTop: a,
@@ -3173,7 +3136,7 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3173
3136
  nodeDragVerifier: s,
3174
3137
  onNodeDragFinished: o
3175
3138
  };
3176
- }, Ut = (r) => {
3139
+ }, zt = (r) => {
3177
3140
  const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, s = r.minY !== null ? r.minY : -1 / 0, o = r.maxY !== null ? r.maxY : 1 / 0;
3178
3141
  return (n) => {
3179
3142
  let a = n.nextTransform.x, h = n.nextTransform.y;
@@ -3183,7 +3146,7 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3183
3146
  const g = n.canvasHeight * n.prevTransform.scale, l = o - g;
3184
3147
  return h > l && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, l)), { scale: n.nextTransform.scale, x: a, y: h };
3185
3148
  };
3186
- }, Ot = (r) => {
3149
+ }, kt = (r) => {
3187
3150
  const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, o = t !== null ? 1 / t : 1 / 0;
3188
3151
  return (n) => {
3189
3152
  const a = n.prevTransform, h = n.nextTransform;
@@ -3204,7 +3167,7 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3204
3167
  y: g
3205
3168
  };
3206
3169
  };
3207
- }, Wt = (r) => (e) => r.reduce(
3170
+ }, Ht = (r) => (e) => r.reduce(
3208
3171
  (t, s) => s({
3209
3172
  prevTransform: e.prevTransform,
3210
3173
  nextTransform: t,
@@ -3217,12 +3180,12 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3217
3180
  return r;
3218
3181
  switch (r.type) {
3219
3182
  case "scale-limit":
3220
- return Ot({
3183
+ return kt({
3221
3184
  minContentScale: r.minContentScale ?? 0,
3222
3185
  maxContentScale: r.maxContentScale ?? 1 / 0
3223
3186
  });
3224
3187
  case "shift-limit":
3225
- return Ut({
3188
+ return zt({
3226
3189
  minX: r.minX ?? -1 / 0,
3227
3190
  maxX: r.maxX ?? 1 / 0,
3228
3191
  minY: r.minY ?? -1 / 0,
@@ -3230,22 +3193,22 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3230
3193
  });
3231
3194
  }
3232
3195
  }, Ae = (r) => {
3233
- var f, v, S, b, T, P, L, V, he, de, ce, le;
3196
+ var f, v, x, b, P, C, L, V, de, ce, le, ge;
3234
3197
  const e = (f = r == null ? void 0 : r.scale) == null ? void 0 : f.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
3235
3198
  let o;
3236
- s !== void 0 ? Array.isArray(s) ? o = Wt(
3199
+ s !== void 0 ? Array.isArray(s) ? o = Ht(
3237
3200
  s.map(
3238
- (C) => ve(C)
3201
+ (T) => ve(T)
3239
3202
  )
3240
- ) : o = ve(s) : o = (C) => C.nextTransform;
3241
- const n = ((v = r == null ? void 0 : r.shift) == null ? void 0 : v.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((S = r == null ? void 0 : r.events) == null ? void 0 : S.onBeforeTransformChange) ?? (() => {
3203
+ ) : o = ve(s) : o = (T) => T.nextTransform;
3204
+ const n = ((v = r == null ? void 0 : r.shift) == null ? void 0 : v.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
3242
3205
  }), h = ((b = r == null ? void 0 : r.events) == null ? void 0 : b.onTransformChange) ?? (() => {
3243
- }), d = (T = r == null ? void 0 : r.shift) == null ? void 0 : T.mouseDownEventVerifier, c = d !== void 0 ? d : (C) => C.button === 0, g = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseUpEventVerifier, l = g !== void 0 ? g : (C) => C.button === 0, u = (L = r == null ? void 0 : r.scale) == null ? void 0 : L.mouseWheelEventVerifier, w = u !== void 0 ? u : () => !0;
3206
+ }), d = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseDownEventVerifier, c = d !== void 0 ? d : (T) => T.button === 0, g = (C = r == null ? void 0 : r.shift) == null ? void 0 : C.mouseUpEventVerifier, l = g !== void 0 ? g : (T) => T.button === 0, u = (L = r == null ? void 0 : r.scale) == null ? void 0 : L.mouseWheelEventVerifier, p = u !== void 0 ? u : () => !0;
3244
3207
  return {
3245
3208
  wheelSensitivity: t,
3246
3209
  onTransformStarted: ((V = r == null ? void 0 : r.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
3247
3210
  }),
3248
- onTransformFinished: ((he = r == null ? void 0 : r.events) == null ? void 0 : he.onTransformFinished) ?? (() => {
3211
+ onTransformFinished: ((de = r == null ? void 0 : r.events) == null ? void 0 : de.onTransformFinished) ?? (() => {
3249
3212
  }),
3250
3213
  onBeforeTransformChange: a,
3251
3214
  onTransformChange: h,
@@ -3253,31 +3216,101 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3253
3216
  shiftCursor: n,
3254
3217
  mouseDownEventVerifier: c,
3255
3218
  mouseUpEventVerifier: l,
3256
- mouseWheelEventVerifier: w,
3257
- scaleWheelFinishTimeout: ((de = r == null ? void 0 : r.scale) == null ? void 0 : de.wheelFinishTimeout) ?? 500,
3258
- onResizeTransformStarted: ((ce = r == null ? void 0 : r.events) == null ? void 0 : ce.onResizeTransformStarted) ?? (() => {
3219
+ mouseWheelEventVerifier: p,
3220
+ scaleWheelFinishTimeout: ((ce = r == null ? void 0 : r.scale) == null ? void 0 : ce.wheelFinishTimeout) ?? 500,
3221
+ onResizeTransformStarted: ((le = r == null ? void 0 : r.events) == null ? void 0 : le.onResizeTransformStarted) ?? (() => {
3259
3222
  }),
3260
- onResizeTransformFinished: ((le = r == null ? void 0 : r.events) == null ? void 0 : le.onResizeTransformFinished) ?? (() => {
3223
+ onResizeTransformFinished: ((ge = r == null ? void 0 : r.events) == null ? void 0 : ge.onResizeTransformFinished) ?? (() => {
3261
3224
  })
3262
3225
  };
3263
- }, zt = (r, e) => {
3226
+ }, Yt = (r, e) => {
3264
3227
  const t = document.createElementNS(
3265
3228
  "http://www.w3.org/2000/svg",
3266
3229
  "circle"
3267
3230
  );
3268
3231
  return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
3269
- }, kt = (r) => r instanceof SVGElement ? r : zt(
3232
+ }, Xt = (r) => r instanceof SVGElement ? r : Yt(
3270
3233
  (r == null ? void 0 : r.radius) ?? 1.5,
3271
3234
  (r == null ? void 0 : r.color) ?? "#d8d8d8"
3272
- ), Ht = (r) => {
3273
- const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25, o = kt(r.renderer ?? {});
3235
+ ), Gt = (r) => {
3236
+ const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25, o = Xt(r.renderer ?? {});
3274
3237
  return {
3275
3238
  tileWidth: t,
3276
3239
  tileHeight: s,
3277
3240
  renderer: o,
3278
3241
  maxViewportScale: r.maxViewportScale ?? 10
3279
3242
  };
3280
- }, Yt = (r, e, t) => {
3243
+ }, he = (r) => {
3244
+ if (typeof r == "function")
3245
+ return r;
3246
+ switch (r.type) {
3247
+ case "straight":
3248
+ return () => new St({
3249
+ color: r.color,
3250
+ width: r.width,
3251
+ arrowLength: r.arrowLength,
3252
+ arrowOffset: r.arrowOffset,
3253
+ arrowRenderer: r.arrowRenderer,
3254
+ hasSourceArrow: r.hasSourceArrow,
3255
+ hasTargetArrow: r.hasTargetArrow,
3256
+ cycleSquareSide: r.cycleSquareSide,
3257
+ roundness: r.roundness,
3258
+ detourDistance: r.detourDistance,
3259
+ detourDirection: r.detourDirection
3260
+ });
3261
+ case "horizontal":
3262
+ return () => new Et({
3263
+ color: r.color,
3264
+ width: r.width,
3265
+ arrowLength: r.arrowLength,
3266
+ arrowOffset: r.arrowOffset,
3267
+ arrowRenderer: r.arrowRenderer,
3268
+ hasSourceArrow: r.hasSourceArrow,
3269
+ hasTargetArrow: r.hasTargetArrow,
3270
+ cycleSquareSide: r.cycleSquareSide,
3271
+ roundness: r.roundness,
3272
+ detourDistance: r.detourDistance
3273
+ });
3274
+ case "vertical":
3275
+ return () => new bt({
3276
+ color: r.color,
3277
+ width: r.width,
3278
+ arrowLength: r.arrowLength,
3279
+ arrowOffset: r.arrowOffset,
3280
+ arrowRenderer: r.arrowRenderer,
3281
+ hasSourceArrow: r.hasSourceArrow,
3282
+ hasTargetArrow: r.hasTargetArrow,
3283
+ cycleSquareSide: r.cycleSquareSide,
3284
+ roundness: r.roundness,
3285
+ detourDistance: r.detourDistance
3286
+ });
3287
+ case "direct":
3288
+ return () => new Ve({
3289
+ color: r.color,
3290
+ width: r.width,
3291
+ arrowLength: r.arrowLength,
3292
+ arrowRenderer: r.arrowRenderer,
3293
+ hasSourceArrow: r.hasSourceArrow,
3294
+ hasTargetArrow: r.hasTargetArrow,
3295
+ sourceOffset: r.sourceOffset,
3296
+ targetOffset: r.targetOffset
3297
+ });
3298
+ default:
3299
+ return () => new xt({
3300
+ color: r.color,
3301
+ width: r.width,
3302
+ arrowLength: r.arrowLength,
3303
+ arrowRenderer: r.arrowRenderer,
3304
+ hasSourceArrow: r.hasSourceArrow,
3305
+ hasTargetArrow: r.hasTargetArrow,
3306
+ cycleRadius: r.cycleRadius,
3307
+ smallCycleRadius: r.smallCycleRadius,
3308
+ curvature: r.curvature,
3309
+ detourDistance: r.detourDistance,
3310
+ detourDirection: r.detourDirection
3311
+ });
3312
+ }
3313
+ }, jt = (r, e, t) => {
3281
3314
  var c, g, l;
3282
3315
  const s = () => "direct", o = (u) => u, n = (u) => u.button === 0, a = () => {
3283
3316
  }, h = () => {
@@ -3292,13 +3325,13 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3292
3325
  onEdgeCreationInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeCreationInterrupted) ?? d,
3293
3326
  onEdgeCreationPrevented: ((l = r.events) == null ? void 0 : l.onEdgeCreationPrevented) ?? h,
3294
3327
  dragPortDirection: r.dragPortDirection ?? t,
3295
- edgeShapeFactory: r.edgeShape !== void 0 ? ae(r.edgeShape) : e
3328
+ edgeShapeFactory: r.edgeShape !== void 0 ? he(r.edgeShape) : e
3296
3329
  };
3297
- }, Xt = (r, e) => {
3330
+ }, qt = (r, e) => {
3298
3331
  var c, g, l;
3299
3332
  const t = (u) => u, s = (u) => u.button === 0 && u.ctrlKey, o = (u) => u.button === 0, n = (u) => {
3300
- const w = e.getPortAdjacentEdgeIds(u);
3301
- return w.length > 0 ? w[w.length - 1] : null;
3333
+ const p = e.getPortAdjacentEdgeIds(u);
3334
+ return p.length > 0 ? p[p.length - 1] : null;
3302
3335
  }, a = () => {
3303
3336
  }, h = () => {
3304
3337
  }, d = () => {
@@ -3308,15 +3341,15 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3308
3341
  mouseDownEventVerifier: r.mouseDownEventVerifier ?? s,
3309
3342
  mouseUpEventVerifier: r.mouseUpEventVerifier ?? o,
3310
3343
  draggingEdgeResolver: r.draggingEdgeResolver ?? n,
3311
- draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? ae(r.draggingEdgeShape) : null,
3344
+ draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? he(r.draggingEdgeShape) : null,
3312
3345
  onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
3313
3346
  onEdgeReattachInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeReattachInterrupted) ?? d,
3314
3347
  onEdgeReattachPrevented: ((l = r.events) == null ? void 0 : l.onEdgeReattachPrevented) ?? h
3315
3348
  };
3316
- }, Gt = (r) => ({
3349
+ }, Kt = (r) => ({
3317
3350
  nodeVerticalRadius: r.nodeContainingRadius.vertical,
3318
3351
  nodeHorizontalRadius: r.nodeContainingRadius.horizontal
3319
- }), jt = (r) => {
3352
+ }), Qt = (r) => {
3320
3353
  var e, t;
3321
3354
  return {
3322
3355
  onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
@@ -3325,13 +3358,13 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3325
3358
  })
3326
3359
  };
3327
3360
  };
3328
- class qt extends Error {
3361
+ class Zt extends Error {
3329
3362
  constructor() {
3330
3363
  super(...arguments);
3331
3364
  i(this, "name", "CanvasBuilderError");
3332
3365
  }
3333
3366
  }
3334
- class $e {
3367
+ class ke {
3335
3368
  constructor(e, t, s) {
3336
3369
  i(this, "dt");
3337
3370
  i(this, "nodeMass");
@@ -3364,12 +3397,12 @@ class $e {
3364
3397
  const s = this.graph.getEdge(t), o = this.graph.getPort(s.from), n = this.graph.getPort(s.to), a = this.currentCoords.get(o.nodeId), h = this.currentCoords.get(n.nodeId), d = this.distanceVectorGenerator.create(
3365
3398
  a,
3366
3399
  h
3367
- ), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, w = e.get(o.nodeId), f = e.get(n.nodeId);
3368
- w.x += l, w.y += u, f.x -= l, f.y -= u;
3400
+ ), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, p = e.get(o.nodeId), f = e.get(n.nodeId);
3401
+ p.x += l, p.y += u, f.x -= l, f.y -= u;
3369
3402
  });
3370
3403
  }
3371
3404
  }
3372
- class Ue {
3405
+ class He {
3373
3406
  constructor(e) {
3374
3407
  i(this, "PI2", 2 * Math.PI);
3375
3408
  this.rand = e;
@@ -3388,13 +3421,13 @@ class Ue {
3388
3421
  return { ex: h, ey: d, d: a };
3389
3422
  }
3390
3423
  }
3391
- const Oe = (r) => {
3424
+ const Ye = (r) => {
3392
3425
  if (r.distance === 0)
3393
3426
  return r.maxForce;
3394
3427
  const e = r.coefficient * (r.sourceCharge * r.targetCharge / (r.distance * r.distance));
3395
3428
  return Math.min(e, r.maxForce);
3396
3429
  };
3397
- class Kt {
3430
+ class Jt {
3398
3431
  constructor(e) {
3399
3432
  i(this, "nodeCharge");
3400
3433
  i(this, "distanceVectorGenerator");
@@ -3409,19 +3442,19 @@ class Kt {
3409
3442
  const d = s[h], c = e.get(a), g = e.get(d), l = this.distanceVectorGenerator.create(
3410
3443
  c,
3411
3444
  g
3412
- ), u = Oe({
3445
+ ), u = Ye({
3413
3446
  coefficient: 1,
3414
3447
  sourceCharge: this.nodeCharge,
3415
3448
  targetCharge: this.nodeCharge,
3416
3449
  distance: l.d,
3417
3450
  maxForce: this.maxForce
3418
- }), w = u * l.ex, f = u * l.ey, v = t.get(a), S = t.get(d);
3419
- v.x -= w, v.y -= f, S.x += w, S.y += f;
3451
+ }), p = u * l.ex, f = u * l.ey, v = t.get(a), x = t.get(d);
3452
+ v.x -= p, v.y -= f, x.x += p, x.y += f;
3420
3453
  }
3421
3454
  }
3422
3455
  }
3423
3456
  }
3424
- const Qt = (r) => {
3457
+ const _t = (r) => {
3425
3458
  if (r.size === 0)
3426
3459
  return {
3427
3460
  centerX: 0,
@@ -3439,7 +3472,7 @@ const Qt = (r) => {
3439
3472
  radius: h / 2
3440
3473
  };
3441
3474
  };
3442
- class Zt {
3475
+ class er {
3443
3476
  constructor(e) {
3444
3477
  i(this, "root");
3445
3478
  i(this, "leaves", /* @__PURE__ */ new Map());
@@ -3494,8 +3527,8 @@ class Zt {
3494
3527
  this.sortedParentNodes.push(e);
3495
3528
  const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c = o / 2;
3496
3529
  e.nodeIds.forEach((u) => {
3497
- const { x: w, y: f } = this.coords.get(u);
3498
- w < t ? f < s ? d.add(u) : h.add(u) : f < s ? a.add(u) : n.add(u), e.nodeIds.delete(u);
3530
+ const { x: p, y: f } = this.coords.get(u);
3531
+ p < t ? f < s ? d.add(u) : h.add(u) : f < s ? a.add(u) : n.add(u), e.nodeIds.delete(u);
3499
3532
  });
3500
3533
  const g = {
3501
3534
  parent: e,
@@ -3596,7 +3629,7 @@ class Zt {
3596
3629
  }), { x: t / e.size, y: s / e.size };
3597
3630
  }
3598
3631
  }
3599
- class Jt {
3632
+ class tr {
3600
3633
  constructor(e) {
3601
3634
  i(this, "areaRadiusThreshold");
3602
3635
  i(this, "nodeMass");
@@ -3608,7 +3641,7 @@ class Jt {
3608
3641
  this.areaRadiusThreshold = e.areaRadiusThreshold, this.nodeMass = e.nodeMass, this.nodeCharge = e.nodeCharge, this.theta = e.theta, this.distanceVectorGenerator = e.distanceVectorGenerator, this.nodeForceCoefficient = e.nodeForceCoefficient, this.maxForce = e.maxForce;
3609
3642
  }
3610
3643
  apply(e, t) {
3611
- const s = Qt(e), o = new Zt({
3644
+ const s = _t(e), o = new er({
3612
3645
  box: s,
3613
3646
  coords: e,
3614
3647
  areaRadiusThreshold: this.areaRadiusThreshold,
@@ -3723,7 +3756,7 @@ class Jt {
3723
3756
  const t = this.distanceVectorGenerator.create(
3724
3757
  e.sourceCoords,
3725
3758
  e.targetCoords
3726
- ), s = Oe({
3759
+ ), s = Ye({
3727
3760
  coefficient: this.nodeForceCoefficient,
3728
3761
  sourceCharge: e.sourceCharge,
3729
3762
  targetCharge: e.targetCharge,
@@ -3758,7 +3791,7 @@ class Jt {
3758
3791
  }
3759
3792
  }
3760
3793
  }
3761
- const We = (r) => r.theta !== 0 ? new Jt({
3794
+ const Xe = (r) => r.theta !== 0 ? new tr({
3762
3795
  nodeCharge: r.nodeCharge,
3763
3796
  nodeForceCoefficient: r.nodeForceCoefficient,
3764
3797
  distanceVectorGenerator: r.distanceVectorGenerator,
@@ -3766,13 +3799,13 @@ const We = (r) => r.theta !== 0 ? new Jt({
3766
3799
  theta: r.theta,
3767
3800
  nodeMass: r.nodeMass,
3768
3801
  areaRadiusThreshold: r.areaRadiusThreshold
3769
- }) : new Kt({
3802
+ }) : new Jt({
3770
3803
  nodeCharge: r.nodeCharge,
3771
3804
  nodeForceCoefficient: r.nodeForceCoefficient,
3772
3805
  distanceVectorGenerator: r.distanceVectorGenerator,
3773
3806
  maxForce: r.maxForce
3774
3807
  });
3775
- class ze {
3808
+ class Ge {
3776
3809
  constructor(e) {
3777
3810
  i(this, "rand");
3778
3811
  i(this, "sparsity");
@@ -3795,7 +3828,7 @@ class ze {
3795
3828
  }), o;
3796
3829
  }
3797
3830
  }
3798
- class _t {
3831
+ class rr {
3799
3832
  constructor(e) {
3800
3833
  i(this, "distanceVectorGenerator");
3801
3834
  i(this, "nodeForcesApplicationStrategy");
@@ -3806,7 +3839,7 @@ class _t {
3806
3839
  i(this, "edgeEquilibriumLength");
3807
3840
  i(this, "edgeStiffness");
3808
3841
  i(this, "convergenceVelocity");
3809
- this.maxIterations = e.maxIterations, this.dtSec = e.dtSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.convergenceVelocity = e.convergenceVelocity, this.distanceVectorGenerator = new Ue(e.rand), this.nodeForcesApplicationStrategy = We({
3842
+ this.maxIterations = e.maxIterations, this.dtSec = e.dtSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.convergenceVelocity = e.convergenceVelocity, this.distanceVectorGenerator = new He(e.rand), this.nodeForcesApplicationStrategy = Xe({
3810
3843
  distanceVectorGenerator: this.distanceVectorGenerator,
3811
3844
  nodeCharge: e.nodeCharge,
3812
3845
  maxForce: e.maxForce,
@@ -3814,7 +3847,7 @@ class _t {
3814
3847
  theta: e.barnesHutTheta,
3815
3848
  areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
3816
3849
  nodeMass: e.nodeMass
3817
- }), this.fillerLayoutAlgorithm = new ze({
3850
+ }), this.fillerLayoutAlgorithm = new Ge({
3818
3851
  rand: e.rand,
3819
3852
  sparsity: e.edgeEquilibriumLength
3820
3853
  });
@@ -3824,7 +3857,7 @@ class _t {
3824
3857
  graph: t,
3825
3858
  viewport: s
3826
3859
  });
3827
- for (let n = 0; n < this.maxIterations && !(new $e(
3860
+ for (let n = 0; n < this.maxIterations && !(new ke(
3828
3861
  t,
3829
3862
  o,
3830
3863
  {
@@ -3840,7 +3873,7 @@ class _t {
3840
3873
  return o;
3841
3874
  }
3842
3875
  }
3843
- class er {
3876
+ class sr {
3844
3877
  constructor(e) {
3845
3878
  i(this, "forest", /* @__PURE__ */ new Set());
3846
3879
  i(this, "remainingNodeIds");
@@ -3883,7 +3916,7 @@ class er {
3883
3916
  }
3884
3917
  }
3885
3918
  }
3886
- class tr {
3919
+ class or {
3887
3920
  constructor(e) {
3888
3921
  i(this, "baseRadius");
3889
3922
  this.baseRadius = e.radius;
@@ -3911,12 +3944,12 @@ class tr {
3911
3944
  };
3912
3945
  }
3913
3946
  }
3914
- class rr {
3947
+ class ir {
3915
3948
  constructor(e, t) {
3916
3949
  i(this, "offsets", /* @__PURE__ */ new Map());
3917
3950
  i(this, "childrenRadii", /* @__PURE__ */ new Map());
3918
3951
  i(this, "layerNodePlacementResolver");
3919
- this.tree = e, this.layerNodePlacementResolver = new tr({
3952
+ this.tree = e, this.layerNodePlacementResolver = new or({
3920
3953
  radius: t.spaceAroundRadius
3921
3954
  }), [...this.tree.sequence].reverse().forEach((s) => {
3922
3955
  if (s.children.size === 0)
@@ -3937,16 +3970,16 @@ class rr {
3937
3970
  return this.offsets;
3938
3971
  }
3939
3972
  }
3940
- class sr {
3973
+ class nr {
3941
3974
  constructor(e) {
3942
3975
  this.params = e;
3943
3976
  }
3944
3977
  calculateCoordinates(e) {
3945
- const t = /* @__PURE__ */ new Map(), o = new er(e.graph).generate();
3978
+ const t = /* @__PURE__ */ new Map(), o = new sr(e.graph).generate();
3946
3979
  let n = 0;
3947
3980
  return o.forEach((a) => {
3948
3981
  t.set(a.root.nodeId, { x: n, y: 0 });
3949
- const d = new rr(a, {
3982
+ const d = new ir(a, {
3950
3983
  spaceAroundRadius: this.params.layerSpace / 2
3951
3984
  }).generate();
3952
3985
  let c = [a.root];
@@ -3954,9 +3987,9 @@ class sr {
3954
3987
  const g = [];
3955
3988
  n += this.params.layerWidth, c.forEach((l) => {
3956
3989
  l.children.forEach((u) => {
3957
- const w = t.get(l.nodeId).y;
3990
+ const p = t.get(l.nodeId).y;
3958
3991
  t.set(u.nodeId, {
3959
- y: w + d.get(u.nodeId),
3992
+ y: p + d.get(u.nodeId),
3960
3993
  x: n
3961
3994
  }), g.push(u);
3962
3995
  });
@@ -3968,7 +4001,7 @@ class sr {
3968
4001
  }), t;
3969
4002
  }
3970
4003
  }
3971
- class or {
4004
+ class ar {
3972
4005
  constructor(e) {
3973
4006
  i(this, "distanceVectorGenerator");
3974
4007
  i(this, "nodeForcesApplicationStrategy");
@@ -3978,7 +4011,7 @@ class or {
3978
4011
  i(this, "edgeEquilibriumLength");
3979
4012
  i(this, "edgeStiffness");
3980
4013
  i(this, "fillerLayoutAlgorithm");
3981
- this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new Ue(e.rand), this.nodeForcesApplicationStrategy = We({
4014
+ this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new He(e.rand), this.nodeForcesApplicationStrategy = Xe({
3982
4015
  distanceVectorGenerator: this.distanceVectorGenerator,
3983
4016
  nodeCharge: e.nodeCharge,
3984
4017
  maxForce: e.maxForce,
@@ -3986,7 +4019,7 @@ class or {
3986
4019
  theta: e.barnesHutTheta,
3987
4020
  areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
3988
4021
  nodeMass: e.nodeMass
3989
- }), this.fillerLayoutAlgorithm = new ze({
4022
+ }), this.fillerLayoutAlgorithm = new Ge({
3990
4023
  rand: e.rand,
3991
4024
  sparsity: e.edgeEquilibriumLength
3992
4025
  });
@@ -3996,7 +4029,7 @@ class or {
3996
4029
  graph: t,
3997
4030
  viewport: s
3998
4031
  });
3999
- return new $e(
4032
+ return new ke(
4000
4033
  t,
4001
4034
  n,
4002
4035
  {
@@ -4013,12 +4046,12 @@ class or {
4013
4046
  }) ? /* @__PURE__ */ new Map() : n;
4014
4047
  }
4015
4048
  }
4016
- const ke = (r) => {
4049
+ const je = (r) => {
4017
4050
  let e = 1779033703, t = 3144134277, s = 1013904242, o = 2773480762;
4018
4051
  for (let n = 0, a; n < r.length; n++)
4019
4052
  a = r.charCodeAt(n), e = t ^ Math.imul(e ^ a, 597399067), t = s ^ Math.imul(t ^ a, 2869860233), s = o ^ Math.imul(s ^ a, 951274213), o = e ^ Math.imul(o ^ a, 2716044179);
4020
4053
  return e = Math.imul(s ^ e >>> 18, 597399067), t = Math.imul(o ^ t >>> 22, 2869860233), s = Math.imul(e ^ s >>> 17, 951274213), o = Math.imul(t ^ o >>> 19, 2716044179), e ^= t ^ s ^ o, t ^= e, s ^= e, o ^= e, [e >>> 0, t >>> 0, s >>> 0, o >>> 0];
4021
- }, He = (r, e, t, s) => function() {
4054
+ }, qe = (r, e, t, s) => function() {
4022
4055
  r |= 0, e |= 0, t |= 0, s |= 0;
4023
4056
  const o = (r + e | 0) + s | 0;
4024
4057
  return s = s + 1 | 0, r = e ^ e >>> 9, e = t + (t << 3) | 0, t = t << 21 | t >>> 11, t = t + o | 0, (o >>> 0) / 4294967296;
@@ -4036,14 +4069,14 @@ const ke = (r) => {
4036
4069
  nodeForceCoefficient: 1,
4037
4070
  barnesHutAreaRadiusThreshold: 0.01,
4038
4071
  barnesHutTheta: 1
4039
- }), ir = (r) => {
4072
+ }), hr = (r) => {
4040
4073
  var e, t;
4041
4074
  switch (r == null ? void 0 : r.type) {
4042
4075
  case "custom":
4043
4076
  return r.instance;
4044
4077
  default: {
4045
- const s = ke((r == null ? void 0 : r.seed) ?? A.seed), o = He(s[0], s[1], s[2], s[3]);
4046
- return new or({
4078
+ const s = je((r == null ? void 0 : r.seed) ?? A.seed), o = qe(s[0], s[1], s[2], s[3]);
4079
+ return new ar({
4047
4080
  rand: o,
4048
4081
  maxTimeDeltaSec: (r == null ? void 0 : r.maxTimeDeltaSec) ?? A.maxTimeDeltaSec,
4049
4082
  nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? A.nodeCharge,
@@ -4058,27 +4091,29 @@ const ke = (r) => {
4058
4091
  });
4059
4092
  }
4060
4093
  }
4061
- }, j = {
4094
+ }, G = {
4062
4095
  staticNodeResolver: () => !1,
4063
4096
  onBeforeApplied: () => {
4064
4097
  },
4065
4098
  onAfterApplied: () => {
4066
4099
  }
4067
- }, nr = (r) => {
4100
+ }, dr = (r) => {
4068
4101
  var t, s;
4069
4102
  return {
4070
- algorithm: ir((r == null ? void 0 : r.algorithm) ?? {}),
4071
- staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? j.staticNodeResolver,
4072
- onBeforeApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeApplied) ?? j.onBeforeApplied,
4073
- onAfterApplied: ((s = r == null ? void 0 : r.events) == null ? void 0 : s.onAfterApplied) ?? j.onAfterApplied
4103
+ algorithm: hr((r == null ? void 0 : r.algorithm) ?? {}),
4104
+ staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? G.staticNodeResolver,
4105
+ onBeforeApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeApplied) ?? G.onBeforeApplied,
4106
+ onAfterApplied: ((s = r == null ? void 0 : r.events) == null ? void 0 : s.onAfterApplied) ?? G.onAfterApplied
4074
4107
  };
4075
- }, ar = (r) => r instanceof Q ? {
4076
- type: "manual",
4108
+ }, cr = (r) => r instanceof K ? {
4109
+ type: "trigger",
4077
4110
  trigger: r
4078
4111
  } : (r == null ? void 0 : r.type) === "topologyChangeMacrotask" ? {
4079
- type: "topologyChangeMacrotask"
4112
+ type: "topologyChangeSchedule",
4113
+ schedule: Tt
4080
4114
  } : {
4081
- type: "topologyChangeMicrotask"
4115
+ type: "topologyChangeSchedule",
4116
+ schedule: Mt
4082
4117
  }, F = Object.freeze({
4083
4118
  staticNodeResolver: () => !1,
4084
4119
  onBeforeApplied: () => {
@@ -4096,7 +4131,7 @@ const ke = (r) => {
4096
4131
  d: r.d * e.a + r.e * e.d,
4097
4132
  e: r.d * e.b + r.e * e.e,
4098
4133
  f: r.d * e.c + r.e * e.f + r.f
4099
- }), hr = (r) => {
4134
+ }), lr = (r) => {
4100
4135
  const { a: e, b: t, c: s, d: o, e: n, f: a } = r, h = e * n - t * o;
4101
4136
  return {
4102
4137
  a: n / h,
@@ -4107,7 +4142,7 @@ const ke = (r) => {
4107
4142
  f: (s * o - e * a) / h
4108
4143
  };
4109
4144
  };
4110
- class dr {
4145
+ class gr {
4111
4146
  resolve(e) {
4112
4147
  if ("shift" in e)
4113
4148
  return this.createShiftBaseMatrix(e.shift);
@@ -4151,7 +4186,7 @@ class dr {
4151
4186
  const s = $(
4152
4187
  t,
4153
4188
  e
4154
- ), o = hr(t);
4189
+ ), o = lr(t);
4155
4190
  return $(s, o);
4156
4191
  }
4157
4192
  createShiftBaseMatrix(e) {
@@ -4196,7 +4231,7 @@ class dr {
4196
4231
  };
4197
4232
  }
4198
4233
  }
4199
- const cr = (r) => {
4234
+ const ur = (r) => {
4200
4235
  if (r === void 0)
4201
4236
  return (o) => o;
4202
4237
  if (typeof r == "function")
@@ -4210,7 +4245,7 @@ const cr = (r) => {
4210
4245
  e: 1,
4211
4246
  f: 0
4212
4247
  };
4213
- const s = new dr();
4248
+ const s = new gr();
4214
4249
  return e.forEach((o) => {
4215
4250
  const n = s.resolve(o);
4216
4251
  t = $(t, n);
@@ -4221,20 +4256,20 @@ const cr = (r) => {
4221
4256
  y: t.d * n + t.e * a + t.f
4222
4257
  };
4223
4258
  };
4224
- }, lr = (r) => {
4259
+ }, pr = (r) => {
4225
4260
  var e, t;
4226
4261
  switch (r == null ? void 0 : r.type) {
4227
4262
  case "custom":
4228
4263
  return r.instance;
4229
4264
  case "hierarchical":
4230
- return new sr({
4265
+ return new nr({
4231
4266
  layerWidth: r.layerWidth ?? F.hierarchicalLayout.layerWidth,
4232
4267
  layerSpace: r.layerSpace ?? F.hierarchicalLayout.layerSpace,
4233
- transform: cr(r.transform)
4268
+ transform: ur(r.transform)
4234
4269
  });
4235
4270
  default: {
4236
- const s = ke((r == null ? void 0 : r.seed) ?? A.seed), o = He(s[0], s[1], s[2], s[3]);
4237
- return new _t({
4271
+ const s = je((r == null ? void 0 : r.seed) ?? A.seed), o = qe(s[0], s[1], s[2], s[3]);
4272
+ return new rr({
4238
4273
  dtSec: (r == null ? void 0 : r.dtSec) ?? A.dtSec,
4239
4274
  maxIterations: (r == null ? void 0 : r.maxIterations) ?? A.maxIterations,
4240
4275
  rand: o,
@@ -4250,16 +4285,16 @@ const cr = (r) => {
4250
4285
  });
4251
4286
  }
4252
4287
  }
4253
- }, gr = (r) => {
4288
+ }, wr = (r) => {
4254
4289
  var e, t;
4255
4290
  return {
4256
- algorithm: lr(r == null ? void 0 : r.algorithm),
4257
- applyOn: ar(r == null ? void 0 : r.applyOn),
4258
- staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? F.staticNodeResolver,
4259
- onBeforeApplied: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onBeforeApplied) ?? F.onBeforeApplied,
4260
- onAfterApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onAfterApplied) ?? F.onAfterApplied
4291
+ algorithm: pr(r.algorithm),
4292
+ applyOn: cr(r.applyOn),
4293
+ staticNodeResolver: r.staticNodeResolver ?? F.staticNodeResolver,
4294
+ onBeforeApplied: ((e = r.events) == null ? void 0 : e.onBeforeApplied) ?? F.onBeforeApplied,
4295
+ onAfterApplied: ((t = r.events) == null ? void 0 : t.onAfterApplied) ?? F.onAfterApplied
4261
4296
  };
4262
- }, ur = (r, e) => ({
4297
+ }, fr = (r, e) => ({
4263
4298
  ...r,
4264
4299
  onNodeDragStarted: (t) => {
4265
4300
  e.add(t), r.onNodeDragStarted(t);
@@ -4267,17 +4302,56 @@ const cr = (r) => {
4267
4302
  onNodeDragFinished: (t) => {
4268
4303
  e.delete(t), r.onNodeDragFinished(t);
4269
4304
  }
4270
- }), pr = (r, e) => {
4305
+ }), yr = (r, e) => {
4271
4306
  r.onBeforeNodeRemoved.subscribe((t) => {
4272
4307
  e.delete(t);
4273
4308
  }), r.onBeforeClear.subscribe(() => {
4274
4309
  e.clear();
4275
4310
  });
4276
- }, wr = (r, e) => ({
4311
+ }, mr = (r, e) => ({
4277
4312
  ...r,
4278
4313
  staticNodeResolver: (t) => r.staticNodeResolver(t) || e.has(t)
4279
- });
4280
- class mr {
4314
+ }), q = (r) => () => r, xe = q(0), vr = () => {
4315
+ let r = 0;
4316
+ return () => r++;
4317
+ }, Ar = (r, e) => {
4318
+ let t = xe, s = xe;
4319
+ const o = vr();
4320
+ return r === "incremental" && (t = o), e === "incremental" && (s = o), typeof r == "number" && (t = q(r)), typeof e == "number" && (s = q(e)), typeof r == "function" && (t = r), typeof e == "function" && (s = e), {
4321
+ nodesPriorityFn: t,
4322
+ edgesPriorityFn: s
4323
+ };
4324
+ }, xr = (r) => {
4325
+ var t, s, o, n, a;
4326
+ const e = Ar(
4327
+ (t = r.nodes) == null ? void 0 : t.priority,
4328
+ (s = r.edges) == null ? void 0 : s.priority
4329
+ );
4330
+ return {
4331
+ nodes: {
4332
+ centerFn: ((o = r.nodes) == null ? void 0 : o.centerFn) ?? Ne,
4333
+ priorityFn: e.nodesPriorityFn
4334
+ },
4335
+ ports: {
4336
+ direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
4337
+ },
4338
+ edges: {
4339
+ shapeFactory: he(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
4340
+ priorityFn: e.edgesPriorityFn
4341
+ }
4342
+ };
4343
+ }, Er = (r) => r.applyOn.type === "topologyChangeSchedule" ? r.applyOn.schedule : _, Sr = (r) => {
4344
+ var s, o;
4345
+ const { canvasDefaults: e } = r, t = r.hasLayout ? Er(r.layoutParams) : _;
4346
+ return {
4347
+ focus: {
4348
+ contentOffset: ((s = e.focus) == null ? void 0 : s.contentOffset) ?? 100,
4349
+ minContentScale: ((o = e.focus) == null ? void 0 : o.minContentScale) ?? 0,
4350
+ schedule: t
4351
+ }
4352
+ };
4353
+ };
4354
+ class Cr {
4281
4355
  constructor(e) {
4282
4356
  i(this, "used", !1);
4283
4357
  i(this, "canvasDefaults", {});
@@ -4297,192 +4371,167 @@ class mr {
4297
4371
  i(this, "hasUserDraggableEdges", !1);
4298
4372
  i(this, "hasAnimatedLayout", !1);
4299
4373
  i(this, "hasLayout", !1);
4300
- i(this, "boxRenderingTrigger", new Q());
4374
+ i(this, "boxRenderingTrigger", new K());
4301
4375
  i(this, "graphStore");
4302
4376
  i(this, "viewportStore");
4303
4377
  i(this, "graph");
4304
4378
  i(this, "viewport");
4305
4379
  i(this, "window", window);
4306
4380
  i(this, "animationStaticNodes", /* @__PURE__ */ new Set());
4307
- this.element = e, this.viewportStore = new _e(this.element), this.viewport = new Ie(this.viewportStore), this.graphStore = new Se(), this.graph = new Fe(this.graphStore);
4381
+ this.element = e, this.viewportStore = new ot(this.element), this.viewport = new $e(this.viewportStore), this.graphStore = new be(), this.graph = new Ie(this.graphStore);
4308
4382
  }
4309
- /**
4310
- * specifies default values for graph entities
4311
- */
4312
4383
  setDefaults(e) {
4313
4384
  return this.canvasDefaults = e, this;
4314
4385
  }
4315
- /**
4316
- * enables nodes draggable by user
4317
- */
4318
4386
  enableUserDraggableNodes(e) {
4319
4387
  return this.hasDraggableNodes = !0, this.dragConfig = e ?? {}, this;
4320
4388
  }
4321
- /**
4322
- * enables viewport transformable by user
4323
- */
4324
4389
  enableUserTransformableViewport(e) {
4325
4390
  return this.hasTransformableViewport = !0, this.transformConfig = e ?? {}, this;
4326
4391
  }
4327
- /**
4328
- * enables automatic edges update on node resize
4329
- */
4330
4392
  enableNodeResizeReactiveEdges() {
4331
4393
  return this.hasNodeResizeReactiveEdges = !0, this;
4332
4394
  }
4333
- /**
4334
- * enables built-in virtual scroll behavior, when only nodes and edges close
4335
- * to viewport are rendered
4336
- */
4337
4395
  enableVirtualScroll(e) {
4338
4396
  return this.virtualScrollConfig = e, this;
4339
4397
  }
4340
- /**
4341
- * enables built-in background rendering
4342
- */
4343
4398
  enableBackground(e) {
4344
4399
  return this.hasBackground = !0, this.backgroundConfig = e ?? {}, this;
4345
4400
  }
4346
- /**
4347
- * enables edge creation by dragging one port to another
4348
- */
4349
4401
  enableUserConnectablePorts(e) {
4350
4402
  return this.hasUserConnectablePorts = !0, this.connectablePortsConfig = e ?? {}, this;
4351
4403
  }
4352
- /**
4353
- * enables edges dragging by dragging one of the adjacent ports
4354
- */
4355
4404
  enableUserDraggableEdges(e) {
4356
4405
  return this.hasUserDraggableEdges = !0, this.draggableEdgesConfig = e ?? {}, this;
4357
4406
  }
4358
- /**
4359
- * enables nodes positioning with specified layout
4360
- */
4361
4407
  enableLayout(e) {
4362
4408
  return this.layoutConfig = e ?? {}, this.hasLayout = !0, this.hasAnimatedLayout = !1, this;
4363
4409
  }
4364
- /**
4365
- * enables animated nodes positioning with specified layout
4366
- */
4367
4410
  enableAnimatedLayout(e) {
4368
4411
  return this.animatedLayoutConfig = e ?? {}, this.hasAnimatedLayout = !0, this.hasLayout = !1, this;
4369
4412
  }
4370
- /**
4371
- * builds final canvas
4372
- */
4373
4413
  build() {
4374
4414
  if (this.used)
4375
- throw new qt("CanvasBuilder is a single use object");
4415
+ throw new Zt("CanvasBuilder is a single use object");
4376
4416
  this.used = !0;
4377
- const e = new Vt(this.element), t = this.createHtmlView(e.main), s = Bt(this.canvasDefaults), o = new Ee(
4378
- this.graph,
4379
- this.viewport,
4417
+ const e = new Ot(this.element), t = this.createHtmlView(e.main), s = xr(
4418
+ this.canvasDefaults
4419
+ ), o = new Be(
4380
4420
  this.graphStore,
4381
- this.viewportStore,
4382
4421
  t,
4383
4422
  s
4423
+ ), n = wr(this.layoutConfig), a = Sr({
4424
+ canvasDefaults: this.canvasDefaults,
4425
+ hasLayout: this.hasLayout,
4426
+ layoutParams: n
4427
+ }), h = new We(
4428
+ this.graphStore,
4429
+ this.viewportStore,
4430
+ a
4431
+ ), d = new Se(
4432
+ this.graph,
4433
+ this.viewport,
4434
+ o,
4435
+ h
4384
4436
  );
4385
4437
  if (this.hasBackground && re.configure(
4386
- o,
4387
- Ht(this.backgroundConfig),
4438
+ d,
4439
+ Gt(this.backgroundConfig),
4388
4440
  e.background
4389
- ), this.hasNodeResizeReactiveEdges && Z.configure(o), this.hasDraggableNodes) {
4390
- let a = $t(this.dragConfig);
4391
- this.hasAnimatedLayout && (a = ur(
4392
- a,
4441
+ ), this.hasNodeResizeReactiveEdges && Q.configure(d), this.hasDraggableNodes) {
4442
+ let g = Wt(this.dragConfig);
4443
+ this.hasAnimatedLayout && (g = fr(
4444
+ g,
4393
4445
  this.animationStaticNodes
4394
4446
  )), ee.configure(
4395
- o,
4447
+ d,
4396
4448
  e.main,
4397
4449
  this.window,
4398
- a
4450
+ g
4399
4451
  );
4400
4452
  }
4401
4453
  if (this.hasUserConnectablePorts) {
4402
- const a = Yt(
4454
+ const g = jt(
4403
4455
  this.connectablePortsConfig,
4404
4456
  s.edges.shapeFactory,
4405
4457
  s.ports.direction
4406
4458
  );
4407
4459
  se.configure(
4408
- o,
4460
+ d,
4409
4461
  e.overlayConnectablePorts,
4410
4462
  this.viewportStore,
4411
4463
  this.window,
4412
- a
4464
+ g
4413
4465
  );
4414
4466
  }
4415
4467
  if (this.hasUserDraggableEdges) {
4416
- const a = Xt(
4468
+ const g = qt(
4417
4469
  this.draggableEdgesConfig,
4418
- o.graph
4470
+ d.graph
4419
4471
  );
4420
4472
  oe.configure(
4421
- o,
4473
+ d,
4422
4474
  e.overlayDraggableEdges,
4423
4475
  this.viewportStore,
4424
4476
  this.window,
4425
- a
4477
+ g
4426
4478
  );
4427
4479
  }
4428
4480
  if (this.virtualScrollConfig !== void 0 ? te.configure(
4429
- o,
4481
+ d,
4430
4482
  e.main,
4431
4483
  this.window,
4432
4484
  Ae(this.transformConfig),
4433
4485
  this.boxRenderingTrigger,
4434
- Gt(this.virtualScrollConfig)
4435
- ) : this.hasTransformableViewport && X.configure(
4436
- o,
4486
+ Kt(this.virtualScrollConfig)
4487
+ ) : this.hasTransformableViewport && Y.configure(
4488
+ d,
4437
4489
  e.main,
4438
4490
  this.window,
4439
4491
  Ae(this.transformConfig)
4440
- ), this.hasLayout && Dt.configure(
4441
- o,
4442
- gr(this.layoutConfig)
4443
- ), this.hasAnimatedLayout) {
4444
- let a = nr(
4492
+ ), this.hasLayout && Bt.configure(d, n), this.hasAnimatedLayout) {
4493
+ let g = dr(
4445
4494
  this.animatedLayoutConfig
4446
4495
  );
4447
- this.hasDraggableNodes && (pr(
4448
- o.graph,
4496
+ this.hasDraggableNodes && (yr(
4497
+ d.graph,
4449
4498
  this.animationStaticNodes
4450
- ), a = wr(
4451
- a,
4499
+ ), g = mr(
4500
+ g,
4452
4501
  this.animationStaticNodes
4453
- )), ne.configure(o, a, this.window);
4502
+ )), ae.configure(d, g, this.window);
4454
4503
  }
4455
- const n = () => {
4456
- e.destroy(), o.onBeforeDestroy.unsubscribe(n);
4504
+ const c = () => {
4505
+ e.destroy(), d.onBeforeDestroy.unsubscribe(c);
4457
4506
  };
4458
- return o.onBeforeDestroy.subscribe(n), o;
4507
+ return d.onBeforeDestroy.subscribe(c), d;
4459
4508
  }
4460
4509
  createHtmlView(e) {
4461
- let t = new xe(
4510
+ let t = new Ee(
4462
4511
  this.graphStore,
4463
4512
  this.viewportStore,
4464
4513
  e
4465
4514
  );
4466
- return this.virtualScrollConfig !== void 0 && (t = new Qe(
4515
+ return this.virtualScrollConfig !== void 0 && (t = new tt(
4467
4516
  t,
4468
4517
  this.graphStore,
4469
4518
  this.boxRenderingTrigger,
4470
- jt(this.virtualScrollConfig)
4471
- )), new Ze(t, this.graphStore);
4519
+ Qt(this.virtualScrollConfig)
4520
+ )), t = new rt(t, this.graphStore), t;
4472
4521
  }
4473
4522
  }
4474
4523
  export {
4475
- ft as BezierEdgeShape,
4476
- mr as CanvasBuilder,
4477
- qt as CanvasBuilderError,
4478
- x as CanvasError,
4524
+ xt as BezierEdgeShape,
4525
+ Cr as CanvasBuilder,
4526
+ Zt as CanvasBuilderError,
4527
+ E as CanvasError,
4479
4528
  D as ConnectionCategory,
4480
- Le as DirectEdgeShape,
4481
- Q as EventSubject,
4482
- yt as HorizontalEdgeShape,
4483
- Et as InteractiveEdgeError,
4484
- Ve as InteractiveEdgeShape,
4485
- yr as MidpointEdgeShape,
4486
- mt as StraightEdgeShape,
4487
- vt as VerticalEdgeShape
4529
+ Ve as DirectEdgeShape,
4530
+ K as EventSubject,
4531
+ Et as HorizontalEdgeShape,
4532
+ Nt as InteractiveEdgeError,
4533
+ Fe as InteractiveEdgeShape,
4534
+ Pr as MidpointEdgeShape,
4535
+ St as StraightEdgeShape,
4536
+ bt as VerticalEdgeShape
4488
4537
  };