@html-graph/html-graph 2.2.2 → 2.3.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,12 +1,25 @@
1
- var tt = Object.defineProperty;
2
- var et = (e, t, o) => t in e ? tt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
- var i = (e, t, o) => et(e, typeof t != "symbol" ? t + "" : t, o);
4
- class ot {
5
- constructor(t) {
6
- this.graphStore = t;
7
- }
8
- getNode(t) {
9
- const o = this.graphStore.getNode(t);
1
+ var te = Object.defineProperty;
2
+ var oe = (t, e, o) => e in t ? te(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var i = (t, e, o) => oe(t, typeof e != "symbol" ? e + "" : e, o);
4
+ class re {
5
+ constructor(e) {
6
+ i(this, "onAfterNodeAdded");
7
+ i(this, "onAfterNodeCoordinatesUpdated");
8
+ i(this, "onAfterNodePriorityUpdated");
9
+ i(this, "onBeforeNodeRemoved");
10
+ i(this, "onAfterPortAdded");
11
+ i(this, "onAfterPortDirectionUpdated");
12
+ i(this, "onBeforePortRemoved");
13
+ i(this, "onAfterEdgeAdded");
14
+ i(this, "onAfterEdgeShapeUpdated");
15
+ i(this, "onAfterEdgeAdjacentPortsUpdated");
16
+ i(this, "onAfterEdgePriorityUpdated");
17
+ i(this, "onBeforeEdgeRemoved");
18
+ i(this, "onBeforeClear");
19
+ this.graphStore = e, this.onAfterNodeAdded = this.graphStore.onAfterNodeAdded, this.onAfterNodeCoordinatesUpdated = this.graphStore.onAfterNodeCoordinatesUpdated, this.onAfterNodePriorityUpdated = this.graphStore.onAfterNodePriorityUpdated, this.onBeforeNodeRemoved = this.graphStore.onBeforeNodeRemoved, this.onAfterPortAdded = this.graphStore.onAfterPortAdded, this.onAfterPortDirectionUpdated = this.graphStore.onAfterPortDirectionUpdated, this.onBeforePortRemoved = this.graphStore.onBeforePortRemoved, this.onAfterEdgeAdded = this.graphStore.onAfterEdgeAdded, this.onAfterEdgeShapeUpdated = this.graphStore.onAfterEdgeShapeUpdated, this.onAfterEdgeAdjacentPortsUpdated = this.graphStore.onAfterEdgeAdjacentPortsUpdated, this.onAfterEdgePriorityUpdated = this.graphStore.onAfterEdgePriorityUpdated, this.onBeforeEdgeRemoved = this.graphStore.onBeforeEdgeRemoved, this.onBeforeClear = this.graphStore.onBeforeClear;
20
+ }
21
+ getNode(e) {
22
+ const o = this.graphStore.getNode(e);
10
23
  return o === void 0 ? null : {
11
24
  element: o.element,
12
25
  x: o.x,
@@ -18,8 +31,8 @@ class ot {
18
31
  getAllNodeIds() {
19
32
  return this.graphStore.getAllNodeIds();
20
33
  }
21
- getPort(t) {
22
- const o = this.graphStore.getPort(t);
34
+ getPort(e) {
35
+ const o = this.graphStore.getPort(e);
23
36
  return o === void 0 ? null : {
24
37
  element: o.element,
25
38
  direction: o.direction,
@@ -29,52 +42,52 @@ class ot {
29
42
  getAllPortIds() {
30
43
  return this.graphStore.getAllPortIds();
31
44
  }
32
- getNodePortIds(t) {
33
- return this.graphStore.getNodePortIds(t) ?? null;
45
+ getNodePortIds(e) {
46
+ return this.graphStore.getNodePortIds(e) ?? null;
34
47
  }
35
48
  /**
36
49
  * @deprecated
37
50
  * use graph.getPort()?.nodeId ?? null instead
38
51
  */
39
- getPortNodeId(t) {
52
+ getPortNodeId(e) {
40
53
  var o;
41
- return ((o = this.graphStore.getPort(t)) == null ? void 0 : o.nodeId) ?? null;
54
+ return ((o = this.graphStore.getPort(e)) == null ? void 0 : o.nodeId) ?? null;
42
55
  }
43
56
  getAllEdgeIds() {
44
57
  return this.graphStore.getAllEdgeIds();
45
58
  }
46
- getEdge(t) {
47
- const o = this.graphStore.getEdge(t);
59
+ getEdge(e) {
60
+ const o = this.graphStore.getEdge(e);
48
61
  return o === void 0 ? null : { from: o.from, to: o.to, priority: o.priority };
49
62
  }
50
- getPortIncomingEdgeIds(t) {
51
- return this.graphStore.getPort(t) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(t);
63
+ getPortIncomingEdgeIds(e) {
64
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
52
65
  }
53
- getPortOutcomingEdgeIds(t) {
54
- return this.graphStore.getPort(t) === void 0 ? null : this.graphStore.getPortOutcomingEdgeIds(t);
66
+ getPortOutcomingEdgeIds(e) {
67
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutcomingEdgeIds(e);
55
68
  }
56
- getPortCycleEdgeIds(t) {
57
- return this.graphStore.getPort(t) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(t);
69
+ getPortCycleEdgeIds(e) {
70
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
58
71
  }
59
- getPortAdjacentEdgeIds(t) {
60
- return this.graphStore.getPort(t) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(t);
72
+ getPortAdjacentEdgeIds(e) {
73
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
61
74
  }
62
- getNodeIncomingEdgeIds(t) {
63
- return this.graphStore.getNode(t) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(t);
75
+ getNodeIncomingEdgeIds(e) {
76
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
64
77
  }
65
- getNodeOutcomingEdgeIds(t) {
66
- return this.graphStore.getNode(t) === void 0 ? null : this.graphStore.getNodeOutcomingEdgeIds(t);
78
+ getNodeOutcomingEdgeIds(e) {
79
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutcomingEdgeIds(e);
67
80
  }
68
- getNodeCycleEdgeIds(t) {
69
- return this.graphStore.getNode(t) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(t);
81
+ getNodeCycleEdgeIds(e) {
82
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
70
83
  }
71
- getNodeAdjacentEdgeIds(t) {
72
- return this.graphStore.getNode(t) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(t);
84
+ getNodeAdjacentEdgeIds(e) {
85
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
73
86
  }
74
87
  }
75
- class rt {
76
- constructor(t) {
77
- this.transformer = t;
88
+ class ie {
89
+ constructor(e) {
90
+ this.transformer = e;
78
91
  }
79
92
  getViewportMatrix() {
80
93
  return { ...this.transformer.getViewportMatrix() };
@@ -83,61 +96,65 @@ class rt {
83
96
  return { ...this.transformer.getContentMatrix() };
84
97
  }
85
98
  }
86
- class it {
87
- constructor(t, o, r) {
99
+ class se {
100
+ constructor(e, o, r) {
88
101
  i(this, "viewport");
89
102
  i(this, "graph");
90
- this.graphStore = t, this.viewportStore = o, this.htmlView = r, this.graph = new ot(this.graphStore), this.viewport = new rt(this.viewportStore);
103
+ this.graphStore = e, this.viewportStore = o, this.htmlView = r, this.graph = new re(this.graphStore), this.viewport = new ie(this.viewportStore);
91
104
  }
92
- attach(t) {
93
- this.htmlView.attach(t);
105
+ attach(e) {
106
+ this.htmlView.attach(e);
94
107
  }
95
108
  detach() {
96
109
  this.htmlView.detach();
97
110
  }
98
- addNode(t) {
99
- this.graphStore.addNode(t), this.htmlView.attachNode(t.id);
111
+ addNode(e) {
112
+ this.graphStore.addNode(e), this.htmlView.attachNode(e.id);
100
113
  }
101
- updateNode(t, o) {
102
- const r = this.graphStore.getNode(t);
103
- r.x = (o == null ? void 0 : o.x) ?? r.x, r.y = (o == null ? void 0 : o.y) ?? r.y, r.centerFn = o.centerFn ?? r.centerFn, this.htmlView.updateNodeCoordinates(t), this.graphStore.getNodeAdjacentEdgeIds(t).forEach((h) => {
104
- this.htmlView.renderEdge(h);
105
- }), o.priority !== void 0 && (r.priority = o.priority, this.htmlView.updateNodePriority(t));
114
+ updateNode(e, o) {
115
+ this.graphStore.updateNodeCoordinates(e, {
116
+ x: o.x,
117
+ y: o.y,
118
+ centerFn: o.centerFn
119
+ }), this.htmlView.updateNodeCoordinates(e), o.priority !== void 0 && (this.graphStore.updateNodePriority(e, o.priority), this.htmlView.updateNodePriority(e)), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((n) => {
120
+ this.htmlView.renderEdge(n);
121
+ });
106
122
  }
107
- removeNode(t) {
108
- this.graphStore.getNodePortIds(t).forEach((o) => {
123
+ removeNode(e) {
124
+ this.graphStore.getNodePortIds(e).forEach((o) => {
109
125
  this.unmarkPort(o);
110
- }), this.graphStore.removeNode(t), this.htmlView.detachNode(t);
126
+ }), this.graphStore.removeNode(e), this.htmlView.detachNode(e);
111
127
  }
112
- markPort(t) {
113
- this.graphStore.addPort(t);
128
+ markPort(e) {
129
+ this.graphStore.addPort(e);
114
130
  }
115
- updatePort(t, o) {
116
- const r = this.graphStore.getPort(t);
117
- r.direction = o.direction ?? r.direction, this.graphStore.getPortAdjacentEdgeIds(t).forEach((h) => {
118
- this.htmlView.renderEdge(h);
131
+ updatePort(e, o) {
132
+ o.direction !== void 0 && this.graphStore.updatePortDirection(e, o.direction), this.graphStore.getPortAdjacentEdgeIds(e).forEach((n) => {
133
+ this.htmlView.renderEdge(n);
119
134
  });
120
135
  }
121
- unmarkPort(t) {
122
- this.graphStore.getPortAdjacentEdgeIds(t).forEach((o) => {
136
+ unmarkPort(e) {
137
+ this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
123
138
  this.removeEdge(o);
124
- }), this.graphStore.removePort(t);
139
+ }), this.graphStore.removePort(e);
125
140
  }
126
- addEdge(t) {
127
- this.graphStore.addEdge(t), this.htmlView.attachEdge(t.id);
141
+ addEdge(e) {
142
+ this.graphStore.addEdge(e), this.htmlView.attachEdge(e.id);
128
143
  }
129
- updateEdge(t, o) {
130
- const r = this.graphStore.getEdge(t);
131
- o.shape !== void 0 && (r.shape = o.shape, this.htmlView.updateEdgeShape(t)), o.from !== void 0 && this.graphStore.updateEdgeFrom(t, o.from), o.to !== void 0 && this.graphStore.updateEdgeTo(t, o.to), this.htmlView.renderEdge(t), o.priority !== void 0 && (r.priority = o.priority, this.htmlView.updateEdgePriority(t));
144
+ updateEdge(e, o) {
145
+ (o.from !== void 0 || o.to !== void 0) && this.graphStore.updateEdgeAdjacentPorts(e, {
146
+ from: o.from,
147
+ to: o.to
148
+ }), o.shape !== void 0 && (this.graphStore.updateEdgeShape(e, o.shape), this.htmlView.updateEdgeShape(e)), this.htmlView.renderEdge(e), o.priority !== void 0 && (this.graphStore.updateEdgePriority(e, o.priority), this.htmlView.updateEdgePriority(e));
132
149
  }
133
- removeEdge(t) {
134
- this.graphStore.removeEdge(t), this.htmlView.detachEdge(t);
150
+ removeEdge(e) {
151
+ this.graphStore.removeEdge(e), this.htmlView.detachEdge(e);
135
152
  }
136
- patchViewportMatrix(t) {
137
- this.viewportStore.patchViewportMatrix(t);
153
+ patchViewportMatrix(e) {
154
+ this.viewportStore.patchViewportMatrix(e);
138
155
  }
139
- patchContentMatrix(t) {
140
- this.viewportStore.patchContentMatrix(t);
156
+ patchContentMatrix(e) {
157
+ this.viewportStore.patchContentMatrix(e);
141
158
  }
142
159
  clear() {
143
160
  this.htmlView.clear(), this.graphStore.clear();
@@ -146,57 +163,57 @@ class it {
146
163
  this.clear(), this.htmlView.destroy();
147
164
  }
148
165
  }
149
- const C = (e, t, o) => {
150
- const { x: r, y: n, width: h, height: s } = e.getBoundingClientRect();
151
- return t >= r && t <= r + h && o >= n && o <= n + s;
152
- }, $ = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, W = (e, t) => {
153
- t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
154
- }, st = (e) => {
155
- var g, y, x, v, A, S;
156
- const t = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
157
- }), o = ((y = e == null ? void 0 : e.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((x = e == null ? void 0 : e.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
158
- }), n = (e == null ? void 0 : e.moveOnTop) === !1, h = (v = e == null ? void 0 : e.mouse) == null ? void 0 : v.dragCursor, s = h !== void 0 ? h : "grab", c = (A = e == null ? void 0 : e.mouse) == null ? void 0 : A.mouseDownEventVerifier, d = c !== void 0 ? c : (T) => T.button === 0, a = (S = e == null ? void 0 : e.mouse) == null ? void 0 : S.mouseUpEventVerifier;
166
+ const $ = (t, e, o) => {
167
+ const { x: r, y: n, width: h, height: s } = t.getBoundingClientRect();
168
+ return e >= r && e <= r + h && o >= n && o <= n + s;
169
+ }, W = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, R = (t, e) => {
170
+ e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
171
+ }, ne = (t) => {
172
+ var g, f, x, y, S, p;
173
+ const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
174
+ }), o = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), r = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
175
+ }), n = (t == null ? void 0 : t.moveOnTop) === !1, h = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, s = h !== void 0 ? h : "grab", d = (S = t == null ? void 0 : t.mouse) == null ? void 0 : S.mouseDownEventVerifier, c = d !== void 0 ? d : (T) => T.button === 0, a = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseUpEventVerifier;
159
176
  return {
160
177
  freezePriority: n,
161
178
  dragCursor: s,
162
- mouseDownEventVerifier: d,
179
+ mouseDownEventVerifier: c,
163
180
  mouseUpEventVerifier: a !== void 0 ? a : (T) => T.button === 0,
164
- onNodeDrag: t,
181
+ onNodeDrag: e,
165
182
  onBeforeNodeDrag: o,
166
183
  onNodeDragFinished: r
167
184
  };
168
185
  };
169
- class nt {
170
- constructor(t, o) {
186
+ class he {
187
+ constructor(e, o) {
171
188
  i(this, "graph");
172
189
  i(this, "viewport");
173
190
  i(this, "maxNodePriority", 0);
174
191
  i(this, "nodes", /* @__PURE__ */ new Map());
175
192
  i(this, "grabbedNodeId", null);
176
193
  i(this, "element", null);
177
- i(this, "onWindowMouseMove", (t) => {
178
- if (this.element !== null && (!C(this.element, t.clientX, t.clientY) || !$(this.window, t.clientX, t.clientY))) {
194
+ i(this, "onWindowMouseMove", (e) => {
195
+ if (this.element !== null && (!$(this.element, e.clientX, e.clientY) || !W(this.window, e.clientX, e.clientY))) {
179
196
  this.cancelMouseDrag();
180
197
  return;
181
198
  }
182
- this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
199
+ this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
183
200
  });
184
- i(this, "onWindowMouseUp", (t) => {
185
- this.options.mouseUpEventVerifier(t) && this.cancelMouseDrag();
201
+ i(this, "onWindowMouseUp", (e) => {
202
+ this.options.mouseUpEventVerifier(e) && this.cancelMouseDrag();
186
203
  });
187
- i(this, "onWindowTouchMove", (t) => {
188
- if (t.touches.length !== 1)
204
+ i(this, "onWindowTouchMove", (e) => {
205
+ if (e.touches.length !== 1)
189
206
  return;
190
- const o = t.touches[0];
191
- if (this.element !== null && (!C(this.element, o.clientX, o.clientY) || !$(this.window, o.clientX, o.clientY))) {
207
+ const o = e.touches[0];
208
+ if (this.element !== null && (!$(this.element, o.clientX, o.clientY) || !W(this.window, o.clientX, o.clientY))) {
192
209
  this.cancelTouchDrag();
193
210
  return;
194
211
  }
195
212
  if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
196
213
  const r = o.clientX - this.previousTouchCoords.x, n = o.clientY - this.previousTouchCoords.y;
197
214
  this.dragNode(this.grabbedNodeId, r, n), this.previousTouchCoords = {
198
- x: t.touches[0].clientX,
199
- y: t.touches[0].clientY
215
+ x: e.touches[0].clientX,
216
+ y: e.touches[0].clientY
200
217
  };
201
218
  }
202
219
  });
@@ -206,26 +223,26 @@ class nt {
206
223
  i(this, "previousTouchCoords", null);
207
224
  i(this, "window", window);
208
225
  i(this, "options");
209
- this.canvas = t, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = st(o ?? {});
226
+ this.canvas = e, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = ne(o ?? {});
210
227
  }
211
- attach(t) {
212
- this.detach(), this.element = t, this.canvas.attach(this.element);
228
+ attach(e) {
229
+ this.detach(), this.element = e, this.canvas.attach(this.element);
213
230
  }
214
231
  detach() {
215
232
  this.canvas.detach(), this.element !== null && (this.element = null);
216
233
  }
217
- addNode(t) {
218
- this.canvas.addNode(t), this.updateMaxNodePriority(t.id);
234
+ addNode(e) {
235
+ this.canvas.addNode(e), this.updateMaxNodePriority(e.id);
219
236
  const o = (n) => {
220
237
  if (this.element === null || !this.options.mouseDownEventVerifier(n))
221
238
  return;
222
- const h = this.graph.getNode(t.id);
239
+ const h = this.graph.getNode(e.id);
223
240
  this.options.onBeforeNodeDrag({
224
- nodeId: t.id,
225
- element: t.element,
241
+ nodeId: e.id,
242
+ element: e.element,
226
243
  x: h.x,
227
244
  y: h.y
228
- }) && (n.stopImmediatePropagation(), this.grabbedNodeId = t.id, W(this.element, this.options.dragCursor), this.moveNodeOnTop(t.id), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
245
+ }) && (n.stopImmediatePropagation(), this.grabbedNodeId = e.id, R(this.element, this.options.dragCursor), this.moveNodeOnTop(e.id), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
229
246
  }, r = (n) => {
230
247
  if (n.touches.length !== 1)
231
248
  return;
@@ -233,206 +250,206 @@ class nt {
233
250
  x: n.touches[0].clientX,
234
251
  y: n.touches[0].clientY
235
252
  };
236
- const h = this.graph.getNode(t.id);
253
+ const h = this.graph.getNode(e.id);
237
254
  this.options.onBeforeNodeDrag({
238
- nodeId: t.id,
239
- element: t.element,
255
+ nodeId: e.id,
256
+ element: e.element,
240
257
  x: h.x,
241
258
  y: h.y
242
- }) && (this.grabbedNodeId = t.id, this.moveNodeOnTop(t.id), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
259
+ }) && (this.grabbedNodeId = e.id, this.moveNodeOnTop(e.id), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
243
260
  };
244
- this.nodes.set(t.id, {
245
- element: t.element,
261
+ this.nodes.set(e.id, {
262
+ element: e.element,
246
263
  onMouseDown: o,
247
264
  onTouchStart: r
248
- }), t.element.addEventListener("mousedown", o), t.element.addEventListener("touchstart", r);
265
+ }), e.element.addEventListener("mousedown", o), e.element.addEventListener("touchstart", r);
249
266
  }
250
- updateNode(t, o) {
251
- this.canvas.updateNode(t, o), this.updateMaxNodePriority(t);
267
+ updateNode(e, o) {
268
+ this.canvas.updateNode(e, o), this.updateMaxNodePriority(e);
252
269
  }
253
- removeNode(t) {
254
- const o = this.nodes.get(t);
255
- o !== void 0 && (o.element.removeEventListener("mousedown", o.onMouseDown), o.element.removeEventListener("touchstart", o.onTouchStart)), this.nodes.delete(t), this.canvas.removeNode(t);
270
+ removeNode(e) {
271
+ const o = this.nodes.get(e);
272
+ o !== void 0 && (o.element.removeEventListener("mousedown", o.onMouseDown), o.element.removeEventListener("touchstart", o.onTouchStart)), this.nodes.delete(e), this.canvas.removeNode(e);
256
273
  }
257
- markPort(t) {
258
- this.canvas.markPort(t);
274
+ markPort(e) {
275
+ this.canvas.markPort(e);
259
276
  }
260
- updatePort(t, o) {
261
- this.canvas.updatePort(t, o);
277
+ updatePort(e, o) {
278
+ this.canvas.updatePort(e, o);
262
279
  }
263
- unmarkPort(t) {
264
- this.canvas.unmarkPort(t);
280
+ unmarkPort(e) {
281
+ this.canvas.unmarkPort(e);
265
282
  }
266
- addEdge(t) {
267
- this.canvas.addEdge(t);
283
+ addEdge(e) {
284
+ this.canvas.addEdge(e);
268
285
  }
269
- updateEdge(t, o) {
270
- this.canvas.updateEdge(t, o);
286
+ updateEdge(e, o) {
287
+ this.canvas.updateEdge(e, o);
271
288
  }
272
- removeEdge(t) {
273
- this.canvas.removeEdge(t);
289
+ removeEdge(e) {
290
+ this.canvas.removeEdge(e);
274
291
  }
275
- patchViewportMatrix(t) {
276
- this.canvas.patchViewportMatrix(t);
292
+ patchViewportMatrix(e) {
293
+ this.canvas.patchViewportMatrix(e);
277
294
  }
278
- patchContentMatrix(t) {
279
- this.canvas.patchContentMatrix(t);
295
+ patchContentMatrix(e) {
296
+ this.canvas.patchContentMatrix(e);
280
297
  }
281
298
  clear() {
282
- this.canvas.clear(), this.nodes.forEach((t) => {
283
- t.element.removeEventListener("mousedown", t.onMouseDown), t.element.removeEventListener("touchstart", t.onTouchStart);
299
+ this.canvas.clear(), this.nodes.forEach((e) => {
300
+ e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart);
284
301
  }), this.nodes.clear(), this.maxNodePriority = 0;
285
302
  }
286
303
  destroy() {
287
304
  this.detach(), this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
288
305
  }
289
- dragNode(t, o, r) {
290
- const n = this.graph.getNode(t);
306
+ dragNode(e, o, r) {
307
+ const n = this.graph.getNode(e);
291
308
  if (n === null)
292
309
  return;
293
- const h = this.canvas.viewport.getContentMatrix(), s = h.scale * n.x + h.x, c = h.scale * n.y + h.y, d = s + o, a = c + r, l = this.canvas.viewport.getViewportMatrix(), g = l.scale * d + l.x, y = l.scale * a + l.y;
294
- this.canvas.updateNode(t, { x: g, y }), this.options.onNodeDrag({
295
- nodeId: t,
310
+ const h = this.canvas.viewport.getContentMatrix(), s = h.scale * n.x + h.x, d = h.scale * n.y + h.y, c = s + o, a = d + r, l = this.canvas.viewport.getViewportMatrix(), g = l.scale * c + l.x, f = l.scale * a + l.y;
311
+ this.canvas.updateNode(e, { x: g, y: f }), this.options.onNodeDrag({
312
+ nodeId: e,
296
313
  element: n.element,
297
314
  x: g,
298
- y
315
+ y: f
299
316
  });
300
317
  }
301
- updateMaxNodePriority(t) {
302
- const o = this.graph.getNode(t).priority;
318
+ updateMaxNodePriority(e) {
319
+ const o = this.graph.getNode(e).priority;
303
320
  this.maxNodePriority = Math.max(this.maxNodePriority, o);
304
321
  }
305
- moveNodeOnTop(t) {
322
+ moveNodeOnTop(e) {
306
323
  if (this.options.freezePriority)
307
324
  return;
308
- this.maxNodePriority += 2, this.updateNode(t, { priority: this.maxNodePriority });
325
+ this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
309
326
  const o = this.maxNodePriority - 1;
310
- this.graph.getNodeAdjacentEdgeIds(t).forEach((n) => {
327
+ this.graph.getNodeAdjacentEdgeIds(e).forEach((n) => {
311
328
  this.updateEdge(n, { priority: o });
312
329
  });
313
330
  }
314
331
  cancelMouseDrag() {
315
- const t = this.graph.getNode(this.grabbedNodeId);
316
- t !== null && this.options.onNodeDragFinished({
332
+ const e = this.graph.getNode(this.grabbedNodeId);
333
+ e !== null && this.options.onNodeDragFinished({
317
334
  nodeId: this.grabbedNodeId,
318
- element: t.element,
319
- x: t.x,
320
- y: t.y
321
- }), this.grabbedNodeId = null, this.element !== null && W(this.element, null), this.removeMouseDragListeners();
335
+ element: e.element,
336
+ x: e.x,
337
+ y: e.y
338
+ }), this.grabbedNodeId = null, this.element !== null && R(this.element, null), this.removeMouseDragListeners();
322
339
  }
323
340
  removeMouseDragListeners() {
324
341
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
325
342
  }
326
343
  cancelTouchDrag() {
327
344
  this.previousTouchCoords = null;
328
- const t = this.graph.getNode(this.grabbedNodeId);
329
- t !== null && this.options.onNodeDragFinished({
345
+ const e = this.graph.getNode(this.grabbedNodeId);
346
+ e !== null && this.options.onNodeDragFinished({
330
347
  nodeId: this.grabbedNodeId,
331
- element: t.element,
332
- x: t.x,
333
- y: t.y
348
+ element: e.element,
349
+ x: e.x,
350
+ y: e.y
334
351
  }), this.grabbedNodeId = null, this.removeTouchDragListeners();
335
352
  }
336
353
  removeTouchDragListeners() {
337
354
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
338
355
  }
339
356
  }
340
- const ht = (e) => {
341
- const t = e.minX !== null ? e.minX : -1 / 0, o = e.maxX !== null ? e.maxX : 1 / 0, r = e.minY !== null ? e.minY : -1 / 0, n = e.maxY !== null ? e.maxY : 1 / 0;
357
+ const de = (t) => {
358
+ const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, r = t.minY !== null ? t.minY : -1 / 0, n = t.maxY !== null ? t.maxY : 1 / 0;
342
359
  return (h) => {
343
- let s = h.nextTransform.x, c = h.nextTransform.y;
344
- s < t && s < h.prevTransform.x && (s = Math.min(h.prevTransform.x, t));
345
- const d = h.canvasWidth * h.prevTransform.scale, a = o - d;
346
- s > a && s > h.prevTransform.x && (s = Math.max(h.prevTransform.x, a)), c < r && c < h.prevTransform.y && (c = Math.min(h.prevTransform.y, r));
360
+ let s = h.nextTransform.x, d = h.nextTransform.y;
361
+ s < e && s < h.prevTransform.x && (s = Math.min(h.prevTransform.x, e));
362
+ const c = h.canvasWidth * h.prevTransform.scale, a = o - c;
363
+ s > a && s > h.prevTransform.x && (s = Math.max(h.prevTransform.x, a)), d < r && d < h.prevTransform.y && (d = Math.min(h.prevTransform.y, r));
347
364
  const l = h.canvasHeight * h.prevTransform.scale, g = n - l;
348
- return c > g && c > h.prevTransform.y && (c = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: s, y: c };
365
+ return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: s, y: d };
349
366
  };
350
- }, ct = (e) => {
351
- const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0, n = o !== null ? 1 / o : 1 / 0;
367
+ }, ce = (t) => {
368
+ const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, n = o !== null ? 1 / o : 1 / 0;
352
369
  return (h) => {
353
- const s = h.prevTransform, c = h.nextTransform;
354
- let d = c.scale, a = c.x, l = c.y;
355
- if (c.scale > n && c.scale > s.scale) {
356
- d = Math.max(s.scale, n), a = s.x, l = s.y;
357
- const g = (d - s.scale) / (c.scale - s.scale);
358
- a = s.x + (c.x - s.x) * g, l = s.y + (c.y - s.y) * g;
370
+ const s = h.prevTransform, d = h.nextTransform;
371
+ let c = d.scale, a = d.x, l = d.y;
372
+ if (d.scale > n && d.scale > s.scale) {
373
+ c = Math.max(s.scale, n), a = s.x, l = s.y;
374
+ const g = (c - s.scale) / (d.scale - s.scale);
375
+ a = s.x + (d.x - s.x) * g, l = s.y + (d.y - s.y) * g;
359
376
  }
360
- if (c.scale < r && c.scale < s.scale) {
361
- d = Math.min(s.scale, r), a = s.x, l = s.y;
362
- const g = (d - s.scale) / (c.scale - s.scale);
363
- a = s.x + (c.x - s.x) * g, l = s.y + (c.y - s.y) * g;
377
+ if (d.scale < r && d.scale < s.scale) {
378
+ c = Math.min(s.scale, r), a = s.x, l = s.y;
379
+ const g = (c - s.scale) / (d.scale - s.scale);
380
+ a = s.x + (d.x - s.x) * g, l = s.y + (d.y - s.y) * g;
364
381
  }
365
382
  return {
366
- scale: d,
383
+ scale: c,
367
384
  x: a,
368
385
  y: l
369
386
  };
370
387
  };
371
- }, dt = (e) => (t) => e.reduce(
388
+ }, ae = (t) => (e) => t.reduce(
372
389
  (o, r) => r({
373
- prevTransform: t.prevTransform,
390
+ prevTransform: e.prevTransform,
374
391
  nextTransform: o,
375
- canvasWidth: t.canvasWidth,
376
- canvasHeight: t.canvasHeight
392
+ canvasWidth: e.canvasWidth,
393
+ canvasHeight: e.canvasHeight
377
394
  }),
378
- t.nextTransform
379
- ), _ = (e) => {
380
- if (typeof e == "function")
381
- return e;
382
- switch (e.type) {
395
+ e.nextTransform
396
+ ), J = (t) => {
397
+ if (typeof t == "function")
398
+ return t;
399
+ switch (t.type) {
383
400
  case "scale-limit":
384
- return ct({
385
- minContentScale: e.minContentScale ?? 0,
386
- maxContentScale: e.maxContentScale ?? 1 / 0
401
+ return ce({
402
+ minContentScale: t.minContentScale ?? 0,
403
+ maxContentScale: t.maxContentScale ?? 1 / 0
387
404
  });
388
405
  case "shift-limit":
389
- return ht({
390
- minX: e.minX ?? -1 / 0,
391
- maxX: e.maxX ?? 1 / 0,
392
- minY: e.minY ?? -1 / 0,
393
- maxY: e.maxY ?? 1 / 0
406
+ return de({
407
+ minX: t.minX ?? -1 / 0,
408
+ maxX: t.maxX ?? 1 / 0,
409
+ minY: t.minY ?? -1 / 0,
410
+ maxY: t.maxY ?? 1 / 0
394
411
  });
395
412
  }
396
- }, at = (e) => {
397
- var v, A, S, T, z, L, D, P, U, j, G, K;
398
- const t = (v = e == null ? void 0 : e.scale) == null ? void 0 : v.mouseWheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
413
+ }, le = (t) => {
414
+ var y, S, p, T, k, V, D, C, H, G, K, _;
415
+ const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
399
416
  let n;
400
- r !== void 0 ? Array.isArray(r) ? n = dt(
417
+ r !== void 0 ? Array.isArray(r) ? n = ae(
401
418
  r.map(
402
- (V) => _(V)
419
+ (P) => J(P)
403
420
  )
404
- ) : n = _(r) : n = (V) => V.nextTransform;
405
- const h = ((A = e == null ? void 0 : e.shift) == null ? void 0 : A.cursor) !== void 0 ? e.shift.cursor : "grab", s = ((S = e == null ? void 0 : e.events) == null ? void 0 : S.onBeforeTransformChange) ?? (() => {
406
- }), c = ((T = e == null ? void 0 : e.events) == null ? void 0 : T.onTransformChange) ?? (() => {
407
- }), d = (z = e == null ? void 0 : e.shift) == null ? void 0 : z.mouseDownEventVerifier, a = d !== void 0 ? d : (V) => V.button === 0, l = (L = e == null ? void 0 : e.shift) == null ? void 0 : L.mouseUpEventVerifier, g = l !== void 0 ? l : (V) => V.button === 0, y = (D = e == null ? void 0 : e.scale) == null ? void 0 : D.mouseWheelEventVerifier, x = y !== void 0 ? y : () => !0;
421
+ ) : n = J(r) : n = (P) => P.nextTransform;
422
+ const h = ((S = t == null ? void 0 : t.shift) == null ? void 0 : S.cursor) !== void 0 ? t.shift.cursor : "grab", s = ((p = t == null ? void 0 : t.events) == null ? void 0 : p.onBeforeTransformChange) ?? (() => {
423
+ }), d = ((T = t == null ? void 0 : t.events) == null ? void 0 : T.onTransformChange) ?? (() => {
424
+ }), c = (k = t == null ? void 0 : t.shift) == null ? void 0 : k.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (V = t == null ? void 0 : t.shift) == null ? void 0 : V.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, f = (D = t == null ? void 0 : t.scale) == null ? void 0 : D.mouseWheelEventVerifier, x = f !== void 0 ? f : () => !0;
408
425
  return {
409
426
  wheelSensitivity: o,
410
- onTransformStarted: ((P = e == null ? void 0 : e.events) == null ? void 0 : P.onTransformStarted) ?? (() => {
427
+ onTransformStarted: ((C = t == null ? void 0 : t.events) == null ? void 0 : C.onTransformStarted) ?? (() => {
411
428
  }),
412
- onTransformFinished: ((U = e == null ? void 0 : e.events) == null ? void 0 : U.onTransformFinished) ?? (() => {
429
+ onTransformFinished: ((H = t == null ? void 0 : t.events) == null ? void 0 : H.onTransformFinished) ?? (() => {
413
430
  }),
414
431
  onBeforeTransformChange: s,
415
- onTransformChange: c,
432
+ onTransformChange: d,
416
433
  transformPreprocessor: n,
417
434
  shiftCursor: h,
418
435
  mouseDownEventVerifier: a,
419
436
  mouseUpEventVerifier: g,
420
437
  mouseWheelEventVerifier: x,
421
- scaleWheelFinishTimeout: ((j = e == null ? void 0 : e.scale) == null ? void 0 : j.wheelFinishTimeout) ?? 500,
422
- onResizeTransformStarted: ((G = e == null ? void 0 : e.events) == null ? void 0 : G.onResizeTransformStarted) ?? (() => {
438
+ scaleWheelFinishTimeout: ((G = t == null ? void 0 : t.scale) == null ? void 0 : G.wheelFinishTimeout) ?? 500,
439
+ onResizeTransformStarted: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onResizeTransformStarted) ?? (() => {
423
440
  }),
424
- onResizeTransformFinished: ((K = e == null ? void 0 : e.events) == null ? void 0 : K.onResizeTransformFinished) ?? (() => {
441
+ onResizeTransformFinished: ((_ = t == null ? void 0 : t.events) == null ? void 0 : _.onResizeTransformFinished) ?? (() => {
425
442
  })
426
443
  };
427
- }, m = (e) => {
428
- const t = [], o = e.touches.length;
429
- for (let c = 0; c < o; c++)
430
- t.push([e.touches[c].clientX, e.touches[c].clientY]);
431
- const r = t.reduce(
432
- (c, d) => [c[0] + d[0], c[1] + d[1]],
444
+ }, b = (t) => {
445
+ const e = [], o = t.touches.length;
446
+ for (let d = 0; d < o; d++)
447
+ e.push([t.touches[d].clientX, t.touches[d].clientY]);
448
+ const r = e.reduce(
449
+ (d, c) => [d[0] + c[0], d[1] + c[1]],
433
450
  [0, 0]
434
- ), n = [r[0] / o, r[1] / o], s = t.map((c) => [c[0] - n[0], c[1] - n[1]]).reduce(
435
- (c, d) => c + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
451
+ ), n = [r[0] / o, r[1] / o], s = e.map((d) => [d[0] - n[0], d[1] - n[1]]).reduce(
452
+ (d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
436
453
  0
437
454
  );
438
455
  return {
@@ -440,62 +457,62 @@ const ht = (e) => {
440
457
  y: n[1],
441
458
  scale: s / o,
442
459
  touchesCnt: o,
443
- touches: t
460
+ touches: e
444
461
  };
445
- }, lt = (e, t, o) => ({
446
- scale: e.scale,
447
- x: e.x + e.scale * t,
448
- y: e.y + e.scale * o
449
- }), gt = (e, t, o, r) => ({
450
- scale: e.scale * t,
451
- x: e.scale * (1 - t) * o + e.x,
452
- y: e.scale * (1 - t) * r + e.y
462
+ }, ge = (t, e, o) => ({
463
+ scale: t.scale,
464
+ x: t.x + t.scale * e,
465
+ y: t.y + t.scale * o
466
+ }), ue = (t, e, o, r) => ({
467
+ scale: t.scale * e,
468
+ x: t.scale * (1 - e) * o + t.x,
469
+ y: t.scale * (1 - e) * r + t.y
453
470
  });
454
- class O {
455
- constructor(t, o) {
471
+ class q {
472
+ constructor(e, o) {
456
473
  i(this, "graph");
457
474
  i(this, "viewport");
458
475
  i(this, "element", null);
459
476
  i(this, "prevTouches", null);
460
477
  i(this, "window", window);
461
478
  i(this, "wheelFinishTimer", null);
462
- i(this, "onMouseDown", (t) => {
463
- this.element === null || !this.options.mouseDownEventVerifier(t) || (W(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
479
+ i(this, "onMouseDown", (e) => {
480
+ this.element === null || !this.options.mouseDownEventVerifier(e) || (R(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
464
481
  });
465
- i(this, "onWindowMouseMove", (t) => {
466
- if (this.element === null || !C(this.element, t.clientX, t.clientY) || !$(this.window, t.clientX, t.clientY)) {
482
+ i(this, "onWindowMouseMove", (e) => {
483
+ if (this.element === null || !$(this.element, e.clientX, e.clientY) || !W(this.window, e.clientX, e.clientY)) {
467
484
  this.stopMouseDrag();
468
485
  return;
469
486
  }
470
- const o = -t.movementX, r = -t.movementY;
487
+ const o = -e.movementX, r = -e.movementY;
471
488
  this.moveViewport(this.element, o, r);
472
489
  });
473
- i(this, "onWindowMouseUp", (t) => {
474
- this.element === null || !this.options.mouseUpEventVerifier(t) || this.stopMouseDrag();
490
+ i(this, "onWindowMouseUp", (e) => {
491
+ this.element === null || !this.options.mouseUpEventVerifier(e) || this.stopMouseDrag();
475
492
  });
476
- i(this, "onWheelScroll", (t) => {
477
- if (!this.options.mouseWheelEventVerifier(t))
493
+ i(this, "onWheelScroll", (e) => {
494
+ if (!this.options.mouseWheelEventVerifier(e))
478
495
  return;
479
- t.preventDefault();
480
- const { left: o, top: r } = this.element.getBoundingClientRect(), n = t.clientX - o, h = t.clientY - r, c = 1 / (t.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
481
- this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(this.element, c, n, h), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
496
+ e.preventDefault();
497
+ const { left: o, top: r } = this.element.getBoundingClientRect(), n = e.clientX - o, h = e.clientY - r, d = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
498
+ this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(this.element, d, n, h), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
482
499
  this.options.onTransformFinished(), this.wheelFinishTimer = null;
483
500
  }, this.options.scaleWheelFinishTimeout);
484
501
  });
485
- i(this, "onTouchStart", (t) => {
502
+ i(this, "onTouchStart", (e) => {
486
503
  if (this.prevTouches !== null) {
487
- this.prevTouches = m(t);
504
+ this.prevTouches = b(e);
488
505
  return;
489
506
  }
490
- this.prevTouches = m(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
507
+ this.prevTouches = b(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
491
508
  });
492
- i(this, "onWindowTouchMove", (t) => {
509
+ i(this, "onWindowTouchMove", (e) => {
493
510
  const o = this.element;
494
511
  if (o === null)
495
512
  return;
496
- const r = m(t);
513
+ const r = b(e);
497
514
  if (!r.touches.every(
498
- (h) => C(o, h[0], h[1]) && $(this.window, h[0], h[1])
515
+ (h) => $(o, h[0], h[1]) && W(this.window, h[0], h[1])
499
516
  )) {
500
517
  this.stopTouchDrag();
501
518
  return;
@@ -505,64 +522,64 @@ class O {
505
522
  -(r.x - this.prevTouches.x),
506
523
  -(r.y - this.prevTouches.y)
507
524
  ), r.touchesCnt === 2) {
508
- const { left: h, top: s } = o.getBoundingClientRect(), c = this.prevTouches.x - h, d = this.prevTouches.y - s, l = 1 / (r.scale / this.prevTouches.scale);
509
- this.scaleViewport(o, l, c, d);
525
+ const { left: h, top: s } = o.getBoundingClientRect(), d = this.prevTouches.x - h, c = this.prevTouches.y - s, l = 1 / (r.scale / this.prevTouches.scale);
526
+ this.scaleViewport(o, l, d, c);
510
527
  }
511
528
  this.prevTouches = r;
512
529
  });
513
- i(this, "onWindowTouchFinish", (t) => {
514
- t.touches.length > 0 ? this.prevTouches = m(t) : this.stopTouchDrag();
530
+ i(this, "onWindowTouchFinish", (e) => {
531
+ e.touches.length > 0 ? this.prevTouches = b(e) : this.stopTouchDrag();
515
532
  });
516
533
  i(this, "observer", new ResizeObserver(() => {
517
- const t = this.canvas.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
518
- prevTransform: t,
519
- nextTransform: t,
534
+ const e = this.canvas.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
535
+ prevTransform: e,
536
+ nextTransform: e,
520
537
  canvasWidth: o,
521
538
  canvasHeight: r
522
539
  });
523
540
  this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(n), this.options.onResizeTransformFinished();
524
541
  }));
525
542
  i(this, "options");
526
- this.canvas = t, this.options = at(o), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
543
+ this.canvas = e, this.options = le(o), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
527
544
  }
528
- attach(t) {
529
- this.detach(), this.element = t, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element);
545
+ attach(e) {
546
+ this.detach(), this.element = e, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element);
530
547
  }
531
548
  detach() {
532
549
  this.canvas.detach(), this.element !== null && (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 = null);
533
550
  }
534
- addNode(t) {
535
- this.canvas.addNode(t);
551
+ addNode(e) {
552
+ this.canvas.addNode(e);
536
553
  }
537
- updateNode(t, o) {
538
- this.canvas.updateNode(t, o);
554
+ updateNode(e, o) {
555
+ this.canvas.updateNode(e, o);
539
556
  }
540
- removeNode(t) {
541
- this.canvas.removeNode(t);
557
+ removeNode(e) {
558
+ this.canvas.removeNode(e);
542
559
  }
543
- markPort(t) {
544
- this.canvas.markPort(t);
560
+ markPort(e) {
561
+ this.canvas.markPort(e);
545
562
  }
546
- updatePort(t, o) {
547
- this.canvas.updatePort(t, o);
563
+ updatePort(e, o) {
564
+ this.canvas.updatePort(e, o);
548
565
  }
549
- unmarkPort(t) {
550
- this.canvas.unmarkPort(t);
566
+ unmarkPort(e) {
567
+ this.canvas.unmarkPort(e);
551
568
  }
552
- addEdge(t) {
553
- this.canvas.addEdge(t);
569
+ addEdge(e) {
570
+ this.canvas.addEdge(e);
554
571
  }
555
- updateEdge(t, o) {
556
- this.canvas.updateEdge(t, o);
572
+ updateEdge(e, o) {
573
+ this.canvas.updateEdge(e, o);
557
574
  }
558
- removeEdge(t) {
559
- this.canvas.removeEdge(t);
575
+ removeEdge(e) {
576
+ this.canvas.removeEdge(e);
560
577
  }
561
- patchViewportMatrix(t) {
562
- this.canvas.patchViewportMatrix(t);
578
+ patchViewportMatrix(e) {
579
+ this.canvas.patchViewportMatrix(e);
563
580
  }
564
- patchContentMatrix(t) {
565
- this.canvas.patchContentMatrix(t);
581
+ patchContentMatrix(e) {
582
+ this.canvas.patchContentMatrix(e);
566
583
  }
567
584
  clear() {
568
585
  this.canvas.clear();
@@ -570,26 +587,26 @@ class O {
570
587
  destroy() {
571
588
  this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
572
589
  }
573
- moveViewport(t, o, r) {
574
- const n = this.viewport.getViewportMatrix(), h = lt(n, o, r), { width: s, height: c } = t.getBoundingClientRect(), d = this.options.transformPreprocessor({
590
+ moveViewport(e, o, r) {
591
+ const n = this.viewport.getViewportMatrix(), h = ge(n, o, r), { width: s, height: d } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
575
592
  prevTransform: n,
576
593
  nextTransform: h,
577
594
  canvasWidth: s,
578
- canvasHeight: c
595
+ canvasHeight: d
579
596
  });
580
- this.performTransform(d);
597
+ this.performTransform(c);
581
598
  }
582
- scaleViewport(t, o, r, n) {
583
- const h = this.canvas.viewport.getViewportMatrix(), s = gt(h, o, r, n), { width: c, height: d } = t.getBoundingClientRect(), a = this.options.transformPreprocessor({
599
+ scaleViewport(e, o, r, n) {
600
+ const h = this.canvas.viewport.getViewportMatrix(), s = ue(h, o, r, n), { width: d, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
584
601
  prevTransform: h,
585
602
  nextTransform: s,
586
- canvasWidth: c,
587
- canvasHeight: d
603
+ canvasWidth: d,
604
+ canvasHeight: c
588
605
  });
589
606
  this.performTransform(a);
590
607
  }
591
608
  stopMouseDrag() {
592
- this.element !== null && W(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
609
+ this.element !== null && R(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
593
610
  }
594
611
  removeMouseDragListeners() {
595
612
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -600,101 +617,101 @@ class O {
600
617
  removeTouchDragListeners() {
601
618
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
602
619
  }
603
- performTransform(t) {
604
- this.options.onBeforeTransformChange(), this.canvas.patchViewportMatrix(t), this.options.onTransformChange();
620
+ performTransform(e) {
621
+ this.options.onBeforeTransformChange(), this.canvas.patchViewportMatrix(e), this.options.onTransformChange();
605
622
  }
606
623
  }
607
- class ut {
624
+ class we {
608
625
  constructor() {
609
626
  i(this, "keyMap", /* @__PURE__ */ new Map());
610
627
  i(this, "valueMap", /* @__PURE__ */ new Map());
611
628
  }
612
- set(t, o) {
613
- this.keyMap.set(t, o), this.valueMap.set(o, t);
629
+ set(e, o) {
630
+ this.keyMap.set(e, o), this.valueMap.set(o, e);
614
631
  }
615
- hasKey(t) {
616
- return this.keyMap.has(t);
632
+ hasKey(e) {
633
+ return this.keyMap.has(e);
617
634
  }
618
- hasValue(t) {
619
- return this.valueMap.has(t);
635
+ hasValue(e) {
636
+ return this.valueMap.has(e);
620
637
  }
621
- getByKey(t) {
622
- return this.keyMap.get(t);
638
+ getByKey(e) {
639
+ return this.keyMap.get(e);
623
640
  }
624
- getByValue(t) {
625
- return this.valueMap.get(t);
641
+ getByValue(e) {
642
+ return this.valueMap.get(e);
626
643
  }
627
- deleteByKey(t) {
628
- const o = this.keyMap.get(t);
629
- o !== void 0 && this.valueMap.delete(o), this.keyMap.delete(t);
644
+ deleteByKey(e) {
645
+ const o = this.keyMap.get(e);
646
+ o !== void 0 && this.valueMap.delete(o), this.keyMap.delete(e);
630
647
  }
631
- deleteByValue(t) {
632
- const o = this.valueMap.get(t);
633
- o !== void 0 && this.keyMap.delete(o), this.valueMap.delete(t);
648
+ deleteByValue(e) {
649
+ const o = this.valueMap.get(e);
650
+ o !== void 0 && this.keyMap.delete(o), this.valueMap.delete(e);
634
651
  }
635
- forEach(t) {
652
+ forEach(e) {
636
653
  this.keyMap.forEach((o, r) => {
637
- t(o, r);
654
+ e(o, r);
638
655
  });
639
656
  }
640
657
  clear() {
641
658
  this.keyMap.clear(), this.valueMap.clear();
642
659
  }
643
660
  }
644
- class wt {
645
- constructor(t) {
661
+ class fe {
662
+ constructor(e) {
646
663
  i(this, "viewport");
647
664
  i(this, "graph");
648
- i(this, "nodes", new ut());
665
+ i(this, "nodes", new we());
649
666
  i(this, "nodesResizeObserver");
650
667
  i(this, "window", window);
651
- this.canvas = t, this.nodesResizeObserver = new this.window.ResizeObserver((o) => {
668
+ this.canvas = e, this.nodesResizeObserver = new this.window.ResizeObserver((o) => {
652
669
  o.forEach((r) => {
653
670
  const n = r.target;
654
671
  this.handleNodeResize(n);
655
672
  });
656
673
  }), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
657
674
  }
658
- attach(t) {
659
- this.canvas.attach(t);
675
+ attach(e) {
676
+ this.canvas.attach(e);
660
677
  }
661
678
  detach() {
662
679
  this.canvas.detach();
663
680
  }
664
- addNode(t) {
665
- this.canvas.addNode(t), this.nodes.set(t.id, t.element), this.nodesResizeObserver.observe(t.element);
681
+ addNode(e) {
682
+ this.canvas.addNode(e), this.nodes.set(e.id, e.element), this.nodesResizeObserver.observe(e.element);
666
683
  }
667
- updateNode(t, o) {
668
- this.canvas.updateNode(t, o);
684
+ updateNode(e, o) {
685
+ this.canvas.updateNode(e, o);
669
686
  }
670
- removeNode(t) {
671
- this.canvas.removeNode(t);
672
- const o = this.nodes.getByKey(t);
673
- this.nodes.deleteByKey(t), this.nodesResizeObserver.unobserve(o);
687
+ removeNode(e) {
688
+ this.canvas.removeNode(e);
689
+ const o = this.nodes.getByKey(e);
690
+ this.nodes.deleteByKey(e), this.nodesResizeObserver.unobserve(o);
674
691
  }
675
- markPort(t) {
676
- this.canvas.markPort(t);
692
+ markPort(e) {
693
+ this.canvas.markPort(e);
677
694
  }
678
- updatePort(t, o) {
679
- this.canvas.updatePort(t, o);
695
+ updatePort(e, o) {
696
+ this.canvas.updatePort(e, o);
680
697
  }
681
- unmarkPort(t) {
682
- this.canvas.unmarkPort(t);
698
+ unmarkPort(e) {
699
+ this.canvas.unmarkPort(e);
683
700
  }
684
- addEdge(t) {
685
- this.canvas.addEdge(t);
701
+ addEdge(e) {
702
+ this.canvas.addEdge(e);
686
703
  }
687
- updateEdge(t, o) {
688
- this.canvas.updateEdge(t, o);
704
+ updateEdge(e, o) {
705
+ this.canvas.updateEdge(e, o);
689
706
  }
690
- removeEdge(t) {
691
- this.canvas.removeEdge(t);
707
+ removeEdge(e) {
708
+ this.canvas.removeEdge(e);
692
709
  }
693
- patchViewportMatrix(t) {
694
- this.canvas.patchViewportMatrix(t);
710
+ patchViewportMatrix(e) {
711
+ this.canvas.patchViewportMatrix(e);
695
712
  }
696
- patchContentMatrix(t) {
697
- this.canvas.patchContentMatrix(t);
713
+ patchContentMatrix(e) {
714
+ this.canvas.patchContentMatrix(e);
698
715
  }
699
716
  clear() {
700
717
  this.canvas.clear(), this.nodesResizeObserver.disconnect(), this.nodes.clear();
@@ -702,15 +719,15 @@ class wt {
702
719
  destroy() {
703
720
  this.clear(), this.canvas.destroy();
704
721
  }
705
- handleNodeResize(t) {
706
- const o = this.nodes.getByValue(t);
722
+ handleNodeResize(e) {
723
+ const o = this.nodes.getByValue(e);
707
724
  this.canvas.updateNode(o, {}), this.graph.getNodeAdjacentEdgeIds(o).forEach((n) => {
708
725
  this.canvas.updateEdge(n, {});
709
726
  });
710
727
  }
711
728
  }
712
- class yt {
713
- constructor(t, o, r, n) {
729
+ class ye {
730
+ constructor(e, o, r, n) {
714
731
  i(this, "graph");
715
732
  i(this, "viewport");
716
733
  i(this, "canvas");
@@ -728,22 +745,22 @@ class yt {
728
745
  yFrom: 1 / 0,
729
746
  yTo: 1 / 0
730
747
  });
731
- i(this, "updateLoadedArea", (t) => {
748
+ i(this, "updateLoadedArea", (e) => {
732
749
  this.loadedArea = {
733
- xFrom: t.x,
734
- xTo: t.x + t.width,
735
- yFrom: t.y,
736
- yTo: t.y + t.height
750
+ xFrom: e.x,
751
+ xTo: e.x + e.width,
752
+ yFrom: e.y,
753
+ yTo: e.y + e.height
737
754
  };
738
755
  });
739
- var d, a;
756
+ var c, a;
740
757
  this.trigger = o, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new this.window.ResizeObserver((l) => {
741
758
  const g = l[0];
742
759
  this.viewportWidth = g.contentRect.width, this.viewportHeight = g.contentRect.height, this.scheduleLoadAreaAroundViewport();
743
760
  });
744
- const h = ((d = r == null ? void 0 : r.events) == null ? void 0 : d.onTransformFinished) ?? (() => {
761
+ const h = ((c = r == null ? void 0 : r.events) == null ? void 0 : c.onTransformFinished) ?? (() => {
745
762
  }), s = ((a = r == null ? void 0 : r.events) == null ? void 0 : a.onTransformChange) ?? (() => {
746
- }), c = {
763
+ }), d = {
747
764
  ...r,
748
765
  events: {
749
766
  ...r == null ? void 0 : r.events,
@@ -756,49 +773,49 @@ class yt {
756
773
  }
757
774
  }
758
775
  };
759
- this.canvas = new O(
760
- t,
761
- c
776
+ this.canvas = new q(
777
+ e,
778
+ d
762
779
  ), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.trigger.subscribe(this.updateLoadedArea);
763
780
  }
764
- attach(t) {
765
- this.detach(), this.element = t, this.canvasResizeObserver.observe(this.element), this.canvas.attach(t);
781
+ attach(e) {
782
+ this.detach(), this.element = e, this.canvasResizeObserver.observe(this.element), this.canvas.attach(e);
766
783
  }
767
784
  detach() {
768
785
  this.element !== null && (this.canvasResizeObserver.unobserve(this.element), this.element = null, this.viewportWidth = 0, this.viewportHeight = 0), this.canvas.detach();
769
786
  }
770
- addNode(t) {
771
- this.canvas.addNode(t);
787
+ addNode(e) {
788
+ this.canvas.addNode(e);
772
789
  }
773
- updateNode(t, o) {
774
- this.canvas.updateNode(t, o);
790
+ updateNode(e, o) {
791
+ this.canvas.updateNode(e, o);
775
792
  }
776
- removeNode(t) {
777
- this.canvas.removeNode(t);
793
+ removeNode(e) {
794
+ this.canvas.removeNode(e);
778
795
  }
779
- markPort(t) {
780
- this.canvas.markPort(t);
796
+ markPort(e) {
797
+ this.canvas.markPort(e);
781
798
  }
782
- updatePort(t, o) {
783
- this.canvas.updatePort(t, o);
799
+ updatePort(e, o) {
800
+ this.canvas.updatePort(e, o);
784
801
  }
785
- unmarkPort(t) {
786
- this.canvas.unmarkPort(t);
802
+ unmarkPort(e) {
803
+ this.canvas.unmarkPort(e);
787
804
  }
788
- addEdge(t) {
789
- this.canvas.addEdge(t);
805
+ addEdge(e) {
806
+ this.canvas.addEdge(e);
790
807
  }
791
- updateEdge(t, o) {
792
- this.canvas.updateEdge(t, o);
808
+ updateEdge(e, o) {
809
+ this.canvas.updateEdge(e, o);
793
810
  }
794
- removeEdge(t) {
795
- this.canvas.removeEdge(t);
811
+ removeEdge(e) {
812
+ this.canvas.removeEdge(e);
796
813
  }
797
- patchViewportMatrix(t) {
798
- this.canvas.patchViewportMatrix(t), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.loadAreaAroundViewport();
814
+ patchViewportMatrix(e) {
815
+ this.canvas.patchViewportMatrix(e), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.loadAreaAroundViewport();
799
816
  }
800
- patchContentMatrix(t) {
801
- this.canvas.patchContentMatrix(t), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.loadAreaAroundViewport();
817
+ patchContentMatrix(e) {
818
+ this.canvas.patchContentMatrix(e), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.loadAreaAroundViewport();
802
819
  }
803
820
  clear() {
804
821
  this.canvas.clear();
@@ -812,153 +829,153 @@ class yt {
812
829
  });
813
830
  }
814
831
  scheduleEnsureViewportAreaLoaded() {
815
- const t = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal, n = this.viewportMatrix.y - this.nodeVertical, h = this.viewportMatrix.x + t + this.nodeHorizontal, s = this.viewportMatrix.y + o + this.nodeVertical;
832
+ const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal, n = this.viewportMatrix.y - this.nodeVertical, h = this.viewportMatrix.x + e + this.nodeHorizontal, s = this.viewportMatrix.y + o + this.nodeVertical;
816
833
  this.loadedArea.xFrom < r && this.loadedArea.xTo > h && this.loadedArea.yFrom < n && this.loadedArea.yTo > s || this.scheduleLoadAreaAroundViewport();
817
834
  }
818
835
  loadAreaAroundViewport() {
819
- const t = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - t - this.nodeHorizontal, n = this.viewportMatrix.y - o - this.nodeVertical, h = 3 * t + 2 * this.nodeHorizontal, s = 3 * o + 2 * this.nodeVertical;
836
+ const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - e - this.nodeHorizontal, n = this.viewportMatrix.y - o - this.nodeVertical, h = 3 * e + 2 * this.nodeHorizontal, s = 3 * o + 2 * this.nodeVertical;
820
837
  this.trigger.emit({ x: r, y: n, width: h, height: s });
821
838
  }
822
839
  }
823
- const vt = () => {
824
- const e = document.createElement("div");
825
- return e.style.width = "100%", e.style.height = "100%", e.style.position = "relative", e.style.overflow = "hidden", e;
826
- }, ft = () => {
827
- const e = document.createElement("div");
828
- return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.width = "0", e.style.height = "0", e;
829
- }, xt = () => {
830
- const e = document.createElement("div");
831
- return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.visibility = "hidden", e;
840
+ const ve = () => {
841
+ const t = document.createElement("div");
842
+ return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
843
+ }, xe = () => {
844
+ const t = document.createElement("div");
845
+ return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
846
+ }, Ee = () => {
847
+ const t = document.createElement("div");
848
+ return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
832
849
  };
833
- class Et {
834
- constructor(t, o) {
850
+ class Ae {
851
+ constructor(e, o) {
835
852
  i(this, "canvasWrapper", null);
836
- i(this, "host", vt());
837
- i(this, "container", ft());
853
+ i(this, "host", ve());
854
+ i(this, "container", xe());
838
855
  i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
839
856
  i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
840
857
  i(this, "applyTransform", () => {
841
- const t = this.viewportStore.getContentMatrix();
842
- this.container.style.transform = `matrix(${t.scale}, 0, 0, ${t.scale}, ${t.x}, ${t.y})`;
858
+ const e = this.viewportStore.getContentMatrix();
859
+ this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
843
860
  });
844
- this.graphStore = t, this.viewportStore = o, this.host.appendChild(this.container), this.viewportStore.onAfterUpdate.subscribe(this.applyTransform);
861
+ this.graphStore = e, this.viewportStore = o, this.host.appendChild(this.container), this.viewportStore.onAfterUpdate.subscribe(this.applyTransform);
845
862
  }
846
- attach(t) {
847
- this.detach(), this.canvasWrapper = t, this.canvasWrapper.appendChild(this.host), this.graphStore.getAllEdgeIds().forEach((o) => {
863
+ attach(e) {
864
+ this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host), this.graphStore.getAllEdgeIds().forEach((o) => {
848
865
  this.renderEdge(o);
849
866
  });
850
867
  }
851
868
  detach() {
852
869
  this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
853
870
  }
854
- attachNode(t) {
855
- const o = this.graphStore.getNode(t), r = xt();
856
- r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(t, r), this.updateNodeCoordinates(t), this.updateNodePriority(t), r.style.visibility = "visible";
871
+ attachNode(e) {
872
+ const o = this.graphStore.getNode(e), r = Ee();
873
+ r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodeCoordinates(e), this.updateNodePriority(e), r.style.visibility = "visible";
857
874
  }
858
- detachNode(t) {
859
- const o = this.nodeIdToWrapperElementMap.get(t);
860
- o.removeChild(o.firstChild), this.container.removeChild(o), this.nodeIdToWrapperElementMap.delete(t);
875
+ detachNode(e) {
876
+ const o = this.nodeIdToWrapperElementMap.get(e);
877
+ o.removeChild(o.firstChild), this.container.removeChild(o), this.nodeIdToWrapperElementMap.delete(e);
861
878
  }
862
- attachEdge(t) {
863
- const o = this.graphStore.getEdge(t).shape.svg;
864
- this.edgeIdToElementMap.set(t, o), this.container.appendChild(o), this.renderEdge(t), this.updateEdgePriority(t);
879
+ attachEdge(e) {
880
+ const o = this.graphStore.getEdge(e).shape.svg;
881
+ this.edgeIdToElementMap.set(e, o), this.container.appendChild(o), this.renderEdge(e), this.updateEdgePriority(e);
865
882
  }
866
- detachEdge(t) {
867
- const o = this.edgeIdToElementMap.get(t);
868
- this.container.removeChild(o), this.edgeIdToElementMap.delete(t);
883
+ detachEdge(e) {
884
+ const o = this.edgeIdToElementMap.get(e);
885
+ this.container.removeChild(o), this.edgeIdToElementMap.delete(e);
869
886
  }
870
887
  clear() {
871
- this.edgeIdToElementMap.forEach((t, o) => {
888
+ this.edgeIdToElementMap.forEach((e, o) => {
872
889
  this.detachEdge(o);
873
- }), this.nodeIdToWrapperElementMap.forEach((t, o) => {
890
+ }), this.nodeIdToWrapperElementMap.forEach((e, o) => {
874
891
  this.detachNode(o);
875
892
  });
876
893
  }
877
894
  destroy() {
878
895
  this.viewportStore.onAfterUpdate.unsubscribe(this.applyTransform), this.clear(), this.detach(), this.host.removeChild(this.container);
879
896
  }
880
- updateNodeCoordinates(t) {
881
- const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: n, height: h } = r.element.getBoundingClientRect(), s = this.viewportStore.getViewportMatrix().scale, c = r.centerFn(n, h), d = r.x - s * c.x, a = r.y - s * c.y;
882
- o.style.transform = `translate(${d}px, ${a}px)`;
897
+ updateNodeCoordinates(e) {
898
+ const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width: n, height: h } = r.element.getBoundingClientRect(), s = this.viewportStore.getViewportMatrix().scale, d = r.centerFn(n, h), c = r.x - s * d.x, a = r.y - s * d.y;
899
+ o.style.transform = `translate(${c}px, ${a}px)`;
883
900
  }
884
- updateNodePriority(t) {
885
- const o = this.graphStore.getNode(t), r = this.nodeIdToWrapperElementMap.get(t);
901
+ updateNodePriority(e) {
902
+ const o = this.graphStore.getNode(e), r = this.nodeIdToWrapperElementMap.get(e);
886
903
  r.style.zIndex = `${o.priority}`;
887
904
  }
888
- updateEdgeShape(t) {
889
- const o = this.edgeIdToElementMap.get(t);
905
+ updateEdgeShape(e) {
906
+ const o = this.edgeIdToElementMap.get(e);
890
907
  this.container.removeChild(o);
891
- const r = this.graphStore.getEdge(t);
892
- this.edgeIdToElementMap.set(t, r.shape.svg), this.container.appendChild(r.shape.svg);
908
+ const r = this.graphStore.getEdge(e);
909
+ this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg);
893
910
  }
894
- renderEdge(t) {
895
- const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from), n = this.graphStore.getPort(o.to), h = r.element.getBoundingClientRect(), s = n.element.getBoundingClientRect(), c = this.host.getBoundingClientRect(), d = this.viewportStore.getViewportMatrix(), a = {
896
- x: d.scale * (h.left - c.left) + d.x,
897
- y: d.scale * (h.top - c.top) + d.y
911
+ renderEdge(e) {
912
+ const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), n = this.graphStore.getPort(o.to), h = r.element.getBoundingClientRect(), s = n.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = {
913
+ x: c.scale * (h.left - d.left) + c.x,
914
+ y: c.scale * (h.top - d.top) + c.y
898
915
  }, l = {
899
- x: d.scale * (s.left - c.left) + d.x,
900
- y: d.scale * (s.top - c.top) + d.y
916
+ x: c.scale * (s.left - d.left) + c.x,
917
+ y: c.scale * (s.top - d.top) + c.y
901
918
  }, g = {
902
919
  x: a.x,
903
920
  y: a.y,
904
- width: h.width * d.scale,
905
- height: h.height * d.scale,
921
+ width: h.width * c.scale,
922
+ height: h.height * c.scale,
906
923
  direction: r.direction,
907
924
  portId: o.from,
908
925
  nodeId: r.nodeId
909
- }, y = {
926
+ }, f = {
910
927
  x: l.x,
911
928
  y: l.y,
912
- width: s.width * d.scale,
913
- height: s.height * d.scale,
929
+ width: s.width * c.scale,
930
+ height: s.height * c.scale,
914
931
  direction: n.direction,
915
932
  portId: o.to,
916
933
  nodeId: n.nodeId
917
934
  };
918
935
  o.shape.render({
919
936
  from: g,
920
- to: y
937
+ to: f
921
938
  });
922
939
  }
923
- updateEdgePriority(t) {
924
- const o = this.graphStore.getEdge(t);
940
+ updateEdgePriority(e) {
941
+ const o = this.graphStore.getEdge(e);
925
942
  o.shape.svg.style.zIndex = `${o.priority}`;
926
943
  }
927
944
  }
928
- class St {
929
- constructor(t) {
945
+ class pe {
946
+ constructor(e) {
930
947
  i(this, "xFrom", 1 / 0);
931
948
  i(this, "yFrom", 1 / 0);
932
949
  i(this, "xTo", 1 / 0);
933
950
  i(this, "yTo", 1 / 0);
934
- this.graphStore = t;
951
+ this.graphStore = e;
935
952
  }
936
- setRenderingBox(t) {
937
- this.xFrom = t.x, this.xTo = t.x + t.width, this.yFrom = t.y, this.yTo = t.y + t.height;
953
+ setRenderingBox(e) {
954
+ this.xFrom = e.x, this.xTo = e.x + e.width, this.yFrom = e.y, this.yTo = e.y + e.height;
938
955
  }
939
- hasNode(t) {
940
- const o = this.graphStore.getNode(t);
956
+ hasNode(e) {
957
+ const o = this.graphStore.getNode(e);
941
958
  return o.x >= this.xFrom && o.x <= this.xTo && o.y >= this.yFrom && o.y <= this.yTo;
942
959
  }
943
- hasEdge(t) {
944
- const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from).nodeId, n = this.graphStore.getPort(o.to).nodeId, h = this.graphStore.getNode(r), s = this.graphStore.getNode(n), c = Math.min(h.x, s.x), d = Math.max(h.x, s.x), a = Math.min(h.y, s.y), l = Math.max(h.y, s.y);
945
- return c <= this.xTo && d >= this.xFrom && a <= this.yTo && l >= this.yFrom;
960
+ hasEdge(e) {
961
+ const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, n = this.graphStore.getPort(o.to).nodeId, h = this.graphStore.getNode(r), s = this.graphStore.getNode(n), d = Math.min(h.x, s.x), c = Math.max(h.x, s.x), a = Math.min(h.y, s.y), l = Math.max(h.y, s.y);
962
+ return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
946
963
  }
947
964
  }
948
- class At {
949
- constructor(t, o, r) {
965
+ class Se {
966
+ constructor(e, o, r) {
950
967
  i(this, "attachedNodes", /* @__PURE__ */ new Set());
951
968
  i(this, "attachedEdges", /* @__PURE__ */ new Set());
952
969
  i(this, "renderingBox");
953
- i(this, "updateViewport", (t) => {
954
- this.renderingBox.setRenderingBox(t);
970
+ i(this, "updateViewport", (e) => {
971
+ this.renderingBox.setRenderingBox(e);
955
972
  const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
956
973
  this.graphStore.getAllNodeIds().forEach((s) => {
957
- const c = this.renderingBox.hasNode(s), d = this.attachedNodes.has(s);
958
- c && !d ? o.add(s) : !c && d && r.add(s);
974
+ const d = this.renderingBox.hasNode(s), c = this.attachedNodes.has(s);
975
+ d && !c ? o.add(s) : !d && c && r.add(s);
959
976
  }), this.graphStore.getAllEdgeIds().forEach((s) => {
960
- const c = this.renderingBox.hasEdge(s), d = this.attachedEdges.has(s), a = this.graphStore.getEdge(s), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
961
- c && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), c && !d ? n.add(s) : !c && d && h.add(s);
977
+ const d = this.renderingBox.hasEdge(s), c = this.attachedEdges.has(s), a = this.graphStore.getEdge(s), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
978
+ d && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), d && !c ? n.add(s) : !d && c && h.add(s);
962
979
  }), h.forEach((s) => {
963
980
  this.handleDetachEdge(s);
964
981
  }), r.forEach((s) => {
@@ -969,42 +986,42 @@ class At {
969
986
  this.handleAttachEdge(s);
970
987
  });
971
988
  });
972
- this.htmlView = t, this.graphStore = o, this.trigger = r, this.renderingBox = new St(this.graphStore), this.trigger.subscribe(this.updateViewport);
989
+ this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new pe(this.graphStore), this.trigger.subscribe(this.updateViewport);
973
990
  }
974
- attach(t) {
975
- this.htmlView.attach(t);
991
+ attach(e) {
992
+ this.htmlView.attach(e);
976
993
  }
977
994
  detach() {
978
995
  this.htmlView.detach();
979
996
  }
980
- attachNode(t) {
981
- this.renderingBox.hasNode(t) && this.handleAttachNode(t);
997
+ attachNode(e) {
998
+ this.renderingBox.hasNode(e) && this.handleAttachNode(e);
982
999
  }
983
- detachNode(t) {
984
- this.attachedNodes.has(t) && this.handleDetachNode(t);
1000
+ detachNode(e) {
1001
+ this.attachedNodes.has(e) && this.handleDetachNode(e);
985
1002
  }
986
- attachEdge(t) {
987
- this.renderingBox.hasEdge(t) && this.attachEdgeEntities(t);
1003
+ attachEdge(e) {
1004
+ this.renderingBox.hasEdge(e) && this.attachEdgeEntities(e);
988
1005
  }
989
- detachEdge(t) {
990
- this.attachedEdges.has(t) && this.handleDetachEdge(t);
1006
+ detachEdge(e) {
1007
+ this.attachedEdges.has(e) && this.handleDetachEdge(e);
991
1008
  }
992
- updateNodeCoordinates(t) {
993
- this.attachedNodes.has(t) ? this.htmlView.updateNodeCoordinates(t) : this.renderingBox.hasNode(t) && (this.handleAttachNode(t), this.graphStore.getNodeAdjacentEdgeIds(t).forEach((o) => {
1009
+ updateNodeCoordinates(e) {
1010
+ this.attachedNodes.has(e) ? this.htmlView.updateNodeCoordinates(e) : this.renderingBox.hasNode(e) && (this.handleAttachNode(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((o) => {
994
1011
  this.attachEdgeEntities(o);
995
1012
  }));
996
1013
  }
997
- updateNodePriority(t) {
998
- this.attachedNodes.has(t) && this.htmlView.updateNodePriority(t);
1014
+ updateNodePriority(e) {
1015
+ this.attachedNodes.has(e) && this.htmlView.updateNodePriority(e);
999
1016
  }
1000
- updateEdgeShape(t) {
1001
- this.attachedEdges.has(t) && this.htmlView.updateEdgeShape(t);
1017
+ updateEdgeShape(e) {
1018
+ this.attachedEdges.has(e) && this.htmlView.updateEdgeShape(e);
1002
1019
  }
1003
- renderEdge(t) {
1004
- this.attachedEdges.has(t) && this.htmlView.renderEdge(t);
1020
+ renderEdge(e) {
1021
+ this.attachedEdges.has(e) && this.htmlView.renderEdge(e);
1005
1022
  }
1006
- updateEdgePriority(t) {
1007
- this.attachedEdges.has(t) && this.htmlView.updateEdgePriority(t);
1023
+ updateEdgePriority(e) {
1024
+ this.attachedEdges.has(e) && this.htmlView.updateEdgePriority(e);
1008
1025
  }
1009
1026
  clear() {
1010
1027
  this.htmlView.clear(), this.attachedNodes.clear(), this.attachedEdges.clear();
@@ -1012,51 +1029,51 @@ class At {
1012
1029
  destroy() {
1013
1030
  this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
1014
1031
  }
1015
- attachEdgeEntities(t) {
1016
- const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from).nodeId, n = this.graphStore.getPort(o.to).nodeId;
1017
- this.attachedNodes.has(r) || this.handleAttachNode(r), this.attachedNodes.has(n) || this.handleAttachNode(n), this.handleAttachEdge(t);
1032
+ attachEdgeEntities(e) {
1033
+ const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, n = this.graphStore.getPort(o.to).nodeId;
1034
+ this.attachedNodes.has(r) || this.handleAttachNode(r), this.attachedNodes.has(n) || this.handleAttachNode(n), this.handleAttachEdge(e);
1018
1035
  }
1019
- handleAttachNode(t) {
1020
- this.attachedNodes.add(t), this.htmlView.attachNode(t);
1036
+ handleAttachNode(e) {
1037
+ this.attachedNodes.add(e), this.htmlView.attachNode(e);
1021
1038
  }
1022
- handleDetachNode(t) {
1023
- this.htmlView.detachNode(t), this.attachedNodes.delete(t);
1039
+ handleDetachNode(e) {
1040
+ this.htmlView.detachNode(e), this.attachedNodes.delete(e);
1024
1041
  }
1025
- handleAttachEdge(t) {
1026
- this.attachedEdges.add(t), this.htmlView.attachEdge(t);
1042
+ handleAttachEdge(e) {
1043
+ this.attachedEdges.add(e), this.htmlView.attachEdge(e);
1027
1044
  }
1028
- handleDetachEdge(t) {
1029
- this.htmlView.detachEdge(t), this.attachedEdges.delete(t);
1045
+ handleDetachEdge(e) {
1046
+ this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
1030
1047
  }
1031
1048
  }
1032
- class q {
1049
+ class ee {
1033
1050
  constructor() {
1034
1051
  i(this, "callbacks", /* @__PURE__ */ new Set());
1035
1052
  }
1036
- subscribe(t) {
1037
- this.callbacks.add(t);
1053
+ subscribe(e) {
1054
+ this.callbacks.add(e);
1038
1055
  }
1039
- unsubscribe(t) {
1040
- this.callbacks.delete(t);
1056
+ unsubscribe(e) {
1057
+ this.callbacks.delete(e);
1041
1058
  }
1042
- emit(t) {
1059
+ emit(e) {
1043
1060
  this.callbacks.forEach((o) => {
1044
- o(t);
1061
+ o(e);
1045
1062
  });
1046
1063
  }
1047
1064
  }
1048
- const Tt = () => {
1049
- const e = new q();
1050
- return [e, e];
1065
+ const E = () => {
1066
+ const t = new ee();
1067
+ return [t, t];
1051
1068
  };
1052
- class Y {
1053
- constructor(t) {
1069
+ class z {
1070
+ constructor(e) {
1054
1071
  i(this, "counter", 0);
1055
- this.checkExists = t;
1072
+ this.checkExists = e;
1056
1073
  }
1057
- create(t) {
1058
- if (t !== void 0)
1059
- return t;
1074
+ create(e) {
1075
+ if (e !== void 0)
1076
+ return e;
1060
1077
  for (; this.checkExists(this.counter); )
1061
1078
  this.counter++;
1062
1079
  return this.counter;
@@ -1065,250 +1082,250 @@ class Y {
1065
1082
  this.counter = 0;
1066
1083
  }
1067
1084
  }
1068
- class E extends Error {
1085
+ class A extends Error {
1069
1086
  constructor() {
1070
1087
  super(...arguments);
1071
1088
  i(this, "name", "HtmlGraphError");
1072
1089
  }
1073
1090
  }
1074
- const pt = (e, t) => ({
1075
- x: e / 2,
1076
- y: t / 2
1077
- }), X = (e) => () => e, J = X(0), Mt = () => {
1078
- let e = 0;
1079
- return () => e++;
1080
- }, Nt = (e, t) => {
1081
- let o = J, r = J;
1082
- const n = Mt();
1083
- return e === "incremental" && (o = n), t === "incremental" && (r = n), typeof e == "number" && (o = X(e)), typeof t == "number" && (r = X(t)), typeof e == "function" && (o = e), typeof t == "function" && (r = t), {
1091
+ const Te = (t, e) => ({
1092
+ x: t / 2,
1093
+ y: e / 2
1094
+ }), Y = (t) => () => t, Q = Y(0), Ne = () => {
1095
+ let t = 0;
1096
+ return () => t++;
1097
+ }, me = (t, e) => {
1098
+ let o = Q, r = Q;
1099
+ const n = Ne();
1100
+ return t === "incremental" && (o = n), e === "incremental" && (r = n), typeof t == "number" && (o = Y(t)), typeof e == "number" && (r = Y(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
1084
1101
  nodesPriorityFn: o,
1085
1102
  edgesPriorityFn: r
1086
1103
  };
1087
- }, f = (e, t, o) => ({
1088
- x: t.x * e.x - t.y * e.y + ((1 - t.x) * o.x + t.y * o.y),
1089
- y: t.y * e.x + t.x * e.y + ((1 - t.x) * o.y - t.y * o.x)
1090
- }), p = (e, t, o) => ({ x: t * Math.cos(e), y: o * Math.sin(e) }), w = {
1104
+ }, v = (t, e, o) => ({
1105
+ x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
1106
+ y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
1107
+ }), N = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
1091
1108
  x: 0,
1092
1109
  y: 0
1093
- }, M = (e, t, o, r) => {
1110
+ }, m = (t, e, o, r) => {
1094
1111
  const h = [
1095
1112
  w,
1096
1113
  { x: o, y: r },
1097
1114
  { x: o, y: -r }
1098
- ].map((a) => f(a, e, w)).map((a) => ({ x: a.x + t.x, y: a.y + t.y })), s = `M ${h[0].x} ${h[0].y}`, c = `L ${h[1].x} ${h[1].y}`, d = `L ${h[2].x} ${h[2].y}`;
1099
- return `${s} ${c} ${d}`;
1100
- }, b = (e, t) => {
1115
+ ].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), s = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
1116
+ return `${s} ${d} ${c}`;
1117
+ }, L = (t, e) => {
1101
1118
  const o = [];
1102
- if (e.length > 0 && o.push(`M ${e[0].x} ${e[0].y}`), e.length === 2 && o.push(`L ${e[1].x} ${e[1].y}`), e.length > 2) {
1103
- const r = e.length - 1;
1119
+ 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) {
1120
+ const r = t.length - 1;
1104
1121
  let n = 0, h = 0, s = 0;
1105
- e.forEach((c, d) => {
1122
+ t.forEach((d, c) => {
1106
1123
  let a = 0, l = 0, g = 0;
1107
- const y = d > 0, x = d < r, v = y && x;
1108
- if (y && (a = -n, l = -h, g = s), x) {
1109
- const P = e[d + 1];
1110
- n = P.x - c.x, h = P.y - c.y, s = Math.sqrt(n * n + h * h);
1124
+ const f = c > 0, x = c < r, y = f && x;
1125
+ if (f && (a = -n, l = -h, g = s), x) {
1126
+ const C = t[c + 1];
1127
+ n = C.x - d.x, h = C.y - d.y, s = Math.sqrt(n * n + h * h);
1111
1128
  }
1112
- const S = s !== 0 ? Math.min((v ? t : 0) / s, d < r - 1 ? 0.5 : 1) : 0, T = v ? { x: c.x + n * S, y: c.y + h * S } : c, L = g !== 0 ? Math.min((v ? t : 0) / g, d > 1 ? 0.5 : 1) : 0, D = v ? { x: c.x + a * L, y: c.y + l * L } : c;
1113
- d > 0 && o.push(`L ${D.x} ${D.y}`), v && o.push(
1114
- `C ${c.x} ${c.y} ${c.x} ${c.y} ${T.x} ${T.y}`
1129
+ const p = s !== 0 ? Math.min((y ? e : 0) / s, c < r - 1 ? 0.5 : 1) : 0, T = y ? { x: d.x + n * p, y: d.y + h * p } : d, V = g !== 0 ? Math.min((y ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, D = y ? { x: d.x + a * V, y: d.y + l * V } : d;
1130
+ c > 0 && o.push(`L ${D.x} ${D.y}`), y && o.push(
1131
+ `C ${d.x} ${d.y} ${d.x} ${d.y} ${T.x} ${T.y}`
1115
1132
  );
1116
1133
  });
1117
1134
  }
1118
1135
  return o.join(" ");
1119
1136
  }, I = () => {
1120
- const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1121
- return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e;
1137
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1138
+ return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
1122
1139
  }, F = () => {
1123
- const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
1124
- return e.style.transformOrigin = "50% 50%", e;
1125
- }, R = (e, t) => {
1140
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
1141
+ return t.style.transformOrigin = "50% 50%", t;
1142
+ }, U = (t, e) => {
1126
1143
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
1127
- return o.setAttribute("stroke", e), o.setAttribute("stroke-width", `${t}`), o.setAttribute("fill", "none"), o;
1128
- }, N = (e) => {
1129
- const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
1130
- return t.setAttribute("fill", e), t;
1131
- }, k = (e, t) => {
1144
+ return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
1145
+ }, M = (t) => {
1146
+ const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1147
+ return e.setAttribute("fill", t), e;
1148
+ }, B = (t, e) => {
1132
1149
  const o = {
1133
- x: e.x + e.width / 2,
1134
- y: e.y + e.height / 2
1135
- }, r = {
1136
1150
  x: t.x + t.width / 2,
1137
1151
  y: t.y + t.height / 2
1138
- }, n = Math.min(o.x, r.x), h = Math.min(o.y, r.y), s = Math.abs(r.x - o.x), c = Math.abs(r.y - o.y), d = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
1152
+ }, r = {
1153
+ x: e.x + e.width / 2,
1154
+ y: e.y + e.height / 2
1155
+ }, n = Math.min(o.x, r.x), h = Math.min(o.y, r.y), s = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
1139
1156
  return {
1140
1157
  x: n,
1141
1158
  y: h,
1142
1159
  width: s,
1143
- height: c,
1144
- flipX: d,
1160
+ height: d,
1161
+ flipX: c,
1145
1162
  flipY: a
1146
1163
  };
1147
- }, Vt = (e) => {
1148
- const t = f(
1149
- { x: e.arrowLength, y: w.y },
1150
- e.fromVect,
1164
+ }, Me = (t) => {
1165
+ const e = v(
1166
+ { x: t.arrowLength, y: w.y },
1167
+ t.fromVect,
1151
1168
  w
1152
- ), o = f(
1153
- { x: e.to.x - e.arrowLength, y: e.to.y },
1154
- e.toVect,
1155
- e.to
1169
+ ), o = v(
1170
+ { x: t.to.x - t.arrowLength, y: t.to.y },
1171
+ t.toVect,
1172
+ t.to
1156
1173
  ), r = {
1157
- x: t.x + e.fromVect.x * e.curvature,
1158
- y: t.y + e.fromVect.y * e.curvature
1174
+ x: e.x + t.fromVect.x * t.curvature,
1175
+ y: e.y + t.fromVect.y * t.curvature
1159
1176
  }, n = {
1160
- x: o.x - e.toVect.x * e.curvature,
1161
- y: o.y - e.toVect.y * e.curvature
1162
- }, h = `M ${t.x} ${t.y} C ${r.x} ${r.y}, ${n.x} ${n.y}, ${o.x} ${o.y}`, s = e.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${t.x} ${t.y} `, c = e.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;
1163
- return `${s}${h}${c}`;
1164
- }, Lt = (e) => {
1165
- const t = e.hasSourceArrow ? f(
1166
- { x: e.arrowLength, y: w.y },
1167
- e.fromVect,
1177
+ x: o.x - t.toVect.x * t.curvature,
1178
+ y: o.y - t.toVect.y * t.curvature
1179
+ }, h = `M ${e.x} ${e.y} C ${r.x} ${r.y}, ${n.x} ${n.y}, ${o.x} ${o.y}`, s = 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}`;
1180
+ return `${s}${h}${d}`;
1181
+ }, Pe = (t) => {
1182
+ const e = t.hasSourceArrow ? v(
1183
+ { x: t.arrowLength, y: w.y },
1184
+ t.fromVect,
1168
1185
  w
1169
- ) : w, o = e.hasTargetArrow ? f(
1170
- { x: e.to.x - e.arrowLength, y: e.to.y },
1171
- e.toVect,
1172
- e.to
1173
- ) : e.to, r = e.arrowLength, n = Math.cos(e.detourDirection) * e.detourDistance, h = Math.sin(e.detourDirection) * e.detourDistance, s = n * e.flipX, c = h * e.flipY, d = f(
1186
+ ) : w, o = t.hasTargetArrow ? v(
1187
+ { x: t.to.x - t.arrowLength, y: t.to.y },
1188
+ t.toVect,
1189
+ t.to
1190
+ ) : t.to, r = t.arrowLength, n = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, s = n * t.flipX, d = h * t.flipY, c = v(
1174
1191
  { x: r, y: w.y },
1175
- e.fromVect,
1192
+ t.fromVect,
1176
1193
  w
1177
1194
  ), a = {
1178
- x: d.x + s,
1179
- y: d.y + c
1180
- }, l = f(
1181
- { x: e.to.x - r, y: e.to.y },
1182
- e.toVect,
1183
- e.to
1195
+ x: c.x + s,
1196
+ y: c.y + d
1197
+ }, l = v(
1198
+ { x: t.to.x - r, y: t.to.y },
1199
+ t.toVect,
1200
+ t.to
1184
1201
  ), g = {
1185
1202
  x: l.x + s,
1186
- y: l.y + c
1187
- }, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, x = {
1188
- x: d.x + e.curvature * e.fromVect.x,
1189
- y: d.y + e.curvature * e.fromVect.y
1190
- }, v = {
1191
- x: l.x - e.curvature * e.toVect.x,
1192
- y: l.y - e.curvature * e.toVect.y
1193
- }, A = {
1194
- x: d.x + s,
1195
- y: d.y + c
1203
+ y: l.y + d
1204
+ }, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, x = {
1205
+ x: c.x + t.curvature * t.fromVect.x,
1206
+ y: c.y + t.curvature * t.fromVect.y
1207
+ }, y = {
1208
+ x: l.x - t.curvature * t.toVect.x,
1209
+ y: l.y - t.curvature * t.toVect.y
1196
1210
  }, S = {
1211
+ x: c.x + s,
1212
+ y: c.y + d
1213
+ }, p = {
1197
1214
  x: l.x + s,
1198
- y: l.y + c
1215
+ y: l.y + d
1199
1216
  };
1200
1217
  return [
1201
- `M ${t.x} ${t.y}`,
1202
- `L ${d.x} ${d.y}`,
1203
- `C ${x.x} ${x.y} ${A.x} ${A.y} ${y.x} ${y.y}`,
1204
- `C ${S.x} ${S.y} ${v.x} ${v.y} ${l.x} ${l.y}`,
1218
+ `M ${e.x} ${e.y}`,
1219
+ `L ${c.x} ${c.y}`,
1220
+ `C ${x.x} ${x.y} ${S.x} ${S.y} ${f.x} ${f.y}`,
1221
+ `C ${p.x} ${p.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
1205
1222
  `L ${o.x} ${o.y}`
1206
1223
  ].join(" ");
1207
- }, Dt = (e) => {
1208
- const t = e.hasSourceArrow ? f(
1209
- { x: e.arrowLength, y: w.y },
1210
- e.fromVect,
1224
+ }, Ve = (t) => {
1225
+ const e = t.hasSourceArrow ? v(
1226
+ { x: t.arrowLength, y: w.y },
1227
+ t.fromVect,
1211
1228
  w
1212
- ) : w, o = e.hasTargetArrow ? f(
1213
- { x: e.to.x - e.arrowLength, y: e.to.y },
1214
- e.toVect,
1215
- e.to
1216
- ) : e.to, r = e.arrowLength + e.arrowOffset, n = r - e.roundness, h = f({ x: n, y: w.y }, e.fromVect, w), s = f(
1217
- { x: e.to.x - n, y: e.to.y },
1218
- e.toVect,
1219
- e.to
1220
- ), c = Math.max((h.x + s.x) / 2, r), d = e.to.y / 2, a = { x: e.flipX > 0 ? c : -r, y: h.y }, l = { x: a.x, y: d }, g = {
1221
- x: e.flipX > 0 ? e.to.x - c : e.to.x + r,
1229
+ ) : w, o = t.hasTargetArrow ? v(
1230
+ { x: t.to.x - t.arrowLength, y: t.to.y },
1231
+ t.toVect,
1232
+ t.to
1233
+ ) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, h = v({ x: n, y: w.y }, t.fromVect, w), s = v(
1234
+ { x: t.to.x - n, y: t.to.y },
1235
+ t.toVect,
1236
+ t.to
1237
+ ), d = Math.max((h.x + s.x) / 2, r), c = t.to.y / 2, a = { x: t.flipX > 0 ? d : -r, y: h.y }, l = { x: a.x, y: c }, g = {
1238
+ x: t.flipX > 0 ? t.to.x - d : t.to.x + r,
1222
1239
  y: s.y
1223
- }, y = { x: g.x, y: d };
1224
- return b(
1225
- [t, h, a, l, y, g, s, o],
1226
- e.roundness
1240
+ }, f = { x: g.x, y: c };
1241
+ return L(
1242
+ [e, h, a, l, f, g, s, o],
1243
+ t.roundness
1227
1244
  );
1228
- }, B = (e) => {
1229
- const t = e.hasSourceArrow ? f(
1230
- { x: e.arrowLength, y: w.y },
1231
- e.fromVect,
1245
+ }, X = (t) => {
1246
+ const e = t.hasSourceArrow ? v(
1247
+ { x: t.arrowLength, y: w.y },
1248
+ t.fromVect,
1232
1249
  w
1233
- ) : w, o = e.hasTargetArrow ? f(
1234
- { x: e.to.x - e.arrowLength, y: e.to.y },
1235
- e.toVect,
1236
- e.to
1237
- ) : e.to, r = e.arrowLength + e.arrowOffset, n = f(
1250
+ ) : w, o = t.hasTargetArrow ? v(
1251
+ { x: t.to.x - t.arrowLength, y: t.to.y },
1252
+ t.toVect,
1253
+ t.to
1254
+ ) : t.to, r = t.arrowLength + t.arrowOffset, n = v(
1238
1255
  { x: r, y: w.y },
1239
- e.fromVect,
1256
+ t.fromVect,
1240
1257
  w
1241
- ), h = Math.cos(e.detourDirection) * e.detourDistance, s = Math.sin(e.detourDirection) * e.detourDistance, c = h * e.flipX, d = s * e.flipY, a = { x: n.x + c, y: n.y + d }, l = f(
1242
- { x: e.to.x - r, y: e.to.y },
1243
- e.toVect,
1244
- e.to
1245
- ), g = { x: l.x + c, y: l.y + d };
1246
- return b(
1247
- [t, n, a, g, l, o],
1248
- e.roundness
1258
+ ), h = Math.cos(t.detourDirection) * t.detourDistance, s = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = s * t.flipY, a = { x: n.x + d, y: n.y + c }, l = v(
1259
+ { x: t.to.x - r, y: t.to.y },
1260
+ t.toVect,
1261
+ t.to
1262
+ ), g = { x: l.x + d, y: l.y + c };
1263
+ return L(
1264
+ [e, n, a, g, l, o],
1265
+ t.roundness
1249
1266
  );
1250
- }, Pt = (e) => {
1251
- const t = e.hasSourceArrow ? f(
1252
- { x: e.arrowLength, y: w.y },
1253
- e.fromVect,
1267
+ }, De = (t) => {
1268
+ const e = t.hasSourceArrow ? v(
1269
+ { x: t.arrowLength, y: w.y },
1270
+ t.fromVect,
1254
1271
  w
1255
- ) : w, o = e.hasTargetArrow ? f(
1256
- { x: e.to.x - e.arrowLength, y: e.to.y },
1257
- e.toVect,
1258
- e.to
1259
- ) : e.to, r = e.arrowLength + e.arrowOffset, n = f({ x: r, y: w.y }, e.fromVect, w), h = f(
1260
- { x: e.to.x - r, y: e.to.y },
1261
- e.toVect,
1262
- e.to
1272
+ ) : w, o = t.hasTargetArrow ? v(
1273
+ { x: t.to.x - t.arrowLength, y: t.to.y },
1274
+ t.toVect,
1275
+ t.to
1276
+ ) : t.to, r = t.arrowLength + t.arrowOffset, n = v({ x: r, y: w.y }, t.fromVect, w), h = v(
1277
+ { x: t.to.x - r, y: t.to.y },
1278
+ t.toVect,
1279
+ t.to
1263
1280
  );
1264
- return b([t, n, h, o], e.roundness);
1265
- }, bt = (e) => {
1266
- const t = e.hasSourceArrow ? f(
1267
- { x: e.arrowLength, y: w.y },
1268
- e.fromVect,
1281
+ return L([e, n, h, o], t.roundness);
1282
+ }, Ce = (t) => {
1283
+ const e = t.hasSourceArrow ? v(
1284
+ { x: t.arrowLength, y: w.y },
1285
+ t.fromVect,
1269
1286
  w
1270
- ) : w, o = e.hasTargetArrow ? f(
1271
- { x: e.to.x - e.arrowLength, y: e.to.y },
1272
- e.toVect,
1273
- e.to
1274
- ) : e.to, r = e.arrowLength + e.arrowOffset, n = r - e.roundness, h = f({ x: n, y: w.y }, e.fromVect, w), s = f(
1275
- { x: e.to.x - n, y: e.to.y },
1276
- e.toVect,
1277
- e.to
1278
- ), c = Math.max((h.y + s.y) / 2, r), d = e.to.x / 2, a = { x: h.x, y: e.flipY > 0 ? c : -r }, l = { x: d, y: a.y }, g = {
1287
+ ) : w, o = t.hasTargetArrow ? v(
1288
+ { x: t.to.x - t.arrowLength, y: t.to.y },
1289
+ t.toVect,
1290
+ t.to
1291
+ ) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, h = v({ x: n, y: w.y }, t.fromVect, w), s = v(
1292
+ { x: t.to.x - n, y: t.to.y },
1293
+ t.toVect,
1294
+ t.to
1295
+ ), d = Math.max((h.y + s.y) / 2, r), c = t.to.x / 2, a = { x: h.x, y: t.flipY > 0 ? d : -r }, l = { x: c, y: a.y }, g = {
1279
1296
  x: s.x,
1280
- y: e.flipY > 0 ? e.to.y - c : e.to.y + r
1281
- }, y = { x: d, y: g.y };
1282
- return b(
1283
- [t, h, a, l, y, g, s, o],
1284
- e.roundness
1297
+ y: t.flipY > 0 ? t.to.y - d : t.to.y + r
1298
+ }, f = { x: c, y: g.y };
1299
+ return L(
1300
+ [e, h, a, l, f, g, s, o],
1301
+ t.roundness
1285
1302
  );
1286
- }, H = (e) => {
1287
- const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, n = r + 2 * o, s = [
1288
- { x: e.arrowLength, y: w.y },
1303
+ }, j = (t) => {
1304
+ const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, n = r + 2 * o, s = [
1305
+ { x: t.arrowLength, y: w.y },
1289
1306
  { x: r, y: w.y },
1290
- { x: r, y: e.side },
1291
- { x: n, y: e.side },
1292
- { x: n, y: -e.side },
1293
- { x: r, y: -e.side },
1307
+ { x: r, y: t.side },
1308
+ { x: n, y: t.side },
1309
+ { x: n, y: -t.side },
1310
+ { x: r, y: -t.side },
1294
1311
  { x: r, y: w.y },
1295
- { x: e.arrowLength, y: w.y }
1312
+ { x: t.arrowLength, y: w.y }
1296
1313
  ].map(
1297
- (d) => f(d, e.fromVect, w)
1298
- ), c = `M ${w.x} ${w.y} L ${s[0].x} ${s[0].y} `;
1299
- return `${e.hasSourceArrow || e.hasTargetArrow ? "" : c}${b(s, e.roundness)}`;
1300
- }, mt = (e) => {
1301
- const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), n = t + o, h = e.arrowLength + r * (1 - o / n), s = t * o / n, d = [
1302
- { x: e.arrowLength, y: w.y },
1314
+ (c) => v(c, t.fromVect, w)
1315
+ ), d = `M ${w.x} ${w.y} L ${s[0].x} ${s[0].y} `;
1316
+ return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${L(s, t.roundness)}`;
1317
+ }, Le = (t) => {
1318
+ const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), n = e + o, h = t.arrowLength + r * (1 - o / n), s = e * o / n, c = [
1319
+ { x: t.arrowLength, y: w.y },
1303
1320
  { x: h, y: s },
1304
1321
  { x: h, y: -s }
1305
- ].map((g) => f(g, e.fromVect, w)), a = [
1306
- `M ${d[0].x} ${d[0].y}`,
1307
- `A ${t} ${t} 0 0 1 ${d[1].x} ${d[1].y}`,
1308
- `A ${o} ${o} 0 1 0 ${d[2].x} ${d[2].y}`,
1309
- `A ${t} ${t} 0 0 1 ${d[0].x} ${d[0].y}`
1310
- ].join(" "), l = `M 0 0 L ${d[0].x} ${d[0].y} `;
1311
- return `${e.hasSourceArrow || e.hasTargetArrow ? "" : l}${a}`;
1322
+ ].map((g) => v(g, t.fromVect, w)), a = [
1323
+ `M ${c[0].x} ${c[0].y}`,
1324
+ `A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
1325
+ `A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
1326
+ `A ${e} ${e} 0 0 1 ${c[0].x} ${c[0].y}`
1327
+ ].join(" "), l = `M 0 0 L ${c[0].x} ${c[0].y} `;
1328
+ return `${t.hasSourceArrow || t.hasTargetArrow ? "" : l}${a}`;
1312
1329
  }, u = Object.freeze({
1313
1330
  color: "#777777",
1314
1331
  width: 1,
@@ -1326,8 +1343,8 @@ const pt = (e, t) => ({
1326
1343
  smallCycleRadius: 15,
1327
1344
  curvature: 90
1328
1345
  });
1329
- class Ct {
1330
- constructor(t) {
1346
+ class be {
1347
+ constructor(e) {
1331
1348
  i(this, "svg", I());
1332
1349
  i(this, "group", F());
1333
1350
  i(this, "line");
@@ -1342,74 +1359,74 @@ class Ct {
1342
1359
  i(this, "detourDistance");
1343
1360
  i(this, "hasSourceArrow");
1344
1361
  i(this, "hasTargetArrow");
1345
- this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.curvature = (t == null ? void 0 : t.curvature) ?? u.curvature, this.portCycleRadius = (t == null ? void 0 : t.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (t == null ? void 0 : t.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
1346
- const o = (t == null ? void 0 : t.color) ?? u.color, r = (t == null ? void 0 : t.width) ?? u.width;
1347
- this.svg.appendChild(this.group), this.line = R(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(o), this.group.appendChild(this.targetArrow));
1348
- }
1349
- render(t) {
1350
- const { x: o, y: r, width: n, height: h, flipX: s, flipY: c } = k(
1351
- t.from,
1352
- t.to
1362
+ 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;
1363
+ const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
1364
+ this.svg.appendChild(this.group), this.line = U(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(o), this.group.appendChild(this.targetArrow));
1365
+ }
1366
+ render(e) {
1367
+ const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
1368
+ e.from,
1369
+ e.to
1353
1370
  );
1354
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${c})`;
1355
- const d = p(
1356
- t.from.direction,
1371
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${d})`;
1372
+ const c = N(
1373
+ e.from.direction,
1357
1374
  s,
1358
- c
1359
- ), a = p(t.to.direction, s, c), l = {
1375
+ d
1376
+ ), a = N(e.to.direction, s, d), l = {
1360
1377
  x: n,
1361
1378
  y: h
1362
1379
  };
1363
- let g, y = a, x = -this.arrowLength;
1364
- if (t.from.portId === t.to.portId ? (g = mt({
1365
- fromVect: d,
1380
+ let g, f = a, x = -this.arrowLength;
1381
+ if (e.from.portId === e.to.portId ? (g = Le({
1382
+ fromVect: c,
1366
1383
  radius: this.portCycleRadius,
1367
1384
  smallRadius: this.portCycleSmallRadius,
1368
1385
  arrowLength: this.arrowLength,
1369
1386
  hasSourceArrow: this.hasSourceArrow,
1370
1387
  hasTargetArrow: this.hasTargetArrow
1371
- }), y = d, x = this.arrowLength) : t.from.nodeId === t.to.nodeId ? g = Lt({
1388
+ }), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = Pe({
1372
1389
  to: l,
1373
- fromVect: d,
1390
+ fromVect: c,
1374
1391
  toVect: a,
1375
1392
  flipX: s,
1376
- flipY: c,
1393
+ flipY: d,
1377
1394
  arrowLength: this.arrowLength,
1378
1395
  detourDirection: this.detourDirection,
1379
1396
  detourDistance: this.detourDistance,
1380
1397
  curvature: this.curvature,
1381
1398
  hasSourceArrow: this.hasSourceArrow,
1382
1399
  hasTargetArrow: this.hasTargetArrow
1383
- }) : g = Vt({
1400
+ }) : g = Me({
1384
1401
  to: l,
1385
- fromVect: d,
1402
+ fromVect: c,
1386
1403
  toVect: a,
1387
1404
  arrowLength: this.arrowLength,
1388
1405
  curvature: this.curvature,
1389
1406
  hasSourceArrow: this.hasSourceArrow,
1390
1407
  hasTargetArrow: this.hasTargetArrow
1391
1408
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1392
- const v = M(
1393
- d,
1409
+ const y = m(
1410
+ c,
1394
1411
  w,
1395
1412
  this.arrowLength,
1396
1413
  this.arrowWidth
1397
1414
  );
1398
- this.sourceArrow.setAttribute("d", v);
1415
+ this.sourceArrow.setAttribute("d", y);
1399
1416
  }
1400
1417
  if (this.targetArrow) {
1401
- const v = M(
1402
- y,
1418
+ const y = m(
1419
+ f,
1403
1420
  l,
1404
1421
  x,
1405
1422
  this.arrowWidth
1406
1423
  );
1407
- this.targetArrow.setAttribute("d", v);
1424
+ this.targetArrow.setAttribute("d", y);
1408
1425
  }
1409
1426
  }
1410
1427
  }
1411
- class $t {
1412
- constructor(t) {
1428
+ class $e {
1429
+ constructor(e) {
1413
1430
  i(this, "svg", I());
1414
1431
  i(this, "group", F());
1415
1432
  i(this, "line");
@@ -1424,45 +1441,45 @@ class $t {
1424
1441
  i(this, "detourDistance");
1425
1442
  i(this, "hasSourceArrow");
1426
1443
  i(this, "hasTargetArrow");
1427
- this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? u.cycleSquareSide;
1428
- const o = (t == null ? void 0 : t.roundness) ?? u.roundness;
1444
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
1445
+ const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
1429
1446
  this.roundness = Math.min(
1430
1447
  o,
1431
1448
  this.arrowOffset,
1432
1449
  this.cycleSquareSide / 2
1433
- ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
1434
- const r = (t == null ? void 0 : t.color) ?? u.color, n = (t == null ? void 0 : t.width) ?? u.width;
1435
- this.svg.appendChild(this.group), this.line = R(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
1436
- }
1437
- render(t) {
1438
- const { x: o, y: r, width: n, height: h, flipX: s, flipY: c } = k(
1439
- t.from,
1440
- t.to
1450
+ ), 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;
1451
+ const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
1452
+ this.svg.appendChild(this.group), this.line = U(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
1453
+ }
1454
+ render(e) {
1455
+ const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
1456
+ e.from,
1457
+ e.to
1441
1458
  );
1442
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${c})`;
1443
- const d = p(
1444
- t.from.direction,
1459
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${d})`;
1460
+ const c = N(
1461
+ e.from.direction,
1445
1462
  s,
1446
- c
1447
- ), a = p(t.to.direction, s, c), l = {
1463
+ d
1464
+ ), a = N(e.to.direction, s, d), l = {
1448
1465
  x: n,
1449
1466
  y: h
1450
1467
  };
1451
- let g, y = a, x = -this.arrowLength;
1452
- if (t.from.portId === t.to.portId ? (g = H({
1453
- fromVect: d,
1468
+ let g, f = a, x = -this.arrowLength;
1469
+ if (e.from.portId === e.to.portId ? (g = j({
1470
+ fromVect: c,
1454
1471
  arrowLength: this.arrowLength,
1455
1472
  side: this.cycleSquareSide,
1456
1473
  arrowOffset: this.arrowOffset,
1457
1474
  roundness: this.roundness,
1458
1475
  hasSourceArrow: this.hasSourceArrow,
1459
1476
  hasTargetArrow: this.hasTargetArrow
1460
- }), y = d, x = this.arrowLength) : t.from.nodeId === t.to.nodeId ? g = B({
1477
+ }), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = X({
1461
1478
  to: l,
1462
- fromVect: d,
1479
+ fromVect: c,
1463
1480
  toVect: a,
1464
1481
  flipX: s,
1465
- flipY: c,
1482
+ flipY: d,
1466
1483
  arrowLength: this.arrowLength,
1467
1484
  arrowOffset: this.arrowOffset,
1468
1485
  roundness: this.roundness,
@@ -1470,9 +1487,9 @@ class $t {
1470
1487
  detourDistance: this.detourDistance,
1471
1488
  hasSourceArrow: this.hasSourceArrow,
1472
1489
  hasTargetArrow: this.hasTargetArrow
1473
- }) : g = Dt({
1490
+ }) : g = Ve({
1474
1491
  to: l,
1475
- fromVect: d,
1492
+ fromVect: c,
1476
1493
  toVect: a,
1477
1494
  flipX: s,
1478
1495
  arrowLength: this.arrowLength,
@@ -1481,27 +1498,27 @@ class $t {
1481
1498
  hasSourceArrow: this.hasSourceArrow,
1482
1499
  hasTargetArrow: this.hasTargetArrow
1483
1500
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1484
- const v = M(
1485
- d,
1501
+ const y = m(
1502
+ c,
1486
1503
  w,
1487
1504
  this.arrowLength,
1488
1505
  this.arrowWidth
1489
1506
  );
1490
- this.sourceArrow.setAttribute("d", v);
1507
+ this.sourceArrow.setAttribute("d", y);
1491
1508
  }
1492
1509
  if (this.targetArrow) {
1493
- const v = M(
1494
- y,
1510
+ const y = m(
1511
+ f,
1495
1512
  l,
1496
1513
  x,
1497
1514
  this.arrowWidth
1498
1515
  );
1499
- this.targetArrow.setAttribute("d", v);
1516
+ this.targetArrow.setAttribute("d", y);
1500
1517
  }
1501
1518
  }
1502
1519
  }
1503
- class Wt {
1504
- constructor(t) {
1520
+ class We {
1521
+ constructor(e) {
1505
1522
  i(this, "svg", I());
1506
1523
  i(this, "group", F());
1507
1524
  i(this, "line");
@@ -1516,45 +1533,45 @@ class Wt {
1516
1533
  i(this, "detourDistance");
1517
1534
  i(this, "hasSourceArrow");
1518
1535
  i(this, "hasTargetArrow");
1519
- this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? u.cycleSquareSide;
1520
- const o = (t == null ? void 0 : t.roundness) ?? u.roundness;
1536
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
1537
+ const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
1521
1538
  this.roundness = Math.min(
1522
1539
  o,
1523
1540
  this.arrowOffset,
1524
1541
  this.cycleSquareSide / 2
1525
- ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
1526
- const r = (t == null ? void 0 : t.color) ?? u.color, n = (t == null ? void 0 : t.width) ?? u.width;
1527
- this.svg.appendChild(this.group), this.line = R(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
1528
- }
1529
- render(t) {
1530
- const { x: o, y: r, width: n, height: h, flipX: s, flipY: c } = k(
1531
- t.from,
1532
- t.to
1542
+ ), 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;
1543
+ const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
1544
+ this.svg.appendChild(this.group), this.line = U(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
1545
+ }
1546
+ render(e) {
1547
+ const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
1548
+ e.from,
1549
+ e.to
1533
1550
  );
1534
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${c})`;
1535
- const d = p(
1536
- t.from.direction,
1551
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${d})`;
1552
+ const c = N(
1553
+ e.from.direction,
1537
1554
  s,
1538
- c
1539
- ), a = p(t.to.direction, s, c), l = {
1555
+ d
1556
+ ), a = N(e.to.direction, s, d), l = {
1540
1557
  x: n,
1541
1558
  y: h
1542
1559
  };
1543
- let g, y = a, x = -this.arrowLength;
1544
- if (t.from.portId === t.to.portId ? (g = H({
1545
- fromVect: d,
1560
+ let g, f = a, x = -this.arrowLength;
1561
+ if (e.from.portId === e.to.portId ? (g = j({
1562
+ fromVect: c,
1546
1563
  arrowLength: this.arrowLength,
1547
1564
  side: this.cycleSquareSide,
1548
1565
  arrowOffset: this.arrowOffset,
1549
1566
  roundness: this.roundness,
1550
1567
  hasSourceArrow: this.hasSourceArrow,
1551
1568
  hasTargetArrow: this.hasTargetArrow
1552
- }), y = d, x = this.arrowLength) : t.from.nodeId === t.to.nodeId ? g = B({
1569
+ }), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = X({
1553
1570
  to: l,
1554
- fromVect: d,
1571
+ fromVect: c,
1555
1572
  toVect: a,
1556
1573
  flipX: s,
1557
- flipY: c,
1574
+ flipY: d,
1558
1575
  arrowLength: this.arrowLength,
1559
1576
  arrowOffset: this.arrowOffset,
1560
1577
  roundness: this.roundness,
@@ -1562,9 +1579,9 @@ class Wt {
1562
1579
  detourDistance: this.detourDistance,
1563
1580
  hasSourceArrow: this.hasSourceArrow,
1564
1581
  hasTargetArrow: this.hasTargetArrow
1565
- }) : g = Pt({
1582
+ }) : g = De({
1566
1583
  to: l,
1567
- fromVect: d,
1584
+ fromVect: c,
1568
1585
  toVect: a,
1569
1586
  arrowLength: this.arrowLength,
1570
1587
  arrowOffset: this.arrowOffset,
@@ -1572,27 +1589,27 @@ class Wt {
1572
1589
  hasSourceArrow: this.hasSourceArrow,
1573
1590
  hasTargetArrow: this.hasTargetArrow
1574
1591
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1575
- const v = M(
1576
- d,
1592
+ const y = m(
1593
+ c,
1577
1594
  w,
1578
1595
  this.arrowLength,
1579
1596
  this.arrowWidth
1580
1597
  );
1581
- this.sourceArrow.setAttribute("d", v);
1598
+ this.sourceArrow.setAttribute("d", y);
1582
1599
  }
1583
1600
  if (this.targetArrow) {
1584
- const v = M(
1585
- y,
1601
+ const y = m(
1602
+ f,
1586
1603
  l,
1587
1604
  x,
1588
1605
  this.arrowWidth
1589
1606
  );
1590
- this.targetArrow.setAttribute("d", v);
1607
+ this.targetArrow.setAttribute("d", y);
1591
1608
  }
1592
1609
  }
1593
1610
  }
1594
- class It {
1595
- constructor(t) {
1611
+ class Re {
1612
+ constructor(e) {
1596
1613
  i(this, "svg", I());
1597
1614
  i(this, "group", F());
1598
1615
  i(this, "line");
@@ -1607,45 +1624,45 @@ class It {
1607
1624
  i(this, "detourDistance");
1608
1625
  i(this, "hasSourceArrow");
1609
1626
  i(this, "hasTargetArrow");
1610
- this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? u.cycleSquareSide;
1611
- const o = (t == null ? void 0 : t.roundness) ?? u.roundness;
1627
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
1628
+ const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
1612
1629
  this.roundness = Math.min(
1613
1630
  o,
1614
1631
  this.arrowOffset,
1615
1632
  this.cycleSquareSide / 2
1616
- ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
1617
- const r = (t == null ? void 0 : t.color) ?? u.color, n = (t == null ? void 0 : t.width) ?? u.width;
1618
- this.svg.appendChild(this.group), this.line = R(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
1619
- }
1620
- render(t) {
1621
- const { x: o, y: r, width: n, height: h, flipX: s, flipY: c } = k(
1622
- t.from,
1623
- t.to
1633
+ ), 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;
1634
+ const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
1635
+ this.svg.appendChild(this.group), this.line = U(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
1636
+ }
1637
+ render(e) {
1638
+ const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
1639
+ e.from,
1640
+ e.to
1624
1641
  );
1625
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${c})`;
1626
- const d = p(
1627
- t.from.direction,
1642
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${h}px`, this.group.style.transform = `scale(${s}, ${d})`;
1643
+ const c = N(
1644
+ e.from.direction,
1628
1645
  s,
1629
- c
1630
- ), a = p(t.to.direction, s, c), l = {
1646
+ d
1647
+ ), a = N(e.to.direction, s, d), l = {
1631
1648
  x: n,
1632
1649
  y: h
1633
1650
  };
1634
- let g, y = a, x = -this.arrowLength;
1635
- if (t.from.portId === t.to.portId ? (g = H({
1636
- fromVect: d,
1651
+ let g, f = a, x = -this.arrowLength;
1652
+ if (e.from.portId === e.to.portId ? (g = j({
1653
+ fromVect: c,
1637
1654
  arrowLength: this.arrowLength,
1638
1655
  side: this.cycleSquareSide,
1639
1656
  arrowOffset: this.arrowOffset,
1640
1657
  roundness: this.roundness,
1641
1658
  hasSourceArrow: this.hasSourceArrow,
1642
1659
  hasTargetArrow: this.hasTargetArrow
1643
- }), y = d, x = this.arrowLength) : t.from.nodeId === t.to.nodeId ? g = B({
1660
+ }), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = X({
1644
1661
  to: l,
1645
- fromVect: d,
1662
+ fromVect: c,
1646
1663
  toVect: a,
1647
1664
  flipX: s,
1648
- flipY: c,
1665
+ flipY: d,
1649
1666
  arrowLength: this.arrowLength,
1650
1667
  arrowOffset: this.arrowOffset,
1651
1668
  roundness: this.roundness,
@@ -1653,127 +1670,127 @@ class It {
1653
1670
  detourDistance: this.detourDistance,
1654
1671
  hasSourceArrow: this.hasSourceArrow,
1655
1672
  hasTargetArrow: this.hasTargetArrow
1656
- }) : g = bt({
1673
+ }) : g = Ce({
1657
1674
  to: l,
1658
- fromVect: d,
1675
+ fromVect: c,
1659
1676
  toVect: a,
1660
- flipY: c,
1677
+ flipY: d,
1661
1678
  arrowLength: this.arrowLength,
1662
1679
  arrowOffset: this.arrowOffset,
1663
1680
  roundness: this.roundness,
1664
1681
  hasSourceArrow: this.hasSourceArrow,
1665
1682
  hasTargetArrow: this.hasTargetArrow
1666
1683
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1667
- const v = M(
1668
- d,
1684
+ const y = m(
1685
+ c,
1669
1686
  w,
1670
1687
  this.arrowLength,
1671
1688
  this.arrowWidth
1672
1689
  );
1673
- this.sourceArrow.setAttribute("d", v);
1690
+ this.sourceArrow.setAttribute("d", y);
1674
1691
  }
1675
1692
  if (this.targetArrow) {
1676
- const v = M(
1677
- y,
1693
+ const y = m(
1694
+ f,
1678
1695
  l,
1679
1696
  x,
1680
1697
  this.arrowWidth
1681
1698
  );
1682
- this.targetArrow.setAttribute("d", v);
1699
+ this.targetArrow.setAttribute("d", y);
1683
1700
  }
1684
1701
  }
1685
1702
  }
1686
- const Ft = (e) => {
1687
- if (typeof e == "function")
1688
- return e;
1689
- switch (e == null ? void 0 : e.type) {
1703
+ const Ie = (t) => {
1704
+ if (typeof t == "function")
1705
+ return t;
1706
+ switch (t == null ? void 0 : t.type) {
1690
1707
  case "straight":
1691
- return () => new Wt({
1692
- color: e.color,
1693
- width: e.width,
1694
- arrowLength: e.arrowLength,
1695
- arrowWidth: e.arrowWidth,
1696
- arrowOffset: e.arrowOffset,
1697
- hasSourceArrow: e.hasSourceArrow,
1698
- hasTargetArrow: e.hasTargetArrow,
1699
- cycleSquareSide: e.cycleSquareSide,
1700
- roundness: e.roundness,
1701
- detourDistance: e.detourDistance,
1702
- detourDirection: e.detourDirection
1708
+ return () => new We({
1709
+ color: t.color,
1710
+ width: t.width,
1711
+ arrowLength: t.arrowLength,
1712
+ arrowWidth: t.arrowWidth,
1713
+ arrowOffset: t.arrowOffset,
1714
+ hasSourceArrow: t.hasSourceArrow,
1715
+ hasTargetArrow: t.hasTargetArrow,
1716
+ cycleSquareSide: t.cycleSquareSide,
1717
+ roundness: t.roundness,
1718
+ detourDistance: t.detourDistance,
1719
+ detourDirection: t.detourDirection
1703
1720
  });
1704
1721
  case "horizontal":
1705
- return () => new $t({
1706
- color: e.color,
1707
- width: e.width,
1708
- arrowLength: e.arrowLength,
1709
- arrowWidth: e.arrowWidth,
1710
- arrowOffset: e.arrowOffset,
1711
- hasSourceArrow: e.hasSourceArrow,
1712
- hasTargetArrow: e.hasTargetArrow,
1713
- cycleSquareSide: e.cycleSquareSide,
1714
- roundness: e.roundness,
1715
- detourDistance: e.detourDistance,
1716
- detourDirection: e.detourDirection
1722
+ return () => new $e({
1723
+ color: t.color,
1724
+ width: t.width,
1725
+ arrowLength: t.arrowLength,
1726
+ arrowWidth: t.arrowWidth,
1727
+ arrowOffset: t.arrowOffset,
1728
+ hasSourceArrow: t.hasSourceArrow,
1729
+ hasTargetArrow: t.hasTargetArrow,
1730
+ cycleSquareSide: t.cycleSquareSide,
1731
+ roundness: t.roundness,
1732
+ detourDistance: t.detourDistance,
1733
+ detourDirection: t.detourDirection
1717
1734
  });
1718
1735
  case "vertical":
1719
- return () => new It({
1720
- color: e.color,
1721
- width: e.width,
1722
- arrowLength: e.arrowLength,
1723
- arrowWidth: e.arrowWidth,
1724
- arrowOffset: e.arrowOffset,
1725
- hasSourceArrow: e.hasSourceArrow,
1726
- hasTargetArrow: e.hasTargetArrow,
1727
- cycleSquareSide: e.cycleSquareSide,
1728
- roundness: e.roundness,
1729
- detourDistance: e.detourDistance,
1730
- detourDirection: e.detourDirection
1736
+ return () => new Re({
1737
+ color: t.color,
1738
+ width: t.width,
1739
+ arrowLength: t.arrowLength,
1740
+ arrowWidth: t.arrowWidth,
1741
+ arrowOffset: t.arrowOffset,
1742
+ hasSourceArrow: t.hasSourceArrow,
1743
+ hasTargetArrow: t.hasTargetArrow,
1744
+ cycleSquareSide: t.cycleSquareSide,
1745
+ roundness: t.roundness,
1746
+ detourDistance: t.detourDistance,
1747
+ detourDirection: t.detourDirection
1731
1748
  });
1732
1749
  default:
1733
- return () => new Ct({
1734
- color: e.color,
1735
- width: e.width,
1736
- arrowLength: e.arrowLength,
1737
- arrowWidth: e.arrowWidth,
1738
- hasSourceArrow: e.hasSourceArrow,
1739
- hasTargetArrow: e.hasTargetArrow,
1740
- cycleRadius: e.cycleRadius,
1741
- smallCycleRadius: e.smallCycleRadius,
1742
- curvature: e.curvature,
1743
- detourDistance: e.detourDistance,
1744
- detourDirection: e.detourDirection
1750
+ return () => new be({
1751
+ color: t.color,
1752
+ width: t.width,
1753
+ arrowLength: t.arrowLength,
1754
+ arrowWidth: t.arrowWidth,
1755
+ hasSourceArrow: t.hasSourceArrow,
1756
+ hasTargetArrow: t.hasTargetArrow,
1757
+ cycleRadius: t.cycleRadius,
1758
+ smallCycleRadius: t.smallCycleRadius,
1759
+ curvature: t.curvature,
1760
+ detourDistance: t.detourDistance,
1761
+ detourDirection: t.detourDirection
1745
1762
  });
1746
1763
  }
1747
- }, Rt = (e) => {
1764
+ }, Fe = (t) => {
1748
1765
  var o, r, n, h, s;
1749
- const t = Nt(
1750
- (o = e == null ? void 0 : e.nodes) == null ? void 0 : o.priority,
1751
- (r = e == null ? void 0 : e.edges) == null ? void 0 : r.priority
1766
+ const e = me(
1767
+ (o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
1768
+ (r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
1752
1769
  );
1753
1770
  return {
1754
1771
  nodes: {
1755
- centerFn: ((n = e == null ? void 0 : e.nodes) == null ? void 0 : n.centerFn) ?? pt,
1756
- priorityFn: t.nodesPriorityFn
1772
+ centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? Te,
1773
+ priorityFn: e.nodesPriorityFn
1757
1774
  },
1758
1775
  ports: {
1759
- direction: ((h = e == null ? void 0 : e.ports) == null ? void 0 : h.direction) ?? 0
1776
+ direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
1760
1777
  },
1761
1778
  edges: {
1762
- shapeFactory: Ft(((s = e == null ? void 0 : e.edges) == null ? void 0 : s.shape) ?? {}),
1763
- priorityFn: t.edgesPriorityFn
1779
+ shapeFactory: Ie(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
1780
+ priorityFn: e.edgesPriorityFn
1764
1781
  }
1765
1782
  };
1766
1783
  };
1767
- class kt {
1768
- constructor(t, o) {
1769
- i(this, "nodeIdGenerator", new Y(
1770
- (t) => this.graph.getNode(t) !== null
1784
+ class Ue {
1785
+ constructor(e, o) {
1786
+ i(this, "nodeIdGenerator", new z(
1787
+ (e) => this.graph.getNode(e) !== null
1771
1788
  ));
1772
- i(this, "portIdGenerator", new Y(
1773
- (t) => this.graph.getPort(t) !== null
1789
+ i(this, "portIdGenerator", new z(
1790
+ (e) => this.graph.getPort(e) !== null
1774
1791
  ));
1775
- i(this, "edgeIdGenerator", new Y(
1776
- (t) => this.graph.getEdge(t) !== null
1792
+ i(this, "edgeIdGenerator", new z(
1793
+ (e) => this.graph.getEdge(e) !== null
1777
1794
  ));
1778
1795
  i(this, "defaults");
1779
1796
  /**
@@ -1784,14 +1801,14 @@ class kt {
1784
1801
  * provides api for accessing viewport state
1785
1802
  */
1786
1803
  i(this, "viewport");
1787
- this.controller = t, this.defaults = Rt(o), this.graph = t.graph, this.viewport = t.viewport;
1804
+ this.controller = e, this.defaults = Fe(o), this.graph = e.graph, this.viewport = e.viewport;
1788
1805
  }
1789
1806
  /**
1790
1807
  * attaches canvas to given element
1791
1808
  * detaches element first when canvas is attached
1792
1809
  */
1793
- attach(t) {
1794
- return this.controller.attach(t), this;
1810
+ attach(e) {
1811
+ return this.controller.attach(e), this;
1795
1812
  }
1796
1813
  /**
1797
1814
  * detaches canvas from element when attached
@@ -1802,19 +1819,19 @@ class kt {
1802
1819
  /**
1803
1820
  * adds node to graph
1804
1821
  */
1805
- addNode(t) {
1806
- const o = this.nodeIdGenerator.create(t.id);
1822
+ addNode(e) {
1823
+ const o = this.nodeIdGenerator.create(e.id);
1807
1824
  if (this.graph.getNode(o) !== null)
1808
- throw new E("failed to add node with existing id");
1825
+ throw new A("failed to add node with existing id");
1809
1826
  if (this.controller.addNode({
1810
1827
  id: o,
1811
- element: t.element,
1812
- x: t.x,
1813
- y: t.y,
1814
- centerFn: t.centerFn ?? this.defaults.nodes.centerFn,
1815
- priority: t.priority ?? this.defaults.nodes.priorityFn()
1816
- }), t.ports !== void 0)
1817
- for (const r of t.ports)
1828
+ element: e.element,
1829
+ x: e.x,
1830
+ y: e.y,
1831
+ centerFn: e.centerFn ?? this.defaults.nodes.centerFn,
1832
+ priority: e.priority ?? this.defaults.nodes.priorityFn()
1833
+ }), e.ports !== void 0)
1834
+ for (const r of e.ports)
1818
1835
  this.markPort({
1819
1836
  id: r.id,
1820
1837
  element: r.element,
@@ -1826,100 +1843,100 @@ class kt {
1826
1843
  /**
1827
1844
  * updates node parameters
1828
1845
  */
1829
- updateNode(t, o) {
1830
- if (this.graph.getNode(t) === null)
1831
- throw new E("failed to update nonexisting node");
1832
- return this.controller.updateNode(t, o ?? {}), this;
1846
+ updateNode(e, o) {
1847
+ if (this.graph.getNode(e) === null)
1848
+ throw new A("failed to update nonexisting node");
1849
+ return this.controller.updateNode(e, o ?? {}), this;
1833
1850
  }
1834
1851
  /**
1835
1852
  * removes node from graph
1836
1853
  * all the ports of node get unmarked
1837
1854
  * all the edges adjacent to node get removed
1838
1855
  */
1839
- removeNode(t) {
1840
- if (this.graph.getNode(t) === null)
1841
- throw new E("failed to remove nonexisting node");
1842
- return this.controller.removeNode(t), this;
1856
+ removeNode(e) {
1857
+ if (this.graph.getNode(e) === null)
1858
+ throw new A("failed to remove nonexisting node");
1859
+ return this.controller.removeNode(e), this;
1843
1860
  }
1844
1861
  /**
1845
1862
  * marks element as port of node
1846
1863
  */
1847
- markPort(t) {
1848
- const o = this.portIdGenerator.create(t.id);
1864
+ markPort(e) {
1865
+ const o = this.portIdGenerator.create(e.id);
1849
1866
  if (this.graph.getPort(o) !== null)
1850
- throw new E("failed to add port with existing id");
1851
- if (this.graph.getNode(t.nodeId) === null)
1852
- throw new E("failed to set port on nonexisting node");
1867
+ throw new A("failed to add port with existing id");
1868
+ if (this.graph.getNode(e.nodeId) === null)
1869
+ throw new A("failed to set port on nonexisting node");
1853
1870
  return this.controller.markPort({
1854
1871
  id: o,
1855
- element: t.element,
1856
- nodeId: t.nodeId,
1857
- direction: t.direction ?? this.defaults.ports.direction
1872
+ element: e.element,
1873
+ nodeId: e.nodeId,
1874
+ direction: e.direction ?? this.defaults.ports.direction
1858
1875
  }), this;
1859
1876
  }
1860
1877
  /**
1861
1878
  * updates port and attached edges
1862
1879
  */
1863
- updatePort(t, o) {
1864
- if (this.graph.getPort(t) === null)
1865
- throw new E("failed to unset nonexisting port");
1866
- return this.controller.updatePort(t, o ?? {}), this;
1880
+ updatePort(e, o) {
1881
+ if (this.graph.getPort(e) === null)
1882
+ throw new A("failed to unset nonexisting port");
1883
+ return this.controller.updatePort(e, o ?? {}), this;
1867
1884
  }
1868
1885
  /**
1869
1886
  * ummarks element as port of node
1870
1887
  * all the edges adjacent to port get removed
1871
1888
  */
1872
- unmarkPort(t) {
1873
- if (this.graph.getPort(t) === null)
1874
- throw new E("failed to unset nonexisting port");
1875
- return this.controller.unmarkPort(t), this;
1889
+ unmarkPort(e) {
1890
+ if (this.graph.getPort(e) === null)
1891
+ throw new A("failed to unset nonexisting port");
1892
+ return this.controller.unmarkPort(e), this;
1876
1893
  }
1877
1894
  /**
1878
1895
  * adds edge to graph
1879
1896
  */
1880
- addEdge(t) {
1881
- const o = this.edgeIdGenerator.create(t.id);
1897
+ addEdge(e) {
1898
+ const o = this.edgeIdGenerator.create(e.id);
1882
1899
  if (this.graph.getEdge(o) !== null)
1883
- throw new E("failed to add edge with existing id");
1884
- if (this.graph.getPort(t.from) === null)
1885
- throw new E("failed to add edge from nonexisting port");
1886
- if (this.graph.getPort(t.to) === null)
1887
- throw new E("failed to add edge to nonexisting port");
1900
+ throw new A("failed to add edge with existing id");
1901
+ if (this.graph.getPort(e.from) === null)
1902
+ throw new A("failed to add edge from nonexisting port");
1903
+ if (this.graph.getPort(e.to) === null)
1904
+ throw new A("failed to add edge to nonexisting port");
1888
1905
  return this.controller.addEdge({
1889
1906
  id: o,
1890
- from: t.from,
1891
- to: t.to,
1892
- shape: t.shape ?? this.defaults.edges.shapeFactory(),
1893
- priority: t.priority ?? this.defaults.edges.priorityFn()
1907
+ from: e.from,
1908
+ to: e.to,
1909
+ shape: e.shape ?? this.defaults.edges.shapeFactory(),
1910
+ priority: e.priority ?? this.defaults.edges.priorityFn()
1894
1911
  }), this;
1895
1912
  }
1896
1913
  /**
1897
1914
  * updates edge
1898
1915
  */
1899
- updateEdge(t, o) {
1900
- if (this.graph.getEdge(t) === null)
1901
- throw new E("failed to update nonexisting edge");
1902
- return this.controller.updateEdge(t, o ?? {}), this;
1916
+ updateEdge(e, o) {
1917
+ if (this.graph.getEdge(e) === null)
1918
+ throw new A("failed to update nonexisting edge");
1919
+ return this.controller.updateEdge(e, o ?? {}), this;
1903
1920
  }
1904
1921
  /**
1905
1922
  * removes edge from graph
1906
1923
  */
1907
- removeEdge(t) {
1908
- if (this.graph.getEdge(t) === null)
1909
- throw new E("failed to remove nonexisting edge");
1910
- return this.controller.removeEdge(t), this;
1924
+ removeEdge(e) {
1925
+ if (this.graph.getEdge(e) === null)
1926
+ throw new A("failed to remove nonexisting edge");
1927
+ return this.controller.removeEdge(e), this;
1911
1928
  }
1912
1929
  /**
1913
1930
  * applies transformation for viewport
1914
1931
  */
1915
- patchViewportMatrix(t) {
1916
- return this.controller.patchViewportMatrix(t), this;
1932
+ patchViewportMatrix(e) {
1933
+ return this.controller.patchViewportMatrix(e), this;
1917
1934
  }
1918
1935
  /**
1919
1936
  * applies transformation for content
1920
1937
  */
1921
- patchContentMatrix(t) {
1922
- return this.controller.patchContentMatrix(t), this;
1938
+ patchContentMatrix(e) {
1939
+ return this.controller.patchContentMatrix(e), this;
1923
1940
  }
1924
1941
  /**
1925
1942
  * clears canvas from nodes and edges
@@ -1936,7 +1953,7 @@ class kt {
1936
1953
  this.controller.destroy();
1937
1954
  }
1938
1955
  }
1939
- class zt {
1956
+ class Be {
1940
1957
  constructor() {
1941
1958
  i(this, "nodes", /* @__PURE__ */ new Map());
1942
1959
  i(this, "ports", /* @__PURE__ */ new Map());
@@ -1944,151 +1961,203 @@ class zt {
1944
1961
  i(this, "incommingEdges", /* @__PURE__ */ new Map());
1945
1962
  i(this, "outcommingEdges", /* @__PURE__ */ new Map());
1946
1963
  i(this, "cycleEdges", /* @__PURE__ */ new Map());
1947
- }
1948
- addNode(t) {
1964
+ i(this, "onAfterNodeAddedEmitter");
1965
+ i(this, "onAfterNodeAdded");
1966
+ i(this, "onAfterNodeCoordinatesUpdatedEmitter");
1967
+ i(this, "onAfterNodeCoordinatesUpdated");
1968
+ i(this, "onAfterNodePriorityUpdatedEmitter");
1969
+ i(this, "onAfterNodePriorityUpdated");
1970
+ i(this, "onBeforeNodeRemovedEmitter");
1971
+ i(this, "onBeforeNodeRemoved");
1972
+ i(this, "onAfterPortAddedEmitter");
1973
+ i(this, "onAfterPortAdded");
1974
+ i(this, "onAfterPortDirectionUpdatedEmitter");
1975
+ i(this, "onAfterPortDirectionUpdated");
1976
+ i(this, "onBeforePortRemovedEmitter");
1977
+ i(this, "onBeforePortRemoved");
1978
+ i(this, "onAfterEdgeAddedEmitter");
1979
+ i(this, "onAfterEdgeAdded");
1980
+ i(this, "onAfterEdgeShapeUpdatedEmitter");
1981
+ i(this, "onAfterEdgeShapeUpdated");
1982
+ i(this, "onAfterEdgeAdjacentPortsUpdatedEmitter");
1983
+ i(this, "onAfterEdgeAdjacentPortsUpdated");
1984
+ i(this, "onAfterEdgePriorityUpdatedEmitter");
1985
+ i(this, "onAfterEdgePriorityUpdated");
1986
+ i(this, "onBeforeEdgeRemovedEmitter");
1987
+ i(this, "onBeforeEdgeRemoved");
1988
+ i(this, "onBeforeClearEmitter");
1989
+ i(this, "onBeforeClear");
1990
+ [this.onAfterNodeAddedEmitter, this.onAfterNodeAdded] = E(), [
1991
+ this.onAfterNodeCoordinatesUpdatedEmitter,
1992
+ this.onAfterNodeCoordinatesUpdated
1993
+ ] = E(), [this.onAfterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = E(), [this.onBeforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = E(), [this.onAfterPortAddedEmitter, this.onAfterPortAdded] = E(), [
1994
+ this.onAfterPortDirectionUpdatedEmitter,
1995
+ this.onAfterPortDirectionUpdated
1996
+ ] = E(), [this.onBeforePortRemovedEmitter, this.onBeforePortRemoved] = E(), [this.onAfterEdgeAddedEmitter, this.onAfterEdgeAdded] = E(), [this.onAfterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = E(), [
1997
+ this.onAfterEdgeAdjacentPortsUpdatedEmitter,
1998
+ this.onAfterEdgeAdjacentPortsUpdated
1999
+ ] = E(), [this.onAfterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = E(), [this.onBeforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = E(), [this.onBeforeClearEmitter, this.onBeforeClear] = E();
2000
+ }
2001
+ addNode(e) {
1949
2002
  const o = /* @__PURE__ */ new Map(), r = {
1950
- element: t.element,
1951
- x: t.x,
1952
- y: t.y,
1953
- centerFn: t.centerFn,
1954
- priority: t.priority,
2003
+ element: e.element,
2004
+ x: e.x,
2005
+ y: e.y,
2006
+ centerFn: e.centerFn,
2007
+ priority: e.priority,
1955
2008
  ports: o
1956
2009
  };
1957
- this.nodes.set(t.id, r);
2010
+ this.nodes.set(e.id, r), this.onAfterNodeAddedEmitter.emit(e.id);
1958
2011
  }
1959
2012
  getAllNodeIds() {
1960
2013
  return Array.from(this.nodes.keys());
1961
2014
  }
1962
- getNode(t) {
1963
- return this.nodes.get(t);
2015
+ getNode(e) {
2016
+ return this.nodes.get(e);
2017
+ }
2018
+ updateNodeCoordinates(e, o) {
2019
+ const r = this.nodes.get(e);
2020
+ r.x = (o == null ? void 0 : o.x) ?? r.x, r.y = (o == null ? void 0 : o.y) ?? r.y, r.centerFn = o.centerFn ?? r.centerFn, this.onAfterNodeCoordinatesUpdatedEmitter.emit(e);
2021
+ }
2022
+ updateNodePriority(e, o) {
2023
+ const r = this.nodes.get(e);
2024
+ r.priority = o, this.onAfterNodePriorityUpdatedEmitter.emit(e);
1964
2025
  }
1965
- removeNode(t) {
1966
- this.nodes.delete(t);
2026
+ removeNode(e) {
2027
+ this.onBeforeNodeRemovedEmitter.emit(e), this.nodes.delete(e);
1967
2028
  }
1968
- addPort(t) {
1969
- this.ports.set(t.id, {
1970
- element: t.element,
1971
- direction: t.direction,
1972
- nodeId: t.nodeId
1973
- }), this.cycleEdges.set(t.id, /* @__PURE__ */ new Set()), this.incommingEdges.set(t.id, /* @__PURE__ */ new Set()), this.outcommingEdges.set(t.id, /* @__PURE__ */ new Set()), this.nodes.get(t.nodeId).ports.set(t.id, t.element);
2029
+ addPort(e) {
2030
+ this.ports.set(e.id, {
2031
+ element: e.element,
2032
+ direction: e.direction,
2033
+ nodeId: e.nodeId
2034
+ }), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.onAfterPortAddedEmitter.emit(e.id);
1974
2035
  }
1975
- getPort(t) {
1976
- return this.ports.get(t);
2036
+ getPort(e) {
2037
+ return this.ports.get(e);
2038
+ }
2039
+ updatePortDirection(e, o) {
2040
+ const r = this.ports.get(e);
2041
+ r.direction = o, this.onAfterPortDirectionUpdatedEmitter.emit(e);
1977
2042
  }
1978
2043
  getAllPortIds() {
1979
2044
  return Array.from(this.ports.keys());
1980
2045
  }
1981
- getNodePortIds(t) {
1982
- const o = this.nodes.get(t);
2046
+ getNodePortIds(e) {
2047
+ const o = this.nodes.get(e);
1983
2048
  if (o !== void 0)
1984
2049
  return Array.from(o.ports.keys());
1985
2050
  }
1986
- removePort(t) {
1987
- const o = this.ports.get(t).nodeId;
1988
- this.nodes.get(o).ports.delete(t), this.ports.delete(t);
1989
- }
1990
- addEdge(t) {
1991
- this.edges.set(t.id, {
1992
- from: t.from,
1993
- to: t.to,
1994
- shape: t.shape,
1995
- priority: t.priority
1996
- }), t.from !== t.to ? (this.outcommingEdges.get(t.from).add(t.id), this.incommingEdges.get(t.to).add(t.id)) : this.cycleEdges.get(t.from).add(t.id);
1997
- }
1998
- updateEdgeFrom(t, o) {
1999
- const r = this.edges.get(t);
2000
- this.removeEdge(t), this.addEdge({
2001
- id: t,
2002
- from: o,
2003
- to: r.to,
2004
- shape: r.shape,
2005
- priority: r.priority
2006
- });
2051
+ removePort(e) {
2052
+ const o = this.ports.get(e).nodeId;
2053
+ this.onBeforePortRemovedEmitter.emit(e), this.nodes.get(o).ports.delete(e), this.ports.delete(e);
2054
+ }
2055
+ addEdge(e) {
2056
+ this.addEdgeInternal(e), this.onAfterEdgeAddedEmitter.emit(e.id);
2007
2057
  }
2008
- updateEdgeTo(t, o) {
2009
- const r = this.edges.get(t);
2010
- this.removeEdge(t), this.addEdge({
2011
- id: t,
2012
- from: r.from,
2013
- to: o,
2058
+ updateEdgeShape(e, o) {
2059
+ const r = this.edges.get(e);
2060
+ r.shape = o, this.onAfterEdgeShapeUpdatedEmitter.emit(e);
2061
+ }
2062
+ updateEdgeAdjacentPorts(e, o) {
2063
+ const r = this.edges.get(e);
2064
+ this.removeEdgeInternal(e), this.addEdgeInternal({
2065
+ id: e,
2066
+ from: o.from ?? r.from,
2067
+ to: o.to ?? r.to,
2014
2068
  shape: r.shape,
2015
2069
  priority: r.priority
2016
- });
2070
+ }), this.onAfterEdgeAdjacentPortsUpdatedEmitter.emit(e);
2071
+ }
2072
+ updateEdgePriority(e, o) {
2073
+ const r = this.edges.get(e);
2074
+ r.priority = o, this.onAfterEdgePriorityUpdatedEmitter.emit(e);
2017
2075
  }
2018
2076
  getAllEdgeIds() {
2019
2077
  return Array.from(this.edges.keys());
2020
2078
  }
2021
- getEdge(t) {
2022
- return this.edges.get(t);
2079
+ getEdge(e) {
2080
+ return this.edges.get(e);
2023
2081
  }
2024
- removeEdge(t) {
2025
- const o = this.edges.get(t), r = o.from, n = o.to;
2026
- this.cycleEdges.get(r).delete(t), this.cycleEdges.get(n).delete(t), this.incommingEdges.get(r).delete(t), this.incommingEdges.get(n).delete(t), this.outcommingEdges.get(r).delete(t), this.outcommingEdges.get(n).delete(t), this.edges.delete(t);
2082
+ removeEdge(e) {
2083
+ this.onBeforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
2027
2084
  }
2028
2085
  clear() {
2029
- this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
2086
+ this.onBeforeClearEmitter.emit(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
2030
2087
  }
2031
- getPortIncomingEdgeIds(t) {
2032
- return Array.from(this.incommingEdges.get(t));
2088
+ getPortIncomingEdgeIds(e) {
2089
+ return Array.from(this.incommingEdges.get(e));
2033
2090
  }
2034
- getPortOutcomingEdgeIds(t) {
2035
- return Array.from(this.outcommingEdges.get(t));
2091
+ getPortOutcomingEdgeIds(e) {
2092
+ return Array.from(this.outcommingEdges.get(e));
2036
2093
  }
2037
- getPortCycleEdgeIds(t) {
2038
- return Array.from(this.cycleEdges.get(t));
2094
+ getPortCycleEdgeIds(e) {
2095
+ return Array.from(this.cycleEdges.get(e));
2039
2096
  }
2040
- getPortAdjacentEdgeIds(t) {
2097
+ getPortAdjacentEdgeIds(e) {
2041
2098
  return [
2042
- ...this.getPortIncomingEdgeIds(t),
2043
- ...this.getPortOutcomingEdgeIds(t),
2044
- ...this.getPortCycleEdgeIds(t)
2099
+ ...this.getPortIncomingEdgeIds(e),
2100
+ ...this.getPortOutcomingEdgeIds(e),
2101
+ ...this.getPortCycleEdgeIds(e)
2045
2102
  ];
2046
2103
  }
2047
- getNodeIncomingEdgeIds(t) {
2048
- const o = Array.from(this.nodes.get(t).ports.keys());
2104
+ getNodeIncomingEdgeIds(e) {
2105
+ const o = Array.from(this.nodes.get(e).ports.keys());
2049
2106
  let r = [];
2050
2107
  return o.forEach((n) => {
2051
2108
  r = [...r, ...this.getPortIncomingEdgeIds(n)];
2052
2109
  }), r;
2053
2110
  }
2054
- getNodeOutcomingEdgeIds(t) {
2055
- const o = Array.from(this.nodes.get(t).ports.keys());
2111
+ getNodeOutcomingEdgeIds(e) {
2112
+ const o = Array.from(this.nodes.get(e).ports.keys());
2056
2113
  let r = [];
2057
2114
  return o.forEach((n) => {
2058
2115
  r = [...r, ...this.getPortOutcomingEdgeIds(n)];
2059
2116
  }), r;
2060
2117
  }
2061
- getNodeCycleEdgeIds(t) {
2062
- const o = Array.from(this.nodes.get(t).ports.keys());
2118
+ getNodeCycleEdgeIds(e) {
2119
+ const o = Array.from(this.nodes.get(e).ports.keys());
2063
2120
  let r = [];
2064
2121
  return o.forEach((n) => {
2065
2122
  r = [...r, ...this.getPortCycleEdgeIds(n)];
2066
2123
  }), r;
2067
2124
  }
2068
- getNodeAdjacentEdgeIds(t) {
2125
+ getNodeAdjacentEdgeIds(e) {
2069
2126
  return [
2070
- ...this.getNodeIncomingEdgeIds(t),
2071
- ...this.getNodeOutcomingEdgeIds(t),
2072
- ...this.getNodeCycleEdgeIds(t)
2127
+ ...this.getNodeIncomingEdgeIds(e),
2128
+ ...this.getNodeOutcomingEdgeIds(e),
2129
+ ...this.getNodeCycleEdgeIds(e)
2073
2130
  ];
2074
2131
  }
2132
+ addEdgeInternal(e) {
2133
+ this.edges.set(e.id, {
2134
+ from: e.from,
2135
+ to: e.to,
2136
+ shape: e.shape,
2137
+ priority: e.priority
2138
+ }), e.from !== e.to ? (this.outcommingEdges.get(e.from).add(e.id), this.incommingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
2139
+ }
2140
+ removeEdgeInternal(e) {
2141
+ const o = this.edges.get(e), r = o.from, n = o.to;
2142
+ this.cycleEdges.get(r).delete(e), this.cycleEdges.get(n).delete(e), this.incommingEdges.get(r).delete(e), this.incommingEdges.get(n).delete(e), this.outcommingEdges.get(r).delete(e), this.outcommingEdges.get(n).delete(e), this.edges.delete(e);
2143
+ }
2075
2144
  }
2076
- const Q = (e) => ({
2077
- scale: 1 / e.scale,
2078
- x: -e.x / e.scale,
2079
- y: -e.y / e.scale
2080
- }), Z = {
2145
+ const Z = (t) => ({
2146
+ scale: 1 / t.scale,
2147
+ x: -t.x / t.scale,
2148
+ y: -t.y / t.scale
2149
+ }), O = {
2081
2150
  scale: 1,
2082
2151
  x: 0,
2083
2152
  y: 0
2084
2153
  };
2085
- class Yt {
2154
+ class ke {
2086
2155
  constructor() {
2087
- i(this, "viewportMatrix", Z);
2088
- i(this, "contentMatrix", Z);
2156
+ i(this, "viewportMatrix", O);
2157
+ i(this, "contentMatrix", O);
2089
2158
  i(this, "emitter");
2090
2159
  i(this, "onAfterUpdate");
2091
- [this.emitter, this.onAfterUpdate] = Tt();
2160
+ [this.emitter, this.onAfterUpdate] = E();
2092
2161
  }
2093
2162
  getViewportMatrix() {
2094
2163
  return this.viewportMatrix;
@@ -2096,22 +2165,22 @@ class Yt {
2096
2165
  getContentMatrix() {
2097
2166
  return this.contentMatrix;
2098
2167
  }
2099
- patchViewportMatrix(t) {
2168
+ patchViewportMatrix(e) {
2100
2169
  this.viewportMatrix = {
2101
- scale: t.scale ?? this.viewportMatrix.scale,
2102
- x: t.x ?? this.viewportMatrix.x,
2103
- y: t.y ?? this.viewportMatrix.y
2104
- }, this.contentMatrix = Q(this.viewportMatrix), this.emitter.emit();
2170
+ scale: e.scale ?? this.viewportMatrix.scale,
2171
+ x: e.x ?? this.viewportMatrix.x,
2172
+ y: e.y ?? this.viewportMatrix.y
2173
+ }, this.contentMatrix = Z(this.viewportMatrix), this.emitter.emit();
2105
2174
  }
2106
- patchContentMatrix(t) {
2175
+ patchContentMatrix(e) {
2107
2176
  this.contentMatrix = {
2108
- scale: t.scale ?? this.contentMatrix.scale,
2109
- x: t.x ?? this.contentMatrix.x,
2110
- y: t.y ?? this.contentMatrix.y
2111
- }, this.viewportMatrix = Q(this.contentMatrix), this.emitter.emit();
2177
+ scale: e.scale ?? this.contentMatrix.scale,
2178
+ x: e.x ?? this.contentMatrix.x,
2179
+ y: e.y ?? this.contentMatrix.y
2180
+ }, this.viewportMatrix = Z(this.contentMatrix), this.emitter.emit();
2112
2181
  }
2113
2182
  }
2114
- class Bt {
2183
+ class Ye {
2115
2184
  constructor() {
2116
2185
  i(this, "canvasDefaults", {});
2117
2186
  i(this, "dragOptions");
@@ -2125,27 +2194,27 @@ class Bt {
2125
2194
  /**
2126
2195
  * specifies default values for graph entities
2127
2196
  */
2128
- setDefaults(t) {
2129
- return this.canvasDefaults = t, this;
2197
+ setDefaults(e) {
2198
+ return this.canvasDefaults = e, this;
2130
2199
  }
2131
2200
  /**
2132
2201
  * @deprecated
2133
2202
  * use setDefaults instead
2134
2203
  */
2135
- setOptions(t) {
2136
- return this.setDefaults(t), this;
2204
+ setOptions(e) {
2205
+ return this.setDefaults(e), this;
2137
2206
  }
2138
2207
  /**
2139
2208
  * enables nodes draggable by user
2140
2209
  */
2141
- enableUserDraggableNodes(t) {
2142
- return this.hasDraggableNode = !0, this.dragOptions = t, this;
2210
+ enableUserDraggableNodes(e) {
2211
+ return this.hasDraggableNode = !0, this.dragOptions = e, this;
2143
2212
  }
2144
2213
  /**
2145
2214
  * enables viewport transformable by user
2146
2215
  */
2147
- enableUserTransformableViewport(t) {
2148
- return this.hasTransformableViewport = !0, this.transformOptions = t, this;
2216
+ enableUserTransformableViewport(e) {
2217
+ return this.hasTransformableViewport = !0, this.transformOptions = e, this;
2149
2218
  }
2150
2219
  /**
2151
2220
  * enables automatic edges update on node resize
@@ -2156,39 +2225,39 @@ class Bt {
2156
2225
  /**
2157
2226
  * sets emitter for rendering graph inside bounded area
2158
2227
  */
2159
- enableBoxAreaRendering(t) {
2160
- return this.boxRenderingTrigger = t, this;
2228
+ enableBoxAreaRendering(e) {
2229
+ return this.boxRenderingTrigger = e, this;
2161
2230
  }
2162
- enableVirtualScroll(t) {
2163
- return this.virtualScrollOptions = t, this;
2231
+ enableVirtualScroll(e) {
2232
+ return this.virtualScrollOptions = e, this;
2164
2233
  }
2165
2234
  /**
2166
2235
  * builds final canvas
2167
2236
  */
2168
2237
  build() {
2169
- let t = this.boxRenderingTrigger;
2170
- this.virtualScrollOptions !== void 0 && t === void 0 && (t = new q());
2171
- const o = new zt(), r = new Yt();
2172
- let n = new Et(o, r);
2173
- t !== void 0 && (n = new At(n, o, t));
2174
- let h = new it(
2238
+ let e = this.boxRenderingTrigger;
2239
+ this.virtualScrollOptions !== void 0 && e === void 0 && (e = new ee());
2240
+ const o = new Be(), r = new ke();
2241
+ let n = new Ae(o, r);
2242
+ e !== void 0 && (n = new Se(n, o, e));
2243
+ let h = new se(
2175
2244
  o,
2176
2245
  r,
2177
2246
  n
2178
2247
  );
2179
- this.hasResizeReactiveNodes && (h = new wt(h)), this.hasDraggableNode && (h = new nt(
2248
+ this.hasResizeReactiveNodes && (h = new fe(h)), this.hasDraggableNode && (h = new he(
2180
2249
  h,
2181
2250
  this.dragOptions
2182
- )), this.virtualScrollOptions !== void 0 ? h = new yt(
2251
+ )), this.virtualScrollOptions !== void 0 ? h = new ye(
2183
2252
  h,
2184
- t,
2253
+ e,
2185
2254
  this.transformOptions,
2186
2255
  this.virtualScrollOptions
2187
- ) : this.hasTransformableViewport && (h = new O(
2256
+ ) : this.hasTransformableViewport && (h = new q(
2188
2257
  h,
2189
2258
  this.transformOptions
2190
2259
  ));
2191
- const s = new kt(h, this.canvasDefaults);
2260
+ const s = new Ue(h, this.canvasDefaults);
2192
2261
  return this.reset(), s;
2193
2262
  }
2194
2263
  reset() {
@@ -2196,11 +2265,11 @@ class Bt {
2196
2265
  }
2197
2266
  }
2198
2267
  export {
2199
- Ct as BezierEdgeShape,
2200
- Bt as CanvasBuilder,
2201
- q as EventSubject,
2202
- $t as HorizontalEdgeShape,
2203
- E as HtmlGraphError,
2204
- Wt as StraightEdgeShape,
2205
- It as VerticalEdgeShape
2268
+ be as BezierEdgeShape,
2269
+ Ye as CanvasBuilder,
2270
+ ee as EventSubject,
2271
+ $e as HorizontalEdgeShape,
2272
+ A as HtmlGraphError,
2273
+ We as StraightEdgeShape,
2274
+ Re as VerticalEdgeShape
2206
2275
  };