@html-graph/html-graph 3.8.0 → 3.10.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,21 +1,22 @@
1
- var ae = Object.defineProperty;
2
- var le = (t, e, o) => e in t ? ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
- var r = (t, e, o) => le(t, typeof e != "symbol" ? e + "" : e, o);
4
- const ue = () => {
1
+ var ye = Object.defineProperty;
2
+ var Ae = (t, e, o) => e in t ? ye(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var r = (t, e, o) => Ae(t, typeof e != "symbol" ? e + "" : e, o);
4
+ const pe = () => {
5
5
  const t = document.createElement("div");
6
6
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
7
- }, ge = () => {
8
- const t = document.createElement("div");
9
- return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
10
- }, we = () => {
7
+ }, Ee = () => {
11
8
  const t = document.createElement("div");
12
9
  return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
13
- };
14
- class ie {
10
+ }, xe = (t) => {
11
+ t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden";
12
+ }, N = (t, e) => ({
13
+ x: t.scale * e.x + t.x,
14
+ y: t.scale * e.y + t.y
15
+ });
16
+ class he {
15
17
  constructor(e, o, i) {
16
- r(this, "host", we());
17
- r(this, "container", ue());
18
- r(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
18
+ r(this, "host", Ee());
19
+ r(this, "container", pe());
19
20
  r(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
20
21
  r(this, "applyTransform", () => {
21
22
  const e = this.viewportStore.getContentMatrix();
@@ -24,12 +25,12 @@ class ie {
24
25
  this.graphStore = e, this.viewportStore = o, this.element = i, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
25
26
  }
26
27
  attachNode(e) {
27
- const o = this.graphStore.getNode(e), i = ge();
28
- i.appendChild(o.element), this.container.appendChild(i), this.nodeIdToWrapperElementMap.set(e, i), this.updateNodePosition(e), this.updateNodePriority(e), i.style.visibility = "visible";
28
+ const o = this.graphStore.getNode(e);
29
+ xe(o.element), this.container.appendChild(o.element), this.updateNodePosition(e), this.updateNodePriority(e), o.element.style.visibility = "visible";
29
30
  }
30
31
  detachNode(e) {
31
- const o = this.nodeIdToWrapperElementMap.get(e);
32
- o.removeChild(o.firstChild), this.container.removeChild(o), this.nodeIdToWrapperElementMap.delete(e);
32
+ const o = this.graphStore.getNode(e);
33
+ this.container.removeChild(o.element);
33
34
  }
34
35
  attachEdge(e) {
35
36
  const o = this.graphStore.getEdge(e).shape.svg;
@@ -42,20 +43,20 @@ class ie {
42
43
  clear() {
43
44
  this.edgeIdToElementMap.forEach((e, o) => {
44
45
  this.detachEdge(o);
45
- }), this.nodeIdToWrapperElementMap.forEach((e, o) => {
46
- this.detachNode(o);
46
+ }), this.graphStore.getAllNodeIds().forEach((e) => {
47
+ this.detachNode(e);
47
48
  });
48
49
  }
49
50
  destroy() {
50
51
  this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
51
52
  }
52
53
  updateNodePosition(e) {
53
- const o = this.nodeIdToWrapperElementMap.get(e), i = this.graphStore.getNode(e), { width: s, height: h } = i.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, d = i.centerFn(s, h), c = i.x - n * d.x, a = i.y - n * d.y;
54
- o.style.transform = `translate(${c}px, ${a}px)`;
54
+ const o = this.graphStore.getNode(e), { width: i, height: s } = o.element.getBoundingClientRect(), h = this.viewportStore.getViewportMatrix().scale, n = o.centerFn(i, s), d = o.x - h * n.x, c = o.y - h * n.y;
55
+ o.element.style.transform = `translate(${d}px, ${c}px)`;
55
56
  }
56
57
  updateNodePriority(e) {
57
- const o = this.graphStore.getNode(e), i = this.nodeIdToWrapperElementMap.get(e);
58
- i.style.zIndex = `${o.priority}`;
58
+ const o = this.graphStore.getNode(e);
59
+ o.element.style.zIndex = `${o.priority}`;
59
60
  }
60
61
  updateEdgeShape(e) {
61
62
  const o = this.edgeIdToElementMap.get(e);
@@ -64,37 +65,42 @@ class ie {
64
65
  this.edgeIdToElementMap.set(e, i.shape.svg), this.container.appendChild(i.shape.svg);
65
66
  }
66
67
  renderEdge(e) {
67
- const o = this.graphStore.getEdge(e), i = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), h = i.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = h.left - d.left, l = h.top - d.top, g = n.left - d.left, y = n.top - d.top, p = {
68
- x: c.scale * a + c.x,
69
- y: c.scale * l + c.y
70
- }, f = {
71
- x: c.scale * g + c.x,
72
- y: c.scale * y + c.y
73
- }, A = {
74
- x: p.x,
75
- y: p.y,
76
- width: h.width * c.scale,
77
- height: h.height * c.scale,
78
- direction: i.direction,
79
- portId: o.from,
80
- nodeId: i.nodeId
81
- }, E = {
82
- x: f.x,
83
- y: f.y,
84
- width: n.width * c.scale,
85
- height: n.height * c.scale,
86
- direction: s.direction,
87
- portId: o.to,
88
- nodeId: s.nodeId
89
- };
90
- o.shape.render({ from: A, to: E });
68
+ const o = this.graphStore.getEdge(e), i = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), h = i.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = this.createEdgeRenderPort(
69
+ o.from,
70
+ i,
71
+ h,
72
+ d,
73
+ c
74
+ ), l = this.createEdgeRenderPort(
75
+ o.to,
76
+ s,
77
+ n,
78
+ d,
79
+ c
80
+ );
81
+ o.shape.render({ from: a, to: l });
91
82
  }
92
83
  updateEdgePriority(e) {
93
84
  const o = this.graphStore.getEdge(e);
94
85
  o.shape.svg.style.zIndex = `${o.priority}`;
95
86
  }
87
+ createEdgeRenderPort(e, o, i, s, h) {
88
+ const n = {
89
+ x: i.left - s.left,
90
+ y: i.top - s.top
91
+ }, d = N(h, n);
92
+ return {
93
+ x: d.x,
94
+ y: d.y,
95
+ width: i.width * h.scale,
96
+ height: i.height * h.scale,
97
+ direction: o.direction,
98
+ portId: e,
99
+ nodeId: o.nodeId
100
+ };
101
+ }
96
102
  }
97
- class fe {
103
+ class Se {
98
104
  constructor(e) {
99
105
  r(this, "xFrom", 1 / 0);
100
106
  r(this, "yFrom", 1 / 0);
@@ -114,7 +120,7 @@ class fe {
114
120
  return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
115
121
  }
116
122
  }
117
- class ve {
123
+ class be {
118
124
  constructor(e, o, i) {
119
125
  r(this, "attachedNodes", /* @__PURE__ */ new Set());
120
126
  r(this, "attachedEdges", /* @__PURE__ */ new Set());
@@ -126,8 +132,8 @@ class ve {
126
132
  const d = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
127
133
  d && !c ? o.add(n) : !d && c && i.add(n);
128
134
  }), this.graphStore.getAllEdgeIds().forEach((n) => {
129
- const d = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
130
- d && (this.renderingBox.hasNode(l) || (o.add(l), i.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), i.delete(g))), d && !c ? s.add(n) : !d && c && h.add(n);
135
+ const d = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPort(a.from).nodeId, w = this.graphStore.getPort(a.to).nodeId;
136
+ d && (this.renderingBox.hasNode(l) || (o.add(l), i.delete(l)), this.renderingBox.hasNode(w) || (o.add(w), i.delete(w))), d && !c ? s.add(n) : !d && c && h.add(n);
131
137
  }), h.forEach((n) => {
132
138
  this.handleDetachEdge(n);
133
139
  }), i.forEach((n) => {
@@ -138,7 +144,7 @@ class ve {
138
144
  this.handleAttachEdge(n);
139
145
  });
140
146
  });
141
- this.htmlView = e, this.graphStore = o, this.trigger = i, this.renderingBox = new fe(this.graphStore), this.trigger.subscribe(this.updateViewport);
147
+ this.htmlView = e, this.graphStore = o, this.trigger = i, this.renderingBox = new Se(this.graphStore), this.trigger.subscribe(this.updateViewport);
142
148
  }
143
149
  attachNode(e) {
144
150
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -192,7 +198,7 @@ class ve {
192
198
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
193
199
  }
194
200
  }
195
- class se {
201
+ class de {
196
202
  constructor() {
197
203
  r(this, "callbacks", /* @__PURE__ */ new Set());
198
204
  }
@@ -209,10 +215,10 @@ class se {
209
215
  }
210
216
  }
211
217
  const x = () => {
212
- const t = new se();
218
+ const t = new de();
213
219
  return [t, t];
214
220
  };
215
- class ye {
221
+ class Te {
216
222
  constructor(e) {
217
223
  r(this, "onBeforeUpdated");
218
224
  r(this, "onAfterUpdated");
@@ -225,7 +231,7 @@ class ye {
225
231
  return { ...this.viewportStore.getContentMatrix() };
226
232
  }
227
233
  }
228
- class pe {
234
+ class Pe {
229
235
  constructor(e) {
230
236
  r(this, "onAfterNodeAdded");
231
237
  r(this, "onAfterNodeUpdated");
@@ -320,7 +326,7 @@ class pe {
320
326
  return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
321
327
  }
322
328
  }
323
- class C {
329
+ class W {
324
330
  constructor(e) {
325
331
  r(this, "counter", 0);
326
332
  this.checkExists = e;
@@ -342,7 +348,7 @@ class S extends Error {
342
348
  r(this, "name", "HtmlGraphError");
343
349
  }
344
350
  }
345
- class ne {
351
+ class ce {
346
352
  constructor(e, o, i, s, h) {
347
353
  /**
348
354
  * provides api for accessing model of rendered graph
@@ -352,13 +358,13 @@ class ne {
352
358
  * provides api for accessing viewport state
353
359
  */
354
360
  r(this, "viewport");
355
- r(this, "nodeIdGenerator", new C(
361
+ r(this, "nodeIdGenerator", new W(
356
362
  (e) => this.graph.getNode(e) !== null
357
363
  ));
358
- r(this, "portIdGenerator", new C(
364
+ r(this, "portIdGenerator", new W(
359
365
  (e) => this.graph.getPort(e) !== null
360
366
  ));
361
- r(this, "edgeIdGenerator", new C(
367
+ r(this, "edgeIdGenerator", new W(
362
368
  (e) => this.graph.getEdge(e) !== null
363
369
  ));
364
370
  r(this, "onAfterNodeAdded", (e) => {
@@ -410,7 +416,7 @@ class ne {
410
416
  * emits event just before destruction of canvas
411
417
  */
412
418
  r(this, "onBeforeDestroy");
413
- this.element = e, this.graphStore = o, this.viewportStore = i, this.htmlView = s, this.defaults = h, this.graph = new pe(this.graphStore), this.viewport = new ye(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
419
+ this.element = e, this.graphStore = o, this.viewportStore = i, this.htmlView = s, this.defaults = h, this.graph = new Pe(this.graphStore), this.viewport = new Te(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
414
420
  this.onAfterNodePriorityUpdated
415
421
  ), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
416
422
  this.onAfterEdgeShapeUpdated
@@ -425,6 +431,10 @@ class ne {
425
431
  const o = this.nodeIdGenerator.create(e.id);
426
432
  if (this.graph.getNode(o) !== null)
427
433
  throw new S("failed to add node with existing id");
434
+ if (this.graphStore.getElementNodeId(e.element) !== void 0)
435
+ throw new S(
436
+ "failed to add node with html element already in use by another node"
437
+ );
428
438
  if (this.graphStore.addNode({
429
439
  id: o,
430
440
  element: e.element,
@@ -561,7 +571,7 @@ class ne {
561
571
  ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
562
572
  }
563
573
  }
564
- class he {
574
+ class De {
565
575
  constructor() {
566
576
  r(this, "singleToMultiMap", /* @__PURE__ */ new Map());
567
577
  r(this, "multiToSingleMap", /* @__PURE__ */ new Map());
@@ -601,7 +611,7 @@ class he {
601
611
  return this.multiToSingleMap.get(e) !== void 0;
602
612
  }
603
613
  }
604
- class de {
614
+ class ae {
605
615
  constructor() {
606
616
  r(this, "nodes", /* @__PURE__ */ new Map());
607
617
  r(this, "ports", /* @__PURE__ */ new Map());
@@ -610,7 +620,7 @@ class de {
610
620
  r(this, "incomingEdges", /* @__PURE__ */ new Map());
611
621
  r(this, "outcomingEdges", /* @__PURE__ */ new Map());
612
622
  r(this, "cycleEdges", /* @__PURE__ */ new Map());
613
- r(this, "elementPorts", new he());
623
+ r(this, "elementPorts", new De());
614
624
  r(this, "afterNodeAddedEmitter");
615
625
  r(this, "onAfterNodeAdded");
616
626
  r(this, "afterNodeUpdatedEmitter");
@@ -783,19 +793,19 @@ class de {
783
793
  this.cycleEdges.get(i).delete(e), this.cycleEdges.get(s).delete(e), this.incomingEdges.get(i).delete(e), this.incomingEdges.get(s).delete(e), this.outcomingEdges.get(i).delete(e), this.outcomingEdges.get(s).delete(e), this.edges.delete(e);
784
794
  }
785
795
  }
786
- const K = (t) => ({
796
+ const q = (t) => ({
787
797
  scale: 1 / t.scale,
788
798
  x: -t.x / t.scale,
789
799
  y: -t.y / t.scale
790
- }), Q = {
800
+ }), ee = {
791
801
  scale: 1,
792
802
  x: 0,
793
803
  y: 0
794
804
  };
795
- class Ae {
805
+ class Ne {
796
806
  constructor() {
797
- r(this, "viewportMatrix", Q);
798
- r(this, "contentMatrix", Q);
807
+ r(this, "viewportMatrix", ee);
808
+ r(this, "contentMatrix", ee);
799
809
  r(this, "afterUpdateEmitter");
800
810
  r(this, "onAfterUpdated");
801
811
  r(this, "beforeUpdateEmitter");
@@ -813,17 +823,17 @@ class Ae {
813
823
  scale: e.scale ?? this.viewportMatrix.scale,
814
824
  x: e.x ?? this.viewportMatrix.x,
815
825
  y: e.y ?? this.viewportMatrix.y
816
- }, this.contentMatrix = K(this.viewportMatrix), this.afterUpdateEmitter.emit();
826
+ }, this.contentMatrix = q(this.viewportMatrix), this.afterUpdateEmitter.emit();
817
827
  }
818
828
  patchContentMatrix(e) {
819
829
  this.beforeUpdateEmitter.emit(), this.contentMatrix = {
820
830
  scale: e.scale ?? this.contentMatrix.scale,
821
831
  x: e.x ?? this.contentMatrix.x,
822
832
  y: e.y ?? this.contentMatrix.y
823
- }, this.viewportMatrix = K(this.contentMatrix), this.afterUpdateEmitter.emit();
833
+ }, this.viewportMatrix = q(this.contentMatrix), this.afterUpdateEmitter.emit();
824
834
  }
825
835
  }
826
- class F {
836
+ class k {
827
837
  constructor(e) {
828
838
  r(this, "elementToNodeId", /* @__PURE__ */ new Map());
829
839
  r(this, "nodesResizeObserver");
@@ -849,47 +859,44 @@ class F {
849
859
  }), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
850
860
  }
851
861
  static configure(e) {
852
- new F(e);
862
+ new k(e);
853
863
  }
854
864
  handleNodeResize(e) {
855
865
  const o = this.elementToNodeId.get(e);
856
866
  this.canvas.updateNode(o);
857
867
  }
858
868
  }
859
- const Ee = (t) => {
860
- var g, y, p, f, A, E;
861
- const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
862
- }), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), i = ((p = t == null ? void 0 : t.events) == null ? void 0 : p.onNodeDragFinished) ?? (() => {
863
- }), s = (t == null ? void 0 : t.moveOnTop) === !1, h = (f = t == null ? void 0 : t.mouse) == null ? void 0 : f.dragCursor, n = h !== void 0 ? h : "grab", d = (A = t == null ? void 0 : t.mouse) == null ? void 0 : A.mouseDownEventVerifier, c = d !== void 0 ? d : (m) => m.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
869
+ const me = (t) => {
870
+ var v, A, y, p, E, b;
871
+ const e = ((v = t == null ? void 0 : t.events) == null ? void 0 : v.onNodeDrag) ?? (() => {
872
+ }), o = ((A = t == null ? void 0 : t.events) == null ? void 0 : A.onBeforeNodeDrag) ?? (() => !0), i = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onNodeDragFinished) ?? (() => {
873
+ }), s = (t == null ? void 0 : t.moveOnTop) !== !1, h = (t == null ? void 0 : t.moveEdgesOnTop) !== !1 && s, n = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.dragCursor, d = n !== void 0 ? n : "grab", c = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseDownEventVerifier, a = c !== void 0 ? c : (T) => T.button === 0, l = (b = t == null ? void 0 : t.mouse) == null ? void 0 : b.mouseUpEventVerifier;
864
874
  return {
865
- freezePriority: s,
866
- dragCursor: n,
867
- mouseDownEventVerifier: c,
868
- mouseUpEventVerifier: a !== void 0 ? a : (m) => m.button === 0,
875
+ moveOnTop: s,
876
+ moveEdgesOnTop: h,
877
+ dragCursor: d,
878
+ mouseDownEventVerifier: a,
879
+ mouseUpEventVerifier: l !== void 0 ? l : (T) => T.button === 0,
869
880
  onNodeDrag: e,
870
881
  onBeforeNodeDrag: o,
871
882
  onNodeDragFinished: i
872
883
  };
873
- }, xe = (t, e, o) => {
884
+ }, Me = (t, e, o) => {
874
885
  const { x: i, y: s, width: h, height: n } = t.getBoundingClientRect();
875
886
  return e >= i && e <= i + h && o >= s && o <= s + n;
876
- }, Se = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, M = (t, e, o, i) => xe(e, o, i) && Se(t, o, i), B = (t, e) => {
887
+ }, Le = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, m = (t, e, o, i) => Me(e, o, i) && Le(t, o, i), B = (t, e) => {
877
888
  e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
878
- }, N = (t, e) => ({
879
- x: t.scale * e.x + t.x,
880
- y: t.scale * e.y + t.y
881
- });
882
- class k {
889
+ };
890
+ class z {
883
891
  constructor(e, o, i, s) {
884
892
  r(this, "grabbedNodeId", null);
885
893
  r(this, "maxNodePriority", 0);
886
894
  r(this, "previousTouchCoordinates", null);
887
- r(this, "nodeIds", /* @__PURE__ */ new Map());
888
895
  r(this, "graph");
889
896
  r(this, "onAfterNodeAdded", (e) => {
890
897
  this.updateMaxNodePriority(e);
891
898
  const o = this.graph.getNode(e);
892
- this.nodeIds.set(o.element, e), o.element.addEventListener("mousedown", this.onMouseDown, {
899
+ o.element.addEventListener("mousedown", this.onMouseDown, {
893
900
  passive: !0
894
901
  }), o.element.addEventListener("touchstart", this.onTouchStart, {
895
902
  passive: !0
@@ -900,20 +907,21 @@ class k {
900
907
  });
901
908
  r(this, "onBeforeNodeRemoved", (e) => {
902
909
  const o = this.graph.getNode(e);
903
- this.nodeIds.delete(o.element), o.element.removeEventListener("mousedown", this.onMouseDown), o.element.removeEventListener("touchstart", this.onTouchStart);
910
+ o.element.removeEventListener("mousedown", this.onMouseDown), o.element.removeEventListener("touchstart", this.onTouchStart);
904
911
  });
905
912
  r(this, "onBeforeDestroy", () => {
906
913
  this.graph.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy), this.removeMouseDragListeners(), this.removeTouchDragListeners();
907
914
  });
908
915
  r(this, "onBeforeClear", () => {
909
- this.nodeIds.forEach((e, o) => {
910
- o.removeEventListener("mousedown", this.onMouseDown), o.removeEventListener("touchstart", this.onTouchStart);
911
- }), this.nodeIds.clear(), this.maxNodePriority = 0;
916
+ this.canvas.graph.getAllNodeIds().forEach((e) => {
917
+ const o = this.canvas.graph.getNode(e);
918
+ o.element.removeEventListener("mousedown", this.onMouseDown), o.element.removeEventListener("touchstart", this.onTouchStart);
919
+ }), this.maxNodePriority = 0;
912
920
  });
913
921
  r(this, "onMouseDown", (e) => {
914
922
  if (!this.config.mouseDownEventVerifier(e))
915
923
  return;
916
- const o = e.currentTarget, i = this.nodeIds.get(o), s = this.graph.getNode(i);
924
+ const o = e.currentTarget, i = this.graph.getElementNodeId(o), s = this.graph.getNode(i);
917
925
  this.config.onBeforeNodeDrag({
918
926
  nodeId: i,
919
927
  element: s.element,
@@ -932,7 +940,7 @@ class k {
932
940
  x: e.touches[0].clientX,
933
941
  y: e.touches[0].clientY
934
942
  };
935
- const o = e.currentTarget, i = this.nodeIds.get(o), s = this.graph.getNode(i);
943
+ const o = e.currentTarget, i = this.canvas.graph.getElementNodeId(o), s = this.graph.getNode(i);
936
944
  this.config.onBeforeNodeDrag({
937
945
  nodeId: i,
938
946
  element: s.element,
@@ -947,7 +955,7 @@ class k {
947
955
  }));
948
956
  });
949
957
  r(this, "onWindowMouseMove", (e) => {
950
- if (!M(
958
+ if (!m(
951
959
  this.window,
952
960
  this.element,
953
961
  e.clientX,
@@ -965,7 +973,7 @@ class k {
965
973
  if (e.touches.length !== 1)
966
974
  return;
967
975
  const o = e.touches[0];
968
- if (!M(
976
+ if (!m(
969
977
  this.window,
970
978
  this.element,
971
979
  o.clientX,
@@ -986,10 +994,10 @@ class k {
986
994
  this.previousTouchCoordinates = null, this.cancelTouchDrag();
987
995
  });
988
996
  r(this, "config");
989
- this.canvas = e, this.element = o, this.window = i, this.config = Ee(s), 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.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
997
+ this.canvas = e, this.element = o, this.window = i, this.config = me(s), 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.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
990
998
  }
991
999
  static configure(e, o, i, s) {
992
- new k(e, o, i, s);
1000
+ new z(e, o, i, s);
993
1001
  }
994
1002
  dragNode(e, o, i) {
995
1003
  const s = this.graph.getNode(e);
@@ -1010,13 +1018,15 @@ class k {
1010
1018
  });
1011
1019
  }
1012
1020
  moveNodeOnTop(e) {
1013
- if (this.config.freezePriority)
1014
- return;
1015
- this.maxNodePriority += 2, this.canvas.updateNode(e, { priority: this.maxNodePriority });
1016
- const o = this.maxNodePriority - 1;
1017
- this.graph.getNodeAdjacentEdgeIds(e).forEach((s) => {
1018
- this.canvas.updateEdge(s, { priority: o });
1019
- });
1021
+ if (this.config.moveOnTop) {
1022
+ if (this.maxNodePriority++, this.config.moveEdgesOnTop) {
1023
+ const o = this.maxNodePriority;
1024
+ this.maxNodePriority++, this.graph.getNodeAdjacentEdgeIds(e).forEach((s) => {
1025
+ this.canvas.updateEdge(s, { priority: o });
1026
+ });
1027
+ }
1028
+ this.canvas.updateNode(e, { priority: this.maxNodePriority });
1029
+ }
1020
1030
  }
1021
1031
  cancelMouseDrag() {
1022
1032
  const e = this.graph.getNode(this.grabbedNodeId);
@@ -1048,30 +1058,30 @@ class k {
1048
1058
  this.maxNodePriority = Math.max(this.maxNodePriority, o);
1049
1059
  }
1050
1060
  }
1051
- const me = (t) => {
1061
+ const Re = (t) => {
1052
1062
  const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, i = t.minY !== null ? t.minY : -1 / 0, s = t.maxY !== null ? t.maxY : 1 / 0;
1053
1063
  return (h) => {
1054
1064
  let n = h.nextTransform.x, d = h.nextTransform.y;
1055
1065
  n < e && n < h.prevTransform.x && (n = Math.min(h.prevTransform.x, e));
1056
1066
  const c = h.canvasWidth * h.prevTransform.scale, a = o - c;
1057
1067
  n > a && n > h.prevTransform.x && (n = Math.max(h.prevTransform.x, a)), d < i && d < h.prevTransform.y && (d = Math.min(h.prevTransform.y, i));
1058
- const l = h.canvasHeight * h.prevTransform.scale, g = s - l;
1059
- return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: n, y: d };
1068
+ const l = h.canvasHeight * h.prevTransform.scale, w = s - l;
1069
+ return d > w && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, w)), { scale: h.nextTransform.scale, x: n, y: d };
1060
1070
  };
1061
- }, be = (t) => {
1071
+ }, Ie = (t) => {
1062
1072
  const e = t.maxContentScale, o = t.minContentScale, i = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
1063
1073
  return (h) => {
1064
1074
  const n = h.prevTransform, d = h.nextTransform;
1065
1075
  let c = d.scale, a = d.x, l = d.y;
1066
1076
  if (d.scale > s && d.scale > n.scale) {
1067
1077
  c = Math.max(n.scale, s), a = n.x, l = n.y;
1068
- const g = (c - n.scale) / (d.scale - n.scale);
1069
- a = n.x + (d.x - n.x) * g, l = n.y + (d.y - n.y) * g;
1078
+ const w = (c - n.scale) / (d.scale - n.scale);
1079
+ a = n.x + (d.x - n.x) * w, l = n.y + (d.y - n.y) * w;
1070
1080
  }
1071
1081
  if (d.scale < i && d.scale < n.scale) {
1072
1082
  c = Math.min(n.scale, i), a = n.x, l = n.y;
1073
- const g = (c - n.scale) / (d.scale - n.scale);
1074
- a = n.x + (d.x - n.x) * g, l = n.y + (d.y - n.y) * g;
1083
+ const w = (c - n.scale) / (d.scale - n.scale);
1084
+ a = n.x + (d.x - n.x) * w, l = n.y + (d.y - n.y) * w;
1075
1085
  }
1076
1086
  return {
1077
1087
  scale: c,
@@ -1079,7 +1089,7 @@ const me = (t) => {
1079
1089
  y: l
1080
1090
  };
1081
1091
  };
1082
- }, Te = (t) => (e) => t.reduce(
1092
+ }, Be = (t) => (e) => t.reduce(
1083
1093
  (o, i) => i({
1084
1094
  prevTransform: e.prevTransform,
1085
1095
  nextTransform: o,
@@ -1087,63 +1097,63 @@ const me = (t) => {
1087
1097
  canvasHeight: e.canvasHeight
1088
1098
  }),
1089
1099
  e.nextTransform
1090
- ), _ = (t) => {
1100
+ ), te = (t) => {
1091
1101
  if (typeof t == "function")
1092
1102
  return t;
1093
1103
  switch (t.type) {
1094
1104
  case "scale-limit":
1095
- return be({
1105
+ return Ie({
1096
1106
  minContentScale: t.minContentScale ?? 0,
1097
1107
  maxContentScale: t.maxContentScale ?? 1 / 0
1098
1108
  });
1099
1109
  case "shift-limit":
1100
- return me({
1110
+ return Re({
1101
1111
  minX: t.minX ?? -1 / 0,
1102
1112
  maxX: t.maxX ?? 1 / 0,
1103
1113
  minY: t.minY ?? -1 / 0,
1104
1114
  maxY: t.maxY ?? 1 / 0
1105
1115
  });
1106
1116
  }
1107
- }, Pe = (t) => {
1108
- var f, A, E, m, T, b, D, L, j, G, Z, J;
1109
- const e = (f = t == null ? void 0 : t.scale) == null ? void 0 : f.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, i = t == null ? void 0 : t.transformPreprocessor;
1117
+ }, Ve = (t) => {
1118
+ var y, p, E, b, T, P, M, L, J, K, Q, _;
1119
+ const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, i = t == null ? void 0 : t.transformPreprocessor;
1110
1120
  let s;
1111
- i !== void 0 ? Array.isArray(i) ? s = Te(
1121
+ i !== void 0 ? Array.isArray(i) ? s = Be(
1112
1122
  i.map(
1113
- (P) => _(P)
1123
+ (D) => te(D)
1114
1124
  )
1115
- ) : s = _(i) : s = (P) => P.nextTransform;
1116
- const h = ((A = t == null ? void 0 : t.shift) == null ? void 0 : A.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
1117
- }), d = ((m = t == null ? void 0 : t.events) == null ? void 0 : m.onTransformChange) ?? (() => {
1118
- }), c = (T = t == null ? void 0 : t.shift) == null ? void 0 : T.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (b = t == null ? void 0 : t.shift) == null ? void 0 : b.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, y = (D = t == null ? void 0 : t.scale) == null ? void 0 : D.mouseWheelEventVerifier, p = y !== void 0 ? y : () => !0;
1125
+ ) : s = te(i) : s = (D) => D.nextTransform;
1126
+ const h = ((p = t == null ? void 0 : t.shift) == null ? void 0 : p.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
1127
+ }), d = ((b = t == null ? void 0 : t.events) == null ? void 0 : b.onTransformChange) ?? (() => {
1128
+ }), c = (T = t == null ? void 0 : t.shift) == null ? void 0 : T.mouseDownEventVerifier, a = c !== void 0 ? c : (D) => D.button === 0, l = (P = t == null ? void 0 : t.shift) == null ? void 0 : P.mouseUpEventVerifier, w = l !== void 0 ? l : (D) => D.button === 0, v = (M = t == null ? void 0 : t.scale) == null ? void 0 : M.mouseWheelEventVerifier, A = v !== void 0 ? v : () => !0;
1119
1129
  return {
1120
1130
  wheelSensitivity: o,
1121
1131
  onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
1122
1132
  }),
1123
- onTransformFinished: ((j = t == null ? void 0 : t.events) == null ? void 0 : j.onTransformFinished) ?? (() => {
1133
+ onTransformFinished: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onTransformFinished) ?? (() => {
1124
1134
  }),
1125
1135
  onBeforeTransformChange: n,
1126
1136
  onTransformChange: d,
1127
1137
  transformPreprocessor: s,
1128
1138
  shiftCursor: h,
1129
1139
  mouseDownEventVerifier: a,
1130
- mouseUpEventVerifier: g,
1131
- mouseWheelEventVerifier: p,
1132
- scaleWheelFinishTimeout: ((G = t == null ? void 0 : t.scale) == null ? void 0 : G.wheelFinishTimeout) ?? 500,
1133
- onResizeTransformStarted: ((Z = t == null ? void 0 : t.events) == null ? void 0 : Z.onResizeTransformStarted) ?? (() => {
1140
+ mouseUpEventVerifier: w,
1141
+ mouseWheelEventVerifier: A,
1142
+ scaleWheelFinishTimeout: ((K = t == null ? void 0 : t.scale) == null ? void 0 : K.wheelFinishTimeout) ?? 500,
1143
+ onResizeTransformStarted: ((Q = t == null ? void 0 : t.events) == null ? void 0 : Q.onResizeTransformStarted) ?? (() => {
1134
1144
  }),
1135
- onResizeTransformFinished: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onResizeTransformFinished) ?? (() => {
1145
+ onResizeTransformFinished: ((_ = t == null ? void 0 : t.events) == null ? void 0 : _.onResizeTransformFinished) ?? (() => {
1136
1146
  })
1137
1147
  };
1138
- }, Ne = (t, e, o) => ({
1148
+ }, Ue = (t, e, o) => ({
1139
1149
  scale: t.scale,
1140
1150
  x: t.x + t.scale * e,
1141
1151
  y: t.y + t.scale * o
1142
- }), Me = (t, e, o, i) => ({
1152
+ }), Ce = (t, e, o, i) => ({
1143
1153
  scale: t.scale * e,
1144
1154
  x: t.scale * (1 - e) * o + t.x,
1145
1155
  y: t.scale * (1 - e) * i + t.y
1146
- }), R = (t) => {
1156
+ }), I = (t) => {
1147
1157
  const e = [], o = t.touches.length;
1148
1158
  for (let d = 0; d < o; d++)
1149
1159
  e.push([t.touches[d].clientX, t.touches[d].clientY]);
@@ -1162,7 +1172,7 @@ const me = (t) => {
1162
1172
  touches: e
1163
1173
  };
1164
1174
  };
1165
- class I {
1175
+ class U {
1166
1176
  constructor(e, o, i, s) {
1167
1177
  r(this, "viewport");
1168
1178
  r(this, "prevTouches", null);
@@ -1179,7 +1189,7 @@ class I {
1179
1189
  }), this.startRegisteredTransform());
1180
1190
  });
1181
1191
  r(this, "onWindowMouseMove", (e) => {
1182
- const o = M(
1192
+ const o = m(
1183
1193
  this.window,
1184
1194
  this.element,
1185
1195
  e.clientX,
@@ -1205,10 +1215,10 @@ class I {
1205
1215
  });
1206
1216
  r(this, "onTouchStart", (e) => {
1207
1217
  if (this.prevTouches !== null) {
1208
- this.prevTouches = R(e);
1218
+ this.prevTouches = I(e);
1209
1219
  return;
1210
1220
  }
1211
- this.prevTouches = R(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
1221
+ this.prevTouches = I(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
1212
1222
  passive: !0
1213
1223
  }), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
1214
1224
  passive: !0
@@ -1217,9 +1227,9 @@ class I {
1217
1227
  }), this.startRegisteredTransform();
1218
1228
  });
1219
1229
  r(this, "onWindowTouchMove", (e) => {
1220
- const o = R(e);
1230
+ const o = I(e);
1221
1231
  if (!o.touches.every(
1222
- (s) => M(this.window, this.element, s[0], s[1])
1232
+ (s) => m(this.window, this.element, s[0], s[1])
1223
1233
  )) {
1224
1234
  this.stopTouchDrag();
1225
1235
  return;
@@ -1234,7 +1244,7 @@ class I {
1234
1244
  this.prevTouches = o;
1235
1245
  });
1236
1246
  r(this, "onWindowTouchFinish", (e) => {
1237
- e.touches.length > 0 ? this.prevTouches = R(e) : this.stopTouchDrag();
1247
+ e.touches.length > 0 ? this.prevTouches = I(e) : this.stopTouchDrag();
1238
1248
  });
1239
1249
  r(this, "observer", new ResizeObserver(() => {
1240
1250
  const e = this.viewport.getViewportMatrix(), { width: o, height: i } = this.element.getBoundingClientRect(), s = this.config.transformPreprocessor({
@@ -1251,7 +1261,7 @@ class I {
1251
1261
  });
1252
1262
  this.canvas = e, this.element = o, this.window = i, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
1253
1263
  passive: !1
1254
- }), this.config = Pe(s), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown, {
1264
+ }), this.config = Ve(s), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown, {
1255
1265
  passive: !0
1256
1266
  }), this.element.addEventListener("wheel", this.onWheelScroll, {
1257
1267
  passive: !0
@@ -1260,7 +1270,7 @@ class I {
1260
1270
  }), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1261
1271
  }
1262
1272
  static configure(e, o, i, s) {
1263
- new I(
1273
+ new U(
1264
1274
  e,
1265
1275
  o,
1266
1276
  i,
@@ -1268,7 +1278,7 @@ class I {
1268
1278
  );
1269
1279
  }
1270
1280
  moveViewport(e, o) {
1271
- const i = this.viewport.getViewportMatrix(), s = Ne(i, e, o), { width: h, height: n } = this.element.getBoundingClientRect(), d = this.config.transformPreprocessor({
1281
+ const i = this.viewport.getViewportMatrix(), s = Ue(i, e, o), { width: h, height: n } = this.element.getBoundingClientRect(), d = this.config.transformPreprocessor({
1272
1282
  prevTransform: i,
1273
1283
  nextTransform: s,
1274
1284
  canvasWidth: h,
@@ -1277,7 +1287,7 @@ class I {
1277
1287
  this.performTransform(d);
1278
1288
  }
1279
1289
  scaleViewport(e, o, i) {
1280
- const s = this.canvas.viewport.getViewportMatrix(), h = Me(s, e, o, i), { width: n, height: d } = this.element.getBoundingClientRect(), c = this.config.transformPreprocessor({
1290
+ const s = this.canvas.viewport.getViewportMatrix(), h = Ce(s, e, o, i), { width: n, height: d } = this.element.getBoundingClientRect(), c = this.config.transformPreprocessor({
1281
1291
  prevTransform: s,
1282
1292
  nextTransform: h,
1283
1293
  canvasWidth: n,
@@ -1307,7 +1317,7 @@ class I {
1307
1317
  this.transformInProgress = !1, this.config.onTransformFinished();
1308
1318
  }
1309
1319
  }
1310
- class z {
1320
+ class X {
1311
1321
  constructor(e, o, i, s, h, n) {
1312
1322
  r(this, "canvasResizeObserver");
1313
1323
  r(this, "nodeHorizontal");
@@ -1339,17 +1349,17 @@ class z {
1339
1349
  this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
1340
1350
  });
1341
1351
  r(this, "userTransformInProgress", !1);
1342
- var p, f, A, E, m;
1352
+ var A, y, p, E, b;
1343
1353
  this.canvas = e, this.element = o, this.window = i, this.trigger = h, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((T) => {
1344
- const b = T[0];
1345
- this.viewportWidth = b.contentRect.width, this.viewportHeight = b.contentRect.height, this.scheduleLoadAreaAroundViewport();
1354
+ const P = T[0];
1355
+ this.viewportWidth = P.contentRect.width, this.viewportHeight = P.contentRect.height, this.scheduleLoadAreaAroundViewport();
1346
1356
  }), this.viewport = e.viewport;
1347
- const d = ((p = s == null ? void 0 : s.events) == null ? void 0 : p.onResizeTransformStarted) ?? (() => {
1348
- }), c = ((f = s == null ? void 0 : s.events) == null ? void 0 : f.onResizeTransformFinished) ?? (() => {
1349
- }), a = ((A = s == null ? void 0 : s.events) == null ? void 0 : A.onTransformChange) ?? (() => {
1357
+ const d = ((A = s == null ? void 0 : s.events) == null ? void 0 : A.onResizeTransformStarted) ?? (() => {
1358
+ }), c = ((y = s == null ? void 0 : s.events) == null ? void 0 : y.onResizeTransformFinished) ?? (() => {
1359
+ }), a = ((p = s == null ? void 0 : s.events) == null ? void 0 : p.onTransformChange) ?? (() => {
1350
1360
  }), l = ((E = s == null ? void 0 : s.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
1351
- }), g = ((m = s == null ? void 0 : s.events) == null ? void 0 : m.onTransformFinished) ?? (() => {
1352
- }), y = {
1361
+ }), w = ((b = s == null ? void 0 : s.events) == null ? void 0 : b.onTransformFinished) ?? (() => {
1362
+ }), v = {
1353
1363
  ...s,
1354
1364
  events: {
1355
1365
  ...s == null ? void 0 : s.events,
@@ -1368,19 +1378,19 @@ class z {
1368
1378
  this.viewportMatrix = this.viewport.getViewportMatrix(), T.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), a();
1369
1379
  },
1370
1380
  onTransformFinished: () => {
1371
- this.scheduleLoadAreaAroundViewport(), g();
1381
+ this.scheduleLoadAreaAroundViewport(), w();
1372
1382
  }
1373
1383
  }
1374
1384
  };
1375
- I.configure(
1385
+ U.configure(
1376
1386
  e,
1377
1387
  this.element,
1378
1388
  this.window,
1379
- y
1389
+ v
1380
1390
  ), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1381
1391
  }
1382
1392
  static configure(e, o, i, s, h, n) {
1383
- new z(
1393
+ new X(
1384
1394
  e,
1385
1395
  o,
1386
1396
  i,
@@ -1403,29 +1413,29 @@ class z {
1403
1413
  this.trigger.emit({ x: i, y: s, width: h, height: n });
1404
1414
  }
1405
1415
  }
1406
- const De = () => {
1416
+ const We = () => {
1407
1417
  const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1408
1418
  return t.style.position = "absolute", t.style.inset = "0", t;
1409
- }, Le = () => {
1419
+ }, $e = () => {
1410
1420
  const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
1411
1421
  return t.setAttribute("fill", "url(#pattern)"), t;
1412
- }, Ve = () => {
1422
+ }, Fe = () => {
1413
1423
  const t = document.createElementNS(
1414
1424
  "http://www.w3.org/2000/svg",
1415
1425
  "pattern"
1416
1426
  );
1417
1427
  return t.setAttribute("id", "pattern"), t;
1418
- }, Re = (t, e) => {
1428
+ }, Oe = (t, e) => {
1419
1429
  const o = document.createElementNS(
1420
1430
  "http://www.w3.org/2000/svg",
1421
1431
  "circle"
1422
1432
  );
1423
1433
  return o.setAttribute("cx", "0"), o.setAttribute("cy", "0"), o.setAttribute("r", `${t}`), o.setAttribute("fill", `${e}`), o;
1424
- }, Be = (t) => t instanceof SVGElement ? t : Re(
1434
+ }, ke = (t) => t instanceof SVGElement ? t : Oe(
1425
1435
  (t == null ? void 0 : t.radius) ?? 1.5,
1426
1436
  (t == null ? void 0 : t.color) ?? "#d8d8d8"
1427
- ), Ie = (t) => {
1428
- const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, i = (e == null ? void 0 : e.height) ?? 25, s = Be(t.renderer ?? {});
1437
+ ), ze = (t) => {
1438
+ const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, i = (e == null ? void 0 : e.height) ?? 25, s = ke(t.renderer ?? {});
1429
1439
  return {
1430
1440
  tileWidth: o,
1431
1441
  tileHeight: i,
@@ -1433,11 +1443,11 @@ const De = () => {
1433
1443
  maxViewportScale: t.maxViewportScale ?? 10
1434
1444
  };
1435
1445
  };
1436
- class O {
1446
+ class Y {
1437
1447
  constructor(e, o, i) {
1438
- r(this, "svg", De());
1439
- r(this, "patternRenderingRectangle", Le());
1440
- r(this, "pattern", Ve());
1448
+ r(this, "svg", We());
1449
+ r(this, "patternRenderingRectangle", $e());
1450
+ r(this, "pattern", Fe());
1441
1451
  r(this, "patternContent");
1442
1452
  r(this, "tileWidth");
1443
1453
  r(this, "tileHeight");
@@ -1461,7 +1471,7 @@ class O {
1461
1471
  ), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
1462
1472
  });
1463
1473
  this.canvas = e, this.host = i;
1464
- const s = Ie(o);
1474
+ const s = ze(o);
1465
1475
  this.tileWidth = s.tileWidth, this.tileHeight = s.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = s.renderer, this.maxViewportScale = s.maxViewportScale;
1466
1476
  const h = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
1467
1477
  this.patternContent.setAttribute("transform", h), this.pattern.appendChild(this.patternContent);
@@ -1469,14 +1479,14 @@ class O {
1469
1479
  n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.host), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated(), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1470
1480
  }
1471
1481
  static configure(e, o, i) {
1472
- new O(e, o, i);
1482
+ new Y(e, o, i);
1473
1483
  }
1474
1484
  updateVisibility() {
1475
1485
  const o = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
1476
1486
  o && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !o && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
1477
1487
  }
1478
1488
  }
1479
- const Ue = (t) => {
1489
+ const Xe = (t) => {
1480
1490
  var d, c, a;
1481
1491
  const e = () => "direct", o = (l) => l, i = (l) => l.button === 0, s = () => {
1482
1492
  }, h = () => {
@@ -1493,22 +1503,21 @@ const Ue = (t) => {
1493
1503
  dragPortDirection: t.dragPortDirection ?? void 0
1494
1504
  };
1495
1505
  };
1496
- class X {
1506
+ class H {
1497
1507
  constructor(e, o, i, s, h, n) {
1498
1508
  r(this, "config");
1499
1509
  r(this, "overlayCanvas");
1500
- r(this, "ports", new he());
1501
1510
  r(this, "staticOverlayPortId", "static");
1502
1511
  r(this, "draggingOverlayPortId", "dragging");
1503
1512
  r(this, "staticPortId", null);
1504
1513
  r(this, "isDirect", !0);
1505
1514
  r(this, "onAfterPortMarked", (e) => {
1506
1515
  const o = this.canvas.graph.getPort(e);
1507
- this.ports.hasSingle(o.element) || this.hookPortEvents(o.element), this.ports.addRecord(o.element, e);
1516
+ this.canvas.graph.getElementPortsIds(o.element).length === 1 && this.hookPortEvents(o.element);
1508
1517
  });
1509
1518
  r(this, "onBeforePortUnmarked", (e) => {
1510
1519
  const o = this.canvas.graph.getPort(e);
1511
- this.ports.removeByMulti(e), this.ports.hasSingle(o.element) || this.unhookPortEvents(o.element);
1520
+ this.canvas.graph.getElementPortsIds(o.element).length === 1 && this.unhookPortEvents(o.element);
1512
1521
  });
1513
1522
  r(this, "onPortMouseDown", (e) => {
1514
1523
  const o = e.currentTarget;
@@ -1519,7 +1528,7 @@ class X {
1519
1528
  }));
1520
1529
  });
1521
1530
  r(this, "onWindowMouseMove", (e) => {
1522
- if (!M(
1531
+ if (!m(
1523
1532
  this.window,
1524
1533
  this.overlayLayer,
1525
1534
  e.clientX,
@@ -1549,7 +1558,7 @@ class X {
1549
1558
  });
1550
1559
  r(this, "onWindowTouchMove", (e) => {
1551
1560
  const o = e.touches[0];
1552
- if (!M(
1561
+ if (!m(
1553
1562
  this.window,
1554
1563
  this.overlayLayer,
1555
1564
  o.clientX,
@@ -1565,9 +1574,10 @@ class X {
1565
1574
  this.tryCreateConnection({ x: o.clientX, y: o.clientY }), this.stopTouchDrag();
1566
1575
  });
1567
1576
  r(this, "onBeforeClear", () => {
1568
- this.ports.forEachSingle((e) => {
1569
- this.unhookPortEvents(e);
1570
- }), this.ports.clear();
1577
+ this.canvas.graph.getAllPortIds().forEach((e) => {
1578
+ const o = this.canvas.graph.getPort(e);
1579
+ this.unhookPortEvents(o.element);
1580
+ });
1571
1581
  });
1572
1582
  r(this, "onBeforeDestroy", () => {
1573
1583
  this.stopMouseDrag(), this.stopTouchDrag(), this.canvas.graph.onAfterPortMarked.unsubscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.unsubscribe(
@@ -1577,13 +1587,13 @@ class X {
1577
1587
  r(this, "onEdgeCreated", (e) => {
1578
1588
  this.config.onAfterEdgeCreated(e);
1579
1589
  });
1580
- this.canvas = e, this.overlayLayer = o, this.viewportStore = i, this.window = s, this.config = Ue(n);
1581
- const d = new de(), c = new ie(
1590
+ this.canvas = e, this.overlayLayer = o, this.viewportStore = i, this.window = s, this.config = Xe(n);
1591
+ const d = new ae(), c = new he(
1582
1592
  d,
1583
1593
  this.viewportStore,
1584
1594
  this.overlayLayer
1585
1595
  );
1586
- this.overlayCanvas = new ne(
1596
+ this.overlayCanvas = new ce(
1587
1597
  this.overlayLayer,
1588
1598
  d,
1589
1599
  this.viewportStore,
@@ -1592,7 +1602,7 @@ class X {
1592
1602
  ), this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1593
1603
  }
1594
1604
  static configure(e, o, i, s, h, n) {
1595
- new X(
1605
+ new H(
1596
1606
  e,
1597
1607
  o,
1598
1608
  i,
@@ -1602,26 +1612,26 @@ class X {
1602
1612
  );
1603
1613
  }
1604
1614
  grabPort(e, o) {
1605
- const i = this.ports.getMultiBySingle(e)[0], s = this.canvas.graph.getPort(i);
1615
+ const i = this.canvas.graph.getElementPortsIds(e)[0], s = this.canvas.graph.getPort(i);
1606
1616
  this.staticPortId = i;
1607
- const h = this.config.connectionTypeResolver(this.staticPortId), n = e.getBoundingClientRect(), d = n.x + n.width / 2, c = n.y + n.height / 2, a = this.overlayLayer.getBoundingClientRect(), l = this.canvas.viewport.getViewportMatrix(), g = N(l, {
1617
+ const h = this.config.connectionTypeResolver(this.staticPortId), n = e.getBoundingClientRect(), d = n.x + n.width / 2, c = n.y + n.height / 2, a = this.overlayLayer.getBoundingClientRect(), l = this.canvas.viewport.getViewportMatrix(), w = N(l, {
1608
1618
  x: d - a.x,
1609
1619
  y: c - a.y
1610
- }), y = N(l, {
1620
+ }), v = N(l, {
1611
1621
  x: o.x - a.x,
1612
1622
  y: o.y - a.y
1613
- }), p = {
1623
+ }), A = {
1614
1624
  overlayId: this.staticOverlayPortId,
1615
- portCoords: g,
1625
+ portCoords: w,
1616
1626
  portDirection: s.direction
1617
- }, f = {
1627
+ }, y = {
1618
1628
  overlayId: this.draggingOverlayPortId,
1619
- portCoords: y,
1629
+ portCoords: v,
1620
1630
  portDirection: this.config.dragPortDirection
1621
1631
  };
1622
1632
  this.isDirect = h === "direct";
1623
- const A = this.isDirect ? p : f, E = this.isDirect ? f : p;
1624
- this.createOverlayGraph(A, E);
1633
+ const p = this.isDirect ? A : y, E = this.isDirect ? y : A;
1634
+ this.createOverlayGraph(p, E);
1625
1635
  }
1626
1636
  hookPortEvents(e) {
1627
1637
  e.addEventListener("mousedown", this.onPortMouseDown, {
@@ -1697,100 +1707,100 @@ class X {
1697
1707
  }
1698
1708
  findPortAtElement(e) {
1699
1709
  let o = e, i = null;
1700
- for (; o !== null && (i = this.ports.getMultiBySingle(o)[0] ?? null, i === null); )
1710
+ for (; o !== null && (i = this.canvas.graph.getElementPortsIds(o)[0] ?? null, i === null); )
1701
1711
  o = o.parentElement;
1702
1712
  return i;
1703
1713
  }
1704
1714
  isPortConnectionAllowed(e) {
1705
- const o = this.ports.getMultiBySingle(e)[0];
1715
+ const o = this.canvas.graph.getElementPortsIds(e)[0];
1706
1716
  return this.config.connectionTypeResolver(o) !== null;
1707
1717
  }
1708
1718
  }
1709
- const Ce = () => {
1719
+ const Ye = () => {
1710
1720
  const t = document.createElement("div");
1711
1721
  return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t;
1712
- }, W = () => {
1722
+ }, $ = () => {
1713
1723
  const t = document.createElement("div");
1714
1724
  return t.style.position = "absolute", t.style.inset = "0", t;
1715
1725
  };
1716
- class We {
1726
+ class He {
1717
1727
  constructor(e) {
1718
- r(this, "background", W());
1719
- r(this, "main", W());
1720
- r(this, "overlay", W());
1721
- r(this, "host", Ce());
1728
+ r(this, "background", $());
1729
+ r(this, "main", $());
1730
+ r(this, "overlay", $());
1731
+ r(this, "host", Ye());
1722
1732
  this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.overlay.style.pointerEvents = "none", this.host.appendChild(this.overlay);
1723
1733
  }
1724
1734
  destroy() {
1725
1735
  this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlay), this.element.removeChild(this.host);
1726
1736
  }
1727
1737
  }
1728
- const $e = (t, e) => ({
1738
+ const je = (t, e) => ({
1729
1739
  x: t / 2,
1730
1740
  y: e / 2
1731
- }), $ = (t) => () => t, q = $(0), Fe = () => {
1741
+ }), F = (t) => () => t, oe = F(0), Ge = () => {
1732
1742
  let t = 0;
1733
1743
  return () => t++;
1734
- }, ke = (t, e) => {
1735
- let o = q, i = q;
1736
- const s = Fe();
1737
- return t === "incremental" && (o = s), e === "incremental" && (i = s), typeof t == "number" && (o = $(t)), typeof e == "number" && (i = $(e)), typeof t == "function" && (o = t), typeof e == "function" && (i = e), {
1744
+ }, Ze = (t, e) => {
1745
+ let o = oe, i = oe;
1746
+ const s = Ge();
1747
+ return t === "incremental" && (o = s), e === "incremental" && (i = s), typeof t == "number" && (o = F(t)), typeof e == "number" && (i = F(e)), typeof t == "function" && (o = t), typeof e == "function" && (i = e), {
1738
1748
  nodesPriorityFn: o,
1739
1749
  edgesPriorityFn: i
1740
1750
  };
1741
- }, v = (t, e, o) => ({
1751
+ }, f = (t, e, o) => ({
1742
1752
  x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
1743
1753
  y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
1744
- }), w = {
1754
+ }), g = {
1745
1755
  x: 0,
1746
1756
  y: 0
1747
- }, ze = (t) => {
1748
- const e = v(
1749
- { x: t.arrowLength, y: w.y },
1750
- t.fromVector,
1751
- w
1752
- ), o = v(
1757
+ }, Je = (t) => {
1758
+ const e = f(
1759
+ { x: t.arrowLength, y: g.y },
1760
+ t.sourceDirection,
1761
+ g
1762
+ ), o = f(
1753
1763
  { x: t.to.x - t.arrowLength, y: t.to.y },
1754
- t.toVector,
1764
+ t.targetDirection,
1755
1765
  t.to
1756
1766
  ), i = {
1757
- x: e.x + t.fromVector.x * t.curvature,
1758
- y: e.y + t.fromVector.y * t.curvature
1767
+ x: e.x + t.sourceDirection.x * t.curvature,
1768
+ y: e.y + t.sourceDirection.y * t.curvature
1759
1769
  }, s = {
1760
- x: o.x - t.toVector.x * t.curvature,
1761
- y: o.y - t.toVector.y * t.curvature
1762
- }, h = `M ${e.x} ${e.y} C ${i.x} ${i.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, d = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
1770
+ x: o.x - t.targetDirection.x * t.curvature,
1771
+ y: o.y - t.targetDirection.y * t.curvature
1772
+ }, h = `M ${e.x} ${e.y} C ${i.x} ${i.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${g.x} ${g.y} L ${e.x} ${e.y} `, d = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
1763
1773
  return `${n}${h}${d}`;
1764
- }, Oe = (t) => {
1765
- const e = t.hasSourceArrow ? v(
1766
- { x: t.arrowLength, y: w.y },
1767
- t.fromVector,
1768
- w
1769
- ) : w, o = t.hasTargetArrow ? v(
1774
+ }, Ke = (t) => {
1775
+ const e = t.hasSourceArrow ? f(
1776
+ { x: t.arrowLength, y: g.y },
1777
+ t.sourceDirection,
1778
+ g
1779
+ ) : g, o = t.hasTargetArrow ? f(
1770
1780
  { x: t.to.x - t.arrowLength, y: t.to.y },
1771
- t.toVector,
1781
+ t.targetDirection,
1772
1782
  t.to
1773
- ) : t.to, i = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c = v(
1774
- { x: i, y: w.y },
1775
- t.fromVector,
1776
- w
1783
+ ) : t.to, i = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c = f(
1784
+ { x: i, y: g.y },
1785
+ t.sourceDirection,
1786
+ g
1777
1787
  ), a = {
1778
1788
  x: c.x + n,
1779
1789
  y: c.y + d
1780
- }, l = v(
1790
+ }, l = f(
1781
1791
  { x: t.to.x - i, y: t.to.y },
1782
- t.toVector,
1792
+ t.targetDirection,
1783
1793
  t.to
1784
- ), g = {
1794
+ ), w = {
1785
1795
  x: l.x + n,
1786
1796
  y: l.y + d
1787
- }, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, p = {
1788
- x: c.x + t.curvature * t.fromVector.x,
1789
- y: c.y + t.curvature * t.fromVector.y
1790
- }, f = {
1791
- x: l.x - t.curvature * t.toVector.x,
1792
- y: l.y - t.curvature * t.toVector.y
1793
- }, A = {
1797
+ }, v = { x: (a.x + w.x) / 2, y: (a.y + w.y) / 2 }, A = {
1798
+ x: c.x + t.curvature * t.sourceDirection.x,
1799
+ y: c.y + t.curvature * t.sourceDirection.y
1800
+ }, y = {
1801
+ x: l.x - t.curvature * t.targetDirection.x,
1802
+ y: l.y - t.curvature * t.targetDirection.y
1803
+ }, p = {
1794
1804
  x: c.x + n,
1795
1805
  y: c.y + d
1796
1806
  }, E = {
@@ -1800,147 +1810,147 @@ const $e = (t, e) => ({
1800
1810
  return [
1801
1811
  `M ${e.x} ${e.y}`,
1802
1812
  `L ${c.x} ${c.y}`,
1803
- `C ${p.x} ${p.y} ${A.x} ${A.y} ${y.x} ${y.y}`,
1804
- `C ${E.x} ${E.y} ${f.x} ${f.y} ${l.x} ${l.y}`,
1813
+ `C ${A.x} ${A.y} ${p.x} ${p.y} ${v.x} ${v.y}`,
1814
+ `C ${E.x} ${E.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
1805
1815
  `L ${o.x} ${o.y}`
1806
1816
  ].join(" ");
1807
- }, V = (t, e) => {
1817
+ }, R = (t, e) => {
1808
1818
  const o = [];
1809
1819
  if (t.length > 0 && o.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && o.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
1810
1820
  const i = t.length - 1;
1811
1821
  let s = 0, h = 0, n = 0;
1812
1822
  t.forEach((d, c) => {
1813
- let a = 0, l = 0, g = 0;
1814
- const y = c > 0, p = c < i, f = y && p;
1815
- if (y && (a = -s, l = -h, g = n), p) {
1823
+ let a = 0, l = 0, w = 0;
1824
+ const v = c > 0, A = c < i, y = v && A;
1825
+ if (v && (a = -s, l = -h, w = n), A) {
1816
1826
  const L = t[c + 1];
1817
1827
  s = L.x - d.x, h = L.y - d.y, n = Math.sqrt(s * s + h * h);
1818
1828
  }
1819
- const E = n !== 0 ? Math.min((f ? e : 0) / n, c < i - 1 ? 0.5 : 1) : 0, m = f ? { x: d.x + s * E, y: d.y + h * E } : d, b = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, D = f ? { x: d.x + a * b, y: d.y + l * b } : d;
1820
- c > 0 && o.push(`L ${D.x} ${D.y}`), f && o.push(
1821
- `C ${d.x} ${d.y} ${d.x} ${d.y} ${m.x} ${m.y}`
1829
+ const E = n !== 0 ? Math.min((y ? e : 0) / n, c < i - 1 ? 0.5 : 1) : 0, b = y ? { x: d.x + s * E, y: d.y + h * E } : d, P = w !== 0 ? Math.min((y ? e : 0) / w, c > 1 ? 0.5 : 1) : 0, M = y ? { x: d.x + a * P, y: d.y + l * P } : d;
1830
+ c > 0 && o.push(`L ${M.x} ${M.y}`), y && o.push(
1831
+ `C ${d.x} ${d.y} ${d.x} ${d.y} ${b.x} ${b.y}`
1822
1832
  );
1823
1833
  });
1824
1834
  }
1825
1835
  return o.join(" ");
1826
- }, Xe = (t) => {
1827
- const e = t.hasSourceArrow ? v(
1828
- { x: t.arrowLength, y: w.y },
1829
- t.fromVector,
1830
- w
1831
- ) : w, o = t.hasTargetArrow ? v(
1836
+ }, Qe = (t) => {
1837
+ const e = t.hasSourceArrow ? f(
1838
+ { x: t.arrowLength, y: g.y },
1839
+ t.sourceDirection,
1840
+ g
1841
+ ) : g, o = t.hasTargetArrow ? f(
1832
1842
  { x: t.to.x - t.arrowLength, y: t.to.y },
1833
- t.toVector,
1843
+ t.targetDirection,
1834
1844
  t.to
1835
- ) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = v(
1836
- { x: s, y: w.y },
1837
- t.fromVector,
1838
- w
1839
- ), n = v(
1845
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = f(
1846
+ { x: s, y: g.y },
1847
+ t.sourceDirection,
1848
+ g
1849
+ ), n = f(
1840
1850
  { x: t.to.x - s, y: t.to.y },
1841
- t.toVector,
1851
+ t.targetDirection,
1842
1852
  t.to
1843
1853
  ), d = Math.max((h.x + n.x) / 2, i), c = t.to.y / 2, a = {
1844
1854
  x: t.flipX > 0 ? d : -i,
1845
1855
  y: h.y
1846
- }, l = { x: a.x, y: c }, g = {
1856
+ }, l = { x: a.x, y: c }, w = {
1847
1857
  x: t.flipX > 0 ? t.to.x - d : t.to.x + i,
1848
1858
  y: n.y
1849
- }, y = { x: g.x, y: c };
1850
- return V(
1851
- [e, h, a, l, y, g, n, o],
1859
+ }, v = { x: w.x, y: c };
1860
+ return R(
1861
+ [e, h, a, l, v, w, n, o],
1852
1862
  t.roundness
1853
1863
  );
1854
- }, Y = (t) => {
1855
- const e = t.hasSourceArrow ? v(
1856
- { x: t.arrowLength, y: w.y },
1857
- t.fromVector,
1858
- w
1859
- ) : w, o = t.hasTargetArrow ? v(
1864
+ }, j = (t) => {
1865
+ const e = t.hasSourceArrow ? f(
1866
+ { x: t.arrowLength, y: g.y },
1867
+ t.sourceDirection,
1868
+ g
1869
+ ) : g, o = t.hasTargetArrow ? f(
1860
1870
  { x: t.to.x - t.arrowLength, y: t.to.y },
1861
- t.toVector,
1871
+ t.targetDirection,
1862
1872
  t.to
1863
- ) : t.to, i = t.arrowLength + t.arrowOffset, s = v(
1864
- { x: i, y: w.y },
1865
- t.fromVector,
1866
- w
1867
- ), h = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = n * t.flipY, a = { x: s.x + d, y: s.y + c }, l = v(
1873
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = f(
1874
+ { x: i, y: g.y },
1875
+ t.sourceDirection,
1876
+ g
1877
+ ), h = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = n * t.flipY, a = { x: s.x + d, y: s.y + c }, l = f(
1868
1878
  { x: t.to.x - i, y: t.to.y },
1869
- t.toVector,
1879
+ t.targetDirection,
1870
1880
  t.to
1871
- ), g = { x: l.x + d, y: l.y + c };
1872
- return V(
1873
- [e, s, a, g, l, o],
1881
+ ), w = { x: l.x + d, y: l.y + c };
1882
+ return R(
1883
+ [e, s, a, w, l, o],
1874
1884
  t.roundness
1875
1885
  );
1876
- }, Ye = (t) => {
1877
- const e = t.hasSourceArrow ? v(
1878
- { x: t.arrowLength, y: w.y },
1879
- t.fromVector,
1880
- w
1881
- ) : w, o = t.hasTargetArrow ? v(
1886
+ }, _e = (t) => {
1887
+ const e = t.hasSourceArrow ? f(
1888
+ { x: t.arrowLength, y: g.y },
1889
+ t.sourceDirection,
1890
+ g
1891
+ ) : g, o = t.hasTargetArrow ? f(
1882
1892
  { x: t.to.x - t.arrowLength, y: t.to.y },
1883
- t.toVector,
1893
+ t.targetDirection,
1884
1894
  t.to
1885
- ) : t.to, i = t.arrowLength + t.arrowOffset, s = v(
1886
- { x: i, y: w.y },
1887
- t.fromVector,
1888
- w
1889
- ), h = v(
1895
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = f(
1896
+ { x: i, y: g.y },
1897
+ t.sourceDirection,
1898
+ g
1899
+ ), h = f(
1890
1900
  { x: t.to.x - i, y: t.to.y },
1891
- t.toVector,
1901
+ t.targetDirection,
1892
1902
  t.to
1893
1903
  );
1894
- return V([e, s, h, o], t.roundness);
1895
- }, He = (t) => {
1896
- const e = t.hasSourceArrow ? v(
1897
- { x: t.arrowLength, y: w.y },
1898
- t.fromVector,
1899
- w
1900
- ) : w, o = t.hasTargetArrow ? v(
1904
+ return R([e, s, h, o], t.roundness);
1905
+ }, qe = (t) => {
1906
+ const e = t.hasSourceArrow ? f(
1907
+ { x: t.arrowLength, y: g.y },
1908
+ t.sourceDirection,
1909
+ g
1910
+ ) : g, o = t.hasTargetArrow ? f(
1901
1911
  { x: t.to.x - t.arrowLength, y: t.to.y },
1902
- t.toVector,
1912
+ t.targetDirection,
1903
1913
  t.to
1904
- ) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = v(
1905
- { x: s, y: w.y },
1906
- t.fromVector,
1907
- w
1908
- ), n = v(
1914
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = f(
1915
+ { x: s, y: g.y },
1916
+ t.sourceDirection,
1917
+ g
1918
+ ), n = f(
1909
1919
  { x: t.to.x - s, y: t.to.y },
1910
- t.toVector,
1920
+ t.targetDirection,
1911
1921
  t.to
1912
1922
  ), d = Math.max((h.y + n.y) / 2, i), c = t.to.x / 2, a = {
1913
1923
  x: h.x,
1914
1924
  y: t.flipY > 0 ? d : -i
1915
- }, l = { x: c, y: a.y }, g = {
1925
+ }, l = { x: c, y: a.y }, w = {
1916
1926
  x: n.x,
1917
1927
  y: t.flipY > 0 ? t.to.y - d : t.to.y + i
1918
- }, y = { x: c, y: g.y };
1919
- return V(
1920
- [e, h, a, l, y, g, n, o],
1928
+ }, v = { x: c, y: w.y };
1929
+ return R(
1930
+ [e, h, a, l, v, w, n, o],
1921
1931
  t.roundness
1922
1932
  );
1923
- }, H = (t) => {
1933
+ }, G = (t) => {
1924
1934
  const e = t.arrowOffset, o = t.side, i = t.arrowLength + e, s = i + 2 * o, n = [
1925
- { x: t.arrowLength, y: w.y },
1926
- { x: i, y: w.y },
1935
+ { x: t.arrowLength, y: g.y },
1936
+ { x: i, y: g.y },
1927
1937
  { x: i, y: t.side },
1928
1938
  { x: s, y: t.side },
1929
1939
  { x: s, y: -t.side },
1930
1940
  { x: i, y: -t.side },
1931
- { x: i, y: w.y },
1932
- { x: t.arrowLength, y: w.y }
1941
+ { x: i, y: g.y },
1942
+ { x: t.arrowLength, y: g.y }
1933
1943
  ].map(
1934
- (c) => v(c, t.fromVector, w)
1935
- ), d = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
1936
- return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${V(n, t.roundness)}`;
1937
- }, je = (t) => {
1944
+ (c) => f(c, t.sourceDirection, g)
1945
+ ), d = `M ${g.x} ${g.y} L ${n[0].x} ${n[0].y} `;
1946
+ return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${R(n, t.roundness)}`;
1947
+ }, et = (t) => {
1938
1948
  const e = t.smallRadius, o = t.radius, i = Math.sqrt(e * e + o * o), s = e + o, h = t.arrowLength + i * (1 - o / s), n = e * o / s, c = [
1939
- { x: t.arrowLength, y: w.y },
1949
+ { x: t.arrowLength, y: g.y },
1940
1950
  { x: h, y: n },
1941
1951
  { x: h, y: -n }
1942
1952
  ].map(
1943
- (g) => v(g, t.fromVector, w)
1953
+ (w) => f(w, t.sourceDirection, g)
1944
1954
  ), a = [
1945
1955
  `M ${c[0].x} ${c[0].y}`,
1946
1956
  `A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
@@ -1948,40 +1958,23 @@ const $e = (t, e) => ({
1948
1958
  `A ${e} ${e} 0 0 1 ${c[0].x} ${c[0].y}`
1949
1959
  ].join(" "), l = `M 0 0 L ${c[0].x} ${c[0].y} `;
1950
1960
  return `${t.hasSourceArrow || t.hasTargetArrow ? "" : l}${a}`;
1951
- }, u = Object.freeze({
1952
- color: "#777777",
1953
- width: 1,
1954
- arrowLength: 15,
1955
- arrowWidth: 4,
1956
- arrowOffset: 15,
1957
- hasSourceArrow: !1,
1958
- hasTargetArrow: !1,
1959
- cycleRadius: 30,
1960
- cycleSquareSide: 30,
1961
- roundness: 10,
1962
- detourDistance: 100,
1963
- detourDirection: -Math.PI / 2,
1964
- detourDirectionVertical: 0,
1965
- smallCycleRadius: 15,
1966
- curvature: 90,
1967
- interactiveWidth: 10
1968
- }), ee = (t, e, o, i) => {
1969
- const h = [
1970
- w,
1971
- { x: o, y: i },
1972
- { x: o, y: -i }
1973
- ].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
1974
- return `${n} ${d} ${c} Z`;
1975
- }, te = (t) => {
1976
- const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1977
- return e.setAttribute("fill", t), e;
1978
- }, Ge = () => {
1961
+ }, le = (t, e) => {
1962
+ t.style.transform = `translate(${e.x}px, ${e.y}px)`, t.style.width = `${Math.max(e.width, 1)}px`, t.style.height = `${Math.max(e.height, 1)}px`;
1963
+ }, Z = Object.freeze({
1964
+ edgeColor: "--edge-color"
1965
+ }), ue = (t) => {
1966
+ const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1967
+ return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(Z.edgeColor, t), e;
1968
+ }, V = () => {
1969
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
1970
+ return t.setAttribute("fill", `var(${Z.edgeColor})`), t;
1971
+ }, ge = () => {
1979
1972
  const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
1980
1973
  return t.style.transformOrigin = "50% 50%", t;
1981
- }, Ze = (t, e) => {
1982
- const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
1983
- return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
1984
- }, Je = (t, e) => {
1974
+ }, we = (t) => {
1975
+ const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1976
+ return e.setAttribute("stroke", `var(${Z.edgeColor})`), e.setAttribute("stroke-width", `${t}`), e.setAttribute("fill", "none"), e;
1977
+ }, fe = (t, e) => {
1985
1978
  const o = {
1986
1979
  x: t.x + t.width / 2,
1987
1980
  y: t.y + t.height / 2
@@ -1997,30 +1990,52 @@ const $e = (t, e) => ({
1997
1990
  flipX: c,
1998
1991
  flipY: a
1999
1992
  };
2000
- }, Ke = () => {
2001
- const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2002
- return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
2003
- }, oe = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) });
2004
- class U {
1993
+ }, O = (t, e, o, i) => {
1994
+ const h = [
1995
+ g,
1996
+ { x: o, y: i },
1997
+ { x: o, y: -i }
1998
+ ].map((a) => f(a, t, g)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
1999
+ return `${n} ${d} ${c} Z`;
2000
+ }, u = Object.freeze({
2001
+ color: "#777777",
2002
+ width: 1,
2003
+ arrowLength: 15,
2004
+ arrowWidth: 4,
2005
+ arrowOffset: 15,
2006
+ hasSourceArrow: !1,
2007
+ hasTargetArrow: !1,
2008
+ cycleRadius: 30,
2009
+ cycleSquareSide: 30,
2010
+ roundness: 10,
2011
+ detourDistance: 100,
2012
+ detourDirection: -Math.PI / 2,
2013
+ detourDirectionVertical: 0,
2014
+ smallCycleRadius: 15,
2015
+ curvature: 90,
2016
+ interactiveWidth: 10,
2017
+ preOffset: 0
2018
+ }), re = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) });
2019
+ class C {
2005
2020
  constructor(e) {
2006
- r(this, "svg", Ke());
2007
- r(this, "group", Ge());
2021
+ r(this, "svg");
2022
+ r(this, "group", ge());
2008
2023
  r(this, "line");
2009
2024
  r(this, "sourceArrow", null);
2010
2025
  r(this, "targetArrow", null);
2011
- this.params = e, this.svg.appendChild(this.group), this.line = Ze(e.color, e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = te(e.color), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = te(e.color), this.group.appendChild(this.targetArrow));
2026
+ this.params = e, this.svg = ue(e.color), this.svg.appendChild(this.group), this.line = we(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = V(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = V(), this.group.appendChild(this.targetArrow));
2012
2027
  }
2013
2028
  render(e) {
2014
- const { x: o, y: i, width: s, height: h, flipX: n, flipY: d } = Je(
2029
+ const { x: o, y: i, width: s, height: h, flipX: n, flipY: d } = fe(
2015
2030
  e.from,
2016
2031
  e.to
2017
2032
  );
2018
- this.svg.style.transform = `translate(${o}px, ${i}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
2019
- const c = oe(
2033
+ le(this.svg, { x: o, y: i, width: s, height: h }), this.group.style.transform = `scale(${n}, ${d})`;
2034
+ const c = re(
2020
2035
  e.from.direction,
2021
2036
  n,
2022
2037
  d
2023
- ), a = oe(
2038
+ ), a = re(
2024
2039
  e.to.direction,
2025
2040
  n,
2026
2041
  d
@@ -2028,36 +2043,36 @@ class U {
2028
2043
  x: s,
2029
2044
  y: h
2030
2045
  };
2031
- let g = a, y = -this.params.arrowLength, p;
2032
- e.from.portId === e.to.portId ? (p = this.params.createCyclePath, g = c, y = this.params.arrowLength) : e.from.nodeId === e.to.nodeId ? p = this.params.createDetourPath : p = this.params.createLinePath;
2033
- const f = p(
2046
+ let w = a, v = -this.params.arrowLength, A;
2047
+ e.from.portId === e.to.portId ? (A = this.params.createCyclePath, w = c, v = this.params.arrowLength) : e.from.nodeId === e.to.nodeId ? A = this.params.createDetourPath : A = this.params.createLinePath;
2048
+ const y = A(
2034
2049
  c,
2035
2050
  a,
2036
2051
  l,
2037
2052
  n,
2038
2053
  d
2039
2054
  );
2040
- if (this.line.setAttribute("d", f), this.sourceArrow) {
2041
- const A = ee(
2055
+ if (this.line.setAttribute("d", y), this.sourceArrow) {
2056
+ const p = O(
2042
2057
  c,
2043
- w,
2058
+ g,
2044
2059
  this.params.arrowLength,
2045
2060
  this.params.arrowWidth
2046
2061
  );
2047
- this.sourceArrow.setAttribute("d", A);
2062
+ this.sourceArrow.setAttribute("d", p);
2048
2063
  }
2049
2064
  if (this.targetArrow) {
2050
- const A = ee(
2051
- g,
2065
+ const p = O(
2066
+ w,
2052
2067
  l,
2053
- y,
2068
+ v,
2054
2069
  this.params.arrowWidth
2055
2070
  );
2056
- this.targetArrow.setAttribute("d", A);
2071
+ this.targetArrow.setAttribute("d", p);
2057
2072
  }
2058
2073
  }
2059
2074
  }
2060
- class Qe {
2075
+ class tt {
2061
2076
  constructor(e) {
2062
2077
  r(this, "svg");
2063
2078
  r(this, "group");
@@ -2074,18 +2089,18 @@ class Qe {
2074
2089
  r(this, "hasSourceArrow");
2075
2090
  r(this, "hasTargetArrow");
2076
2091
  r(this, "lineShape");
2077
- r(this, "createCyclePath", (e) => je({
2078
- fromVector: e,
2092
+ r(this, "createCyclePath", (e) => et({
2093
+ sourceDirection: e,
2079
2094
  radius: this.portCycleRadius,
2080
2095
  smallRadius: this.portCycleSmallRadius,
2081
2096
  arrowLength: this.arrowLength,
2082
2097
  hasSourceArrow: this.hasSourceArrow,
2083
2098
  hasTargetArrow: this.hasTargetArrow
2084
2099
  }));
2085
- r(this, "createDetourPath", (e, o, i, s, h) => Oe({
2100
+ r(this, "createDetourPath", (e, o, i, s, h) => Ke({
2086
2101
  to: i,
2087
- fromVector: e,
2088
- toVector: o,
2102
+ sourceDirection: e,
2103
+ targetDirection: o,
2089
2104
  flipX: s,
2090
2105
  flipY: h,
2091
2106
  arrowLength: this.arrowLength,
@@ -2095,16 +2110,16 @@ class Qe {
2095
2110
  hasSourceArrow: this.hasSourceArrow,
2096
2111
  hasTargetArrow: this.hasTargetArrow
2097
2112
  }));
2098
- r(this, "createLinePath", (e, o, i) => ze({
2113
+ r(this, "createLinePath", (e, o, i) => Je({
2099
2114
  to: i,
2100
- fromVector: e,
2101
- toVector: o,
2115
+ sourceDirection: e,
2116
+ targetDirection: o,
2102
2117
  arrowLength: this.arrowLength,
2103
2118
  curvature: this.curvature,
2104
2119
  hasSourceArrow: this.hasSourceArrow,
2105
2120
  hasTargetArrow: this.hasTargetArrow
2106
2121
  }));
2107
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new U({
2122
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new C({
2108
2123
  color: (e == null ? void 0 : e.color) ?? u.color,
2109
2124
  width: (e == null ? void 0 : e.width) ?? u.width,
2110
2125
  arrowLength: this.arrowLength,
@@ -2120,7 +2135,7 @@ class Qe {
2120
2135
  this.lineShape.render(e);
2121
2136
  }
2122
2137
  }
2123
- class _e {
2138
+ class ot {
2124
2139
  constructor(e) {
2125
2140
  r(this, "svg");
2126
2141
  r(this, "group");
@@ -2137,8 +2152,8 @@ class _e {
2137
2152
  r(this, "hasSourceArrow");
2138
2153
  r(this, "hasTargetArrow");
2139
2154
  r(this, "lineShape");
2140
- r(this, "createCyclePath", (e) => H({
2141
- fromVector: e,
2155
+ r(this, "createCyclePath", (e) => G({
2156
+ sourceDirection: e,
2142
2157
  arrowLength: this.arrowLength,
2143
2158
  side: this.cycleSquareSide,
2144
2159
  arrowOffset: this.arrowOffset,
@@ -2146,10 +2161,10 @@ class _e {
2146
2161
  hasSourceArrow: this.hasSourceArrow,
2147
2162
  hasTargetArrow: this.hasTargetArrow
2148
2163
  }));
2149
- r(this, "createDetourPath", (e, o, i, s, h) => Y({
2164
+ r(this, "createDetourPath", (e, o, i, s, h) => j({
2150
2165
  to: i,
2151
- fromVector: e,
2152
- toVector: o,
2166
+ sourceDirection: e,
2167
+ targetDirection: o,
2153
2168
  flipX: s,
2154
2169
  flipY: h,
2155
2170
  arrowLength: this.arrowLength,
@@ -2160,10 +2175,10 @@ class _e {
2160
2175
  hasSourceArrow: this.hasSourceArrow,
2161
2176
  hasTargetArrow: this.hasTargetArrow
2162
2177
  }));
2163
- r(this, "createLinePath", (e, o, i, s) => Xe({
2178
+ r(this, "createLinePath", (e, o, i, s) => Qe({
2164
2179
  to: i,
2165
- fromVector: e,
2166
- toVector: o,
2180
+ sourceDirection: e,
2181
+ targetDirection: o,
2167
2182
  flipX: s,
2168
2183
  arrowLength: this.arrowLength,
2169
2184
  arrowOffset: this.arrowOffset,
@@ -2177,7 +2192,7 @@ class _e {
2177
2192
  o,
2178
2193
  this.arrowOffset,
2179
2194
  this.cycleSquareSide / 2
2180
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new U({
2195
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new C({
2181
2196
  color: (e == null ? void 0 : e.color) ?? u.color,
2182
2197
  width: (e == null ? void 0 : e.width) ?? u.width,
2183
2198
  arrowLength: this.arrowLength,
@@ -2193,7 +2208,7 @@ class _e {
2193
2208
  this.lineShape.render(e);
2194
2209
  }
2195
2210
  }
2196
- class qe {
2211
+ class rt {
2197
2212
  constructor(e) {
2198
2213
  r(this, "svg");
2199
2214
  r(this, "group");
@@ -2210,8 +2225,8 @@ class qe {
2210
2225
  r(this, "hasSourceArrow");
2211
2226
  r(this, "hasTargetArrow");
2212
2227
  r(this, "lineShape");
2213
- r(this, "createCyclePath", (e) => H({
2214
- fromVector: e,
2228
+ r(this, "createCyclePath", (e) => G({
2229
+ sourceDirection: e,
2215
2230
  arrowLength: this.arrowLength,
2216
2231
  side: this.cycleSquareSide,
2217
2232
  arrowOffset: this.arrowOffset,
@@ -2219,10 +2234,10 @@ class qe {
2219
2234
  hasSourceArrow: this.hasSourceArrow,
2220
2235
  hasTargetArrow: this.hasTargetArrow
2221
2236
  }));
2222
- r(this, "createDetourPath", (e, o, i, s, h) => Y({
2237
+ r(this, "createDetourPath", (e, o, i, s, h) => j({
2223
2238
  to: i,
2224
- fromVector: e,
2225
- toVector: o,
2239
+ sourceDirection: e,
2240
+ targetDirection: o,
2226
2241
  flipX: s,
2227
2242
  flipY: h,
2228
2243
  arrowLength: this.arrowLength,
@@ -2233,10 +2248,10 @@ class qe {
2233
2248
  hasSourceArrow: this.hasSourceArrow,
2234
2249
  hasTargetArrow: this.hasTargetArrow
2235
2250
  }));
2236
- r(this, "createLinePath", (e, o, i) => Ye({
2251
+ r(this, "createLinePath", (e, o, i) => _e({
2237
2252
  to: i,
2238
- fromVector: e,
2239
- toVector: o,
2253
+ sourceDirection: e,
2254
+ targetDirection: o,
2240
2255
  arrowLength: this.arrowLength,
2241
2256
  arrowOffset: this.arrowOffset,
2242
2257
  roundness: this.roundness,
@@ -2249,7 +2264,7 @@ class qe {
2249
2264
  o,
2250
2265
  this.arrowOffset,
2251
2266
  this.cycleSquareSide / 2
2252
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new U({
2267
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new C({
2253
2268
  color: (e == null ? void 0 : e.color) ?? u.color,
2254
2269
  width: (e == null ? void 0 : e.width) ?? u.width,
2255
2270
  arrowLength: this.arrowLength,
@@ -2265,7 +2280,7 @@ class qe {
2265
2280
  this.lineShape.render(e);
2266
2281
  }
2267
2282
  }
2268
- class et {
2283
+ class it {
2269
2284
  constructor(e) {
2270
2285
  r(this, "svg");
2271
2286
  r(this, "group");
@@ -2282,8 +2297,8 @@ class et {
2282
2297
  r(this, "hasSourceArrow");
2283
2298
  r(this, "hasTargetArrow");
2284
2299
  r(this, "lineShape");
2285
- r(this, "createCyclePath", (e) => H({
2286
- fromVector: e,
2300
+ r(this, "createCyclePath", (e) => G({
2301
+ sourceDirection: e,
2287
2302
  arrowLength: this.arrowLength,
2288
2303
  side: this.cycleSquareSide,
2289
2304
  arrowOffset: this.arrowOffset,
@@ -2291,10 +2306,10 @@ class et {
2291
2306
  hasSourceArrow: this.hasSourceArrow,
2292
2307
  hasTargetArrow: this.hasTargetArrow
2293
2308
  }));
2294
- r(this, "createDetourPath", (e, o, i, s, h) => Y({
2309
+ r(this, "createDetourPath", (e, o, i, s, h) => j({
2295
2310
  to: i,
2296
- fromVector: e,
2297
- toVector: o,
2311
+ sourceDirection: e,
2312
+ targetDirection: o,
2298
2313
  flipX: s,
2299
2314
  flipY: h,
2300
2315
  arrowLength: this.arrowLength,
@@ -2305,10 +2320,10 @@ class et {
2305
2320
  hasSourceArrow: this.hasSourceArrow,
2306
2321
  hasTargetArrow: this.hasTargetArrow
2307
2322
  }));
2308
- r(this, "createLinePath", (e, o, i, s, h) => He({
2323
+ r(this, "createLinePath", (e, o, i, s, h) => qe({
2309
2324
  to: i,
2310
- fromVector: e,
2311
- toVector: o,
2325
+ sourceDirection: e,
2326
+ targetDirection: o,
2312
2327
  flipY: h,
2313
2328
  arrowLength: this.arrowLength,
2314
2329
  arrowOffset: this.arrowOffset,
@@ -2322,7 +2337,7 @@ class et {
2322
2337
  o,
2323
2338
  this.arrowOffset,
2324
2339
  this.cycleSquareSide / 2
2325
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new U({
2340
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new C({
2326
2341
  color: (e == null ? void 0 : e.color) ?? u.color,
2327
2342
  width: (e == null ? void 0 : e.width) ?? u.width,
2328
2343
  arrowLength: this.arrowLength,
@@ -2338,39 +2353,142 @@ class et {
2338
2353
  this.lineShape.render(e);
2339
2354
  }
2340
2355
  }
2341
- const tt = () => {
2356
+ const ie = (t) => {
2357
+ if (t.diagonalDistance === 0)
2358
+ return "";
2359
+ const e = t.offset / t.diagonalDistance, o = t.flip * t.to.x, i = t.flip * t.to.y, s = {
2360
+ x: o * e + t.shift.x,
2361
+ y: i * e + t.shift.y
2362
+ }, h = {
2363
+ x: o / t.diagonalDistance,
2364
+ y: i / t.diagonalDistance
2365
+ };
2366
+ return O(
2367
+ h,
2368
+ s,
2369
+ t.arrowLength,
2370
+ t.arrowWidth
2371
+ );
2372
+ }, se = (t) => {
2373
+ const e = t.hasArrow ? t.arrowLength : 0, o = t.offset + e, i = t.flip * o / t.diagonalDistance;
2374
+ return {
2375
+ x: t.to.x * i + t.shift.x,
2376
+ y: t.to.y * i + t.shift.y
2377
+ };
2378
+ }, st = (t) => {
2379
+ const e = se({
2380
+ diagonalDistance: t.diagonalDistance,
2381
+ to: t.to,
2382
+ offset: t.sourceOffset,
2383
+ hasArrow: t.hasSourceArrow,
2384
+ flip: 1,
2385
+ shift: g,
2386
+ arrowLength: t.arrowLength
2387
+ }), o = se({
2388
+ diagonalDistance: t.diagonalDistance,
2389
+ to: t.to,
2390
+ offset: t.targetOffset,
2391
+ hasArrow: t.hasTargetArrow,
2392
+ flip: -1,
2393
+ shift: t.to,
2394
+ arrowLength: t.arrowLength
2395
+ });
2396
+ return `M ${e.x} ${e.y} L ${o.x} ${o.y}`;
2397
+ };
2398
+ class nt {
2399
+ constructor(e) {
2400
+ r(this, "svg");
2401
+ r(this, "group", ge());
2402
+ r(this, "line");
2403
+ r(this, "sourceArrow", null);
2404
+ r(this, "targetArrow", null);
2405
+ r(this, "color");
2406
+ r(this, "width");
2407
+ r(this, "arrowLength");
2408
+ r(this, "arrowWidth");
2409
+ r(this, "sourceOffset");
2410
+ r(this, "targetOffset");
2411
+ this.color = (e == null ? void 0 : e.color) ?? u.color, this.width = (e == null ? void 0 : e.width) ?? u.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? u.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? u.preOffset, this.svg = ue(this.color), this.svg.appendChild(this.group), this.line = we(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = V(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = V(), this.group.appendChild(this.targetArrow));
2412
+ }
2413
+ render(e) {
2414
+ const { x: o, y: i, width: s, height: h, flipX: n, flipY: d } = fe(
2415
+ e.from,
2416
+ e.to
2417
+ );
2418
+ le(this.svg, { x: o, y: i, width: s, height: h }), this.group.style.transform = `scale(${n}, ${d})`;
2419
+ const c = Math.sqrt(s * s + h * h), a = { x: s, y: h };
2420
+ if (c > 0) {
2421
+ const l = st({
2422
+ diagonalDistance: c,
2423
+ to: a,
2424
+ sourceOffset: this.sourceOffset,
2425
+ targetOffset: this.targetOffset,
2426
+ hasSourceArrow: this.sourceArrow !== null,
2427
+ hasTargetArrow: this.targetArrow !== null,
2428
+ arrowLength: this.arrowLength
2429
+ });
2430
+ this.line.setAttribute("d", l);
2431
+ } else
2432
+ this.line.setAttribute("d", "");
2433
+ if (this.sourceArrow) {
2434
+ const l = ie({
2435
+ diagonalDistance: c,
2436
+ to: a,
2437
+ offset: this.sourceOffset,
2438
+ flip: 1,
2439
+ shift: g,
2440
+ arrowWidth: this.arrowWidth,
2441
+ arrowLength: this.arrowLength
2442
+ });
2443
+ this.sourceArrow.setAttribute("d", l);
2444
+ }
2445
+ if (this.targetArrow) {
2446
+ const l = ie({
2447
+ diagonalDistance: c,
2448
+ to: a,
2449
+ offset: this.targetOffset,
2450
+ flip: -1,
2451
+ shift: a,
2452
+ arrowWidth: this.arrowWidth,
2453
+ arrowLength: this.arrowLength
2454
+ });
2455
+ this.targetArrow.setAttribute("d", l);
2456
+ }
2457
+ }
2458
+ }
2459
+ const ht = () => {
2342
2460
  const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
2343
2461
  return t.style.pointerEvents = "auto", t.style.cursor = "pointer", t;
2344
- }, ot = (t) => {
2462
+ }, dt = (t) => {
2345
2463
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
2346
2464
  return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${t}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
2347
- }, re = (t) => {
2465
+ }, ne = (t) => {
2348
2466
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
2349
2467
  return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${t}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
2350
2468
  };
2351
- class rt extends Error {
2469
+ class ct extends Error {
2352
2470
  constructor(e) {
2353
2471
  super(e), this.name = "InteractiveEdgeError";
2354
2472
  }
2355
2473
  }
2356
- class ce {
2474
+ class ve {
2357
2475
  constructor(e, o) {
2358
2476
  r(this, "svg");
2359
2477
  r(this, "group");
2360
2478
  r(this, "line");
2361
2479
  r(this, "sourceArrow");
2362
2480
  r(this, "targetArrow");
2363
- r(this, "handle", tt());
2481
+ r(this, "handle", ht());
2364
2482
  r(this, "interactiveLine");
2365
2483
  r(this, "interactiveSourceArrow", null);
2366
2484
  r(this, "interactiveTargetArrow", null);
2367
- if (this.structuredEdge = e, e instanceof ce)
2368
- throw new rt(
2485
+ if (this.structuredEdge = e, e instanceof ve)
2486
+ throw new ct(
2369
2487
  "interactive edge can be configured only once"
2370
2488
  );
2371
2489
  this.svg = this.structuredEdge.svg, this.group = this.structuredEdge.group, this.line = this.structuredEdge.line, this.sourceArrow = this.structuredEdge.sourceArrow, this.targetArrow = this.structuredEdge.targetArrow;
2372
2490
  const i = (o == null ? void 0 : o.width) ?? u.interactiveWidth;
2373
- this.interactiveLine = ot(i), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = re(i), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = re(i), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle);
2491
+ this.interactiveLine = dt(i), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = ne(i), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = ne(i), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle);
2374
2492
  }
2375
2493
  render(e) {
2376
2494
  this.structuredEdge.render(e);
@@ -2385,12 +2503,12 @@ class ce {
2385
2503
  }
2386
2504
  }
2387
2505
  }
2388
- const it = (t) => {
2506
+ const at = (t) => {
2389
2507
  if (typeof t == "function")
2390
2508
  return t;
2391
2509
  switch (t == null ? void 0 : t.type) {
2392
2510
  case "straight":
2393
- return () => new qe({
2511
+ return () => new rt({
2394
2512
  color: t.color,
2395
2513
  width: t.width,
2396
2514
  arrowLength: t.arrowLength,
@@ -2404,7 +2522,7 @@ const it = (t) => {
2404
2522
  detourDirection: t.detourDirection
2405
2523
  });
2406
2524
  case "horizontal":
2407
- return () => new _e({
2525
+ return () => new ot({
2408
2526
  color: t.color,
2409
2527
  width: t.width,
2410
2528
  arrowLength: t.arrowLength,
@@ -2418,7 +2536,7 @@ const it = (t) => {
2418
2536
  detourDirection: t.detourDirection
2419
2537
  });
2420
2538
  case "vertical":
2421
- return () => new et({
2539
+ return () => new it({
2422
2540
  color: t.color,
2423
2541
  width: t.width,
2424
2542
  arrowLength: t.arrowLength,
@@ -2431,8 +2549,19 @@ const it = (t) => {
2431
2549
  detourDistance: t.detourDistance,
2432
2550
  detourDirection: t.detourDirection
2433
2551
  });
2552
+ case "direct":
2553
+ return () => new nt({
2554
+ color: t.color,
2555
+ width: t.width,
2556
+ arrowLength: t.arrowLength,
2557
+ arrowWidth: t.arrowWidth,
2558
+ hasSourceArrow: t.hasSourceArrow,
2559
+ hasTargetArrow: t.hasTargetArrow,
2560
+ sourceOffset: t.sourceOffset,
2561
+ targetOffset: t.targetOffset
2562
+ });
2434
2563
  default:
2435
- return () => new Qe({
2564
+ return () => new tt({
2436
2565
  color: t.color,
2437
2566
  width: t.width,
2438
2567
  arrowLength: t.arrowLength,
@@ -2446,27 +2575,27 @@ const it = (t) => {
2446
2575
  detourDirection: t.detourDirection
2447
2576
  });
2448
2577
  }
2449
- }, st = (t) => {
2578
+ }, lt = (t) => {
2450
2579
  var o, i, s, h, n;
2451
- const e = ke(
2580
+ const e = Ze(
2452
2581
  (o = t.nodes) == null ? void 0 : o.priority,
2453
2582
  (i = t.edges) == null ? void 0 : i.priority
2454
2583
  );
2455
2584
  return {
2456
2585
  nodes: {
2457
- centerFn: ((s = t.nodes) == null ? void 0 : s.centerFn) ?? $e,
2586
+ centerFn: ((s = t.nodes) == null ? void 0 : s.centerFn) ?? je,
2458
2587
  priorityFn: e.nodesPriorityFn
2459
2588
  },
2460
2589
  ports: {
2461
2590
  direction: ((h = t.ports) == null ? void 0 : h.direction) ?? 0
2462
2591
  },
2463
2592
  edges: {
2464
- shapeFactory: it(((n = t.edges) == null ? void 0 : n.shape) ?? {}),
2593
+ shapeFactory: at(((n = t.edges) == null ? void 0 : n.shape) ?? {}),
2465
2594
  priorityFn: e.edgesPriorityFn
2466
2595
  }
2467
2596
  };
2468
2597
  };
2469
- class ht {
2598
+ class gt {
2470
2599
  constructor(e) {
2471
2600
  r(this, "element", null);
2472
2601
  r(this, "canvasDefaults", {});
@@ -2549,15 +2678,15 @@ class ht {
2549
2678
  "unable to build canvas when no attach element specified"
2550
2679
  );
2551
2680
  let e = this.boxRenderingTrigger;
2552
- this.virtualScrollConfig !== void 0 && e === void 0 && (e = new se());
2553
- const o = new de(), i = new Ae(), s = new We(this.element);
2554
- let h = new ie(
2681
+ this.virtualScrollConfig !== void 0 && e === void 0 && (e = new de());
2682
+ const o = new ae(), i = new Ne(), s = new He(this.element);
2683
+ let h = new he(
2555
2684
  o,
2556
2685
  i,
2557
2686
  s.main
2558
2687
  );
2559
- e !== void 0 && (h = new ve(h, o, e));
2560
- const n = st(this.canvasDefaults), d = new ne(
2688
+ e !== void 0 && (h = new be(h, o, e));
2689
+ const n = lt(this.canvasDefaults), d = new ce(
2561
2690
  this.element,
2562
2691
  o,
2563
2692
  i,
@@ -2566,30 +2695,30 @@ class ht {
2566
2695
  ), c = () => {
2567
2696
  s.destroy(), d.onBeforeDestroy.unsubscribe(c);
2568
2697
  };
2569
- return d.onBeforeDestroy.subscribe(c), this.hasBackground && O.configure(
2698
+ return d.onBeforeDestroy.subscribe(c), this.hasBackground && Y.configure(
2570
2699
  d,
2571
2700
  this.backgroundConfig,
2572
2701
  s.background
2573
- ), this.hasResizeReactiveNodes && F.configure(d), this.hasDraggableNode && k.configure(
2702
+ ), this.hasResizeReactiveNodes && k.configure(d), this.hasDraggableNode && z.configure(
2574
2703
  d,
2575
2704
  s.main,
2576
2705
  this.window,
2577
2706
  this.dragConfig
2578
- ), this.hasUserConnectablePorts && X.configure(
2707
+ ), this.hasUserConnectablePorts && H.configure(
2579
2708
  d,
2580
2709
  s.overlay,
2581
2710
  i,
2582
2711
  this.window,
2583
2712
  n,
2584
2713
  this.connectablePortsConfig
2585
- ), this.virtualScrollConfig !== void 0 ? z.configure(
2714
+ ), this.virtualScrollConfig !== void 0 ? X.configure(
2586
2715
  d,
2587
2716
  s.main,
2588
2717
  this.window,
2589
2718
  this.transformConfig,
2590
2719
  e,
2591
2720
  this.virtualScrollConfig
2592
- ) : this.hasTransformableViewport && I.configure(
2721
+ ) : this.hasTransformableViewport && U.configure(
2593
2722
  d,
2594
2723
  s.main,
2595
2724
  this.window,
@@ -2605,14 +2734,15 @@ class ht {
2605
2734
  }
2606
2735
  }
2607
2736
  export {
2608
- Qe as BezierEdgeShape,
2609
- ht as CanvasBuilder,
2610
- se as EventSubject,
2611
- _e as HorizontalEdgeShape,
2737
+ tt as BezierEdgeShape,
2738
+ gt as CanvasBuilder,
2739
+ nt as DirectEdgeShape,
2740
+ de as EventSubject,
2741
+ ot as HorizontalEdgeShape,
2612
2742
  S as HtmlGraphError,
2613
- rt as InteractiveEdgeError,
2614
- ce as InteractiveEdgeShape,
2615
- U as LineEdgeShape,
2616
- qe as StraightEdgeShape,
2617
- et as VerticalEdgeShape
2743
+ ct as InteractiveEdgeError,
2744
+ ve as InteractiveEdgeShape,
2745
+ C as LineEdgeShape,
2746
+ rt as StraightEdgeShape,
2747
+ it as VerticalEdgeShape
2618
2748
  };