@html-graph/html-graph 8.15.0 → 8.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,22 @@
1
- var Qe = Object.defineProperty;
2
- var Ze = (r, e, t) => e in r ? Qe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var i = (r, e, t) => Ze(r, typeof e != "symbol" ? e + "" : e, t);
4
- var R = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(R || {});
5
- const _e = () => {
1
+ var qe = Object.defineProperty;
2
+ var et = (r, e, t) => e in r ? qe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var i = (r, e, t) => et(r, typeof e != "symbol" ? e + "" : e, t);
4
+ var V = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(V || {});
5
+ const tt = () => {
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
- }, qe = () => {
8
+ }, rt = () => {
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
- }, et = (r) => {
11
+ }, ot = (r) => {
12
12
  r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden";
13
- }, tt = (r) => {
13
+ }, st = (r) => {
14
14
  r.style.removeProperty("position"), r.style.removeProperty("top"), r.style.removeProperty("left"), r.style.removeProperty("visibility"), r.style.removeProperty("transform");
15
15
  };
16
- class Ne {
16
+ class Ce {
17
17
  constructor(e, t, o) {
18
- i(this, "host", _e());
19
- i(this, "container", qe());
18
+ i(this, "host", tt());
19
+ i(this, "container", rt());
20
20
  i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
21
21
  i(this, "attachedNodeIds", /* @__PURE__ */ new Set());
22
22
  i(this, "applyTransform", () => {
@@ -27,11 +27,11 @@ class Ne {
27
27
  }
28
28
  attachNode(e) {
29
29
  const t = this.graphStore.getNode(e);
30
- et(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
30
+ ot(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
31
31
  }
32
32
  detachNode(e) {
33
33
  const t = this.graphStore.getNode(e);
34
- tt(t.element), this.container.removeChild(t.element), this.attachedNodeIds.delete(e);
34
+ st(t.element), this.container.removeChild(t.element), this.attachedNodeIds.delete(e);
35
35
  }
36
36
  attachEdge(e) {
37
37
  const t = this.graphStore.getEdge(e).payload.shape.svg;
@@ -72,8 +72,8 @@ class Ne {
72
72
  h,
73
73
  d
74
74
  ), u = this.createEdgeRenderPort(s, a, h, d);
75
- let g = R.Line;
76
- o.element === s.element ? g = R.PortCycle : o.nodeId === s.nodeId && (g = R.NodeCycle), t.payload.shape.render({ from: c, to: u, category: g });
75
+ let g = V.Line;
76
+ o.element === s.element ? g = V.PortCycle : o.nodeId === s.nodeId && (g = V.NodeCycle), t.payload.shape.render({ from: c, to: u, category: g });
77
77
  }
78
78
  updateEdgePriority(e) {
79
79
  const t = this.graphStore.getEdge(e);
@@ -93,7 +93,7 @@ class Ne {
93
93
  };
94
94
  }
95
95
  }
96
- class rt {
96
+ class it {
97
97
  constructor(e) {
98
98
  i(this, "xFrom", 1 / 0);
99
99
  i(this, "yFrom", 1 / 0);
@@ -113,7 +113,7 @@ class rt {
113
113
  return h <= this.xTo && d >= this.xFrom && c <= this.yTo && u >= this.yFrom;
114
114
  }
115
115
  }
116
- class ot {
116
+ class nt {
117
117
  constructor(e, t, o, s) {
118
118
  i(this, "attachedNodes", /* @__PURE__ */ new Set());
119
119
  i(this, "attachedEdges", /* @__PURE__ */ new Set());
@@ -137,7 +137,7 @@ class ot {
137
137
  this.handleAttachEdge(a);
138
138
  });
139
139
  });
140
- this.htmlView = e, this.graphStore = t, this.trigger = o, this.params = s, this.renderingBox = new rt(this.graphStore), this.trigger.subscribe(this.updateViewport);
140
+ this.htmlView = e, this.graphStore = t, this.trigger = o, this.params = s, this.renderingBox = new it(this.graphStore), this.trigger.subscribe(this.updateViewport);
141
141
  }
142
142
  attachNode(e) {
143
143
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -191,7 +191,7 @@ class ot {
191
191
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
192
192
  }
193
193
  }
194
- class st {
194
+ class at {
195
195
  constructor(e, t) {
196
196
  i(this, "deferredNodes", /* @__PURE__ */ new Set());
197
197
  i(this, "deferredEdges", /* @__PURE__ */ new Set());
@@ -265,7 +265,7 @@ const P = () => {
265
265
  const r = new _();
266
266
  return [r, r];
267
267
  };
268
- class be {
268
+ class Te {
269
269
  constructor(e, t, o, s) {
270
270
  i(this, "beforeDestroyEmitter");
271
271
  i(this, "destroyed", !1);
@@ -318,7 +318,7 @@ class be {
318
318
  this.destroyed || (this.destroyed = !0, this.beforeDestroyEmitter.emit(), this.graphController.destroy(), this.viewportController.destroy());
319
319
  }
320
320
  }
321
- class it {
321
+ class ht {
322
322
  constructor() {
323
323
  i(this, "singleToMultiMap", /* @__PURE__ */ new Map());
324
324
  i(this, "multiToSingleMap", /* @__PURE__ */ new Map());
@@ -358,13 +358,13 @@ class it {
358
358
  return this.multiToSingleMap.get(e) !== void 0;
359
359
  }
360
360
  }
361
- class S extends Error {
361
+ class A extends Error {
362
362
  constructor() {
363
363
  super(...arguments);
364
364
  i(this, "name", "CanvasError");
365
365
  }
366
366
  }
367
- const N = Object.freeze({
367
+ const S = Object.freeze({
368
368
  accessNonexistingNode: (r) => `Failed to access node with ID ${JSON.stringify(r)} because it does not exist`,
369
369
  addNodeWithExistingId: (r) => `Failed to add node with ID ${JSON.stringify(r)} because a node with this ID already exists`,
370
370
  addNodeWithElementInUse: (r, e) => `Failed to add node with ID ${JSON.stringify(r)} because its HTML element is already attached to node with ID ${JSON.stringify(e)}`,
@@ -378,6 +378,7 @@ const N = Object.freeze({
378
378
  removeNonexistentPort: (r) => `Failed to remove port with ID ${JSON.stringify(r)} because it does not exist`,
379
379
  accessNonexistentEdge: (r) => `Failed to access edge with ID ${JSON.stringify(r)} because it does not exist`,
380
380
  addEdgeWithExistingId: (r) => `Failed to add edge with ID ${JSON.stringify(r)} because an edge with this ID already exists`,
381
+ addEdgeWithElementInUse: (r, e) => `Failed to add edge with ID ${JSON.stringify(r)} because its SVG element is already attached to edge with ID ${JSON.stringify(e)}`,
381
382
  addEdgeFromNonexistentPort: (r, e) => `Failed to add edge with ID ${JSON.stringify(r)} from port with ID ${JSON.stringify(e)} because the port does not exist`,
382
383
  addEdgeToNonexistentPort: (r, e) => `Failed to add edge with ID ${JSON.stringify(r)} to port with ID ${JSON.stringify(e)} because the port does not exist`,
383
384
  updateNonexistentEdge: (r) => `Failed to update edge with ID ${JSON.stringify(r)} because it does not exist`,
@@ -386,7 +387,7 @@ const N = Object.freeze({
386
387
  removeNonexistentEdge: (r) => `Failed to remove edge with ID ${JSON.stringify(r)} because it does not exist`,
387
388
  accessEdgesForNonexistentPort: (r) => `Failed to access edges for port with ID ${JSON.stringify(r)} because the port does not exist`
388
389
  });
389
- class Pe {
390
+ class Me {
390
391
  constructor() {
391
392
  i(this, "nodes", /* @__PURE__ */ new Map());
392
393
  i(this, "ports", /* @__PURE__ */ new Map());
@@ -395,7 +396,8 @@ class Pe {
395
396
  i(this, "portIncomingEdges", /* @__PURE__ */ new Map());
396
397
  i(this, "portOutgoingEdges", /* @__PURE__ */ new Map());
397
398
  i(this, "portCycleEdges", /* @__PURE__ */ new Map());
398
- i(this, "elementPorts", new it());
399
+ i(this, "elementPorts", new ht());
400
+ i(this, "edgesElementsMap", /* @__PURE__ */ new Map());
399
401
  i(this, "afterNodeAddedEmitter");
400
402
  i(this, "onAfterNodeAdded");
401
403
  i(this, "afterNodeUpdatedEmitter");
@@ -430,16 +432,16 @@ class Pe {
430
432
  getNode(e) {
431
433
  const t = this.nodes.get(e);
432
434
  if (t === void 0)
433
- throw new S(N.accessNonexistingNode(e));
435
+ throw new A(S.accessNonexistingNode(e));
434
436
  return t;
435
437
  }
436
438
  addNode(e) {
437
439
  if (this.hasNode(e.id))
438
- throw new S(N.addNodeWithExistingId(e.id));
440
+ throw new A(S.addNodeWithExistingId(e.id));
439
441
  const t = this.findNodeIdByElement(e.element);
440
442
  if (t !== void 0)
441
- throw new S(
442
- N.addNodeWithElementInUse(e.id, t)
443
+ throw new A(
444
+ S.addNodeWithElementInUse(e.id, t)
443
445
  );
444
446
  const o = /* @__PURE__ */ new Map(), s = {
445
447
  element: e.element,
@@ -461,13 +463,13 @@ class Pe {
461
463
  }
462
464
  updateNode(e, t) {
463
465
  if (!this.hasNode(e))
464
- throw new S(N.updateNonexistentNode(e));
466
+ throw new A(S.updateNonexistentNode(e));
465
467
  const { payload: o } = this.nodes.get(e);
466
468
  o.x = t.x ?? o.x, o.y = t.y ?? o.y, o.centerFn = t.centerFn ?? o.centerFn, t.priority !== void 0 && (o.priority = t.priority, this.afterNodePriorityUpdatedEmitter.emit(e)), this.afterNodeUpdatedEmitter.emit(e);
467
469
  }
468
470
  removeNode(e) {
469
471
  if (!this.hasNode(e))
470
- throw new S(N.removeNonexistentNode(e));
472
+ throw new A(S.removeNonexistentNode(e));
471
473
  this.beforeNodeRemovedEmitter.emit(e);
472
474
  const t = this.getNode(e);
473
475
  this.nodesElementsMap.delete(t.element), this.nodes.delete(e);
@@ -478,15 +480,15 @@ class Pe {
478
480
  getPort(e) {
479
481
  const t = this.ports.get(e);
480
482
  if (t === void 0)
481
- throw new S(N.accessNonexistentPort(e));
483
+ throw new A(S.accessNonexistentPort(e));
482
484
  return t;
483
485
  }
484
486
  addPort(e) {
485
487
  if (this.hasPort(e.id))
486
- throw new S(N.addPortWithExistingId(e.id));
488
+ throw new A(S.addPortWithExistingId(e.id));
487
489
  if (!this.hasNode(e.nodeId))
488
- throw new S(
489
- N.addPortToNonexistentNode(e.id, e.nodeId)
490
+ throw new A(
491
+ S.addPortToNonexistentNode(e.id, e.nodeId)
490
492
  );
491
493
  this.ports.set(e.id, {
492
494
  element: e.element,
@@ -498,7 +500,7 @@ class Pe {
498
500
  }
499
501
  updatePort(e, t) {
500
502
  if (!this.hasPort(e))
501
- throw new S(N.updateNonexistentPort(e));
503
+ throw new A(S.updateNonexistentPort(e));
502
504
  const o = this.getPort(e).payload;
503
505
  o.direction = t.direction ?? o.direction, this.afterPortUpdatedEmitter.emit(e);
504
506
  }
@@ -511,14 +513,14 @@ class Pe {
511
513
  getNodePortIds(e) {
512
514
  const t = this.nodes.get(e);
513
515
  if (t === void 0)
514
- throw new S(
515
- N.accessPortsOfNonexistentNode(e)
516
+ throw new A(
517
+ S.accessPortsOfNonexistentNode(e)
516
518
  );
517
519
  return Array.from(t.ports.keys());
518
520
  }
519
521
  removePort(e) {
520
522
  if (!this.hasPort(e))
521
- throw new S(N.removeNonexistentPort(e));
523
+ throw new A(S.removeNonexistentPort(e));
522
524
  const t = this.getPort(e).nodeId;
523
525
  this.beforePortRemovedEmitter.emit(e), this.getNode(t).ports.delete(e), this.ports.delete(e), this.elementPorts.removeByMulti(e);
524
526
  }
@@ -528,33 +530,41 @@ class Pe {
528
530
  getEdge(e) {
529
531
  const t = this.edges.get(e);
530
532
  if (t === void 0)
531
- throw new S(N.accessNonexistentEdge(e));
533
+ throw new A(S.accessNonexistentEdge(e));
532
534
  return t;
533
535
  }
536
+ findEdgeIdByElement(e) {
537
+ return this.edgesElementsMap.get(e);
538
+ }
534
539
  addEdge(e) {
535
540
  if (this.hasEdge(e.id))
536
- throw new S(N.addEdgeWithExistingId(e.id));
541
+ throw new A(S.addEdgeWithExistingId(e.id));
537
542
  if (!this.hasPort(e.from))
538
- throw new S(
539
- N.addEdgeFromNonexistentPort(e.id, e.from)
543
+ throw new A(
544
+ S.addEdgeFromNonexistentPort(e.id, e.from)
540
545
  );
541
546
  if (!this.hasPort(e.to))
542
- throw new S(
543
- N.addEdgeToNonexistentPort(e.id, e.to)
547
+ throw new A(
548
+ S.addEdgeToNonexistentPort(e.id, e.to)
549
+ );
550
+ const t = this.findEdgeIdByElement(e.shape.svg);
551
+ if (t !== void 0)
552
+ throw new A(
553
+ S.addEdgeWithElementInUse(e.id, t)
544
554
  );
545
555
  this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
546
556
  }
547
557
  updateEdge(e, t) {
548
558
  if (!this.hasEdge(e))
549
- throw new S(N.updateNonexistentEdge(e));
559
+ throw new A(S.updateNonexistentEdge(e));
550
560
  if (t.from !== void 0 || t.to !== void 0) {
551
561
  if (t.from !== void 0 && !this.hasPort(t.from))
552
- throw new S(
553
- N.updateNonexistentEdgeSource(e, t.from)
562
+ throw new A(
563
+ S.updateNonexistentEdgeSource(e, t.from)
554
564
  );
555
565
  if (t.to !== void 0 && !this.hasPort(t.to))
556
- throw new S(
557
- N.updateNonexistentEdgeTarget(e, t.to)
566
+ throw new A(
567
+ S.updateNonexistentEdgeTarget(e, t.to)
558
568
  );
559
569
  const s = this.getEdge(e), n = s.payload;
560
570
  this.removeEdgeInternal(e), this.addEdgeInternal({
@@ -573,33 +583,33 @@ class Pe {
573
583
  }
574
584
  removeEdge(e) {
575
585
  if (!this.hasEdge(e))
576
- throw new S(N.removeNonexistentEdge(e));
586
+ throw new A(S.removeNonexistentEdge(e));
577
587
  this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
578
588
  }
579
589
  clear() {
580
- 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();
590
+ this.beforeClearEmitter.emit(), this.portIncomingEdges.clear(), this.portOutgoingEdges.clear(), this.portCycleEdges.clear(), this.elementPorts.clear(), this.nodesElementsMap.clear(), this.edgesElementsMap.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
581
591
  }
582
592
  getPortIncomingEdgeIds(e) {
583
593
  const t = this.portIncomingEdges.get(e);
584
594
  if (t === void 0)
585
- throw new S(
586
- N.accessEdgesForNonexistentPort(e)
595
+ throw new A(
596
+ S.accessEdgesForNonexistentPort(e)
587
597
  );
588
598
  return Array.from(t);
589
599
  }
590
600
  getPortOutgoingEdgeIds(e) {
591
601
  const t = this.portOutgoingEdges.get(e);
592
602
  if (t === void 0)
593
- throw new S(
594
- N.accessEdgesForNonexistentPort(e)
603
+ throw new A(
604
+ S.accessEdgesForNonexistentPort(e)
595
605
  );
596
606
  return Array.from(t);
597
607
  }
598
608
  getPortCycleEdgeIds(e) {
599
609
  const t = this.portCycleEdges.get(e);
600
610
  if (t === void 0)
601
- throw new S(
602
- N.accessEdgesForNonexistentPort(e)
611
+ throw new A(
612
+ S.accessEdgesForNonexistentPort(e)
603
613
  );
604
614
  return Array.from(t);
605
615
  }
@@ -665,29 +675,29 @@ class Pe {
665
675
  shape: e.shape,
666
676
  priority: e.priority
667
677
  }
668
- }), 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);
678
+ }), this.edgesElementsMap.set(e.shape.svg, e.id), 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);
669
679
  }
670
680
  removeEdgeInternal(e) {
671
- const { from: t, to: o } = this.getEdge(e);
672
- this.portCycleEdges.get(t).delete(e), this.portCycleEdges.get(o).delete(e), this.portIncomingEdges.get(t).delete(e), this.portIncomingEdges.get(o).delete(e), this.portOutgoingEdges.get(t).delete(e), this.portOutgoingEdges.get(o).delete(e), this.edges.delete(e);
681
+ const { from: t, to: o, payload: s } = this.getEdge(e);
682
+ this.portCycleEdges.get(t).delete(e), this.portCycleEdges.get(o).delete(e), this.portIncomingEdges.get(t).delete(e), this.portIncomingEdges.get(o).delete(e), this.portOutgoingEdges.get(t).delete(e), this.portOutgoingEdges.get(o).delete(e), this.edges.delete(e), this.edgesElementsMap.delete(s.shape.svg);
673
683
  }
674
684
  }
675
- const we = (r) => ({
685
+ const ve = (r) => ({
676
686
  scale: 1 / r.scale,
677
687
  x: -r.x / r.scale,
678
688
  y: -r.y / r.scale
679
- }), ye = {
689
+ }), me = {
680
690
  scale: 1,
681
691
  x: 0,
682
692
  y: 0
683
- }, fe = (r, e) => ({
693
+ }, xe = (r, e) => ({
684
694
  x: r.scale * e.x + r.x,
685
695
  y: r.scale * e.y + r.y
686
696
  });
687
- class nt {
697
+ class dt {
688
698
  constructor(e) {
689
- i(this, "viewportMatrix", ye);
690
- i(this, "contentMatrix", ye);
699
+ i(this, "viewportMatrix", me);
700
+ i(this, "contentMatrix", me);
691
701
  i(this, "beforeUpdateEmitter");
692
702
  i(this, "onBeforeUpdated");
693
703
  i(this, "afterUpdateEmitter");
@@ -710,24 +720,24 @@ class nt {
710
720
  scale: e.scale ?? this.viewportMatrix.scale,
711
721
  x: e.x ?? this.viewportMatrix.x,
712
722
  y: e.y ?? this.viewportMatrix.y
713
- }, this.beforeUpdateEmitter.emit(), this.contentMatrix = we(this.viewportMatrix), this.afterUpdateEmitter.emit();
723
+ }, this.beforeUpdateEmitter.emit(), this.contentMatrix = ve(this.viewportMatrix), this.afterUpdateEmitter.emit();
714
724
  }
715
725
  patchContentMatrix(e) {
716
726
  this.contentMatrix = {
717
727
  scale: e.scale ?? this.contentMatrix.scale,
718
728
  x: e.x ?? this.contentMatrix.x,
719
729
  y: e.y ?? this.contentMatrix.y
720
- }, this.beforeUpdateEmitter.emit(), this.viewportMatrix = we(this.contentMatrix), this.afterUpdateEmitter.emit();
730
+ }, this.beforeUpdateEmitter.emit(), this.viewportMatrix = ve(this.contentMatrix), this.afterUpdateEmitter.emit();
721
731
  }
722
732
  getDimensions() {
723
733
  const { width: e, height: t } = this.host.getBoundingClientRect();
724
734
  return { width: e, height: t };
725
735
  }
726
736
  createContentCoords(e) {
727
- return fe(this.viewportMatrix, e);
737
+ return xe(this.viewportMatrix, e);
728
738
  }
729
739
  createViewportCoords(e) {
730
- return fe(this.contentMatrix, e);
740
+ return xe(this.contentMatrix, e);
731
741
  }
732
742
  destroy() {
733
743
  this.observer.disconnect();
@@ -766,21 +776,21 @@ class q {
766
776
  this.canvas.updateNode(t);
767
777
  }
768
778
  }
769
- const at = (r, e, t) => {
779
+ const ct = (r, e, t) => {
770
780
  const { x: o, y: s, width: n, height: a } = r.getBoundingClientRect();
771
781
  return e >= o && e <= o + n && t >= s && t <= s + a;
772
- }, ht = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight;
773
- class dt {
782
+ }, lt = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight;
783
+ class ut {
774
784
  constructor(e, t) {
775
785
  this.element = e, this.win = t;
776
786
  }
777
787
  verify(e, t) {
778
- return at(this.element, e, t) && ht(this.win, e, t);
788
+ return ct(this.element, e, t) && lt(this.win, e, t);
779
789
  }
780
790
  }
781
791
  const k = (r, e) => {
782
792
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
783
- }, Y = (r) => {
793
+ }, H = (r) => {
784
794
  const e = document.createElement("div");
785
795
  return {
786
796
  id: r.overlayNodeId,
@@ -795,7 +805,7 @@ const k = (r, e) => {
795
805
  }
796
806
  ]
797
807
  };
798
- }, ct = (r, e) => {
808
+ }, gt = (r, e) => {
799
809
  let t = e;
800
810
  for (; t !== null; ) {
801
811
  const o = r.findPortIdsByElement(t)[0] ?? null;
@@ -814,21 +824,21 @@ const k = (r, e) => {
814
824
  status: "notFound"
815
825
  };
816
826
  };
817
- function* Te(r, e) {
827
+ function* De(r, e) {
818
828
  const t = r.elementsFromPoint(e.x, e.y);
819
829
  for (const o of t) {
820
830
  if (o.shadowRoot !== null) {
821
- const s = Te(o.shadowRoot, e);
831
+ const s = De(o.shadowRoot, e);
822
832
  for (const n of s)
823
833
  yield n;
824
834
  }
825
835
  yield o;
826
836
  }
827
837
  }
828
- const Ce = (r, e) => {
829
- const t = Te(document, e);
838
+ const Re = (r, e) => {
839
+ const t = De(document, e);
830
840
  for (const o of t) {
831
- const s = ct(r, o);
841
+ const s = gt(r, o);
832
842
  if (s.status === "portFound")
833
843
  return s.portId;
834
844
  if (s.status === "nodeEncountered")
@@ -837,13 +847,13 @@ const Ce = (r, e) => {
837
847
  return null;
838
848
  };
839
849
  var M = /* @__PURE__ */ ((r) => (r.StaticNodeId = "static", r.DraggingNodeId = "dragging", r.EdgeId = "edge", r))(M || {});
840
- const Me = (r, e) => ({
850
+ const Le = (r, e) => ({
841
851
  x: r / 2,
842
852
  y: e / 2
843
853
  }), m = (r, e, t) => ({
844
854
  x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
845
855
  y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
846
- }), De = (r, e, t) => {
856
+ }), Ve = (r, e, t) => {
847
857
  const o = {
848
858
  x: r.x + r.width / 2,
849
859
  y: r.y + r.height / 2
@@ -860,7 +870,7 @@ const Me = (r, e) => ({
860
870
  to: { x: s.x - n, y: s.y - a }
861
871
  };
862
872
  };
863
- class lt {
873
+ class pt {
864
874
  constructor(e) {
865
875
  i(this, "path");
866
876
  i(this, "midpoint");
@@ -893,7 +903,7 @@ class lt {
893
903
  this.path = `${x}${f}${E}`;
894
904
  }
895
905
  }
896
- class ut {
906
+ class wt {
897
907
  constructor(e) {
898
908
  i(this, "path");
899
909
  i(this, "midpoint");
@@ -930,13 +940,13 @@ class ut {
930
940
  { x: c.x - u, y: c.y },
931
941
  a,
932
942
  c
933
- ), b = {
943
+ ), N = {
934
944
  x: E.x + p,
935
945
  y: E.y + y
936
- }, T = {
937
- x: (x.x + b.x) / 2,
938
- y: (x.y + b.y) / 2
939
946
  }, C = {
947
+ x: (x.x + N.x) / 2,
948
+ y: (x.y + N.y) / 2
949
+ }, T = {
940
950
  x: f.x + s * n.x,
941
951
  y: f.y + s * n.y
942
952
  }, I = {
@@ -952,24 +962,24 @@ class ut {
952
962
  this.path = [
953
963
  `M ${l.x} ${l.y}`,
954
964
  `L ${f.x} ${f.y}`,
955
- `C ${C.x} ${C.y} ${F.x} ${F.y} ${T.x} ${T.y}`,
965
+ `C ${T.x} ${T.y} ${F.x} ${F.y} ${C.x} ${C.y}`,
956
966
  `C ${U.x} ${U.y} ${I.x} ${I.y} ${E.x} ${E.y}`,
957
967
  `L ${w.x} ${w.y}`
958
- ].join(" "), this.midpoint = T;
968
+ ].join(" "), this.midpoint = C;
959
969
  }
960
970
  }
961
971
  const ee = Object.freeze({
962
972
  edgeColor: "--edge-color"
963
- }), Le = (r) => {
973
+ }), Ie = (r) => {
964
974
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
965
975
  return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(ee.edgeColor, r), e;
966
- }, Re = (r) => {
976
+ }, Fe = (r) => {
967
977
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
968
978
  return e.setAttribute("stroke", `var(${ee.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
969
- }, X = () => {
979
+ }, Y = () => {
970
980
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
971
981
  return r.setAttribute("fill", `var(${ee.edgeColor})`), r;
972
- }, Ve = (r, e) => {
982
+ }, Ue = (r, e) => {
973
983
  r.style.transform = `translate(${e.x}px, ${e.y}px)`, r.style.width = `${e.width}px`, r.style.height = `${e.height}px`;
974
984
  }, L = (r, e) => {
975
985
  const t = [];
@@ -980,17 +990,17 @@ const ee = Object.freeze({
980
990
  let c = 0, u = 0, g = 0;
981
991
  const l = d > 0, w = d < o, p = l && w;
982
992
  if (l && (c = -s, u = -n, g = a), w) {
983
- const C = r[d + 1];
984
- s = C.x - h.x, n = C.y - h.y, a = Math.sqrt(s * s + n * n);
993
+ const T = r[d + 1];
994
+ s = T.x - h.x, n = T.y - h.y, a = Math.sqrt(s * s + n * n);
985
995
  }
986
- const f = a !== 0 ? Math.min((p ? e : 0) / a, d < o - 1 ? 0.5 : 1) : 0, x = p ? { x: h.x + s * f, y: h.y + n * f } : h, b = g !== 0 ? Math.min((p ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, T = p ? { x: h.x + c * b, y: h.y + u * b } : h;
987
- d > 0 && t.push(`L ${T.x} ${T.y}`), p && t.push(
996
+ const f = a !== 0 ? Math.min((p ? e : 0) / a, d < o - 1 ? 0.5 : 1) : 0, x = p ? { x: h.x + s * f, y: h.y + n * f } : h, N = g !== 0 ? Math.min((p ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, C = p ? { x: h.x + c * N, y: h.y + u * N } : h;
997
+ d > 0 && t.push(`L ${C.x} ${C.y}`), p && t.push(
988
998
  `C ${h.x} ${h.y} ${h.x} ${h.y} ${x.x} ${x.y}`
989
999
  );
990
1000
  });
991
1001
  }
992
1002
  return t.join(" ");
993
- }, gt = (r, e) => {
1003
+ }, yt = (r, e) => {
994
1004
  const t = e.x - r.x >= 0, o = r.dirX >= 0, s = e.dirX >= 0;
995
1005
  if (o === s) {
996
1006
  const c = o === t, u = (r.x + e.x) / 2, g = (r.y + e.y) / 2, l = { x: u, y: g };
@@ -1026,7 +1036,7 @@ const ee = Object.freeze({
1026
1036
  midpoint: { x: d.x, y: h }
1027
1037
  };
1028
1038
  };
1029
- class pt {
1039
+ class ft {
1030
1040
  constructor(e) {
1031
1041
  i(this, "path");
1032
1042
  i(this, "midpoint");
@@ -1055,7 +1065,7 @@ class pt {
1055
1065
  { x: t.x + w, y: t.y },
1056
1066
  s,
1057
1067
  t
1058
- ), y = m({ x: o.x - w, y: o.y }, n, o), f = gt(
1068
+ ), y = m({ x: o.x - w, y: o.y }, n, o), f = yt(
1059
1069
  {
1060
1070
  x: p.x,
1061
1071
  y: p.y,
@@ -1073,7 +1083,7 @@ class pt {
1073
1083
  ), this.midpoint = f.midpoint;
1074
1084
  }
1075
1085
  }
1076
- class wt {
1086
+ class vt {
1077
1087
  constructor(e) {
1078
1088
  i(this, "path");
1079
1089
  i(this, "midpoint");
@@ -1104,27 +1114,27 @@ class wt {
1104
1114
  { x: s.x + y, y: s.y },
1105
1115
  h,
1106
1116
  s
1107
- ), b = {
1117
+ ), N = {
1108
1118
  x: E.x + f,
1109
1119
  y: E.y + x
1110
- }, T = m(
1120
+ }, C = m(
1111
1121
  { x: n.x - y, y: n.y },
1112
1122
  d,
1113
1123
  n
1114
- ), C = {
1115
- x: T.x + f,
1116
- y: T.y + x
1124
+ ), T = {
1125
+ x: C.x + f,
1126
+ y: C.y + x
1117
1127
  };
1118
1128
  this.midpoint = {
1119
- x: (b.x + C.x) / 2,
1120
- y: (b.y + C.y) / 2
1129
+ x: (N.x + T.x) / 2,
1130
+ y: (N.y + T.y) / 2
1121
1131
  }, this.path = L(
1122
- [w, E, b, C, T, p],
1132
+ [w, E, N, T, C, p],
1123
1133
  l
1124
1134
  );
1125
1135
  }
1126
1136
  }
1127
- class yt {
1137
+ class mt {
1128
1138
  constructor(e) {
1129
1139
  i(this, "path");
1130
1140
  i(this, "midpoint");
@@ -1153,8 +1163,8 @@ class yt {
1153
1163
  [g, y, x, l],
1154
1164
  u
1155
1165
  );
1156
- const E = (y.x + x.x) / 2, b = (y.y + x.y) / 2;
1157
- this.midpoint = { x: E, y: b };
1166
+ const E = (y.x + x.x) / 2, N = (y.y + x.y) / 2;
1167
+ this.midpoint = { x: E, y: N };
1158
1168
  }
1159
1169
  createArrowPoint(e, t, o, s) {
1160
1170
  if (!e)
@@ -1166,7 +1176,7 @@ class yt {
1166
1176
  return m(n, t, o);
1167
1177
  }
1168
1178
  }
1169
- const ft = (r, e) => {
1179
+ const xt = (r, e) => {
1170
1180
  const t = e.y - r.y >= 0, o = r.dirY >= 0, s = e.dirY >= 0;
1171
1181
  if (o === s) {
1172
1182
  const c = o === t, u = (r.x + e.x) / 2, g = (r.y + e.y) / 2, l = { x: u, y: g };
@@ -1202,7 +1212,7 @@ const ft = (r, e) => {
1202
1212
  midpoint: { x: h, y: d.y }
1203
1213
  };
1204
1214
  };
1205
- class vt {
1215
+ class Et {
1206
1216
  constructor(e) {
1207
1217
  i(this, "path");
1208
1218
  i(this, "midpoint");
@@ -1231,7 +1241,7 @@ class vt {
1231
1241
  { x: t.x + w, y: t.y },
1232
1242
  d,
1233
1243
  t
1234
- ), y = m({ x: o.x - w, y: o.y }, c, o), f = ft(
1244
+ ), y = m({ x: o.x - w, y: o.y }, c, o), f = xt(
1235
1245
  {
1236
1246
  x: p.x,
1237
1247
  y: p.y,
@@ -1266,7 +1276,7 @@ class te {
1266
1276
  this.path = `${h ? "" : l}${L(g, e.roundness)}`, this.midpoint = { x: (g[3].x + g[4].x) / 2, y: (g[3].y + g[4].y) / 2 };
1267
1277
  }
1268
1278
  }
1269
- class mt {
1279
+ class At {
1270
1280
  constructor(e) {
1271
1281
  i(this, "path");
1272
1282
  i(this, "midpoint");
@@ -1284,7 +1294,7 @@ class mt {
1284
1294
  this.path = `${h ? "" : x}${f}`, this.midpoint = y[3];
1285
1295
  }
1286
1296
  }
1287
- class xt {
1297
+ class St {
1288
1298
  constructor(e) {
1289
1299
  i(this, "path");
1290
1300
  i(this, "midpoint");
@@ -1329,11 +1339,11 @@ class xt {
1329
1339
  };
1330
1340
  }
1331
1341
  }
1332
- const Et = (r, e, t) => {
1342
+ const bt = (r, e, t) => {
1333
1343
  const o = Math.max(r.y, e.y), s = Math.min(r.y, e.y);
1334
1344
  return (t >= 0 ? o : s) + t;
1335
1345
  };
1336
- class At {
1346
+ class Nt {
1337
1347
  constructor(e) {
1338
1348
  i(this, "path");
1339
1349
  i(this, "midpoint");
@@ -1367,7 +1377,7 @@ class At {
1367
1377
  { x: a.x - p, y: a.y },
1368
1378
  d,
1369
1379
  a
1370
- ), x = Et(y, f, g);
1380
+ ), x = bt(y, f, g);
1371
1381
  this.midpoint = {
1372
1382
  x: (y.x + f.x) / 2,
1373
1383
  y: x
@@ -1384,11 +1394,11 @@ class At {
1384
1394
  );
1385
1395
  }
1386
1396
  }
1387
- const St = (r, e, t) => {
1397
+ const Pt = (r, e, t) => {
1388
1398
  const o = Math.max(r.x, e.x), s = Math.min(r.x, e.x);
1389
1399
  return (t >= 0 ? o : s) + t;
1390
1400
  };
1391
- class Nt {
1401
+ class Ct {
1392
1402
  constructor(e) {
1393
1403
  i(this, "path");
1394
1404
  i(this, "midpoint");
@@ -1422,7 +1432,7 @@ class Nt {
1422
1432
  { x: d.x - p, y: d.y },
1423
1433
  a,
1424
1434
  d
1425
- ), x = St(y, f, u);
1435
+ ), x = Pt(y, f, u);
1426
1436
  this.midpoint = {
1427
1437
  x,
1428
1438
  y: (y.y + f.y) / 2
@@ -1461,8 +1471,8 @@ const v = Object.freeze({
1461
1471
  curvature: 90,
1462
1472
  interactiveWidth: 10,
1463
1473
  preOffset: 0
1464
- }), ve = (r) => ({ x: Math.cos(r), y: Math.sin(r) });
1465
- class H {
1474
+ }), Ee = (r) => ({ x: Math.cos(r), y: Math.sin(r) });
1475
+ class X {
1466
1476
  constructor(e) {
1467
1477
  i(this, "svg");
1468
1478
  i(this, "group", document.createElementNS(
@@ -1475,18 +1485,18 @@ class H {
1475
1485
  i(this, "onAfterRender");
1476
1486
  i(this, "afterRenderEmitter");
1477
1487
  i(this, "arrowRenderer");
1478
- this.params = e, [this.afterRenderEmitter, this.onAfterRender] = P(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Le(e.color), this.svg.appendChild(this.group), this.line = Re(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = X(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = X(), this.group.appendChild(this.targetArrow));
1488
+ this.params = e, [this.afterRenderEmitter, this.onAfterRender] = P(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Ie(e.color), this.svg.appendChild(this.group), this.line = Fe(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = Y(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = Y(), this.group.appendChild(this.targetArrow));
1479
1489
  }
1480
1490
  render(e) {
1481
- const { x: t, y: o, width: s, height: n, from: a, to: h } = De(
1491
+ const { x: t, y: o, width: s, height: n, from: a, to: h } = Ve(
1482
1492
  e.from,
1483
1493
  e.to,
1484
1494
  this.params.padding
1485
1495
  );
1486
- Ve(this.svg, { x: t, y: o, width: s, height: n });
1487
- const d = ve(e.from.direction), c = ve(e.to.direction);
1496
+ Ue(this.svg, { x: t, y: o, width: s, height: n });
1497
+ const d = Ee(e.from.direction), c = Ee(e.to.direction);
1488
1498
  let u = { x: -c.x, y: -c.y }, g;
1489
- e.category === R.PortCycle ? (g = this.params.createCyclePath, u = d) : e.category === R.NodeCycle ? g = this.params.createDetourPath : g = this.params.createLinePath;
1499
+ e.category === V.PortCycle ? (g = this.params.createCyclePath, u = d) : e.category === V.NodeCycle ? g = this.params.createDetourPath : g = this.params.createLinePath;
1490
1500
  const l = g(a, h, d, c);
1491
1501
  this.line.setAttribute("d", l.path);
1492
1502
  let w = null;
@@ -1507,7 +1517,7 @@ class H {
1507
1517
  });
1508
1518
  }
1509
1519
  }
1510
- const bt = (r) => (e) => {
1520
+ const Tt = (r) => (e) => {
1511
1521
  const o = [
1512
1522
  { x: 0, y: 0 },
1513
1523
  { x: e.arrowLength, y: r.radius },
@@ -1519,7 +1529,7 @@ const bt = (r) => (e) => {
1519
1529
  y: h.y + e.shift.y
1520
1530
  })), s = `M ${o[0].x} ${o[0].y}`, n = `L ${o[1].x} ${o[1].y}`, a = `L ${o[2].x} ${o[2].y}`;
1521
1531
  return `${s} ${n} ${a} Z`;
1522
- }, Pt = (r) => (e) => {
1532
+ }, Mt = (r) => (e) => {
1523
1533
  const t = r.radius, o = e.arrowLength, s = (o * o + 2 * o * t) / (2 * t), n = s + t, a = o + t - t * (o + t) / n, h = t * s / n, c = [
1524
1534
  { x: 0, y: 0 },
1525
1535
  { x: a, y: -h },
@@ -1531,7 +1541,7 @@ const bt = (r) => (e) => {
1531
1541
  y: p.y + e.shift.y
1532
1542
  })), u = `M ${c[0].x} ${c[0].y}`, g = `A ${s} ${s} 0 0 0 ${c[1].x} ${c[1].y}`, l = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, w = `A ${s} ${s} 0 0 0 ${c[0].x} ${c[0].y}`;
1533
1543
  return `${u} ${g} ${l} ${w}`;
1534
- }, Tt = (r) => (e) => {
1544
+ }, Dt = (r) => (e) => {
1535
1545
  const t = r.smallRadius, o = r.radius, s = m(
1536
1546
  {
1537
1547
  x: e.arrowLength,
@@ -1557,22 +1567,22 @@ const bt = (r) => (e) => {
1557
1567
  return r;
1558
1568
  switch (r.type) {
1559
1569
  case "triangle":
1560
- return bt({
1570
+ return Tt({
1561
1571
  radius: r.radius ?? v.polygonArrowRadius
1562
1572
  });
1563
1573
  case "arc":
1564
- return Pt({
1574
+ return Mt({
1565
1575
  radius: r.radius ?? v.circleArrowRadius
1566
1576
  });
1567
1577
  default:
1568
- return Tt({
1578
+ return Dt({
1569
1579
  smallRadius: r.smallRadius ?? v.wedgeArrowSmallRadius,
1570
1580
  angle: r.angle ?? v.wedgeArrowAngle,
1571
1581
  radius: r.radius ?? v.wedgeArrowRadius
1572
1582
  });
1573
1583
  }
1574
- }, W = 50;
1575
- class Ct {
1584
+ }, O = 50;
1585
+ class Rt {
1576
1586
  constructor(e) {
1577
1587
  i(this, "svg");
1578
1588
  i(this, "group");
@@ -1589,7 +1599,7 @@ class Ct {
1589
1599
  i(this, "hasSourceArrow");
1590
1600
  i(this, "hasTargetArrow");
1591
1601
  i(this, "pathShape");
1592
- i(this, "createCyclePath", (e, t, o) => new mt({
1602
+ i(this, "createCyclePath", (e, t, o) => new At({
1593
1603
  origin: e,
1594
1604
  dir: o,
1595
1605
  radius: this.portCycleRadius,
@@ -1597,7 +1607,7 @@ class Ct {
1597
1607
  arrowLength: this.arrowLength,
1598
1608
  hasArrow: this.hasSourceArrow || this.hasTargetArrow
1599
1609
  }));
1600
- i(this, "createDetourPath", (e, t, o, s) => new ut({
1610
+ i(this, "createDetourPath", (e, t, o, s) => new wt({
1601
1611
  from: e,
1602
1612
  to: t,
1603
1613
  fromDir: o,
@@ -1609,7 +1619,7 @@ class Ct {
1609
1619
  hasSourceArrow: this.hasSourceArrow,
1610
1620
  hasTargetArrow: this.hasTargetArrow
1611
1621
  }));
1612
- i(this, "createLinePath", (e, t, o, s) => new lt({
1622
+ i(this, "createLinePath", (e, t, o, s) => new pt({
1613
1623
  from: e,
1614
1624
  to: t,
1615
1625
  fromDir: o,
@@ -1619,7 +1629,7 @@ class Ct {
1619
1629
  hasSourceArrow: this.hasSourceArrow,
1620
1630
  hasTargetArrow: this.hasTargetArrow
1621
1631
  }));
1622
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? v.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? v.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? v.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? v.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? v.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new H({
1632
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? v.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? v.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? v.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? v.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? v.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new X({
1623
1633
  color: (e == null ? void 0 : e.color) ?? v.color,
1624
1634
  width: (e == null ? void 0 : e.width) ?? v.width,
1625
1635
  arrowRenderer: B((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1629,14 +1639,14 @@ class Ct {
1629
1639
  createCyclePath: this.createCyclePath,
1630
1640
  createDetourPath: this.createDetourPath,
1631
1641
  createLinePath: this.createLinePath,
1632
- padding: W
1642
+ padding: O
1633
1643
  }), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
1634
1644
  }
1635
1645
  render(e) {
1636
1646
  this.pathShape.render(e);
1637
1647
  }
1638
1648
  }
1639
- class Mt {
1649
+ class Lt {
1640
1650
  constructor(e) {
1641
1651
  i(this, "svg");
1642
1652
  i(this, "group");
@@ -1661,7 +1671,7 @@ class Mt {
1661
1671
  roundness: this.roundness,
1662
1672
  hasArrow: this.hasSourceArrow || this.hasTargetArrow
1663
1673
  }));
1664
- i(this, "createDetourPath", (e, t, o, s) => new At({
1674
+ i(this, "createDetourPath", (e, t, o, s) => new Nt({
1665
1675
  from: e,
1666
1676
  to: t,
1667
1677
  fromDir: o,
@@ -1673,7 +1683,7 @@ class Mt {
1673
1683
  hasSourceArrow: this.hasSourceArrow,
1674
1684
  hasTargetArrow: this.hasTargetArrow
1675
1685
  }));
1676
- i(this, "createLinePath", (e, t, o, s) => new pt({
1686
+ i(this, "createLinePath", (e, t, o, s) => new ft({
1677
1687
  from: e,
1678
1688
  to: t,
1679
1689
  fromDir: o,
@@ -1690,7 +1700,7 @@ class Mt {
1690
1700
  t,
1691
1701
  this.arrowOffset,
1692
1702
  this.cycleSquareSide / 2
1693
- ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new H({
1703
+ ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new X({
1694
1704
  color: (e == null ? void 0 : e.color) ?? v.color,
1695
1705
  width: (e == null ? void 0 : e.width) ?? v.width,
1696
1706
  arrowRenderer: B((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1700,14 +1710,14 @@ class Mt {
1700
1710
  createCyclePath: this.createCyclePath,
1701
1711
  createDetourPath: this.createDetourPath,
1702
1712
  createLinePath: this.createLinePath,
1703
- padding: W
1713
+ padding: O
1704
1714
  }), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
1705
1715
  }
1706
1716
  render(e) {
1707
1717
  this.pathShape.render(e);
1708
1718
  }
1709
1719
  }
1710
- class Dt {
1720
+ class Vt {
1711
1721
  constructor(e) {
1712
1722
  i(this, "svg");
1713
1723
  i(this, "group");
@@ -1733,7 +1743,7 @@ class Dt {
1733
1743
  roundness: this.roundness,
1734
1744
  hasArrow: this.hasSourceArrow || this.hasTargetArrow
1735
1745
  }));
1736
- i(this, "createDetourPath", (e, t, o, s) => new wt({
1746
+ i(this, "createDetourPath", (e, t, o, s) => new vt({
1737
1747
  from: e,
1738
1748
  to: t,
1739
1749
  fromDir: o,
@@ -1746,7 +1756,7 @@ class Dt {
1746
1756
  hasSourceArrow: this.hasSourceArrow,
1747
1757
  hasTargetArrow: this.hasTargetArrow
1748
1758
  }));
1749
- i(this, "createLinePath", (e, t, o, s) => new yt({
1759
+ i(this, "createLinePath", (e, t, o, s) => new mt({
1750
1760
  from: e,
1751
1761
  to: t,
1752
1762
  fromDir: o,
@@ -1763,7 +1773,7 @@ class Dt {
1763
1773
  t,
1764
1774
  this.arrowOffset,
1765
1775
  this.cycleSquareSide / 2
1766
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? v.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new H({
1776
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? v.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new X({
1767
1777
  color: (e == null ? void 0 : e.color) ?? v.color,
1768
1778
  width: (e == null ? void 0 : e.width) ?? v.width,
1769
1779
  arrowRenderer: B((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1773,14 +1783,14 @@ class Dt {
1773
1783
  createCyclePath: this.createCyclePath,
1774
1784
  createDetourPath: this.createDetourPath,
1775
1785
  createLinePath: this.createLinePath,
1776
- padding: W
1786
+ padding: O
1777
1787
  }), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
1778
1788
  }
1779
1789
  render(e) {
1780
1790
  this.pathShape.render(e);
1781
1791
  }
1782
1792
  }
1783
- class Lt {
1793
+ class It {
1784
1794
  constructor(e) {
1785
1795
  i(this, "svg");
1786
1796
  i(this, "group");
@@ -1805,7 +1815,7 @@ class Lt {
1805
1815
  roundness: this.roundness,
1806
1816
  hasArrow: this.hasSourceArrow || this.hasTargetArrow
1807
1817
  }));
1808
- i(this, "createDetourPath", (e, t, o, s) => new Nt({
1818
+ i(this, "createDetourPath", (e, t, o, s) => new Ct({
1809
1819
  from: e,
1810
1820
  to: t,
1811
1821
  fromDir: o,
@@ -1817,7 +1827,7 @@ class Lt {
1817
1827
  hasSourceArrow: this.hasSourceArrow,
1818
1828
  hasTargetArrow: this.hasTargetArrow
1819
1829
  }));
1820
- i(this, "createLinePath", (e, t, o, s) => new vt({
1830
+ i(this, "createLinePath", (e, t, o, s) => new Et({
1821
1831
  from: e,
1822
1832
  to: t,
1823
1833
  fromDir: o,
@@ -1834,7 +1844,7 @@ class Lt {
1834
1844
  t,
1835
1845
  this.arrowOffset,
1836
1846
  this.cycleSquareSide / 2
1837
- ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new H({
1847
+ ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new X({
1838
1848
  color: (e == null ? void 0 : e.color) ?? v.color,
1839
1849
  width: (e == null ? void 0 : e.width) ?? v.width,
1840
1850
  arrowRenderer: B((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1844,14 +1854,14 @@ class Lt {
1844
1854
  createCyclePath: this.createCyclePath,
1845
1855
  createDetourPath: this.createDetourPath,
1846
1856
  createLinePath: this.createLinePath,
1847
- padding: W
1857
+ padding: O
1848
1858
  }), this.svg = this.pathShape.svg, this.group = this.pathShape.group, this.line = this.pathShape.line, this.sourceArrow = this.pathShape.sourceArrow, this.targetArrow = this.pathShape.targetArrow, this.onAfterRender = this.pathShape.onAfterRender;
1849
1859
  }
1850
1860
  render(e) {
1851
1861
  this.pathShape.render(e);
1852
1862
  }
1853
1863
  }
1854
- class Ie {
1864
+ class $e {
1855
1865
  constructor(e) {
1856
1866
  i(this, "svg");
1857
1867
  i(this, "group", document.createElementNS(
@@ -1869,16 +1879,16 @@ class Ie {
1869
1879
  i(this, "onAfterRender");
1870
1880
  i(this, "afterRenderEmitter");
1871
1881
  i(this, "arrowRenderer");
1872
- [this.afterRenderEmitter, this.onAfterRender] = P(), this.color = (e == null ? void 0 : e.color) ?? v.color, this.width = (e == null ? void 0 : e.width) ?? v.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? v.arrowLength, this.arrowRenderer = B((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? v.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? v.preOffset, this.svg = Le(this.color), this.svg.appendChild(this.group), this.line = Re(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = X(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = X(), this.group.appendChild(this.targetArrow));
1882
+ [this.afterRenderEmitter, this.onAfterRender] = P(), this.color = (e == null ? void 0 : e.color) ?? v.color, this.width = (e == null ? void 0 : e.width) ?? v.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? v.arrowLength, this.arrowRenderer = B((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? v.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? v.preOffset, this.svg = Ie(this.color), this.svg.appendChild(this.group), this.line = Fe(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = Y(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = Y(), this.group.appendChild(this.targetArrow));
1873
1883
  }
1874
1884
  render(e) {
1875
- const { x: t, y: o, width: s, height: n, from: a, to: h } = De(
1885
+ const { x: t, y: o, width: s, height: n, from: a, to: h } = Ve(
1876
1886
  e.from,
1877
1887
  e.to,
1878
- W
1888
+ O
1879
1889
  );
1880
- Ve(this.svg, { x: t, y: o, width: s, height: n });
1881
- const d = new xt({
1890
+ Ue(this.svg, { x: t, y: o, width: s, height: n });
1891
+ const d = new St({
1882
1892
  from: a,
1883
1893
  to: h,
1884
1894
  sourceOffset: this.sourceOffset,
@@ -1930,40 +1940,40 @@ class Ie {
1930
1940
  });
1931
1941
  }
1932
1942
  }
1933
- const Rt = () => {
1943
+ const Ft = () => {
1934
1944
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
1935
1945
  return r.style.pointerEvents = "auto", r.style.cursor = "pointer", r;
1936
- }, Vt = (r) => {
1946
+ }, Ut = (r) => {
1937
1947
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1938
1948
  return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
1939
- }, me = (r) => {
1949
+ }, Ae = (r) => {
1940
1950
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1941
1951
  return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
1942
1952
  };
1943
- class It extends Error {
1953
+ class $t extends Error {
1944
1954
  constructor(e) {
1945
1955
  super(e), this.name = "InteractiveEdgeError";
1946
1956
  }
1947
1957
  }
1948
- class Fe {
1958
+ class Be {
1949
1959
  constructor(e, t) {
1950
1960
  i(this, "svg");
1951
1961
  i(this, "group");
1952
1962
  i(this, "line");
1953
1963
  i(this, "sourceArrow");
1954
1964
  i(this, "targetArrow");
1955
- i(this, "handle", Rt());
1965
+ i(this, "handle", Ft());
1956
1966
  i(this, "onAfterRender");
1957
1967
  i(this, "interactiveLine");
1958
1968
  i(this, "interactiveSourceArrow", null);
1959
1969
  i(this, "interactiveTargetArrow", null);
1960
- if (this.baseEdge = e, e instanceof Fe)
1961
- throw new It(
1970
+ if (this.baseEdge = e, e instanceof Be)
1971
+ throw new $t(
1962
1972
  "interactive edge can be configured only once"
1963
1973
  );
1964
1974
  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;
1965
1975
  const o = (t == null ? void 0 : t.distance) ?? v.interactiveWidth;
1966
- this.interactiveLine = Vt(o), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = me(o), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = me(o), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((s) => {
1976
+ this.interactiveLine = Ut(o), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = Ae(o), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = Ae(o), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((s) => {
1967
1977
  this.interactiveLine.setAttribute("d", s.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", s.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", s.targetArrowPath);
1968
1978
  });
1969
1979
  }
@@ -1971,7 +1981,7 @@ class Fe {
1971
1981
  this.baseEdge.render(e);
1972
1982
  }
1973
1983
  }
1974
- class Br {
1984
+ class Hr {
1975
1985
  constructor(e, t) {
1976
1986
  i(this, "group");
1977
1987
  i(this, "line");
@@ -1988,7 +1998,7 @@ class Br {
1988
1998
  this.baseShape.render(e);
1989
1999
  }
1990
2000
  }
1991
- class Ue {
2001
+ class Oe {
1992
2002
  constructor(e) {
1993
2003
  i(this, "onAfterNodeAdded");
1994
2004
  i(this, "onAfterNodeUpdated");
@@ -2059,6 +2069,9 @@ class Ue {
2059
2069
  shape: o.shape
2060
2070
  };
2061
2071
  }
2072
+ findEdgeIdByElement(e) {
2073
+ return this.graphStore.findEdgeIdByElement(e);
2074
+ }
2062
2075
  getPortIncomingEdgeIds(e) {
2063
2076
  return this.graphStore.getPortIncomingEdgeIds(e);
2064
2077
  }
@@ -2100,7 +2113,7 @@ class J {
2100
2113
  this.counter = 0;
2101
2114
  }
2102
2115
  }
2103
- class $e {
2116
+ class We {
2104
2117
  constructor(e, t, o) {
2105
2118
  i(this, "nodeIdGenerator", new J(
2106
2119
  (e) => this.graphStore.hasNode(e)
@@ -2231,18 +2244,18 @@ class $e {
2231
2244
  ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
2232
2245
  }
2233
2246
  }
2234
- const Ft = (r) => {
2247
+ const Bt = (r) => {
2235
2248
  setTimeout(() => {
2236
2249
  r();
2237
2250
  });
2238
- }, Ut = (r) => {
2251
+ }, Ot = (r) => {
2239
2252
  queueMicrotask(() => {
2240
2253
  r();
2241
2254
  });
2242
2255
  }, re = (r) => {
2243
2256
  r();
2244
2257
  };
2245
- class Be {
2258
+ class ze {
2246
2259
  constructor(e) {
2247
2260
  i(this, "onBeforeUpdated");
2248
2261
  i(this, "onAfterUpdated");
@@ -2265,7 +2278,7 @@ class Be {
2265
2278
  return this.viewportStore.createViewportCoords(e);
2266
2279
  }
2267
2280
  }
2268
- const $t = (r, e) => Symbol.iterator in r ? {
2281
+ const Wt = (r, e) => Symbol.iterator in r ? {
2269
2282
  minContentScale: e.focus.minContentScale,
2270
2283
  nodes: r,
2271
2284
  contentPadding: e.focus.contentPadding,
@@ -2275,16 +2288,16 @@ const $t = (r, e) => Symbol.iterator in r ? {
2275
2288
  nodes: r.nodes ?? [],
2276
2289
  contentPadding: r.contentPadding ?? r.contentOffset ?? e.focus.contentPadding,
2277
2290
  animationDuration: r.animationDuration ?? e.focus.animationDuration
2278
- }, We = (r, e, t) => ({
2291
+ }, ke = (r, e, t) => ({
2279
2292
  scale: r.scale,
2280
2293
  x: r.x + r.scale * e,
2281
2294
  y: r.y + r.scale * t
2282
- }), Oe = (r, e, t, o) => ({
2295
+ }), He = (r, e, t, o) => ({
2283
2296
  scale: r.scale * e,
2284
2297
  x: r.scale * (1 - e) * t + r.x,
2285
2298
  y: r.scale * (1 - e) * o + r.y
2286
2299
  });
2287
- class ze {
2300
+ class Ye {
2288
2301
  constructor(e, t, o, s) {
2289
2302
  this.graphStore = e, this.viewportStore = t, this.params = o, this.win = s;
2290
2303
  }
@@ -2296,11 +2309,11 @@ class ze {
2296
2309
  }
2297
2310
  center(e, t) {
2298
2311
  const { width: o, height: s } = this.viewportStore.getDimensions(), n = { x: o / 2, y: s / 2 }, a = this.viewportStore.getViewportMatrix(), h = this.viewportStore.createViewportCoords(e), d = h.x - n.x, c = h.y - n.y;
2299
- let u = We(a, d, c);
2312
+ let u = ke(a, d, c);
2300
2313
  const g = t == null ? void 0 : t.contentScale;
2301
2314
  if (g !== void 0) {
2302
2315
  const w = 1 / g;
2303
- u = Oe(
2316
+ u = He(
2304
2317
  u,
2305
2318
  w / a.scale,
2306
2319
  n.x,
@@ -2311,7 +2324,7 @@ class ze {
2311
2324
  l > 0 ? this.animateNavigation(a, u, l) : this.viewportStore.patchViewportMatrix(u);
2312
2325
  }
2313
2326
  focus(e) {
2314
- const t = $t(e ?? {}, this.params);
2327
+ const t = Wt(e ?? {}, this.params);
2315
2328
  this.params.focus.schedule(() => {
2316
2329
  this.navigate(t);
2317
2330
  });
@@ -2360,20 +2373,20 @@ class ze {
2360
2373
  this.win.requestAnimationFrame(a);
2361
2374
  }
2362
2375
  }
2363
- const ke = (r, e, t) => {
2364
- const o = new Pe(), s = new Ue(o), n = new Be(e), a = new Ne(o, e, r), h = {
2376
+ const Xe = (r, e, t) => {
2377
+ const o = new Me(), s = new Oe(o), n = new ze(e), a = new Ce(o, e, r), h = {
2365
2378
  nodes: {
2366
- centerFn: Me,
2379
+ centerFn: Le,
2367
2380
  priorityFn: () => 0
2368
2381
  },
2369
2382
  edges: {
2370
- shapeFactory: () => new Ie(),
2383
+ shapeFactory: () => new $e(),
2371
2384
  priorityFn: () => 0
2372
2385
  },
2373
2386
  ports: {
2374
2387
  direction: 0
2375
2388
  }
2376
- }, d = new $e(
2389
+ }, d = new We(
2377
2390
  o,
2378
2391
  a,
2379
2392
  h
@@ -2384,13 +2397,13 @@ const ke = (r, e, t) => {
2384
2397
  schedule: re,
2385
2398
  animationDuration: 0
2386
2399
  }
2387
- }, u = new ze(
2400
+ }, u = new Ye(
2388
2401
  o,
2389
2402
  e,
2390
2403
  c,
2391
2404
  t
2392
2405
  );
2393
- return new be(s, n, d, u);
2406
+ return new Te(s, n, d, u);
2394
2407
  };
2395
2408
  class G {
2396
2409
  constructor(e, t, o, s) {
@@ -2497,7 +2510,7 @@ class G {
2497
2510
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
2498
2511
  }
2499
2512
  }
2500
- class Bt {
2513
+ class zt {
2501
2514
  constructor(e, t, o) {
2502
2515
  this.canvas = e, this.layoutAlgorithm = t, this.params = o;
2503
2516
  }
@@ -2511,7 +2524,7 @@ class Bt {
2511
2524
  }), this.params.onAfterApplied();
2512
2525
  }
2513
2526
  }
2514
- class Wt {
2527
+ class kt {
2515
2528
  constructor(e, t, o) {
2516
2529
  this.canvas = e, this.layoutAlgorithm = t, this.params = o;
2517
2530
  }
@@ -2526,7 +2539,111 @@ class Wt {
2526
2539
  }), this.params.onAfterApplied();
2527
2540
  }
2528
2541
  }
2529
- class oe {
2542
+ class Ht {
2543
+ constructor() {
2544
+ i(this, "field", "_htmlGraphTags");
2545
+ }
2546
+ has(e, t) {
2547
+ const s = e[this.field];
2548
+ return s !== void 0 && s.has(t);
2549
+ }
2550
+ tag(e, t) {
2551
+ const o = e, s = o[this.field];
2552
+ s === void 0 ? o[this.field] = /* @__PURE__ */ new Set([t]) : s.add(t);
2553
+ }
2554
+ }
2555
+ const oe = Symbol();
2556
+ class se {
2557
+ constructor(e, t, o) {
2558
+ i(this, "onSelected");
2559
+ i(this, "mouseDownEventVerifier");
2560
+ i(this, "mouseUpEventVerifier");
2561
+ i(this, "movementThreshold");
2562
+ i(this, "selectionCandidate", null);
2563
+ i(this, "previousMouse", null);
2564
+ i(this, "previousTouch", null);
2565
+ i(this, "movedDistance", 0);
2566
+ i(this, "onElementMouseDown", (e) => {
2567
+ const t = e;
2568
+ this.mouseDownEventVerifier(t) && (this.selectionCandidate = t.currentTarget, this.previousMouse = { x: t.clientX, y: t.clientY }, this.movedDistance = 0, this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2569
+ passive: !0
2570
+ }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2571
+ passive: !0
2572
+ }));
2573
+ });
2574
+ i(this, "onElementTouchStart", (e) => {
2575
+ const t = e, o = t.touches;
2576
+ o.length === 1 && (this.selectionCandidate = t.currentTarget, this.previousTouch = o[0], this.movedDistance = 0, this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2577
+ passive: !0
2578
+ }), this.window.addEventListener("touchend", this.onWindowTouchEnd, {
2579
+ passive: !0
2580
+ }), this.window.addEventListener("touchcancel", this.onWindowTouchCancel, {
2581
+ passive: !0
2582
+ }));
2583
+ });
2584
+ i(this, "onWindowMouseMove", (e) => {
2585
+ const t = e;
2586
+ if (!this.pointInsideVerifier.verify(
2587
+ t.clientX,
2588
+ t.clientY
2589
+ )) {
2590
+ this.removeWindowMouseListeners();
2591
+ return;
2592
+ }
2593
+ const s = this.previousMouse, n = t.clientX - s.x, a = t.clientY - s.y;
2594
+ this.previousMouse = { x: t.clientX, y: t.clientY }, this.processMoveThresholdVerification(n, a, () => {
2595
+ this.removeWindowMouseListeners();
2596
+ });
2597
+ });
2598
+ i(this, "onWindowMouseUp", (e) => {
2599
+ const t = e;
2600
+ this.mouseUpEventVerifier(t) && (this.removeWindowMouseListeners(), this.onSelected(this.selectionCandidate, e));
2601
+ });
2602
+ i(this, "onWindowTouchMove", (e) => {
2603
+ const o = e.touches;
2604
+ if (o.length !== 1) {
2605
+ this.removeWindowTouchListeners();
2606
+ return;
2607
+ }
2608
+ const s = o[0];
2609
+ if (!this.pointInsideVerifier.verify(
2610
+ s.clientX,
2611
+ s.clientY
2612
+ )) {
2613
+ this.removeWindowTouchListeners();
2614
+ return;
2615
+ }
2616
+ const a = this.previousTouch, h = s.clientX - a.clientX, d = s.clientY - a.clientY;
2617
+ this.previousTouch = s, this.processMoveThresholdVerification(h, d, () => {
2618
+ this.removeWindowTouchListeners();
2619
+ });
2620
+ });
2621
+ i(this, "onWindowTouchEnd", (e) => {
2622
+ this.removeWindowTouchListeners(), this.onSelected(this.selectionCandidate, e);
2623
+ });
2624
+ i(this, "onWindowTouchCancel", () => {
2625
+ this.removeWindowTouchListeners();
2626
+ });
2627
+ this.window = e, this.pointInsideVerifier = t, this.mouseDownEventVerifier = o.mouseDownEventVerifier, this.mouseUpEventVerifier = o.mouseUpEventVerifier, this.onSelected = o.onSelected, this.movementThreshold = o.movementThreshold;
2628
+ }
2629
+ enable(e) {
2630
+ e.addEventListener("mousedown", this.onElementMouseDown), e.addEventListener("touchstart", this.onElementTouchStart);
2631
+ }
2632
+ disable(e) {
2633
+ e.removeEventListener("mousedown", this.onElementMouseDown), e.removeEventListener("touchstart", this.onElementTouchStart), e === this.selectionCandidate && (this.removeWindowMouseListeners(), this.removeWindowTouchListeners());
2634
+ }
2635
+ removeWindowMouseListeners() {
2636
+ this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
2637
+ }
2638
+ removeWindowTouchListeners() {
2639
+ this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchEnd), this.window.removeEventListener("touchcancel", this.onWindowTouchCancel);
2640
+ }
2641
+ processMoveThresholdVerification(e, t, o) {
2642
+ const s = Math.sqrt(e * e + t * t);
2643
+ this.movedDistance += s, this.movedDistance > this.movementThreshold && o();
2644
+ }
2645
+ }
2646
+ class ie {
2530
2647
  constructor(e, t, o, s, n) {
2531
2648
  i(this, "grabbedNode", null);
2532
2649
  i(this, "maxNodePriority", 0);
@@ -2645,7 +2762,7 @@ class oe {
2645
2762
  this.canvas = e, this.element = t, this.window = o, this.pointInsideVerifier = s, this.params = n, this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.reset), this.canvas.onBeforeDestroy.subscribe(this.revert);
2646
2763
  }
2647
2764
  static configure(e, t, o, s, n) {
2648
- new oe(
2765
+ new ie(
2649
2766
  e,
2650
2767
  t,
2651
2768
  o,
@@ -2720,7 +2837,7 @@ class oe {
2720
2837
  return e;
2721
2838
  }
2722
2839
  }
2723
- const O = (r) => {
2840
+ const W = (r) => {
2724
2841
  const e = [], t = r.touches.length;
2725
2842
  for (let h = 0; h < t; h++)
2726
2843
  e.push([r.touches[h].clientX, r.touches[h].clientY]);
@@ -2780,10 +2897,10 @@ class j {
2780
2897
  });
2781
2898
  i(this, "onTouchStart", (e) => {
2782
2899
  if (this.prevTouches !== null) {
2783
- this.prevTouches = O(e);
2900
+ this.prevTouches = W(e);
2784
2901
  return;
2785
2902
  }
2786
- this.prevTouches = O(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2903
+ this.prevTouches = W(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2787
2904
  passive: !0
2788
2905
  }), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
2789
2906
  passive: !0
@@ -2792,7 +2909,7 @@ class j {
2792
2909
  }), this.startRegisteredTransform();
2793
2910
  });
2794
2911
  i(this, "onWindowTouchMove", (e) => {
2795
- const t = O(e);
2912
+ const t = W(e);
2796
2913
  if (!t.touches.every(
2797
2914
  (s) => this.pointInsideVerifier.verify(s[0], s[1])
2798
2915
  )) {
@@ -2809,7 +2926,7 @@ class j {
2809
2926
  this.prevTouches = t;
2810
2927
  });
2811
2928
  i(this, "onWindowTouchFinish", (e) => {
2812
- e.touches.length > 0 ? this.prevTouches = O(e) : this.stopTouchDrag();
2929
+ e.touches.length > 0 ? this.prevTouches = W(e) : this.stopTouchDrag();
2813
2930
  });
2814
2931
  i(this, "preventWheelScaleListener", (e) => {
2815
2932
  e.preventDefault();
@@ -2836,7 +2953,7 @@ class j {
2836
2953
  );
2837
2954
  }
2838
2955
  moveViewport(e, t) {
2839
- const o = this.viewport.getViewportMatrix(), s = We(o, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
2956
+ const o = this.viewport.getViewportMatrix(), s = ke(o, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
2840
2957
  prevTransform: o,
2841
2958
  nextTransform: s,
2842
2959
  canvasWidth: n,
@@ -2845,7 +2962,7 @@ class j {
2845
2962
  this.performTransform(h);
2846
2963
  }
2847
2964
  scaleViewport(e, t, o) {
2848
- const s = this.canvas.viewport.getViewportMatrix(), n = Oe(s, e, t, o), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
2965
+ const s = this.canvas.viewport.getViewportMatrix(), n = He(s, e, t, o), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
2849
2966
  prevTransform: s,
2850
2967
  nextTransform: n,
2851
2968
  canvasWidth: a,
@@ -2884,7 +3001,7 @@ class j {
2884
3001
  this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.params.onResizeTransformFinished();
2885
3002
  }
2886
3003
  }
2887
- class se {
3004
+ class ne {
2888
3005
  constructor(e, t, o, s, n, a, h) {
2889
3006
  i(this, "nodeHorizontal");
2890
3007
  i(this, "nodeVertical");
@@ -2940,7 +3057,7 @@ class se {
2940
3057
  ), this.trigger.subscribe(this.updateLoadedArea), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
2941
3058
  }
2942
3059
  static configure(e, t, o, s, n, a, h) {
2943
- new se(
3060
+ new ne(
2944
3061
  e,
2945
3062
  t,
2946
3063
  o,
@@ -2971,24 +3088,24 @@ class se {
2971
3088
  });
2972
3089
  }
2973
3090
  }
2974
- const Ot = () => {
3091
+ const Yt = () => {
2975
3092
  const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2976
3093
  return r.style.position = "absolute", r.style.inset = "0", r;
2977
- }, zt = () => {
3094
+ }, Xt = () => {
2978
3095
  const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2979
3096
  return r.setAttribute("fill", "url(#pattern)"), r;
2980
- }, kt = () => {
3097
+ }, Gt = () => {
2981
3098
  const r = document.createElementNS(
2982
3099
  "http://www.w3.org/2000/svg",
2983
3100
  "pattern"
2984
3101
  );
2985
3102
  return r.setAttribute("id", "pattern"), r;
2986
3103
  };
2987
- class ie {
3104
+ class ae {
2988
3105
  constructor(e, t, o) {
2989
- i(this, "svg", Ot());
2990
- i(this, "patternRenderingRectangle", zt());
2991
- i(this, "pattern", kt());
3106
+ i(this, "svg", Yt());
3107
+ i(this, "patternRenderingRectangle", Xt());
3108
+ i(this, "pattern", Gt());
2992
3109
  i(this, "patternContent");
2993
3110
  i(this, "tileWidth");
2994
3111
  i(this, "tileHeight");
@@ -3009,7 +3126,7 @@ class ie {
3009
3126
  }), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated();
3010
3127
  }
3011
3128
  static configure(e, t, o) {
3012
- new ie(e, t, o);
3129
+ new ae(e, t, o);
3013
3130
  }
3014
3131
  updateVisibility() {
3015
3132
  const { scale: e } = this.canvas.viewport.getViewportMatrix(), t = e > this.maxViewportScale;
@@ -3023,7 +3140,7 @@ class ie {
3023
3140
  }
3024
3141
  }
3025
3142
  }
3026
- class ne {
3143
+ class he {
3027
3144
  constructor(e, t, o, s, n, a) {
3028
3145
  i(this, "overlayCanvas");
3029
3146
  i(this, "staticPortId", null);
@@ -3031,7 +3148,7 @@ class ne {
3031
3148
  i(this, "onEdgeCreated", (e) => {
3032
3149
  this.params.onAfterEdgeCreated(e);
3033
3150
  });
3034
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = ke(
3151
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = Xe(
3035
3152
  this.overlayLayer,
3036
3153
  this.viewportStore,
3037
3154
  this.window
@@ -3062,7 +3179,7 @@ class ne {
3062
3179
  );
3063
3180
  }
3064
3181
  static configure(e, t, o, s, n, a) {
3065
- new ne(
3182
+ new he(
3066
3183
  e,
3067
3184
  t,
3068
3185
  o,
@@ -3091,7 +3208,7 @@ class ne {
3091
3208
  };
3092
3209
  this.isTargetDragging = o === "direct";
3093
3210
  const [w, p] = this.isTargetDragging ? [g, l] : [l, g];
3094
- this.overlayCanvas.addNode(Y(w)), this.overlayCanvas.addNode(Y(p)), this.overlayCanvas.addEdge({
3211
+ this.overlayCanvas.addNode(H(w)), this.overlayCanvas.addNode(H(p)), this.overlayCanvas.addEdge({
3095
3212
  from: w.overlayNodeId,
3096
3213
  to: p.overlayNodeId,
3097
3214
  shape: this.params.edgeShapeFactory(M.EdgeId)
@@ -3101,7 +3218,7 @@ class ne {
3101
3218
  this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
3102
3219
  }
3103
3220
  tryCreateConnection(e) {
3104
- const t = Ce(this.canvas.graph, e);
3221
+ const t = Re(this.canvas.graph, e);
3105
3222
  if (t === null) {
3106
3223
  this.handleEdgeCreationInterrupted();
3107
3224
  return;
@@ -3127,7 +3244,7 @@ class ne {
3127
3244
  });
3128
3245
  }
3129
3246
  }
3130
- class ae {
3247
+ class de {
3131
3248
  constructor(e, t, o, s, n, a) {
3132
3249
  i(this, "overlayCanvas");
3133
3250
  i(this, "staticPortId", null);
@@ -3136,7 +3253,7 @@ class ae {
3136
3253
  i(this, "onEdgeReattached", (e) => {
3137
3254
  this.params.onAfterEdgeReattached(e);
3138
3255
  });
3139
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = ke(
3256
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = Xe(
3140
3257
  this.overlayLayer,
3141
3258
  this.viewportStore,
3142
3259
  this.window
@@ -3155,7 +3272,16 @@ class ae {
3155
3272
  this.moveDraggingPort(h);
3156
3273
  },
3157
3274
  onPointerMoveOutside: () => {
3158
- this.handleEdgeReattachInterrupted();
3275
+ const h = this.draggingEdgePayload;
3276
+ queueMicrotask(() => {
3277
+ this.params.onEdgeReattachInterrupted({
3278
+ id: h.id,
3279
+ from: h.from,
3280
+ to: h.to,
3281
+ shape: h.shape,
3282
+ priority: h.priority
3283
+ });
3284
+ });
3159
3285
  },
3160
3286
  onPointerUp: (h) => {
3161
3287
  this.tryCreateConnection(h);
@@ -3164,7 +3290,7 @@ class ae {
3164
3290
  );
3165
3291
  }
3166
3292
  static configure(e, t, o, s, n, a) {
3167
- new ae(
3293
+ new de(
3168
3294
  e,
3169
3295
  t,
3170
3296
  o,
@@ -3205,13 +3331,13 @@ class ae {
3205
3331
  portCoords: p,
3206
3332
  portDirection: d.direction
3207
3333
  }, [x, E] = this.isTargetDragging ? [y, f] : [f, y];
3208
- this.overlayCanvas.addNode(Y(x)), this.overlayCanvas.addNode(Y(E));
3209
- const b = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(M.EdgeId) : s.shape;
3334
+ this.overlayCanvas.addNode(H(x)), this.overlayCanvas.addNode(H(E));
3335
+ const N = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(M.EdgeId) : s.shape;
3210
3336
  return this.overlayCanvas.addEdge({
3211
3337
  id: M.EdgeId,
3212
3338
  from: x.overlayNodeId,
3213
3339
  to: E.overlayNodeId,
3214
- shape: b
3340
+ shape: N
3215
3341
  }), !0;
3216
3342
  }
3217
3343
  resetDragState() {
@@ -3228,7 +3354,7 @@ class ae {
3228
3354
  });
3229
3355
  }
3230
3356
  tryCreateConnection(e) {
3231
- const t = Ce(this.canvas.graph, e);
3357
+ const t = Re(this.canvas.graph, e);
3232
3358
  if (this.overlayCanvas.removeEdge(M.EdgeId), t === null) {
3233
3359
  this.handleEdgeReattachInterrupted();
3234
3360
  return;
@@ -3264,17 +3390,17 @@ class ae {
3264
3390
  });
3265
3391
  }
3266
3392
  }
3267
- class he {
3393
+ class ce {
3268
3394
  constructor(e, t) {
3269
3395
  this.applier = e, this.trigger = t, this.trigger.subscribe(() => {
3270
3396
  this.applier.apply();
3271
3397
  });
3272
3398
  }
3273
3399
  static configure(e, t) {
3274
- new he(e, t);
3400
+ new ce(e, t);
3275
3401
  }
3276
3402
  }
3277
- class de {
3403
+ class le {
3278
3404
  constructor(e, t, o) {
3279
3405
  i(this, "applyScheduled", !1);
3280
3406
  i(this, "apply", () => {
@@ -3291,7 +3417,7 @@ class de {
3291
3417
  });
3292
3418
  }
3293
3419
  static configure(e, t, o) {
3294
- new de(
3420
+ new le(
3295
3421
  e,
3296
3422
  t,
3297
3423
  o
@@ -3301,23 +3427,23 @@ class de {
3301
3427
  this.applyScheduled || (this.applyScheduled = !0, this.defererFn(this.apply));
3302
3428
  }
3303
3429
  }
3304
- class Yt {
3430
+ class jt {
3305
3431
  static configure(e, t) {
3306
- const o = t.applyOn, s = new Bt(e, t.algorithm, {
3432
+ const o = t.applyOn, s = new zt(e, t.algorithm, {
3307
3433
  staticNodeResolver: t.staticNodeResolver,
3308
3434
  onBeforeApplied: t.onBeforeApplied,
3309
3435
  onAfterApplied: t.onAfterApplied
3310
3436
  });
3311
3437
  switch (o.type) {
3312
3438
  case "trigger": {
3313
- he.configure(
3439
+ ce.configure(
3314
3440
  s,
3315
3441
  o.trigger
3316
3442
  );
3317
3443
  break;
3318
3444
  }
3319
3445
  case "topologyChangeSchedule": {
3320
- de.configure(
3446
+ le.configure(
3321
3447
  e.graph,
3322
3448
  s,
3323
3449
  o.schedule
@@ -3327,7 +3453,7 @@ class Yt {
3327
3453
  }
3328
3454
  }
3329
3455
  }
3330
- class Xt {
3456
+ class Jt {
3331
3457
  constructor(e, t) {
3332
3458
  i(this, "previousTimeStamp");
3333
3459
  i(this, "step", (e) => {
@@ -3342,222 +3468,100 @@ class Xt {
3342
3468
  this.win = e, this.callback = t, this.win.requestAnimationFrame(this.step);
3343
3469
  }
3344
3470
  }
3345
- class ce {
3471
+ class ue {
3346
3472
  constructor(e, t, o) {
3347
3473
  i(this, "applier");
3348
3474
  i(this, "step", (e) => {
3349
3475
  this.applier.apply(e);
3350
3476
  });
3351
- this.win = o, this.applier = new Wt(e, t.algorithm, {
3477
+ this.win = o, this.applier = new kt(e, t.algorithm, {
3352
3478
  staticNodeResolver: t.staticNodeResolver,
3353
3479
  onBeforeApplied: t.onBeforeApplied,
3354
3480
  onAfterApplied: t.onAfterApplied
3355
- }), new Xt(this.win, this.step);
3481
+ }), new Jt(this.win, this.step);
3356
3482
  }
3357
3483
  static configure(e, t, o) {
3358
- new ce(e, t, o);
3484
+ new ue(e, t, o);
3359
3485
  }
3360
3486
  }
3361
- class le {
3362
- constructor(e, t, o, s) {
3487
+ class ge {
3488
+ constructor(e, t, o, s, n) {
3489
+ i(this, "configurator");
3363
3490
  i(this, "onNodeSelected");
3364
- i(this, "mouseDownEventVerifier");
3365
- i(this, "mouseUpEventVerifier");
3366
- i(this, "movementThreshold");
3367
- i(this, "selectionCandidateNodeId", null);
3368
- i(this, "movedDistance", 0);
3369
- i(this, "previousMouse", null);
3370
- i(this, "previousTouch", null);
3491
+ i(this, "selectionHandledTag", oe);
3371
3492
  i(this, "onAfterNodeAdded", (e) => {
3372
3493
  const { element: t } = this.canvas.graph.getNode(e);
3373
- t.addEventListener("mousedown", this.onNodeMouseDown, {
3374
- passive: !0
3375
- }), t.addEventListener("touchstart", this.onNodeTouchStart, {
3376
- passive: !0
3377
- });
3494
+ this.configurator.enable(t);
3378
3495
  });
3379
3496
  i(this, "onBeforeNodeRemoved", (e) => {
3380
3497
  const { element: t } = this.canvas.graph.getNode(e);
3381
- t.removeEventListener("mousedown", this.onNodeMouseDown), t.removeEventListener("touchstart", this.onNodeTouchStart);
3498
+ this.configurator.disable(t);
3382
3499
  });
3383
3500
  i(this, "reset", () => {
3384
3501
  this.canvas.graph.getAllNodeIds().forEach((e) => {
3385
3502
  const { element: t } = this.canvas.graph.getNode(e);
3386
- t.removeEventListener("mousedown", this.onNodeMouseDown), t.removeEventListener("touchstart", this.onNodeTouchStart);
3387
- });
3388
- });
3389
- i(this, "revert", () => {
3390
- this.reset(), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
3391
- });
3392
- i(this, "onNodeMouseDown", (e) => {
3393
- const t = e;
3394
- if (!this.mouseDownEventVerifier(t))
3395
- return;
3396
- const o = this.canvas.graph.findNodeIdByElement(
3397
- e.currentTarget
3398
- );
3399
- this.selectionCandidateNodeId = o, this.previousMouse = { x: t.clientX, y: t.clientY }, this.movedDistance = 0, this.window.addEventListener("mousemove", this.onWindowMouseMove, {
3400
- passive: !0
3401
- }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
3402
- passive: !0
3403
- });
3404
- });
3405
- i(this, "onNodeTouchStart", (e) => {
3406
- const t = e;
3407
- if (t.touches.length !== 1)
3408
- return;
3409
- const o = this.canvas.graph.findNodeIdByElement(
3410
- t.currentTarget
3411
- );
3412
- this.selectionCandidateNodeId = o, this.previousTouch = t.touches[0], this.movedDistance = 0, this.window.addEventListener("touchmove", this.onWindowTouchMove, {
3413
- passive: !0
3414
- }), this.window.addEventListener("touchend", this.onWindowTouchEnd, {
3415
- passive: !0
3416
- }), this.window.addEventListener("touchcancel", this.onWindowTouchCancel, {
3417
- passive: !0
3503
+ this.configurator.disable(t);
3418
3504
  });
3419
3505
  });
3420
- i(this, "onWindowMouseMove", (e) => {
3421
- const t = e, o = this.previousMouse, s = t.clientX - o.x, n = t.clientY - o.y;
3422
- if (!this.pointInsideVerifier.verify(t.clientX, t.clientY)) {
3423
- this.removeWindowMouseListeners();
3424
- return;
3425
- }
3426
- this.processMoveThresholdVerification(s, n, () => {
3427
- this.removeWindowMouseListeners();
3428
- }), this.previousMouse = { x: t.clientX, y: t.clientY };
3429
- });
3430
- i(this, "onWindowTouchMove", (e) => {
3431
- const t = e;
3432
- if (t.touches.length !== 1) {
3433
- this.removeWindowTouchListeners();
3434
- return;
3435
- }
3436
- const o = t.touches[0];
3437
- if (!this.pointInsideVerifier.verify(o.clientX, o.clientY)) {
3438
- this.removeWindowTouchListeners();
3439
- return;
3506
+ this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.eventTagger = s, this.onNodeSelected = n.onNodeSelected, this.configurator = new se(
3507
+ this.window,
3508
+ this.pointInsideVerifier,
3509
+ {
3510
+ onSelected: (a, h) => {
3511
+ const d = this.canvas.graph.findNodeIdByElement(a);
3512
+ this.eventTagger.tag(h, this.selectionHandledTag), this.onNodeSelected(d);
3513
+ },
3514
+ movementThreshold: n.movementThreshold,
3515
+ mouseDownEventVerifier: n.mouseDownEventVerifier,
3516
+ mouseUpEventVerifier: n.mouseUpEventVerifier
3440
3517
  }
3441
- const s = this.previousTouch, n = o.clientX - s.clientX, a = o.clientY - s.clientY;
3442
- this.processMoveThresholdVerification(n, a, () => {
3443
- this.removeWindowTouchListeners();
3444
- }), this.previousTouch = o;
3445
- });
3446
- i(this, "onWindowMouseUp", (e) => {
3447
- const t = e;
3448
- this.mouseUpEventVerifier(t) && (this.removeWindowMouseListeners(), this.trySelectNode(e));
3449
- });
3450
- i(this, "onWindowTouchEnd", (e) => {
3451
- this.removeWindowTouchListeners(), this.trySelectNode(e);
3452
- });
3453
- i(this, "onWindowTouchCancel", () => {
3454
- this.removeWindowTouchListeners();
3455
- });
3456
- this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.mouseDownEventVerifier = s.mouseDownEventVerifier, this.mouseUpEventVerifier = s.mouseUpEventVerifier, this.onNodeSelected = s.onNodeSelected, this.movementThreshold = s.movementThreshold, this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.reset), this.canvas.onBeforeDestroy.subscribe(this.revert);
3518
+ ), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.reset), this.canvas.onBeforeDestroy.subscribe(this.reset);
3457
3519
  }
3458
- static configure(e, t, o, s) {
3459
- new le(
3520
+ static configure(e, t, o, s, n) {
3521
+ new ge(
3460
3522
  e,
3461
3523
  t,
3462
3524
  o,
3463
- s
3525
+ s,
3526
+ n
3464
3527
  );
3465
3528
  }
3466
- removeWindowMouseListeners() {
3467
- this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
3468
- }
3469
- removeWindowTouchListeners() {
3470
- this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchEnd), this.window.removeEventListener("touchcancel", this.onWindowTouchCancel);
3471
- }
3472
- trySelectNode(e) {
3473
- const t = this.selectionCandidateNodeId;
3474
- this.canvas.graph.hasNode(t) && (this.onNodeSelected(t), e.ignoreCanvasSelection = !0);
3475
- }
3476
- processMoveThresholdVerification(e, t, o) {
3477
- const s = Math.sqrt(e * e + t * t);
3478
- this.movedDistance += s, this.movedDistance > this.movementThreshold && o();
3479
- }
3480
3529
  }
3481
- class ue {
3530
+ class pe {
3482
3531
  constructor(e, t, o, s, n) {
3483
- i(this, "onCanvasSelected");
3484
- i(this, "movementThreshold");
3485
- i(this, "mouseDownEventVerifier");
3486
- i(this, "mouseUpEventVerifier");
3487
- i(this, "movedDistance", 0);
3488
- i(this, "previousMouseDown", null);
3489
- i(this, "previousTouch", null);
3490
- i(this, "onMouseDown", (e) => {
3491
- const t = e;
3492
- this.mouseDownEventVerifier(t) && (this.previousMouseDown = { x: t.clientX, y: t.clientY }, this.movedDistance = 0, this.window.addEventListener("mousemove", this.onWindowMouseMove, {
3493
- passive: !0
3494
- }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
3495
- passive: !0
3496
- }));
3532
+ i(this, "configurator");
3533
+ i(this, "selectionHandledTag", oe);
3534
+ i(this, "onEdgeSelected");
3535
+ i(this, "onAfterEdgeAdded", (e) => {
3536
+ const { shape: t } = this.canvas.graph.getEdge(e);
3537
+ this.configurator.enable(t.svg);
3497
3538
  });
3498
- i(this, "onTouchStart", (e) => {
3499
- const t = e;
3500
- if (t.touches.length !== 1)
3501
- return;
3502
- const o = t.touches[0];
3503
- this.previousTouch = o, this.movedDistance = 0, this.window.addEventListener("touchmove", this.onWindowTouchMove, {
3504
- passive: !0
3505
- }), this.window.addEventListener("touchend", this.onWindowTouchEnd, {
3506
- passive: !0
3507
- }), this.window.addEventListener("touchcancel", this.onWindowTouchCancel, {
3508
- passive: !0
3509
- });
3539
+ i(this, "onBeforeEdgeRemoved", (e) => {
3540
+ const { shape: t } = this.canvas.graph.getEdge(e);
3541
+ this.configurator.disable(t.svg);
3510
3542
  });
3511
- i(this, "onWindowMouseMove", (e) => {
3512
- const t = e;
3513
- if (!this.pointInsideVerifier.verify(t.clientX, t.clientY)) {
3514
- this.removeWindowMouseListeners();
3515
- return;
3516
- }
3517
- const o = this.previousMouseDown, s = t.clientX - o.x, n = t.clientY - o.y;
3518
- this.processMoveThresholdVerification(s, n, () => {
3519
- this.removeWindowMouseListeners();
3520
- }), this.previousMouseDown = { x: t.clientX, y: t.clientY };
3543
+ i(this, "reset", () => {
3544
+ this.canvas.graph.getAllEdgeIds().forEach((e) => {
3545
+ const { shape: t } = this.canvas.graph.getEdge(e);
3546
+ this.configurator.disable(t.svg);
3547
+ });
3521
3548
  });
3522
- i(this, "onWindowTouchMove", (e) => {
3523
- const t = e;
3524
- if (t.touches.length !== 1) {
3525
- this.removeWindowTouchListeners();
3526
- return;
3527
- }
3528
- const o = t.touches[0];
3529
- if (!this.pointInsideVerifier.verify(o.clientX, o.clientY)) {
3530
- this.removeWindowTouchListeners();
3531
- return;
3549
+ this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.eventTagger = s, this.onEdgeSelected = n.onEdgeSelected, this.configurator = new se(
3550
+ this.window,
3551
+ this.pointInsideVerifier,
3552
+ {
3553
+ onSelected: (a, h) => {
3554
+ const d = this.canvas.graph.findEdgeIdByElement(a);
3555
+ this.eventTagger.tag(h, this.selectionHandledTag), this.onEdgeSelected(d);
3556
+ },
3557
+ movementThreshold: n.movementThreshold,
3558
+ mouseDownEventVerifier: n.mouseDownEventVerifier,
3559
+ mouseUpEventVerifier: n.mouseUpEventVerifier
3532
3560
  }
3533
- const s = this.previousTouch, n = o.clientX - s.clientX, a = o.clientY - s.clientY;
3534
- this.processMoveThresholdVerification(n, a, () => {
3535
- this.removeWindowTouchListeners();
3536
- }), this.previousTouch = o;
3537
- });
3538
- i(this, "onWindowMouseUp", (e) => {
3539
- const t = e;
3540
- if (!this.mouseUpEventVerifier(t))
3541
- return;
3542
- e.ignoreCanvasSelection !== !0 && this.onCanvasSelected(), this.removeWindowMouseListeners();
3543
- });
3544
- i(this, "onWindowTouchEnd", () => {
3545
- this.onCanvasSelected(), this.removeWindowTouchListeners();
3546
- });
3547
- i(this, "onWindowTouchCancel", () => {
3548
- this.removeWindowTouchListeners();
3549
- });
3550
- i(this, "restore", () => {
3551
- this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("touchstart", this.onTouchStart), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
3552
- });
3553
- this.canvas = e, this.element = t, this.window = o, this.pointInsideVerifier = s, this.onCanvasSelected = n.onCanvasSelected, this.movementThreshold = n.movementThreshold, this.mouseDownEventVerifier = n.mouseDownEventVerifier, this.mouseUpEventVerifier = n.mouseUpEventVerifier, this.canvas.onBeforeDestroy.subscribe(this.restore), this.element.addEventListener("mousedown", this.onMouseDown, {
3554
- passive: !0
3555
- }), this.element.addEventListener("touchstart", this.onTouchStart, {
3556
- passive: !0
3557
- });
3561
+ ), this.canvas.graph.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.canvas.graph.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.reset), this.canvas.onBeforeDestroy.subscribe(this.reset);
3558
3562
  }
3559
3563
  static configure(e, t, o, s, n) {
3560
- new ue(
3564
+ new pe(
3561
3565
  e,
3562
3566
  t,
3563
3567
  o,
@@ -3565,46 +3569,68 @@ class ue {
3565
3569
  n
3566
3570
  );
3567
3571
  }
3568
- removeWindowMouseListeners() {
3569
- this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
3570
- }
3571
- removeWindowTouchListeners() {
3572
- this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchEnd), this.window.removeEventListener("touchcancel", this.onWindowTouchCancel);
3572
+ }
3573
+ class we {
3574
+ constructor(e, t, o, s, n, a) {
3575
+ i(this, "configurator");
3576
+ i(this, "onCanvasSelected");
3577
+ i(this, "selectionHandledTag", oe);
3578
+ i(this, "restore", () => {
3579
+ this.configurator.disable(this.element);
3580
+ });
3581
+ this.canvas = e, this.element = t, this.window = o, this.pointInsideVerifier = s, this.eventTagger = n, this.onCanvasSelected = a.onCanvasSelected, this.configurator = new se(
3582
+ this.window,
3583
+ this.pointInsideVerifier,
3584
+ {
3585
+ onSelected: (h, d) => {
3586
+ this.eventTagger.has(d, this.selectionHandledTag) || this.onCanvasSelected();
3587
+ },
3588
+ movementThreshold: a.movementThreshold,
3589
+ mouseDownEventVerifier: a.mouseDownEventVerifier,
3590
+ mouseUpEventVerifier: a.mouseUpEventVerifier
3591
+ }
3592
+ ), this.configurator.enable(this.element), this.canvas.onBeforeDestroy.subscribe(this.restore);
3573
3593
  }
3574
- processMoveThresholdVerification(e, t, o) {
3575
- const s = Math.sqrt(e * e + t * t);
3576
- this.movedDistance += s, this.movedDistance > this.movementThreshold && o();
3594
+ static configure(e, t, o, s, n, a) {
3595
+ new we(
3596
+ e,
3597
+ t,
3598
+ o,
3599
+ s,
3600
+ n,
3601
+ a
3602
+ );
3577
3603
  }
3578
3604
  }
3579
- const Ht = () => {
3605
+ const Kt = () => {
3580
3606
  const r = document.createElement("div");
3581
3607
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
3582
3608
  }, Q = () => {
3583
3609
  const r = document.createElement("div");
3584
3610
  return r.style.position = "absolute", r.style.inset = "0", r;
3585
- }, xe = () => {
3611
+ }, Se = () => {
3586
3612
  const r = Q();
3587
3613
  return r.style.pointerEvents = "none", r;
3588
3614
  };
3589
- class Gt {
3615
+ class Qt {
3590
3616
  constructor(e) {
3591
3617
  i(this, "background", Q());
3592
3618
  i(this, "main", Q());
3593
- i(this, "overlayConnectablePorts", xe());
3594
- i(this, "overlayDraggableEdges", xe());
3595
- i(this, "host", Ht());
3619
+ i(this, "overlayConnectablePorts", Se());
3620
+ i(this, "overlayDraggableEdges", Se());
3621
+ i(this, "host", Kt());
3596
3622
  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);
3597
3623
  }
3598
3624
  destroy() {
3599
3625
  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);
3600
3626
  }
3601
3627
  }
3602
- const jt = (r) => {
3628
+ const Zt = (r) => {
3603
3629
  var w, p, y, f, x, E;
3604
3630
  const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
3605
3631
  }), t = ((p = r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
3606
3632
  }), o = r.nodeDragVerifier ?? (() => !0), s = ((y = r.events) == null ? void 0 : y.onNodeDragFinished) ?? (() => {
3607
- }), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (f = r.mouse) == null ? void 0 : f.dragCursor, d = h !== void 0 ? h : "grab", c = (x = r.mouse) == null ? void 0 : x.mouseDownEventVerifier, u = c !== void 0 ? c : (b) => b.button === 0, g = (E = r.mouse) == null ? void 0 : E.mouseUpEventVerifier, l = g !== void 0 ? g : (b) => b.button === 0;
3633
+ }), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (f = r.mouse) == null ? void 0 : f.dragCursor, d = h !== void 0 ? h : "grab", c = (x = r.mouse) == null ? void 0 : x.mouseDownEventVerifier, u = c !== void 0 ? c : (N) => N.button === 0, g = (E = r.mouse) == null ? void 0 : E.mouseUpEventVerifier, l = g !== void 0 ? g : (N) => N.button === 0;
3608
3634
  return {
3609
3635
  moveOnTop: n,
3610
3636
  moveEdgesOnTop: a,
@@ -3617,7 +3643,7 @@ const jt = (r) => {
3617
3643
  nodeDragVerifier: o,
3618
3644
  onNodeDragFinished: s
3619
3645
  };
3620
- }, Jt = (r) => {
3646
+ }, _t = (r) => {
3621
3647
  const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, o = r.minY !== null ? r.minY : -1 / 0, s = r.maxY !== null ? r.maxY : 1 / 0;
3622
3648
  return (n) => {
3623
3649
  let a = n.nextTransform.x, h = n.nextTransform.y;
@@ -3627,7 +3653,7 @@ const jt = (r) => {
3627
3653
  const u = n.canvasHeight * n.prevTransform.scale, g = s - u;
3628
3654
  return h > g && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, g)), { scale: n.nextTransform.scale, x: a, y: h };
3629
3655
  };
3630
- }, Kt = (r) => {
3656
+ }, qt = (r) => {
3631
3657
  const e = r.maxContentScale, t = r.minContentScale, o = e !== null ? 1 / e : 0, s = t !== null ? 1 / t : 1 / 0;
3632
3658
  return (n) => {
3633
3659
  const a = n.prevTransform, h = n.nextTransform;
@@ -3648,7 +3674,7 @@ const jt = (r) => {
3648
3674
  y: u
3649
3675
  };
3650
3676
  };
3651
- }, Qt = (r) => (e) => r.reduce(
3677
+ }, er = (r) => (e) => r.reduce(
3652
3678
  (t, o) => o({
3653
3679
  prevTransform: e.prevTransform,
3654
3680
  nextTransform: t,
@@ -3656,38 +3682,38 @@ const jt = (r) => {
3656
3682
  canvasHeight: e.canvasHeight
3657
3683
  }),
3658
3684
  e.nextTransform
3659
- ), Ee = (r) => {
3685
+ ), be = (r) => {
3660
3686
  if (typeof r == "function")
3661
3687
  return r;
3662
3688
  switch (r.type) {
3663
3689
  case "scale-limit":
3664
- return Kt({
3690
+ return qt({
3665
3691
  minContentScale: r.minContentScale ?? 0,
3666
3692
  maxContentScale: r.maxContentScale ?? 1 / 0
3667
3693
  });
3668
3694
  case "shift-limit":
3669
- return Jt({
3695
+ return _t({
3670
3696
  minX: r.minX ?? -1 / 0,
3671
3697
  maxX: r.maxX ?? 1 / 0,
3672
3698
  minY: r.minY ?? -1 / 0,
3673
3699
  maxY: r.maxY ?? 1 / 0
3674
3700
  });
3675
3701
  }
3676
- }, Ae = (r) => {
3677
- var p, y, f, x, E, b, T, C, I, F, U, pe;
3702
+ }, Ne = (r) => {
3703
+ var p, y, f, x, E, N, C, T, I, F, U, fe;
3678
3704
  const e = (p = r == null ? void 0 : r.scale) == null ? void 0 : p.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, o = r == null ? void 0 : r.transformPreprocessor;
3679
3705
  let s;
3680
- o !== void 0 ? Array.isArray(o) ? s = Qt(
3706
+ o !== void 0 ? Array.isArray(o) ? s = er(
3681
3707
  o.map(
3682
- (D) => Ee(D)
3708
+ (R) => be(R)
3683
3709
  )
3684
- ) : s = Ee(o) : s = (D) => D.nextTransform;
3710
+ ) : s = be(o) : s = (R) => R.nextTransform;
3685
3711
  const n = ((y = r == null ? void 0 : r.shift) == null ? void 0 : y.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((f = r == null ? void 0 : r.events) == null ? void 0 : f.onBeforeTransformChange) ?? (() => {
3686
3712
  }), h = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onTransformChange) ?? (() => {
3687
- }), d = (E = r == null ? void 0 : r.shift) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (D) => D.button === 0, u = (b = r == null ? void 0 : r.shift) == null ? void 0 : b.mouseUpEventVerifier, g = u !== void 0 ? u : (D) => D.button === 0, l = (T = r == null ? void 0 : r.scale) == null ? void 0 : T.mouseWheelEventVerifier, w = l !== void 0 ? l : () => !0;
3713
+ }), d = (E = r == null ? void 0 : r.shift) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (R) => R.button === 0, u = (N = r == null ? void 0 : r.shift) == null ? void 0 : N.mouseUpEventVerifier, g = u !== void 0 ? u : (R) => R.button === 0, l = (C = r == null ? void 0 : r.scale) == null ? void 0 : C.mouseWheelEventVerifier, w = l !== void 0 ? l : () => !0;
3688
3714
  return {
3689
3715
  wheelSensitivity: t,
3690
- onTransformStarted: ((C = r == null ? void 0 : r.events) == null ? void 0 : C.onTransformStarted) ?? (() => {
3716
+ onTransformStarted: ((T = r == null ? void 0 : r.events) == null ? void 0 : T.onTransformStarted) ?? (() => {
3691
3717
  }),
3692
3718
  onTransformFinished: ((I = r == null ? void 0 : r.events) == null ? void 0 : I.onTransformFinished) ?? (() => {
3693
3719
  }),
@@ -3701,32 +3727,32 @@ const jt = (r) => {
3701
3727
  scaleWheelFinishTimeout: ((F = r == null ? void 0 : r.scale) == null ? void 0 : F.wheelFinishTimeout) ?? 500,
3702
3728
  onResizeTransformStarted: ((U = r == null ? void 0 : r.events) == null ? void 0 : U.onResizeTransformStarted) ?? (() => {
3703
3729
  }),
3704
- onResizeTransformFinished: ((pe = r == null ? void 0 : r.events) == null ? void 0 : pe.onResizeTransformFinished) ?? (() => {
3730
+ onResizeTransformFinished: ((fe = r == null ? void 0 : r.events) == null ? void 0 : fe.onResizeTransformFinished) ?? (() => {
3705
3731
  })
3706
3732
  };
3707
- }, Zt = (r, e) => {
3733
+ }, tr = (r, e) => {
3708
3734
  const t = document.createElementNS(
3709
3735
  "http://www.w3.org/2000/svg",
3710
3736
  "circle"
3711
3737
  );
3712
3738
  return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
3713
- }, _t = (r) => r instanceof SVGElement ? r : Zt(
3739
+ }, rr = (r) => r instanceof SVGElement ? r : tr(
3714
3740
  (r == null ? void 0 : r.radius) ?? 1.5,
3715
3741
  (r == null ? void 0 : r.color) ?? "#d8d8d8"
3716
- ), qt = (r) => {
3717
- const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, o = (e == null ? void 0 : e.height) ?? 25, s = _t(r.renderer ?? {});
3742
+ ), or = (r) => {
3743
+ const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, o = (e == null ? void 0 : e.height) ?? 25, s = rr(r.renderer ?? {});
3718
3744
  return {
3719
3745
  tileWidth: t,
3720
3746
  tileHeight: o,
3721
3747
  renderer: s,
3722
3748
  maxViewportScale: r.maxViewportScale ?? 10
3723
3749
  };
3724
- }, ge = (r) => {
3750
+ }, ye = (r) => {
3725
3751
  if (typeof r == "function")
3726
3752
  return r;
3727
3753
  switch (r.type) {
3728
3754
  case "straight":
3729
- return () => new Dt({
3755
+ return () => new Vt({
3730
3756
  color: r.color,
3731
3757
  width: r.width,
3732
3758
  arrowLength: r.arrowLength,
@@ -3740,7 +3766,7 @@ const jt = (r) => {
3740
3766
  detourDirection: r.detourDirection
3741
3767
  });
3742
3768
  case "horizontal":
3743
- return () => new Mt({
3769
+ return () => new Lt({
3744
3770
  color: r.color,
3745
3771
  width: r.width,
3746
3772
  arrowLength: r.arrowLength,
@@ -3753,7 +3779,7 @@ const jt = (r) => {
3753
3779
  detourDistance: r.detourDistance
3754
3780
  });
3755
3781
  case "vertical":
3756
- return () => new Lt({
3782
+ return () => new It({
3757
3783
  color: r.color,
3758
3784
  width: r.width,
3759
3785
  arrowLength: r.arrowLength,
@@ -3766,7 +3792,7 @@ const jt = (r) => {
3766
3792
  detourDistance: r.detourDistance
3767
3793
  });
3768
3794
  case "direct":
3769
- return () => new Ie({
3795
+ return () => new $e({
3770
3796
  color: r.color,
3771
3797
  width: r.width,
3772
3798
  arrowLength: r.arrowLength,
@@ -3777,7 +3803,7 @@ const jt = (r) => {
3777
3803
  targetOffset: r.targetOffset
3778
3804
  });
3779
3805
  default:
3780
- return () => new Ct({
3806
+ return () => new Rt({
3781
3807
  color: r.color,
3782
3808
  width: r.width,
3783
3809
  arrowLength: r.arrowLength,
@@ -3791,7 +3817,7 @@ const jt = (r) => {
3791
3817
  detourDirection: r.detourDirection
3792
3818
  });
3793
3819
  }
3794
- }, er = (r, e, t) => {
3820
+ }, sr = (r, e, t) => {
3795
3821
  var c, u, g;
3796
3822
  const o = () => "direct", s = (l) => l, n = (l) => l.button === 0, a = () => {
3797
3823
  }, h = () => {
@@ -3806,9 +3832,9 @@ const jt = (r) => {
3806
3832
  onEdgeCreationInterrupted: ((u = r.events) == null ? void 0 : u.onEdgeCreationInterrupted) ?? d,
3807
3833
  onEdgeCreationPrevented: ((g = r.events) == null ? void 0 : g.onEdgeCreationPrevented) ?? h,
3808
3834
  dragPortDirection: r.dragPortDirection ?? t,
3809
- edgeShapeFactory: r.edgeShape !== void 0 ? ge(r.edgeShape) : e
3835
+ edgeShapeFactory: r.edgeShape !== void 0 ? ye(r.edgeShape) : e
3810
3836
  };
3811
- }, tr = (r, e) => {
3837
+ }, ir = (r, e) => {
3812
3838
  var c, u, g;
3813
3839
  const t = (l) => l, o = (l) => l.button === 0 && l.ctrlKey, s = (l) => l.button === 0, n = (l) => {
3814
3840
  const w = e.getPortAdjacentEdgeIds(l);
@@ -3822,15 +3848,15 @@ const jt = (r) => {
3822
3848
  mouseDownEventVerifier: r.mouseDownEventVerifier ?? o,
3823
3849
  mouseUpEventVerifier: r.mouseUpEventVerifier ?? s,
3824
3850
  draggingEdgeResolver: r.draggingEdgeResolver ?? n,
3825
- draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? ge(r.draggingEdgeShape) : null,
3851
+ draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? ye(r.draggingEdgeShape) : null,
3826
3852
  onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
3827
3853
  onEdgeReattachInterrupted: ((u = r.events) == null ? void 0 : u.onEdgeReattachInterrupted) ?? d,
3828
3854
  onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ?? h
3829
3855
  };
3830
- }, rr = (r) => ({
3856
+ }, nr = (r) => ({
3831
3857
  nodeVerticalRadius: r.nodeContainingRadius.vertical,
3832
3858
  nodeHorizontalRadius: r.nodeContainingRadius.horizontal
3833
- }), or = (r) => {
3859
+ }), ar = (r) => {
3834
3860
  var e, t;
3835
3861
  return {
3836
3862
  onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
@@ -3839,13 +3865,13 @@ const jt = (r) => {
3839
3865
  })
3840
3866
  };
3841
3867
  };
3842
- class sr extends Error {
3868
+ class hr extends Error {
3843
3869
  constructor() {
3844
3870
  super(...arguments);
3845
3871
  i(this, "name", "CanvasBuilderError");
3846
3872
  }
3847
3873
  }
3848
- class Ye {
3874
+ class Ge {
3849
3875
  constructor(e, t, o) {
3850
3876
  i(this, "dt");
3851
3877
  i(this, "nodeMass");
@@ -3883,7 +3909,7 @@ class Ye {
3883
3909
  });
3884
3910
  }
3885
3911
  }
3886
- class Xe {
3912
+ class je {
3887
3913
  constructor(e) {
3888
3914
  i(this, "PI2", 2 * Math.PI);
3889
3915
  this.rand = e;
@@ -3902,13 +3928,13 @@ class Xe {
3902
3928
  return { ex: h, ey: d, d: a };
3903
3929
  }
3904
3930
  }
3905
- const He = (r) => {
3931
+ const Je = (r) => {
3906
3932
  if (r.distance === 0)
3907
3933
  return r.maxForce;
3908
3934
  const e = r.coefficient * (r.sourceCharge * r.targetCharge / (r.distance * r.distance));
3909
3935
  return Math.min(e, r.maxForce);
3910
3936
  };
3911
- class ir {
3937
+ class dr {
3912
3938
  constructor(e) {
3913
3939
  i(this, "nodeCharge");
3914
3940
  i(this, "distanceVectorGenerator");
@@ -3923,7 +3949,7 @@ class ir {
3923
3949
  const d = o[h], c = e.get(a), u = e.get(d), g = this.distanceVectorGenerator.create(
3924
3950
  c,
3925
3951
  u
3926
- ), l = He({
3952
+ ), l = Je({
3927
3953
  coefficient: 1,
3928
3954
  sourceCharge: this.nodeCharge,
3929
3955
  targetCharge: this.nodeCharge,
@@ -3935,7 +3961,7 @@ class ir {
3935
3961
  }
3936
3962
  }
3937
3963
  }
3938
- const nr = (r) => {
3964
+ const cr = (r) => {
3939
3965
  if (r.size === 0)
3940
3966
  return {
3941
3967
  centerX: 0,
@@ -3953,7 +3979,7 @@ const nr = (r) => {
3953
3979
  radius: h / 2
3954
3980
  };
3955
3981
  };
3956
- class ar {
3982
+ class lr {
3957
3983
  constructor(e) {
3958
3984
  i(this, "root");
3959
3985
  i(this, "leaves", /* @__PURE__ */ new Map());
@@ -4110,7 +4136,7 @@ class ar {
4110
4136
  }), { x: t / e.size, y: o / e.size };
4111
4137
  }
4112
4138
  }
4113
- class hr {
4139
+ class ur {
4114
4140
  constructor(e) {
4115
4141
  i(this, "areaRadiusThreshold");
4116
4142
  i(this, "nodeMass");
@@ -4122,7 +4148,7 @@ class hr {
4122
4148
  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;
4123
4149
  }
4124
4150
  apply(e, t) {
4125
- const o = nr(e), s = new ar({
4151
+ const o = cr(e), s = new lr({
4126
4152
  box: o,
4127
4153
  coords: e,
4128
4154
  areaRadiusThreshold: this.areaRadiusThreshold,
@@ -4237,7 +4263,7 @@ class hr {
4237
4263
  const t = this.distanceVectorGenerator.create(
4238
4264
  e.sourceCoords,
4239
4265
  e.targetCoords
4240
- ), o = He({
4266
+ ), o = Je({
4241
4267
  coefficient: this.nodeForceCoefficient,
4242
4268
  sourceCharge: e.sourceCharge,
4243
4269
  targetCharge: e.targetCharge,
@@ -4272,7 +4298,7 @@ class hr {
4272
4298
  }
4273
4299
  }
4274
4300
  }
4275
- const Ge = (r) => r.theta !== 0 ? new hr({
4301
+ const Ke = (r) => r.theta !== 0 ? new ur({
4276
4302
  nodeCharge: r.nodeCharge,
4277
4303
  nodeForceCoefficient: r.nodeForceCoefficient,
4278
4304
  distanceVectorGenerator: r.distanceVectorGenerator,
@@ -4280,13 +4306,13 @@ const Ge = (r) => r.theta !== 0 ? new hr({
4280
4306
  theta: r.theta,
4281
4307
  nodeMass: r.nodeMass,
4282
4308
  areaRadiusThreshold: r.areaRadiusThreshold
4283
- }) : new ir({
4309
+ }) : new dr({
4284
4310
  nodeCharge: r.nodeCharge,
4285
4311
  nodeForceCoefficient: r.nodeForceCoefficient,
4286
4312
  distanceVectorGenerator: r.distanceVectorGenerator,
4287
4313
  maxForce: r.maxForce
4288
4314
  });
4289
- class je {
4315
+ class Qe {
4290
4316
  constructor(e) {
4291
4317
  i(this, "rand");
4292
4318
  i(this, "sparsity");
@@ -4309,7 +4335,7 @@ class je {
4309
4335
  }), s;
4310
4336
  }
4311
4337
  }
4312
- class dr {
4338
+ class gr {
4313
4339
  constructor(e) {
4314
4340
  i(this, "distanceVectorGenerator");
4315
4341
  i(this, "nodeForcesApplicationStrategy");
@@ -4320,7 +4346,7 @@ class dr {
4320
4346
  i(this, "edgeEquilibriumLength");
4321
4347
  i(this, "edgeStiffness");
4322
4348
  i(this, "convergenceVelocity");
4323
- 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 Xe(e.rand), this.nodeForcesApplicationStrategy = Ge({
4349
+ 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 je(e.rand), this.nodeForcesApplicationStrategy = Ke({
4324
4350
  distanceVectorGenerator: this.distanceVectorGenerator,
4325
4351
  nodeCharge: e.nodeCharge,
4326
4352
  maxForce: e.maxForce,
@@ -4328,7 +4354,7 @@ class dr {
4328
4354
  theta: e.barnesHutTheta,
4329
4355
  areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
4330
4356
  nodeMass: e.nodeMass
4331
- }), this.fillerLayoutAlgorithm = new je({
4357
+ }), this.fillerLayoutAlgorithm = new Qe({
4332
4358
  rand: e.rand,
4333
4359
  sparsity: e.edgeEquilibriumLength
4334
4360
  });
@@ -4338,7 +4364,7 @@ class dr {
4338
4364
  graph: t,
4339
4365
  viewport: o
4340
4366
  });
4341
- for (let n = 0; n < this.maxIterations && !(new Ye(
4367
+ for (let n = 0; n < this.maxIterations && !(new Ge(
4342
4368
  t,
4343
4369
  s,
4344
4370
  {
@@ -4354,7 +4380,7 @@ class dr {
4354
4380
  return s;
4355
4381
  }
4356
4382
  }
4357
- class cr {
4383
+ class pr {
4358
4384
  constructor(e, t) {
4359
4385
  i(this, "forest", /* @__PURE__ */ new Set());
4360
4386
  i(this, "remainingNodeIds");
@@ -4395,7 +4421,7 @@ class cr {
4395
4421
  }
4396
4422
  }
4397
4423
  }
4398
- class lr {
4424
+ class wr {
4399
4425
  constructor(e) {
4400
4426
  this.params = e;
4401
4427
  }
@@ -4436,12 +4462,12 @@ class lr {
4436
4462
  return o - 2 * this.params.spaceAroundRadius;
4437
4463
  }
4438
4464
  }
4439
- class ur {
4465
+ class yr {
4440
4466
  constructor(e, t) {
4441
4467
  i(this, "offsets", /* @__PURE__ */ new Map());
4442
4468
  i(this, "treeSpans", /* @__PURE__ */ new Map());
4443
4469
  this.tree = e;
4444
- const o = t.spaceAroundRadius, s = new lr({
4470
+ const o = t.spaceAroundRadius, s = new wr({
4445
4471
  spaceAroundRadius: o
4446
4472
  });
4447
4473
  [...this.tree.sequence].reverse().forEach((n) => {
@@ -4463,19 +4489,19 @@ class ur {
4463
4489
  return this.offsets;
4464
4490
  }
4465
4491
  }
4466
- class gr {
4492
+ class fr {
4467
4493
  constructor(e) {
4468
4494
  this.params = e;
4469
4495
  }
4470
4496
  calculateCoordinates(e) {
4471
- const t = /* @__PURE__ */ new Map(), s = new cr(
4497
+ const t = /* @__PURE__ */ new Map(), s = new pr(
4472
4498
  e.graph,
4473
4499
  this.params.nextLayerNodesResolver
4474
4500
  ).generate();
4475
4501
  let n = 0;
4476
4502
  return s.forEach((a) => {
4477
4503
  t.set(a.root.nodeId, { x: n, y: 0 });
4478
- const d = new ur(a, {
4504
+ const d = new yr(a, {
4479
4505
  spaceAroundRadius: this.params.layerSpace / 2
4480
4506
  }).generate();
4481
4507
  let c = [a.root];
@@ -4496,7 +4522,7 @@ class gr {
4496
4522
  }), t;
4497
4523
  }
4498
4524
  }
4499
- const pr = (r) => {
4525
+ const vr = (r) => {
4500
4526
  const { graph: e, currentNodeId: t } = r, o = e.getNodeOutgoingEdgeIds(t).map((n) => {
4501
4527
  const a = e.getEdge(n);
4502
4528
  return e.getPort(a.to).nodeId;
@@ -4505,20 +4531,20 @@ const pr = (r) => {
4505
4531
  return e.getPort(a.from).nodeId;
4506
4532
  });
4507
4533
  return /* @__PURE__ */ new Set([...o, ...s]);
4508
- }, wr = (r) => {
4534
+ }, mr = (r) => {
4509
4535
  const { graph: e, currentNodeId: t } = r, o = e.getNodeOutgoingEdgeIds(t).map((s) => {
4510
4536
  const n = e.getEdge(s);
4511
4537
  return e.getPort(n.to).nodeId;
4512
4538
  });
4513
4539
  return new Set(o);
4514
- }, yr = (r) => {
4540
+ }, xr = (r) => {
4515
4541
  const { graph: e, currentNodeId: t } = r, o = e.getNodeIncomingEdgeIds(t).map((s) => {
4516
4542
  const n = e.getEdge(s);
4517
4543
  return e.getPort(n.from).nodeId;
4518
4544
  });
4519
4545
  return new Set(o);
4520
4546
  };
4521
- class fr {
4547
+ class Er {
4522
4548
  constructor(e) {
4523
4549
  i(this, "distanceVectorGenerator");
4524
4550
  i(this, "nodeForcesApplicationStrategy");
@@ -4528,7 +4554,7 @@ class fr {
4528
4554
  i(this, "edgeEquilibriumLength");
4529
4555
  i(this, "edgeStiffness");
4530
4556
  i(this, "fillerLayoutAlgorithm");
4531
- this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new Xe(e.rand), this.nodeForcesApplicationStrategy = Ge({
4557
+ this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new je(e.rand), this.nodeForcesApplicationStrategy = Ke({
4532
4558
  distanceVectorGenerator: this.distanceVectorGenerator,
4533
4559
  nodeCharge: e.nodeCharge,
4534
4560
  maxForce: e.maxForce,
@@ -4536,7 +4562,7 @@ class fr {
4536
4562
  theta: e.barnesHutTheta,
4537
4563
  areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
4538
4564
  nodeMass: e.nodeMass
4539
- }), this.fillerLayoutAlgorithm = new je({
4565
+ }), this.fillerLayoutAlgorithm = new Qe({
4540
4566
  rand: e.rand,
4541
4567
  sparsity: e.edgeEquilibriumLength
4542
4568
  });
@@ -4546,7 +4572,7 @@ class fr {
4546
4572
  graph: t,
4547
4573
  viewport: o
4548
4574
  });
4549
- return new Ye(
4575
+ return new Ge(
4550
4576
  t,
4551
4577
  n,
4552
4578
  {
@@ -4563,16 +4589,16 @@ class fr {
4563
4589
  }) ? /* @__PURE__ */ new Map() : n;
4564
4590
  }
4565
4591
  }
4566
- const Je = (r) => {
4592
+ const Ze = (r) => {
4567
4593
  let e = 1779033703, t = 3144134277, o = 1013904242, s = 2773480762;
4568
4594
  for (let n = 0, a; n < r.length; n++)
4569
4595
  a = r.charCodeAt(n), e = t ^ Math.imul(e ^ a, 597399067), t = o ^ Math.imul(t ^ a, 2869860233), o = s ^ Math.imul(o ^ a, 951274213), s = e ^ Math.imul(s ^ a, 2716044179);
4570
4596
  return e = Math.imul(o ^ e >>> 18, 597399067), t = Math.imul(s ^ t >>> 22, 2869860233), o = Math.imul(e ^ o >>> 17, 951274213), s = Math.imul(t ^ s >>> 19, 2716044179), e ^= t ^ o ^ s, t ^= e, o ^= e, s ^= e, [e >>> 0, t >>> 0, o >>> 0, s >>> 0];
4571
- }, Ke = (r, e, t, o) => function() {
4597
+ }, _e = (r, e, t, o) => function() {
4572
4598
  r |= 0, e |= 0, t |= 0, o |= 0;
4573
4599
  const s = (r + e | 0) + o | 0;
4574
4600
  return o = o + 1 | 0, r = e ^ e >>> 9, e = t + (t << 3) | 0, t = t << 21 | t >>> 11, t = t + s | 0, (s >>> 0) / 4294967296;
4575
- }, A = Object.freeze({
4601
+ }, b = Object.freeze({
4576
4602
  seed: "HTMLGraph is awesome",
4577
4603
  maxTimeDeltaSec: 0.01,
4578
4604
  nodeCharge: 1e5,
@@ -4586,29 +4612,29 @@ const Je = (r) => {
4586
4612
  nodeForceCoefficient: 1,
4587
4613
  barnesHutAreaRadiusThreshold: 0.01,
4588
4614
  barnesHutTheta: 1
4589
- }), V = Object.freeze({
4615
+ }), D = Object.freeze({
4590
4616
  mouseDownEventVerifier: (r) => r.button === 0,
4591
4617
  mouseUpEventVerifier: (r) => r.button === 0,
4592
4618
  movementThreshold: 10
4593
- }), vr = (r) => {
4619
+ }), Ar = (r) => {
4594
4620
  var e, t;
4595
4621
  switch (r == null ? void 0 : r.type) {
4596
4622
  case "custom":
4597
4623
  return r.instance;
4598
4624
  default: {
4599
- const o = Je((r == null ? void 0 : r.seed) ?? A.seed), s = Ke(o[0], o[1], o[2], o[3]);
4600
- return new fr({
4625
+ const o = Ze((r == null ? void 0 : r.seed) ?? b.seed), s = _e(o[0], o[1], o[2], o[3]);
4626
+ return new Er({
4601
4627
  rand: s,
4602
- maxTimeDeltaSec: (r == null ? void 0 : r.maxTimeDeltaSec) ?? A.maxTimeDeltaSec,
4603
- nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? A.nodeCharge,
4604
- nodeMass: (r == null ? void 0 : r.nodeMass) ?? A.nodeMass,
4605
- edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? A.edgeEquilibriumLength,
4606
- edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? A.edgeStiffness,
4607
- convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? A.convergenceVelocity,
4608
- maxForce: (r == null ? void 0 : r.maxForce) ?? A.maxForce,
4609
- nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? A.nodeForceCoefficient,
4610
- barnesHutTheta: ((e = r == null ? void 0 : r.barnesHut) == null ? void 0 : e.theta) ?? A.barnesHutTheta,
4611
- barnesHutAreaRadiusThreshold: ((t = r == null ? void 0 : r.barnesHut) == null ? void 0 : t.areaRadiusThreshold) ?? A.barnesHutAreaRadiusThreshold
4628
+ maxTimeDeltaSec: (r == null ? void 0 : r.maxTimeDeltaSec) ?? b.maxTimeDeltaSec,
4629
+ nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? b.nodeCharge,
4630
+ nodeMass: (r == null ? void 0 : r.nodeMass) ?? b.nodeMass,
4631
+ edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? b.edgeEquilibriumLength,
4632
+ edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? b.edgeStiffness,
4633
+ convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? b.convergenceVelocity,
4634
+ maxForce: (r == null ? void 0 : r.maxForce) ?? b.maxForce,
4635
+ nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? b.nodeForceCoefficient,
4636
+ barnesHutTheta: ((e = r == null ? void 0 : r.barnesHut) == null ? void 0 : e.theta) ?? b.barnesHutTheta,
4637
+ barnesHutAreaRadiusThreshold: ((t = r == null ? void 0 : r.barnesHut) == null ? void 0 : t.areaRadiusThreshold) ?? b.barnesHutAreaRadiusThreshold
4612
4638
  });
4613
4639
  }
4614
4640
  }
@@ -4618,23 +4644,23 @@ const Je = (r) => {
4618
4644
  },
4619
4645
  onAfterApplied: () => {
4620
4646
  }
4621
- }, mr = (r) => {
4647
+ }, Sr = (r) => {
4622
4648
  var t, o;
4623
4649
  return {
4624
- algorithm: vr((r == null ? void 0 : r.algorithm) ?? {}),
4650
+ algorithm: Ar((r == null ? void 0 : r.algorithm) ?? {}),
4625
4651
  staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? K.staticNodeResolver,
4626
4652
  onBeforeApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeApplied) ?? K.onBeforeApplied,
4627
4653
  onAfterApplied: ((o = r == null ? void 0 : r.events) == null ? void 0 : o.onAfterApplied) ?? K.onAfterApplied
4628
4654
  };
4629
- }, xr = (r) => r instanceof _ ? {
4655
+ }, br = (r) => r instanceof _ ? {
4630
4656
  type: "trigger",
4631
4657
  trigger: r
4632
4658
  } : (r == null ? void 0 : r.type) === "topologyChangeMacrotask" ? {
4633
4659
  type: "topologyChangeSchedule",
4634
- schedule: Ft
4660
+ schedule: Bt
4635
4661
  } : {
4636
4662
  type: "topologyChangeSchedule",
4637
- schedule: Ut
4663
+ schedule: Ot
4638
4664
  }, $ = Object.freeze({
4639
4665
  staticNodeResolver: () => !1,
4640
4666
  onBeforeApplied: () => {
@@ -4652,7 +4678,7 @@ const Je = (r) => {
4652
4678
  d: r.d * e.a + r.e * e.d,
4653
4679
  e: r.d * e.b + r.e * e.e,
4654
4680
  f: r.d * e.c + r.e * e.f + r.f
4655
- }), Er = (r) => {
4681
+ }), Nr = (r) => {
4656
4682
  const { a: e, b: t, c: o, d: s, e: n, f: a } = r, h = e * n - t * s;
4657
4683
  return {
4658
4684
  a: n / h,
@@ -4663,7 +4689,7 @@ const Je = (r) => {
4663
4689
  f: (o * s - e * a) / h
4664
4690
  };
4665
4691
  };
4666
- class Ar {
4692
+ class Pr {
4667
4693
  resolve(e) {
4668
4694
  if ("shift" in e)
4669
4695
  return this.createShiftBaseMatrix(e.shift);
@@ -4707,7 +4733,7 @@ class Ar {
4707
4733
  const o = z(
4708
4734
  t,
4709
4735
  e
4710
- ), s = Er(t);
4736
+ ), s = Nr(t);
4711
4737
  return z(o, s);
4712
4738
  }
4713
4739
  createShiftBaseMatrix(e) {
@@ -4752,7 +4778,7 @@ class Ar {
4752
4778
  };
4753
4779
  }
4754
4780
  }
4755
- const Sr = (r) => {
4781
+ const Cr = (r) => {
4756
4782
  if (r === void 0)
4757
4783
  return (s) => s;
4758
4784
  if (typeof r == "function")
@@ -4766,7 +4792,7 @@ const Sr = (r) => {
4766
4792
  e: 1,
4767
4793
  f: 0
4768
4794
  };
4769
- const o = new Ar();
4795
+ const o = new Pr();
4770
4796
  return e.forEach((s) => {
4771
4797
  const n = o.resolve(s);
4772
4798
  t = z(t, n);
@@ -4777,59 +4803,59 @@ const Sr = (r) => {
4777
4803
  y: t.d * n + t.e * a + t.f
4778
4804
  };
4779
4805
  };
4780
- }, Nr = (r) => {
4806
+ }, Tr = (r) => {
4781
4807
  if (typeof r == "function")
4782
4808
  return r;
4783
4809
  switch (r) {
4784
4810
  case "outgoing":
4785
- return wr;
4811
+ return mr;
4786
4812
  case "incoming":
4787
- return yr;
4813
+ return xr;
4788
4814
  default:
4789
- return pr;
4815
+ return vr;
4790
4816
  }
4791
- }, br = (r) => {
4817
+ }, Mr = (r) => {
4792
4818
  var e, t;
4793
4819
  switch (r == null ? void 0 : r.type) {
4794
4820
  case "custom":
4795
4821
  return r.instance;
4796
4822
  case "hierarchical":
4797
- return new gr({
4823
+ return new fr({
4798
4824
  layerWidth: r.layerWidth ?? $.hierarchicalLayout.layerWidth,
4799
4825
  layerSpace: r.layerSpace ?? $.hierarchicalLayout.layerSpace,
4800
- transform: Sr(r.transform),
4801
- nextLayerNodesResolver: Nr(
4826
+ transform: Cr(r.transform),
4827
+ nextLayerNodesResolver: Tr(
4802
4828
  r.nextLayerNodesResolver
4803
4829
  )
4804
4830
  });
4805
4831
  default: {
4806
- const o = Je((r == null ? void 0 : r.seed) ?? A.seed), s = Ke(o[0], o[1], o[2], o[3]);
4807
- return new dr({
4808
- dtSec: (r == null ? void 0 : r.dtSec) ?? A.dtSec,
4809
- maxIterations: (r == null ? void 0 : r.maxIterations) ?? A.maxIterations,
4832
+ const o = Ze((r == null ? void 0 : r.seed) ?? b.seed), s = _e(o[0], o[1], o[2], o[3]);
4833
+ return new gr({
4834
+ dtSec: (r == null ? void 0 : r.dtSec) ?? b.dtSec,
4835
+ maxIterations: (r == null ? void 0 : r.maxIterations) ?? b.maxIterations,
4810
4836
  rand: s,
4811
- nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? A.nodeCharge,
4812
- nodeMass: (r == null ? void 0 : r.nodeMass) ?? A.nodeMass,
4813
- edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? A.edgeEquilibriumLength,
4814
- edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? A.edgeStiffness,
4815
- convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? A.convergenceVelocity,
4816
- maxForce: (r == null ? void 0 : r.maxForce) ?? A.maxForce,
4817
- nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? A.nodeForceCoefficient,
4818
- barnesHutTheta: ((e = r == null ? void 0 : r.barnesHut) == null ? void 0 : e.theta) ?? A.barnesHutTheta,
4819
- barnesHutAreaRadiusThreshold: ((t = r == null ? void 0 : r.barnesHut) == null ? void 0 : t.areaRadiusThreshold) ?? A.barnesHutAreaRadiusThreshold
4837
+ nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? b.nodeCharge,
4838
+ nodeMass: (r == null ? void 0 : r.nodeMass) ?? b.nodeMass,
4839
+ edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? b.edgeEquilibriumLength,
4840
+ edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? b.edgeStiffness,
4841
+ convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? b.convergenceVelocity,
4842
+ maxForce: (r == null ? void 0 : r.maxForce) ?? b.maxForce,
4843
+ nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? b.nodeForceCoefficient,
4844
+ barnesHutTheta: ((e = r == null ? void 0 : r.barnesHut) == null ? void 0 : e.theta) ?? b.barnesHutTheta,
4845
+ barnesHutAreaRadiusThreshold: ((t = r == null ? void 0 : r.barnesHut) == null ? void 0 : t.areaRadiusThreshold) ?? b.barnesHutAreaRadiusThreshold
4820
4846
  });
4821
4847
  }
4822
4848
  }
4823
- }, Pr = (r) => {
4849
+ }, Dr = (r) => {
4824
4850
  var e, t;
4825
4851
  return {
4826
- algorithm: br(r.algorithm),
4827
- applyOn: xr(r.applyOn),
4852
+ algorithm: Mr(r.algorithm),
4853
+ applyOn: br(r.applyOn),
4828
4854
  staticNodeResolver: r.staticNodeResolver ?? $.staticNodeResolver,
4829
4855
  onBeforeApplied: ((e = r.events) == null ? void 0 : e.onBeforeApplied) ?? $.onBeforeApplied,
4830
4856
  onAfterApplied: ((t = r.events) == null ? void 0 : t.onAfterApplied) ?? $.onAfterApplied
4831
4857
  };
4832
- }, Tr = (r, e) => ({
4858
+ }, Rr = (r, e) => ({
4833
4859
  ...r,
4834
4860
  onNodeDragStarted: (t) => {
4835
4861
  e.add(t), r.onNodeDragStarted(t);
@@ -4837,7 +4863,7 @@ const Sr = (r) => {
4837
4863
  onNodeDragFinished: (t) => {
4838
4864
  e.delete(t), r.onNodeDragFinished(t);
4839
4865
  }
4840
- }), Cr = (r, e) => {
4866
+ }), Lr = (r, e) => {
4841
4867
  r.graph.onBeforeNodeRemoved.subscribe((t) => {
4842
4868
  e.delete(t);
4843
4869
  }), r.graph.onBeforeClear.subscribe(() => {
@@ -4845,41 +4871,41 @@ const Sr = (r) => {
4845
4871
  }), r.onBeforeDestroy.subscribe(() => {
4846
4872
  e.clear();
4847
4873
  });
4848
- }, Mr = (r, e) => ({
4874
+ }, Vr = (r, e) => ({
4849
4875
  ...r,
4850
4876
  staticNodeResolver: (t) => r.staticNodeResolver(t) || e.has(t)
4851
- }), Z = (r) => () => r, Se = Z(0), Dr = () => {
4877
+ }), Z = (r) => () => r, Pe = Z(0), Ir = () => {
4852
4878
  let r = 0;
4853
4879
  return () => r++;
4854
- }, Lr = (r, e) => {
4855
- let t = Se, o = Se;
4856
- const s = Dr();
4880
+ }, Fr = (r, e) => {
4881
+ let t = Pe, o = Pe;
4882
+ const s = Ir();
4857
4883
  return r === "incremental" && (t = s), e === "incremental" && (o = s), typeof r == "number" && (t = Z(r)), typeof e == "number" && (o = Z(e)), typeof r == "function" && (t = r), typeof e == "function" && (o = e), {
4858
4884
  nodesPriorityFn: t,
4859
4885
  edgesPriorityFn: o
4860
4886
  };
4861
- }, Rr = (r) => {
4887
+ }, Ur = (r) => {
4862
4888
  var t, o, s, n, a;
4863
- const e = Lr(
4889
+ const e = Fr(
4864
4890
  (t = r.nodes) == null ? void 0 : t.priority,
4865
4891
  (o = r.edges) == null ? void 0 : o.priority
4866
4892
  );
4867
4893
  return {
4868
4894
  nodes: {
4869
- centerFn: ((s = r.nodes) == null ? void 0 : s.centerFn) ?? Me,
4895
+ centerFn: ((s = r.nodes) == null ? void 0 : s.centerFn) ?? Le,
4870
4896
  priorityFn: e.nodesPriorityFn
4871
4897
  },
4872
4898
  ports: {
4873
4899
  direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
4874
4900
  },
4875
4901
  edges: {
4876
- shapeFactory: ge(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
4902
+ shapeFactory: ye(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
4877
4903
  priorityFn: e.edgesPriorityFn
4878
4904
  }
4879
4905
  };
4880
- }, Vr = (r) => r.applyOn.type === "topologyChangeSchedule" ? r.applyOn.schedule : re, Ir = (r) => {
4906
+ }, $r = (r) => r.applyOn.type === "topologyChangeSchedule" ? r.applyOn.schedule : re, Br = (r) => {
4881
4907
  var o, s, n, a;
4882
- const { canvasDefaults: e } = r, t = r.hasLayout ? Vr(r.layoutParams) : re;
4908
+ const { canvasDefaults: e } = r, t = r.hasLayout ? $r(r.layoutParams) : re;
4883
4909
  return {
4884
4910
  focus: {
4885
4911
  contentPadding: ((o = e.focus) == null ? void 0 : o.contentPadding) ?? ((s = e.focus) == null ? void 0 : s.contentOffset) ?? 100,
@@ -4888,18 +4914,23 @@ const Sr = (r) => {
4888
4914
  animationDuration: ((a = e.focus) == null ? void 0 : a.animationDuration) ?? 0
4889
4915
  }
4890
4916
  };
4891
- }, Fr = (r) => ({
4917
+ }, Or = (r) => ({
4892
4918
  onNodeSelected: r.onNodeSelected,
4893
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? V.mouseDownEventVerifier,
4894
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? V.mouseUpEventVerifier,
4895
- movementThreshold: r.movementThreshold ?? V.movementThreshold
4896
- }), Ur = (r) => ({
4919
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? D.mouseDownEventVerifier,
4920
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? D.mouseUpEventVerifier,
4921
+ movementThreshold: r.movementThreshold ?? D.movementThreshold
4922
+ }), Wr = (r) => ({
4897
4923
  onCanvasSelected: r.onCanvasSelected,
4898
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? V.mouseDownEventVerifier,
4899
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? V.mouseUpEventVerifier,
4900
- movementThreshold: r.movementThreshold ?? V.movementThreshold
4924
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? D.mouseDownEventVerifier,
4925
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? D.mouseUpEventVerifier,
4926
+ movementThreshold: r.movementThreshold ?? D.movementThreshold
4927
+ }), zr = (r) => ({
4928
+ onEdgeSelected: r.onEdgeSelected,
4929
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? D.mouseDownEventVerifier,
4930
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? D.mouseUpEventVerifier,
4931
+ movementThreshold: r.movementThreshold ?? D.movementThreshold
4901
4932
  });
4902
- class Wr {
4933
+ class Yr {
4903
4934
  constructor(e) {
4904
4935
  i(this, "used", !1);
4905
4936
  i(this, "canvasDefaults", {});
@@ -4912,6 +4943,7 @@ class Wr {
4912
4943
  i(this, "layoutConfig", {});
4913
4944
  i(this, "animatedLayoutConfig", {});
4914
4945
  i(this, "userSelectableNodesConfig");
4946
+ i(this, "userSelectableEdgesConfig");
4915
4947
  i(this, "userSelectableCanvasConfig");
4916
4948
  i(this, "hasDraggableNodes", !1);
4917
4949
  i(this, "hasTransformableViewport", !1);
@@ -4925,7 +4957,8 @@ class Wr {
4925
4957
  i(this, "window", window);
4926
4958
  i(this, "animationStaticNodes", /* @__PURE__ */ new Set());
4927
4959
  i(this, "pointInsideVerifier");
4928
- this.element = e, this.pointInsideVerifier = new dt(e, this.window);
4960
+ i(this, "eventTagger", new Ht());
4961
+ this.element = e, this.pointInsideVerifier = new ut(e, this.window);
4929
4962
  }
4930
4963
  setDefaults(e) {
4931
4964
  return this.canvasDefaults = e, this;
@@ -4960,73 +4993,90 @@ class Wr {
4960
4993
  enableUserSelectableNodes(e) {
4961
4994
  return this.userSelectableNodesConfig = e, this;
4962
4995
  }
4996
+ enableUserSelectableEdges(e) {
4997
+ return this.userSelectableEdgesConfig = e, this;
4998
+ }
4963
4999
  enableUserSelectableCanvas(e) {
4964
5000
  return this.userSelectableCanvasConfig = e, this;
4965
5001
  }
4966
5002
  build() {
4967
5003
  if (this.used)
4968
- throw new sr(
5004
+ throw new hr(
4969
5005
  "Failed to build Canvas because CanvasBuilder is a single-use object"
4970
5006
  );
4971
5007
  this.used = !0;
4972
- const e = new nt(this.element), t = new Pe(), o = new Gt(this.element), s = this.createHtmlView(
5008
+ const e = new dt(this.element), t = new Me(), o = new Qt(this.element), s = this.createHtmlView(
4973
5009
  o.main,
4974
5010
  t,
4975
5011
  e
4976
- ), n = Rr(
5012
+ ), n = Ur(
4977
5013
  this.canvasDefaults
4978
- ), a = new $e(
5014
+ ), a = new We(
4979
5015
  t,
4980
5016
  s,
4981
5017
  n
4982
- ), h = Pr(this.layoutConfig), d = Ir({
5018
+ ), h = Dr(this.layoutConfig), d = Br({
4983
5019
  canvasDefaults: this.canvasDefaults,
4984
5020
  hasLayout: this.hasLayout,
4985
5021
  layoutParams: h
4986
- }), c = new ze(
5022
+ }), c = new Ye(
4987
5023
  t,
4988
5024
  e,
4989
5025
  d,
4990
5026
  this.window
4991
- ), u = new Be(e), g = new Ue(t), l = new be(
5027
+ ), u = new ze(e), g = new Oe(t), l = new Te(
4992
5028
  g,
4993
5029
  u,
4994
5030
  a,
4995
5031
  c
4996
5032
  );
4997
- if (this.hasBackground && ie.configure(
5033
+ if (this.hasBackground && ae.configure(
4998
5034
  l,
4999
- qt(this.backgroundConfig),
5035
+ or(this.backgroundConfig),
5000
5036
  o.background
5001
- ), this.hasNodeResizeReactiveEdges && q.configure(l), this.userSelectableNodesConfig !== void 0) {
5002
- const p = Fr(
5037
+ ), this.hasNodeResizeReactiveEdges && q.configure(l), this.userSelectableEdgesConfig !== void 0) {
5038
+ const p = zr(
5039
+ this.userSelectableEdgesConfig
5040
+ );
5041
+ pe.configure(
5042
+ l,
5043
+ this.window,
5044
+ this.pointInsideVerifier,
5045
+ this.eventTagger,
5046
+ p
5047
+ );
5048
+ }
5049
+ if (this.userSelectableNodesConfig !== void 0) {
5050
+ const p = Or(
5003
5051
  this.userSelectableNodesConfig
5004
5052
  );
5005
- le.configure(
5053
+ ge.configure(
5006
5054
  l,
5007
5055
  this.window,
5008
5056
  this.pointInsideVerifier,
5057
+ this.eventTagger,
5009
5058
  p
5010
5059
  );
5011
5060
  }
5012
5061
  if (this.userSelectableCanvasConfig !== void 0) {
5013
- const p = Ur(
5062
+ const p = Wr(
5014
5063
  this.userSelectableCanvasConfig
5015
5064
  );
5016
- ue.configure(
5065
+ we.configure(
5017
5066
  l,
5018
5067
  o.main,
5019
5068
  this.window,
5020
5069
  this.pointInsideVerifier,
5070
+ this.eventTagger,
5021
5071
  p
5022
5072
  );
5023
5073
  }
5024
5074
  if (this.hasDraggableNodes) {
5025
- let p = jt(this.dragConfig);
5026
- this.hasAnimatedLayout && (p = Tr(
5075
+ let p = Zt(this.dragConfig);
5076
+ this.hasAnimatedLayout && (p = Rr(
5027
5077
  p,
5028
5078
  this.animationStaticNodes
5029
- )), oe.configure(
5079
+ )), ie.configure(
5030
5080
  l,
5031
5081
  o.main,
5032
5082
  this.window,
@@ -5035,12 +5085,12 @@ class Wr {
5035
5085
  );
5036
5086
  }
5037
5087
  if (this.hasUserConnectablePorts) {
5038
- const p = er(
5088
+ const p = sr(
5039
5089
  this.connectablePortsConfig,
5040
5090
  n.edges.shapeFactory,
5041
5091
  n.ports.direction
5042
5092
  );
5043
- ne.configure(
5093
+ he.configure(
5044
5094
  l,
5045
5095
  o.overlayConnectablePorts,
5046
5096
  e,
@@ -5050,11 +5100,11 @@ class Wr {
5050
5100
  );
5051
5101
  }
5052
5102
  if (this.hasUserDraggableEdges) {
5053
- const p = tr(
5103
+ const p = ir(
5054
5104
  this.draggableEdgesConfig,
5055
5105
  l.graph
5056
5106
  );
5057
- ae.configure(
5107
+ de.configure(
5058
5108
  l,
5059
5109
  o.overlayDraggableEdges,
5060
5110
  e,
@@ -5063,31 +5113,31 @@ class Wr {
5063
5113
  p
5064
5114
  );
5065
5115
  }
5066
- if (this.virtualScrollConfig !== void 0 ? se.configure(
5116
+ if (this.virtualScrollConfig !== void 0 ? ne.configure(
5067
5117
  l,
5068
5118
  o.main,
5069
5119
  this.window,
5070
- Ae(this.transformConfig),
5120
+ Ne(this.transformConfig),
5071
5121
  this.boxRenderingTrigger,
5072
5122
  this.pointInsideVerifier,
5073
- rr(this.virtualScrollConfig)
5123
+ nr(this.virtualScrollConfig)
5074
5124
  ) : this.hasTransformableViewport && j.configure(
5075
5125
  l,
5076
5126
  o.main,
5077
5127
  this.window,
5078
5128
  this.pointInsideVerifier,
5079
- Ae(this.transformConfig)
5080
- ), this.hasLayout && Yt.configure(l, h), this.hasAnimatedLayout) {
5081
- let p = mr(
5129
+ Ne(this.transformConfig)
5130
+ ), this.hasLayout && jt.configure(l, h), this.hasAnimatedLayout) {
5131
+ let p = Sr(
5082
5132
  this.animatedLayoutConfig
5083
5133
  );
5084
- this.hasDraggableNodes && (Cr(
5134
+ this.hasDraggableNodes && (Lr(
5085
5135
  l,
5086
5136
  this.animationStaticNodes
5087
- ), p = Mr(
5137
+ ), p = Vr(
5088
5138
  p,
5089
5139
  this.animationStaticNodes
5090
- )), ce.configure(l, p, this.window);
5140
+ )), ue.configure(l, p, this.window);
5091
5141
  }
5092
5142
  const w = () => {
5093
5143
  o.destroy(), l.onBeforeDestroy.unsubscribe(w);
@@ -5095,27 +5145,27 @@ class Wr {
5095
5145
  return l.onBeforeDestroy.subscribe(w), l;
5096
5146
  }
5097
5147
  createHtmlView(e, t, o) {
5098
- let s = new Ne(t, o, e);
5099
- return this.virtualScrollConfig !== void 0 && (s = new ot(
5148
+ let s = new Ce(t, o, e);
5149
+ return this.virtualScrollConfig !== void 0 && (s = new nt(
5100
5150
  s,
5101
5151
  t,
5102
5152
  this.boxRenderingTrigger,
5103
- or(this.virtualScrollConfig)
5104
- )), s = new st(s, t), s;
5153
+ ar(this.virtualScrollConfig)
5154
+ )), s = new at(s, t), s;
5105
5155
  }
5106
5156
  }
5107
5157
  export {
5108
- Ct as BezierEdgeShape,
5109
- Wr as CanvasBuilder,
5110
- sr as CanvasBuilderError,
5111
- S as CanvasError,
5112
- R as ConnectionCategory,
5113
- Ie as DirectEdgeShape,
5158
+ Rt as BezierEdgeShape,
5159
+ Yr as CanvasBuilder,
5160
+ hr as CanvasBuilderError,
5161
+ A as CanvasError,
5162
+ V as ConnectionCategory,
5163
+ $e as DirectEdgeShape,
5114
5164
  _ as EventSubject,
5115
- Mt as HorizontalEdgeShape,
5116
- It as InteractiveEdgeError,
5117
- Fe as InteractiveEdgeShape,
5118
- Br as MidpointEdgeShape,
5119
- Dt as StraightEdgeShape,
5120
- Lt as VerticalEdgeShape
5165
+ Lt as HorizontalEdgeShape,
5166
+ $t as InteractiveEdgeError,
5167
+ Be as InteractiveEdgeShape,
5168
+ Hr as MidpointEdgeShape,
5169
+ Vt as StraightEdgeShape,
5170
+ It as VerticalEdgeShape
5121
5171
  };