@html-graph/html-graph 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,47 @@
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 {
1
+ var oe = Object.defineProperty;
2
+ var re = (t, e, o) => e in t ? oe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var i = (t, e, o) => re(t, typeof e != "symbol" ? e + "" : e, o);
4
+ class ie {
5
5
  constructor(e) {
6
6
  i(this, "onAfterNodeAdded");
7
+ /**
8
+ * @deprecated
9
+ * use onAfterNodeUpdated instead
10
+ */
7
11
  i(this, "onAfterNodeCoordinatesUpdated");
12
+ i(this, "onAfterNodeUpdated");
8
13
  i(this, "onAfterNodePriorityUpdated");
9
14
  i(this, "onBeforeNodeRemoved");
15
+ i(this, "onAfterPortMarked");
16
+ /**
17
+ * @deprecated
18
+ * use onAfterPortMarked instead
19
+ */
10
20
  i(this, "onAfterPortAdded");
21
+ i(this, "onAfterPortUpdated");
22
+ /**
23
+ * @deprecated
24
+ * use onAfterPortUpdated instead
25
+ */
11
26
  i(this, "onAfterPortDirectionUpdated");
27
+ i(this, "onBeforePortUnmarked");
28
+ /**
29
+ * @deprecated
30
+ * use onBeforePortUnmarked instead
31
+ */
12
32
  i(this, "onBeforePortRemoved");
13
33
  i(this, "onAfterEdgeAdded");
14
34
  i(this, "onAfterEdgeShapeUpdated");
35
+ i(this, "onAfterEdgeUpdated");
36
+ /**
37
+ * @deprecated
38
+ * use onAfterEdgeUpdated instead
39
+ */
15
40
  i(this, "onAfterEdgeAdjacentPortsUpdated");
16
41
  i(this, "onAfterEdgePriorityUpdated");
17
42
  i(this, "onBeforeEdgeRemoved");
18
43
  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;
44
+ this.graphStore = e, this.onAfterNodeAdded = this.graphStore.onAfterNodeAdded, this.onAfterNodeUpdated = this.graphStore.onAfterNodeUpdated, this.onAfterNodeCoordinatesUpdated = this.onAfterNodeUpdated, this.onAfterNodePriorityUpdated = this.graphStore.onAfterNodePriorityUpdated, this.onBeforeNodeRemoved = this.graphStore.onBeforeNodeRemoved, this.onAfterPortMarked = this.graphStore.onAfterPortAdded, this.onAfterPortAdded = this.onAfterPortMarked, this.onAfterPortUpdated = this.graphStore.onAfterPortUpdated, this.onAfterPortDirectionUpdated = this.onAfterPortUpdated, this.onBeforePortUnmarked = this.graphStore.onBeforePortRemoved, this.onBeforePortRemoved = this.onBeforePortUnmarked, this.onAfterEdgeAdded = this.graphStore.onAfterEdgeAdded, this.onAfterEdgeShapeUpdated = this.graphStore.onAfterEdgeShapeUpdated, this.onAfterEdgeUpdated = this.graphStore.onAfterEdgeUpdated, this.onAfterEdgeAdjacentPortsUpdated = this.onAfterEdgeUpdated, this.onAfterEdgePriorityUpdated = this.graphStore.onAfterEdgePriorityUpdated, this.onBeforeEdgeRemoved = this.graphStore.onBeforeEdgeRemoved, this.onBeforeClear = this.graphStore.onBeforeClear;
20
45
  }
21
46
  getNode(e) {
22
47
  const o = this.graphStore.getNode(e);
@@ -85,9 +110,11 @@ class re {
85
110
  return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
86
111
  }
87
112
  }
88
- class ie {
113
+ class se {
89
114
  constructor(e) {
90
- this.transformer = e;
115
+ i(this, "onBeforeUpdated");
116
+ i(this, "onAfterUpdated");
117
+ this.transformer = e, this.onBeforeUpdated = this.transformer.onBeforeUpdated, this.onAfterUpdated = this.transformer.onAfterUpdated;
91
118
  }
92
119
  getViewportMatrix() {
93
120
  return { ...this.transformer.getViewportMatrix() };
@@ -96,11 +123,61 @@ class ie {
96
123
  return { ...this.transformer.getContentMatrix() };
97
124
  }
98
125
  }
99
- class se {
126
+ class ne {
100
127
  constructor(e, o, r) {
101
128
  i(this, "viewport");
102
129
  i(this, "graph");
103
- this.graphStore = e, this.viewportStore = o, this.htmlView = r, this.graph = new re(this.graphStore), this.viewport = new ie(this.viewportStore);
130
+ i(this, "onAfterNodeAdded", (e) => {
131
+ this.htmlView.attachNode(e);
132
+ });
133
+ i(this, "onAfterNodeUpdated", (e) => {
134
+ this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((r) => {
135
+ this.htmlView.renderEdge(r);
136
+ });
137
+ });
138
+ i(this, "onAfterNodePriorityUpdated", (e) => {
139
+ this.htmlView.updateNodePriority(e);
140
+ });
141
+ i(this, "onBeforeNodeRemoved", (e) => {
142
+ this.graphStore.getNodePortIds(e).forEach((o) => {
143
+ this.unmarkPort(o);
144
+ }), this.htmlView.detachNode(e);
145
+ });
146
+ i(this, "onAfterPortUpdated", (e) => {
147
+ this.graphStore.getPortAdjacentEdgeIds(e).forEach((r) => {
148
+ this.htmlView.renderEdge(r);
149
+ });
150
+ });
151
+ i(this, "onBeforePortUnmarked", (e) => {
152
+ this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
153
+ this.removeEdge(o);
154
+ });
155
+ });
156
+ i(this, "onAfterEdgeAdded", (e) => {
157
+ this.htmlView.attachEdge(e);
158
+ });
159
+ i(this, "onAfterEdgeShapeUpdated", (e) => {
160
+ this.htmlView.updateEdgeShape(e);
161
+ });
162
+ i(this, "onAfterEdgeUpdated", (e) => {
163
+ this.htmlView.renderEdge(e);
164
+ });
165
+ i(this, "onAfterEdgePriorityUpdated", (e) => {
166
+ this.htmlView.updateEdgePriority(e);
167
+ });
168
+ i(this, "onBeforeEdgeRemoved", (e) => {
169
+ this.htmlView.detachEdge(e);
170
+ });
171
+ i(this, "onBeforeClear", () => {
172
+ this.htmlView.clear();
173
+ });
174
+ this.graphStore = e, this.viewportStore = o, this.htmlView = r, this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
175
+ this.onAfterNodePriorityUpdated
176
+ ), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
177
+ this.onAfterEdgeShapeUpdated
178
+ ), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
179
+ this.onAfterEdgePriorityUpdated
180
+ ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), this.graph = new ie(this.graphStore), this.viewport = new se(this.viewportStore);
104
181
  }
105
182
  attach(e) {
106
183
  this.htmlView.attach(e);
@@ -109,46 +186,31 @@ class se {
109
186
  this.htmlView.detach();
110
187
  }
111
188
  addNode(e) {
112
- this.graphStore.addNode(e), this.htmlView.attachNode(e.id);
189
+ this.graphStore.addNode(e);
113
190
  }
114
191
  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
- });
192
+ this.graphStore.updateNode(e, o);
122
193
  }
123
194
  removeNode(e) {
124
- this.graphStore.getNodePortIds(e).forEach((o) => {
125
- this.unmarkPort(o);
126
- }), this.graphStore.removeNode(e), this.htmlView.detachNode(e);
195
+ this.graphStore.removeNode(e);
127
196
  }
128
197
  markPort(e) {
129
198
  this.graphStore.addPort(e);
130
199
  }
131
200
  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);
134
- });
201
+ this.graphStore.updatePort(e, o);
135
202
  }
136
203
  unmarkPort(e) {
137
- this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
138
- this.removeEdge(o);
139
- }), this.graphStore.removePort(e);
204
+ this.graphStore.removePort(e);
140
205
  }
141
206
  addEdge(e) {
142
- this.graphStore.addEdge(e), this.htmlView.attachEdge(e.id);
207
+ this.graphStore.addEdge(e);
143
208
  }
144
209
  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));
210
+ this.graphStore.updateEdge(e, o);
149
211
  }
150
212
  removeEdge(e) {
151
- this.graphStore.removeEdge(e), this.htmlView.detachEdge(e);
213
+ this.graphStore.removeEdge(e);
152
214
  }
153
215
  patchViewportMatrix(e) {
154
216
  this.viewportStore.patchViewportMatrix(e);
@@ -157,33 +219,39 @@ class se {
157
219
  this.viewportStore.patchContentMatrix(e);
158
220
  }
159
221
  clear() {
160
- this.htmlView.clear(), this.graphStore.clear();
222
+ this.graphStore.clear();
161
223
  }
162
224
  destroy() {
163
- this.clear(), this.htmlView.destroy();
225
+ this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
226
+ this.onAfterNodePriorityUpdated
227
+ ), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
228
+ this.onAfterEdgeShapeUpdated
229
+ ), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
230
+ this.onAfterEdgePriorityUpdated
231
+ ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.clear(), this.htmlView.destroy();
164
232
  }
165
233
  }
166
- const $ = (t, e, o) => {
234
+ const U = (t, e, o) => {
167
235
  const { x: r, y: n, width: h, height: s } = t.getBoundingClientRect();
168
236
  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) => {
237
+ }, $ = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, R = (t, e) => {
170
238
  e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
171
- }, ne = (t) => {
172
- var g, f, x, y, S, p;
239
+ }, he = (t) => {
240
+ var g, f, x, v, S, p;
173
241
  const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
174
242
  }), 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;
