@html-graph/html-graph 8.15.1 → 8.17.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 I = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(I || {});
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 Te {
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 = I.Line;
76
+ o.element === s.element ? g = I.PortCycle : o.nodeId === s.nodeId && (g = I.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());
@@ -245,7 +245,7 @@ class st {
245
245
  this.isEdgeValid(e) && (this.deferredEdges.delete(e), this.htmlView.attachEdge(e));
246
246
  }
247
247
  }
248
- class _ {
248
+ class q {
249
249
  constructor() {
250
250
  i(this, "callbacks", /* @__PURE__ */ new Set());
251
251
  }
@@ -262,10 +262,10 @@ class _ {
262
262
  }
263
263
  }
264
264
  const P = () => {
265
- const r = new _();
265
+ const r = new q();
266
266
  return [r, r];
267
267
  };
268
- class be {
268
+ class Ce {
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,30 +720,30 @@ 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();
734
744
  }
735
745
  }
736
- class q {
746
+ class ee {
737
747
  constructor(e) {
738
748
  i(this, "elementToNodeId", /* @__PURE__ */ new Map());
739
749
  i(this, "nodesResizeObserver");
@@ -759,26 +769,26 @@ class q {
759
769
  }), 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);
760
770
  }
761
771
  static configure(e) {
762
- new q(e);
772
+ new ee(e);
763
773
  }
764
774
  handleNodeResize(e) {
765
775
  const t = this.elementToNodeId.get(e);
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
- const k = (r, e) => {
791
+ const H = (r, e) => {
782
792
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
783
793
  }, Y = (r) => {
784
794
  const e = document.createElement("div");
@@ -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")
@@ -836,14 +846,14 @@ const Ce = (r, e) => {
836
846
  }
837
847
  return null;
838
848
  };
839
- var M = /* @__PURE__ */ ((r) => (r.StaticNodeId = "static", r.DraggingNodeId = "dragging", r.EdgeId = "edge", r))(M || {});
840
- const Me = (r, e) => ({
849
+ var D = /* @__PURE__ */ ((r) => (r.StaticNodeId = "static", r.DraggingNodeId = "dragging", r.EdgeId = "edge", r))(D || {});
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");
@@ -879,21 +889,21 @@ class lt {
879
889
  { x: t.x + s, y: t.y },
880
890
  n,
881
891
  t
882
- ), w = m(
892
+ ), p = m(
883
893
  { x: o.x - s, y: o.y },
884
894
  a,
885
895
  o
886
- ), p = {
896
+ ), w = {
887
897
  x: l.x + n.x * h,
888
898
  y: l.y + n.y * h
889
899
  }, y = {
890
- x: w.x - a.x * h,
891
- y: w.y - a.y * h
892
- }, f = `M ${l.x} ${l.y} C ${p.x} ${p.y}, ${y.x} ${y.y}, ${w.x} ${w.y}`, x = d ? "" : `M ${t.x} ${t.y} L ${l.x} ${l.y} `, E = c ? "" : ` M ${w.x} ${w.y} L ${o.x} ${o.y}`;
900
+ x: p.x - a.x * h,
901
+ y: p.y - a.y * h
902
+ }, f = `M ${l.x} ${l.y} C ${w.x} ${w.y}, ${y.x} ${y.y}, ${p.x} ${p.y}`, x = d ? "" : `M ${t.x} ${t.y} L ${l.x} ${l.y} `, E = c ? "" : ` M ${p.x} ${p.y} L ${o.x} ${o.y}`;
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");
@@ -912,85 +922,85 @@ class ut {
912
922
  { x: d.x + u, y: d.y },
913
923
  n,
914
924
  d
915
- ) : d, w = o ? m(
925
+ ) : d, p = o ? m(
916
926
  {
917
927
  x: c.x - u,
918
928
  y: c.y
919
929
  },
920
930
  a,
921
931
  c
922
- ) : c, p = Math.cos(h) * g, y = Math.sin(h) * g, f = m(
932
+ ) : c, w = Math.cos(h) * g, y = Math.sin(h) * g, f = m(
923
933
  { x: d.x + u, y: d.y },
924
934
  n,
925
935
  d
926
936
  ), x = {
927
- x: f.x + p,
937
+ x: f.x + w,
928
938
  y: f.y + y
929
939
  }, E = m(
930
940
  { x: c.x - u, y: c.y },
931
941
  a,
932
942
  c
933
- ), b = {
934
- x: E.x + p,
943
+ ), T = {
944
+ x: E.x + w,
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 + T.x) / 2,
948
+ y: (x.y + T.y) / 2
949
+ }, M = {
940
950
  x: f.x + s * n.x,
941
951
  y: f.y + s * n.y
942
- }, I = {
952
+ }, F = {
943
953
  x: E.x - s * a.x,
944
954
  y: E.y - s * a.y
945
- }, F = {
946
- x: f.x + p,
947
- y: f.y + y
948
955
  }, U = {
949
- x: E.x + p,
956
+ x: f.x + w,
957
+ y: f.y + y
958
+ }, R = {
959
+ x: E.x + w,
950
960
  y: E.y + y
951
961
  };
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}`,
956
- `C ${U.x} ${U.y} ${I.x} ${I.y} ${E.x} ${E.y}`,
957
- `L ${w.x} ${w.y}`
958
- ].join(" "), this.midpoint = T;
965
+ `C ${M.x} ${M.y} ${U.x} ${U.y} ${C.x} ${C.y}`,
966
+ `C ${R.x} ${R.y} ${F.x} ${F.y} ${E.x} ${E.y}`,
967
+ `L ${p.x} ${p.y}`
968
+ ].join(" "), this.midpoint = C;
959
969
  }
960
970
  }
961
- const ee = Object.freeze({
971
+ const te = 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
- 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) => {
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(te.edgeColor, r), e;
976
+ }, Fe = (r) => {
967
977
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
968
- return e.setAttribute("stroke", `var(${ee.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
978
+ return e.setAttribute("stroke", `var(${te.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
969
979
  }, X = () => {
970
980
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
971
- return r.setAttribute("fill", `var(${ee.edgeColor})`), r;
972
- }, Ve = (r, e) => {
981
+ return r.setAttribute("fill", `var(${te.edgeColor})`), r;
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
- }, L = (r, e) => {
984
+ }, V = (r, e) => {
975
985
  const t = [];
976
986
  if (r.length > 0 && t.push(`M ${r[0].x} ${r[0].y}`), r.length === 2 && t.push(`L ${r[1].x} ${r[1].y}`), r.length > 2) {
977
987
  const o = r.length - 1;
978
988
  let s = 0, n = 0, a = 0;
979
989
  r.forEach((h, d) => {
980
990
  let c = 0, u = 0, g = 0;
981
- const l = d > 0, w = d < o, p = l && w;
982
- 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);
991
+ const l = d > 0, p = d < o, w = l && p;
992
+ if (l && (c = -s, u = -n, g = a), p) {
993
+ const M = r[d + 1];
994
+ s = M.x - h.x, n = M.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((w ? e : 0) / a, d < o - 1 ? 0.5 : 1) : 0, x = w ? { x: h.x + s * f, y: h.y + n * f } : h, T = g !== 0 ? Math.min((w ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, C = w ? { x: h.x + c * T, y: h.y + u * T } : h;
997
+ d > 0 && t.push(`L ${C.x} ${C.y}`), w && 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");
@@ -1051,14 +1061,14 @@ class pt {
1051
1061
  },
1052
1062
  n,
1053
1063
  o
1054
- ) : o, w = a + h, p = m(
1055
- { x: t.x + w, y: t.y },
1064
+ ) : o, p = a + h, w = m(
1065
+ { x: t.x + p, 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 - p, y: o.y }, n, o), f = yt(
1059
1069
  {
1060
- x: p.x,
1061
- y: p.y,
1070
+ x: w.x,
1071
+ y: w.y,
1062
1072
  dirX: s.x
1063
1073
  },
1064
1074
  {
@@ -1067,13 +1077,13 @@ class pt {
1067
1077
  dirX: n.x
1068
1078
  }
1069
1079
  );
1070
- this.path = L(
1080
+ this.path = V(
1071
1081
  [g, ...f.points, l],
1072
1082
  d
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");
@@ -1089,11 +1099,11 @@ class wt {
1089
1099
  detourDir: u,
1090
1100
  detourDistance: g,
1091
1101
  roundness: l
1092
- } = e, w = t ? m(
1102
+ } = e, p = t ? m(
1093
1103
  { x: s.x + a, y: s.y },
1094
1104
  h,
1095
1105
  s
1096
- ) : s, p = o ? m(
1106
+ ) : s, w = o ? m(
1097
1107
  {
1098
1108
  x: n.x - a,
1099
1109
  y: n.y
@@ -1104,27 +1114,27 @@ class wt {
1104
1114
  { x: s.x + y, y: s.y },
1105
1115
  h,
1106
1116
  s
1107
- ), b = {
1117
+ ), T = {
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
+ ), M = {
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
1121
- }, this.path = L(
1122
- [w, E, b, C, T, p],
1129
+ x: (T.x + M.x) / 2,
1130
+ y: (T.y + M.y) / 2
1131
+ }, this.path = V(
1132
+ [p, E, T, M, C, w],
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");
@@ -1148,13 +1158,13 @@ class yt {
1148
1158
  d,
1149
1159
  o,
1150
1160
  -a
1151
- ), w = a + c, p = { x: t.x + w, y: t.y }, y = m(p, h, t), f = { x: o.x - w, y: o.y }, x = m(f, d, o);
1152
- this.path = L(
1161
+ ), p = a + c, w = { x: t.x + p, y: t.y }, y = m(w, h, t), f = { x: o.x - p, y: o.y }, x = m(f, d, o);
1162
+ this.path = V(
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, T = (y.y + x.y) / 2;
1167
+ this.midpoint = { x: E, y: T };
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");
@@ -1227,14 +1237,14 @@ class vt {
1227
1237
  },
1228
1238
  c,
1229
1239
  o
1230
- ) : o, w = a + h, p = m(
1231
- { x: t.x + w, y: t.y },
1240
+ ) : o, p = a + h, w = m(
1241
+ { x: t.x + p, 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 - p, y: o.y }, c, o), f = xt(
1235
1245
  {
1236
- x: p.x,
1237
- y: p.y,
1246
+ x: w.x,
1247
+ y: w.y,
1238
1248
  dirY: d.y
1239
1249
  },
1240
1250
  {
@@ -1243,13 +1253,13 @@ class vt {
1243
1253
  dirY: c.y
1244
1254
  }
1245
1255
  );
1246
- this.path = L(
1256
+ this.path = V(
1247
1257
  [g, ...f.points, l],
1248
1258
  u
1249
1259
  ), this.midpoint = f.midpoint;
1250
1260
  }
1251
1261
  }
1252
- class te {
1262
+ class re {
1253
1263
  constructor(e) {
1254
1264
  i(this, "path");
1255
1265
  i(this, "midpoint");
@@ -1262,18 +1272,18 @@ class te {
1262
1272
  { x: d, y: -t },
1263
1273
  { x: d, y: 0 },
1264
1274
  { x: o, y: 0 }
1265
- ].map((w) => m(w, n, { x: 0, y: 0 })).map((w) => ({ x: w.x + a.x, y: w.y + a.y })), l = `M ${a.x} ${a.y} L ${g[0].x} ${g[0].y} `;
1266
- 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 };
1275
+ ].map((p) => m(p, n, { x: 0, y: 0 })).map((p) => ({ x: p.x + a.x, y: p.y + a.y })), l = `M ${a.x} ${a.y} L ${g[0].x} ${g[0].y} `;
1276
+ this.path = `${h ? "" : l}${V(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");
1273
- const { arrowLength: t, radius: o, smallRadius: s, dir: n, origin: a, hasArrow: h } = e, d = s + o, c = s * o / d, u = Math.sqrt(d * d - s * s), g = u * s / d, l = u + o + t, w = t + g, y = [
1283
+ const { arrowLength: t, radius: o, smallRadius: s, dir: n, origin: a, hasArrow: h } = e, d = s + o, c = s * o / d, u = Math.sqrt(d * d - s * s), g = u * s / d, l = u + o + t, p = t + g, y = [
1274
1284
  { x: t, y: 0 },
1275
- { x: w, y: c },
1276
- { x: w, y: -c },
1285
+ { x: p, y: c },
1286
+ { x: p, y: -c },
1277
1287
  { x: l, y: 0 }
1278
1288
  ].map((E) => m(E, n, { x: 0, y: 0 })).map((E) => ({ x: E.x + a.x, y: E.y + a.y })), f = [
1279
1289
  `M ${y[0].x} ${y[0].y}`,
@@ -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");
@@ -1311,7 +1321,7 @@ class xt {
1311
1321
  shift: t,
1312
1322
  arrowLength: d,
1313
1323
  dir: g
1314
- }), w = this.createDirectLinePoint({
1324
+ }), p = this.createDirectLinePoint({
1315
1325
  offset: n,
1316
1326
  hasArrow: h,
1317
1327
  flip: -1,
@@ -1319,7 +1329,7 @@ class xt {
1319
1329
  arrowLength: d,
1320
1330
  dir: g
1321
1331
  });
1322
- this.path = `M ${l.x} ${l.y} L ${w.x} ${w.y}`;
1332
+ this.path = `M ${l.x} ${l.y} L ${p.x} ${p.y}`;
1323
1333
  }
1324
1334
  createDirectLinePoint(e) {
1325
1335
  const t = e.hasArrow ? e.arrowLength : 0, o = e.offset + t, s = e.flip * o / this.diagonalDistance, { dir: n, shift: a } = e;
@@ -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");
@@ -1352,43 +1362,43 @@ class At {
1352
1362
  { x: n.x + s, y: n.y },
1353
1363
  h,
1354
1364
  n
1355
- ) : n, w = o ? m(
1365
+ ) : n, p = o ? m(
1356
1366
  {
1357
1367
  x: a.x - s,
1358
1368
  y: a.y
1359
1369
  },
1360
1370
  d,
1361
1371
  a
1362
- ) : a, p = s + c, y = m(
1363
- { x: n.x + p, y: n.y },
1372
+ ) : a, w = s + c, y = m(
1373
+ { x: n.x + w, y: n.y },
1364
1374
  h,
1365
1375
  n
1366
1376
  ), f = m(
1367
- { x: a.x - p, y: a.y },
1377
+ { x: a.x - w, 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
1374
- }, this.path = L(
1384
+ }, this.path = V(
1375
1385
  [
1376
1386
  l,
1377
1387
  y,
1378
1388
  { x: y.x, y: x },
1379
1389
  { x: f.x, y: x },
1380
1390
  f,
1381
- w
1391
+ p
1382
1392
  ],
1383
1393
  u
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 Tt {
1392
1402
  constructor(e) {
1393
1403
  i(this, "path");
1394
1404
  i(this, "midpoint");
@@ -1407,33 +1417,33 @@ class Nt {
1407
1417
  { x: h.x + s, y: h.y },
1408
1418
  n,
1409
1419
  h
1410
- ) : h, w = o ? m(
1420
+ ) : h, p = o ? m(
1411
1421
  {
1412
1422
  x: d.x - s,
1413
1423
  y: d.y
1414
1424
  },
1415
1425
  a,
1416
1426
  d
1417
- ) : d, p = s + c, y = m(
1418
- { x: h.x + p, y: h.y },
1427
+ ) : d, w = s + c, y = m(
1428
+ { x: h.x + w, y: h.y },
1419
1429
  n,
1420
1430
  h
1421
1431
  ), f = m(
1422
- { x: d.x - p, y: d.y },
1432
+ { x: d.x - w, 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
1429
- }, this.path = L(
1439
+ }, this.path = V(
1430
1440
  [
1431
1441
  l,
1432
1442
  y,
1433
1443
  { x, y: y.y },
1434
1444
  { x, y: f.y },
1435
1445
  f,
1436
- w
1446
+ p
1437
1447
  ],
1438
1448
  g
1439
1449
  );
@@ -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 G {
1466
1476
  constructor(e) {
1467
1477
  i(this, "svg");
1468
1478
  i(this, "group", document.createElementNS(
@@ -1475,39 +1485,39 @@ 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 = X(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = X(), 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 === I.PortCycle ? (g = this.params.createCyclePath, u = d) : e.category === I.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
- let w = null;
1493
- this.sourceArrow && (w = this.arrowRenderer({
1502
+ let p = null;
1503
+ this.sourceArrow && (p = this.arrowRenderer({
1494
1504
  direction: d,
1495
1505
  shift: a,
1496
1506
  arrowLength: this.params.arrowLength
1497
- }), this.sourceArrow.setAttribute("d", w));
1498
- let p = null;
1499
- this.targetArrow && (p = this.arrowRenderer({
1507
+ }), this.sourceArrow.setAttribute("d", p));
1508
+ let w = null;
1509
+ this.targetArrow && (w = this.arrowRenderer({
1500
1510
  direction: u,
1501
1511
  shift: h,
1502
1512
  arrowLength: this.params.arrowLength
1503
- }), this.targetArrow.setAttribute("d", p)), this.afterRenderEmitter.emit({
1513
+ }), this.targetArrow.setAttribute("d", w)), this.afterRenderEmitter.emit({
1504
1514
  edgePath: l,
1505
- sourceArrowPath: w,
1506
- targetArrowPath: p
1515
+ sourceArrowPath: p,
1516
+ targetArrowPath: w
1507
1517
  });
1508
1518
  }
1509
1519
  }
1510
- const bt = (r) => (e) => {
1520
+ const Ct = (r) => (e) => {
1511
1521
  const o = [
1512
1522
  { x: 0, y: 0 },
1513
1523
  { x: e.arrowLength, y: r.radius },
@@ -1519,19 +1529,19 @@ 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 },
1526
1536
  { x: a, y: h }
1527
1537
  ].map(
1528
- (p) => m(p, e.direction, { x: 0, y: 0 })
1529
- ).map((p) => ({
1530
- x: p.x + e.shift.x,
1531
- y: p.y + e.shift.y
1532
- })), 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
- return `${u} ${g} ${l} ${w}`;
1534
- }, Tt = (r) => (e) => {
1538
+ (w) => m(w, e.direction, { x: 0, y: 0 })
1539
+ ).map((w) => ({
1540
+ x: w.x + e.shift.x,
1541
+ y: w.y + e.shift.y
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}`, p = `A ${s} ${s} 0 0 0 ${c[0].x} ${c[0].y}`;
1543
+ return `${u} ${g} ${l} ${p}`;
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 Ct({
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 G({
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");
@@ -1652,7 +1662,7 @@ class Mt {
1652
1662
  i(this, "hasSourceArrow");
1653
1663
  i(this, "hasTargetArrow");
1654
1664
  i(this, "pathShape");
1655
- i(this, "createCyclePath", (e, t, o) => new te({
1665
+ i(this, "createCyclePath", (e, t, o) => new re({
1656
1666
  origin: e,
1657
1667
  dir: o,
1658
1668
  arrowLength: this.arrowLength,
@@ -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 G({
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");
@@ -1724,7 +1734,7 @@ class Dt {
1724
1734
  i(this, "hasSourceArrow");
1725
1735
  i(this, "hasTargetArrow");
1726
1736
  i(this, "pathShape");
1727
- i(this, "createCyclePath", (e, t, o) => new te({
1737
+ i(this, "createCyclePath", (e, t, o) => new re({
1728
1738
  origin: e,
1729
1739
  dir: o,
1730
1740
  arrowLength: this.arrowLength,
@@ -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 G({
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");
@@ -1796,7 +1806,7 @@ class Lt {
1796
1806
  i(this, "hasSourceArrow");
1797
1807
  i(this, "hasTargetArrow");
1798
1808
  i(this, "pathShape");
1799
- i(this, "createCyclePath", (e, t, o) => new te({
1809
+ i(this, "createCyclePath", (e, t, o) => new re({
1800
1810
  origin: e,
1801
1811
  dir: o,
1802
1812
  arrowLength: this.arrowLength,
@@ -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 Tt({
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 G({
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 = X(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = X(), 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,
@@ -1898,26 +1908,26 @@ class Ie {
1898
1908
  y: (h.y - a.y) / g
1899
1909
  };
1900
1910
  if (this.sourceArrow) {
1901
- const w = {
1911
+ const p = {
1902
1912
  x: l.x * this.sourceOffset,
1903
1913
  y: l.y * this.sourceOffset
1904
1914
  };
1905
1915
  c = this.arrowRenderer({
1906
1916
  direction: l,
1907
- shift: w,
1917
+ shift: p,
1908
1918
  arrowLength: this.arrowLength
1909
1919
  }), this.sourceArrow.setAttribute("d", c);
1910
1920
  }
1911
1921
  if (this.targetArrow) {
1912
- const w = {
1922
+ const p = {
1913
1923
  x: l.x * this.targetOffset,
1914
1924
  y: l.y * this.targetOffset
1915
1925
  };
1916
1926
  u = this.arrowRenderer({
1917
1927
  direction: { x: -l.x, y: -l.y },
1918
1928
  shift: {
1919
- x: h.x - w.x,
1920
- y: h.y - w.y
1929
+ x: h.x - p.x,
1930
+ y: h.y - p.y
1921
1931
  },
1922
1932
  arrowLength: this.arrowLength
1923
1933
  }), this.targetArrow.setAttribute("d", u);
@@ -1930,40 +1940,45 @@ 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
+ // TODO: make private
1966
+ /**
1967
+ * @deprecated
1968
+ * do use shape.svg instead
1969
+ */
1970
+ i(this, "handle", Ft());
1956
1971
  i(this, "onAfterRender");
1957
1972
  i(this, "interactiveLine");
1958
1973
  i(this, "interactiveSourceArrow", null);
1959
1974
  i(this, "interactiveTargetArrow", null);
1960
- if (this.baseEdge = e, e instanceof Fe)
1961
- throw new It(
1975
+ if (this.baseEdge = e, e instanceof Be)
1976
+ throw new $t(
1962
1977
  "interactive edge can be configured only once"
1963
1978
  );
1964
1979
  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
1980
  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) => {
1981
+ 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
1982
  this.interactiveLine.setAttribute("d", s.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", s.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", s.targetArrowPath);
1968
1983
  });
1969
1984
  }
@@ -1971,7 +1986,7 @@ class Fe {
1971
1986
  this.baseEdge.render(e);
1972
1987
  }
1973
1988
  }
1974
- class Br {
1989
+ class Yr {
1975
1990
  constructor(e, t) {
1976
1991
  i(this, "group");
1977
1992
  i(this, "line");
@@ -1988,7 +2003,7 @@ class Br {
1988
2003
  this.baseShape.render(e);
1989
2004
  }
1990
2005
  }
1991
- class Ue {
2006
+ class Oe {
1992
2007
  constructor(e) {
1993
2008
  i(this, "onAfterNodeAdded");
1994
2009
  i(this, "onAfterNodeUpdated");
@@ -2059,6 +2074,9 @@ class Ue {
2059
2074
  shape: o.shape
2060
2075
  };
2061
2076
  }
2077
+ findEdgeIdByElement(e) {
2078
+ return this.graphStore.findEdgeIdByElement(e);
2079
+ }
2062
2080
  getPortIncomingEdgeIds(e) {
2063
2081
  return this.graphStore.getPortIncomingEdgeIds(e);
2064
2082
  }
@@ -2084,7 +2102,7 @@ class Ue {
2084
2102
  return this.graphStore.getNodeAdjacentEdgeIds(e);
2085
2103
  }
2086
2104
  }
2087
- class J {
2105
+ class K {
2088
2106
  constructor(e) {
2089
2107
  i(this, "counter", 0);
2090
2108
  this.checkExists = e;
@@ -2100,15 +2118,15 @@ class J {
2100
2118
  this.counter = 0;
2101
2119
  }
2102
2120
  }
2103
- class $e {
2121
+ class We {
2104
2122
  constructor(e, t, o) {
2105
- i(this, "nodeIdGenerator", new J(
2123
+ i(this, "nodeIdGenerator", new K(
2106
2124
  (e) => this.graphStore.hasNode(e)
2107
2125
  ));
2108
- i(this, "portIdGenerator", new J(
2126
+ i(this, "portIdGenerator", new K(
2109
2127
  (e) => this.graphStore.hasPort(e)
2110
2128
  ));
2111
- i(this, "edgeIdGenerator", new J(
2129
+ i(this, "edgeIdGenerator", new K(
2112
2130
  (e) => this.graphStore.hasEdge(e)
2113
2131
  ));
2114
2132
  i(this, "onAfterNodeAdded", (e) => {
@@ -2231,18 +2249,18 @@ class $e {
2231
2249
  ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
2232
2250
  }
2233
2251
  }
2234
- const Ft = (r) => {
2252
+ const Bt = (r) => {
2235
2253
  setTimeout(() => {
2236
2254
  r();
2237
2255
  });
2238
- }, Ut = (r) => {
2256
+ }, Ot = (r) => {
2239
2257
  queueMicrotask(() => {
2240
2258
  r();
2241
2259
  });
2242
- }, re = (r) => {
2260
+ }, oe = (r) => {
2243
2261
  r();
2244
2262
  };
2245
- class Be {
2263
+ class ze {
2246
2264
  constructor(e) {
2247
2265
  i(this, "onBeforeUpdated");
2248
2266
  i(this, "onAfterUpdated");
@@ -2265,7 +2283,7 @@ class Be {
2265
2283
  return this.viewportStore.createViewportCoords(e);
2266
2284
  }
2267
2285
  }
2268
- const $t = (r, e) => Symbol.iterator in r ? {
2286
+ const Wt = (r, e) => Symbol.iterator in r ? {
2269
2287
  minContentScale: e.focus.minContentScale,
2270
2288
  nodes: r,
2271
2289
  contentPadding: e.focus.contentPadding,
@@ -2275,16 +2293,16 @@ const $t = (r, e) => Symbol.iterator in r ? {
2275
2293
  nodes: r.nodes ?? [],
2276
2294
  contentPadding: r.contentPadding ?? r.contentOffset ?? e.focus.contentPadding,
2277
2295
  animationDuration: r.animationDuration ?? e.focus.animationDuration
2278
- }, We = (r, e, t) => ({
2296
+ }, ke = (r, e, t) => ({
2279
2297
  scale: r.scale,
2280
2298
  x: r.x + r.scale * e,
2281
2299
  y: r.y + r.scale * t
2282
- }), Oe = (r, e, t, o) => ({
2300
+ }), He = (r, e, t, o) => ({
2283
2301
  scale: r.scale * e,
2284
2302
  x: r.scale * (1 - e) * t + r.x,
2285
2303
  y: r.scale * (1 - e) * o + r.y
2286
2304
  });
2287
- class ze {
2305
+ class Ye {
2288
2306
  constructor(e, t, o, s) {
2289
2307
  this.graphStore = e, this.viewportStore = t, this.params = o, this.win = s;
2290
2308
  }
@@ -2296,13 +2314,13 @@ class ze {
2296
2314
  }
2297
2315
  center(e, t) {
2298
2316
  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);
2317
+ let u = ke(a, d, c);
2300
2318
  const g = t == null ? void 0 : t.contentScale;
2301
2319
  if (g !== void 0) {
2302
- const w = 1 / g;
2303
- u = Oe(
2320
+ const p = 1 / g;
2321
+ u = He(
2304
2322
  u,
2305
- w / a.scale,
2323
+ p / a.scale,
2306
2324
  n.x,
2307
2325
  n.y
2308
2326
  );
@@ -2311,7 +2329,7 @@ class ze {
2311
2329
  l > 0 ? this.animateNavigation(a, u, l) : this.viewportStore.patchViewportMatrix(u);
2312
2330
  }
2313
2331
  focus(e) {
2314
- const t = $t(e ?? {}, this.params);
2332
+ const t = Wt(e ?? {}, this.params);
2315
2333
  this.params.focus.schedule(() => {
2316
2334
  this.navigate(t);
2317
2335
  });
@@ -2332,10 +2350,10 @@ class ze {
2332
2350
  const d = {
2333
2351
  x: (t + o) / 2,
2334
2352
  y: (s + n) / 2
2335
- }, { scale: c } = this.viewportStore.getContentMatrix(), u = (n - s) * c, g = (o - t) * c, { width: l, height: w } = this.viewportStore.getDimensions(), p = Math.max(
2353
+ }, { scale: c } = this.viewportStore.getContentMatrix(), u = (n - s) * c, g = (o - t) * c, { width: l, height: p } = this.viewportStore.getDimensions(), w = Math.max(
2336
2354
  g / l,
2337
- u / w
2338
- ), y = p > 1 ? c / p : c, f = Math.max(y, e.minContentScale);
2355
+ u / p
2356
+ ), y = w > 1 ? c / w : c, f = Math.max(y, e.minContentScale);
2339
2357
  this.center(d, {
2340
2358
  contentScale: f,
2341
2359
  animationDuration: e.animationDuration
@@ -2360,20 +2378,20 @@ class ze {
2360
2378
  this.win.requestAnimationFrame(a);
2361
2379
  }
2362
2380
  }
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 = {
2381
+ const Xe = (r, e, t) => {
2382
+ const o = new Me(), s = new Oe(o), n = new ze(e), a = new Te(o, e, r), h = {
2365
2383
  nodes: {
2366
- centerFn: Me,
2384
+ centerFn: Le,
2367
2385
  priorityFn: () => 0
2368
2386
  },
2369
2387
  edges: {
2370
- shapeFactory: () => new Ie(),
2388
+ shapeFactory: () => new $e(),
2371
2389
  priorityFn: () => 0
2372
2390
  },
2373
2391
  ports: {
2374
2392
  direction: 0
2375
2393
  }
2376
- }, d = new $e(
2394
+ }, d = new We(
2377
2395
  o,
2378
2396
  a,
2379
2397
  h
@@ -2381,18 +2399,18 @@ const ke = (r, e, t) => {
2381
2399
  focus: {
2382
2400
  contentPadding: 0,
2383
2401
  minContentScale: 0,
2384
- schedule: re,
2402
+ schedule: oe,
2385
2403
  animationDuration: 0
2386
2404
  }
2387
- }, u = new ze(
2405
+ }, u = new Ye(
2388
2406
  o,
2389
2407
  e,
2390
2408
  c,
2391
2409
  t
2392
2410
  );
2393
- return new be(s, n, d, u);
2411
+ return new Ce(s, n, d, u);
2394
2412
  };
2395
- class G {
2413
+ class j {
2396
2414
  constructor(e, t, o, s) {
2397
2415
  i(this, "onAfterPortMarked", (e) => {
2398
2416
  const t = this.canvas.graph.getPort(e);
@@ -2407,7 +2425,7 @@ class G {
2407
2425
  if (!this.params.mouseDownEventVerifier(t))
2408
2426
  return;
2409
2427
  const o = e.currentTarget, s = this.canvas.graph.findPortIdsByElement(o)[0];
2410
- this.params.onPortPointerDown(s, {
2428
+ this.params.portDragAllowedVerifier(s, {
2411
2429
  x: t.clientX,
2412
2430
  y: t.clientY
2413
2431
  }) && (e.stopPropagation(), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
@@ -2421,20 +2439,20 @@ class G {
2421
2439
  e.clientX,
2422
2440
  e.clientY
2423
2441
  )) {
2424
- this.params.onPointerMoveOutside(), this.stopMouseDrag();
2442
+ this.removeWindowMouseListeners(), this.params.onPointerOutside();
2425
2443
  return;
2426
2444
  }
2427
2445
  this.params.onPointerMove({ x: e.clientX, y: e.clientY });
2428
2446
  });
2429
2447
  i(this, "onWindowMouseUp", (e) => {
2430
- this.params.mouseUpEventVerifier(e) && (this.params.onPointerUp({ x: e.clientX, y: e.clientY }), this.stopMouseDrag());
2448
+ this.params.mouseUpEventVerifier(e) && (this.removeWindowMouseListeners(), this.params.onPointerUp({ x: e.clientX, y: e.clientY }));
2431
2449
  });
2432
2450
  i(this, "onPortTouchStart", (e) => {
2433
2451
  const t = e;
2434
2452
  if (t.touches.length !== 1)
2435
2453
  return;
2436
2454
  const o = t.touches[0], s = e.currentTarget, n = this.canvas.graph.findPortIdsByElement(s)[0];
2437
- this.params.onPortPointerDown(n, {
2455
+ this.params.portDragAllowedVerifier(n, {
2438
2456
  x: o.clientX,
2439
2457
  y: o.clientY
2440
2458
  }) && (e.stopPropagation(), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
@@ -2451,14 +2469,15 @@ class G {
2451
2469
  t.clientX,
2452
2470
  t.clientY
2453
2471
  )) {
2454
- this.params.onPointerMoveOutside(), this.stopTouchDrag();
2472
+ this.removeWindowTouchListeners(), this.params.onPointerOutside();
2455
2473
  return;
2456
2474
  }
2457
2475
  this.params.onPointerMove({ x: t.clientX, y: t.clientY });
2458
2476
  });
2459
2477
  i(this, "onWindowTouchFinish", (e) => {
2478
+ this.removeWindowTouchListeners();
2460
2479
  const t = e.changedTouches[0];
2461
- this.params.onPointerUp({ x: t.clientX, y: t.clientY }), this.stopTouchDrag();
2480
+ this.params.onPointerUp({ x: t.clientX, y: t.clientY });
2462
2481
  });
2463
2482
  i(this, "reset", () => {
2464
2483
  this.canvas.graph.getAllPortIds().forEach((e) => {
@@ -2467,12 +2486,12 @@ class G {
2467
2486
  });
2468
2487
  });
2469
2488
  i(this, "revert", () => {
2470
- this.params.onStopDrag(), this.reset(), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
2489
+ this.removeWindowMouseListeners(), this.removeWindowTouchListeners(), this.reset();
2471
2490
  });
2472
2491
  this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.params = s, this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.reset), this.canvas.onBeforeDestroy.subscribe(this.revert);
2473
2492
  }
2474
2493
  static configure(e, t, o, s) {
2475
- new G(e, t, o, s);
2494
+ new j(e, t, o, s);
2476
2495
  }
2477
2496
  hookPortEvents(e) {
2478
2497
  e.addEventListener("mousedown", this.onPortMouseDown, {
@@ -2484,12 +2503,6 @@ class G {
2484
2503
  unhookPortEvents(e) {
2485
2504
  e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
2486
2505
  }
2487
- stopMouseDrag() {
2488
- this.params.onStopDrag(), this.removeWindowMouseListeners();
2489
- }
2490
- stopTouchDrag() {
2491
- this.params.onStopDrag(), this.removeWindowTouchListeners();
2492
- }
2493
2506
  removeWindowMouseListeners() {
2494
2507
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
2495
2508
  }
@@ -2497,36 +2510,111 @@ 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 {
2501
- constructor(e, t, o) {
2502
- this.canvas = e, this.layoutAlgorithm = t, this.params = o;
2513
+ class zt {
2514
+ constructor() {
2515
+ i(this, "field", "_htmlGraphTags");
2503
2516
  }
2504
- apply() {
2505
- const e = this.layoutAlgorithm.calculateCoordinates({
2506
- graph: this.canvas.graph,
2507
- viewport: this.canvas.viewport
2508
- });
2509
- this.params.onBeforeApplied(), e.forEach((t, o) => {
2510
- this.params.staticNodeResolver(o) || this.canvas.updateNode(o, t);
2511
- }), this.params.onAfterApplied();
2517
+ has(e, t) {
2518
+ const s = e[this.field];
2519
+ return s !== void 0 && s.has(t);
2520
+ }
2521
+ tag(e, t) {
2522
+ const o = e, s = o[this.field];
2523
+ s === void 0 ? o[this.field] = /* @__PURE__ */ new Set([t]) : s.add(t);
2512
2524
  }
2513
2525
  }
2514
- class Wt {
2526
+ const se = Symbol();
2527
+ class ie {
2515
2528
  constructor(e, t, o) {
2516
- this.canvas = e, this.layoutAlgorithm = t, this.params = o;
2517
- }
2518
- apply(e) {
2519
- const t = this.layoutAlgorithm.calculateNextCoordinates({
2520
- graph: this.canvas.graph,
2521
- viewport: this.canvas.viewport,
2522
- dt: e
2529
+ i(this, "onSelected");
2530
+ i(this, "mouseDownEventVerifier");
2531
+ i(this, "mouseUpEventVerifier");
2532
+ i(this, "movementThreshold");
2533
+ i(this, "selectionCandidate", null);
2534
+ i(this, "previousMouse", null);
2535
+ i(this, "previousTouch", null);
2536
+ i(this, "movedDistance", 0);
2537
+ i(this, "onElementMouseDown", (e) => {
2538
+ const t = e;
2539
+ this.mouseDownEventVerifier(t) && (this.selectionCandidate = t.currentTarget, this.previousMouse = { x: t.clientX, y: t.clientY }, this.movedDistance = 0, this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2540
+ passive: !0
2541
+ }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2542
+ passive: !0
2543
+ }));
2523
2544
  });
2524
- this.params.onBeforeApplied(), t.forEach((o, s) => {
2525
- this.params.staticNodeResolver(s) || this.canvas.updateNode(s, o);
2526
- }), this.params.onAfterApplied();
2545
+ i(this, "onElementTouchStart", (e) => {
2546
+ const t = e, o = t.touches;
2547
+ o.length === 1 && (this.selectionCandidate = t.currentTarget, this.previousTouch = o[0], this.movedDistance = 0, this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2548
+ passive: !0
2549
+ }), this.window.addEventListener("touchend", this.onWindowTouchEnd, {
2550
+ passive: !0
2551
+ }), this.window.addEventListener("touchcancel", this.onWindowTouchCancel, {
2552
+ passive: !0
2553
+ }));
2554
+ });
2555
+ i(this, "onWindowMouseMove", (e) => {
2556
+ const t = e;
2557
+ if (!this.pointInsideVerifier.verify(
2558
+ t.clientX,
2559
+ t.clientY
2560
+ )) {
2561
+ this.removeWindowMouseListeners();
2562
+ return;
2563
+ }
2564
+ const s = this.previousMouse, n = t.clientX - s.x, a = t.clientY - s.y;
2565
+ this.previousMouse = { x: t.clientX, y: t.clientY }, this.processMoveThresholdVerification(n, a, () => {
2566
+ this.removeWindowMouseListeners();
2567
+ });
2568
+ });
2569
+ i(this, "onWindowMouseUp", (e) => {
2570
+ const t = e;
2571
+ this.mouseUpEventVerifier(t) && (this.removeWindowMouseListeners(), this.onSelected(this.selectionCandidate, e));
2572
+ });
2573
+ i(this, "onWindowTouchMove", (e) => {
2574
+ const o = e.touches;
2575
+ if (o.length !== 1) {
2576
+ this.removeWindowTouchListeners();
2577
+ return;
2578
+ }
2579
+ const s = o[0];
2580
+ if (!this.pointInsideVerifier.verify(
2581
+ s.clientX,
2582
+ s.clientY
2583
+ )) {
2584
+ this.removeWindowTouchListeners();
2585
+ return;
2586
+ }
2587
+ const a = this.previousTouch, h = s.clientX - a.clientX, d = s.clientY - a.clientY;
2588
+ this.previousTouch = s, this.processMoveThresholdVerification(h, d, () => {
2589
+ this.removeWindowTouchListeners();
2590
+ });
2591
+ });
2592
+ i(this, "onWindowTouchEnd", (e) => {
2593
+ this.removeWindowTouchListeners(), this.onSelected(this.selectionCandidate, e);
2594
+ });
2595
+ i(this, "onWindowTouchCancel", () => {
2596
+ this.removeWindowTouchListeners();
2597
+ });
2598
+ this.window = e, this.pointInsideVerifier = t, this.mouseDownEventVerifier = o.mouseDownEventVerifier, this.mouseUpEventVerifier = o.mouseUpEventVerifier, this.onSelected = o.onSelected, this.movementThreshold = o.movementThreshold;
2599
+ }
2600
+ enable(e) {
2601
+ e.addEventListener("mousedown", this.onElementMouseDown), e.addEventListener("touchstart", this.onElementTouchStart);
2602
+ }
2603
+ disable(e) {
2604
+ e.removeEventListener("mousedown", this.onElementMouseDown), e.removeEventListener("touchstart", this.onElementTouchStart), e === this.selectionCandidate && (this.removeWindowMouseListeners(), this.removeWindowTouchListeners());
2605
+ }
2606
+ removeWindowMouseListeners() {
2607
+ this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
2608
+ }
2609
+ removeWindowTouchListeners() {
2610
+ this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchEnd), this.window.removeEventListener("touchcancel", this.onWindowTouchCancel);
2611
+ }
2612
+ processMoveThresholdVerification(e, t, o) {
2613
+ const s = Math.sqrt(e * e + t * t);
2614
+ this.movedDistance += s, this.movedDistance > this.movementThreshold && o();
2527
2615
  }
2528
2616
  }
2529
- class oe {
2617
+ class ne {
2530
2618
  constructor(e, t, o, s, n) {
2531
2619
  i(this, "grabbedNode", null);
2532
2620
  i(this, "maxNodePriority", 0);
@@ -2563,7 +2651,7 @@ class oe {
2563
2651
  nodeId: s,
2564
2652
  dx: h.x - n.x,
2565
2653
  dy: h.y - n.y
2566
- }, k(this.element, this.params.dragCursor), this.moveNodeOnTop(s), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2654
+ }, H(this.element, this.params.dragCursor), this.moveNodeOnTop(s), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2567
2655
  passive: !0
2568
2656
  }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2569
2657
  passive: !0
@@ -2645,7 +2733,7 @@ class oe {
2645
2733
  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
2734
  }
2647
2735
  static configure(e, t, o, s, n) {
2648
- new oe(
2736
+ new ne(
2649
2737
  e,
2650
2738
  t,
2651
2739
  o,
@@ -2677,7 +2765,7 @@ class oe {
2677
2765
  }
2678
2766
  }
2679
2767
  stopMouseDrag() {
2680
- this.grabbedNode !== null && this.graph.hasNode(this.grabbedNode.nodeId) && this.params.onNodeDragFinished(this.grabbedNode.nodeId), this.grabbedNode = null, k(this.element, null), this.removeMouseDragListeners();
2768
+ this.grabbedNode !== null && this.graph.hasNode(this.grabbedNode.nodeId) && this.params.onNodeDragFinished(this.grabbedNode.nodeId), this.grabbedNode = null, H(this.element, null), this.removeMouseDragListeners();
2681
2769
  }
2682
2770
  removeMouseDragListeners() {
2683
2771
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
@@ -2720,7 +2808,7 @@ class oe {
2720
2808
  return e;
2721
2809
  }
2722
2810
  }
2723
- const O = (r) => {
2811
+ const W = (r) => {
2724
2812
  const e = [], t = r.touches.length;
2725
2813
  for (let h = 0; h < t; h++)
2726
2814
  e.push([r.touches[h].clientX, r.touches[h].clientY]);
@@ -2739,7 +2827,7 @@ const O = (r) => {
2739
2827
  touches: e
2740
2828
  };
2741
2829
  };
2742
- class j {
2830
+ class J {
2743
2831
  constructor(e, t, o, s, n) {
2744
2832
  i(this, "viewport");
2745
2833
  i(this, "prevTouches", null);
@@ -2749,7 +2837,7 @@ class j {
2749
2837
  this.removeMouseDragListeners(), this.removeTouchDragListeners();
2750
2838
  });
2751
2839
  i(this, "onMouseDown", (e) => {
2752
- this.params.mouseDownEventVerifier(e) && (k(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2840
+ this.params.mouseDownEventVerifier(e) && (H(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2753
2841
  passive: !0
2754
2842
  }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2755
2843
  passive: !0
@@ -2780,10 +2868,10 @@ class j {
2780
2868
  });
2781
2869
  i(this, "onTouchStart", (e) => {
2782
2870
  if (this.prevTouches !== null) {
2783
- this.prevTouches = O(e);
2871
+ this.prevTouches = W(e);
2784
2872
  return;
2785
2873
  }
2786
- this.prevTouches = O(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2874
+ this.prevTouches = W(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2787
2875
  passive: !0
2788
2876
  }), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
2789
2877
  passive: !0
@@ -2792,7 +2880,7 @@ class j {
2792
2880
  }), this.startRegisteredTransform();
2793
2881
  });
2794
2882
  i(this, "onWindowTouchMove", (e) => {
2795
- const t = O(e);
2883
+ const t = W(e);
2796
2884
  if (!t.touches.every(
2797
2885
  (s) => this.pointInsideVerifier.verify(s[0], s[1])
2798
2886
  )) {
@@ -2809,7 +2897,7 @@ class j {
2809
2897
  this.prevTouches = t;
2810
2898
  });
2811
2899
  i(this, "onWindowTouchFinish", (e) => {
2812
- e.touches.length > 0 ? this.prevTouches = O(e) : this.stopTouchDrag();
2900
+ e.touches.length > 0 ? this.prevTouches = W(e) : this.stopTouchDrag();
2813
2901
  });
2814
2902
  i(this, "preventWheelScaleListener", (e) => {
2815
2903
  e.preventDefault();
@@ -2827,7 +2915,7 @@ class j {
2827
2915
  }), e.onBeforeDestroy.subscribe(this.revert);
2828
2916
  }
2829
2917
  static configure(e, t, o, s, n) {
2830
- new j(
2918
+ new J(
2831
2919
  e,
2832
2920
  t,
2833
2921
  o,
@@ -2836,7 +2924,7 @@ class j {
2836
2924
  );
2837
2925
  }
2838
2926
  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({
2927
+ const o = this.viewport.getViewportMatrix(), s = ke(o, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
2840
2928
  prevTransform: o,
2841
2929
  nextTransform: s,
2842
2930
  canvasWidth: n,
@@ -2845,7 +2933,7 @@ class j {
2845
2933
  this.performTransform(h);
2846
2934
  }
2847
2935
  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({
2936
+ const s = this.canvas.viewport.getViewportMatrix(), n = He(s, e, t, o), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
2849
2937
  prevTransform: s,
2850
2938
  nextTransform: n,
2851
2939
  canvasWidth: a,
@@ -2854,7 +2942,7 @@ class j {
2854
2942
  this.performTransform(d);
2855
2943
  }
2856
2944
  stopMouseDrag() {
2857
- k(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
2945
+ H(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
2858
2946
  }
2859
2947
  removeMouseDragListeners() {
2860
2948
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -2884,7 +2972,7 @@ class j {
2884
2972
  this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.params.onResizeTransformFinished();
2885
2973
  }
2886
2974
  }
2887
- class se {
2975
+ class ae {
2888
2976
  constructor(e, t, o, s, n, a, h) {
2889
2977
  i(this, "nodeHorizontal");
2890
2978
  i(this, "nodeVertical");
@@ -2931,7 +3019,7 @@ class se {
2931
3019
  this.scheduleLoadAreaAroundViewport(), s.onTransformFinished();
2932
3020
  }
2933
3021
  };
2934
- j.configure(
3022
+ J.configure(
2935
3023
  e,
2936
3024
  this.element,
2937
3025
  this.window,
@@ -2940,7 +3028,7 @@ class se {
2940
3028
  ), this.trigger.subscribe(this.updateLoadedArea), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
2941
3029
  }
2942
3030
  static configure(e, t, o, s, n, a, h) {
2943
- new se(
3031
+ new ae(
2944
3032
  e,
2945
3033
  t,
2946
3034
  o,
@@ -2971,24 +3059,24 @@ class se {
2971
3059
  });
2972
3060
  }
2973
3061
  }
2974
- const Ot = () => {
3062
+ const kt = () => {
2975
3063
  const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2976
3064
  return r.style.position = "absolute", r.style.inset = "0", r;
2977
- }, zt = () => {
3065
+ }, Ht = () => {
2978
3066
  const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2979
3067
  return r.setAttribute("fill", "url(#pattern)"), r;
2980
- }, kt = () => {
3068
+ }, Yt = () => {
2981
3069
  const r = document.createElementNS(
2982
3070
  "http://www.w3.org/2000/svg",
2983
3071
  "pattern"
2984
3072
  );
2985
3073
  return r.setAttribute("id", "pattern"), r;
2986
3074
  };
2987
- class ie {
3075
+ class he {
2988
3076
  constructor(e, t, o) {
2989
- i(this, "svg", Ot());
2990
- i(this, "patternRenderingRectangle", zt());
2991
- i(this, "pattern", kt());
3077
+ i(this, "svg", kt());
3078
+ i(this, "patternRenderingRectangle", Ht());
3079
+ i(this, "pattern", Yt());
2992
3080
  i(this, "patternContent");
2993
3081
  i(this, "tileWidth");
2994
3082
  i(this, "tileHeight");
@@ -3009,7 +3097,7 @@ class ie {
3009
3097
  }), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated();
3010
3098
  }
3011
3099
  static configure(e, t, o) {
3012
- new ie(e, t, o);
3100
+ new he(e, t, o);
3013
3101
  }
3014
3102
  updateVisibility() {
3015
3103
  const { scale: e } = this.canvas.viewport.getViewportMatrix(), t = e > this.maxViewportScale;
@@ -3023,7 +3111,7 @@ class ie {
3023
3111
  }
3024
3112
  }
3025
3113
  }
3026
- class ne {
3114
+ class de {
3027
3115
  constructor(e, t, o, s, n, a) {
3028
3116
  i(this, "overlayCanvas");
3029
3117
  i(this, "staticPortId", null);
@@ -3031,38 +3119,41 @@ class ne {
3031
3119
  i(this, "onEdgeCreated", (e) => {
3032
3120
  this.params.onAfterEdgeCreated(e);
3033
3121
  });
3034
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = ke(
3122
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = Xe(
3035
3123
  this.overlayLayer,
3036
3124
  this.viewportStore,
3037
3125
  this.window
3038
- ), G.configure(
3126
+ );
3127
+ const h = {
3128
+ mouseDownEventVerifier: this.params.mouseDownEventVerifier,
3129
+ mouseUpEventVerifier: this.params.mouseUpEventVerifier,
3130
+ portDragAllowedVerifier: (d, c) => {
3131
+ const u = this.params.connectionTypeResolver(d);
3132
+ return u === null ? !1 : (this.grabPort(d, c, u), !0);
3133
+ },
3134
+ onPointerMove: (d) => {
3135
+ this.moveDraggingPort(d);
3136
+ },
3137
+ onPointerUp: (d) => {
3138
+ this.tryCreateConnection(d), this.resetDragState();
3139
+ },
3140
+ onPointerOutside: () => {
3141
+ const d = this.staticPortId, c = this.isTargetDragging;
3142
+ this.resetDragState(), this.params.onEdgeCreationInterrupted({
3143
+ staticPortId: d,
3144
+ isDirect: c
3145
+ });
3146
+ }
3147
+ };
3148
+ j.configure(
3039
3149
  this.canvas,
3040
3150
  this.window,
3041
3151
  this.pointInsideVerifier,
3042
- {
3043
- mouseDownEventVerifier: this.params.mouseDownEventVerifier,
3044
- mouseUpEventVerifier: this.params.mouseUpEventVerifier,
3045
- onStopDrag: () => {
3046
- this.resetDragState();
3047
- },
3048
- onPortPointerDown: (h, d) => {
3049
- const c = this.params.connectionTypeResolver(h);
3050
- return c === null ? !1 : (this.grabPort(h, d, c), !0);
3051
- },
3052
- onPointerMove: (h) => {
3053
- this.moveDraggingPort(h);
3054
- },
3055
- onPointerMoveOutside: () => {
3056
- this.handleEdgeCreationInterrupted();
3057
- },
3058
- onPointerUp: (h) => {
3059
- this.tryCreateConnection(h);
3060
- }
3061
- }
3152
+ h
3062
3153
  );
3063
3154
  }
3064
3155
  static configure(e, t, o, s, n, a) {
3065
- new ne(
3156
+ new de(
3066
3157
  e,
3067
3158
  t,
3068
3159
  o,
@@ -3081,53 +3172,49 @@ class ne {
3081
3172
  x: t.x - d.x,
3082
3173
  y: t.y - d.y
3083
3174
  }), g = {
3084
- overlayNodeId: M.StaticNodeId,
3175
+ overlayNodeId: D.StaticNodeId,
3085
3176
  portCoords: c,
3086
3177
  portDirection: s.direction
3087
3178
  }, l = {
3088
- overlayNodeId: M.DraggingNodeId,
3179
+ overlayNodeId: D.DraggingNodeId,
3089
3180
  portCoords: u,
3090
3181
  portDirection: this.params.dragPortDirection
3091
3182
  };
3092
3183
  this.isTargetDragging = o === "direct";
3093
- const [w, p] = this.isTargetDragging ? [g, l] : [l, g];
3094
- this.overlayCanvas.addNode(Y(w)), this.overlayCanvas.addNode(Y(p)), this.overlayCanvas.addEdge({
3095
- from: w.overlayNodeId,
3096
- to: p.overlayNodeId,
3097
- shape: this.params.edgeShapeFactory(M.EdgeId)
3184
+ const [p, w] = this.isTargetDragging ? [g, l] : [l, g];
3185
+ this.overlayCanvas.addNode(Y(p)), this.overlayCanvas.addNode(Y(w)), this.overlayCanvas.addEdge({
3186
+ from: p.overlayNodeId,
3187
+ to: w.overlayNodeId,
3188
+ shape: this.params.edgeShapeFactory(D.EdgeId)
3098
3189
  });
3099
3190
  }
3100
3191
  resetDragState() {
3101
3192
  this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
3102
3193
  }
3103
3194
  tryCreateConnection(e) {
3104
- const t = Ce(this.canvas.graph, e);
3195
+ const t = Re(this.canvas.graph, e);
3105
3196
  if (t === null) {
3106
- this.handleEdgeCreationInterrupted();
3197
+ this.params.onEdgeCreationInterrupted({
3198
+ staticPortId: this.staticPortId,
3199
+ isDirect: this.isTargetDragging
3200
+ });
3107
3201
  return;
3108
3202
  }
3109
- const o = this.staticPortId, s = this.isTargetDragging ? o : t, n = this.isTargetDragging ? t : o, a = { from: s, to: n }, h = this.params.connectionPreprocessor(a);
3110
- h !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.params.onEdgeCreationPrevented(a);
3203
+ const o = this.staticPortId, s = this.isTargetDragging ? o : t, n = this.isTargetDragging ? t : o, a = { from: s, to: n }, h = this.params.connectionAllowedVerifier(a), d = this.params.connectionPreprocessor(a);
3204
+ h && d !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(d), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.params.onEdgeCreationPrevented(a);
3111
3205
  }
3112
3206
  moveDraggingPort(e) {
3113
3207
  const t = this.overlayLayer.getBoundingClientRect(), o = this.canvas.viewport.createContentCoords({
3114
3208
  x: e.x - t.x,
3115
3209
  y: e.y - t.y
3116
3210
  });
3117
- this.overlayCanvas.updateNode(M.DraggingNodeId, {
3211
+ this.overlayCanvas.updateNode(D.DraggingNodeId, {
3118
3212
  x: o.x,
3119
3213
  y: o.y
3120
3214
  });
3121
3215
  }
3122
- handleEdgeCreationInterrupted() {
3123
- const e = this.staticPortId;
3124
- this.params.onEdgeCreationInterrupted({
3125
- staticPortId: e,
3126
- isDirect: this.isTargetDragging
3127
- });
3128
- }
3129
3216
  }
3130
- class ae {
3217
+ class ce {
3131
3218
  constructor(e, t, o, s, n, a) {
3132
3219
  i(this, "overlayCanvas");
3133
3220
  i(this, "staticPortId", null);
@@ -3136,44 +3223,41 @@ class ae {
3136
3223
  i(this, "onEdgeReattached", (e) => {
3137
3224
  this.params.onAfterEdgeReattached(e);
3138
3225
  });
3139
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = ke(
3226
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = Xe(
3140
3227
  this.overlayLayer,
3141
3228
  this.viewportStore,
3142
3229
  this.window
3143
- ), G.configure(
3230
+ );
3231
+ const h = {
3232
+ mouseDownEventVerifier: this.params.mouseDownEventVerifier,
3233
+ mouseUpEventVerifier: this.params.mouseUpEventVerifier,
3234
+ portDragAllowedVerifier: (d, c) => this.tryStartEdgeDragging(d, c),
3235
+ onPointerMove: (d) => {
3236
+ this.moveDraggingPort(d);
3237
+ },
3238
+ onPointerUp: (d) => {
3239
+ this.tryCreateConnection(d), this.resetDragState();
3240
+ },
3241
+ onPointerOutside: () => {
3242
+ const d = this.draggingEdgePayload;
3243
+ this.resetDragState(), this.params.onEdgeReattachInterrupted({
3244
+ id: d.id,
3245
+ from: d.from,
3246
+ to: d.to,
3247
+ shape: d.shape,
3248
+ priority: d.priority
3249
+ });
3250
+ }
3251
+ };
3252
+ j.configure(
3144
3253
  this.canvas,
3145
3254
  this.window,
3146
3255
  this.pointInsideVerifier,
3147
- {
3148
- mouseDownEventVerifier: this.params.mouseDownEventVerifier,
3149
- mouseUpEventVerifier: this.params.mouseUpEventVerifier,
3150
- onStopDrag: () => {
3151
- this.resetDragState();
3152
- },
3153
- onPortPointerDown: (h, d) => this.tryStartEdgeDragging(h, d),
3154
- onPointerMove: (h) => {
3155
- this.moveDraggingPort(h);
3156
- },
3157
- onPointerMoveOutside: () => {
3158
- const h = this.draggingEdgePayload;
3159
- queueMicrotask(() => {
3160
- this.params.onEdgeReattachInterrupted({
3161
- id: h.id,
3162
- from: h.from,
3163
- to: h.to,
3164
- shape: h.shape,
3165
- priority: h.priority
3166
- });
3167
- });
3168
- },
3169
- onPointerUp: (h) => {
3170
- this.tryCreateConnection(h);
3171
- }
3172
- }
3256
+ h
3173
3257
  );
3174
3258
  }
3175
3259
  static configure(e, t, o, s, n, a) {
3176
- new ae(
3260
+ new ce(
3177
3261
  e,
3178
3262
  t,
3179
3263
  o,
@@ -3184,17 +3268,17 @@ class ae {
3184
3268
  }
3185
3269
  tryStartEdgeDragging(e, t) {
3186
3270
  const o = this.params.draggingEdgeResolver(e);
3187
- if (o === null || !this.canvas.graph.hasEdge(o))
3271
+ if (o === null)
3188
3272
  return !1;
3189
3273
  const s = this.canvas.graph.getEdge(o), n = e === s.from, a = e === s.to, h = n ? s.to : s.from;
3190
3274
  this.staticPortId = h, this.isTargetDragging = a;
3191
3275
  const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(h), u = c.element.getBoundingClientRect(), g = {
3192
3276
  x: u.x + u.width / 2,
3193
3277
  y: u.y + u.height / 2
3194
- }, l = this.overlayLayer.getBoundingClientRect(), w = this.canvas.viewport.createContentCoords({
3278
+ }, l = this.overlayLayer.getBoundingClientRect(), p = this.canvas.viewport.createContentCoords({
3195
3279
  x: g.x - l.x,
3196
3280
  y: g.y - l.y
3197
- }), p = this.canvas.viewport.createContentCoords({
3281
+ }), w = this.canvas.viewport.createContentCoords({
3198
3282
  x: t.x - l.x,
3199
3283
  y: t.y - l.y
3200
3284
  });
@@ -3206,21 +3290,21 @@ class ae {
3206
3290
  priority: s.priority
3207
3291
  }, this.canvas.removeEdge(o);
3208
3292
  const y = {
3209
- overlayNodeId: M.StaticNodeId,
3210
- portCoords: w,
3293
+ overlayNodeId: D.StaticNodeId,
3294
+ portCoords: p,
3211
3295
  portDirection: c.direction
3212
3296
  }, f = {
3213
- overlayNodeId: M.DraggingNodeId,
3214
- portCoords: p,
3297
+ overlayNodeId: D.DraggingNodeId,
3298
+ portCoords: w,
3215
3299
  portDirection: d.direction
3216
3300
  }, [x, E] = this.isTargetDragging ? [y, f] : [f, y];
3217
3301
  this.overlayCanvas.addNode(Y(x)), this.overlayCanvas.addNode(Y(E));
3218
- const b = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(M.EdgeId) : s.shape;
3302
+ const T = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(D.EdgeId) : s.shape;
3219
3303
  return this.overlayCanvas.addEdge({
3220
- id: M.EdgeId,
3304
+ id: D.EdgeId,
3221
3305
  from: x.overlayNodeId,
3222
3306
  to: E.overlayNodeId,
3223
- shape: b
3307
+ shape: T
3224
3308
  }), !0;
3225
3309
  }
3226
3310
  resetDragState() {
@@ -3231,14 +3315,14 @@ class ae {
3231
3315
  x: e.x - t.x,
3232
3316
  y: e.y - t.y
3233
3317
  }, s = this.canvas.viewport.createContentCoords(o);
3234
- this.overlayCanvas.updateNode(M.DraggingNodeId, {
3318
+ this.overlayCanvas.updateNode(D.DraggingNodeId, {
3235
3319
  x: s.x,
3236
3320
  y: s.y
3237
3321
  });
3238
3322
  }
3239
3323
  tryCreateConnection(e) {
3240
- const t = Ce(this.canvas.graph, e);
3241
- if (this.overlayCanvas.removeEdge(M.EdgeId), t === null) {
3324
+ const t = Re(this.canvas.graph, e);
3325
+ if (this.overlayCanvas.removeEdge(D.EdgeId), t === null) {
3242
3326
  this.handleEdgeReattachInterrupted();
3243
3327
  return;
3244
3328
  }
@@ -3248,17 +3332,20 @@ class ae {
3248
3332
  to: s,
3249
3333
  shape: n.shape,
3250
3334
  priority: n.priority
3251
- }, h = this.params.connectionPreprocessor(a);
3252
- if (h !== null)
3253
- this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeReattached), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeReattached);
3335
+ }, h = this.params.connectionAllowedVerifier({
3336
+ from: o,
3337
+ to: s
3338
+ }), d = this.params.connectionPreprocessor(a);
3339
+ if (h && d !== null)
3340
+ this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeReattached), this.canvas.addEdge(d), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeReattached);
3254
3341
  else {
3255
- const d = this.draggingEdgePayload;
3342
+ const c = this.draggingEdgePayload;
3256
3343
  this.params.onEdgeReattachPrevented({
3257
- id: d.id,
3258
- from: d.from,
3259
- to: d.to,
3260
- shape: d.shape,
3261
- priority: d.priority
3344
+ id: c.id,
3345
+ from: c.from,
3346
+ to: c.to,
3347
+ shape: c.shape,
3348
+ priority: c.priority
3262
3349
  });
3263
3350
  }
3264
3351
  }
@@ -3273,17 +3360,17 @@ class ae {
3273
3360
  });
3274
3361
  }
3275
3362
  }
3276
- class he {
3363
+ class le {
3277
3364
  constructor(e, t) {
3278
3365
  this.applier = e, this.trigger = t, this.trigger.subscribe(() => {
3279
3366
  this.applier.apply();
3280
3367
  });
3281
3368
  }
3282
3369
  static configure(e, t) {
3283
- new he(e, t);
3370
+ new le(e, t);
3284
3371
  }
3285
3372
  }
3286
- class de {
3373
+ class ue {
3287
3374
  constructor(e, t, o) {
3288
3375
  i(this, "applyScheduled", !1);
3289
3376
  i(this, "apply", () => {
@@ -3300,7 +3387,7 @@ class de {
3300
3387
  });
3301
3388
  }
3302
3389
  static configure(e, t, o) {
3303
- new de(
3390
+ new ue(
3304
3391
  e,
3305
3392
  t,
3306
3393
  o
@@ -3310,23 +3397,37 @@ class de {
3310
3397
  this.applyScheduled || (this.applyScheduled = !0, this.defererFn(this.apply));
3311
3398
  }
3312
3399
  }
3313
- class Yt {
3400
+ class Xt {
3401
+ constructor(e, t, o) {
3402
+ this.canvas = e, this.layoutAlgorithm = t, this.params = o;
3403
+ }
3404
+ apply() {
3405
+ const e = this.layoutAlgorithm.calculateCoordinates({
3406
+ graph: this.canvas.graph,
3407
+ viewport: this.canvas.viewport
3408
+ });
3409
+ this.params.onBeforeApplied(), e.forEach((t, o) => {
3410
+ this.params.staticNodeResolver(o) || this.canvas.updateNode(o, t);
3411
+ }), this.params.onAfterApplied();
3412
+ }
3413
+ }
3414
+ class Gt {
3314
3415
  static configure(e, t) {
3315
- const o = t.applyOn, s = new Bt(e, t.algorithm, {
3416
+ const o = t.applyOn, s = new Xt(e, t.algorithm, {
3316
3417
  staticNodeResolver: t.staticNodeResolver,
3317
3418
  onBeforeApplied: t.onBeforeApplied,
3318
3419
  onAfterApplied: t.onAfterApplied
3319
3420
  });
3320
3421
  switch (o.type) {
3321
3422
  case "trigger": {
3322
- he.configure(
3423
+ le.configure(
3323
3424
  s,
3324
3425
  o.trigger
3325
3426
  );
3326
3427
  break;
3327
3428
  }
3328
3429
  case "topologyChangeSchedule": {
3329
- de.configure(
3430
+ ue.configure(
3330
3431
  e.graph,
3331
3432
  s,
3332
3433
  o.schedule
@@ -3336,7 +3437,7 @@ class Yt {
3336
3437
  }
3337
3438
  }
3338
3439
  }
3339
- class Xt {
3440
+ class jt {
3340
3441
  constructor(e, t) {
3341
3442
  i(this, "previousTimeStamp");
3342
3443
  i(this, "step", (e) => {
@@ -3351,222 +3452,115 @@ class Xt {
3351
3452
  this.win = e, this.callback = t, this.win.requestAnimationFrame(this.step);
3352
3453
  }
3353
3454
  }
3354
- class ce {
3455
+ class Jt {
3456
+ constructor(e, t, o) {
3457
+ this.canvas = e, this.layoutAlgorithm = t, this.params = o;
3458
+ }
3459
+ apply(e) {
3460
+ const t = this.layoutAlgorithm.calculateNextCoordinates({
3461
+ graph: this.canvas.graph,
3462
+ viewport: this.canvas.viewport,
3463
+ dt: e
3464
+ });
3465
+ this.params.onBeforeApplied(), t.forEach((o, s) => {
3466
+ this.params.staticNodeResolver(s) || this.canvas.updateNode(s, o);
3467
+ }), this.params.onAfterApplied();
3468
+ }
3469
+ }
3470
+ class ge {
3355
3471
  constructor(e, t, o) {
3356
3472
  i(this, "applier");
3357
3473
  i(this, "step", (e) => {
3358
3474
  this.applier.apply(e);
3359
3475
  });
3360
- this.win = o, this.applier = new Wt(e, t.algorithm, {
3476
+ this.win = o, this.applier = new Jt(e, t.algorithm, {
3361
3477
  staticNodeResolver: t.staticNodeResolver,
3362
3478
  onBeforeApplied: t.onBeforeApplied,
3363
3479
  onAfterApplied: t.onAfterApplied
3364
- }), new Xt(this.win, this.step);
3480
+ }), new jt(this.win, this.step);
3365
3481
  }
3366
3482
  static configure(e, t, o) {
3367
- new ce(e, t, o);
3483
+ new ge(e, t, o);
3368
3484
  }
3369
3485
  }
3370
- class le {
3371
- constructor(e, t, o, s) {
3486
+ class pe {
3487
+ constructor(e, t, o, s, n) {
3488
+ i(this, "configurator");
3372
3489
  i(this, "onNodeSelected");
3373
- i(this, "mouseDownEventVerifier");
3374
- i(this, "mouseUpEventVerifier");
3375
- i(this, "movementThreshold");
3376
- i(this, "selectionCandidateNodeId", null);
3377
- i(this, "movedDistance", 0);
3378
- i(this, "previousMouse", null);
3379
- i(this, "previousTouch", null);
3490
+ i(this, "selectionHandledTag", se);
3380
3491
  i(this, "onAfterNodeAdded", (e) => {
3381
3492
  const { element: t } = this.canvas.graph.getNode(e);
3382
- t.addEventListener("mousedown", this.onNodeMouseDown, {
3383
- passive: !0
3384
- }), t.addEventListener("touchstart", this.onNodeTouchStart, {
3385
- passive: !0
3386
- });
3493
+ this.configurator.enable(t);
3387
3494
  });
3388
3495
  i(this, "onBeforeNodeRemoved", (e) => {
3389
3496
  const { element: t } = this.canvas.graph.getNode(e);
3390
- t.removeEventListener("mousedown", this.onNodeMouseDown), t.removeEventListener("touchstart", this.onNodeTouchStart);
3497
+ this.configurator.disable(t);
3391
3498
  });
3392
3499
  i(this, "reset", () => {
3393
3500
  this.canvas.graph.getAllNodeIds().forEach((e) => {
3394
3501
  const { element: t } = this.canvas.graph.getNode(e);
3395
- t.removeEventListener("mousedown", this.onNodeMouseDown), t.removeEventListener("touchstart", this.onNodeTouchStart);
3502
+ this.configurator.disable(t);
3396
3503
  });
3397
3504
  });
3398
- i(this, "revert", () => {
3399
- this.reset(), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
3400
- });
3401
- i(this, "onNodeMouseDown", (e) => {
3402
- const t = e;
3403
- if (!this.mouseDownEventVerifier(t))
3404
- return;
3405
- const o = this.canvas.graph.findNodeIdByElement(
3406
- e.currentTarget
3407
- );
3408
- this.selectionCandidateNodeId = o, this.previousMouse = { x: t.clientX, y: t.clientY }, this.movedDistance = 0, this.window.addEventListener("mousemove", this.onWindowMouseMove, {
3409
- passive: !0
3410
- }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
3411
- passive: !0
3412
- });
3413
- });
3414
- i(this, "onNodeTouchStart", (e) => {
3415
- const t = e;
3416
- if (t.touches.length !== 1)
3417
- return;
3418
- const o = this.canvas.graph.findNodeIdByElement(
3419
- t.currentTarget
3420
- );
3421
- this.selectionCandidateNodeId = o, this.previousTouch = t.touches[0], this.movedDistance = 0, this.window.addEventListener("touchmove", this.onWindowTouchMove, {
3422
- passive: !0
3423
- }), this.window.addEventListener("touchend", this.onWindowTouchEnd, {
3424
- passive: !0
3425
- }), this.window.addEventListener("touchcancel", this.onWindowTouchCancel, {
3426
- passive: !0
3427
- });
3428
- });
3429
- i(this, "onWindowMouseMove", (e) => {
3430
- const t = e, o = this.previousMouse, s = t.clientX - o.x, n = t.clientY - o.y;
3431
- if (!this.pointInsideVerifier.verify(t.clientX, t.clientY)) {
3432
- this.removeWindowMouseListeners();
3433
- return;
3434
- }
3435
- this.processMoveThresholdVerification(s, n, () => {
3436
- this.removeWindowMouseListeners();
3437
- }), this.previousMouse = { x: t.clientX, y: t.clientY };
3438
- });
3439
- i(this, "onWindowTouchMove", (e) => {
3440
- const t = e;
3441
- if (t.touches.length !== 1) {
3442
- this.removeWindowTouchListeners();
3443
- return;
3444
- }
3445
- const o = t.touches[0];
3446
- if (!this.pointInsideVerifier.verify(o.clientX, o.clientY)) {
3447
- this.removeWindowTouchListeners();
3448
- return;
3505
+ this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.eventTagger = s, this.onNodeSelected = n.onNodeSelected, this.configurator = new ie(
3506
+ this.window,
3507
+ this.pointInsideVerifier,
3508
+ {
3509
+ onSelected: (a, h) => {
3510
+ const d = this.canvas.graph.findNodeIdByElement(a);
3511
+ this.eventTagger.tag(h, this.selectionHandledTag), this.onNodeSelected(d);
3512
+ },
3513
+ movementThreshold: n.movementThreshold,
3514
+ mouseDownEventVerifier: n.mouseDownEventVerifier,
3515
+ mouseUpEventVerifier: n.mouseUpEventVerifier
3449
3516
  }
3450
- const s = this.previousTouch, n = o.clientX - s.clientX, a = o.clientY - s.clientY;
3451
- this.processMoveThresholdVerification(n, a, () => {
3452
- this.removeWindowTouchListeners();
3453
- }), this.previousTouch = o;
3454
- });
3455
- i(this, "onWindowMouseUp", (e) => {
3456
- const t = e;
3457
- this.mouseUpEventVerifier(t) && (this.removeWindowMouseListeners(), this.trySelectNode(e));
3458
- });
3459
- i(this, "onWindowTouchEnd", (e) => {
3460
- this.removeWindowTouchListeners(), this.trySelectNode(e);
3461
- });
3462
- i(this, "onWindowTouchCancel", () => {
3463
- this.removeWindowTouchListeners();
3464
- });
3465
- 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);
3517
+ ), 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);
3466
3518
  }
3467
- static configure(e, t, o, s) {
3468
- new le(
3519
+ static configure(e, t, o, s, n) {
3520
+ new pe(
3469
3521
  e,
3470
3522
  t,
3471
3523
  o,
3472
- s
3524
+ s,
3525
+ n
3473
3526
  );
3474
3527
  }
3475
- removeWindowMouseListeners() {
3476
- this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
3477
- }
3478
- removeWindowTouchListeners() {
3479
- this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchEnd), this.window.removeEventListener("touchcancel", this.onWindowTouchCancel);
3480
- }
3481
- trySelectNode(e) {
3482
- const t = this.selectionCandidateNodeId;
3483
- this.canvas.graph.hasNode(t) && (this.onNodeSelected(t), e.ignoreCanvasSelection = !0);
3484
- }
3485
- processMoveThresholdVerification(e, t, o) {
3486
- const s = Math.sqrt(e * e + t * t);
3487
- this.movedDistance += s, this.movedDistance > this.movementThreshold && o();
3488
- }
3489
3528
  }
3490
- class ue {
3529
+ class we {
3491
3530
  constructor(e, t, o, s, n) {
3492
- i(this, "onCanvasSelected");
3493
- i(this, "movementThreshold");
3494
- i(this, "mouseDownEventVerifier");
3495
- i(this, "mouseUpEventVerifier");
3496
- i(this, "movedDistance", 0);
3497
- i(this, "previousMouseDown", null);
3498
- i(this, "previousTouch", null);
3499
- i(this, "onMouseDown", (e) => {
3500
- const t = e;
3501
- this.mouseDownEventVerifier(t) && (this.previousMouseDown = { x: t.clientX, y: t.clientY }, this.movedDistance = 0, this.window.addEventListener("mousemove", this.onWindowMouseMove, {
3502
- passive: !0
3503
- }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
3504
- passive: !0
3505
- }));
3531
+ i(this, "configurator");
3532
+ i(this, "selectionHandledTag", se);
3533
+ i(this, "onEdgeSelected");
3534
+ i(this, "onAfterEdgeAdded", (e) => {
3535
+ const { shape: t } = this.canvas.graph.getEdge(e);
3536
+ this.configurator.enable(t.svg);
3506
3537
  });
3507
- i(this, "onTouchStart", (e) => {
3508
- const t = e;
3509
- if (t.touches.length !== 1)
3510
- return;
3511
- const o = t.touches[0];
3512
- this.previousTouch = o, this.movedDistance = 0, this.window.addEventListener("touchmove", this.onWindowTouchMove, {
3513
- passive: !0
3514
- }), this.window.addEventListener("touchend", this.onWindowTouchEnd, {
3515
- passive: !0
3516
- }), this.window.addEventListener("touchcancel", this.onWindowTouchCancel, {
3517
- passive: !0
3518
- });
3538
+ i(this, "onBeforeEdgeRemoved", (e) => {
3539
+ const { shape: t } = this.canvas.graph.getEdge(e);
3540
+ this.configurator.disable(t.svg);
3519
3541
  });
3520
- i(this, "onWindowMouseMove", (e) => {
3521
- const t = e;
3522
- if (!this.pointInsideVerifier.verify(t.clientX, t.clientY)) {
3523
- this.removeWindowMouseListeners();
3524
- return;
3525
- }
3526
- const o = this.previousMouseDown, s = t.clientX - o.x, n = t.clientY - o.y;
3527
- this.processMoveThresholdVerification(s, n, () => {
3528
- this.removeWindowMouseListeners();
3529
- }), this.previousMouseDown = { x: t.clientX, y: t.clientY };
3542
+ i(this, "reset", () => {
3543
+ this.canvas.graph.getAllEdgeIds().forEach((e) => {
3544
+ const { shape: t } = this.canvas.graph.getEdge(e);
3545
+ this.configurator.disable(t.svg);
3546
+ });
3530
3547
  });
3531
- i(this, "onWindowTouchMove", (e) => {
3532
- const t = e;
3533
- if (t.touches.length !== 1) {
3534
- this.removeWindowTouchListeners();
3535
- return;
3536
- }
3537
- const o = t.touches[0];
3538
- if (!this.pointInsideVerifier.verify(o.clientX, o.clientY)) {
3539
- this.removeWindowTouchListeners();
3540
- return;
3548
+ this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.eventTagger = s, this.onEdgeSelected = n.onEdgeSelected, this.configurator = new ie(
3549
+ this.window,
3550
+ this.pointInsideVerifier,
3551
+ {
3552
+ onSelected: (a, h) => {
3553
+ const d = this.canvas.graph.findEdgeIdByElement(a);
3554
+ this.eventTagger.tag(h, this.selectionHandledTag), this.onEdgeSelected(d);
3555
+ },
3556
+ movementThreshold: n.movementThreshold,
3557
+ mouseDownEventVerifier: n.mouseDownEventVerifier,
3558
+ mouseUpEventVerifier: n.mouseUpEventVerifier
3541
3559
  }
3542
- const s = this.previousTouch, n = o.clientX - s.clientX, a = o.clientY - s.clientY;
3543
- this.processMoveThresholdVerification(n, a, () => {
3544
- this.removeWindowTouchListeners();
3545
- }), this.previousTouch = o;
3546
- });
3547
- i(this, "onWindowMouseUp", (e) => {
3548
- const t = e;
3549
- if (!this.mouseUpEventVerifier(t))
3550
- return;
3551
- e.ignoreCanvasSelection !== !0 && this.onCanvasSelected(), this.removeWindowMouseListeners();
3552
- });
3553
- i(this, "onWindowTouchEnd", () => {
3554
- this.onCanvasSelected(), this.removeWindowTouchListeners();
3555
- });
3556
- i(this, "onWindowTouchCancel", () => {
3557
- this.removeWindowTouchListeners();
3558
- });
3559
- i(this, "restore", () => {
3560
- this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("touchstart", this.onTouchStart), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
3561
- });
3562
- 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, {
3563
- passive: !0
3564
- }), this.element.addEventListener("touchstart", this.onTouchStart, {
3565
- passive: !0
3566
- });
3560
+ ), 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);
3567
3561
  }
3568
3562
  static configure(e, t, o, s, n) {
3569
- new ue(
3563
+ new we(
3570
3564
  e,
3571
3565
  t,
3572
3566
  o,
@@ -3574,59 +3568,96 @@ class ue {
3574
3568
  n
3575
3569
  );
3576
3570
  }
3577
- removeWindowMouseListeners() {
3578
- this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
3579
- }
3580
- removeWindowTouchListeners() {
3581
- this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchEnd), this.window.removeEventListener("touchcancel", this.onWindowTouchCancel);
3571
+ }
3572
+ class ye {
3573
+ constructor(e, t, o, s, n, a) {
3574
+ i(this, "configurator");
3575
+ i(this, "onCanvasSelected");
3576
+ i(this, "selectionHandledTag", se);
3577
+ this.canvas = e, this.element = t, this.window = o, this.pointInsideVerifier = s, this.eventTagger = n, this.onCanvasSelected = a.onCanvasSelected, this.configurator = new ie(
3578
+ this.window,
3579
+ this.pointInsideVerifier,
3580
+ {
3581
+ onSelected: (h, d) => {
3582
+ this.eventTagger.has(d, this.selectionHandledTag) || this.onCanvasSelected();
3583
+ },
3584
+ movementThreshold: a.movementThreshold,
3585
+ mouseDownEventVerifier: a.mouseDownEventVerifier,
3586
+ mouseUpEventVerifier: a.mouseUpEventVerifier
3587
+ }
3588
+ ), this.configurator.enable(this.element), this.canvas.onBeforeDestroy.subscribe(() => {
3589
+ this.configurator.disable(this.element);
3590
+ });
3582
3591
  }
3583
- processMoveThresholdVerification(e, t, o) {
3584
- const s = Math.sqrt(e * e + t * t);
3585
- this.movedDistance += s, this.movedDistance > this.movementThreshold && o();
3592
+ static configure(e, t, o, s, n, a) {
3593
+ new ye(
3594
+ e,
3595
+ t,
3596
+ o,
3597
+ s,
3598
+ n,
3599
+ a
3600
+ );
3586
3601
  }
3587
3602
  }
3588
- const Ht = () => {
3603
+ const Kt = () => {
3589
3604
  const r = document.createElement("div");
3590
3605
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
3591
3606
  }, Q = () => {
3592
3607
  const r = document.createElement("div");
3593
3608
  return r.style.position = "absolute", r.style.inset = "0", r;
3594
- }, xe = () => {
3609
+ }, Se = () => {
3595
3610
  const r = Q();
3596
3611
  return r.style.pointerEvents = "none", r;
3597
3612
  };
3598
- class Gt {
3613
+ class Qt {
3599
3614
  constructor(e) {
3600
3615
  i(this, "background", Q());
3601
3616
  i(this, "main", Q());
3602
- i(this, "overlayConnectablePorts", xe());
3603
- i(this, "overlayDraggableEdges", xe());
3604
- i(this, "host", Ht());
3617
+ i(this, "overlayConnectablePorts", Se());
3618
+ i(this, "overlayDraggableEdges", Se());
3619
+ i(this, "host", Kt());
3605
3620
  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);
3606
3621
  }
3607
3622
  destroy() {
3608
3623
  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);
3609
3624
  }
3610
3625
  }
3611
- const jt = (r) => {
3612
- var w, p, y, f, x, E;
3613
- const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
3614
- }), t = ((p = r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
3615
- }), o = r.nodeDragVerifier ?? (() => !0), s = ((y = r.events) == null ? void 0 : y.onNodeDragFinished) ?? (() => {
3616
- }), 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;
3626
+ const b = Object.freeze({
3627
+ seed: "HTMLGraph is awesome",
3628
+ maxTimeDeltaSec: 0.01,
3629
+ nodeCharge: 1e5,
3630
+ nodeMass: 1,
3631
+ edgeEquilibriumLength: 300,
3632
+ edgeStiffness: 1e3,
3633
+ dtSec: 0.01,
3634
+ maxIterations: 1e3,
3635
+ convergenceVelocity: 10,
3636
+ maxForce: 1e7,
3637
+ nodeForceCoefficient: 1,
3638
+ barnesHutAreaRadiusThreshold: 0.01,
3639
+ barnesHutTheta: 1
3640
+ }), L = Object.freeze({
3641
+ mouseDownEventVerifier: (r) => r.button === 0,
3642
+ mouseUpEventVerifier: (r) => r.button === 0,
3643
+ movementThreshold: 10
3644
+ }), N = () => {
3645
+ }, Zt = (r) => {
3646
+ var u, g, l, p, w, y;
3647
+ const e = r.nodeDragVerifier ?? (() => !0), t = r.moveOnTop !== !1, o = r.moveEdgesOnTop !== !1 && t, s = (u = r.mouse) == null ? void 0 : u.dragCursor, n = s !== void 0 ? s : "grab", a = (g = r.mouse) == null ? void 0 : g.mouseDownEventVerifier, h = a !== void 0 ? a : (f) => f.button === 0, d = (l = r.mouse) == null ? void 0 : l.mouseUpEventVerifier, c = d !== void 0 ? d : (f) => f.button === 0;
3617
3648
  return {
3618
- moveOnTop: n,
3619
- moveEdgesOnTop: a,
3620
- dragCursor: d,
3649
+ moveOnTop: t,
3650
+ moveEdgesOnTop: o,
3651
+ dragCursor: n,
3621
3652
  gridSize: r.gridSize ?? null,
3622
- mouseDownEventVerifier: u,
3623
- mouseUpEventVerifier: l,
3624
- onNodeDragStarted: e,
3625
- onNodeDrag: t,
3626
- nodeDragVerifier: o,
3627
- onNodeDragFinished: s
3653
+ mouseDownEventVerifier: h,
3654
+ mouseUpEventVerifier: c,
3655
+ onNodeDragStarted: ((p = r.events) == null ? void 0 : p.onNodeDragStarted) ?? N,
3656
+ onNodeDrag: ((w = r.events) == null ? void 0 : w.onNodeDrag) ?? N,
3657
+ nodeDragVerifier: e,
3658
+ onNodeDragFinished: ((y = r.events) == null ? void 0 : y.onNodeDragFinished) ?? N
3628
3659
  };
3629
- }, Jt = (r) => {
3660
+ }, _t = (r) => {
3630
3661
  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;
3631
3662
  return (n) => {
3632
3663
  let a = n.nextTransform.x, h = n.nextTransform.y;
@@ -3636,7 +3667,7 @@ const jt = (r) => {
3636
3667
  const u = n.canvasHeight * n.prevTransform.scale, g = s - u;
3637
3668
  return h > g && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, g)), { scale: n.nextTransform.scale, x: a, y: h };
3638
3669
  };
3639
- }, Kt = (r) => {
3670
+ }, qt = (r) => {
3640
3671
  const e = r.maxContentScale, t = r.minContentScale, o = e !== null ? 1 / e : 0, s = t !== null ? 1 / t : 1 / 0;
3641
3672
  return (n) => {
3642
3673
  const a = n.prevTransform, h = n.nextTransform;
@@ -3657,7 +3688,7 @@ const jt = (r) => {
3657
3688
  y: u
3658
3689
  };
3659
3690
  };
3660
- }, Qt = (r) => (e) => r.reduce(
3691
+ }, er = (r) => (e) => r.reduce(
3661
3692
  (t, o) => o({
3662
3693
  prevTransform: e.prevTransform,
3663
3694
  nextTransform: t,
@@ -3665,77 +3696,71 @@ const jt = (r) => {
3665
3696
  canvasHeight: e.canvasHeight
3666
3697
  }),
3667
3698
  e.nextTransform
3668
- ), Ee = (r) => {
3699
+ ), be = (r) => {
3669
3700
  if (typeof r == "function")
3670
3701
  return r;
3671
3702
  switch (r.type) {
3672
3703
  case "scale-limit":
3673
- return Kt({
3704
+ return qt({
3674
3705
  minContentScale: r.minContentScale ?? 0,
3675
3706
  maxContentScale: r.maxContentScale ?? 1 / 0
3676
3707
  });
3677
3708
  case "shift-limit":
3678
- return Jt({
3709
+ return _t({
3679
3710
  minX: r.minX ?? -1 / 0,
3680
3711
  maxX: r.maxX ?? 1 / 0,
3681
3712
  minY: r.minY ?? -1 / 0,
3682
3713
  maxY: r.maxY ?? 1 / 0
3683
3714
  });
3684
3715
  }
3685
- }, Ae = (r) => {
3686
- var p, y, f, x, E, b, T, C, I, F, U, pe;
3687
- 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;
3716
+ }, Ne = (r) => {
3717
+ var l, p, w, y, f, x, E, T, C, M, F, U;
3718
+ const e = (l = r == null ? void 0 : r.scale) == null ? void 0 : l.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, o = r == null ? void 0 : r.transformPreprocessor;
3688
3719
  let s;
3689
- o !== void 0 ? Array.isArray(o) ? s = Qt(
3720
+ o !== void 0 ? Array.isArray(o) ? s = er(
3690
3721
  o.map(
3691
- (D) => Ee(D)
3722
+ (R) => be(R)
3692
3723
  )
3693
- ) : s = Ee(o) : s = (D) => D.nextTransform;
3694
- 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) ?? (() => {
3695
- }), h = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onTransformChange) ?? (() => {
3696
- }), 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;
3724
+ ) : s = be(o) : s = (R) => R.nextTransform;
3725
+ const n = ((p = r == null ? void 0 : r.shift) == null ? void 0 : p.cursor) !== void 0 ? r.shift.cursor : "grab", a = (w = r == null ? void 0 : r.shift) == null ? void 0 : w.mouseDownEventVerifier, h = a !== void 0 ? a : (R) => R.button === 0, d = (y = r == null ? void 0 : r.shift) == null ? void 0 : y.mouseUpEventVerifier, c = d !== void 0 ? d : (R) => R.button === 0, u = (f = r == null ? void 0 : r.scale) == null ? void 0 : f.mouseWheelEventVerifier, g = u !== void 0 ? u : () => !0;
3697
3726
  return {
3698
3727
  wheelSensitivity: t,
3699
- onTransformStarted: ((C = r == null ? void 0 : r.events) == null ? void 0 : C.onTransformStarted) ?? (() => {
3700
- }),
3701
- onTransformFinished: ((I = r == null ? void 0 : r.events) == null ? void 0 : I.onTransformFinished) ?? (() => {
3702
- }),
3703
- onBeforeTransformChange: a,
3704
- onTransformChange: h,
3728
+ onTransformStarted: ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onTransformStarted) ?? N,
3729
+ onTransformFinished: ((E = r == null ? void 0 : r.events) == null ? void 0 : E.onTransformFinished) ?? N,
3730
+ onBeforeTransformChange: ((T = r == null ? void 0 : r.events) == null ? void 0 : T.onBeforeTransformChange) ?? N,
3731
+ onTransformChange: ((C = r == null ? void 0 : r.events) == null ? void 0 : C.onTransformChange) ?? N,
3705
3732
  transformPreprocessor: s,
3706
3733
  shiftCursor: n,
3707
- mouseDownEventVerifier: c,
3708
- mouseUpEventVerifier: g,
3709
- mouseWheelEventVerifier: w,
3710
- scaleWheelFinishTimeout: ((F = r == null ? void 0 : r.scale) == null ? void 0 : F.wheelFinishTimeout) ?? 500,
3711
- onResizeTransformStarted: ((U = r == null ? void 0 : r.events) == null ? void 0 : U.onResizeTransformStarted) ?? (() => {
3712
- }),
3713
- onResizeTransformFinished: ((pe = r == null ? void 0 : r.events) == null ? void 0 : pe.onResizeTransformFinished) ?? (() => {
3714
- })
3734
+ mouseDownEventVerifier: h,
3735
+ mouseUpEventVerifier: c,
3736
+ mouseWheelEventVerifier: g,
3737
+ scaleWheelFinishTimeout: ((M = r == null ? void 0 : r.scale) == null ? void 0 : M.wheelFinishTimeout) ?? 500,
3738
+ onResizeTransformStarted: ((F = r == null ? void 0 : r.events) == null ? void 0 : F.onResizeTransformStarted) ?? N,
3739
+ onResizeTransformFinished: ((U = r == null ? void 0 : r.events) == null ? void 0 : U.onResizeTransformFinished) ?? N
3715
3740
  };
3716
- }, Zt = (r, e) => {
3741
+ }, tr = (r, e) => {
3717
3742
  const t = document.createElementNS(
3718
3743
  "http://www.w3.org/2000/svg",
3719
3744
  "circle"
3720
3745
  );
3721
3746
  return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
3722
- }, _t = (r) => r instanceof SVGElement ? r : Zt(
3747
+ }, rr = (r) => r instanceof SVGElement ? r : tr(
3723
3748
  (r == null ? void 0 : r.radius) ?? 1.5,
3724
3749
  (r == null ? void 0 : r.color) ?? "#d8d8d8"
3725
- ), qt = (r) => {
3726
- const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, o = (e == null ? void 0 : e.height) ?? 25, s = _t(r.renderer ?? {});
3750
+ ), or = (r) => {
3751
+ const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, o = (e == null ? void 0 : e.height) ?? 25, s = rr(r.renderer ?? {});
3727
3752
  return {
3728
3753
  tileWidth: t,
3729
3754
  tileHeight: o,
3730
3755
  renderer: s,
3731
3756
  maxViewportScale: r.maxViewportScale ?? 10
3732
3757
  };
3733
- }, ge = (r) => {
3758
+ }, fe = (r) => {
3734
3759
  if (typeof r == "function")
3735
3760
  return r;
3736
3761
  switch (r.type) {
3737
3762
  case "straight":
3738
- return () => new Dt({
3763
+ return () => new Vt({
3739
3764
  color: r.color,
3740
3765
  width: r.width,
3741
3766
  arrowLength: r.arrowLength,
@@ -3749,7 +3774,7 @@ const jt = (r) => {
3749
3774
  detourDirection: r.detourDirection
3750
3775
  });
3751
3776
  case "horizontal":
3752
- return () => new Mt({
3777
+ return () => new Lt({
3753
3778
  color: r.color,
3754
3779
  width: r.width,
3755
3780
  arrowLength: r.arrowLength,
@@ -3762,7 +3787,7 @@ const jt = (r) => {
3762
3787
  detourDistance: r.detourDistance
3763
3788
  });
3764
3789
  case "vertical":
3765
- return () => new Lt({
3790
+ return () => new It({
3766
3791
  color: r.color,
3767
3792
  width: r.width,
3768
3793
  arrowLength: r.arrowLength,
@@ -3775,7 +3800,7 @@ const jt = (r) => {
3775
3800
  detourDistance: r.detourDistance
3776
3801
  });
3777
3802
  case "direct":
3778
- return () => new Ie({
3803
+ return () => new $e({
3779
3804
  color: r.color,
3780
3805
  width: r.width,
3781
3806
  arrowLength: r.arrowLength,
@@ -3786,7 +3811,7 @@ const jt = (r) => {
3786
3811
  targetOffset: r.targetOffset
3787
3812
  });
3788
3813
  default:
3789
- return () => new Ct({
3814
+ return () => new Rt({
3790
3815
  color: r.color,
3791
3816
  width: r.width,
3792
3817
  arrowLength: r.arrowLength,
@@ -3800,61 +3825,64 @@ const jt = (r) => {
3800
3825
  detourDirection: r.detourDirection
3801
3826
  });
3802
3827
  }
3803
- }, er = (r, e, t) => {
3804
- var c, u, g;
3805
- const o = () => "direct", s = (l) => l, n = (l) => l.button === 0, a = () => {
3806
- }, h = () => {
3807
- }, d = () => {
3808
- };
3828
+ }, $ = Object.freeze({
3829
+ connectionTypeResolver: () => "direct",
3830
+ connectionPreprocessor: (r) => r,
3831
+ connectionAllowedVerifier: () => !0,
3832
+ mouseEventVerifier: (r) => r.button === 0
3833
+ }), sr = (r, e, t) => {
3834
+ var o, s, n;
3809
3835
  return {
3810
- connectionTypeResolver: r.connectionTypeResolver ?? o,
3811
- connectionPreprocessor: r.connectionPreprocessor ?? s,
3812
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? n,
3813
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? n,
3814
- onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ?? a,
3815
- onEdgeCreationInterrupted: ((u = r.events) == null ? void 0 : u.onEdgeCreationInterrupted) ?? d,
3816
- onEdgeCreationPrevented: ((g = r.events) == null ? void 0 : g.onEdgeCreationPrevented) ?? h,
3836
+ connectionTypeResolver: r.connectionTypeResolver ?? $.connectionTypeResolver,
3837
+ connectionPreprocessor: r.connectionPreprocessor ?? $.connectionPreprocessor,
3838
+ connectionAllowedVerifier: r.connectionAllowedVerifier ?? $.connectionAllowedVerifier,
3839
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? $.mouseEventVerifier,
3840
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? $.mouseEventVerifier,
3841
+ onAfterEdgeCreated: ((o = r.events) == null ? void 0 : o.onAfterEdgeCreated) ?? N,
3842
+ onEdgeCreationInterrupted: ((s = r.events) == null ? void 0 : s.onEdgeCreationInterrupted) ?? N,
3843
+ onEdgeCreationPrevented: ((n = r.events) == null ? void 0 : n.onEdgeCreationPrevented) ?? N,
3817
3844
  dragPortDirection: r.dragPortDirection ?? t,
3818
- edgeShapeFactory: r.edgeShape !== void 0 ? ge(r.edgeShape) : e
3845
+ edgeShapeFactory: r.edgeShape !== void 0 ? fe(r.edgeShape) : e
3819
3846
  };
3820
- }, tr = (r, e) => {
3821
- var c, u, g;
3822
- const t = (l) => l, o = (l) => l.button === 0 && l.ctrlKey, s = (l) => l.button === 0, n = (l) => {
3823
- const w = e.getPortAdjacentEdgeIds(l);
3824
- return w.length > 0 ? w[w.length - 1] : null;
3825
- }, a = () => {
3826
- }, h = () => {
3827
- }, d = () => {
3847
+ }, z = Object.freeze({
3848
+ connectionAllowedVerifier: () => !0,
3849
+ connectionPreprocessor: (r) => r,
3850
+ mouseDownEventVerifier: (r) => r.button === 0 && r.ctrlKey,
3851
+ mouseUpEventVerifier: (r) => r.button === 0
3852
+ }), ir = (r, e) => {
3853
+ var o, s, n;
3854
+ const t = (a) => {
3855
+ const h = e.getPortAdjacentEdgeIds(a);
3856
+ return h.length > 0 ? h[h.length - 1] : null;
3828
3857
  };
3829
3858
  return {
3830
- connectionPreprocessor: r.connectionPreprocessor ?? t,
3831
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? o,
3832
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? s,
3833
- draggingEdgeResolver: r.draggingEdgeResolver ?? n,
3834
- draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? ge(r.draggingEdgeShape) : null,
3835
- onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
3836
- onEdgeReattachInterrupted: ((u = r.events) == null ? void 0 : u.onEdgeReattachInterrupted) ?? d,
3837
- onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ?? h
3859
+ connectionPreprocessor: r.connectionPreprocessor ?? z.connectionPreprocessor,
3860
+ connectionAllowedVerifier: r.connectionAllowedVerifier ?? z.connectionAllowedVerifier,
3861
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? z.mouseDownEventVerifier,
3862
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? z.mouseUpEventVerifier,
3863
+ draggingEdgeResolver: r.draggingEdgeResolver ?? t,
3864
+ draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? fe(r.draggingEdgeShape) : null,
3865
+ onAfterEdgeReattached: ((o = r.events) == null ? void 0 : o.onAfterEdgeReattached) ?? N,
3866
+ onEdgeReattachInterrupted: ((s = r.events) == null ? void 0 : s.onEdgeReattachInterrupted) ?? N,
3867
+ onEdgeReattachPrevented: ((n = r.events) == null ? void 0 : n.onEdgeReattachPrevented) ?? N
3838
3868
  };
3839
- }, rr = (r) => ({
3869
+ }, nr = (r) => ({
3840
3870
  nodeVerticalRadius: r.nodeContainingRadius.vertical,
3841
3871
  nodeHorizontalRadius: r.nodeContainingRadius.horizontal
3842
- }), or = (r) => {
3872
+ }), ar = (r) => {
3843
3873
  var e, t;
3844
3874
  return {
3845
- onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
3846
- }),
3847
- onBeforeNodeAttached: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeNodeAttached) ?? (() => {
3848
- })
3875
+ onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? N,
3876
+ onBeforeNodeAttached: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeNodeAttached) ?? N
3849
3877
  };
3850
3878
  };
3851
- class sr extends Error {
3879
+ class hr extends Error {
3852
3880
  constructor() {
3853
3881
  super(...arguments);
3854
3882
  i(this, "name", "CanvasBuilderError");
3855
3883
  }
3856
3884
  }
3857
- class Ye {
3885
+ class Ge {
3858
3886
  constructor(e, t, o) {
3859
3887
  i(this, "dt");
3860
3888
  i(this, "nodeMass");
@@ -3887,12 +3915,12 @@ class Ye {
3887
3915
  const o = this.graph.getEdge(t), s = this.graph.getPort(o.from), n = this.graph.getPort(o.to), a = this.currentCoords.get(s.nodeId), h = this.currentCoords.get(n.nodeId), d = this.distanceVectorGenerator.create(
3888
3916
  a,
3889
3917
  h
3890
- ), u = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, g = d.ex * u, l = d.ey * u, w = e.get(s.nodeId), p = e.get(n.nodeId);
3891
- w.x += g, w.y += l, p.x -= g, p.y -= l;
3918
+ ), u = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, g = d.ex * u, l = d.ey * u, p = e.get(s.nodeId), w = e.get(n.nodeId);
3919
+ p.x += g, p.y += l, w.x -= g, w.y -= l;
3892
3920
  });
3893
3921
  }
3894
3922
  }
3895
- class Xe {
3923
+ class je {
3896
3924
  constructor(e) {
3897
3925
  i(this, "PI2", 2 * Math.PI);
3898
3926
  this.rand = e;
@@ -3911,13 +3939,13 @@ class Xe {
3911
3939
  return { ex: h, ey: d, d: a };
3912
3940
  }
3913
3941
  }
3914
- const He = (r) => {
3942
+ const Je = (r) => {
3915
3943
  if (r.distance === 0)
3916
3944
  return r.maxForce;
3917
3945
  const e = r.coefficient * (r.sourceCharge * r.targetCharge / (r.distance * r.distance));
3918
3946
  return Math.min(e, r.maxForce);
3919
3947
  };
3920
- class ir {
3948
+ class dr {
3921
3949
  constructor(e) {
3922
3950
  i(this, "nodeCharge");
3923
3951
  i(this, "distanceVectorGenerator");
@@ -3932,19 +3960,19 @@ class ir {
3932
3960
  const d = o[h], c = e.get(a), u = e.get(d), g = this.distanceVectorGenerator.create(
3933
3961
  c,
3934
3962
  u
3935
- ), l = He({
3963
+ ), l = Je({
3936
3964
  coefficient: 1,
3937
3965
  sourceCharge: this.nodeCharge,
3938
3966
  targetCharge: this.nodeCharge,
3939
3967
  distance: g.d,
3940
3968
  maxForce: this.maxForce
3941
- }), w = l * g.ex, p = l * g.ey, y = t.get(a), f = t.get(d);
3942
- y.x -= w, y.y -= p, f.x += w, f.y += p;
3969
+ }), p = l * g.ex, w = l * g.ey, y = t.get(a), f = t.get(d);
3970
+ y.x -= p, y.y -= w, f.x += p, f.y += w;
3943
3971
  }
3944
3972
  }
3945
3973
  }
3946
3974
  }
3947
- const nr = (r) => {
3975
+ const cr = (r) => {
3948
3976
  if (r.size === 0)
3949
3977
  return {
3950
3978
  centerX: 0,
@@ -3962,7 +3990,7 @@ const nr = (r) => {
3962
3990
  radius: h / 2
3963
3991
  };
3964
3992
  };
3965
- class ar {
3993
+ class lr {
3966
3994
  constructor(e) {
3967
3995
  i(this, "root");
3968
3996
  i(this, "leaves", /* @__PURE__ */ new Map());
@@ -4017,8 +4045,8 @@ class ar {
4017
4045
  this.sortedParentNodes.push(e);
4018
4046
  const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c = s / 2;
4019
4047
  e.nodeIds.forEach((l) => {
4020
- const { x: w, y: p } = this.coords.get(l);
4021
- w < t ? p < o ? d.add(l) : h.add(l) : p < o ? a.add(l) : n.add(l), e.nodeIds.delete(l);
4048
+ const { x: p, y: w } = this.coords.get(l);
4049
+ p < t ? w < o ? d.add(l) : h.add(l) : w < o ? a.add(l) : n.add(l), e.nodeIds.delete(l);
4022
4050
  });
4023
4051
  const u = {
4024
4052
  parent: e,
@@ -4119,7 +4147,7 @@ class ar {
4119
4147
  }), { x: t / e.size, y: o / e.size };
4120
4148
  }
4121
4149
  }
4122
- class hr {
4150
+ class ur {
4123
4151
  constructor(e) {
4124
4152
  i(this, "areaRadiusThreshold");
4125
4153
  i(this, "nodeMass");
@@ -4131,7 +4159,7 @@ class hr {
4131
4159
  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;
4132
4160
  }
4133
4161
  apply(e, t) {
4134
- const o = nr(e), s = new ar({
4162
+ const o = cr(e), s = new lr({
4135
4163
  box: o,
4136
4164
  coords: e,
4137
4165
  areaRadiusThreshold: this.areaRadiusThreshold,
@@ -4246,7 +4274,7 @@ class hr {
4246
4274
  const t = this.distanceVectorGenerator.create(
4247
4275
  e.sourceCoords,
4248
4276
  e.targetCoords
4249
- ), o = He({
4277
+ ), o = Je({
4250
4278
  coefficient: this.nodeForceCoefficient,
4251
4279
  sourceCharge: e.sourceCharge,
4252
4280
  targetCharge: e.targetCharge,
@@ -4281,7 +4309,7 @@ class hr {
4281
4309
  }
4282
4310
  }
4283
4311
  }
4284
- const Ge = (r) => r.theta !== 0 ? new hr({
4312
+ const Ke = (r) => r.theta !== 0 ? new ur({
4285
4313
  nodeCharge: r.nodeCharge,
4286
4314
  nodeForceCoefficient: r.nodeForceCoefficient,
4287
4315
  distanceVectorGenerator: r.distanceVectorGenerator,
@@ -4289,36 +4317,36 @@ const Ge = (r) => r.theta !== 0 ? new hr({
4289
4317
  theta: r.theta,
4290
4318
  nodeMass: r.nodeMass,
4291
4319
  areaRadiusThreshold: r.areaRadiusThreshold
4292
- }) : new ir({
4320
+ }) : new dr({
4293
4321
  nodeCharge: r.nodeCharge,
4294
4322
  nodeForceCoefficient: r.nodeForceCoefficient,
4295
4323
  distanceVectorGenerator: r.distanceVectorGenerator,
4296
4324
  maxForce: r.maxForce
4297
4325
  });
4298
- class je {
4326
+ class Qe {
4299
4327
  constructor(e) {
4300
4328
  i(this, "rand");
4301
4329
  i(this, "sparsity");
4302
4330
  this.rand = e.rand, this.sparsity = e.sparsity;
4303
4331
  }
4304
4332
  calculateCoordinates(e) {
4305
- const { graph: t, viewport: o } = e, s = /* @__PURE__ */ new Map(), n = t.getAllNodeIds().filter((p) => {
4306
- const y = t.getNode(p);
4333
+ const { graph: t, viewport: o } = e, s = /* @__PURE__ */ new Map(), n = t.getAllNodeIds().filter((w) => {
4334
+ const y = t.getNode(w);
4307
4335
  return y.x === null || y.y === null;
4308
4336
  }), a = Math.sqrt(n.length) * this.sparsity, { width: h, height: d } = o.getDimensions(), c = { x: h / 2, y: d / 2 }, u = o.createContentCoords(c), g = a / 2, l = {
4309
4337
  x: u.x - g,
4310
4338
  y: u.y - g
4311
4339
  };
4312
- return t.getAllNodeIds().forEach((p) => {
4313
- const y = t.getNode(p);
4314
- s.set(p, {
4340
+ return t.getAllNodeIds().forEach((w) => {
4341
+ const y = t.getNode(w);
4342
+ s.set(w, {
4315
4343
  x: y.x ?? l.x + a * this.rand(),
4316
4344
  y: y.y ?? l.y + a * this.rand()
4317
4345
  });
4318
4346
  }), s;
4319
4347
  }
4320
4348
  }
4321
- class dr {
4349
+ class gr {
4322
4350
  constructor(e) {
4323
4351
  i(this, "distanceVectorGenerator");
4324
4352
  i(this, "nodeForcesApplicationStrategy");
@@ -4329,7 +4357,7 @@ class dr {
4329
4357
  i(this, "edgeEquilibriumLength");
4330
4358
  i(this, "edgeStiffness");
4331
4359
  i(this, "convergenceVelocity");
4332
- 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({
4360
+ 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({
4333
4361
  distanceVectorGenerator: this.distanceVectorGenerator,
4334
4362
  nodeCharge: e.nodeCharge,
4335
4363
  maxForce: e.maxForce,
@@ -4337,7 +4365,7 @@ class dr {
4337
4365
  theta: e.barnesHutTheta,
4338
4366
  areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
4339
4367
  nodeMass: e.nodeMass
4340
- }), this.fillerLayoutAlgorithm = new je({
4368
+ }), this.fillerLayoutAlgorithm = new Qe({
4341
4369
  rand: e.rand,
4342
4370
  sparsity: e.edgeEquilibriumLength
4343
4371
  });
@@ -4347,7 +4375,7 @@ class dr {
4347
4375
  graph: t,
4348
4376
  viewport: o
4349
4377
  });
4350
- for (let n = 0; n < this.maxIterations && !(new Ye(
4378
+ for (let n = 0; n < this.maxIterations && !(new Ge(
4351
4379
  t,
4352
4380
  s,
4353
4381
  {
@@ -4363,7 +4391,7 @@ class dr {
4363
4391
  return s;
4364
4392
  }
4365
4393
  }
4366
- class cr {
4394
+ class pr {
4367
4395
  constructor(e, t) {
4368
4396
  i(this, "forest", /* @__PURE__ */ new Set());
4369
4397
  i(this, "remainingNodeIds");
@@ -4404,7 +4432,7 @@ class cr {
4404
4432
  }
4405
4433
  }
4406
4434
  }
4407
- class lr {
4435
+ class wr {
4408
4436
  constructor(e) {
4409
4437
  this.params = e;
4410
4438
  }
@@ -4445,12 +4473,12 @@ class lr {
4445
4473
  return o - 2 * this.params.spaceAroundRadius;
4446
4474
  }
4447
4475
  }
4448
- class ur {
4476
+ class yr {
4449
4477
  constructor(e, t) {
4450
4478
  i(this, "offsets", /* @__PURE__ */ new Map());
4451
4479
  i(this, "treeSpans", /* @__PURE__ */ new Map());
4452
4480
  this.tree = e;
4453
- const o = t.spaceAroundRadius, s = new lr({
4481
+ const o = t.spaceAroundRadius, s = new wr({
4454
4482
  spaceAroundRadius: o
4455
4483
  });
4456
4484
  [...this.tree.sequence].reverse().forEach((n) => {
@@ -4472,19 +4500,19 @@ class ur {
4472
4500
  return this.offsets;
4473
4501
  }
4474
4502
  }
4475
- class gr {
4503
+ class fr {
4476
4504
  constructor(e) {
4477
4505
  this.params = e;
4478
4506
  }
4479
4507
  calculateCoordinates(e) {
4480
- const t = /* @__PURE__ */ new Map(), s = new cr(
4508
+ const t = /* @__PURE__ */ new Map(), s = new pr(
4481
4509
  e.graph,
4482
4510
  this.params.nextLayerNodesResolver
4483
4511
  ).generate();
4484
4512
  let n = 0;
4485
4513
  return s.forEach((a) => {
4486
4514
  t.set(a.root.nodeId, { x: n, y: 0 });
4487
- const d = new ur(a, {
4515
+ const d = new yr(a, {
4488
4516
  spaceAroundRadius: this.params.layerSpace / 2
4489
4517
  }).generate();
4490
4518
  let c = [a.root];
@@ -4492,9 +4520,9 @@ class gr {
4492
4520
  const u = [];
4493
4521
  n += this.params.layerWidth, c.forEach((g) => {
4494
4522
  g.children.forEach((l) => {
4495
- const w = t.get(g.nodeId).y;
4523
+ const p = t.get(g.nodeId).y;
4496
4524
  t.set(l.nodeId, {
4497
- y: w + d.get(l.nodeId),
4525
+ y: p + d.get(l.nodeId),
4498
4526
  x: n
4499
4527
  }), u.push(l);
4500
4528
  });
@@ -4505,7 +4533,7 @@ class gr {
4505
4533
  }), t;
4506
4534
  }
4507
4535
  }
4508
- const pr = (r) => {
4536
+ const vr = (r) => {
4509
4537
  const { graph: e, currentNodeId: t } = r, o = e.getNodeOutgoingEdgeIds(t).map((n) => {
4510
4538
  const a = e.getEdge(n);
4511
4539
  return e.getPort(a.to).nodeId;
@@ -4514,20 +4542,20 @@ const pr = (r) => {
4514
4542
  return e.getPort(a.from).nodeId;
4515
4543
  });
4516
4544
  return /* @__PURE__ */ new Set([...o, ...s]);
4517
- }, wr = (r) => {
4545
+ }, mr = (r) => {
4518
4546
  const { graph: e, currentNodeId: t } = r, o = e.getNodeOutgoingEdgeIds(t).map((s) => {
4519
4547
  const n = e.getEdge(s);
4520
4548
  return e.getPort(n.to).nodeId;
4521
4549
  });
4522
4550
  return new Set(o);
4523
- }, yr = (r) => {
4551
+ }, xr = (r) => {
4524
4552
  const { graph: e, currentNodeId: t } = r, o = e.getNodeIncomingEdgeIds(t).map((s) => {
4525
4553
  const n = e.getEdge(s);
4526
4554
  return e.getPort(n.from).nodeId;
4527
4555
  });
4528
4556
  return new Set(o);
4529
4557
  };
4530
- class fr {
4558
+ class Er {
4531
4559
  constructor(e) {
4532
4560
  i(this, "distanceVectorGenerator");
4533
4561
  i(this, "nodeForcesApplicationStrategy");
@@ -4537,7 +4565,7 @@ class fr {
4537
4565
  i(this, "edgeEquilibriumLength");
4538
4566
  i(this, "edgeStiffness");
4539
4567
  i(this, "fillerLayoutAlgorithm");
4540
- 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({
4568
+ 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({
4541
4569
  distanceVectorGenerator: this.distanceVectorGenerator,
4542
4570
  nodeCharge: e.nodeCharge,
4543
4571
  maxForce: e.maxForce,
@@ -4545,7 +4573,7 @@ class fr {
4545
4573
  theta: e.barnesHutTheta,
4546
4574
  areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
4547
4575
  nodeMass: e.nodeMass
4548
- }), this.fillerLayoutAlgorithm = new je({
4576
+ }), this.fillerLayoutAlgorithm = new Qe({
4549
4577
  rand: e.rand,
4550
4578
  sparsity: e.edgeEquilibriumLength
4551
4579
  });
@@ -4555,7 +4583,7 @@ class fr {
4555
4583
  graph: t,
4556
4584
  viewport: o
4557
4585
  });
4558
- return new Ye(
4586
+ return new Ge(
4559
4587
  t,
4560
4588
  n,
4561
4589
  {
@@ -4572,96 +4600,70 @@ class fr {
4572
4600
  }) ? /* @__PURE__ */ new Map() : n;
4573
4601
  }
4574
4602
  }
4575
- const Je = (r) => {
4603
+ const Ze = (r) => {
4576
4604
  let e = 1779033703, t = 3144134277, o = 1013904242, s = 2773480762;
4577
4605
  for (let n = 0, a; n < r.length; n++)
4578
4606
  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);
4579
4607
  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];
4580
- }, Ke = (r, e, t, o) => function() {
4608
+ }, _e = (r, e, t, o) => function() {
4581
4609
  r |= 0, e |= 0, t |= 0, o |= 0;
4582
4610
  const s = (r + e | 0) + o | 0;
4583
4611
  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;
4584
- }, A = Object.freeze({
4585
- seed: "HTMLGraph is awesome",
4586
- maxTimeDeltaSec: 0.01,
4587
- nodeCharge: 1e5,
4588
- nodeMass: 1,
4589
- edgeEquilibriumLength: 300,
4590
- edgeStiffness: 1e3,
4591
- dtSec: 0.01,
4592
- maxIterations: 1e3,
4593
- convergenceVelocity: 10,
4594
- maxForce: 1e7,
4595
- nodeForceCoefficient: 1,
4596
- barnesHutAreaRadiusThreshold: 0.01,
4597
- barnesHutTheta: 1
4598
- }), V = Object.freeze({
4599
- mouseDownEventVerifier: (r) => r.button === 0,
4600
- mouseUpEventVerifier: (r) => r.button === 0,
4601
- movementThreshold: 10
4602
- }), vr = (r) => {
4612
+ }, Ar = (r) => {
4603
4613
  var e, t;
4604
4614
  switch (r == null ? void 0 : r.type) {
4605
4615
  case "custom":
4606
4616
  return r.instance;
4607
4617
  default: {
4608
- const o = Je((r == null ? void 0 : r.seed) ?? A.seed), s = Ke(o[0], o[1], o[2], o[3]);
4609
- return new fr({
4618
+ const o = Ze((r == null ? void 0 : r.seed) ?? b.seed), s = _e(o[0], o[1], o[2], o[3]);
4619
+ return new Er({
4610
4620
  rand: s,
4611
- maxTimeDeltaSec: (r == null ? void 0 : r.maxTimeDeltaSec) ?? A.maxTimeDeltaSec,
4612
- nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? A.nodeCharge,
4613
- nodeMass: (r == null ? void 0 : r.nodeMass) ?? A.nodeMass,
4614
- edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? A.edgeEquilibriumLength,
4615
- edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? A.edgeStiffness,
4616
- convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? A.convergenceVelocity,
4617
- maxForce: (r == null ? void 0 : r.maxForce) ?? A.maxForce,
4618
- nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? A.nodeForceCoefficient,
4619
- barnesHutTheta: ((e = r == null ? void 0 : r.barnesHut) == null ? void 0 : e.theta) ?? A.barnesHutTheta,
4620
- barnesHutAreaRadiusThreshold: ((t = r == null ? void 0 : r.barnesHut) == null ? void 0 : t.areaRadiusThreshold) ?? A.barnesHutAreaRadiusThreshold
4621
+ maxTimeDeltaSec: (r == null ? void 0 : r.maxTimeDeltaSec) ?? b.maxTimeDeltaSec,
4622
+ nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? b.nodeCharge,
4623
+ nodeMass: (r == null ? void 0 : r.nodeMass) ?? b.nodeMass,
4624
+ edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? b.edgeEquilibriumLength,
4625
+ edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? b.edgeStiffness,
4626
+ convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? b.convergenceVelocity,
4627
+ maxForce: (r == null ? void 0 : r.maxForce) ?? b.maxForce,
4628
+ nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? b.nodeForceCoefficient,
4629
+ barnesHutTheta: ((e = r == null ? void 0 : r.barnesHut) == null ? void 0 : e.theta) ?? b.barnesHutTheta,
4630
+ barnesHutAreaRadiusThreshold: ((t = r == null ? void 0 : r.barnesHut) == null ? void 0 : t.areaRadiusThreshold) ?? b.barnesHutAreaRadiusThreshold
4621
4631
  });
4622
4632
  }
4623
4633
  }
4624
- }, K = {
4625
- staticNodeResolver: () => !1,
4626
- onBeforeApplied: () => {
4627
- },
4628
- onAfterApplied: () => {
4629
- }
4630
- }, mr = (r) => {
4634
+ }, Sr = {
4635
+ staticNodeResolver: () => !1
4636
+ }, br = (r) => {
4631
4637
  var t, o;
4632
4638
  return {
4633
- algorithm: vr((r == null ? void 0 : r.algorithm) ?? {}),
4634
- staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? K.staticNodeResolver,
4635
- onBeforeApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeApplied) ?? K.onBeforeApplied,
4636
- onAfterApplied: ((o = r == null ? void 0 : r.events) == null ? void 0 : o.onAfterApplied) ?? K.onAfterApplied
4639
+ algorithm: Ar((r == null ? void 0 : r.algorithm) ?? {}),
4640
+ staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? Sr.staticNodeResolver,
4641
+ onBeforeApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeApplied) ?? N,
4642
+ onAfterApplied: ((o = r == null ? void 0 : r.events) == null ? void 0 : o.onAfterApplied) ?? N
4637
4643
  };
4638
- }, xr = (r) => r instanceof _ ? {
4644
+ }, Nr = (r) => r instanceof q ? {
4639
4645
  type: "trigger",
4640
4646
  trigger: r
4641
4647
  } : (r == null ? void 0 : r.type) === "topologyChangeMacrotask" ? {
4642
4648
  type: "topologyChangeSchedule",
4643
- schedule: Ft
4649
+ schedule: Bt
4644
4650
  } : {
4645
4651
  type: "topologyChangeSchedule",
4646
- schedule: Ut
4647
- }, $ = Object.freeze({
4652
+ schedule: Ot
4653
+ }, Z = Object.freeze({
4648
4654
  staticNodeResolver: () => !1,
4649
- onBeforeApplied: () => {
4650
- },
4651
- onAfterApplied: () => {
4652
- },
4653
4655
  hierarchicalLayout: {
4654
4656
  layerWidth: 300,
4655
4657
  layerSpace: 300
4656
4658
  }
4657
- }), z = (r, e) => ({
4659
+ }), k = (r, e) => ({
4658
4660
  a: r.a * e.a + r.b * e.d,
4659
4661
  b: r.a * e.b + r.b * e.e,
4660
4662
  c: r.a * e.c + r.b * e.f + r.c,
4661
4663
  d: r.d * e.a + r.e * e.d,
4662
4664
  e: r.d * e.b + r.e * e.e,
4663
4665
  f: r.d * e.c + r.e * e.f + r.f
4664
- }), Er = (r) => {
4666
+ }), Pr = (r) => {
4665
4667
  const { a: e, b: t, c: o, d: s, e: n, f: a } = r, h = e * n - t * s;
4666
4668
  return {
4667
4669
  a: n / h,
@@ -4672,7 +4674,7 @@ const Je = (r) => {
4672
4674
  f: (o * s - e * a) / h
4673
4675
  };
4674
4676
  };
4675
- class Ar {
4677
+ class Tr {
4676
4678
  resolve(e) {
4677
4679
  if ("shift" in e)
4678
4680
  return this.createShiftBaseMatrix(e.shift);
@@ -4706,18 +4708,18 @@ class Ar {
4706
4708
  return this.createRelativeTransform(o, s);
4707
4709
  }
4708
4710
  createMirrorRelativeMatrix(e, t) {
4709
- const o = this.createMirrorYBaseMatrix(), s = z(
4711
+ const o = this.createMirrorYBaseMatrix(), s = k(
4710
4712
  this.createShiftBaseMatrix(t),
4711
4713
  this.createRotateBaseMatrix(e)
4712
4714
  );
4713
4715
  return this.createRelativeTransform(o, s);
4714
4716
  }
4715
4717
  createRelativeTransform(e, t) {
4716
- const o = z(
4718
+ const o = k(
4717
4719
  t,
4718
4720
  e
4719
- ), s = Er(t);
4720
- return z(o, s);
4721
+ ), s = Pr(t);
4722
+ return k(o, s);
4721
4723
  }
4722
4724
  createShiftBaseMatrix(e) {
4723
4725
  return {
@@ -4761,7 +4763,7 @@ class Ar {
4761
4763
  };
4762
4764
  }
4763
4765
  }
4764
- const Sr = (r) => {
4766
+ const Cr = (r) => {
4765
4767
  if (r === void 0)
4766
4768
  return (s) => s;
4767
4769
  if (typeof r == "function")
@@ -4775,10 +4777,10 @@ const Sr = (r) => {
4775
4777
  e: 1,
4776
4778
  f: 0
4777
4779
  };
4778
- const o = new Ar();
4780
+ const o = new Tr();
4779
4781
  return e.forEach((s) => {
4780
4782
  const n = o.resolve(s);
4781
- t = z(t, n);
4783
+ t = k(t, n);
4782
4784
  }), (s) => {
4783
4785
  const { x: n, y: a } = s;
4784
4786
  return {
@@ -4786,59 +4788,59 @@ const Sr = (r) => {
4786
4788
  y: t.d * n + t.e * a + t.f
4787
4789
  };
4788
4790
  };
4789
- }, Nr = (r) => {
4791
+ }, Mr = (r) => {
4790
4792
  if (typeof r == "function")
4791
4793
  return r;
4792
4794
  switch (r) {
4793
4795
  case "outgoing":
4794
- return wr;
4796
+ return mr;
4795
4797
  case "incoming":
4796
- return yr;
4798
+ return xr;
4797
4799
  default:
4798
- return pr;
4800
+ return vr;
4799
4801
  }
4800
- }, br = (r) => {
4802
+ }, Dr = (r) => {
4801
4803
  var e, t;
4802
4804
  switch (r == null ? void 0 : r.type) {
4803
4805
  case "custom":
4804
4806
  return r.instance;
4805
4807
  case "hierarchical":
4806
- return new gr({
4807
- layerWidth: r.layerWidth ?? $.hierarchicalLayout.layerWidth,
4808
- layerSpace: r.layerSpace ?? $.hierarchicalLayout.layerSpace,
4809
- transform: Sr(r.transform),
4810
- nextLayerNodesResolver: Nr(
4808
+ return new fr({
4809
+ layerWidth: r.layerWidth ?? Z.hierarchicalLayout.layerWidth,
4810
+ layerSpace: r.layerSpace ?? Z.hierarchicalLayout.layerSpace,
4811
+ transform: Cr(r.transform),
4812
+ nextLayerNodesResolver: Mr(
4811
4813
  r.nextLayerNodesResolver
4812
4814
  )
4813
4815
  });
4814
4816
  default: {
4815
- const o = Je((r == null ? void 0 : r.seed) ?? A.seed), s = Ke(o[0], o[1], o[2], o[3]);
4816
- return new dr({
4817
- dtSec: (r == null ? void 0 : r.dtSec) ?? A.dtSec,
4818
- maxIterations: (r == null ? void 0 : r.maxIterations) ?? A.maxIterations,
4817
+ const o = Ze((r == null ? void 0 : r.seed) ?? b.seed), s = _e(o[0], o[1], o[2], o[3]);
4818
+ return new gr({
4819
+ dtSec: (r == null ? void 0 : r.dtSec) ?? b.dtSec,
4820
+ maxIterations: (r == null ? void 0 : r.maxIterations) ?? b.maxIterations,
4819
4821
  rand: s,
4820
- nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? A.nodeCharge,
4821
- nodeMass: (r == null ? void 0 : r.nodeMass) ?? A.nodeMass,
4822
- edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? A.edgeEquilibriumLength,
4823
- edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? A.edgeStiffness,
4824
- convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? A.convergenceVelocity,
4825
- maxForce: (r == null ? void 0 : r.maxForce) ?? A.maxForce,
4826
- nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? A.nodeForceCoefficient,
4827
- barnesHutTheta: ((e = r == null ? void 0 : r.barnesHut) == null ? void 0 : e.theta) ?? A.barnesHutTheta,
4828
- barnesHutAreaRadiusThreshold: ((t = r == null ? void 0 : r.barnesHut) == null ? void 0 : t.areaRadiusThreshold) ?? A.barnesHutAreaRadiusThreshold
4822
+ nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? b.nodeCharge,
4823
+ nodeMass: (r == null ? void 0 : r.nodeMass) ?? b.nodeMass,
4824
+ edgeEquilibriumLength: (r == null ? void 0 : r.edgeEquilibriumLength) ?? b.edgeEquilibriumLength,
4825
+ edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? b.edgeStiffness,
4826
+ convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? b.convergenceVelocity,
4827
+ maxForce: (r == null ? void 0 : r.maxForce) ?? b.maxForce,
4828
+ nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? b.nodeForceCoefficient,
4829
+ barnesHutTheta: ((e = r == null ? void 0 : r.barnesHut) == null ? void 0 : e.theta) ?? b.barnesHutTheta,
4830
+ barnesHutAreaRadiusThreshold: ((t = r == null ? void 0 : r.barnesHut) == null ? void 0 : t.areaRadiusThreshold) ?? b.barnesHutAreaRadiusThreshold
4829
4831
  });
4830
4832
  }
4831
4833
  }
4832
- }, Pr = (r) => {
4834
+ }, Rr = (r) => {
4833
4835
  var e, t;
4834
4836
  return {
4835
- algorithm: br(r.algorithm),
4836
- applyOn: xr(r.applyOn),
4837
- staticNodeResolver: r.staticNodeResolver ?? $.staticNodeResolver,
4838
- onBeforeApplied: ((e = r.events) == null ? void 0 : e.onBeforeApplied) ?? $.onBeforeApplied,
4839
- onAfterApplied: ((t = r.events) == null ? void 0 : t.onAfterApplied) ?? $.onAfterApplied
4837
+ algorithm: Dr(r.algorithm),
4838
+ applyOn: Nr(r.applyOn),
4839
+ staticNodeResolver: r.staticNodeResolver ?? Z.staticNodeResolver,
4840
+ onBeforeApplied: ((e = r.events) == null ? void 0 : e.onBeforeApplied) ?? N,
4841
+ onAfterApplied: ((t = r.events) == null ? void 0 : t.onAfterApplied) ?? N
4840
4842
  };
4841
- }, Tr = (r, e) => ({
4843
+ }, Lr = (r, e) => ({
4842
4844
  ...r,
4843
4845
  onNodeDragStarted: (t) => {
4844
4846
  e.add(t), r.onNodeDragStarted(t);
@@ -4846,7 +4848,7 @@ const Sr = (r) => {
4846
4848
  onNodeDragFinished: (t) => {
4847
4849
  e.delete(t), r.onNodeDragFinished(t);
4848
4850
  }
4849
- }), Cr = (r, e) => {
4851
+ }), Vr = (r, e) => {
4850
4852
  r.graph.onBeforeNodeRemoved.subscribe((t) => {
4851
4853
  e.delete(t);
4852
4854
  }), r.graph.onBeforeClear.subscribe(() => {
@@ -4854,41 +4856,41 @@ const Sr = (r) => {
4854
4856
  }), r.onBeforeDestroy.subscribe(() => {
4855
4857
  e.clear();
4856
4858
  });
4857
- }, Mr = (r, e) => ({
4859
+ }, Ir = (r, e) => ({
4858
4860
  ...r,
4859
4861
  staticNodeResolver: (t) => r.staticNodeResolver(t) || e.has(t)
4860
- }), Z = (r) => () => r, Se = Z(0), Dr = () => {
4862
+ }), _ = (r) => () => r, Pe = _(0), Fr = () => {
4861
4863
  let r = 0;
4862
4864
  return () => r++;
4863
- }, Lr = (r, e) => {
4864
- let t = Se, o = Se;
4865
- const s = Dr();
4866
- 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), {
4865
+ }, Ur = (r, e) => {
4866
+ let t = Pe, o = Pe;
4867
+ const s = Fr();
4868
+ return r === "incremental" && (t = s), e === "incremental" && (o = s), typeof r == "number" && (t = _(r)), typeof e == "number" && (o = _(e)), typeof r == "function" && (t = r), typeof e == "function" && (o = e), {
4867
4869
  nodesPriorityFn: t,
4868
4870
  edgesPriorityFn: o
4869
4871
  };
4870
- }, Rr = (r) => {
4872
+ }, $r = (r) => {
4871
4873
  var t, o, s, n, a;
4872
- const e = Lr(
4874
+ const e = Ur(
4873
4875
  (t = r.nodes) == null ? void 0 : t.priority,
4874
4876
  (o = r.edges) == null ? void 0 : o.priority
4875
4877
  );
4876
4878
  return {
4877
4879
  nodes: {
4878
- centerFn: ((s = r.nodes) == null ? void 0 : s.centerFn) ?? Me,
4880
+ centerFn: ((s = r.nodes) == null ? void 0 : s.centerFn) ?? Le,
4879
4881
  priorityFn: e.nodesPriorityFn
4880
4882
  },
4881
4883
  ports: {
4882
4884
  direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
4883
4885
  },
4884
4886
  edges: {
4885
- shapeFactory: ge(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
4887
+ shapeFactory: fe(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
4886
4888
  priorityFn: e.edgesPriorityFn
4887
4889
  }
4888
4890
  };
4889
- }, Vr = (r) => r.applyOn.type === "topologyChangeSchedule" ? r.applyOn.schedule : re, Ir = (r) => {
4891
+ }, Br = (r) => r.applyOn.type === "topologyChangeSchedule" ? r.applyOn.schedule : oe, Or = (r) => {
4890
4892
  var o, s, n, a;
4891
- const { canvasDefaults: e } = r, t = r.hasLayout ? Vr(r.layoutParams) : re;
4893
+ const { canvasDefaults: e } = r, t = r.hasLayout ? Br(r.layoutParams) : oe;
4892
4894
  return {
4893
4895
  focus: {
4894
4896
  contentPadding: ((o = e.focus) == null ? void 0 : o.contentPadding) ?? ((s = e.focus) == null ? void 0 : s.contentOffset) ?? 100,
@@ -4897,18 +4899,23 @@ const Sr = (r) => {
4897
4899
  animationDuration: ((a = e.focus) == null ? void 0 : a.animationDuration) ?? 0
4898
4900
  }
4899
4901
  };
4900
- }, Fr = (r) => ({
4902
+ }, Wr = (r) => ({
4901
4903
  onNodeSelected: r.onNodeSelected,
4902
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? V.mouseDownEventVerifier,
4903
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? V.mouseUpEventVerifier,
4904
- movementThreshold: r.movementThreshold ?? V.movementThreshold
4905
- }), Ur = (r) => ({
4904
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? L.mouseDownEventVerifier,
4905
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? L.mouseUpEventVerifier,
4906
+ movementThreshold: r.movementThreshold ?? L.movementThreshold
4907
+ }), zr = (r) => ({
4906
4908
  onCanvasSelected: r.onCanvasSelected,
4907
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? V.mouseDownEventVerifier,
4908
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? V.mouseUpEventVerifier,
4909
- movementThreshold: r.movementThreshold ?? V.movementThreshold
4909
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? L.mouseDownEventVerifier,
4910
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? L.mouseUpEventVerifier,
4911
+ movementThreshold: r.movementThreshold ?? L.movementThreshold
4912
+ }), kr = (r) => ({
4913
+ onEdgeSelected: r.onEdgeSelected,
4914
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? L.mouseDownEventVerifier,
4915
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? L.mouseUpEventVerifier,
4916
+ movementThreshold: r.movementThreshold ?? L.movementThreshold
4910
4917
  });
4911
- class Wr {
4918
+ class Xr {
4912
4919
  constructor(e) {
4913
4920
  i(this, "used", !1);
4914
4921
  i(this, "canvasDefaults", {});
@@ -4921,6 +4928,7 @@ class Wr {
4921
4928
  i(this, "layoutConfig", {});
4922
4929
  i(this, "animatedLayoutConfig", {});
4923
4930
  i(this, "userSelectableNodesConfig");
4931
+ i(this, "userSelectableEdgesConfig");
4924
4932
  i(this, "userSelectableCanvasConfig");
4925
4933
  i(this, "hasDraggableNodes", !1);
4926
4934
  i(this, "hasTransformableViewport", !1);
@@ -4930,11 +4938,12 @@ class Wr {
4930
4938
  i(this, "hasUserDraggableEdges", !1);
4931
4939
  i(this, "hasAnimatedLayout", !1);
4932
4940
  i(this, "hasLayout", !1);
4933
- i(this, "boxRenderingTrigger", new _());
4941
+ i(this, "boxRenderingTrigger", new q());
4934
4942
  i(this, "window", window);
4935
4943
  i(this, "animationStaticNodes", /* @__PURE__ */ new Set());
4936
4944
  i(this, "pointInsideVerifier");
4937
- this.element = e, this.pointInsideVerifier = new dt(e, this.window);
4945
+ i(this, "eventTagger", new zt());
4946
+ this.element = e, this.pointInsideVerifier = new ut(e, this.window);
4938
4947
  }
4939
4948
  setDefaults(e) {
4940
4949
  return this.canvasDefaults = e, this;
@@ -4969,73 +4978,90 @@ class Wr {
4969
4978
  enableUserSelectableNodes(e) {
4970
4979
  return this.userSelectableNodesConfig = e, this;
4971
4980
  }
4981
+ enableUserSelectableEdges(e) {
4982
+ return this.userSelectableEdgesConfig = e, this;
4983
+ }
4972
4984
  enableUserSelectableCanvas(e) {
4973
4985
  return this.userSelectableCanvasConfig = e, this;
4974
4986
  }
4975
4987
  build() {
4976
4988
  if (this.used)
4977
- throw new sr(
4989
+ throw new hr(
4978
4990
  "Failed to build Canvas because CanvasBuilder is a single-use object"
4979
4991
  );
4980
4992
  this.used = !0;
4981
- const e = new nt(this.element), t = new Pe(), o = new Gt(this.element), s = this.createHtmlView(
4993
+ const e = new dt(this.element), t = new Me(), o = new Qt(this.element), s = this.createHtmlView(
4982
4994
  o.main,
4983
4995
  t,
4984
4996
  e
4985
- ), n = Rr(
4997
+ ), n = $r(
4986
4998
  this.canvasDefaults
4987
- ), a = new $e(
4999
+ ), a = new We(
4988
5000
  t,
4989
5001
  s,
4990
5002
  n
4991
- ), h = Pr(this.layoutConfig), d = Ir({
5003
+ ), h = Rr(this.layoutConfig), d = Or({
4992
5004
  canvasDefaults: this.canvasDefaults,
4993
5005
  hasLayout: this.hasLayout,
4994
5006
  layoutParams: h
4995
- }), c = new ze(
5007
+ }), c = new Ye(
4996
5008
  t,
4997
5009
  e,
4998
5010
  d,
4999
5011
  this.window
5000
- ), u = new Be(e), g = new Ue(t), l = new be(
5012
+ ), u = new ze(e), g = new Oe(t), l = new Ce(
5001
5013
  g,
5002
5014
  u,
5003
5015
  a,
5004
5016
  c
5005
5017
  );
5006
- if (this.hasBackground && ie.configure(
5018
+ if (this.hasBackground && he.configure(
5007
5019
  l,
5008
- qt(this.backgroundConfig),
5020
+ or(this.backgroundConfig),
5009
5021
  o.background
5010
- ), this.hasNodeResizeReactiveEdges && q.configure(l), this.userSelectableNodesConfig !== void 0) {
5011
- const p = Fr(
5022
+ ), this.hasNodeResizeReactiveEdges && ee.configure(l), this.userSelectableEdgesConfig !== void 0) {
5023
+ const p = kr(
5024
+ this.userSelectableEdgesConfig
5025
+ );
5026
+ we.configure(
5027
+ l,
5028
+ this.window,
5029
+ this.pointInsideVerifier,
5030
+ this.eventTagger,
5031
+ p
5032
+ );
5033
+ }
5034
+ if (this.userSelectableNodesConfig !== void 0) {
5035
+ const p = Wr(
5012
5036
  this.userSelectableNodesConfig
5013
5037
  );
5014
- le.configure(
5038
+ pe.configure(
5015
5039
  l,
5016
5040
  this.window,
5017
5041
  this.pointInsideVerifier,
5042
+ this.eventTagger,
5018
5043
  p
5019
5044
  );
5020
5045
  }
5021
5046
  if (this.userSelectableCanvasConfig !== void 0) {
5022
- const p = Ur(
5047
+ const p = zr(
5023
5048
  this.userSelectableCanvasConfig
5024
5049
  );
5025
- ue.configure(
5050
+ ye.configure(
5026
5051
  l,
5027
5052
  o.main,
5028
5053
  this.window,
5029
5054
  this.pointInsideVerifier,
5055
+ this.eventTagger,
5030
5056
  p
5031
5057
  );
5032
5058
  }
5033
5059
  if (this.hasDraggableNodes) {
5034
- let p = jt(this.dragConfig);
5035
- this.hasAnimatedLayout && (p = Tr(
5060
+ let p = Zt(this.dragConfig);
5061
+ this.hasAnimatedLayout && (p = Lr(
5036
5062
  p,
5037
5063
  this.animationStaticNodes
5038
- )), oe.configure(
5064
+ )), ne.configure(
5039
5065
  l,
5040
5066
  o.main,
5041
5067
  this.window,
@@ -5044,12 +5070,12 @@ class Wr {
5044
5070
  );
5045
5071
  }
5046
5072
  if (this.hasUserConnectablePorts) {
5047
- const p = er(
5073
+ const p = sr(
5048
5074
  this.connectablePortsConfig,
5049
5075
  n.edges.shapeFactory,
5050
5076
  n.ports.direction
5051
5077
  );
5052
- ne.configure(
5078
+ de.configure(
5053
5079
  l,
5054
5080
  o.overlayConnectablePorts,
5055
5081
  e,
@@ -5059,11 +5085,11 @@ class Wr {
5059
5085
  );
5060
5086
  }
5061
5087
  if (this.hasUserDraggableEdges) {
5062
- const p = tr(
5088
+ const p = ir(
5063
5089
  this.draggableEdgesConfig,
5064
5090
  l.graph
5065
5091
  );
5066
- ae.configure(
5092
+ ce.configure(
5067
5093
  l,
5068
5094
  o.overlayDraggableEdges,
5069
5095
  e,
@@ -5072,59 +5098,56 @@ class Wr {
5072
5098
  p
5073
5099
  );
5074
5100
  }
5075
- if (this.virtualScrollConfig !== void 0 ? se.configure(
5101
+ if (this.virtualScrollConfig !== void 0 ? ae.configure(
5076
5102
  l,
5077
5103
  o.main,
5078
5104
  this.window,
5079
- Ae(this.transformConfig),
5105
+ Ne(this.transformConfig),
5080
5106
  this.boxRenderingTrigger,
5081
5107
  this.pointInsideVerifier,
5082
- rr(this.virtualScrollConfig)
5083
- ) : this.hasTransformableViewport && j.configure(
5108
+ nr(this.virtualScrollConfig)
5109
+ ) : this.hasTransformableViewport && J.configure(
5084
5110
  l,
5085
5111
  o.main,
5086
5112
  this.window,
5087
5113
  this.pointInsideVerifier,
5088
- Ae(this.transformConfig)
5089
- ), this.hasLayout && Yt.configure(l, h), this.hasAnimatedLayout) {
5090
- let p = mr(
5091
- this.animatedLayoutConfig
5092
- );
5093
- this.hasDraggableNodes && (Cr(
5114
+ Ne(this.transformConfig)
5115
+ ), this.hasLayout && Gt.configure(l, h), this.hasAnimatedLayout) {
5116
+ let p = br(this.animatedLayoutConfig);
5117
+ this.hasDraggableNodes && (Vr(
5094
5118
  l,
5095
5119
  this.animationStaticNodes
5096
- ), p = Mr(
5120
+ ), p = Ir(
5097
5121
  p,
5098
5122
  this.animationStaticNodes
5099
- )), ce.configure(l, p, this.window);
5123
+ )), ge.configure(l, p, this.window);
5100
5124
  }
5101
- const w = () => {
5102
- o.destroy(), l.onBeforeDestroy.unsubscribe(w);
5103
- };
5104
- return l.onBeforeDestroy.subscribe(w), l;
5125
+ return l.onBeforeDestroy.subscribe(() => {
5126
+ o.destroy();
5127
+ }), l;
5105
5128
  }
5106
5129
  createHtmlView(e, t, o) {
5107
- let s = new Ne(t, o, e);
5108
- return this.virtualScrollConfig !== void 0 && (s = new ot(
5130
+ let s = new Te(t, o, e);
5131
+ return this.virtualScrollConfig !== void 0 && (s = new nt(
5109
5132
  s,
5110
5133
  t,
5111
5134
  this.boxRenderingTrigger,
5112
- or(this.virtualScrollConfig)
5113
- )), s = new st(s, t), s;
5135
+ ar(this.virtualScrollConfig)
5136
+ )), s = new at(s, t), s;
5114
5137
  }
5115
5138
  }
5116
5139
  export {
5117
- Ct as BezierEdgeShape,
5118
- Wr as CanvasBuilder,
5119
- sr as CanvasBuilderError,
5120
- S as CanvasError,
5121
- R as ConnectionCategory,
5122
- Ie as DirectEdgeShape,
5123
- _ as EventSubject,
5124
- Mt as HorizontalEdgeShape,
5125
- It as InteractiveEdgeError,
5126
- Fe as InteractiveEdgeShape,
5127
- Br as MidpointEdgeShape,
5128
- Dt as StraightEdgeShape,
5129
- Lt as VerticalEdgeShape
5140
+ Rt as BezierEdgeShape,
5141
+ Xr as CanvasBuilder,
5142
+ hr as CanvasBuilderError,
5143
+ A as CanvasError,
5144
+ I as ConnectionCategory,
5145
+ $e as DirectEdgeShape,
5146
+ q as EventSubject,
5147
+ Lt as HorizontalEdgeShape,
5148
+ $t as InteractiveEdgeError,
5149
+ Be as InteractiveEdgeShape,
5150
+ Yr as MidpointEdgeShape,
5151
+ Vt as StraightEdgeShape,
5152
+ It as VerticalEdgeShape
5130
5153
  };