@html-graph/html-graph 2.5.0 → 3.0.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.
@@ -4,44 +4,19 @@ var i = (t, e, o) => re(t, typeof e != "symbol" ? e + "" : e, o);
4
4
  class ie {
5
5
  constructor(e) {
6
6
  i(this, "onAfterNodeAdded");
7
- /**
8
- * @deprecated
9
- * use onAfterNodeUpdated instead
10
- */
11
- i(this, "onAfterNodeCoordinatesUpdated");
12
7
  i(this, "onAfterNodeUpdated");
13
8
  i(this, "onAfterNodePriorityUpdated");
14
9
  i(this, "onBeforeNodeRemoved");
15
10
  i(this, "onAfterPortMarked");
16
- /**
17
- * @deprecated
18
- * use onAfterPortMarked instead
19
- */
20
- i(this, "onAfterPortAdded");
21
11
  i(this, "onAfterPortUpdated");
22
- /**
23
- * @deprecated
24
- * use onAfterPortUpdated instead
25
- */
26
- i(this, "onAfterPortDirectionUpdated");
27
12
  i(this, "onBeforePortUnmarked");
28
- /**
29
- * @deprecated
30
- * use onBeforePortUnmarked instead
31
- */
32
- i(this, "onBeforePortRemoved");
33
13
  i(this, "onAfterEdgeAdded");
34
14
  i(this, "onAfterEdgeShapeUpdated");
35
15
  i(this, "onAfterEdgeUpdated");
36
- /**
37
- * @deprecated
38
- * use onAfterEdgeUpdated instead
39
- */
40
- i(this, "onAfterEdgeAdjacentPortsUpdated");
41
16
  i(this, "onAfterEdgePriorityUpdated");
42
17
  i(this, "onBeforeEdgeRemoved");
43
18
  i(this, "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;
19
+ this.graphStore = e, this.onAfterNodeAdded = this.graphStore.onAfterNodeAdded, this.onAfterNodeUpdated = this.graphStore.onAfterNodeUpdated, this.onAfterNodePriorityUpdated = this.graphStore.onAfterNodePriorityUpdated, this.onBeforeNodeRemoved = this.graphStore.onBeforeNodeRemoved, this.onAfterPortMarked = this.graphStore.onAfterPortAdded, this.onAfterPortUpdated = this.graphStore.onAfterPortUpdated, this.onBeforePortUnmarked = this.graphStore.onBeforePortRemoved, this.onAfterEdgeAdded = this.graphStore.onAfterEdgeAdded, this.onAfterEdgeShapeUpdated = this.graphStore.onAfterEdgeShapeUpdated, this.onAfterEdgeUpdated = this.graphStore.onAfterEdgeUpdated, this.onAfterEdgePriorityUpdated = this.graphStore.onAfterEdgePriorityUpdated, this.onBeforeEdgeRemoved = this.graphStore.onBeforeEdgeRemoved, this.onBeforeClear = this.graphStore.onBeforeClear;
45
20
  }
46
21
  getNode(e) {
47
22
  const o = this.graphStore.getNode(e);
@@ -70,14 +45,6 @@ class ie {
70
45
  getNodePortIds(e) {
71
46
  return this.graphStore.getNodePortIds(e) ?? null;
72
47
  }
73
- /**
74
- * @deprecated
75
- * use graph.getPort()?.nodeId ?? null instead
76
- */
77
- getPortNodeId(e) {
78
- var o;
79
- return ((o = this.graphStore.getPort(e)) == null ? void 0 : o.nodeId) ?? null;
80
- }
81
48
  getAllEdgeIds() {
82
49
  return this.graphStore.getAllEdgeIds();
83
50
  }
@@ -179,12 +146,6 @@ class ne {
179
146
  this.onAfterEdgePriorityUpdated
180
147
  ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), this.graph = new ie(this.graphStore), this.viewport = new se(this.viewportStore);
181
148
  }
182
- attach(e) {
183
- this.htmlView.attach(e);
184
- }
185
- detach() {
186
- this.htmlView.detach();
187
- }
188
149
  addNode(e) {
189
150
  this.graphStore.addNode(e);
190
151
  }
@@ -232,18 +193,18 @@ class ne {
232
193
  }
233
194
  }
234
195
  const U = (t, e, o) => {
235
- const { x: r, y: n, width: h, height: s } = t.getBoundingClientRect();
236
- return e >= r && e <= r + h && o >= n && o <= n + s;
196
+ const { x: r, y: s, width: d, height: n } = t.getBoundingClientRect();
197
+ return e >= r && e <= r + d && o >= s && o <= s + n;
237
198
  }, $ = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, R = (t, e) => {
238
199
  e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
239
200
  }, he = (t) => {
240
- var g, f, x, v, S, p;
201
+ var g, f, x, y, p, S;
241
202
  const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
242
203
  }), 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) ?? (() => {
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;
204
+ }), s = (t == null ? void 0 : t.moveOnTop) === !1, d = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, n = d !== void 0 ? d : "grab", h = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseDownEventVerifier, c = h !== void 0 ? h : (N) => N.button === 0, a = (S = t == null ? void 0 : t.mouse) == null ? void 0 : S.mouseUpEventVerifier;
244
205
  return {
245
- freezePriority: n,
246
- dragCursor: s,
206
+ freezePriority: s,
207
+ dragCursor: n,
247
208
  mouseDownEventVerifier: c,
248
209
  mouseUpEventVerifier: a !== void 0 ? a : (N) => N.button === 0,
249
210
  onNodeDrag: e,
@@ -252,15 +213,14 @@ const U = (t, e, o) => {
252
213
  };
253
214
  };
