@html-graph/html-graph 3.8.0 → 3.9.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 ve = Object.defineProperty;
2
+ var ye = (t, e, o) => e in t ? ve(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var r = (t, e, o) => ye(t, typeof e != "symbol" ? e + "" : e, o);
4
+ const Ae = () => {
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
+ }, pe = (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 ne {
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", Ae());
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
+ pe(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 xe {
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 Se {
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 xe(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 he {
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 he();
213
219
  return [t, t];
214
220
  };
215
- class ye {
221
+ class be {
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 Te {
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 de {
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 Te(this.graphStore), this.viewport = new be(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 Pe {
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 ce {
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 Pe());
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 _ = (t) => ({
787
797
  scale: 1 / t.scale,
788
798
  x: -t.x / t.scale,
789
799
  y: -t.y / t.scale
790
- }), Q = {
800
+ }), q = {
791
801
  scale: 1,
792
802
  x: 0,
793
803
  y: 0
794
804
  };
795
- class Ae {
805
+ class me {
796
806
  constructor() {
797
- r(this, "viewportMatrix", Q);
798
- r(this, "contentMatrix", Q);
807
+ r(this, "viewportMatrix", q);
808
+ r(this, "contentMatrix", q);
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 = _(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 = _(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 Ne = (t) => {
870
+ var v, A, y, E, p, 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 = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.dragCursor, d = n !== void 0 ? n : "grab", c = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.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
+ }, De = (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
+ }, Me = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, D = (t, e, o, i) => De(e, o, i) && Me(t, o, i), I = (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,26 +907,27 @@ 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,
920
928
  x: s.x,
921
929
  y: s.y
922
- }) && (e.stopImmediatePropagation(), this.grabbedNodeId = i, B(this.element, this.config.dragCursor), this.moveNodeOnTop(i), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
930
+ }) && (e.stopImmediatePropagation(), this.grabbedNodeId = i, I(this.element, this.config.dragCursor), this.moveNodeOnTop(i), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
923
931
  passive: !0
924
932
  }), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
925
933
  passive: !0
@@ -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 (!D(
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 (!D(
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 = Ne(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);
@@ -1025,7 +1035,7 @@ class k {
1025
1035
  element: e.element,
1026
1036
  x: e.x,
1027
1037
  y: e.y
1028
- }), this.grabbedNodeId = null, B(this.element, null), this.removeMouseDragListeners();
1038
+ }), this.grabbedNodeId = null, I(this.element, null), this.removeMouseDragListeners();
1029
1039
  }
1030
1040
  removeMouseDragListeners() {
1031
1041
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
@@ -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 Le = (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
+ }, Ve = (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
+ }, Re = (t) => (e) => t.reduce(
1083
1093
  (o, i) => i({
1084
1094
  prevTransform: e.prevTransform,
1085
1095
  nextTransform: o,
@@ -1087,59 +1097,59 @@ const me = (t) => {
1087
1097
  canvasHeight: e.canvasHeight
1088
1098
  }),
1089
1099
  e.nextTransform
1090
- ), _ = (t) => {
1100
+ ), ee = (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 Ve({
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 Le({
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
+ }, Ie = (t) => {
1118
+ var y, E, p, b, T, P, M, L, Z, 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 = Re(
1112
1122
  i.map(
1113
- (P) => _(P)
1123
+ (m) => ee(m)
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 = ee(i) : s = (m) => m.nextTransform;
1126
+ const h = ((E = t == null ? void 0 : t.shift) == null ? void 0 : E.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((p = t == null ? void 0 : t.events) == null ? void 0 : p.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 : (m) => m.button === 0, l = (P = t == null ? void 0 : t.shift) == null ? void 0 : P.mouseUpEventVerifier, w = l !== void 0 ? l : (m) => m.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: ((Z = t == null ? void 0 : t.events) == null ? void 0 : Z.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: ((J = t == null ? void 0 : t.scale) == null ? void 0 : J.wheelFinishTimeout) ?? 500,
1143
+ onResizeTransformStarted: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onResizeTransformStarted) ?? (() => {
1134
1144
  }),
1135
- onResizeTransformFinished: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onResizeTransformFinished) ?? (() => {
1145
+ onResizeTransformFinished: ((Q = t == null ? void 0 : t.events) == null ? void 0 : Q.onResizeTransformFinished) ?? (() => {
1136
1146
  })
1137
1147
  };
1138
- }, Ne = (t, e, o) => ({
1148
+ }, Be = (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
+ }), Ue = (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
@@ -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);
@@ -1172,14 +1182,14 @@ class I {
1172
1182
  this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element.removeEventListener("wheel", this.preventWheelScaleListener), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
1173
1183
  });
1174
1184
  r(this, "onMouseDown", (e) => {
1175
- this.element === null || !this.config.mouseDownEventVerifier(e) || (B(this.element, this.config.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
1185
+ this.element === null || !this.config.mouseDownEventVerifier(e) || (I(this.element, this.config.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
1176
1186
  passive: !0
1177
1187
  }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
1178
1188
  passive: !0
1179
1189
  }), this.startRegisteredTransform());
1180
1190
  });
1181
1191
  r(this, "onWindowMouseMove", (e) => {
1182
- const o = M(
1192
+ const o = D(
1183
1193
  this.window,
1184
1194
  this.element,
1185
1195
  e.clientX,
@@ -1219,7 +1229,7 @@ class I {
1219
1229
  r(this, "onWindowTouchMove", (e) => {
1220
1230
  const o = R(e);
1221
1231
  if (!o.touches.every(
1222
- (s) => M(this.window, this.element, s[0], s[1])
1232
+ (s) => D(this.window, this.element, s[0], s[1])
1223
1233
  )) {
1224
1234
  this.stopTouchDrag();
1225
1235
  return;
@@ -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 = Ie(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 = Be(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 = Ue(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,
@@ -1286,7 +1296,7 @@ class I {
1286
1296
  this.performTransform(c);
1287
1297
  }
1288
1298
  stopMouseDrag() {
1289
- B(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
1299
+ I(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
1290
1300
  }
1291
1301
  removeMouseDragListeners() {
1292
1302
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -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, E, p, 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) ?? (() => {
1350
- }), 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 = {
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 = ((E = s == null ? void 0 : s.events) == null ? void 0 : E.onTransformChange) ?? (() => {
1360
+ }), l = ((p = s == null ? void 0 : s.events) == null ? void 0 : p.onBeforeTransformChange) ?? (() => {
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 Ce = () => {
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
+ }, We = () => {
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
+ }, $e = () => {
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
+ }, Fe = (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
+ }, Oe = (t) => t instanceof SVGElement ? t : Fe(
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
+ ), ke = (t) => {
1438
+ const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, i = (e == null ? void 0 : e.height) ?? 25, s = Oe(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", Ce());
1449
+ r(this, "patternRenderingRectangle", We());
1450
+ r(this, "pattern", $e());
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 = ke(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 ze = (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 (!D(
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 (!D(
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 = ze(n);
1591
+ const d = new ce(), c = new ne(
1582
1592
  d,
1583
1593
  this.viewportStore,
1584
1594
  this.overlayLayer
1585
1595
  );
1586
- this.overlayCanvas = new ne(
1596
+ this.overlayCanvas = new de(
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 E = this.isDirect ? A : y, p = this.isDirect ? y : A;
1634
+ this.createOverlayGraph(E, p);
1625
1635
  }
1626
1636
  hookPortEvents(e) {
1627
1637
  e.addEventListener("mousedown", this.onPortMouseDown, {
@@ -1697,59 +1707,59 @@ 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 Xe = () => {
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 Ye {
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", Xe());
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 He = (t, e) => ({
1729
1739
  x: t / 2,
1730
1740
  y: e / 2
1731
- }), $ = (t) => () => t, q = $(0), Fe = () => {
1741
+ }), F = (t) => () => t, te = F(0), je = () => {
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
+ }, Ge = (t, e) => {
1745
+ let o = te, i = te;
1746
+ const s = je();
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 },
1757
+ }, Ze = (t) => {
1758
+ const e = f(
1759
+ { x: t.arrowLength, y: g.y },
1750
1760
  t.fromVector,
1751
- w
1752
- ), o = v(
1761
+ g
1762
+ ), o = f(
1753
1763
  { x: t.to.x - t.arrowLength, y: t.to.y },
1754
1764
  t.toVector,
1755
1765
  t.to
@@ -1759,49 +1769,49 @@ const $e = (t, e) => ({
1759
1769
  }, s = {
1760
1770
  x: o.x - t.toVector.x * t.curvature,
1761
1771
  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}`;
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 },
1774
+ }, Je = (t) => {
1775
+ const e = t.hasSourceArrow ? f(
1776
+ { x: t.arrowLength, y: g.y },
1767
1777
  t.fromVector,
1768
- w
1769
- ) : w, o = t.hasTargetArrow ? v(
1778
+ g
1779
+ ) : g, o = t.hasTargetArrow ? f(
1770
1780
  { x: t.to.x - t.arrowLength, y: t.to.y },
1771
1781
  t.toVector,
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 },
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 },
1775
1785
  t.fromVector,
1776
- w
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
1792
  t.toVector,
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 = {
1797
+ }, v = { x: (a.x + w.x) / 2, y: (a.y + w.y) / 2 }, A = {
1788
1798
  x: c.x + t.curvature * t.fromVector.x,
1789
1799
  y: c.y + t.curvature * t.fromVector.y
1790
- }, f = {
1800
+ }, y = {
1791
1801
  x: l.x - t.curvature * t.toVector.x,
1792
1802
  y: l.y - t.curvature * t.toVector.y
1793
- }, A = {
1803
+ }, E = {
1794
1804
  x: c.x + n,
1795
1805
  y: c.y + d
1796
- }, E = {
1806
+ }, p = {
1797
1807
  x: l.x + n,
1798
1808
  y: l.y + d
1799
1809
  };
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} ${E.x} ${E.y} ${v.x} ${v.y}`,
1814
+ `C ${p.x} ${p.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
1805
1815
  `L ${o.x} ${o.y}`
1806
1816
  ].join(" ");
1807
1817
  }, V = (t, e) => {
@@ -1810,137 +1820,137 @@ const $e = (t, e) => ({
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 p = n !== 0 ? Math.min((y ? e : 0) / n, c < i - 1 ? 0.5 : 1) : 0, b = y ? { x: d.x + s * p, y: d.y + h * p } : 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 },
1836
+ }, Ke = (t) => {
1837
+ const e = t.hasSourceArrow ? f(
1838
+ { x: t.arrowLength, y: g.y },
1829
1839
  t.fromVector,
1830
- w
1831
- ) : w, o = t.hasTargetArrow ? v(
1840
+ g
1841
+ ) : g, o = t.hasTargetArrow ? f(
1832
1842
  { x: t.to.x - t.arrowLength, y: t.to.y },
1833
1843
  t.toVector,
1834
1844
  t.to
1835
- ) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = v(
1836
- { x: s, y: w.y },
1845
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = f(
1846
+ { x: s, y: g.y },
1837
1847
  t.fromVector,
1838
- w
1839
- ), n = v(
1848
+ g
1849
+ ), n = f(
1840
1850
  { x: t.to.x - s, y: t.to.y },
1841
1851
  t.toVector,
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 };
1859
+ }, v = { x: w.x, y: c };
1850
1860
  return V(
1851
- [e, h, a, l, y, g, n, o],
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 },
1864
+ }, j = (t) => {
1865
+ const e = t.hasSourceArrow ? f(
1866
+ { x: t.arrowLength, y: g.y },
1857
1867
  t.fromVector,
1858
- w
1859
- ) : w, o = t.hasTargetArrow ? v(
1868
+ g
1869
+ ) : g, o = t.hasTargetArrow ? f(
1860
1870
  { x: t.to.x - t.arrowLength, y: t.to.y },
1861
1871
  t.toVector,
1862
1872
  t.to
1863
- ) : t.to, i = t.arrowLength + t.arrowOffset, s = v(
1864
- { x: i, y: w.y },
1873
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = f(
1874
+ { x: i, y: g.y },
1865
1875
  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(
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
1879
  t.toVector,
1870
1880
  t.to
1871
- ), g = { x: l.x + d, y: l.y + c };
1881
+ ), w = { x: l.x + d, y: l.y + c };
1872
1882
  return V(
1873
- [e, s, a, g, l, o],
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 },
1886
+ }, Qe = (t) => {
1887
+ const e = t.hasSourceArrow ? f(
1888
+ { x: t.arrowLength, y: g.y },
1879
1889
  t.fromVector,
1880
- w
1881
- ) : w, o = t.hasTargetArrow ? v(
1890
+ g
1891
+ ) : g, o = t.hasTargetArrow ? f(
1882
1892
  { x: t.to.x - t.arrowLength, y: t.to.y },
1883
1893
  t.toVector,
1884
1894
  t.to
1885
- ) : t.to, i = t.arrowLength + t.arrowOffset, s = v(
1886
- { x: i, y: w.y },
1895
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = f(
1896
+ { x: i, y: g.y },
1887
1897
  t.fromVector,
1888
- w
1889
- ), h = v(
1898
+ g
1899
+ ), h = f(
1890
1900
  { x: t.to.x - i, y: t.to.y },
1891
1901
  t.toVector,
1892
1902
  t.to
1893
1903
  );
1894
1904
  return V([e, s, h, o], t.roundness);
1895
- }, He = (t) => {
1896
- const e = t.hasSourceArrow ? v(
1897
- { x: t.arrowLength, y: w.y },
1905
+ }, _e = (t) => {
1906
+ const e = t.hasSourceArrow ? f(
1907
+ { x: t.arrowLength, y: g.y },
1898
1908
  t.fromVector,
1899
- w
1900
- ) : w, o = t.hasTargetArrow ? v(
1909
+ g
1910
+ ) : g, o = t.hasTargetArrow ? f(
1901
1911
  { x: t.to.x - t.arrowLength, y: t.to.y },
1902
1912
  t.toVector,
1903
1913
  t.to
1904
- ) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = v(
1905
- { x: s, y: w.y },
1914
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = f(
1915
+ { x: s, y: g.y },
1906
1916
  t.fromVector,
1907
- w
1908
- ), n = v(
1917
+ g
1918
+ ), n = f(
1909
1919
  { x: t.to.x - s, y: t.to.y },
1910
1920
  t.toVector,
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 };
1928
+ }, v = { x: c, y: w.y };
1919
1929
  return V(
1920
- [e, h, a, l, y, g, n, o],
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} `;
1944
+ (c) => f(c, t.fromVector, g)
1945
+ ), d = `M ${g.x} ${g.y} L ${n[0].x} ${n[0].y} `;
1936
1946
  return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${V(n, t.roundness)}`;
1937
- }, je = (t) => {
1947
+ }, qe = (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.fromVector, 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,6 +1958,8 @@ 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}`;
1961
+ }, ae = (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`;
1951
1963
  }, u = Object.freeze({
1952
1964
  color: "#777777",
1953
1965
  width: 1,
@@ -1964,24 +1976,25 @@ const $e = (t, e) => ({
1964
1976
  detourDirectionVertical: 0,
1965
1977
  smallCycleRadius: 15,
1966
1978
  curvature: 90,
1967
- interactiveWidth: 10
1968
- }), ee = (t, e, o, i) => {
1979
+ interactiveWidth: 10,
1980
+ preOffset: 0
1981
+ }), O = (t, e, o, i) => {
1969
1982
  const h = [
1970
- w,
1983
+ g,
1971
1984
  { x: o, y: i },
1972
1985
  { 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}`;
1986
+ ].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}`;
1974
1987
  return `${n} ${d} ${c} Z`;
1975
- }, te = (t) => {
1988
+ }, B = (t) => {
1976
1989
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1977
1990
  return e.setAttribute("fill", t), e;
1978
- }, Ge = () => {
1991
+ }, le = () => {
1979
1992
  const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
1980
1993
  return t.style.transformOrigin = "50% 50%", t;
1981
- }, Ze = (t, e) => {
1994
+ }, ue = (t, e) => {
1982
1995
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
1983
1996
  return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
1984
- }, Je = (t, e) => {
1997
+ }, ge = (t, e) => {
1985
1998
  const o = {
1986
1999
  x: t.x + t.width / 2,
1987
2000
  y: t.y + t.height / 2
@@ -1997,25 +2010,25 @@ const $e = (t, e) => ({
1997
2010
  flipX: c,
1998
2011
  flipY: a
1999
2012
  };
2000
- }, Ke = () => {
2013
+ }, we = () => {
2001
2014
  const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2002
2015
  return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
2003
2016
  }, oe = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) });
2004
- class U {
2017
+ class C {
2005
2018
  constructor(e) {
2006
- r(this, "svg", Ke());
2007
- r(this, "group", Ge());
2019
+ r(this, "svg", we());
2020
+ r(this, "group", le());
2008
2021
  r(this, "line");
2009
2022
  r(this, "sourceArrow", null);
2010
2023
  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));
2024
+ this.params = e, this.svg.appendChild(this.group), this.line = ue(e.color, e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = B(e.color), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = B(e.color), this.group.appendChild(this.targetArrow));
2012
2025
  }
2013
2026
  render(e) {
2014
- const { x: o, y: i, width: s, height: h, flipX: n, flipY: d } = Je(
2027
+ const { x: o, y: i, width: s, height: h, flipX: n, flipY: d } = ge(
2015
2028
  e.from,
2016
2029
  e.to
2017
2030
  );
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})`;
2031
+ ae(this.svg, { x: o, y: i, width: s, height: h }), this.group.style.transform = `scale(${n}, ${d})`;
2019
2032
  const c = oe(
2020
2033
  e.from.direction,
2021
2034
  n,
@@ -2028,36 +2041,36 @@ class U {
2028
2041
  x: s,
2029
2042
  y: h
2030
2043
  };
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(
2044
+ let w = a, v = -this.params.arrowLength, A;
2045
+ 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;
2046
+ const y = A(
2034
2047
  c,
2035
2048
  a,
2036
2049
  l,
2037
2050
  n,
2038
2051
  d
2039
2052
  );
2040
- if (this.line.setAttribute("d", f), this.sourceArrow) {
2041
- const A = ee(
2053
+ if (this.line.setAttribute("d", y), this.sourceArrow) {
2054
+ const E = O(
2042
2055
  c,
2043
- w,
2056
+ g,
2044
2057
  this.params.arrowLength,
2045
2058
  this.params.arrowWidth
2046
2059
  );
2047
- this.sourceArrow.setAttribute("d", A);
2060
+ this.sourceArrow.setAttribute("d", E);
2048
2061
  }
2049
2062
  if (this.targetArrow) {
2050
- const A = ee(
2051
- g,
2063
+ const E = O(
2064
+ w,
2052
2065
  l,
2053
- y,
2066
+ v,
2054
2067
  this.params.arrowWidth
2055
2068
  );
2056
- this.targetArrow.setAttribute("d", A);
2069
+ this.targetArrow.setAttribute("d", E);
2057
2070
  }
2058
2071
  }
2059
2072
  }
2060
- class Qe {
2073
+ class et {
2061
2074
  constructor(e) {
2062
2075
  r(this, "svg");
2063
2076
  r(this, "group");
@@ -2074,7 +2087,7 @@ class Qe {
2074
2087
  r(this, "hasSourceArrow");
2075
2088
  r(this, "hasTargetArrow");
2076
2089
  r(this, "lineShape");
2077
- r(this, "createCyclePath", (e) => je({
2090
+ r(this, "createCyclePath", (e) => qe({
2078
2091
  fromVector: e,
2079
2092
  radius: this.portCycleRadius,
2080
2093
  smallRadius: this.portCycleSmallRadius,
@@ -2082,7 +2095,7 @@ class Qe {
2082
2095
  hasSourceArrow: this.hasSourceArrow,
2083
2096
  hasTargetArrow: this.hasTargetArrow
2084
2097
  }));
2085
- r(this, "createDetourPath", (e, o, i, s, h) => Oe({
2098
+ r(this, "createDetourPath", (e, o, i, s, h) => Je({
2086
2099
  to: i,
2087
2100
  fromVector: e,
2088
2101
  toVector: o,
@@ -2095,7 +2108,7 @@ class Qe {
2095
2108
  hasSourceArrow: this.hasSourceArrow,
2096
2109
  hasTargetArrow: this.hasTargetArrow
2097
2110
  }));
2098
- r(this, "createLinePath", (e, o, i) => ze({
2111
+ r(this, "createLinePath", (e, o, i) => Ze({
2099
2112
  to: i,
2100
2113
  fromVector: e,
2101
2114
  toVector: o,
@@ -2104,7 +2117,7 @@ class Qe {
2104
2117
  hasSourceArrow: this.hasSourceArrow,
2105
2118
  hasTargetArrow: this.hasTargetArrow
2106
2119
  }));
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({
2120
+ 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
2121
  color: (e == null ? void 0 : e.color) ?? u.color,
2109
2122
  width: (e == null ? void 0 : e.width) ?? u.width,
2110
2123
  arrowLength: this.arrowLength,
@@ -2120,7 +2133,7 @@ class Qe {
2120
2133
  this.lineShape.render(e);
2121
2134
  }
2122
2135
  }
2123
- class _e {
2136
+ class tt {
2124
2137
  constructor(e) {
2125
2138
  r(this, "svg");
2126
2139
  r(this, "group");
@@ -2137,7 +2150,7 @@ class _e {
2137
2150
  r(this, "hasSourceArrow");
2138
2151
  r(this, "hasTargetArrow");
2139
2152
  r(this, "lineShape");
2140
- r(this, "createCyclePath", (e) => H({
2153
+ r(this, "createCyclePath", (e) => G({
2141
2154
  fromVector: e,
2142
2155
  arrowLength: this.arrowLength,
2143
2156
  side: this.cycleSquareSide,
@@ -2146,7 +2159,7 @@ class _e {
2146
2159
  hasSourceArrow: this.hasSourceArrow,
2147
2160
  hasTargetArrow: this.hasTargetArrow
2148
2161
  }));
2149
- r(this, "createDetourPath", (e, o, i, s, h) => Y({
2162
+ r(this, "createDetourPath", (e, o, i, s, h) => j({
2150
2163
  to: i,
2151
2164
  fromVector: e,
2152
2165
  toVector: o,
@@ -2160,7 +2173,7 @@ class _e {
2160
2173
  hasSourceArrow: this.hasSourceArrow,
2161
2174
  hasTargetArrow: this.hasTargetArrow
2162
2175
  }));
2163
- r(this, "createLinePath", (e, o, i, s) => Xe({
2176
+ r(this, "createLinePath", (e, o, i, s) => Ke({
2164
2177
  to: i,
2165
2178
  fromVector: e,
2166
2179
  toVector: o,
@@ -2177,7 +2190,7 @@ class _e {
2177
2190
  o,
2178
2191
  this.arrowOffset,
2179
2192
  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({
2193
+ ), 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
2194
  color: (e == null ? void 0 : e.color) ?? u.color,
2182
2195
  width: (e == null ? void 0 : e.width) ?? u.width,
2183
2196
  arrowLength: this.arrowLength,
@@ -2193,7 +2206,7 @@ class _e {
2193
2206
  this.lineShape.render(e);
2194
2207
  }
2195
2208
  }
2196
- class qe {
2209
+ class ot {
2197
2210
  constructor(e) {
2198
2211
  r(this, "svg");
2199
2212
  r(this, "group");
@@ -2210,7 +2223,7 @@ class qe {
2210
2223
  r(this, "hasSourceArrow");
2211
2224
  r(this, "hasTargetArrow");
2212
2225
  r(this, "lineShape");
2213
- r(this, "createCyclePath", (e) => H({
2226
+ r(this, "createCyclePath", (e) => G({
2214
2227
  fromVector: e,
2215
2228
  arrowLength: this.arrowLength,
2216
2229
  side: this.cycleSquareSide,
@@ -2219,7 +2232,7 @@ class qe {
2219
2232
  hasSourceArrow: this.hasSourceArrow,
2220
2233
  hasTargetArrow: this.hasTargetArrow
2221
2234
  }));
2222
- r(this, "createDetourPath", (e, o, i, s, h) => Y({
2235
+ r(this, "createDetourPath", (e, o, i, s, h) => j({
2223
2236
  to: i,
2224
2237
  fromVector: e,
2225
2238
  toVector: o,
@@ -2233,7 +2246,7 @@ class qe {
2233
2246
  hasSourceArrow: this.hasSourceArrow,
2234
2247
  hasTargetArrow: this.hasTargetArrow
2235
2248
  }));
2236
- r(this, "createLinePath", (e, o, i) => Ye({
2249
+ r(this, "createLinePath", (e, o, i) => Qe({
2237
2250
  to: i,
2238
2251
  fromVector: e,
2239
2252
  toVector: o,
@@ -2249,7 +2262,7 @@ class qe {
2249
2262
  o,
2250
2263
  this.arrowOffset,
2251
2264
  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({
2265
+ ), 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
2266
  color: (e == null ? void 0 : e.color) ?? u.color,
2254
2267
  width: (e == null ? void 0 : e.width) ?? u.width,
2255
2268
  arrowLength: this.arrowLength,
@@ -2265,7 +2278,7 @@ class qe {
2265
2278
  this.lineShape.render(e);
2266
2279
  }
2267
2280
  }
2268
- class et {
2281
+ class rt {
2269
2282
  constructor(e) {
2270
2283
  r(this, "svg");
2271
2284
  r(this, "group");
@@ -2282,7 +2295,7 @@ class et {
2282
2295
  r(this, "hasSourceArrow");
2283
2296
  r(this, "hasTargetArrow");
2284
2297
  r(this, "lineShape");
2285
- r(this, "createCyclePath", (e) => H({
2298
+ r(this, "createCyclePath", (e) => G({
2286
2299
  fromVector: e,
2287
2300
  arrowLength: this.arrowLength,
2288
2301
  side: this.cycleSquareSide,
@@ -2291,7 +2304,7 @@ class et {
2291
2304
  hasSourceArrow: this.hasSourceArrow,
2292
2305
  hasTargetArrow: this.hasTargetArrow
2293
2306
  }));
2294
- r(this, "createDetourPath", (e, o, i, s, h) => Y({
2307
+ r(this, "createDetourPath", (e, o, i, s, h) => j({
2295
2308
  to: i,
2296
2309
  fromVector: e,
2297
2310
  toVector: o,
@@ -2305,7 +2318,7 @@ class et {
2305
2318
  hasSourceArrow: this.hasSourceArrow,
2306
2319
  hasTargetArrow: this.hasTargetArrow
2307
2320
  }));
2308
- r(this, "createLinePath", (e, o, i, s, h) => He({
2321
+ r(this, "createLinePath", (e, o, i, s, h) => _e({
2309
2322
  to: i,
2310
2323
  fromVector: e,
2311
2324
  toVector: o,
@@ -2322,7 +2335,7 @@ class et {
2322
2335
  o,
2323
2336
  this.arrowOffset,
2324
2337
  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({
2338
+ ), 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
2339
  color: (e == null ? void 0 : e.color) ?? u.color,
2327
2340
  width: (e == null ? void 0 : e.width) ?? u.width,
2328
2341
  arrowLength: this.arrowLength,
@@ -2338,39 +2351,142 @@ class et {
2338
2351
  this.lineShape.render(e);
2339
2352
  }
2340
2353
  }
2341
- const tt = () => {
2354
+ const re = (t) => {
2355
+ if (t.diagonalDistance === 0)
2356
+ return "";
2357
+ const e = t.offset / t.diagonalDistance, o = t.flip * t.to.x, i = t.flip * t.to.y, s = {
2358
+ x: o * e + t.shift.x,
2359
+ y: i * e + t.shift.y
2360
+ }, h = {
2361
+ x: o / t.diagonalDistance,
2362
+ y: i / t.diagonalDistance
2363
+ };
2364
+ return O(
2365
+ h,
2366
+ s,
2367
+ t.arrowLength,
2368
+ t.arrowWidth
2369
+ );
2370
+ }, ie = (t) => {
2371
+ const e = t.hasArrow ? t.arrowLength : 0, o = t.offset + e, i = t.flip * o / t.diagonalDistance;
2372
+ return {
2373
+ x: t.to.x * i + t.shift.x,
2374
+ y: t.to.y * i + t.shift.y
2375
+ };
2376
+ }, it = (t) => {
2377
+ const e = ie({
2378
+ diagonalDistance: t.diagonalDistance,
2379
+ to: t.to,
2380
+ offset: t.sourceOffset,
2381
+ hasArrow: t.hasSourceArrow,
2382
+ flip: 1,
2383
+ shift: g,
2384
+ arrowLength: t.arrowLength
2385
+ }), o = ie({
2386
+ diagonalDistance: t.diagonalDistance,
2387
+ to: t.to,
2388
+ offset: t.targetOffset,
2389
+ hasArrow: t.hasTargetArrow,
2390
+ flip: -1,
2391
+ shift: t.to,
2392
+ arrowLength: t.arrowLength
2393
+ });
2394
+ return `M ${e.x} ${e.y} L ${o.x} ${o.y}`;
2395
+ };
2396
+ class st {
2397
+ constructor(e) {
2398
+ r(this, "svg", we());
2399
+ r(this, "group", le());
2400
+ r(this, "line");
2401
+ r(this, "sourceArrow", null);
2402
+ r(this, "targetArrow", null);
2403
+ r(this, "color");
2404
+ r(this, "width");
2405
+ r(this, "arrowLength");
2406
+ r(this, "arrowWidth");
2407
+ r(this, "sourceOffset");
2408
+ r(this, "targetOffset");
2409
+ 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.appendChild(this.group), this.line = ue(this.color, this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = B(this.color), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = B(this.color), this.group.appendChild(this.targetArrow));
2410
+ }
2411
+ render(e) {
2412
+ const { x: o, y: i, width: s, height: h, flipX: n, flipY: d } = ge(
2413
+ e.from,
2414
+ e.to
2415
+ );
2416
+ ae(this.svg, { x: o, y: i, width: s, height: h }), this.group.style.transform = `scale(${n}, ${d})`;
2417
+ const c = Math.sqrt(s * s + h * h), a = { x: s, y: h };
2418
+ if (c > 0) {
2419
+ const l = it({
2420
+ diagonalDistance: c,
2421
+ to: a,
2422
+ sourceOffset: this.sourceOffset,
2423
+ targetOffset: this.targetOffset,
2424
+ hasSourceArrow: this.sourceArrow !== null,
2425
+ hasTargetArrow: this.targetArrow !== null,
2426
+ arrowLength: this.arrowLength
2427
+ });
2428
+ this.line.setAttribute("d", l);
2429
+ } else
2430
+ this.line.setAttribute("d", "");
2431
+ if (this.sourceArrow) {
2432
+ const l = re({
2433
+ diagonalDistance: c,
2434
+ to: a,
2435
+ offset: this.sourceOffset,
2436
+ flip: 1,
2437
+ shift: g,
2438
+ arrowWidth: this.arrowWidth,
2439
+ arrowLength: this.arrowLength
2440
+ });
2441
+ this.sourceArrow.setAttribute("d", l);
2442
+ }
2443
+ if (this.targetArrow) {
2444
+ const l = re({
2445
+ diagonalDistance: c,
2446
+ to: a,
2447
+ offset: this.targetOffset,
2448
+ flip: -1,
2449
+ shift: a,
2450
+ arrowWidth: this.arrowWidth,
2451
+ arrowLength: this.arrowLength
2452
+ });
2453
+ this.targetArrow.setAttribute("d", l);
2454
+ }
2455
+ }
2456
+ }
2457
+ const nt = () => {
2342
2458
  const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
2343
2459
  return t.style.pointerEvents = "auto", t.style.cursor = "pointer", t;
2344
- }, ot = (t) => {
2460
+ }, ht = (t) => {
2345
2461
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
2346
2462
  return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${t}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
2347
- }, re = (t) => {
2463
+ }, se = (t) => {
2348
2464
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
2349
2465
  return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${t}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
2350
2466
  };
2351
- class rt extends Error {
2467
+ class dt extends Error {
2352
2468
  constructor(e) {
2353
2469
  super(e), this.name = "InteractiveEdgeError";
2354
2470
  }
2355
2471
  }
2356
- class ce {
2472
+ class fe {
2357
2473
  constructor(e, o) {
2358
2474
  r(this, "svg");
2359
2475
  r(this, "group");
2360
2476
  r(this, "line");
2361
2477
  r(this, "sourceArrow");
2362
2478
  r(this, "targetArrow");
2363
- r(this, "handle", tt());
2479
+ r(this, "handle", nt());
2364
2480
  r(this, "interactiveLine");
2365
2481
  r(this, "interactiveSourceArrow", null);
2366
2482
  r(this, "interactiveTargetArrow", null);
2367
- if (this.structuredEdge = e, e instanceof ce)
2368
- throw new rt(
2483
+ if (this.structuredEdge = e, e instanceof fe)
2484
+ throw new dt(
2369
2485
  "interactive edge can be configured only once"
2370
2486
  );
2371
2487
  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
2488
  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);
2489
+ this.interactiveLine = ht(i), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = se(i), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = se(i), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle);
2374
2490
  }
2375
2491
  render(e) {
2376
2492
  this.structuredEdge.render(e);
@@ -2385,12 +2501,12 @@ class ce {
2385
2501
  }
2386
2502
  }
2387
2503
  }
2388
- const it = (t) => {
2504
+ const ct = (t) => {
2389
2505
  if (typeof t == "function")
2390
2506
  return t;
2391
2507
  switch (t == null ? void 0 : t.type) {
2392
2508
  case "straight":
2393
- return () => new qe({
2509
+ return () => new ot({
2394
2510
  color: t.color,
2395
2511
  width: t.width,
2396
2512
  arrowLength: t.arrowLength,
@@ -2404,7 +2520,7 @@ const it = (t) => {
2404
2520
  detourDirection: t.detourDirection
2405
2521
  });
2406
2522
  case "horizontal":
2407
- return () => new _e({
2523
+ return () => new tt({
2408
2524
  color: t.color,
2409
2525
  width: t.width,
2410
2526
  arrowLength: t.arrowLength,
@@ -2418,7 +2534,7 @@ const it = (t) => {
2418
2534
  detourDirection: t.detourDirection
2419
2535
  });
2420
2536
  case "vertical":
2421
- return () => new et({
2537
+ return () => new rt({
2422
2538
  color: t.color,
2423
2539
  width: t.width,
2424
2540
  arrowLength: t.arrowLength,
@@ -2431,8 +2547,19 @@ const it = (t) => {
2431
2547
  detourDistance: t.detourDistance,
2432
2548
  detourDirection: t.detourDirection
2433
2549
  });
2550
+ case "direct":
2551
+ return () => new st({
2552
+ color: t.color,
2553
+ width: t.width,
2554
+ arrowLength: t.arrowLength,
2555
+ arrowWidth: t.arrowWidth,
2556
+ hasSourceArrow: t.hasSourceArrow,
2557
+ hasTargetArrow: t.hasTargetArrow,
2558
+ sourceOffset: t.sourceOffset,
2559
+ targetOffset: t.targetOffset
2560
+ });
2434
2561
  default:
2435
- return () => new Qe({
2562
+ return () => new et({
2436
2563
  color: t.color,
2437
2564
  width: t.width,
2438
2565
  arrowLength: t.arrowLength,
@@ -2446,27 +2573,27 @@ const it = (t) => {
2446
2573
  detourDirection: t.detourDirection
2447
2574
  });
2448
2575
  }
2449
- }, st = (t) => {
2576
+ }, at = (t) => {
2450
2577
  var o, i, s, h, n;
2451
- const e = ke(
2578
+ const e = Ge(
2452
2579
  (o = t.nodes) == null ? void 0 : o.priority,
2453
2580
  (i = t.edges) == null ? void 0 : i.priority
2454
2581
  );
2455
2582
  return {
2456
2583
  nodes: {
2457
- centerFn: ((s = t.nodes) == null ? void 0 : s.centerFn) ?? $e,
2584
+ centerFn: ((s = t.nodes) == null ? void 0 : s.centerFn) ?? He,
2458
2585
  priorityFn: e.nodesPriorityFn
2459
2586
  },
2460
2587
  ports: {
2461
2588
  direction: ((h = t.ports) == null ? void 0 : h.direction) ?? 0
2462
2589
  },
2463
2590
  edges: {
2464
- shapeFactory: it(((n = t.edges) == null ? void 0 : n.shape) ?? {}),
2591
+ shapeFactory: ct(((n = t.edges) == null ? void 0 : n.shape) ?? {}),
2465
2592
  priorityFn: e.edgesPriorityFn
2466
2593
  }
2467
2594
  };
2468
2595
  };
2469
- class ht {
2596
+ class ut {
2470
2597
  constructor(e) {
2471
2598
  r(this, "element", null);
2472
2599
  r(this, "canvasDefaults", {});
@@ -2549,15 +2676,15 @@ class ht {
2549
2676
  "unable to build canvas when no attach element specified"
2550
2677
  );
2551
2678
  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(
2679
+ this.virtualScrollConfig !== void 0 && e === void 0 && (e = new he());
2680
+ const o = new ce(), i = new me(), s = new Ye(this.element);
2681
+ let h = new ne(
2555
2682
  o,
2556
2683
  i,
2557
2684
  s.main
2558
2685
  );
2559
- e !== void 0 && (h = new ve(h, o, e));
2560
- const n = st(this.canvasDefaults), d = new ne(
2686
+ e !== void 0 && (h = new Se(h, o, e));
2687
+ const n = at(this.canvasDefaults), d = new de(
2561
2688
  this.element,
2562
2689
  o,
2563
2690
  i,
@@ -2566,30 +2693,30 @@ class ht {
2566
2693
  ), c = () => {
2567
2694
  s.destroy(), d.onBeforeDestroy.unsubscribe(c);
2568
2695
  };
2569
- return d.onBeforeDestroy.subscribe(c), this.hasBackground && O.configure(
2696
+ return d.onBeforeDestroy.subscribe(c), this.hasBackground && Y.configure(
2570
2697
  d,
2571
2698
  this.backgroundConfig,
2572
2699
  s.background
2573
- ), this.hasResizeReactiveNodes && F.configure(d), this.hasDraggableNode && k.configure(
2700
+ ), this.hasResizeReactiveNodes && k.configure(d), this.hasDraggableNode && z.configure(
2574
2701
  d,
2575
2702
  s.main,
2576
2703
  this.window,
2577
2704
  this.dragConfig
2578
- ), this.hasUserConnectablePorts && X.configure(
2705
+ ), this.hasUserConnectablePorts && H.configure(
2579
2706
  d,
2580
2707
  s.overlay,
2581
2708
  i,
2582
2709
  this.window,
2583
2710
  n,
2584
2711
  this.connectablePortsConfig
2585
- ), this.virtualScrollConfig !== void 0 ? z.configure(
2712
+ ), this.virtualScrollConfig !== void 0 ? X.configure(
2586
2713
  d,
2587
2714
  s.main,
2588
2715
  this.window,
2589
2716
  this.transformConfig,
2590
2717
  e,
2591
2718
  this.virtualScrollConfig
2592
- ) : this.hasTransformableViewport && I.configure(
2719
+ ) : this.hasTransformableViewport && U.configure(
2593
2720
  d,
2594
2721
  s.main,
2595
2722
  this.window,
@@ -2605,14 +2732,15 @@ class ht {
2605
2732
  }
2606
2733
  }
2607
2734
  export {
2608
- Qe as BezierEdgeShape,
2609
- ht as CanvasBuilder,
2610
- se as EventSubject,
2611
- _e as HorizontalEdgeShape,
2735
+ et as BezierEdgeShape,
2736
+ ut as CanvasBuilder,
2737
+ st as DirectEdgeShape,
2738
+ he as EventSubject,
2739
+ tt as HorizontalEdgeShape,
2612
2740
  S as HtmlGraphError,
2613
- rt as InteractiveEdgeError,
2614
- ce as InteractiveEdgeShape,
2615
- U as LineEdgeShape,
2616
- qe as StraightEdgeShape,
2617
- et as VerticalEdgeShape
2741
+ dt as InteractiveEdgeError,
2742
+ fe as InteractiveEdgeShape,
2743
+ C as LineEdgeShape,
2744
+ ot as StraightEdgeShape,
2745
+ rt as VerticalEdgeShape
2618
2746
  };