243
+ }), n = (t == null ? void 0 : t.moveOnTop) === !1, h = (v = t == null ? void 0 : t.mouse) == null ? void 0 : v.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 : (N) => N.button === 0, a = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseUpEventVerifier;
176
244
  return {
177
245
  freezePriority: n,
178
246
  dragCursor: s,
179
247
  mouseDownEventVerifier: c,
180
- mouseUpEventVerifier: a !== void 0 ? a : (T) => T.button === 0,
248
+ mouseUpEventVerifier: a !== void 0 ? a : (N) => N.button === 0,
181
249
  onNodeDrag: e,
182
250
  onBeforeNodeDrag: o,
183
251
  onNodeDragFinished: r
184
252
  };
185
253
  };
186
- class he {
254
+ class de {
187
255
  constructor(e, o) {
188
256
  i(this, "graph");
189
257
  i(this, "viewport");
@@ -192,7 +260,7 @@ class he {
192
260
  i(this, "grabbedNodeId", null);
193
261
  i(this, "element", null);
194
262
  i(this, "onWindowMouseMove", (e) => {
195
- if (this.element !== null && (!$(this.element, e.clientX, e.clientY) || !W(this.window, e.clientX, e.clientY))) {
263
+ if (this.element !== null && (!U(this.element, e.clientX, e.clientY) || !$(this.window, e.clientX, e.clientY))) {
196
264
  this.cancelMouseDrag();
197
265
  return;
198
266
  }
@@ -205,7 +273,7 @@ class he {
205
273
  if (e.touches.length !== 1)
206
274
  return;
207
275
  const o = e.touches[0];
208
- if (this.element !== null && (!$(this.element, o.clientX, o.clientY) || !W(this.window, o.clientX, o.clientY))) {
276
+ if (this.element !== null && (!U(this.element, o.clientX, o.clientY) || !$(this.window, o.clientX, o.clientY))) {
209
277
  this.cancelTouchDrag();
210
278
  return;
211
279
  }
@@ -223,7 +291,7 @@ class he {
223
291
  i(this, "previousTouchCoords", null);
224
292
  i(this, "window", window);
225
293
  i(this, "options");
226
- this.canvas = e, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = ne(o ?? {});
294
+ this.canvas = e, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = he(o ?? {});
227
295
  }
228
296
  attach(e) {
229
297
  this.detach(), this.element = e, this.canvas.attach(this.element);
@@ -354,7 +422,7 @@ class he {
354
422
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
355
423
  }
356
424
  }
357
- const de = (t) => {
425
+ const ce = (t) => {
358
426
  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;
359
427
  return (h) => {
360
428
  let s = h.nextTransform.x, d = h.nextTransform.y;
@@ -364,7 +432,7 @@ const de = (t) => {
364
432
  const l = h.canvasHeight * h.prevTransform.scale, g = n - l;
365
433
  return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: s, y: d };
366
434
  };
367
- }, ce = (t) => {
435
+ }, ae = (t) => {
368
436
  const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, n = o !== null ? 1 / o : 1 / 0;
369
437
  return (h) => {
370
438
  const s = h.prevTransform, d = h.nextTransform;
@@ -385,7 +453,7 @@ const de = (t) => {
385
453
  y: l
386
454
  };
387
455
  };
388
- }, ae = (t) => (e) => t.reduce(
456
+ }, le = (t) => (e) => t.reduce(
389
457
  (o, r) => r({
390
458
  prevTransform: e.prevTransform,
391
459
  nextTransform: o,
@@ -393,40 +461,40 @@ const de = (t) => {
393
461
  canvasHeight: e.canvasHeight
394
462
  }),
395
463
  e.nextTransform
396
- ), J = (t) => {
464
+ ), Q = (t) => {
397
465
  if (typeof t == "function")
398
466
  return t;
399
467
  switch (t.type) {
400
468
  case "scale-limit":
401
- return ce({
469
+ return ae({
402
470
  minContentScale: t.minContentScale ?? 0,
403
471
  maxContentScale: t.maxContentScale ?? 1 / 0
404
472
  });
405
473
  case "shift-limit":
406
- return de({
474
+ return ce({
407
475
  minX: t.minX ?? -1 / 0,
408
476
  maxX: t.maxX ?? 1 / 0,
409
477
  minY: t.minY ?? -1 / 0,
410
478
  maxY: t.maxY ?? 1 / 0
411
479
  });
412
480
  }
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;
481
+ }, ge = (t) => {
482
+ var v, S, p, N, k, M, V, L, G, _, J, K;
483
+ const e = (v = t == null ? void 0 : t.scale) == null ? void 0 : v.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
416
484
  let n;
417
- r !== void 0 ? Array.isArray(r) ? n = ae(
485
+ r !== void 0 ? Array.isArray(r) ? n = le(
418
486
  r.map(
419
- (P) => J(P)
487
+ (b) => Q(b)
420
488
  )
421
- ) : n = J(r) : n = (P) => P.nextTransform;
489
+ ) : n = Q(r) : n = (b) => b.nextTransform;
422
490
  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;
491
+ }), d = ((N = t == null ? void 0 : t.events) == null ? void 0 : N.onTransformChange) ?? (() => {
492
+ }), c = (k = t == null ? void 0 : t.shift) == null ? void 0 : k.mouseDownEventVerifier, a = c !== void 0 ? c : (b) => b.button === 0, l = (M = t == null ? void 0 : t.shift) == null ? void 0 : M.mouseUpEventVerifier, g = l !== void 0 ? l : (b) => b.button === 0, f = (V = t == null ? void 0 : t.scale) == null ? void 0 : V.mouseWheelEventVerifier, x = f !== void 0 ? f : () => !0;
425
493
  return {
426
494
  wheelSensitivity: o,
427
- onTransformStarted: ((C = t == null ? void 0 : t.events) == null ? void 0 : C.onTransformStarted) ?? (() => {
495
+ onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
428
496
  }),
429
- onTransformFinished: ((H = t == null ? void 0 : t.events) == null ? void 0 : H.onTransformFinished) ?? (() => {
497
+ onTransformFinished: ((G = t == null ? void 0 : t.events) == null ? void 0 : G.onTransformFinished) ?? (() => {
430
498
  }),
431
499
  onBeforeTransformChange: s,
432
500
  onTransformChange: d,
@@ -435,13 +503,13 @@ const de = (t) => {
435
503
  mouseDownEventVerifier: a,
436
504
  mouseUpEventVerifier: g,
437
505
  mouseWheelEventVerifier: x,
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) ?? (() => {
506
+ scaleWheelFinishTimeout: ((_ = t == null ? void 0 : t.scale) == null ? void 0 : _.wheelFinishTimeout) ?? 500,
507
+ onResizeTransformStarted: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onResizeTransformStarted) ?? (() => {
440
508
  }),
441
- onResizeTransformFinished: ((_ = t == null ? void 0 : t.events) == null ? void 0 : _.onResizeTransformFinished) ?? (() => {
509
+ onResizeTransformFinished: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onResizeTransformFinished) ?? (() => {
442
510
  })
443
511
  };
444
- }, b = (t) => {
512
+ }, C = (t) => {
445
513
  const e = [], o = t.touches.length;
446
514
  for (let d = 0; d < o; d++)
447
515
  e.push([t.touches[d].clientX, t.touches[d].clientY]);
@@ -459,16 +527,16 @@ const de = (t) => {
459
527
  touchesCnt: o,
460
528
  touches: e
461
529
  };
462
- }, ge = (t, e, o) => ({
530
+ }, ue = (t, e, o) => ({
463
531
  scale: t.scale,
464
532
  x: t.x + t.scale * e,
465
533
  y: t.y + t.scale * o
466
- }), ue = (t, e, o, r) => ({
534
+ }), we = (t, e, o, r) => ({
467
535
  scale: t.scale * e,
468
536
  x: t.scale * (1 - e) * o + t.x,
469
537
  y: t.scale * (1 - e) * r + t.y
470
538
  });
471
- class q {
539
+ class ee {
472
540
  constructor(e, o) {
473
541
  i(this, "graph");
474
542
  i(this, "viewport");
@@ -480,7 +548,7 @@ class q {
480
548
  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());
481
549
  });
482
550
  i(this, "onWindowMouseMove", (e) => {
483
- if (this.element === null || !$(this.element, e.clientX, e.clientY) || !W(this.window, e.clientX, e.clientY)) {
551
+ if (this.element === null || !U(this.element, e.clientX, e.clientY) || !$(this.window, e.clientX, e.clientY)) {
484
552
  this.stopMouseDrag();
485
553
  return;
486
554
  }
@@ -501,18 +569,18 @@ class q {
501
569
  });
502
570
  i(this, "onTouchStart", (e) => {
503
571
  if (this.prevTouches !== null) {
504
- this.prevTouches = b(e);
572
+ this.prevTouches = C(e);
505
573
  return;
506
574
  }
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();
575
+ this.prevTouches = C(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
508
576
  });
509
577
  i(this, "onWindowTouchMove", (e) => {
510
578
  const o = this.element;
511
579
  if (o === null)
512
580
  return;
513
- const r = b(e);
581
+ const r = C(e);
514
582
  if (!r.touches.every(
515
- (h) => $(o, h[0], h[1]) && W(this.window, h[0], h[1])
583
+ (h) => U(o, h[0], h[1]) && $(this.window, h[0], h[1])
516
584
  )) {
517
585
  this.stopTouchDrag();
518
586
  return;
@@ -528,7 +596,7 @@ class q {
528
596
  this.prevTouches = r;
529
597
  });
530
598
  i(this, "onWindowTouchFinish", (e) => {
531
- e.touches.length > 0 ? this.prevTouches = b(e) : this.stopTouchDrag();
599
+ e.touches.length > 0 ? this.prevTouches = C(e) : this.stopTouchDrag();
532
600
  });
533
601
  i(this, "observer", new ResizeObserver(() => {
534
602
  const e = this.canvas.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
@@ -540,7 +608,7 @@ class q {
540
608
  this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(n), this.options.onResizeTransformFinished();
541
609
  }));
542
610
  i(this, "options");
543
- this.canvas = e, this.options = le(o), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
611
+ this.canvas = e, this.options = ge(o), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
544
612
  }
545
613
  attach(e) {
546
614
  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);
@@ -588,7 +656,7 @@ class q {
588
656
  this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
589
657
  }
590
658
  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({
659
+ const n = this.viewport.getViewportMatrix(), h = ue(n, o, r), { width: s, height: d } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
592
660
  prevTransform: n,
593
661
  nextTransform: h,
594
662
  canvasWidth: s,
@@ -597,7 +665,7 @@ class q {
597
665
  this.performTransform(c);
598
666
  }
599
667
  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({
668
+ const h = this.canvas.viewport.getViewportMatrix(), s = we(h, o, r, n), { width: d, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
601
669
  prevTransform: h,
602
670
  nextTransform: s,
603
671
  canvasWidth: d,
@@ -621,112 +689,7 @@ class q {
621
689
  this.options.onBeforeTransformChange(), this.canvas.patchViewportMatrix(e), this.options.onTransformChange();
622
690
  }
623
691
  }
624
- class we {
625
- constructor() {
626
- i(this, "keyMap", /* @__PURE__ */ new Map());
627
- i(this, "valueMap", /* @__PURE__ */ new Map());
628
- }
629
- set(e, o) {
630
- this.keyMap.set(e, o), this.valueMap.set(o, e);
631
- }
632
- hasKey(e) {
633
- return this.keyMap.has(e);
634
- }
635
- hasValue(e) {
636
- return this.valueMap.has(e);
637
- }
638
- getByKey(e) {
639
- return this.keyMap.get(e);
640
- }
641
- getByValue(e) {
642
- return this.valueMap.get(e);
643
- }
644
- deleteByKey(e) {
645
- const o = this.keyMap.get(e);
646
- o !== void 0 && this.valueMap.delete(o), this.keyMap.delete(e);
647
- }
648
- deleteByValue(e) {
649
- const o = this.valueMap.get(e);
650
- o !== void 0 && this.keyMap.delete(o), this.valueMap.delete(e);
651
- }
652
- forEach(e) {
653
- this.keyMap.forEach((o, r) => {
654
- e(o, r);
655
- });
656
- }
657
- clear() {
658
- this.keyMap.clear(), this.valueMap.clear();
659
- }
660
- }
661
692
  class fe {
662
- constructor(e) {
663
- i(this, "viewport");
664
- i(this, "graph");
665
- i(this, "nodes", new we());
666
- i(this, "nodesResizeObserver");
667
- i(this, "window", window);
668
- this.canvas = e, this.nodesResizeObserver = new this.window.ResizeObserver((o) => {
669
- o.forEach((r) => {
670
- const n = r.target;
671
- this.handleNodeResize(n);
672
- });
673
- }), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
674
- }
675
- attach(e) {
676
- this.canvas.attach(e);
677
- }
678
- detach() {
679
- this.canvas.detach();
680
- }
681
- addNode(e) {
682
- this.canvas.addNode(e), this.nodes.set(e.id, e.element), this.nodesResizeObserver.observe(e.element);
683
- }
684
- updateNode(e, o) {
685
- this.canvas.updateNode(e, o);
686
- }
687
- removeNode(e) {
688
- this.canvas.removeNode(e);
689
- const o = this.nodes.getByKey(e);
690
- this.nodes.deleteByKey(e), this.nodesResizeObserver.unobserve(o);
691
- }
692
- markPort(e) {
693
- this.canvas.markPort(e);
694
- }
695
- updatePort(e, o) {
696
- this.canvas.updatePort(e, o);
697
- }
698
- unmarkPort(e) {
699
- this.canvas.unmarkPort(e);
700
- }
701
- addEdge(e) {
702
- this.canvas.addEdge(e);
703
- }
704
- updateEdge(e, o) {
705
- this.canvas.updateEdge(e, o);
706
- }
707
- removeEdge(e) {
708
- this.canvas.removeEdge(e);
709
- }
710
- patchViewportMatrix(e) {
711
- this.canvas.patchViewportMatrix(e);
712
- }
713
- patchContentMatrix(e) {
714
- this.canvas.patchContentMatrix(e);
715
- }
716
- clear() {
717
- this.canvas.clear(), this.nodesResizeObserver.disconnect(), this.nodes.clear();
718
- }
719
- destroy() {
720
- this.clear(), this.canvas.destroy();
721
- }
722
- handleNodeResize(e) {
723
- const o = this.nodes.getByValue(e);
724
- this.canvas.updateNode(o, {}), this.graph.getNodeAdjacentEdgeIds(o).forEach((n) => {
725
- this.canvas.updateEdge(n, {});
726
- });
727
- }
728
- }
729
- class ye {
730
693
  constructor(e, o, r, n) {
731
694
  i(this, "graph");
732
695
  i(this, "viewport");
@@ -773,7 +736,7 @@ class ye {
773
736
  }
774
737
  }
775
738
  };
776
- this.canvas = new q(
739
+ this.canvas = new ee(
777
740
  e,
778
741
  d
779
742
  ), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.trigger.subscribe(this.updateLoadedArea);
@@ -840,10 +803,10 @@ class ye {
840
803
  const ve = () => {
841
804
  const t = document.createElement("div");
842
805
  return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
843
- }, xe = () => {
806
+ }, ye = () => {
844
807
  const t = document.createElement("div");
845
808
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
846
- }, Ee = () => {
809
+ }, xe = () => {
847
810
  const t = document.createElement("div");
848
811
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
849
812
  };
@@ -851,14 +814,14 @@ class Ae {
851
814
  constructor(e, o) {
852
815
  i(this, "canvasWrapper", null);
853
816
  i(this, "host", ve());
854
- i(this, "container", xe());
817
+ i(this, "container", ye());
855
818
  i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
856
819
  i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
857
820
  i(this, "applyTransform", () => {
858
821
  const e = this.viewportStore.getContentMatrix();
859
822
  this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
860
823
  });
861
- this.graphStore = e, this.viewportStore = o, this.host.appendChild(this.container), this.viewportStore.onAfterUpdate.subscribe(this.applyTransform);
824
+ this.graphStore = e, this.viewportStore = o, this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
862
825
  }
863
826
  attach(e) {
864
827
  this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host), this.graphStore.getAllEdgeIds().forEach((o) => {
@@ -869,8 +832,8 @@ class Ae {
869
832
  this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
870
833
  }
871
834
  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";
835
+ const o = this.graphStore.getNode(e), r = xe();
836
+ r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodePosition(e), this.updateNodePriority(e), r.style.visibility = "visible";
874
837
  }
875
838
  detachNode(e) {
876
839
  const o = this.nodeIdToWrapperElementMap.get(e);
@@ -892,9 +855,9 @@ class Ae {
892
855
  });
893
856
  }
894
857
  destroy() {
895
- this.viewportStore.onAfterUpdate.unsubscribe(this.applyTransform), this.clear(), this.detach(), this.host.removeChild(this.container);
858
+ this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.detach(), this.host.removeChild(this.container);
896
859
  }
897
- updateNodeCoordinates(e) {
860
+ updateNodePosition(e) {
898
861
  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
862
  o.style.transform = `translate(${c}px, ${a}px)`;
900
863
  }
@@ -942,7 +905,7 @@ class Ae {
942
905
  o.shape.svg.style.zIndex = `${o.priority}`;
943
906
  }
944
907
  }
945
- class pe {
908
+ class Ee {
946
909
  constructor(e) {
947
910
  i(this, "xFrom", 1 / 0);
948
911
  i(this, "yFrom", 1 / 0);
@@ -962,7 +925,7 @@ class pe {
962
925
  return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
963
926
  }
964
927
  }
965
- class Se {
928
+ class pe {
966
929
  constructor(e, o, r) {
967
930
  i(this, "attachedNodes", /* @__PURE__ */ new Set());
968
931
  i(this, "attachedEdges", /* @__PURE__ */ new Set());
@@ -986,7 +949,7 @@ class Se {
986
949
  this.handleAttachEdge(s);
987
950
  });
988
951
  });
989
- this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new pe(this.graphStore), this.trigger.subscribe(this.updateViewport);
952
+ this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new Ee(this.graphStore), this.trigger.subscribe(this.updateViewport);
990
953
  }
991
954
  attach(e) {
992
955
  this.htmlView.attach(e);
@@ -1006,8 +969,8 @@ class Se {
1006
969
  detachEdge(e) {
1007
970
  this.attachedEdges.has(e) && this.handleDetachEdge(e);
1008
971
  }
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) => {
972
+ updateNodePosition(e) {
973
+ this.attachedNodes.has(e) ? this.htmlView.updateNodePosition(e) : this.renderingBox.hasNode(e) && (this.handleAttachNode(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((o) => {
1011
974
  this.attachEdgeEntities(o);
1012
975
  }));
1013
976
  }
@@ -1046,7 +1009,7 @@ class Se {
1046
1009
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
1047
1010
  }
1048
1011
  }
1049
- class ee {
1012
+ class te {
1050
1013
  constructor() {
1051
1014
  i(this, "callbacks", /* @__PURE__ */ new Set());
1052
1015
  }
@@ -1062,8 +1025,8 @@ class ee {
1062
1025
  });
1063
1026
  }
1064
1027
  }
1065
- const E = () => {
1066
- const t = new ee();
1028
+ const A = () => {
1029
+ const t = new te();
1067
1030
  return [t, t];
1068
1031
  };
1069
1032
  class z {
@@ -1082,53 +1045,53 @@ class z {
1082
1045
  this.counter = 0;
1083
1046
  }
1084
1047
  }
1085
- class A extends Error {
1048
+ class E extends Error {
1086
1049
  constructor() {
1087
1050
  super(...arguments);
1088
1051
  i(this, "name", "HtmlGraphError");
1089
1052
  }
1090
1053
  }
1091
- const Te = (t, e) => ({
1054
+ const Se = (t, e) => ({
1092
1055
  x: t / 2,
1093
1056
  y: e / 2
1094
- }), Y = (t) => () => t, Q = Y(0), Ne = () => {
1057
+ }), Y = (t) => () => t, Z = Y(0), Ne = () => {
1095
1058
  let t = 0;
1096
1059
  return () => t++;
1097
1060
  }, me = (t, e) => {
1098
- let o = Q, r = Q;
1061
+ let o = Z, r = Z;
1099
1062
  const n = Ne();
1100
1063
  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), {
1101
1064
  nodesPriorityFn: o,
1102
1065
  edgesPriorityFn: r
1103
1066
  };
1104
- }, v = (t, e, o) => ({
1067
+ }, y = (t, e, o) => ({
1105
1068
  x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
1106
1069
  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 = {
1070
+ }), m = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
1108
1071
  x: 0,
1109
1072
  y: 0
1110
- }, m = (t, e, o, r) => {
1073
+ }, T = (t, e, o, r) => {
1111
1074
  const h = [
1112
1075
  w,
1113
1076
  { x: o, y: r },
1114
1077
  { x: o, y: -r }
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}`;
1078
+ ].map((a) => y(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
1079
  return `${s} ${d} ${c}`;
1117
- }, L = (t, e) => {
1080
+ }, D = (t, e) => {
1118
1081
  const o = [];
1119
1082
  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
1083
  const r = t.length - 1;
1121
1084
  let n = 0, h = 0, s = 0;
1122
1085
  t.forEach((d, c) => {
1123
1086
  let a = 0, l = 0, g = 0;
1124
- const f = c > 0, x = c < r, y = f && x;
1087
+ const f = c > 0, x = c < r, v = f && x;
1125
1088
  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);
1089
+ const L = t[c + 1];
1090
+ n = L.x - d.x, h = L.y - d.y, s = Math.sqrt(n * n + h * h);
1128
1091
  }
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}`
1092
+ const p = s !== 0 ? Math.min((v ? e : 0) / s, c < r - 1 ? 0.5 : 1) : 0, N = v ? { x: d.x + n * p, y: d.y + h * p } : d, M = g !== 0 ? Math.min((v ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, V = v ? { x: d.x + a * M, y: d.y + l * M } : d;
1093
+ c > 0 && o.push(`L ${V.x} ${V.y}`), v && o.push(
1094
+ `C ${d.x} ${d.y} ${d.x} ${d.y} ${N.x} ${N.y}`
1132
1095
  );
1133
1096
  });
1134
1097
  }
@@ -1136,13 +1099,13 @@ const Te = (t, e) => ({
1136
1099
  }, I = () => {
1137
1100
  const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1138
1101
  return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
1139
- }, F = () => {
1102
+ }, W = () => {
1140
1103
  const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
1141
1104
  return t.style.transformOrigin = "50% 50%", t;
1142
- }, U = (t, e) => {
1105
+ }, F = (t, e) => {
1143
1106
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
1144
1107
  return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
1145
- }, M = (t) => {
1108
+ }, P = (t) => {
1146
1109
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1147
1110
  return e.setAttribute("fill", t), e;
1148
1111
  }, B = (t, e) => {
@@ -1161,12 +1124,12 @@ const Te = (t, e) => ({
1161
1124
  flipX: c,
1162
1125
  flipY: a
1163
1126
  };
1164
- }, Me = (t) => {
1165
- const e = v(
1127
+ }, Te = (t) => {
1128
+ const e = y(
1166
1129
  { x: t.arrowLength, y: w.y },
1167
1130
  t.fromVect,
1168
1131
  w
1169
- ), o = v(
1132
+ ), o = y(
1170
1133
  { x: t.to.x - t.arrowLength, y: t.to.y },
1171
1134
  t.toVect,
1172
1135
  t.to
@@ -1179,22 +1142,22 @@ const Te = (t, e) => ({
1179
1142
  }, 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
1143
  return `${s}${h}${d}`;
1181
1144
  }, Pe = (t) => {
1182
- const e = t.hasSourceArrow ? v(
1145
+ const e = t.hasSourceArrow ? y(
1183
1146
  { x: t.arrowLength, y: w.y },
1184
1147
  t.fromVect,
1185
1148
  w
1186
- ) : w, o = t.hasTargetArrow ? v(
1149
+ ) : w, o = t.hasTargetArrow ? y(
1187
1150
  { x: t.to.x - t.arrowLength, y: t.to.y },
1188
1151
  t.toVect,
1189
1152
  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(
1153
+ ) : 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 = y(
1191
1154
  { x: r, y: w.y },
1192
1155
  t.fromVect,
1193
1156
  w
1194
1157
  ), a = {
1195
1158
  x: c.x + s,
1196
1159
  y: c.y + d
1197
- }, l = v(
1160
+ }, l = y(
1198
1161
  { x: t.to.x - r, y: t.to.y },
1199
1162
  t.toVect,
1200
1163
  t.to
@@ -1204,7 +1167,7 @@ const Te = (t, e) => ({
1204
1167
  }, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, x = {
1205
1168
  x: c.x + t.curvature * t.fromVect.x,
1206
1169
  y: c.y + t.curvature * t.fromVect.y
1207
- }, y = {
1170
+ }, v = {
1208
1171
  x: l.x - t.curvature * t.toVect.x,
1209
1172
  y: l.y - t.curvature * t.toVect.y
1210
1173
  }, S = {
@@ -1218,19 +1181,19 @@ const Te = (t, e) => ({
1218
1181
  `M ${e.x} ${e.y}`,
1219
1182
  `L ${c.x} ${c.y}`,
1220
1183
  `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}`,
1184
+ `C ${p.x} ${p.y} ${v.x} ${v.y} ${l.x} ${l.y}`,
1222
1185
  `L ${o.x} ${o.y}`
1223
1186
  ].join(" ");
1224
- }, Ve = (t) => {
1225
- const e = t.hasSourceArrow ? v(
1187
+ }, be = (t) => {
1188
+ const e = t.hasSourceArrow ? y(
1226
1189
  { x: t.arrowLength, y: w.y },
1227
1190
  t.fromVect,
1228
1191
  w
1229
- ) : w, o = t.hasTargetArrow ? v(
1192
+ ) : w, o = t.hasTargetArrow ? y(
1230
1193
  { x: t.to.x - t.arrowLength, y: t.to.y },
1231
1194
  t.toVect,
1232
1195
  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(
1196
+ ) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, h = y({ x: n, y: w.y }, t.fromVect, w), s = y(
1234
1197
  { x: t.to.x - n, y: t.to.y },
1235
1198
  t.toVect,
1236
1199
  t.to
@@ -1238,57 +1201,57 @@ const Te = (t, e) => ({
1238
1201
  x: t.flipX > 0 ? t.to.x - d : t.to.x + r,
1239
1202
  y: s.y
1240
1203
  }, f = { x: g.x, y: c };
1241
- return L(
1204
+ return D(
1242
1205
  [e, h, a, l, f, g, s, o],
1243
1206
  t.roundness
1244
1207
  );
1245
1208
  }, X = (t) => {
1246
- const e = t.hasSourceArrow ? v(
1209
+ const e = t.hasSourceArrow ? y(
1247
1210
  { x: t.arrowLength, y: w.y },
1248
1211
  t.fromVect,
1249
1212
  w
1250
- ) : w, o = t.hasTargetArrow ? v(
1213
+ ) : w, o = t.hasTargetArrow ? y(
1251
1214
  { x: t.to.x - t.arrowLength, y: t.to.y },
1252
1215
  t.toVect,
1253
1216
  t.to
1254
- ) : t.to, r = t.arrowLength + t.arrowOffset, n = v(
1217
+ ) : t.to, r = t.arrowLength + t.arrowOffset, n = y(
1255
1218
  { x: r, y: w.y },
1256
1219
  t.fromVect,
1257
1220
  w
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(
1221
+ ), 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 = y(
1259
1222
  { x: t.to.x - r, y: t.to.y },
1260
1223
  t.toVect,
1261
1224
  t.to
1262
1225
  ), g = { x: l.x + d, y: l.y + c };
1263
- return L(
1226
+ return D(
1264
1227
  [e, n, a, g, l, o],
1265
1228
  t.roundness
1266
1229
  );
1267
- }, De = (t) => {
1268
- const e = t.hasSourceArrow ? v(
1230
+ }, Me = (t) => {
1231
+ const e = t.hasSourceArrow ? y(
1269
1232
  { x: t.arrowLength, y: w.y },
1270
1233
  t.fromVect,
1271
1234
  w
1272
- ) : w, o = t.hasTargetArrow ? v(
1235
+ ) : w, o = t.hasTargetArrow ? y(
1273
1236
  { x: t.to.x - t.arrowLength, y: t.to.y },
1274
1237
  t.toVect,
1275
1238
  t.to
1276
- ) : t.to, r = t.arrowLength + t.arrowOffset, n = v({ x: r, y: w.y }, t.fromVect, w), h = v(
1239
+ ) : t.to, r = t.arrowLength + t.arrowOffset, n = y({ x: r, y: w.y }, t.fromVect, w), h = y(
1277
1240
  { x: t.to.x - r, y: t.to.y },
1278
1241
  t.toVect,
1279
1242
  t.to
1280
1243
  );
1281
- return L([e, n, h, o], t.roundness);
1282
- }, Ce = (t) => {
1283
- const e = t.hasSourceArrow ? v(
1244
+ return D([e, n, h, o], t.roundness);
1245
+ }, Ve = (t) => {
1246
+ const e = t.hasSourceArrow ? y(
1284
1247
  { x: t.arrowLength, y: w.y },
1285
1248
  t.fromVect,
1286
1249
  w
1287
- ) : w, o = t.hasTargetArrow ? v(
1250
+ ) : w, o = t.hasTargetArrow ? y(
1288
1251
  { x: t.to.x - t.arrowLength, y: t.to.y },
1289
1252
  t.toVect,
1290
1253
  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(
1254
+ ) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, h = y({ x: n, y: w.y }, t.fromVect, w), s = y(
1292
1255
  { x: t.to.x - n, y: t.to.y },
1293
1256
  t.toVect,
1294
1257
  t.to
@@ -1296,11 +1259,11 @@ const Te = (t, e) => ({
1296
1259
  x: s.x,
1297
1260
  y: t.flipY > 0 ? t.to.y - d : t.to.y + r
1298
1261
  }, f = { x: c, y: g.y };
1299
- return L(
1262
+ return D(
1300
1263
  [e, h, a, l, f, g, s, o],
1301
1264
  t.roundness
1302
1265
  );
1303
- }, j = (t) => {
1266
+ }, H = (t) => {
1304
1267
  const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, n = r + 2 * o, s = [
1305
1268
  { x: t.arrowLength, y: w.y },
1306
1269
  { x: r, y: w.y },
@@ -1311,15 +1274,15 @@ const Te = (t, e) => ({
1311
1274
  { x: r, y: w.y },
1312
1275
  { x: t.arrowLength, y: w.y }
1313
1276
  ].map(
1314
- (c) => v(c, t.fromVect, w)
1277
+ (c) => y(c, t.fromVect, w)
1315
1278
  ), d = `M ${w.x} ${w.y} L ${s[0].x} ${s[0].y} `;
1316
- return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${L(s, t.roundness)}`;
1279
+ return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${D(s, t.roundness)}`;
1317
1280
  }, Le = (t) => {
1318
1281
  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
1282
  { x: t.arrowLength, y: w.y },
1320
1283
  { x: h, y: s },
1321
1284
  { x: h, y: -s }
1322
- ].map((g) => v(g, t.fromVect, w)), a = [
1285
+ ].map((g) => y(g, t.fromVect, w)), a = [
1323
1286
  `M ${c[0].x} ${c[0].y}`,
1324
1287
  `A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
1325
1288
  `A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
@@ -1343,10 +1306,10 @@ const Te = (t, e) => ({
1343
1306
  smallCycleRadius: 15,
1344
1307
  curvature: 90
1345
1308
  });
1346
- class be {
1309
+ class De {
1347
1310
  constructor(e) {
1348
1311
  i(this, "svg", I());
1349
- i(this, "group", F());
1312
+ i(this, "group", W());
1350
1313
  i(this, "line");
1351
1314
  i(this, "sourceArrow", null);
1352
1315
  i(this, "targetArrow", null);
@@ -1361,7 +1324,7 @@ class be {
1361
1324
  i(this, "hasTargetArrow");
1362
1325
  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
1326
  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));
1327
+ this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(o), this.group.appendChild(this.targetArrow));
1365
1328
  }
1366
1329
  render(e) {
1367
1330
  const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
@@ -1369,11 +1332,11 @@ class be {
1369
1332
  e.to
1370
1333
  );
1371
1334
  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(
1335
+ const c = m(
1373
1336
  e.from.direction,
1374
1337
  s,
1375
1338
  d
1376
- ), a = N(e.to.direction, s, d), l = {
1339
+ ), a = m(e.to.direction, s, d), l = {
1377
1340
  x: n,
1378
1341
  y: h
1379
1342
  };
@@ -1397,7 +1360,7 @@ class be {
1397
1360
  curvature: this.curvature,
1398
1361
  hasSourceArrow: this.hasSourceArrow,
1399
1362
  hasTargetArrow: this.hasTargetArrow
1400
- }) : g = Me({
1363
+ }) : g = Te({
1401
1364
  to: l,
1402
1365
  fromVect: c,
1403
1366
  toVect: a,
@@ -1406,29 +1369,29 @@ class be {
1406
1369
  hasSourceArrow: this.hasSourceArrow,
1407
1370
  hasTargetArrow: this.hasTargetArrow
1408
1371
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1409
- const y = m(
1372
+ const v = T(
1410
1373
  c,
1411
1374
  w,
1412
1375
  this.arrowLength,
1413
1376
  this.arrowWidth
1414
1377
  );
1415
- this.sourceArrow.setAttribute("d", y);
1378
+ this.sourceArrow.setAttribute("d", v);
1416
1379
  }
1417
1380
  if (this.targetArrow) {
1418
- const y = m(
1381
+ const v = T(
1419
1382
  f,
1420
1383
  l,
1421
1384
  x,
1422
1385
  this.arrowWidth
1423
1386
  );
1424
- this.targetArrow.setAttribute("d", y);
1387
+ this.targetArrow.setAttribute("d", v);
1425
1388
  }
1426
1389
  }
1427
1390
  }
1428
- class $e {
1391
+ class Ce {
1429
1392
  constructor(e) {
1430
1393
  i(this, "svg", I());
1431
- i(this, "group", F());
1394
+ i(this, "group", W());
1432
1395
  i(this, "line");
1433
1396
  i(this, "sourceArrow", null);
1434
1397
  i(this, "targetArrow", null);
@@ -1449,7 +1412,7 @@ class $e {
1449
1412
  this.cycleSquareSide / 2
1450
1413
  ), 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
1414
  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));
1415
+ this.svg.appendChild(this.group), this.line = F(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
1453
1416
  }
1454
1417
  render(e) {
1455
1418
  const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
@@ -1457,16 +1420,16 @@ class $e {
1457
1420
  e.to
1458
1421
  );
1459
1422
  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(
1423
+ const c = m(
1461
1424
  e.from.direction,
1462
1425
  s,
1463
1426
  d
1464
- ), a = N(e.to.direction, s, d), l = {
1427
+ ), a = m(e.to.direction, s, d), l = {
1465
1428
  x: n,
1466
1429
  y: h
1467
1430
  };
1468
1431
  let g, f = a, x = -this.arrowLength;
1469
- if (e.from.portId === e.to.portId ? (g = j({
1432
+ if (e.from.portId === e.to.portId ? (g = H({
1470
1433
  fromVect: c,
1471
1434
  arrowLength: this.arrowLength,
1472
1435
  side: this.cycleSquareSide,
@@ -1487,7 +1450,7 @@ class $e {
1487
1450
  detourDistance: this.detourDistance,
1488
1451
  hasSourceArrow: this.hasSourceArrow,
1489
1452
  hasTargetArrow: this.hasTargetArrow
1490
- }) : g = Ve({
1453
+ }) : g = be({
1491
1454
  to: l,
1492
1455
  fromVect: c,
1493
1456
  toVect: a,
@@ -1498,29 +1461,29 @@ class $e {
1498
1461
  hasSourceArrow: this.hasSourceArrow,
1499
1462
  hasTargetArrow: this.hasTargetArrow
1500
1463
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1501
- const y = m(
1464
+ const v = T(
1502
1465
  c,
1503
1466
  w,
1504
1467
  this.arrowLength,
1505
1468
  this.arrowWidth
1506
1469
  );
1507
- this.sourceArrow.setAttribute("d", y);
1470
+ this.sourceArrow.setAttribute("d", v);
1508
1471
  }
1509
1472
  if (this.targetArrow) {
1510
- const y = m(
1473
+ const v = T(
1511
1474
  f,
1512
1475
  l,
1513
1476
  x,
1514
1477
  this.arrowWidth
1515
1478
  );
1516
- this.targetArrow.setAttribute("d", y);
1479
+ this.targetArrow.setAttribute("d", v);
1517
1480
  }
1518
1481
  }
1519
1482
  }
1520
- class We {
1483
+ class Ue {
1521
1484
  constructor(e) {
1522
1485
  i(this, "svg", I());
1523
- i(this, "group", F());
1486
+ i(this, "group", W());
1524
1487
  i(this, "line");
1525
1488
  i(this, "sourceArrow", null);
1526
1489
  i(this, "targetArrow", null);
@@ -1541,7 +1504,7 @@ class We {
1541
1504
  this.cycleSquareSide / 2
1542
1505
  ), 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
1506
  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));
1507
+ this.svg.appendChild(this.group), this.line = F(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
1545
1508
  }
1546
1509
  render(e) {
1547
1510
  const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
@@ -1549,16 +1512,16 @@ class We {
1549
1512
  e.to
1550
1513
  );
1551
1514
  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(
1515
+ const c = m(
1553
1516
  e.from.direction,
1554
1517
  s,
1555
1518
  d
1556
- ), a = N(e.to.direction, s, d), l = {
1519
+ ), a = m(e.to.direction, s, d), l = {
1557
1520
  x: n,
1558
1521
  y: h
1559
1522
  };
1560
1523
  let g, f = a, x = -this.arrowLength;
1561
- if (e.from.portId === e.to.portId ? (g = j({
1524
+ if (e.from.portId === e.to.portId ? (g = H({
1562
1525
  fromVect: c,
1563
1526
  arrowLength: this.arrowLength,
1564
1527
  side: this.cycleSquareSide,
@@ -1579,7 +1542,7 @@ class We {
1579
1542
  detourDistance: this.detourDistance,
1580
1543
  hasSourceArrow: this.hasSourceArrow,
1581
1544
  hasTargetArrow: this.hasTargetArrow
1582
- }) : g = De({
1545
+ }) : g = Me({
1583
1546
  to: l,
1584
1547
  fromVect: c,
1585
1548
  toVect: a,
@@ -1589,29 +1552,29 @@ class We {
1589
1552
  hasSourceArrow: this.hasSourceArrow,
1590
1553
  hasTargetArrow: this.hasTargetArrow
1591
1554
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1592
- const y = m(
1555
+ const v = T(
1593
1556
  c,
1594
1557
  w,
1595
1558
  this.arrowLength,
1596
1559
  this.arrowWidth
1597
1560
  );
1598
- this.sourceArrow.setAttribute("d", y);
1561
+ this.sourceArrow.setAttribute("d", v);
1599
1562
  }
1600
1563
  if (this.targetArrow) {
1601
- const y = m(
1564
+ const v = T(
1602
1565
  f,
1603
1566
  l,
1604
1567
  x,
1605
1568
  this.arrowWidth
1606
1569
  );
1607
- this.targetArrow.setAttribute("d", y);
1570
+ this.targetArrow.setAttribute("d", v);
1608
1571
  }
1609
1572
  }
1610
1573
  }
1611
- class Re {
1574
+ class $e {
1612
1575
  constructor(e) {
1613
1576
  i(this, "svg", I());
1614
- i(this, "group", F());
1577
+ i(this, "group", W());
1615
1578
  i(this, "line");
1616
1579
  i(this, "sourceArrow", null);
1617
1580
  i(this, "targetArrow", null);
@@ -1632,7 +1595,7 @@ class Re {
1632
1595
  this.cycleSquareSide / 2
1633
1596
  ), 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
1597
  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));
1598
+ this.svg.appendChild(this.group), this.line = F(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
1636
1599
  }
1637
1600
  render(e) {
1638
1601
  const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
@@ -1640,16 +1603,16 @@ class Re {
1640
1603
  e.to
1641
1604
  );
1642
1605
  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(
1606
+ const c = m(
1644
1607
  e.from.direction,
1645
1608
  s,
1646
1609
  d
1647
- ), a = N(e.to.direction, s, d), l = {
1610
+ ), a = m(e.to.direction, s, d), l = {
1648
1611
  x: n,
1649
1612
  y: h
1650
1613
  };
1651
1614
  let g, f = a, x = -this.arrowLength;
1652
- if (e.from.portId === e.to.portId ? (g = j({
1615
+ if (e.from.portId === e.to.portId ? (g = H({
1653
1616
  fromVect: c,
1654
1617
  arrowLength: this.arrowLength,
1655
1618
  side: this.cycleSquareSide,
@@ -1670,7 +1633,7 @@ class Re {
1670
1633
  detourDistance: this.detourDistance,
1671
1634
  hasSourceArrow: this.hasSourceArrow,
1672
1635
  hasTargetArrow: this.hasTargetArrow
1673
- }) : g = Ce({
1636
+ }) : g = Ve({
1674
1637
  to: l,
1675
1638
  fromVect: c,
1676
1639
  toVect: a,
@@ -1681,31 +1644,31 @@ class Re {
1681
1644
  hasSourceArrow: this.hasSourceArrow,
1682
1645
  hasTargetArrow: this.hasTargetArrow
1683
1646
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1684
- const y = m(
1647
+ const v = T(
1685
1648
  c,
1686
1649
  w,
1687
1650
  this.arrowLength,
1688
1651
  this.arrowWidth
1689
1652
  );
1690
- this.sourceArrow.setAttribute("d", y);
1653
+ this.sourceArrow.setAttribute("d", v);
1691
1654
  }
1692
1655
  if (this.targetArrow) {
1693
- const y = m(
1656
+ const v = T(
1694
1657
  f,
1695
1658
  l,
1696
1659
  x,
1697
1660
  this.arrowWidth
1698
1661
  );
1699
- this.targetArrow.setAttribute("d", y);
1662
+ this.targetArrow.setAttribute("d", v);
1700
1663
  }
1701
1664
  }
1702
1665
  }
1703
- const Ie = (t) => {
1666
+ const Re = (t) => {
1704
1667
  if (typeof t == "function")
1705
1668
  return t;
1706
1669
  switch (t == null ? void 0 : t.type) {
1707
1670
  case "straight":
1708
- return () => new We({
1671
+ return () => new Ue({
1709
1672
  color: t.color,
1710
1673
  width: t.width,
1711
1674
  arrowLength: t.arrowLength,
@@ -1719,7 +1682,7 @@ const Ie = (t) => {
1719
1682
  detourDirection: t.detourDirection
1720
1683
  });
1721
1684
  case "horizontal":
1722
- return () => new $e({
1685
+ return () => new Ce({
1723
1686
  color: t.color,
1724
1687
  width: t.width,
1725
1688
  arrowLength: t.arrowLength,
@@ -1733,7 +1696,7 @@ const Ie = (t) => {
1733
1696
  detourDirection: t.detourDirection
1734
1697
  });
1735
1698
  case "vertical":
1736
- return () => new Re({
1699
+ return () => new $e({
1737
1700
  color: t.color,
1738
1701
  width: t.width,
1739
1702
  arrowLength: t.arrowLength,
@@ -1747,7 +1710,7 @@ const Ie = (t) => {
1747
1710
  detourDirection: t.detourDirection
1748
1711
  });
1749
1712
  default:
1750
- return () => new be({
1713
+ return () => new De({
1751
1714
  color: t.color,
1752
1715
  width: t.width,
1753
1716
  arrowLength: t.arrowLength,
@@ -1761,7 +1724,7 @@ const Ie = (t) => {
1761
1724
  detourDirection: t.detourDirection
1762
1725
  });
1763
1726
  }
1764
- }, Fe = (t) => {
1727
+ }, Ie = (t) => {
1765
1728
  var o, r, n, h, s;
1766
1729
  const e = me(
1767
1730
  (o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
@@ -1769,20 +1732,20 @@ const Ie = (t) => {
1769
1732
  );
1770
1733
  return {
1771
1734
  nodes: {
1772
- centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? Te,
1735
+ centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? Se,
1773
1736
  priorityFn: e.nodesPriorityFn
1774
1737
  },
1775
1738
  ports: {
1776
1739
  direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
1777
1740
  },
1778
1741
  edges: {
1779
- shapeFactory: Ie(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
1742
+ shapeFactory: Re(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
1780
1743
  priorityFn: e.edgesPriorityFn
1781
1744
  }
1782
1745
  };
1783
1746
  };
1784
- class Ue {
1785
- constructor(e, o) {
1747
+ class We {
1748
+ constructor(e, o, r) {
1786
1749
  i(this, "nodeIdGenerator", new z(
1787
1750
  (e) => this.graph.getNode(e) !== null
1788
1751
  ));
@@ -1801,9 +1764,11 @@ class Ue {
1801
1764
  * provides api for accessing viewport state
1802
1765
  */
1803
1766
  i(this, "viewport");
1804
- this.controller = e, this.defaults = Fe(o), this.graph = e.graph, this.viewport = e.viewport;
1767
+ this.element = e, this.controller = o, this.defaults = Ie(r), this.graph = o.graph, this.viewport = o.viewport, this.attach(this.element);
1805
1768
  }
1806
1769
  /**
1770
+ * @deprecated
1771
+ * use CanvasBuilder.attach instead
1807
1772
  * attaches canvas to given element
1808
1773
  * detaches element first when canvas is attached
1809
1774
  */
@@ -1811,6 +1776,8 @@ class Ue {
1811
1776
  return this.controller.attach(e), this;
1812
1777
  }
1813
1778
  /**
1779
+ * @deprecated
1780
+ * attach canvas once instead, then reattach wrapper element
1814
1781
  * detaches canvas from element when attached
1815
1782
  */
1816
1783
  detach() {
@@ -1822,7 +1789,7 @@ class Ue {
1822
1789
  addNode(e) {
1823
1790
  const o = this.nodeIdGenerator.create(e.id);
1824
1791
  if (this.graph.getNode(o) !== null)
1825
- throw new A("failed to add node with existing id");
1792
+ throw new E("failed to add node with existing id");
1826
1793
  if (this.controller.addNode({
1827
1794
  id: o,
1828
1795
  element: e.element,
@@ -1845,7 +1812,7 @@ class Ue {
1845
1812
  */
1846
1813
  updateNode(e, o) {
1847
1814
  if (this.graph.getNode(e) === null)
1848
- throw new A("failed to update nonexisting node");
1815
+ throw new E("failed to update nonexisting node");
1849
1816
  return this.controller.updateNode(e, o ?? {}), this;
1850
1817
  }
1851
1818
  /**
@@ -1855,7 +1822,7 @@ class Ue {
1855
1822
  */
1856
1823
  removeNode(e) {
1857
1824
  if (this.graph.getNode(e) === null)
1858
- throw new A("failed to remove nonexisting node");
1825
+ throw new E("failed to remove nonexisting node");
1859
1826
  return this.controller.removeNode(e), this;
1860
1827
  }
1861
1828
  /**
@@ -1864,9 +1831,9 @@ class Ue {
1864
1831
  markPort(e) {
1865
1832
  const o = this.portIdGenerator.create(e.id);
1866
1833
  if (this.graph.getPort(o) !== null)
1867
- throw new A("failed to add port with existing id");
1834
+ throw new E("failed to add port with existing id");
1868
1835
  if (this.graph.getNode(e.nodeId) === null)
1869
- throw new A("failed to set port on nonexisting node");
1836
+ throw new E("failed to set port on nonexisting node");
1870
1837
  return this.controller.markPort({
1871
1838
  id: o,
1872
1839
  element: e.element,
@@ -1879,7 +1846,7 @@ class Ue {
1879
1846
  */
1880
1847
  updatePort(e, o) {
1881
1848
  if (this.graph.getPort(e) === null)
1882
- throw new A("failed to unset nonexisting port");
1849
+ throw new E("failed to unset nonexisting port");
1883
1850
  return this.controller.updatePort(e, o ?? {}), this;
1884
1851
  }
1885
1852
  /**
@@ -1888,7 +1855,7 @@ class Ue {
1888
1855
  */
1889
1856
  unmarkPort(e) {
1890
1857
  if (this.graph.getPort(e) === null)
1891
- throw new A("failed to unset nonexisting port");
1858
+ throw new E("failed to unset nonexisting port");
1892
1859
  return this.controller.unmarkPort(e), this;
1893
1860
  }
1894
1861
  /**
@@ -1897,11 +1864,11 @@ class Ue {
1897
1864
  addEdge(e) {
1898
1865
  const o = this.edgeIdGenerator.create(e.id);
1899
1866
  if (this.graph.getEdge(o) !== null)
1900
- throw new A("failed to add edge with existing id");
1867
+ throw new E("failed to add edge with existing id");
1901
1868
  if (this.graph.getPort(e.from) === null)
1902
- throw new A("failed to add edge from nonexisting port");
1869
+ throw new E("failed to add edge from nonexisting port");
1903
1870
  if (this.graph.getPort(e.to) === null)
1904
- throw new A("failed to add edge to nonexisting port");
1871
+ throw new E("failed to add edge to nonexisting port");
1905
1872
  return this.controller.addEdge({
1906
1873
  id: o,
1907
1874
  from: e.from,
@@ -1915,7 +1882,7 @@ class Ue {
1915
1882
  */
1916
1883
  updateEdge(e, o) {
1917
1884
  if (this.graph.getEdge(e) === null)
1918
- throw new A("failed to update nonexisting edge");
1885
+ throw new E("failed to update nonexisting edge");
1919
1886
  return this.controller.updateEdge(e, o ?? {}), this;
1920
1887
  }
1921
1888
  /**
@@ -1923,7 +1890,7 @@ class Ue {
1923
1890
  */
1924
1891
  removeEdge(e) {
1925
1892
  if (this.graph.getEdge(e) === null)
1926
- throw new A("failed to remove nonexisting edge");
1893
+ throw new E("failed to remove nonexisting edge");
1927
1894
  return this.controller.removeEdge(e), this;
1928
1895
  }
1929
1896
  /**
@@ -1953,7 +1920,7 @@ class Ue {
1953
1920
  this.controller.destroy();
1954
1921
  }
1955
1922
  }
1956
- class Be {
1923
+ class Fe {
1957
1924
  constructor() {
1958
1925
  i(this, "nodes", /* @__PURE__ */ new Map());
1959
1926
  i(this, "ports", /* @__PURE__ */ new Map());
@@ -1961,42 +1928,33 @@ class Be {
1961
1928
  i(this, "incommingEdges", /* @__PURE__ */ new Map());
1962
1929
  i(this, "outcommingEdges", /* @__PURE__ */ new Map());
1963
1930
  i(this, "cycleEdges", /* @__PURE__ */ new Map());
1964
- i(this, "onAfterNodeAddedEmitter");
1931
+ i(this, "afterNodeAddedEmitter");
1965
1932
  i(this, "onAfterNodeAdded");
1966
- i(this, "onAfterNodeCoordinatesUpdatedEmitter");
1967
- i(this, "onAfterNodeCoordinatesUpdated");
1968
- i(this, "onAfterNodePriorityUpdatedEmitter");
1933
+ i(this, "afterNodeUpdatedEmitter");
1934
+ i(this, "onAfterNodeUpdated");
1935
+ i(this, "afterNodePriorityUpdatedEmitter");
1969
1936
  i(this, "onAfterNodePriorityUpdated");
1970
- i(this, "onBeforeNodeRemovedEmitter");
1937
+ i(this, "beforeNodeRemovedEmitter");
1971
1938
  i(this, "onBeforeNodeRemoved");
1972
- i(this, "onAfterPortAddedEmitter");
1939
+ i(this, "afterPortAddedEmitter");
1973
1940
  i(this, "onAfterPortAdded");
1974
- i(this, "onAfterPortDirectionUpdatedEmitter");
1975
- i(this, "onAfterPortDirectionUpdated");
1976
- i(this, "onBeforePortRemovedEmitter");
1941
+ i(this, "afterPortUpdatedEmitter");
1942
+ i(this, "onAfterPortUpdated");
1943
+ i(this, "beforePortRemovedEmitter");
1977
1944
  i(this, "onBeforePortRemoved");
1978
- i(this, "onAfterEdgeAddedEmitter");
1945
+ i(this, "afterEdgeAddedEmitter");
1979
1946
  i(this, "onAfterEdgeAdded");
1980
- i(this, "onAfterEdgeShapeUpdatedEmitter");
1947
+ i(this, "afterEdgeShapeUpdatedEmitter");
1981
1948
  i(this, "onAfterEdgeShapeUpdated");
1982
- i(this, "onAfterEdgeAdjacentPortsUpdatedEmitter");
1983
- i(this, "onAfterEdgeAdjacentPortsUpdated");
1984
- i(this, "onAfterEdgePriorityUpdatedEmitter");
1949
+ i(this, "afterEdgeUpdatedEmitter");
1950
+ i(this, "onAfterEdgeUpdated");
1951
+ i(this, "afterEdgePriorityUpdatedEmitter");
1985
1952
  i(this, "onAfterEdgePriorityUpdated");
1986
- i(this, "onBeforeEdgeRemovedEmitter");
1953
+ i(this, "beforeEdgeRemovedEmitter");
1987
1954
  i(this, "onBeforeEdgeRemoved");
1988
- i(this, "onBeforeClearEmitter");
1955
+ i(this, "beforeClearEmitter");
1989
1956
  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();
1957
+ [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = A(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = A(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = A(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = A(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = A(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = A(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = A(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = A(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = A(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = A(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = A(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = A(), [this.beforeClearEmitter, this.onBeforeClear] = A();
2000
1958
  }
2001
1959
  addNode(e) {
2002
1960
  const o = /* @__PURE__ */ new Map(), r = {
@@ -2007,7 +1965,7 @@ class Be {
2007
1965
  priority: e.priority,
2008
1966
  ports: o
2009
1967
  };
2010
- this.nodes.set(e.id, r), this.onAfterNodeAddedEmitter.emit(e.id);
1968
+ this.nodes.set(e.id, r), this.afterNodeAddedEmitter.emit(e.id);
2011
1969
  }
2012
1970
  getAllNodeIds() {
2013
1971
  return Array.from(this.nodes.keys());
@@ -2015,30 +1973,26 @@ class Be {
2015
1973
  getNode(e) {
2016
1974
  return this.nodes.get(e);
2017
1975
  }
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) {
1976
+ updateNode(e, o) {
2023
1977
  const r = this.nodes.get(e);
2024
- r.priority = o, this.onAfterNodePriorityUpdatedEmitter.emit(e);
1978
+ r.x = o.x ?? r.x, r.y = o.y ?? r.y, r.centerFn = o.centerFn ?? r.centerFn, o.priority !== void 0 && (r.priority = o.priority, this.afterNodePriorityUpdatedEmitter.emit(e)), this.afterNodeUpdatedEmitter.emit(e);
2025
1979
  }
2026
1980
  removeNode(e) {
2027
- this.onBeforeNodeRemovedEmitter.emit(e), this.nodes.delete(e);
1981
+ this.beforeNodeRemovedEmitter.emit(e), this.nodes.delete(e);
2028
1982
  }
2029
1983
  addPort(e) {
2030
1984
  this.ports.set(e.id, {
2031
1985
  element: e.element,
2032
1986
  direction: e.direction,
2033
1987
  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);
1988
+ }), 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.afterPortAddedEmitter.emit(e.id);
2035
1989
  }
2036
1990
  getPort(e) {
2037
1991
  return this.ports.get(e);
2038
1992
  }
2039
- updatePortDirection(e, o) {
1993
+ updatePort(e, o) {
2040
1994
  const r = this.ports.get(e);
2041
- r.direction = o, this.onAfterPortDirectionUpdatedEmitter.emit(e);
1995
+ r.direction = o.direction ?? r.direction, this.afterPortUpdatedEmitter.emit(e);
2042
1996
  }
2043
1997
  getAllPortIds() {
2044
1998
  return Array.from(this.ports.keys());
@@ -2050,28 +2004,24 @@ class Be {
2050
2004
  }
2051
2005
  removePort(e) {
2052
2006
  const o = this.ports.get(e).nodeId;
2053
- this.onBeforePortRemovedEmitter.emit(e), this.nodes.get(o).ports.delete(e), this.ports.delete(e);
2007
+ this.beforePortRemovedEmitter.emit(e), this.nodes.get(o).ports.delete(e), this.ports.delete(e);
2054
2008
  }
2055
2009
  addEdge(e) {
2056
- this.addEdgeInternal(e), this.onAfterEdgeAddedEmitter.emit(e.id);
2057
- }
2058
- updateEdgeShape(e, o) {
2059
- const r = this.edges.get(e);
2060
- r.shape = o, this.onAfterEdgeShapeUpdatedEmitter.emit(e);
2010
+ this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
2061
2011
  }
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,
2068
- shape: r.shape,
2069
- priority: r.priority
2070
- }), this.onAfterEdgeAdjacentPortsUpdatedEmitter.emit(e);
2071
- }
2072
- updateEdgePriority(e, o) {
2012
+ updateEdge(e, o) {
2013
+ if (o.from !== void 0 || o.to !== void 0) {
2014
+ const n = this.edges.get(e);
2015
+ this.removeEdgeInternal(e), this.addEdgeInternal({
2016
+ id: e,
2017
+ from: o.from ?? n.from,
2018
+ to: o.to ?? n.to,
2019
+ shape: n.shape,
2020
+ priority: n.priority
2021
+ });
2022
+ }
2073
2023
  const r = this.edges.get(e);
2074
- r.priority = o, this.onAfterEdgePriorityUpdatedEmitter.emit(e);
2024
+ o.shape !== void 0 && (r.shape = o.shape, this.afterEdgeShapeUpdatedEmitter.emit(e)), o.priority !== void 0 && (r.priority = o.priority, this.afterEdgePriorityUpdatedEmitter.emit(e)), this.afterEdgeUpdatedEmitter.emit(e);
2075
2025
  }
2076
2026
  getAllEdgeIds() {
2077
2027
  return Array.from(this.edges.keys());
@@ -2080,10 +2030,10 @@ class Be {
2080
2030
  return this.edges.get(e);
2081
2031
  }
2082
2032
  removeEdge(e) {
2083
- this.onBeforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
2033
+ this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
2084
2034
  }
2085
2035
  clear() {
2086
- this.onBeforeClearEmitter.emit(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
2036
+ this.beforeClearEmitter.emit(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
2087
2037
  }
2088
2038
  getPortIncomingEdgeIds(e) {
2089
2039
  return Array.from(this.incommingEdges.get(e));
@@ -2142,22 +2092,24 @@ class Be {
2142
2092
  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
2093
  }
2144
2094
  }
2145
- const Z = (t) => ({
2095
+ const O = (t) => ({
2146
2096
  scale: 1 / t.scale,
2147
2097
  x: -t.x / t.scale,
2148
2098
  y: -t.y / t.scale
2149
- }), O = {
2099
+ }), q = {
2150
2100
  scale: 1,
2151
2101
  x: 0,
2152
2102
  y: 0
2153
2103
  };
2154
- class ke {
2104
+ class Be {
2155
2105
  constructor() {
2156
- i(this, "viewportMatrix", O);
2157
- i(this, "contentMatrix", O);
2158
- i(this, "emitter");
2159
- i(this, "onAfterUpdate");
2160
- [this.emitter, this.onAfterUpdate] = E();
2106
+ i(this, "viewportMatrix", q);
2107
+ i(this, "contentMatrix", q);
2108
+ i(this, "afterUpdateEmitter");
2109
+ i(this, "onAfterUpdated");
2110
+ i(this, "beforeUpdateEmitter");
2111
+ i(this, "onBeforeUpdated");
2112
+ [this.afterUpdateEmitter, this.onAfterUpdated] = A(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = A();
2161
2113
  }
2162
2114
  getViewportMatrix() {
2163
2115
  return this.viewportMatrix;
@@ -2166,22 +2118,55 @@ class ke {
2166
2118
  return this.contentMatrix;
2167
2119
  }
2168
2120
  patchViewportMatrix(e) {
2169
- this.viewportMatrix = {
2121
+ this.beforeUpdateEmitter.emit(), this.viewportMatrix = {
2170
2122
  scale: e.scale ?? this.viewportMatrix.scale,
2171
2123
  x: e.x ?? this.viewportMatrix.x,
2172
2124
  y: e.y ?? this.viewportMatrix.y
2173
- }, this.contentMatrix = Z(this.viewportMatrix), this.emitter.emit();
2125
+ }, this.contentMatrix = O(this.viewportMatrix), this.afterUpdateEmitter.emit();
2174
2126
  }
2175
2127
  patchContentMatrix(e) {
2176
- this.contentMatrix = {
2128
+ this.beforeUpdateEmitter.emit(), this.contentMatrix = {
2177
2129
  scale: e.scale ?? this.contentMatrix.scale,
2178
2130
  x: e.x ?? this.contentMatrix.x,
2179
2131
  y: e.y ?? this.contentMatrix.y
2180
- }, this.viewportMatrix = Z(this.contentMatrix), this.emitter.emit();
2132
+ }, this.viewportMatrix = O(this.contentMatrix), this.afterUpdateEmitter.emit();
2133
+ }
2134
+ }
2135
+ class j {
2136
+ constructor(e) {
2137
+ i(this, "elementToNodeId", /* @__PURE__ */ new Map());
2138
+ i(this, "nodesResizeObserver");
2139
+ i(this, "onAfterNodeAdded", (e) => {
2140
+ const o = this.canvas.graph.getNode(e);
2141
+ this.elementToNodeId.set(o.element, e), this.nodesResizeObserver.observe(o.element);
2142
+ });
2143
+ i(this, "onBeforeNodeRemoved", (e) => {
2144
+ const o = this.canvas.graph.getNode(e);
2145
+ this.elementToNodeId.delete(o.element), this.nodesResizeObserver.unobserve(o.element);
2146
+ });
2147
+ i(this, "onBeforeClear", () => {
2148
+ this.nodesResizeObserver.disconnect(), this.elementToNodeId.clear();
2149
+ });
2150
+ this.canvas = e, this.nodesResizeObserver = new ResizeObserver((o) => {
2151
+ o.forEach((r) => {
2152
+ const n = r.target;
2153
+ this.handleNodeResize(n);
2154
+ });
2155
+ }), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
2156
+ }
2157
+ static configure(e) {
2158
+ new j(e);
2159
+ }
2160
+ handleNodeResize(e) {
2161
+ const o = this.elementToNodeId.get(e);
2162
+ this.canvas.updateNode(o), this.canvas.graph.getNodeAdjacentEdgeIds(o).forEach((n) => {
2163
+ this.canvas.updateEdge(n);
2164
+ });
2181
2165
  }
2182
2166
  }
2183
- class Ye {
2167
+ class ze {
2184
2168
  constructor() {
2169
+ i(this, "element", null);
2185
2170
  i(this, "canvasDefaults", {});
2186
2171
  i(this, "dragOptions");
2187
2172
  i(this, "transformOptions");
@@ -2191,6 +2176,9 @@ class Ye {
2191
2176
  i(this, "hasResizeReactiveNodes", !1);
2192
2177
  i(this, "boxRenderingTrigger");
2193
2178
  }
2179
+ attach(e) {
2180
+ return this.element = e, this;
2181
+ }
2194
2182
  /**
2195
2183
  * specifies default values for graph entities
2196
2184
  */
@@ -2235,41 +2223,45 @@ class Ye {
2235
2223
  * builds final canvas
2236
2224
  */
2237
2225
  build() {
2226
+ if (this.element === null)
2227
+ throw new E(
2228
+ "unable to build canvas when no attach element specified"
2229
+ );
2238
2230
  let e = this.boxRenderingTrigger;
2239
- this.virtualScrollOptions !== void 0 && e === void 0 && (e = new ee());
2240
- const o = new Be(), r = new ke();
2231
+ this.virtualScrollOptions !== void 0 && e === void 0 && (e = new te());
2232
+ const o = new Fe(), r = new Be();
2241
2233
  let n = new Ae(o, r);
2242
- e !== void 0 && (n = new Se(n, o, e));
2243
- let h = new se(
2234
+ e !== void 0 && (n = new pe(n, o, e));
2235
+ let h = new ne(
2244
2236
  o,
2245
2237
  r,
2246
2238
  n
2247
2239
  );
2248
- this.hasResizeReactiveNodes && (h = new fe(h)), this.hasDraggableNode && (h = new he(
2240
+ this.hasDraggableNode && (h = new de(
2249
2241
  h,
2250
2242
  this.dragOptions
2251
- )), this.virtualScrollOptions !== void 0 ? h = new ye(
2243
+ )), this.virtualScrollOptions !== void 0 ? h = new fe(
2252
2244
  h,
2253
2245
  e,
2254
2246
  this.transformOptions,
2255
2247
  this.virtualScrollOptions
2256
- ) : this.hasTransformableViewport && (h = new q(
2248
+ ) : this.hasTransformableViewport && (h = new ee(
2257
2249
  h,
2258
2250
  this.transformOptions
2259
2251
  ));
2260
- const s = new Ue(h, this.canvasDefaults);
2261
- return this.reset(), s;
2252
+ const s = new We(this.element, h, this.canvasDefaults);
2253
+ return this.hasResizeReactiveNodes && j.configure(s), this.reset(), s;
2262
2254
  }
2263
2255
  reset() {
2264
- this.canvasDefaults = {}, this.dragOptions = void 0, this.transformOptions = void 0, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.boxRenderingTrigger = void 0;
2256
+ this.element = null, this.canvasDefaults = {}, this.dragOptions = void 0, this.transformOptions = void 0, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.boxRenderingTrigger = void 0;
2265
2257
  }
2266
2258
  }
2267
2259
  export {
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
2260
+ De as BezierEdgeShape,
2261
+ ze as CanvasBuilder,
2262
+ te as EventSubject,
2263
+ Ce as HorizontalEdgeShape,
2264
+ E as HtmlGraphError,
2265
+ Ue as StraightEdgeShape,
2266
+ $e as VerticalEdgeShape
2275
2267
  };