254
215
  class de {
255
- constructor(e, o) {
216
+ constructor(e, o, r) {
256
217
  i(this, "graph");
257
218
  i(this, "viewport");
258
219
  i(this, "maxNodePriority", 0);
259
220
  i(this, "nodes", /* @__PURE__ */ new Map());
260
221
  i(this, "grabbedNodeId", null);
261
- i(this, "element", null);
262
222
  i(this, "onWindowMouseMove", (e) => {
263
- if (this.element !== null && (!U(this.element, e.clientX, e.clientY) || !$(this.window, e.clientX, e.clientY))) {
223
+ if (!U(this.element, e.clientX, e.clientY) || !$(this.window, e.clientX, e.clientY)) {
264
224
  this.cancelMouseDrag();
265
225
  return;
266
226
  }
@@ -273,13 +233,13 @@ class de {
273
233
  if (e.touches.length !== 1)
274
234
  return;
275
235
  const o = e.touches[0];
276
- if (this.element !== null && (!U(this.element, o.clientX, o.clientY) || !$(this.window, o.clientX, o.clientY))) {
236
+ if (!U(this.element, o.clientX, o.clientY) || !$(this.window, o.clientX, o.clientY)) {
277
237
  this.cancelTouchDrag();
278
238
  return;
279
239
  }
280
240
  if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
281
- const r = o.clientX - this.previousTouchCoords.x, n = o.clientY - this.previousTouchCoords.y;
282
- this.dragNode(this.grabbedNodeId, r, n), this.previousTouchCoords = {
241
+ const r = o.clientX - this.previousTouchCoords.x, s = o.clientY - this.previousTouchCoords.y;
242
+ this.dragNode(this.grabbedNodeId, r, s), this.previousTouchCoords = {
283
243
  x: e.touches[0].clientX,
284
244
  y: e.touches[0].clientY
285
245
  };
@@ -291,39 +251,33 @@ class de {
291
251
  i(this, "previousTouchCoords", null);
292
252
  i(this, "window", window);
293
253
  i(this, "options");
294
- this.canvas = e, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = he(o ?? {});
295
- }
296
- attach(e) {
297
- this.detach(), this.element = e, this.canvas.attach(this.element);
298
- }
299
- detach() {
300
- this.canvas.detach(), this.element !== null && (this.element = null);
254
+ this.canvas = e, this.element = o, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = he(r ?? {});
301
255
  }
302
256
  addNode(e) {
303
257
  this.canvas.addNode(e), this.updateMaxNodePriority(e.id);
304
- const o = (n) => {
305
- if (this.element === null || !this.options.mouseDownEventVerifier(n))
258
+ const o = (s) => {
259
+ if (!this.options.mouseDownEventVerifier(s))
306
260
  return;
307
- const h = this.graph.getNode(e.id);
261
+ const d = this.graph.getNode(e.id);
308
262
  this.options.onBeforeNodeDrag({
309
263
  nodeId: e.id,
310
264
  element: e.element,
311
- x: h.x,
312
- y: h.y
313
- }) && (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));
314
- }, r = (n) => {
315
- if (n.touches.length !== 1)
265
+ x: d.x,
266
+ y: d.y
267
+ }) && (s.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));
268
+ }, r = (s) => {
269
+ if (s.touches.length !== 1)
316
270
  return;
317
- n.stopImmediatePropagation(), this.previousTouchCoords = {
318
- x: n.touches[0].clientX,
319
- y: n.touches[0].clientY
271
+ s.stopImmediatePropagation(), this.previousTouchCoords = {
272
+ x: s.touches[0].clientX,
273
+ y: s.touches[0].clientY
320
274
  };
321
- const h = this.graph.getNode(e.id);
275
+ const d = this.graph.getNode(e.id);
322
276
  this.options.onBeforeNodeDrag({
323
277
  nodeId: e.id,
324
278
  element: e.element,
325
- x: h.x,
326
- y: h.y
279
+ x: d.x,
280
+ y: d.y
327
281
  }) && (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));
328
282
  };
329
283
  this.nodes.set(e.id, {
@@ -369,16 +323,16 @@ class de {
369
323
  }), this.nodes.clear(), this.maxNodePriority = 0;
370
324
  }
371
325
  destroy() {
372
- this.detach(), this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
326
+ this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
373
327
  }
374
328
  dragNode(e, o, r) {
375
- const n = this.graph.getNode(e);
376
- if (n === null)
329
+ const s = this.graph.getNode(e);
330
+ if (s === null)
377
331
  return;
378
- 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;
332
+ const d = this.canvas.viewport.getContentMatrix(), n = d.scale * s.x + d.x, h = d.scale * s.y + d.y, c = n + o, a = h + r, l = this.canvas.viewport.getViewportMatrix(), g = l.scale * c + l.x, f = l.scale * a + l.y;
379
333
  this.canvas.updateNode(e, { x: g, y: f }), this.options.onNodeDrag({
380
334
  nodeId: e,
381
- element: n.element,
335
+ element: s.element,
382
336
  x: g,
383
337
  y: f
384
338
  });
@@ -392,8 +346,8 @@ class de {
392
346
  return;
393
347
  this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
394
348
  const o = this.maxNodePriority - 1;
395
- this.graph.getNodeAdjacentEdgeIds(e).forEach((n) => {
396
- this.updateEdge(n, { priority: o });
349
+ this.graph.getNodeAdjacentEdgeIds(e).forEach((s) => {
350
+ this.updateEdge(s, { priority: o });
397
351
  });
398
352
  }
399
353
  cancelMouseDrag() {
@@ -403,7 +357,7 @@ class de {
403
357
  element: e.element,
404
358
  x: e.x,
405
359
  y: e.y
406
- }), this.grabbedNodeId = null, this.element !== null && R(this.element, null), this.removeMouseDragListeners();
360
+ }), this.grabbedNodeId = null, R(this.element, null), this.removeMouseDragListeners();
407
361
  }
408
362
  removeMouseDragListeners() {
409
363
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
@@ -423,29 +377,29 @@ class de {
423
377
  }
424
378
  }
425
379
  const ce = (t) => {
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;
427
- return (h) => {
428
- let s = h.nextTransform.x, d = h.nextTransform.y;
429
- s < e && s < h.prevTransform.x && (s = Math.min(h.prevTransform.x, e));
430
- const c = h.canvasWidth * h.prevTransform.scale, a = o - c;
431
- 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));
432
- const l = h.canvasHeight * h.prevTransform.scale, g = n - l;
433
- return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: s, y: d };
380
+ 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, s = t.maxY !== null ? t.maxY : 1 / 0;
381
+ return (d) => {
382
+ let n = d.nextTransform.x, h = d.nextTransform.y;
383
+ n < e && n < d.prevTransform.x && (n = Math.min(d.prevTransform.x, e));
384
+ const c = d.canvasWidth * d.prevTransform.scale, a = o - c;
385
+ n > a && n > d.prevTransform.x && (n = Math.max(d.prevTransform.x, a)), h < r && h < d.prevTransform.y && (h = Math.min(d.prevTransform.y, r));
386
+ const l = d.canvasHeight * d.prevTransform.scale, g = s - l;
387
+ return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x: n, y: h };
434
388
  };
435
389
  }, ae = (t) => {
436
- const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, n = o !== null ? 1 / o : 1 / 0;
437
- return (h) => {
438
- const s = h.prevTransform, d = h.nextTransform;
439
- let c = d.scale, a = d.x, l = d.y;
440
- if (d.scale > n && d.scale > s.scale) {
441
- c = Math.max(s.scale, n), a = s.x, l = s.y;
442
- const g = (c - s.scale) / (d.scale - s.scale);
443
- a = s.x + (d.x - s.x) * g, l = s.y + (d.y - s.y) * g;
390
+ const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
391
+ return (d) => {
392
+ const n = d.prevTransform, h = d.nextTransform;
393
+ let c = h.scale, a = h.x, l = h.y;
394
+ if (h.scale > s && h.scale > n.scale) {
395
+ c = Math.max(n.scale, s), a = n.x, l = n.y;
396
+ const g = (c - n.scale) / (h.scale - n.scale);
397
+ a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
444
398
  }
445
- if (d.scale < r && d.scale < s.scale) {
446
- c = Math.min(s.scale, r), a = s.x, l = s.y;
447
- const g = (c - s.scale) / (d.scale - s.scale);
448
- a = s.x + (d.x - s.x) * g, l = s.y + (d.y - s.y) * g;
399
+ if (h.scale < r && h.scale < n.scale) {
400
+ c = Math.min(n.scale, r), a = n.x, l = n.y;
401
+ const g = (c - n.scale) / (h.scale - n.scale);
402
+ a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
449
403
  }
450
404
  return {
451
405
  scale: c,
@@ -479,27 +433,27 @@ const ce = (t) => {
479
433
  });
480
434
  }
481
435
  }, 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;
484
- let n;
485
- r !== void 0 ? Array.isArray(r) ? n = le(
436
+ var y, p, S, N, z, M, V, L, G, _, J, K;
437
+ 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;
438
+ let s;
439
+ r !== void 0 ? Array.isArray(r) ? s = le(
486
440
  r.map(
487
- (b) => Q(b)
441
+ (P) => Q(P)
488
442
  )
489
- ) : n = Q(r) : n = (b) => b.nextTransform;
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) ?? (() => {
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;
443
+ ) : s = Q(r) : s = (P) => P.nextTransform;
444
+ const d = ((p = t == null ? void 0 : t.shift) == null ? void 0 : p.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((S = t == null ? void 0 : t.events) == null ? void 0 : S.onBeforeTransformChange) ?? (() => {
445
+ }), h = ((N = t == null ? void 0 : t.events) == null ? void 0 : N.onTransformChange) ?? (() => {
446
+ }), c = (z = t == null ? void 0 : t.shift) == null ? void 0 : z.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (M = t == null ? void 0 : t.shift) == null ? void 0 : M.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, f = (V = t == null ? void 0 : t.scale) == null ? void 0 : V.mouseWheelEventVerifier, x = f !== void 0 ? f : () => !0;
493
447
  return {
494
448
  wheelSensitivity: o,
495
449
  onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
496
450
  }),
497
451
  onTransformFinished: ((G = t == null ? void 0 : t.events) == null ? void 0 : G.onTransformFinished) ?? (() => {
498
452
  }),
499
- onBeforeTransformChange: s,
500
- onTransformChange: d,
501
- transformPreprocessor: n,
502
- shiftCursor: h,
453
+ onBeforeTransformChange: n,
454
+ onTransformChange: h,
455
+ transformPreprocessor: s,
456
+ shiftCursor: d,
503
457
  mouseDownEventVerifier: a,
504
458
  mouseUpEventVerifier: g,
505
459
  mouseWheelEventVerifier: x,
@@ -511,19 +465,19 @@ const ce = (t) => {
511
465
  };
512
466
  }, C = (t) => {
513
467
  const e = [], o = t.touches.length;
514
- for (let d = 0; d < o; d++)
515
- e.push([t.touches[d].clientX, t.touches[d].clientY]);
468
+ for (let h = 0; h < o; h++)
469
+ e.push([t.touches[h].clientX, t.touches[h].clientY]);
516
470
  const r = e.reduce(
517
- (d, c) => [d[0] + c[0], d[1] + c[1]],
471
+ (h, c) => [h[0] + c[0], h[1] + c[1]],
518
472
  [0, 0]
519
- ), n = [r[0] / o, r[1] / o], s = e.map((d) => [d[0] - n[0], d[1] - n[1]]).reduce(
520
- (d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
473
+ ), s = [r[0] / o, r[1] / o], n = e.map((h) => [h[0] - s[0], h[1] - s[1]]).reduce(
474
+ (h, c) => h + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
521
475
  0
522
476
  );
523
477
  return {
524
- x: n[0],
525
- y: n[1],
526
- scale: s / o,
478
+ x: s[0],
479
+ y: s[1],
480
+ scale: n / o,
527
481
  touchesCnt: o,
528
482
  touches: e
529
483
  };
@@ -537,10 +491,9 @@ const ce = (t) => {
537
491
  y: t.scale * (1 - e) * r + t.y
538
492
  });
539
493
  class ee {
540
- constructor(e, o) {
494
+ constructor(e, o, r) {
541
495
  i(this, "graph");
542
496
  i(this, "viewport");
543
- i(this, "element", null);
544
497
  i(this, "prevTouches", null);
545
498
  i(this, "window", window);
546
499
  i(this, "wheelFinishTimer", null);
@@ -553,7 +506,7 @@ class ee {
553
506
  return;
554
507
  }
555
508
  const o = -e.movementX, r = -e.movementY;
556
- this.moveViewport(this.element, o, r);
509
+ this.moveViewport(o, r);
557
510
  });
558
511
  i(this, "onWindowMouseUp", (e) => {
559
512
  this.element === null || !this.options.mouseUpEventVerifier(e) || this.stopMouseDrag();
@@ -562,8 +515,8 @@ class ee {
562
515
  if (!this.options.mouseWheelEventVerifier(e))
563
516
  return;
564
517
  e.preventDefault();
565
- 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);
566
- this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(this.element, d, n, h), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
518
+ const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o, d = e.clientY - r, h = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
519
+ this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(h, s, d), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
567
520
  this.options.onTransformFinished(), this.wheelFinishTimer = null;
568
521
  }, this.options.scaleWheelFinishTimeout);
569
522
  });
@@ -575,46 +528,36 @@ class ee {
575
528
  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();
576
529
  });
577
530
  i(this, "onWindowTouchMove", (e) => {
578
- const o = this.element;
579
- if (o === null)
580
- return;
581
- const r = C(e);
582
- if (!r.touches.every(
583
- (h) => U(o, h[0], h[1]) && $(this.window, h[0], h[1])
531
+ const o = C(e);
532
+ if (!o.touches.every(
533
+ (s) => U(this.element, s[0], s[1]) && $(this.window, s[0], s[1])
584
534
  )) {
585
535
  this.stopTouchDrag();
586
536
  return;
587
537
  }
588
- if ((r.touchesCnt === 1 || r.touchesCnt === 2) && this.moveViewport(
589
- o,
590
- -(r.x - this.prevTouches.x),
591
- -(r.y - this.prevTouches.y)
592
- ), r.touchesCnt === 2) {
593
- const { left: h, top: s } = o.getBoundingClientRect(), d = this.prevTouches.x - h, c = this.prevTouches.y - s, l = 1 / (r.scale / this.prevTouches.scale);
594
- this.scaleViewport(o, l, d, c);
538
+ if ((o.touchesCnt === 1 || o.touchesCnt === 2) && this.moveViewport(
539
+ -(o.x - this.prevTouches.x),
540
+ -(o.y - this.prevTouches.y)
541
+ ), o.touchesCnt === 2) {
542
+ const { left: s, top: d } = this.element.getBoundingClientRect(), n = this.prevTouches.x - s, h = this.prevTouches.y - d, a = 1 / (o.scale / this.prevTouches.scale);
543
+ this.scaleViewport(a, n, h);
595
544
  }
596
- this.prevTouches = r;
545
+ this.prevTouches = o;
597
546
  });
598
547
  i(this, "onWindowTouchFinish", (e) => {
599
548
  e.touches.length > 0 ? this.prevTouches = C(e) : this.stopTouchDrag();
600
549
  });
601
550
  i(this, "observer", new ResizeObserver(() => {
602
- const e = this.canvas.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
551
+ const e = this.canvas.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.options.transformPreprocessor({
603
552
  prevTransform: e,
604
553
  nextTransform: e,
605
554
  canvasWidth: o,
606
555
  canvasHeight: r
607
556
  });
608
- this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(n), this.options.onResizeTransformFinished();
557
+ this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.options.onResizeTransformFinished();
609
558
  }));
610
559
  i(this, "options");
611
- this.canvas = e, this.options = ge(o), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
612
- }
613
- attach(e) {
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);
615
- }
616
- detach() {
617
- 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);
560
+ this.canvas = e, this.element = o, this.options = ge(r), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart);
618
561
  }
619
562
  addNode(e) {
620
563
  this.canvas.addNode(e);
@@ -653,28 +596,28 @@ class ee {
653
596
  this.canvas.clear();
654
597
  }
655
598
  destroy() {
656
- this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
657
- }
658
- moveViewport(e, o, r) {
659
- const n = this.viewport.getViewportMatrix(), h = ue(n, o, r), { width: s, height: d } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
660
- prevTransform: n,
661
- nextTransform: h,
662
- canvasWidth: s,
663
- canvasHeight: d
664
- });
665
- this.performTransform(c);
599
+ this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.canvas.destroy();
666
600
  }
667
- scaleViewport(e, o, r, n) {
668
- const h = this.canvas.viewport.getViewportMatrix(), s = we(h, o, r, n), { width: d, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
669
- prevTransform: h,
601
+ moveViewport(e, o) {
602
+ const r = this.viewport.getViewportMatrix(), s = ue(r, e, o), { width: d, height: n } = this.element.getBoundingClientRect(), h = this.options.transformPreprocessor({
603
+ prevTransform: r,
670
604
  nextTransform: s,
671
605
  canvasWidth: d,
672
- canvasHeight: c
606
+ canvasHeight: n
673
607
  });
674
- this.performTransform(a);
608
+ this.performTransform(h);
609
+ }
610
+ scaleViewport(e, o, r) {
611
+ const s = this.canvas.viewport.getViewportMatrix(), d = we(s, e, o, r), { width: n, height: h } = this.element.getBoundingClientRect(), c = this.options.transformPreprocessor({
612
+ prevTransform: s,
613
+ nextTransform: d,
614
+ canvasWidth: n,
615
+ canvasHeight: h
616
+ });
617
+ this.performTransform(c);
675
618
  }
676
619
  stopMouseDrag() {
677
- this.element !== null && R(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
620
+ R(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
678
621
  }
679
622
  removeMouseDragListeners() {
680
623
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -690,11 +633,10 @@ class ee {
690
633
  }
691
634
  }
692
635
  class fe {
693
- constructor(e, o, r, n) {
636
+ constructor(e, o, r, s, d) {
694
637
  i(this, "graph");
695
638
  i(this, "viewport");
696
639
  i(this, "canvas");
697
- i(this, "element", null);
698
640
  i(this, "canvasResizeObserver");
699
641
  i(this, "window", window);
700
642
  i(this, "nodeHorizontal");
@@ -716,36 +658,31 @@ class fe {
716
658
  yTo: e.y + e.height
717
659
  };
718
660
  });
719
- var c, a;
720
- 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) => {
721
- const g = l[0];
722
- this.viewportWidth = g.contentRect.width, this.viewportHeight = g.contentRect.height, this.scheduleLoadAreaAroundViewport();
661
+ var a, l;
662
+ this.trigger = o, this.virtualScrollOptions = s, this.element = d, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new this.window.ResizeObserver((g) => {
663
+ const f = g[0];
664
+ this.viewportWidth = f.contentRect.width, this.viewportHeight = f.contentRect.height, this.scheduleLoadAreaAroundViewport();
723
665
  });
724
- const h = ((c = r == null ? void 0 : r.events) == null ? void 0 : c.onTransformFinished) ?? (() => {
725
- }), s = ((a = r == null ? void 0 : r.events) == null ? void 0 : a.onTransformChange) ?? (() => {
726
- }), d = {
666
+ const n = ((a = r == null ? void 0 : r.events) == null ? void 0 : a.onTransformFinished) ?? (() => {
667
+ }), h = ((l = r == null ? void 0 : r.events) == null ? void 0 : l.onTransformChange) ?? (() => {
668
+ }), c = {
727
669
  ...r,
728
670
  events: {
729
671
  ...r == null ? void 0 : r.events,
730
672
  onTransformChange: () => {
731
- const l = this.viewportMatrix;
732
- this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), l.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), s();
673
+ const g = this.viewportMatrix;
674
+ this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), g.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), h();
733
675
  },
734
676
  onTransformFinished: () => {
735
- this.scheduleLoadAreaAroundViewport(), h();
677
+ this.scheduleLoadAreaAroundViewport(), n();
736
678
  }
737
679
  }
738
680
  };
739
681
  this.canvas = new ee(
740
682
  e,
741
- d
742
- ), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.trigger.subscribe(this.updateLoadedArea);
743
- }
744
- attach(e) {
745
- this.detach(), this.element = e, this.canvasResizeObserver.observe(this.element), this.canvas.attach(e);
746
- }
747
- detach() {
748
- this.element !== null && (this.canvasResizeObserver.unobserve(this.element), this.element = null, this.viewportWidth = 0, this.viewportHeight = 0), this.canvas.detach();
683
+ this.element,
684
+ c
685
+ ), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element);
749
686
  }
750
687
  addNode(e) {
751
688
  this.canvas.addNode(e);
@@ -784,7 +721,7 @@ class fe {
784
721
  this.canvas.clear();
785
722
  }
786
723
  destroy() {
787
- this.trigger.unsubscribe(this.updateLoadedArea), this.canvas.destroy();
724
+ this.trigger.unsubscribe(this.updateLoadedArea), this.canvasResizeObserver.unobserve(this.element), this.canvas.destroy();
788
725
  }
789
726
  scheduleLoadAreaAroundViewport() {
790
727
  setTimeout(() => {
@@ -792,44 +729,35 @@ class fe {
792
729
  });
793
730
  }
794
731
  scheduleEnsureViewportAreaLoaded() {
795
- 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;
796
- this.loadedArea.xFrom < r && this.loadedArea.xTo > h && this.loadedArea.yFrom < n && this.loadedArea.yTo > s || this.scheduleLoadAreaAroundViewport();
732
+ const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal, s = this.viewportMatrix.y - this.nodeVertical, d = this.viewportMatrix.x + e + this.nodeHorizontal, n = this.viewportMatrix.y + o + this.nodeVertical;
733
+ this.loadedArea.xFrom < r && this.loadedArea.xTo > d && this.loadedArea.yFrom < s && this.loadedArea.yTo > n || this.scheduleLoadAreaAroundViewport();
797
734
  }
798
735
  loadAreaAroundViewport() {
799
- 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;
800
- this.trigger.emit({ x: r, y: n, width: h, height: s });
736
+ const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - e - this.nodeHorizontal, s = this.viewportMatrix.y - o - this.nodeVertical, d = 3 * e + 2 * this.nodeHorizontal, n = 3 * o + 2 * this.nodeVertical;
737
+ this.trigger.emit({ x: r, y: s, width: d, height: n });
801
738
  }
802
739
  }
803
- const ve = () => {
740
+ const ye = () => {
804
741
  const t = document.createElement("div");
805
742
  return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
806
- }, ye = () => {
743
+ }, ve = () => {
807
744
  const t = document.createElement("div");
808
745
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
809
746
  }, xe = () => {
810
747
  const t = document.createElement("div");
811
748
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
812
749
  };
813
- class Ae {
814
- constructor(e, o) {
815
- i(this, "canvasWrapper", null);
816
- i(this, "host", ve());
817
- i(this, "container", ye());
750
+ class Ee {
751
+ constructor(e, o, r) {
752
+ i(this, "host", ye());
753
+ i(this, "container", ve());
818
754
  i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
819
755
  i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
820
756
  i(this, "applyTransform", () => {
821
757
  const e = this.viewportStore.getContentMatrix();
822
758
  this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
823
759
  });
824
- this.graphStore = e, this.viewportStore = o, this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
825
- }
826
- attach(e) {
827
- this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host), this.graphStore.getAllEdgeIds().forEach((o) => {
828
- this.renderEdge(o);
829
- });
830
- }
831
- detach() {
832
- this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
760
+ this.graphStore = e, this.viewportStore = o, this.element = r, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
833
761
  }
834
762
  attachNode(e) {
835
763
  const o = this.graphStore.getNode(e), r = xe();
@@ -855,10 +783,10 @@ class Ae {
855
783
  });
856
784
  }
857
785
  destroy() {
858
- this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.detach(), this.host.removeChild(this.container);
786
+ this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
859
787
  }
860
788
  updateNodePosition(e) {
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;
789
+ const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width: s, height: d } = r.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, h = r.centerFn(s, d), c = r.x - n * h.x, a = r.y - n * h.y;
862
790
  o.style.transform = `translate(${c}px, ${a}px)`;
863
791
  }
864
792
  updateNodePriority(e) {
@@ -872,28 +800,28 @@ class Ae {
872
800
  this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg);
873
801
  }
874
802
  renderEdge(e) {
875
- 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 = {
876
- x: c.scale * (h.left - d.left) + c.x,
877
- y: c.scale * (h.top - d.top) + c.y
803
+ const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), d = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = {
804
+ x: c.scale * (d.left - h.left) + c.x,
805
+ y: c.scale * (d.top - h.top) + c.y
878
806
  }, l = {
879
- x: c.scale * (s.left - d.left) + c.x,
880
- y: c.scale * (s.top - d.top) + c.y
807
+ x: c.scale * (n.left - h.left) + c.x,
808
+ y: c.scale * (n.top - h.top) + c.y
881
809
  }, g = {
882
810
  x: a.x,
883
811
  y: a.y,
884
- width: h.width * c.scale,
885
- height: h.height * c.scale,
812
+ width: d.width * c.scale,
813
+ height: d.height * c.scale,
886
814
  direction: r.direction,
887
815
  portId: o.from,
888
816
  nodeId: r.nodeId
889
817
  }, f = {
890
818
  x: l.x,
891
819
  y: l.y,
892
- width: s.width * c.scale,
893
- height: s.height * c.scale,
894
- direction: n.direction,
820
+ width: n.width * c.scale,
821
+ height: n.height * c.scale,
822
+ direction: s.direction,
895
823
  portId: o.to,
896
- nodeId: n.nodeId
824
+ nodeId: s.nodeId
897
825
  };
898
826
  o.shape.render({
899
827
  from: g,
@@ -905,7 +833,7 @@ class Ae {
905
833
  o.shape.svg.style.zIndex = `${o.priority}`;
906
834
  }
907
835
  }
908
- class Ee {
836
+ class Ae {
909
837
  constructor(e) {
910
838
  i(this, "xFrom", 1 / 0);
911
839
  i(this, "yFrom", 1 / 0);
@@ -921,41 +849,35 @@ class Ee {
921
849
  return o.x >= this.xFrom && o.x <= this.xTo && o.y >= this.yFrom && o.y <= this.yTo;
922
850
  }
923
851
  hasEdge(e) {
924
- 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);
925
- return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
852
+ const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId, d = this.graphStore.getNode(r), n = this.graphStore.getNode(s), h = Math.min(d.x, n.x), c = Math.max(d.x, n.x), a = Math.min(d.y, n.y), l = Math.max(d.y, n.y);
853
+ return h <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
926
854
  }
927
855
  }
928
- class pe {
856
+ class Se {
929
857
  constructor(e, o, r) {
930
858
  i(this, "attachedNodes", /* @__PURE__ */ new Set());
931
859
  i(this, "attachedEdges", /* @__PURE__ */ new Set());
932
860
  i(this, "renderingBox");
933
861
  i(this, "updateViewport", (e) => {
934
862
  this.renderingBox.setRenderingBox(e);
935
- const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
936
- this.graphStore.getAllNodeIds().forEach((s) => {
937
- const d = this.renderingBox.hasNode(s), c = this.attachedNodes.has(s);
938
- d && !c ? o.add(s) : !d && c && r.add(s);
939
- }), this.graphStore.getAllEdgeIds().forEach((s) => {
940
- 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;
941
- 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);
942
- }), h.forEach((s) => {
943
- this.handleDetachEdge(s);
944
- }), r.forEach((s) => {
945
- this.handleDetachNode(s);
946
- }), o.forEach((s) => {
947
- this.attachedNodes.has(s) || this.handleAttachNode(s);
948
- }), n.forEach((s) => {
949
- this.handleAttachEdge(s);
863
+ const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
864
+ this.graphStore.getAllNodeIds().forEach((n) => {
865
+ const h = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
866
+ h && !c ? o.add(n) : !h && c && r.add(n);
867
+ }), this.graphStore.getAllEdgeIds().forEach((n) => {
868
+ const h = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
869
+ h && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), h && !c ? s.add(n) : !h && c && d.add(n);
870
+ }), d.forEach((n) => {
871
+ this.handleDetachEdge(n);
872
+ }), r.forEach((n) => {
873
+ this.handleDetachNode(n);
874
+ }), o.forEach((n) => {
875
+ this.attachedNodes.has(n) || this.handleAttachNode(n);
876
+ }), s.forEach((n) => {
877
+ this.handleAttachEdge(n);
950
878
  });
951
879
  });
952
- this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new Ee(this.graphStore), this.trigger.subscribe(this.updateViewport);
953
- }
954
- attach(e) {
955
- this.htmlView.attach(e);
956
- }
957
- detach() {
958
- this.htmlView.detach();
880
+ this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new Ae(this.graphStore), this.trigger.subscribe(this.updateViewport);
959
881
  }
960
882
  attachNode(e) {
961
883
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -993,8 +915,8 @@ class pe {
993
915
  this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
994
916
  }
995
917
  attachEdgeEntities(e) {
996
- const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, n = this.graphStore.getPort(o.to).nodeId;
997
- this.attachedNodes.has(r) || this.handleAttachNode(r), this.attachedNodes.has(n) || this.handleAttachNode(n), this.handleAttachEdge(e);
918
+ const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId;
919
+ this.attachedNodes.has(r) || this.handleAttachNode(r), this.attachedNodes.has(s) || this.handleAttachNode(s), this.handleAttachEdge(e);
998
920
  }
999
921
  handleAttachNode(e) {
1000
922
  this.attachedNodes.add(e), this.htmlView.attachNode(e);
@@ -1025,11 +947,11 @@ class te {
1025
947
  });
1026
948
  }
1027
949
  }
1028
- const A = () => {
950
+ const E = () => {
1029
951
  const t = new te();
1030
952
  return [t, t];
1031
953
  };
1032
- class z {
954
+ class Y {
1033
955
  constructor(e) {
1034
956
  i(this, "counter", 0);
1035
957
  this.checkExists = e;
@@ -1045,53 +967,53 @@ class z {
1045
967
  this.counter = 0;
1046
968
  }
1047
969
  }
1048
- class E extends Error {
970
+ class A extends Error {
1049
971
  constructor() {
1050
972
  super(...arguments);
1051
973
  i(this, "name", "HtmlGraphError");
1052
974
  }
1053
975
  }
1054
- const Se = (t, e) => ({
976
+ const pe = (t, e) => ({
1055
977
  x: t / 2,
1056
978
  y: e / 2
1057
- }), Y = (t) => () => t, Z = Y(0), Ne = () => {
979
+ }), k = (t) => () => t, Z = k(0), Ne = () => {
1058
980
  let t = 0;
1059
981
  return () => t++;
1060
- }, me = (t, e) => {
982
+ }, Te = (t, e) => {
1061
983
  let o = Z, r = Z;
1062
- const n = Ne();
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), {
984
+ const s = Ne();
985
+ return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = k(t)), typeof e == "number" && (r = k(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
1064
986
  nodesPriorityFn: o,
1065
987
  edgesPriorityFn: r
1066
988
  };
1067
- }, y = (t, e, o) => ({
989
+ }, v = (t, e, o) => ({
1068
990
  x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
1069
991
  y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
1070
- }), m = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
992
+ }), T = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
1071
993
  x: 0,
1072
994
  y: 0
1073
- }, T = (t, e, o, r) => {
1074
- const h = [
995
+ }, m = (t, e, o, r) => {
996
+ const d = [
1075
997
  w,
1076
998
  { x: o, y: r },
1077
999
  { x: o, y: -r }
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}`;
1079
- return `${s} ${d} ${c}`;
1000
+ ].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${d[0].x} ${d[0].y}`, h = `L ${d[1].x} ${d[1].y}`, c = `L ${d[2].x} ${d[2].y}`;
1001
+ return `${n} ${h} ${c}`;
1080
1002
  }, D = (t, e) => {
1081
1003
  const o = [];
1082
1004
  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) {
1083
1005
  const r = t.length - 1;
1084
- let n = 0, h = 0, s = 0;
1085
- t.forEach((d, c) => {
1006
+ let s = 0, d = 0, n = 0;
1007
+ t.forEach((h, c) => {
1086
1008
  let a = 0, l = 0, g = 0;
1087
- const f = c > 0, x = c < r, v = f && x;
1088
- if (f && (a = -n, l = -h, g = s), x) {
1009
+ const f = c > 0, x = c < r, y = f && x;
1010
+ if (f && (a = -s, l = -d, g = n), x) {
1089
1011
  const L = t[c + 1];
1090
- n = L.x - d.x, h = L.y - d.y, s = Math.sqrt(n * n + h * h);
1012
+ s = L.x - h.x, d = L.y - h.y, n = Math.sqrt(s * s + d * d);
1091
1013
  }
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}`
1014
+ const S = n !== 0 ? Math.min((y ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, N = y ? { x: h.x + s * S, y: h.y + d * S } : h, M = g !== 0 ? Math.min((y ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, V = y ? { x: h.x + a * M, y: h.y + l * M } : h;
1015
+ c > 0 && o.push(`L ${V.x} ${V.y}`), y && o.push(
1016
+ `C ${h.x} ${h.y} ${h.x} ${h.y} ${N.x} ${N.y}`
1095
1017
  );
1096
1018
  });
1097
1019
  }
@@ -1105,7 +1027,7 @@ const Se = (t, e) => ({
1105
1027
  }, F = (t, e) => {
1106
1028
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
1107
1029
  return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
1108
- }, P = (t) => {
1030
+ }, b = (t) => {
1109
1031
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1110
1032
  return e.setAttribute("fill", t), e;
1111
1033
  }, B = (t, e) => {
@@ -1115,174 +1037,174 @@ const Se = (t, e) => ({
1115
1037
  }, r = {
1116
1038
  x: e.x + e.width / 2,
1117
1039
  y: e.y + e.height / 2
1118
- }, 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;
1040
+ }, s = Math.min(o.x, r.x), d = Math.min(o.y, r.y), n = Math.abs(r.x - o.x), h = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
1119
1041
  return {
1120
- x: n,
1121
- y: h,
1122
- width: s,
1123
- height: d,
1042
+ x: s,
1043
+ y: d,
1044
+ width: n,
1045
+ height: h,
1124
1046
  flipX: c,
1125
1047
  flipY: a
1126
1048
  };
1127
- }, Te = (t) => {
1128
- const e = y(
1049
+ }, me = (t) => {
1050
+ const e = v(
1129
1051
  { x: t.arrowLength, y: w.y },
1130
1052
  t.fromVect,
1131
1053
  w
1132
- ), o = y(
1054
+ ), o = v(
1133
1055
  { x: t.to.x - t.arrowLength, y: t.to.y },
1134
1056
  t.toVect,
1135
1057
  t.to
1136
1058
  ), r = {
1137
1059
  x: e.x + t.fromVect.x * t.curvature,
1138
1060
  y: e.y + t.fromVect.y * t.curvature
1139
- }, n = {
1061
+ }, s = {
1140
1062
  x: o.x - t.toVect.x * t.curvature,
1141
1063
  y: o.y - t.toVect.y * t.curvature
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}`;
1143
- return `${s}${h}${d}`;
1144
- }, Pe = (t) => {
1145
- const e = t.hasSourceArrow ? y(
1064
+ }, d = `M ${e.x} ${e.y} C ${r.x} ${r.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, h = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
1065
+ return `${n}${d}${h}`;
1066
+ }, be = (t) => {
1067
+ const e = t.hasSourceArrow ? v(
1146
1068
  { x: t.arrowLength, y: w.y },
1147
1069
  t.fromVect,
1148
1070
  w
1149
- ) : w, o = t.hasTargetArrow ? y(
1071
+ ) : w, o = t.hasTargetArrow ? v(
1150
1072
  { x: t.to.x - t.arrowLength, y: t.to.y },
1151
1073
  t.toVect,
1152
1074
  t.to
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(
1075
+ ) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, d = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, h = d * t.flipY, c = v(
1154
1076
  { x: r, y: w.y },
1155
1077
  t.fromVect,
1156
1078
  w
1157
1079
  ), a = {
1158
- x: c.x + s,
1159
- y: c.y + d
1160
- }, l = y(
1080
+ x: c.x + n,
1081
+ y: c.y + h
1082
+ }, l = v(
1161
1083
  { x: t.to.x - r, y: t.to.y },
1162
1084
  t.toVect,
1163
1085
  t.to
1164
1086
  ), g = {
1165
- x: l.x + s,
1166
- y: l.y + d
1087
+ x: l.x + n,
1088
+ y: l.y + h
1167
1089
  }, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, x = {
1168
1090
  x: c.x + t.curvature * t.fromVect.x,
1169
1091
  y: c.y + t.curvature * t.fromVect.y
1170
- }, v = {
1092
+ }, y = {
1171
1093
  x: l.x - t.curvature * t.toVect.x,
1172
1094
  y: l.y - t.curvature * t.toVect.y
1173
- }, S = {
1174
- x: c.x + s,
1175
- y: c.y + d
1176
1095
  }, p = {
1177
- x: l.x + s,
1178
- y: l.y + d
1096
+ x: c.x + n,
1097
+ y: c.y + h
1098
+ }, S = {
1099
+ x: l.x + n,
1100
+ y: l.y + h
1179
1101
  };
1180
1102
  return [
1181
1103
  `M ${e.x} ${e.y}`,
1182
1104
  `L ${c.x} ${c.y}`,
1183
- `C ${x.x} ${x.y} ${S.x} ${S.y} ${f.x} ${f.y}`,
1184
- `C ${p.x} ${p.y} ${v.x} ${v.y} ${l.x} ${l.y}`,
1105
+ `C ${x.x} ${x.y} ${p.x} ${p.y} ${f.x} ${f.y}`,
1106
+ `C ${S.x} ${S.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
1185
1107
  `L ${o.x} ${o.y}`
1186
1108
  ].join(" ");
1187
- }, be = (t) => {
1188
- const e = t.hasSourceArrow ? y(
1109
+ }, Pe = (t) => {
1110
+ const e = t.hasSourceArrow ? v(
1189
1111
  { x: t.arrowLength, y: w.y },
1190
1112
  t.fromVect,
1191
1113
  w
1192
- ) : w, o = t.hasTargetArrow ? y(
1114
+ ) : w, o = t.hasTargetArrow ? v(
1193
1115
  { x: t.to.x - t.arrowLength, y: t.to.y },
1194
1116
  t.toVect,
1195
1117
  t.to
1196
- ) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, h = y({ x: n, y: w.y }, t.fromVect, w), s = y(
1197
- { x: t.to.x - n, y: t.to.y },
1118
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = v({ x: s, y: w.y }, t.fromVect, w), n = v(
1119
+ { x: t.to.x - s, y: t.to.y },
1198
1120
  t.toVect,
1199
1121
  t.to
1200
- ), 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 = {
1201
- x: t.flipX > 0 ? t.to.x - d : t.to.x + r,
1202
- y: s.y
1122
+ ), h = Math.max((d.x + n.x) / 2, r), c = t.to.y / 2, a = { x: t.flipX > 0 ? h : -r, y: d.y }, l = { x: a.x, y: c }, g = {
1123
+ x: t.flipX > 0 ? t.to.x - h : t.to.x + r,
1124
+ y: n.y
1203
1125
  }, f = { x: g.x, y: c };
1204
1126
  return D(
1205
- [e, h, a, l, f, g, s, o],
1127
+ [e, d, a, l, f, g, n, o],
1206
1128
  t.roundness
1207
1129
  );
1208
1130
  }, X = (t) => {
1209
- const e = t.hasSourceArrow ? y(
1131
+ const e = t.hasSourceArrow ? v(
1210
1132
  { x: t.arrowLength, y: w.y },
1211
1133
  t.fromVect,
1212
1134
  w
1213
- ) : w, o = t.hasTargetArrow ? y(
1135
+ ) : w, o = t.hasTargetArrow ? v(
1214
1136
  { x: t.to.x - t.arrowLength, y: t.to.y },
1215
1137
  t.toVect,
1216
1138
  t.to
1217
- ) : t.to, r = t.arrowLength + t.arrowOffset, n = y(
1139
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = v(
1218
1140
  { x: r, y: w.y },
1219
1141
  t.fromVect,
1220
1142
  w
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(
1143
+ ), d = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, h = d * t.flipX, c = n * t.flipY, a = { x: s.x + h, y: s.y + c }, l = v(
1222
1144
  { x: t.to.x - r, y: t.to.y },
1223
1145
  t.toVect,
1224
1146
  t.to
1225
- ), g = { x: l.x + d, y: l.y + c };
1147
+ ), g = { x: l.x + h, y: l.y + c };
1226
1148
  return D(
1227
- [e, n, a, g, l, o],
1149
+ [e, s, a, g, l, o],
1228
1150
  t.roundness
1229
1151
  );
1230
1152
  }, Me = (t) => {
1231
- const e = t.hasSourceArrow ? y(
1153
+ const e = t.hasSourceArrow ? v(
1232
1154
  { x: t.arrowLength, y: w.y },
1233
1155
  t.fromVect,
1234
1156
  w
1235
- ) : w, o = t.hasTargetArrow ? y(
1157
+ ) : w, o = t.hasTargetArrow ? v(
1236
1158
  { x: t.to.x - t.arrowLength, y: t.to.y },
1237
1159
  t.toVect,
1238
1160
  t.to
1239
- ) : t.to, r = t.arrowLength + t.arrowOffset, n = y({ x: r, y: w.y }, t.fromVect, w), h = y(
1161
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = v({ x: r, y: w.y }, t.fromVect, w), d = v(
1240
1162
  { x: t.to.x - r, y: t.to.y },
1241
1163
  t.toVect,
1242
1164
  t.to
1243
1165
  );
1244
- return D([e, n, h, o], t.roundness);
1166
+ return D([e, s, d, o], t.roundness);
1245
1167
  }, Ve = (t) => {
1246
- const e = t.hasSourceArrow ? y(
1168
+ const e = t.hasSourceArrow ? v(
1247
1169
  { x: t.arrowLength, y: w.y },
1248
1170
  t.fromVect,
1249
1171
  w
1250
- ) : w, o = t.hasTargetArrow ? y(
1172
+ ) : w, o = t.hasTargetArrow ? v(
1251
1173
  { x: t.to.x - t.arrowLength, y: t.to.y },
1252
1174
  t.toVect,
1253
1175
  t.to
1254
- ) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, h = y({ x: n, y: w.y }, t.fromVect, w), s = y(
1255
- { x: t.to.x - n, y: t.to.y },
1176
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = v({ x: s, y: w.y }, t.fromVect, w), n = v(
1177
+ { x: t.to.x - s, y: t.to.y },
1256
1178
  t.toVect,
1257
1179
  t.to
1258
- ), 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 = {
1259
- x: s.x,
1260
- y: t.flipY > 0 ? t.to.y - d : t.to.y + r
1180
+ ), h = Math.max((d.y + n.y) / 2, r), c = t.to.x / 2, a = { x: d.x, y: t.flipY > 0 ? h : -r }, l = { x: c, y: a.y }, g = {
1181
+ x: n.x,
1182
+ y: t.flipY > 0 ? t.to.y - h : t.to.y + r
1261
1183
  }, f = { x: c, y: g.y };
1262
1184
  return D(
1263
- [e, h, a, l, f, g, s, o],
1185
+ [e, d, a, l, f, g, n, o],
1264
1186
  t.roundness
1265
1187
  );
1266
1188
  }, H = (t) => {
1267
- const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, n = r + 2 * o, s = [
1189
+ const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, s = r + 2 * o, n = [
1268
1190
  { x: t.arrowLength, y: w.y },
1269
1191
  { x: r, y: w.y },
1270
1192
  { x: r, y: t.side },
1271
- { x: n, y: t.side },
1272
- { x: n, y: -t.side },
1193
+ { x: s, y: t.side },
1194
+ { x: s, y: -t.side },
1273
1195
  { x: r, y: -t.side },
1274
1196
  { x: r, y: w.y },
1275
1197
  { x: t.arrowLength, y: w.y }
1276
1198
  ].map(
1277
- (c) => y(c, t.fromVect, w)
1278
- ), d = `M ${w.x} ${w.y} L ${s[0].x} ${s[0].y} `;
1279
- return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${D(s, t.roundness)}`;
1199
+ (c) => v(c, t.fromVect, w)
1200
+ ), h = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
1201
+ return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${D(n, t.roundness)}`;
1280
1202
  }, Le = (t) => {
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 = [
1203
+ const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o, d = t.arrowLength + r * (1 - o / s), n = e * o / s, c = [
1282
1204
  { x: t.arrowLength, y: w.y },
1283
- { x: h, y: s },
1284
- { x: h, y: -s }
1285
- ].map((g) => y(g, t.fromVect, w)), a = [
1205
+ { x: d, y: n },
1206
+ { x: d, y: -n }
1207
+ ].map((g) => v(g, t.fromVect, w)), a = [
1286
1208
  `M ${c[0].x} ${c[0].y}`,
1287
1209
  `A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
1288
1210
  `A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
@@ -1324,21 +1246,21 @@ class De {
1324
1246
  i(this, "hasTargetArrow");
1325
1247
  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;
1326
1248
  const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
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));
1249
+ this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(o), this.group.appendChild(this.targetArrow));
1328
1250
  }
1329
1251
  render(e) {
1330
- const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
1252
+ const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = B(
1331
1253
  e.from,
1332
1254
  e.to
1333
1255
  );
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})`;
1335
- const c = m(
1256
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
1257
+ const c = T(
1336
1258
  e.from.direction,
1337
- s,
1338
- d
1339
- ), a = m(e.to.direction, s, d), l = {
1340
- x: n,
1341
- y: h
1259
+ n,
1260
+ h
1261
+ ), a = T(e.to.direction, n, h), l = {
1262
+ x: s,
1263
+ y: d
1342
1264
  };
1343
1265
  let g, f = a, x = -this.arrowLength;
1344
1266
  if (e.from.portId === e.to.portId ? (g = Le({
@@ -1348,19 +1270,19 @@ class De {
1348
1270
  arrowLength: this.arrowLength,
1349
1271
  hasSourceArrow: this.hasSourceArrow,
1350
1272
  hasTargetArrow: this.hasTargetArrow
1351
- }), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = Pe({
1273
+ }), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = be({
1352
1274
  to: l,
1353
1275
  fromVect: c,
1354
1276
  toVect: a,
1355
- flipX: s,
1356
- flipY: d,
1277
+ flipX: n,
1278
+ flipY: h,
1357
1279
  arrowLength: this.arrowLength,
1358
1280
  detourDirection: this.detourDirection,
1359
1281
  detourDistance: this.detourDistance,
1360
1282
  curvature: this.curvature,
1361
1283
  hasSourceArrow: this.hasSourceArrow,
1362
1284
  hasTargetArrow: this.hasTargetArrow
1363
- }) : g = Te({
1285
+ }) : g = me({
1364
1286
  to: l,
1365
1287
  fromVect: c,
1366
1288
  toVect: a,
@@ -1369,22 +1291,22 @@ class De {
1369
1291
  hasSourceArrow: this.hasSourceArrow,
1370
1292
  hasTargetArrow: this.hasTargetArrow
1371
1293
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1372
- const v = T(
1294
+ const y = m(
1373
1295
  c,
1374
1296
  w,
1375
1297
  this.arrowLength,
1376
1298
  this.arrowWidth
1377
1299
  );
1378
- this.sourceArrow.setAttribute("d", v);
1300
+ this.sourceArrow.setAttribute("d", y);
1379
1301
  }
1380
1302
  if (this.targetArrow) {
1381
- const v = T(
1303
+ const y = m(
1382
1304
  f,
1383
1305
  l,
1384
1306
  x,
1385
1307
  this.arrowWidth
1386
1308
  );
1387
- this.targetArrow.setAttribute("d", v);
1309
+ this.targetArrow.setAttribute("d", y);
1388
1310
  }
1389
1311
  }
1390
1312
  }
@@ -1411,22 +1333,22 @@ class Ce {
1411
1333
  this.arrowOffset,
1412
1334
  this.cycleSquareSide / 2
1413
1335
  ), 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;
1414
- const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
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));
1336
+ const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
1337
+ this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(r), this.group.appendChild(this.targetArrow));
1416
1338
  }
1417
1339
  render(e) {
1418
- const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
1340
+ const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = B(
1419
1341
  e.from,
1420
1342
  e.to
1421
1343
  );
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})`;
1423
- const c = m(
1344
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
1345
+ const c = T(
1424
1346
  e.from.direction,
1425
- s,
1426
- d
1427
- ), a = m(e.to.direction, s, d), l = {
1428
- x: n,
1429
- y: h
1347
+ n,
1348
+ h
1349
+ ), a = T(e.to.direction, n, h), l = {
1350
+ x: s,
1351
+ y: d
1430
1352
  };
1431
1353
  let g, f = a, x = -this.arrowLength;
1432
1354
  if (e.from.portId === e.to.portId ? (g = H({
@@ -1441,8 +1363,8 @@ class Ce {
1441
1363
  to: l,
1442
1364
  fromVect: c,
1443
1365
  toVect: a,
1444
- flipX: s,
1445
- flipY: d,
1366
+ flipX: n,
1367
+ flipY: h,
1446
1368
  arrowLength: this.arrowLength,
1447
1369
  arrowOffset: this.arrowOffset,
1448
1370
  roundness: this.roundness,
@@ -1450,33 +1372,33 @@ class Ce {
1450
1372
  detourDistance: this.detourDistance,
1451
1373
  hasSourceArrow: this.hasSourceArrow,
1452
1374
  hasTargetArrow: this.hasTargetArrow
1453
- }) : g = be({
1375
+ }) : g = Pe({
1454
1376
  to: l,
1455
1377
  fromVect: c,
1456
1378
  toVect: a,
1457
- flipX: s,
1379
+ flipX: n,
1458
1380
  arrowLength: this.arrowLength,
1459
1381
  arrowOffset: this.arrowOffset,
1460
1382
  roundness: this.roundness,
1461
1383
  hasSourceArrow: this.hasSourceArrow,
1462
1384
  hasTargetArrow: this.hasTargetArrow
1463
1385
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1464
- const v = T(
1386
+ const y = m(
1465
1387
  c,
1466
1388
  w,
1467
1389
  this.arrowLength,
1468
1390
  this.arrowWidth
1469
1391
  );
1470
- this.sourceArrow.setAttribute("d", v);
1392
+ this.sourceArrow.setAttribute("d", y);
1471
1393
  }
1472
1394
  if (this.targetArrow) {
1473
- const v = T(
1395
+ const y = m(
1474
1396
  f,
1475
1397
  l,
1476
1398
  x,
1477
1399
  this.arrowWidth
1478
1400
  );
1479
- this.targetArrow.setAttribute("d", v);
1401
+ this.targetArrow.setAttribute("d", y);
1480
1402
  }
1481
1403
  }
1482
1404
  }
@@ -1503,22 +1425,22 @@ class Ue {
1503
1425
  this.arrowOffset,
1504
1426
  this.cycleSquareSide / 2
1505
1427
  ), 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;
1506
- const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
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));
1428
+ const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
1429
+ this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(r), this.group.appendChild(this.targetArrow));
1508
1430
  }
1509
1431
  render(e) {
1510
- const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
1432
+ const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = B(
1511
1433
  e.from,
1512
1434
  e.to
1513
1435
  );
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})`;
1515
- const c = m(
1436
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
1437
+ const c = T(
1516
1438
  e.from.direction,
1517
- s,
1518
- d
1519
- ), a = m(e.to.direction, s, d), l = {
1520
- x: n,
1521
- y: h
1439
+ n,
1440
+ h
1441
+ ), a = T(e.to.direction, n, h), l = {
1442
+ x: s,
1443
+ y: d
1522
1444
  };
1523
1445
  let g, f = a, x = -this.arrowLength;
1524
1446
  if (e.from.portId === e.to.portId ? (g = H({
@@ -1533,8 +1455,8 @@ class Ue {
1533
1455
  to: l,
1534
1456
  fromVect: c,
1535
1457
  toVect: a,
1536
- flipX: s,
1537
- flipY: d,
1458
+ flipX: n,
1459
+ flipY: h,
1538
1460
  arrowLength: this.arrowLength,
1539
1461
  arrowOffset: this.arrowOffset,
1540
1462
  roundness: this.roundness,
@@ -1552,22 +1474,22 @@ class Ue {
1552
1474
  hasSourceArrow: this.hasSourceArrow,
1553
1475
  hasTargetArrow: this.hasTargetArrow
1554
1476
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1555
- const v = T(
1477
+ const y = m(
1556
1478
  c,
1557
1479
  w,
1558
1480
  this.arrowLength,
1559
1481
  this.arrowWidth
1560
1482
  );
1561
- this.sourceArrow.setAttribute("d", v);
1483
+ this.sourceArrow.setAttribute("d", y);
1562
1484
  }
1563
1485
  if (this.targetArrow) {
1564
- const v = T(
1486
+ const y = m(
1565
1487
  f,
1566
1488
  l,
1567
1489
  x,
1568
1490
  this.arrowWidth
1569
1491
  );
1570
- this.targetArrow.setAttribute("d", v);
1492
+ this.targetArrow.setAttribute("d", y);
1571
1493
  }
1572
1494
  }
1573
1495
  }
@@ -1594,22 +1516,22 @@ class $e {
1594
1516
  this.arrowOffset,
1595
1517
  this.cycleSquareSide / 2
1596
1518
  ), 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;
1597
- const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
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));
1519
+ const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
1520
+ this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(r), this.group.appendChild(this.targetArrow));
1599
1521
  }
1600
1522
  render(e) {
1601
- const { x: o, y: r, width: n, height: h, flipX: s, flipY: d } = B(
1523
+ const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = B(
1602
1524
  e.from,
1603
1525
  e.to
1604
1526
  );
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})`;
1606
- const c = m(
1527
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
1528
+ const c = T(
1607
1529
  e.from.direction,
1608
- s,
1609
- d
1610
- ), a = m(e.to.direction, s, d), l = {
1611
- x: n,
1612
- y: h
1530
+ n,
1531
+ h
1532
+ ), a = T(e.to.direction, n, h), l = {
1533
+ x: s,
1534
+ y: d
1613
1535
  };
1614
1536
  let g, f = a, x = -this.arrowLength;
1615
1537
  if (e.from.portId === e.to.portId ? (g = H({
@@ -1624,8 +1546,8 @@ class $e {
1624
1546
  to: l,
1625
1547
  fromVect: c,
1626
1548
  toVect: a,
1627
- flipX: s,
1628
- flipY: d,
1549
+ flipX: n,
1550
+ flipY: h,
1629
1551
  arrowLength: this.arrowLength,
1630
1552
  arrowOffset: this.arrowOffset,
1631
1553
  roundness: this.roundness,
@@ -1637,29 +1559,29 @@ class $e {
1637
1559
  to: l,
1638
1560
  fromVect: c,
1639
1561
  toVect: a,
1640
- flipY: d,
1562
+ flipY: h,
1641
1563
  arrowLength: this.arrowLength,
1642
1564
  arrowOffset: this.arrowOffset,
1643
1565
  roundness: this.roundness,
1644
1566
  hasSourceArrow: this.hasSourceArrow,
1645
1567
  hasTargetArrow: this.hasTargetArrow
1646
1568
  }), this.line.setAttribute("d", g), this.sourceArrow) {
1647
- const v = T(
1569
+ const y = m(
1648
1570
  c,
1649
1571
  w,
1650
1572
  this.arrowLength,
1651
1573
  this.arrowWidth
1652
1574
  );
1653
- this.sourceArrow.setAttribute("d", v);
1575
+ this.sourceArrow.setAttribute("d", y);
1654
1576
  }
1655
1577
  if (this.targetArrow) {
1656
- const v = T(
1578
+ const y = m(
1657
1579
  f,
1658
1580
  l,
1659
1581
  x,
1660
1582
  this.arrowWidth
1661
1583
  );
1662
- this.targetArrow.setAttribute("d", v);
1584
+ this.targetArrow.setAttribute("d", y);
1663
1585
  }
1664
1586
  }
1665
1587
  }
@@ -1725,34 +1647,34 @@ const Re = (t) => {
1725
1647
  });
1726
1648
  }
1727
1649
  }, Ie = (t) => {
1728
- var o, r, n, h, s;
1729
- const e = me(
1650
+ var o, r, s, d, n;
1651
+ const e = Te(
1730
1652
  (o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
1731
1653
  (r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
1732
1654
  );
1733
1655
  return {
1734
1656
  nodes: {
1735
- centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? Se,
1657
+ centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? pe,
1736
1658
  priorityFn: e.nodesPriorityFn
1737
1659
  },
1738
1660
  ports: {
1739
- direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
1661
+ direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
1740
1662
  },
1741
1663
  edges: {
1742
- shapeFactory: Re(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
1664
+ shapeFactory: Re(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
1743
1665
  priorityFn: e.edgesPriorityFn
1744
1666
  }
1745
1667
  };
1746
1668
  };
1747
1669
  class We {
1748
1670
  constructor(e, o, r) {
1749
- i(this, "nodeIdGenerator", new z(
1671
+ i(this, "nodeIdGenerator", new Y(
1750
1672
  (e) => this.graph.getNode(e) !== null
1751
1673
  ));
1752
- i(this, "portIdGenerator", new z(
1674
+ i(this, "portIdGenerator", new Y(
1753
1675
  (e) => this.graph.getPort(e) !== null
1754
1676
  ));
1755
- i(this, "edgeIdGenerator", new z(
1677
+ i(this, "edgeIdGenerator", new Y(
1756
1678
  (e) => this.graph.getEdge(e) !== null
1757
1679
  ));
1758
1680
  i(this, "defaults");
@@ -1764,24 +1686,7 @@ class We {
1764
1686
  * provides api for accessing viewport state
1765
1687
  */
1766
1688
  i(this, "viewport");
1767
- this.element = e, this.controller = o, this.defaults = Ie(r), this.graph = o.graph, this.viewport = o.viewport, this.attach(this.element);
1768
- }
1769
- /**
1770
- * @deprecated
1771
- * use CanvasBuilder.attach instead
1772
- * attaches canvas to given element
1773
- * detaches element first when canvas is attached
1774
- */
1775
- attach(e) {
1776
- return this.controller.attach(e), this;
1777
- }
1778
- /**
1779
- * @deprecated
1780
- * attach canvas once instead, then reattach wrapper element
1781
- * detaches canvas from element when attached
1782
- */
1783
- detach() {
1784
- return this.controller.detach(), this;
1689
+ this.element = e, this.controller = o, this.defaults = Ie(r), this.graph = o.graph, this.viewport = o.viewport;
1785
1690
  }
1786
1691
  /**
1787
1692
  * adds node to graph
@@ -1789,7 +1694,7 @@ class We {
1789
1694
  addNode(e) {
1790
1695
  const o = this.nodeIdGenerator.create(e.id);
1791
1696
  if (this.graph.getNode(o) !== null)
1792
- throw new E("failed to add node with existing id");
1697
+ throw new A("failed to add node with existing id");
1793
1698
  if (this.controller.addNode({
1794
1699
  id: o,
1795
1700
  element: e.element,
@@ -1812,7 +1717,7 @@ class We {
1812
1717
  */
1813
1718
  updateNode(e, o) {
1814
1719
  if (this.graph.getNode(e) === null)
1815
- throw new E("failed to update nonexisting node");
1720
+ throw new A("failed to update nonexisting node");
1816
1721
  return this.controller.updateNode(e, o ?? {}), this;
1817
1722
  }
1818
1723
  /**
@@ -1822,7 +1727,7 @@ class We {
1822
1727
  */
1823
1728
  removeNode(e) {
1824
1729
  if (this.graph.getNode(e) === null)
1825
- throw new E("failed to remove nonexisting node");
1730
+ throw new A("failed to remove nonexisting node");
1826
1731
  return this.controller.removeNode(e), this;
1827
1732
  }
1828
1733
  /**
@@ -1831,9 +1736,9 @@ class We {
1831
1736
  markPort(e) {
1832
1737
  const o = this.portIdGenerator.create(e.id);
1833
1738
  if (this.graph.getPort(o) !== null)
1834
- throw new E("failed to add port with existing id");
1739
+ throw new A("failed to add port with existing id");
1835
1740
  if (this.graph.getNode(e.nodeId) === null)
1836
- throw new E("failed to set port on nonexisting node");
1741
+ throw new A("failed to set port on nonexisting node");
1837
1742
  return this.controller.markPort({
1838
1743
  id: o,
1839
1744
  element: e.element,
@@ -1846,7 +1751,7 @@ class We {
1846
1751
  */
1847
1752
  updatePort(e, o) {
1848
1753
  if (this.graph.getPort(e) === null)
1849
- throw new E("failed to unset nonexisting port");
1754
+ throw new A("failed to unset nonexisting port");
1850
1755
  return this.controller.updatePort(e, o ?? {}), this;
1851
1756
  }
1852
1757
  /**
@@ -1855,7 +1760,7 @@ class We {
1855
1760
  */
1856
1761
  unmarkPort(e) {
1857
1762
  if (this.graph.getPort(e) === null)
1858
- throw new E("failed to unset nonexisting port");
1763
+ throw new A("failed to unset nonexisting port");
1859
1764
  return this.controller.unmarkPort(e), this;
1860
1765
  }
1861
1766
  /**
@@ -1864,11 +1769,11 @@ class We {
1864
1769
  addEdge(e) {
1865
1770
  const o = this.edgeIdGenerator.create(e.id);
1866
1771
  if (this.graph.getEdge(o) !== null)
1867
- throw new E("failed to add edge with existing id");
1772
+ throw new A("failed to add edge with existing id");
1868
1773
  if (this.graph.getPort(e.from) === null)
1869
- throw new E("failed to add edge from nonexisting port");
1774
+ throw new A("failed to add edge from nonexisting port");
1870
1775
  if (this.graph.getPort(e.to) === null)
1871
- throw new E("failed to add edge to nonexisting port");
1776
+ throw new A("failed to add edge to nonexisting port");
1872
1777
  return this.controller.addEdge({
1873
1778
  id: o,
1874
1779
  from: e.from,
@@ -1882,7 +1787,7 @@ class We {
1882
1787
  */
1883
1788
  updateEdge(e, o) {
1884
1789
  if (this.graph.getEdge(e) === null)
1885
- throw new E("failed to update nonexisting edge");
1790
+ throw new A("failed to update nonexisting edge");
1886
1791
  return this.controller.updateEdge(e, o ?? {}), this;
1887
1792
  }
1888
1793
  /**
@@ -1890,7 +1795,7 @@ class We {
1890
1795
  */
1891
1796
  removeEdge(e) {
1892
1797
  if (this.graph.getEdge(e) === null)
1893
- throw new E("failed to remove nonexisting edge");
1798
+ throw new A("failed to remove nonexisting edge");
1894
1799
  return this.controller.removeEdge(e), this;
1895
1800
  }
1896
1801
  /**
@@ -1954,7 +1859,7 @@ class Fe {
1954
1859
  i(this, "onBeforeEdgeRemoved");
1955
1860
  i(this, "beforeClearEmitter");
1956
1861
  i(this, "onBeforeClear");
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();
1862
+ [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = E(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = E(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = E(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = E(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = E(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = E(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = E(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = E(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = E(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = E(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = E(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = E(), [this.beforeClearEmitter, this.onBeforeClear] = E();
1958
1863
  }
1959
1864
  addNode(e) {
1960
1865
  const o = /* @__PURE__ */ new Map(), r = {
@@ -2011,13 +1916,13 @@ class Fe {
2011
1916
  }
2012
1917
  updateEdge(e, o) {
2013
1918
  if (o.from !== void 0 || o.to !== void 0) {
2014
- const n = this.edges.get(e);
1919
+ const s = this.edges.get(e);
2015
1920
  this.removeEdgeInternal(e), this.addEdgeInternal({
2016
1921
  id: e,
2017
- from: o.from ?? n.from,
2018
- to: o.to ?? n.to,
2019
- shape: n.shape,
2020
- priority: n.priority
1922
+ from: o.from ?? s.from,
1923
+ to: o.to ?? s.to,
1924
+ shape: s.shape,
1925
+ priority: s.priority
2021
1926
  });
2022
1927
  }
2023
1928
  const r = this.edges.get(e);
@@ -2054,22 +1959,22 @@ class Fe {
2054
1959
  getNodeIncomingEdgeIds(e) {
2055
1960
  const o = Array.from(this.nodes.get(e).ports.keys());
2056
1961
  let r = [];
2057
- return o.forEach((n) => {
2058
- r = [...r, ...this.getPortIncomingEdgeIds(n)];
1962
+ return o.forEach((s) => {
1963
+ r = [...r, ...this.getPortIncomingEdgeIds(s)];
2059
1964
  }), r;
2060
1965
  }
2061
1966
  getNodeOutcomingEdgeIds(e) {
2062
1967
  const o = Array.from(this.nodes.get(e).ports.keys());
2063
1968
  let r = [];
2064
- return o.forEach((n) => {
2065
- r = [...r, ...this.getPortOutcomingEdgeIds(n)];
1969
+ return o.forEach((s) => {
1970
+ r = [...r, ...this.getPortOutcomingEdgeIds(s)];
2066
1971
  }), r;
2067
1972
  }
2068
1973
  getNodeCycleEdgeIds(e) {
2069
1974
  const o = Array.from(this.nodes.get(e).ports.keys());
2070
1975
  let r = [];
2071
- return o.forEach((n) => {
2072
- r = [...r, ...this.getPortCycleEdgeIds(n)];
1976
+ return o.forEach((s) => {
1977
+ r = [...r, ...this.getPortCycleEdgeIds(s)];
2073
1978
  }), r;
2074
1979
  }
2075
1980
  getNodeAdjacentEdgeIds(e) {
@@ -2088,28 +1993,28 @@ class Fe {
2088
1993
  }), 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);
2089
1994
  }
2090
1995
  removeEdgeInternal(e) {
2091
- const o = this.edges.get(e), r = o.from, n = o.to;
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);
1996
+ const o = this.edges.get(e), r = o.from, s = o.to;
1997
+ this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.incommingEdges.get(r).delete(e), this.incommingEdges.get(s).delete(e), this.outcommingEdges.get(r).delete(e), this.outcommingEdges.get(s).delete(e), this.edges.delete(e);
2093
1998
  }
2094
1999
  }
2095
- const O = (t) => ({
2000
+ const q = (t) => ({
2096
2001
  scale: 1 / t.scale,
2097
2002
  x: -t.x / t.scale,
2098
2003
  y: -t.y / t.scale
2099
- }), q = {
2004
+ }), O = {
2100
2005
  scale: 1,
2101
2006
  x: 0,
2102
2007
  y: 0
2103
2008
  };
2104
2009
  class Be {
2105
2010
  constructor() {
2106
- i(this, "viewportMatrix", q);
2107
- i(this, "contentMatrix", q);
2011
+ i(this, "viewportMatrix", O);
2012
+ i(this, "contentMatrix", O);
2108
2013
  i(this, "afterUpdateEmitter");
2109
2014
  i(this, "onAfterUpdated");
2110
2015
  i(this, "beforeUpdateEmitter");
2111
2016
  i(this, "onBeforeUpdated");
2112
- [this.afterUpdateEmitter, this.onAfterUpdated] = A(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = A();
2017
+ [this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E();
2113
2018
  }
2114
2019
  getViewportMatrix() {
2115
2020
  return this.viewportMatrix;
@@ -2122,14 +2027,14 @@ class Be {
2122
2027
  scale: e.scale ?? this.viewportMatrix.scale,
2123
2028
  x: e.x ?? this.viewportMatrix.x,
2124
2029
  y: e.y ?? this.viewportMatrix.y
2125
- }, this.contentMatrix = O(this.viewportMatrix), this.afterUpdateEmitter.emit();
2030
+ }, this.contentMatrix = q(this.viewportMatrix), this.afterUpdateEmitter.emit();
2126
2031
  }
2127
2032
  patchContentMatrix(e) {
2128
2033
  this.beforeUpdateEmitter.emit(), this.contentMatrix = {
2129
2034
  scale: e.scale ?? this.contentMatrix.scale,
2130
2035
  x: e.x ?? this.contentMatrix.x,
2131
2036
  y: e.y ?? this.contentMatrix.y
2132
- }, this.viewportMatrix = O(this.contentMatrix), this.afterUpdateEmitter.emit();
2037
+ }, this.viewportMatrix = q(this.contentMatrix), this.afterUpdateEmitter.emit();
2133
2038
  }
2134
2039
  }
2135
2040
  class j {
@@ -2149,8 +2054,8 @@ class j {
2149
2054
  });
2150
2055
  this.canvas = e, this.nodesResizeObserver = new ResizeObserver((o) => {
2151
2056
  o.forEach((r) => {
2152
- const n = r.target;
2153
- this.handleNodeResize(n);
2057
+ const s = r.target;
2058
+ this.handleNodeResize(s);
2154
2059
  });
2155
2060
  }), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
2156
2061
  }
@@ -2159,12 +2064,12 @@ class j {
2159
2064
  }
2160
2065
  handleNodeResize(e) {
2161
2066
  const o = this.elementToNodeId.get(e);
2162
- this.canvas.updateNode(o), this.canvas.graph.getNodeAdjacentEdgeIds(o).forEach((n) => {
2163
- this.canvas.updateEdge(n);
2067
+ this.canvas.updateNode(o), this.canvas.graph.getNodeAdjacentEdgeIds(o).forEach((s) => {
2068
+ this.canvas.updateEdge(s);
2164
2069
  });
2165
2070
  }
2166
2071
  }
2167
- class ze {
2072
+ class Ye {
2168
2073
  constructor() {
2169
2074
  i(this, "element", null);
2170
2075
  i(this, "canvasDefaults", {});
@@ -2176,7 +2081,7 @@ class ze {
2176
2081
  i(this, "hasResizeReactiveNodes", !1);
2177
2082
  i(this, "boxRenderingTrigger");
2178
2083
  }
2179
- attach(e) {
2084
+ setElement(e) {
2180
2085
  return this.element = e, this;
2181
2086
  }
2182
2087
  /**
@@ -2185,13 +2090,6 @@ class ze {
2185
2090
  setDefaults(e) {
2186
2091
  return this.canvasDefaults = e, this;
2187
2092
  }
2188
- /**
2189
- * @deprecated
2190
- * use setDefaults instead
2191
- */
2192
- setOptions(e) {
2193
- return this.setDefaults(e), this;
2194
- }
2195
2093
  /**
2196
2094
  * enables nodes draggable by user
2197
2095
  */
@@ -2224,33 +2122,40 @@ class ze {
2224
2122
  */
2225
2123
  build() {
2226
2124
  if (this.element === null)
2227
- throw new E(
2125
+ throw new A(
2228
2126
  "unable to build canvas when no attach element specified"
2229
2127
  );
2230
2128
  let e = this.boxRenderingTrigger;
2231
2129
  this.virtualScrollOptions !== void 0 && e === void 0 && (e = new te());
2232
2130
  const o = new Fe(), r = new Be();
2233
- let n = new Ae(o, r);
2234
- e !== void 0 && (n = new pe(n, o, e));
2235
- let h = new ne(
2131
+ let s = new Ee(
2132
+ o,
2133
+ r,
2134
+ this.element
2135
+ );
2136
+ e !== void 0 && (s = new Se(s, o, e));
2137
+ let d = new ne(
2236
2138
  o,
2237
2139
  r,
2238
- n
2140
+ s
2239
2141
  );
2240
- this.hasDraggableNode && (h = new de(
2241
- h,
2142
+ this.hasDraggableNode && (d = new de(
2143
+ d,
2144
+ this.element,
2242
2145
  this.dragOptions
2243
- )), this.virtualScrollOptions !== void 0 ? h = new fe(
2244
- h,
2146
+ )), this.virtualScrollOptions !== void 0 ? d = new fe(
2147
+ d,
2245
2148
  e,
2246
2149
  this.transformOptions,
2247
- this.virtualScrollOptions
2248
- ) : this.hasTransformableViewport && (h = new ee(
2249
- h,
2150
+ this.virtualScrollOptions,
2151
+ this.element
2152
+ ) : this.hasTransformableViewport && (d = new ee(
2153
+ d,
2154
+ this.element,
2250
2155
  this.transformOptions
2251
2156
  ));
2252
- const s = new We(this.element, h, this.canvasDefaults);
2253
- return this.hasResizeReactiveNodes && j.configure(s), this.reset(), s;
2157
+ const n = new We(this.element, d, this.canvasDefaults);
2158
+ return this.hasResizeReactiveNodes && j.configure(n), this.reset(), n;
2254
2159
  }
2255
2160
  reset() {
2256
2161
  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;
@@ -2258,10 +2163,10 @@ class ze {
2258
2163
  }
2259
2164
  export {
2260
2165
  De as BezierEdgeShape,
2261
- ze as CanvasBuilder,
2166
+ Ye as CanvasBuilder,
2262
2167
  te as EventSubject,
2263
2168
  Ce as HorizontalEdgeShape,
2264
- E as HtmlGraphError,
2169
+ A as HtmlGraphError,
2265
2170
  Ue as StraightEdgeShape,
2266
2171
  $e as VerticalEdgeShape
2267
2172
  };