@html-graph/html-graph 3.6.0 → 3.7.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,31 +1,31 @@
1
- var he = Object.defineProperty;
2
- var de = (t, e, o) => e in t ? he(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
- var i = (t, e, o) => de(t, typeof e != "symbol" ? e + "" : e, o);
4
- const ce = () => {
1
+ var ae = Object.defineProperty;
2
+ var le = (t, e, o) => e in t ? ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var r = (t, e, o) => le(t, typeof e != "symbol" ? e + "" : e, o);
4
+ const ue = () => {
5
5
  const t = document.createElement("div");
6
6
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
7
- }, ae = () => {
7
+ }, ge = () => {
8
8
  const t = document.createElement("div");
9
9
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
10
- }, le = () => {
10
+ }, we = () => {
11
11
  const t = document.createElement("div");
12
12
  return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
13
13
  };
14
- class re {
15
- constructor(e, o, r) {
16
- i(this, "host", le());
17
- i(this, "container", ce());
18
- i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
19
- i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
20
- i(this, "applyTransform", () => {
14
+ class ie {
15
+ constructor(e, o, i) {
16
+ r(this, "host", we());
17
+ r(this, "container", ue());
18
+ r(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
19
+ r(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
20
+ r(this, "applyTransform", () => {
21
21
  const e = this.viewportStore.getContentMatrix();
22
22
  this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
23
23
  });
24
- 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);
24
+ this.graphStore = e, this.viewportStore = o, this.element = i, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
25
25
  }
26
26
  attachNode(e) {
27
- const o = this.graphStore.getNode(e), r = ae();
28
- r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodePosition(e), this.updateNodePriority(e), r.style.visibility = "visible";
27
+ const o = this.graphStore.getNode(e), i = ge();
28
+ i.appendChild(o.element), this.container.appendChild(i), this.nodeIdToWrapperElementMap.set(e, i), this.updateNodePosition(e), this.updateNodePriority(e), i.style.visibility = "visible";
29
29
  }
30
30
  detachNode(e) {
31
31
  const o = this.nodeIdToWrapperElementMap.get(e);
@@ -50,35 +50,35 @@ class re {
50
50
  this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
51
51
  }
52
52
  updateNodePosition(e) {
53
- const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width: s, height: h } = r.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, d = r.centerFn(s, h), c = r.x - n * d.x, a = r.y - n * d.y;
53
+ const o = this.nodeIdToWrapperElementMap.get(e), i = this.graphStore.getNode(e), { width: s, height: h } = i.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, d = i.centerFn(s, h), c = i.x - n * d.x, a = i.y - n * d.y;
54
54
  o.style.transform = `translate(${c}px, ${a}px)`;
55
55
  }
56
56
  updateNodePriority(e) {
57
- const o = this.graphStore.getNode(e), r = this.nodeIdToWrapperElementMap.get(e);
58
- r.style.zIndex = `${o.priority}`;
57
+ const o = this.graphStore.getNode(e), i = this.nodeIdToWrapperElementMap.get(e);
58
+ i.style.zIndex = `${o.priority}`;
59
59
  }
60
60
  updateEdgeShape(e) {
61
61
  const o = this.edgeIdToElementMap.get(e);
62
62
  this.container.removeChild(o);
63
- const r = this.graphStore.getEdge(e);
64
- this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg);
63
+ const i = this.graphStore.getEdge(e);
64
+ this.edgeIdToElementMap.set(e, i.shape.svg), this.container.appendChild(i.shape.svg);
65
65
  }
66
66
  renderEdge(e) {
67
- const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), h = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = h.left - d.left, l = h.top - d.top, g = n.left - d.left, y = n.top - d.top, p = {
67
+ const o = this.graphStore.getEdge(e), i = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), h = i.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = h.left - d.left, l = h.top - d.top, g = n.left - d.left, y = n.top - d.top, p = {
68
68
  x: c.scale * a + c.x,
69
69
  y: c.scale * l + c.y
70
70
  }, f = {
71
71
  x: c.scale * g + c.x,
72
72
  y: c.scale * y + c.y
73
- }, E = {
73
+ }, A = {
74
74
  x: p.x,
75
75
  y: p.y,
76
76
  width: h.width * c.scale,
77
77
  height: h.height * c.scale,
78
- direction: r.direction,
78
+ direction: i.direction,
79
79
  portId: o.from,
80
- nodeId: r.nodeId
81
- }, x = {
80
+ nodeId: i.nodeId
81
+ }, E = {
82
82
  x: f.x,
83
83
  y: f.y,
84
84
  width: n.width * c.scale,
@@ -87,19 +87,19 @@ class re {
87
87
  portId: o.to,
88
88
  nodeId: s.nodeId
89
89
  };
90
- o.shape.render({ from: E, to: x });
90
+ o.shape.render({ from: A, to: E });
91
91
  }
92
92
  updateEdgePriority(e) {
93
93
  const o = this.graphStore.getEdge(e);
94
94
  o.shape.svg.style.zIndex = `${o.priority}`;
95
95
  }
96
96
  }
97
- class ge {
97
+ class fe {
98
98
  constructor(e) {
99
- i(this, "xFrom", 1 / 0);
100
- i(this, "yFrom", 1 / 0);
101
- i(this, "xTo", 1 / 0);
102
- i(this, "yTo", 1 / 0);
99
+ r(this, "xFrom", 1 / 0);
100
+ r(this, "yFrom", 1 / 0);
101
+ r(this, "xTo", 1 / 0);
102
+ r(this, "yTo", 1 / 0);
103
103
  this.graphStore = e;
104
104
  }
105
105
  setRenderingBox(e) {
@@ -110,27 +110,27 @@ class ge {
110
110
  return o.x >= this.xFrom && o.x <= this.xTo && o.y >= this.yFrom && o.y <= this.yTo;
111
111
  }
112
112
  hasEdge(e) {
113
- const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId, h = this.graphStore.getNode(r), n = this.graphStore.getNode(s), d = Math.min(h.x, n.x), c = Math.max(h.x, n.x), a = Math.min(h.y, n.y), l = Math.max(h.y, n.y);
113
+ const o = this.graphStore.getEdge(e), i = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId, h = this.graphStore.getNode(i), n = this.graphStore.getNode(s), d = Math.min(h.x, n.x), c = Math.max(h.x, n.x), a = Math.min(h.y, n.y), l = Math.max(h.y, n.y);
114
114
  return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
115
115
  }
116
116
  }
117
- class ue {
118
- constructor(e, o, r) {
119
- i(this, "attachedNodes", /* @__PURE__ */ new Set());
120
- i(this, "attachedEdges", /* @__PURE__ */ new Set());
121
- i(this, "renderingBox");
122
- i(this, "updateViewport", (e) => {
117
+ class ve {
118
+ constructor(e, o, i) {
119
+ r(this, "attachedNodes", /* @__PURE__ */ new Set());
120
+ r(this, "attachedEdges", /* @__PURE__ */ new Set());
121
+ r(this, "renderingBox");
122
+ r(this, "updateViewport", (e) => {
123
123
  this.renderingBox.setRenderingBox(e);
124
- const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
124
+ const o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
125
125
  this.graphStore.getAllNodeIds().forEach((n) => {
126
126
  const d = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
127
- d && !c ? o.add(n) : !d && c && r.add(n);
127
+ d && !c ? o.add(n) : !d && c && i.add(n);
128
128
  }), this.graphStore.getAllEdgeIds().forEach((n) => {
129
129
  const d = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
130
- d && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), d && !c ? s.add(n) : !d && c && h.add(n);
130
+ d && (this.renderingBox.hasNode(l) || (o.add(l), i.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), i.delete(g))), d && !c ? s.add(n) : !d && c && h.add(n);
131
131
  }), h.forEach((n) => {
132
132
  this.handleDetachEdge(n);
133
- }), r.forEach((n) => {
133
+ }), i.forEach((n) => {
134
134
  this.handleDetachNode(n);
135
135
  }), o.forEach((n) => {
136
136
  this.attachedNodes.has(n) || this.handleAttachNode(n);
@@ -138,7 +138,7 @@ class ue {
138
138
  this.handleAttachEdge(n);
139
139
  });
140
140
  });
141
- this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new ge(this.graphStore), this.trigger.subscribe(this.updateViewport);
141
+ this.htmlView = e, this.graphStore = o, this.trigger = i, this.renderingBox = new fe(this.graphStore), this.trigger.subscribe(this.updateViewport);
142
142
  }
143
143
  attachNode(e) {
144
144
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -176,8 +176,8 @@ class ue {
176
176
  this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
177
177
  }
178
178
  attachEdgeEntities(e) {
179
- const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId;
180
- this.attachedNodes.has(r) || this.handleAttachNode(r), this.attachedNodes.has(s) || this.handleAttachNode(s), this.handleAttachEdge(e);
179
+ const o = this.graphStore.getEdge(e), i = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId;
180
+ this.attachedNodes.has(i) || this.handleAttachNode(i), this.attachedNodes.has(s) || this.handleAttachNode(s), this.handleAttachEdge(e);
181
181
  }
182
182
  handleAttachNode(e) {
183
183
  this.attachedNodes.add(e), this.htmlView.attachNode(e);
@@ -192,9 +192,9 @@ class ue {
192
192
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
193
193
  }
194
194
  }
195
- class ie {
195
+ class se {
196
196
  constructor() {
197
- i(this, "callbacks", /* @__PURE__ */ new Set());
197
+ r(this, "callbacks", /* @__PURE__ */ new Set());
198
198
  }
199
199
  subscribe(e) {
200
200
  this.callbacks.add(e);
@@ -208,14 +208,14 @@ class ie {
208
208
  });
209
209
  }
210
210
  }
211
- const A = () => {
212
- const t = new ie();
211
+ const x = () => {
212
+ const t = new se();
213
213
  return [t, t];
214
214
  };
215
- class we {
215
+ class ye {
216
216
  constructor(e) {
217
- i(this, "onBeforeUpdated");
218
- i(this, "onAfterUpdated");
217
+ r(this, "onBeforeUpdated");
218
+ r(this, "onAfterUpdated");
219
219
  this.viewportStore = e, this.onBeforeUpdated = this.viewportStore.onBeforeUpdated, this.onAfterUpdated = this.viewportStore.onAfterUpdated;
220
220
  }
221
221
  getViewportMatrix() {
@@ -225,21 +225,21 @@ class we {
225
225
  return { ...this.viewportStore.getContentMatrix() };
226
226
  }
227
227
  }
228
- class fe {
228
+ class pe {
229
229
  constructor(e) {
230
- i(this, "onAfterNodeAdded");
231
- i(this, "onAfterNodeUpdated");
232
- i(this, "onAfterNodePriorityUpdated");
233
- i(this, "onBeforeNodeRemoved");
234
- i(this, "onAfterPortMarked");
235
- i(this, "onAfterPortUpdated");
236
- i(this, "onBeforePortUnmarked");
237
- i(this, "onAfterEdgeAdded");
238
- i(this, "onAfterEdgeShapeUpdated");
239
- i(this, "onAfterEdgeUpdated");
240
- i(this, "onAfterEdgePriorityUpdated");
241
- i(this, "onBeforeEdgeRemoved");
242
- i(this, "onBeforeClear");
230
+ r(this, "onAfterNodeAdded");
231
+ r(this, "onAfterNodeUpdated");
232
+ r(this, "onAfterNodePriorityUpdated");
233
+ r(this, "onBeforeNodeRemoved");
234
+ r(this, "onAfterPortMarked");
235
+ r(this, "onAfterPortUpdated");
236
+ r(this, "onBeforePortUnmarked");
237
+ r(this, "onAfterEdgeAdded");
238
+ r(this, "onAfterEdgeShapeUpdated");
239
+ r(this, "onAfterEdgeUpdated");
240
+ r(this, "onAfterEdgePriorityUpdated");
241
+ r(this, "onBeforeEdgeRemoved");
242
+ r(this, "onBeforeClear");
243
243
  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;
244
244
  }
245
245
  getNode(e) {
@@ -252,6 +252,7 @@ class fe {
252
252
  priority: o.priority
253
253
  };
254
254
  }
255
+ // TODO: use Set in v4
255
256
  getAllNodeIds() {
256
257
  return this.graphStore.getAllNodeIds();
257
258
  }
@@ -263,12 +264,19 @@ class fe {
263
264
  nodeId: o.nodeId
264
265
  };
265
266
  }
267
+ // TODO: use Set in v4
266
268
  getAllPortIds() {
267
269
  return this.graphStore.getAllPortIds();
268
270
  }
271
+ // TODO: use Set in v4
269
272
  getNodePortIds(e) {
270
273
  return this.graphStore.getNodePortIds(e) ?? null;
271
274
  }
275
+ // TODO: use Set in v4
276
+ getElementPortsIds(e) {
277
+ return [...this.graphStore.getElementPortsIds(e)];
278
+ }
279
+ // TODO: use Set in v4
272
280
  getAllEdgeIds() {
273
281
  return this.graphStore.getAllEdgeIds();
274
282
  }
@@ -276,34 +284,42 @@ class fe {
276
284
  const o = this.graphStore.getEdge(e);
277
285
  return o === void 0 ? null : { from: o.from, to: o.to, priority: o.priority };
278
286
  }
287
+ // TODO: use Set in v4
279
288
  getPortIncomingEdgeIds(e) {
280
289
  return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
281
290
  }
291
+ // TODO: use Set in v4
282
292
  getPortOutcomingEdgeIds(e) {
283
293
  return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutcomingEdgeIds(e);
284
294
  }
295
+ // TODO: use Set in v4
285
296
  getPortCycleEdgeIds(e) {
286
297
  return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
287
298
  }
299
+ // TODO: use Set in v4
288
300
  getPortAdjacentEdgeIds(e) {
289
301
  return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
290
302
  }
303
+ // TODO: use Set in v4
291
304
  getNodeIncomingEdgeIds(e) {
292
305
  return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
293
306
  }
307
+ // TODO: use Set in v4
294
308
  getNodeOutcomingEdgeIds(e) {
295
309
  return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutcomingEdgeIds(e);
296
310
  }
311
+ // TODO: use Set in v4
297
312
  getNodeCycleEdgeIds(e) {
298
313
  return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
299
314
  }
315
+ // TODO: use Set in v4
300
316
  getNodeAdjacentEdgeIds(e) {
301
317
  return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
302
318
  }
303
319
  }
304
320
  class C {
305
321
  constructor(e) {
306
- i(this, "counter", 0);
322
+ r(this, "counter", 0);
307
323
  this.checkExists = e;
308
324
  }
309
325
  create(e) {
@@ -320,21 +336,21 @@ class C {
320
336
  class S extends Error {
321
337
  constructor() {
322
338
  super(...arguments);
323
- i(this, "name", "HtmlGraphError");
339
+ r(this, "name", "HtmlGraphError");
324
340
  }
325
341
  }
326
- const ve = (t, e) => ({
342
+ const Ae = (t, e) => ({
327
343
  x: t / 2,
328
344
  y: e / 2
329
- }), $ = (t) => () => t, Q = $(0), ye = () => {
345
+ }), $ = (t) => () => t, K = $(0), Ee = () => {
330
346
  let t = 0;
331
347
  return () => t++;
332
- }, pe = (t, e) => {
333
- let o = Q, r = Q;
334
- const s = ye();
335
- return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = $(t)), typeof e == "number" && (r = $(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
348
+ }, xe = (t, e) => {
349
+ let o = K, i = K;
350
+ const s = Ee();
351
+ return t === "incremental" && (o = s), e === "incremental" && (i = s), typeof t == "number" && (o = $(t)), typeof e == "number" && (i = $(e)), typeof t == "function" && (o = t), typeof e == "function" && (i = e), {
336
352
  nodesPriorityFn: o,
337
- edgesPriorityFn: r
353
+ edgesPriorityFn: i
338
354
  };
339
355
  }, v = (t, e, o) => ({
340
356
  x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
@@ -342,7 +358,7 @@ const ve = (t, e) => ({
342
358
  }), w = {
343
359
  x: 0,
344
360
  y: 0
345
- }, xe = (t) => {
361
+ }, Se = (t) => {
346
362
  const e = v(
347
363
  { x: t.arrowLength, y: w.y },
348
364
  t.fromVector,
@@ -351,15 +367,15 @@ const ve = (t, e) => ({
351
367
  { x: t.to.x - t.arrowLength, y: t.to.y },
352
368
  t.toVector,
353
369
  t.to
354
- ), r = {
370
+ ), i = {
355
371
  x: e.x + t.fromVector.x * t.curvature,
356
372
  y: e.y + t.fromVector.y * t.curvature
357
373
  }, s = {
358
374
  x: o.x - t.toVector.x * t.curvature,
359
375
  y: o.y - t.toVector.y * t.curvature
360
- }, h = `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} `, d = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
376
+ }, h = `M ${e.x} ${e.y} C ${i.x} ${i.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, d = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
361
377
  return `${n}${h}${d}`;
362
- }, Ee = (t) => {
378
+ }, be = (t) => {
363
379
  const e = t.hasSourceArrow ? v(
364
380
  { x: t.arrowLength, y: w.y },
365
381
  t.fromVector,
@@ -368,15 +384,15 @@ const ve = (t, e) => ({
368
384
  { x: t.to.x - t.arrowLength, y: t.to.y },
369
385
  t.toVector,
370
386
  t.to
371
- ) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c = v(
372
- { x: r, y: w.y },
387
+ ) : t.to, i = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c = v(
388
+ { x: i, y: w.y },
373
389
  t.fromVector,
374
390
  w
375
391
  ), a = {
376
392
  x: c.x + n,
377
393
  y: c.y + d
378
394
  }, l = v(
379
- { x: t.to.x - r, y: t.to.y },
395
+ { x: t.to.x - i, y: t.to.y },
380
396
  t.toVector,
381
397
  t.to
382
398
  ), g = {
@@ -388,40 +404,40 @@ const ve = (t, e) => ({
388
404
  }, f = {
389
405
  x: l.x - t.curvature * t.toVector.x,
390
406
  y: l.y - t.curvature * t.toVector.y
391
- }, E = {
407
+ }, A = {
392
408
  x: c.x + n,
393
409
  y: c.y + d
394
- }, x = {
410
+ }, E = {
395
411
  x: l.x + n,
396
412
  y: l.y + d
397
413
  };
398
414
  return [
399
415
  `M ${e.x} ${e.y}`,
400
416
  `L ${c.x} ${c.y}`,
401
- `C ${p.x} ${p.y} ${E.x} ${E.y} ${y.x} ${y.y}`,
402
- `C ${x.x} ${x.y} ${f.x} ${f.y} ${l.x} ${l.y}`,
417
+ `C ${p.x} ${p.y} ${A.x} ${A.y} ${y.x} ${y.y}`,
418
+ `C ${E.x} ${E.y} ${f.x} ${f.y} ${l.x} ${l.y}`,
403
419
  `L ${o.x} ${o.y}`
404
420
  ].join(" ");
405
- }, L = (t, e) => {
421
+ }, V = (t, e) => {
406
422
  const o = [];
407
423
  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) {
408
- const r = t.length - 1;
424
+ const i = t.length - 1;
409
425
  let s = 0, h = 0, n = 0;
410
426
  t.forEach((d, c) => {
411
427
  let a = 0, l = 0, g = 0;
412
- const y = c > 0, p = c < r, f = y && p;
428
+ const y = c > 0, p = c < i, f = y && p;
413
429
  if (y && (a = -s, l = -h, g = n), p) {
414
- const V = t[c + 1];
415
- s = V.x - d.x, h = V.y - d.y, n = Math.sqrt(s * s + h * h);
430
+ const L = t[c + 1];
431
+ s = L.x - d.x, h = L.y - d.y, n = Math.sqrt(s * s + h * h);
416
432
  }
417
- const x = n !== 0 ? Math.min((f ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, T = f ? { x: d.x + s * x, y: d.y + h * x } : d, m = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, D = f ? { x: d.x + a * m, y: d.y + l * m } : d;
433
+ const E = n !== 0 ? Math.min((f ? e : 0) / n, c < i - 1 ? 0.5 : 1) : 0, b = f ? { x: d.x + s * E, y: d.y + h * E } : d, m = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, D = f ? { x: d.x + a * m, y: d.y + l * m } : d;
418
434
  c > 0 && o.push(`L ${D.x} ${D.y}`), f && o.push(
419
- `C ${d.x} ${d.y} ${d.x} ${d.y} ${T.x} ${T.y}`
435
+ `C ${d.x} ${d.y} ${d.x} ${d.y} ${b.x} ${b.y}`
420
436
  );
421
437
  });
422
438
  }
423
439
  return o.join(" ");
424
- }, Ae = (t) => {
440
+ }, me = (t) => {
425
441
  const e = t.hasSourceArrow ? v(
426
442
  { x: t.arrowLength, y: w.y },
427
443
  t.fromVector,
@@ -430,7 +446,7 @@ const ve = (t, e) => ({
430
446
  { x: t.to.x - t.arrowLength, y: t.to.y },
431
447
  t.toVector,
432
448
  t.to
433
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = v(
449
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = v(
434
450
  { x: s, y: w.y },
435
451
  t.fromVector,
436
452
  w
@@ -438,14 +454,14 @@ const ve = (t, e) => ({
438
454
  { x: t.to.x - s, y: t.to.y },
439
455
  t.toVector,
440
456
  t.to
441
- ), d = Math.max((h.x + n.x) / 2, r), c = t.to.y / 2, a = {
442
- x: t.flipX > 0 ? d : -r,
457
+ ), d = Math.max((h.x + n.x) / 2, i), c = t.to.y / 2, a = {
458
+ x: t.flipX > 0 ? d : -i,
443
459
  y: h.y
444
460
  }, l = { x: a.x, y: c }, g = {
445
- x: t.flipX > 0 ? t.to.x - d : t.to.x + r,
461
+ x: t.flipX > 0 ? t.to.x - d : t.to.x + i,
446
462
  y: n.y
447
463
  }, y = { x: g.x, y: c };
448
- return L(
464
+ return V(
449
465
  [e, h, a, l, y, g, n, o],
450
466
  t.roundness
451
467
  );
@@ -458,20 +474,20 @@ const ve = (t, e) => ({
458
474
  { x: t.to.x - t.arrowLength, y: t.to.y },
459
475
  t.toVector,
460
476
  t.to
461
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = v(
462
- { x: r, y: w.y },
477
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = v(
478
+ { x: i, y: w.y },
463
479
  t.fromVector,
464
480
  w
465
481
  ), h = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = n * t.flipY, a = { x: s.x + d, y: s.y + c }, l = v(
466
- { x: t.to.x - r, y: t.to.y },
482
+ { x: t.to.x - i, y: t.to.y },
467
483
  t.toVector,
468
484
  t.to
469
485
  ), g = { x: l.x + d, y: l.y + c };
470
- return L(
486
+ return V(
471
487
  [e, s, a, g, l, o],
472
488
  t.roundness
473
489
  );
474
- }, Se = (t) => {
490
+ }, Te = (t) => {
475
491
  const e = t.hasSourceArrow ? v(
476
492
  { x: t.arrowLength, y: w.y },
477
493
  t.fromVector,
@@ -480,17 +496,17 @@ const ve = (t, e) => ({
480
496
  { x: t.to.x - t.arrowLength, y: t.to.y },
481
497
  t.toVector,
482
498
  t.to
483
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = v(
484
- { x: r, y: w.y },
499
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = v(
500
+ { x: i, y: w.y },
485
501
  t.fromVector,
486
502
  w
487
503
  ), h = v(
488
- { x: t.to.x - r, y: t.to.y },
504
+ { x: t.to.x - i, y: t.to.y },
489
505
  t.toVector,
490
506
  t.to
491
507
  );
492
- return L([e, s, h, o], t.roundness);
493
- }, Te = (t) => {
508
+ return V([e, s, h, o], t.roundness);
509
+ }, Pe = (t) => {
494
510
  const e = t.hasSourceArrow ? v(
495
511
  { x: t.arrowLength, y: w.y },
496
512
  t.fromVector,
@@ -499,7 +515,7 @@ const ve = (t, e) => ({
499
515
  { x: t.to.x - t.arrowLength, y: t.to.y },
500
516
  t.toVector,
501
517
  t.to
502
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = v(
518
+ ) : t.to, i = t.arrowLength + t.arrowOffset, s = i - t.roundness, h = v(
503
519
  { x: s, y: w.y },
504
520
  t.fromVector,
505
521
  w
@@ -507,33 +523,33 @@ const ve = (t, e) => ({
507
523
  { x: t.to.x - s, y: t.to.y },
508
524
  t.toVector,
509
525
  t.to
510
- ), d = Math.max((h.y + n.y) / 2, r), c = t.to.x / 2, a = {
526
+ ), d = Math.max((h.y + n.y) / 2, i), c = t.to.x / 2, a = {
511
527
  x: h.x,
512
- y: t.flipY > 0 ? d : -r
528
+ y: t.flipY > 0 ? d : -i
513
529
  }, l = { x: c, y: a.y }, g = {
514
530
  x: n.x,
515
- y: t.flipY > 0 ? t.to.y - d : t.to.y + r
531
+ y: t.flipY > 0 ? t.to.y - d : t.to.y + i
516
532
  }, y = { x: c, y: g.y };
517
- return L(
533
+ return V(
518
534
  [e, h, a, l, y, g, n, o],
519
535
  t.roundness
520
536
  );
521
- }, z = (t) => {
522
- const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, s = r + 2 * o, n = [
537
+ }, k = (t) => {
538
+ const e = t.arrowOffset, o = t.side, i = t.arrowLength + e, s = i + 2 * o, n = [
523
539
  { x: t.arrowLength, y: w.y },
524
- { x: r, y: w.y },
525
- { x: r, y: t.side },
540
+ { x: i, y: w.y },
541
+ { x: i, y: t.side },
526
542
  { x: s, y: t.side },
527
543
  { x: s, y: -t.side },
528
- { x: r, y: -t.side },
529
- { x: r, y: w.y },
544
+ { x: i, y: -t.side },
545
+ { x: i, y: w.y },
530
546
  { x: t.arrowLength, y: w.y }
531
547
  ].map(
532
548
  (c) => v(c, t.fromVector, w)
533
549
  ), d = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
534
- return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${L(n, t.roundness)}`;
535
- }, me = (t) => {
536
- const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o, h = t.arrowLength + r * (1 - o / s), n = e * o / s, c = [
550
+ return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${V(n, t.roundness)}`;
551
+ }, Ne = (t) => {
552
+ const e = t.smallRadius, o = t.radius, i = Math.sqrt(e * e + o * o), s = e + o, h = t.arrowLength + i * (1 - o / s), n = e * o / s, c = [
537
553
  { x: t.arrowLength, y: w.y },
538
554
  { x: h, y: n },
539
555
  { x: h, y: -n }
@@ -561,31 +577,32 @@ const ve = (t, e) => ({
561
577
  detourDirection: -Math.PI / 2,
562
578
  detourDirectionVertical: 0,
563
579
  smallCycleRadius: 15,
564
- curvature: 90
565
- }), Z = (t, e, o, r) => {
580
+ curvature: 90,
581
+ interactiveWidth: 10
582
+ }), Q = (t, e, o, i) => {
566
583
  const h = [
567
584
  w,
568
- { x: o, y: r },
569
- { x: o, y: -r }
585
+ { x: o, y: i },
586
+ { x: o, y: -i }
570
587
  ].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
571
- return `${n} ${d} ${c}`;
588
+ return `${n} ${d} ${c} Z`;
572
589
  }, _ = (t) => {
573
590
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
574
591
  return e.setAttribute("fill", t), e;
575
- }, be = () => {
592
+ }, Me = () => {
576
593
  const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
577
594
  return t.style.transformOrigin = "50% 50%", t;
578
- }, Pe = (t, e) => {
595
+ }, De = (t, e) => {
579
596
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
580
597
  return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
581
- }, Ne = (t, e) => {
598
+ }, Le = (t, e) => {
582
599
  const o = {
583
600
  x: t.x + t.width / 2,
584
601
  y: t.y + t.height / 2
585
- }, r = {
602
+ }, i = {
586
603
  x: e.x + e.width / 2,
587
604
  y: e.y + e.height / 2
588
- }, s = Math.min(o.x, r.x), h = Math.min(o.y, r.y), n = 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;
605
+ }, s = Math.min(o.x, i.x), h = Math.min(o.y, i.y), n = Math.abs(i.x - o.x), d = Math.abs(i.y - o.y), c = o.x <= i.x ? 1 : -1, a = o.y <= i.y ? 1 : -1;
589
606
  return {
590
607
  x: s,
591
608
  y: h,
@@ -594,25 +611,25 @@ const ve = (t, e) => ({
594
611
  flipX: c,
595
612
  flipY: a
596
613
  };
597
- }, Me = () => {
614
+ }, Ve = () => {
598
615
  const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
599
616
  return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
600
617
  }, q = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) });
601
618
  class I {
602
619
  constructor(e) {
603
- i(this, "svg", Me());
604
- i(this, "group", be());
605
- i(this, "line");
606
- i(this, "sourceArrow", null);
607
- i(this, "targetArrow", null);
608
- this.params = e, this.svg.appendChild(this.group), this.line = Pe(e.color, e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = _(e.color), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = _(e.color), this.group.appendChild(this.targetArrow));
620
+ r(this, "svg", Ve());
621
+ r(this, "group", Me());
622
+ r(this, "line");
623
+ r(this, "sourceArrow", null);
624
+ r(this, "targetArrow", null);
625
+ this.params = e, this.svg.appendChild(this.group), this.line = De(e.color, e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = _(e.color), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = _(e.color), this.group.appendChild(this.targetArrow));
609
626
  }
610
627
  render(e) {
611
- const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = Ne(
628
+ const { x: o, y: i, width: s, height: h, flipX: n, flipY: d } = Le(
612
629
  e.from,
613
630
  e.to
614
631
  );
615
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
632
+ this.svg.style.transform = `translate(${o}px, ${i}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
616
633
  const c = q(
617
634
  e.from.direction,
618
635
  n,
@@ -625,59 +642,53 @@ class I {
625
642
  x: s,
626
643
  y: h
627
644
  };
628
- let g, y = a, p = -this.params.arrowLength;
629
- if (e.from.portId === e.to.portId ? (g = this.params.createCyclePath(
630
- c,
631
- a,
632
- l,
633
- n,
634
- d
635
- ), y = c, p = this.params.arrowLength) : e.from.nodeId === e.to.nodeId ? g = this.params.createDetourPath(
636
- c,
637
- a,
638
- l,
639
- n,
640
- d
641
- ) : g = this.params.createLinePath(
645
+ let g = a, y = -this.params.arrowLength, p;
646
+ e.from.portId === e.to.portId ? (p = this.params.createCyclePath, g = c, y = this.params.arrowLength) : e.from.nodeId === e.to.nodeId ? p = this.params.createDetourPath : p = this.params.createLinePath;
647
+ const f = p(
642
648
  c,
643
649
  a,
644
650
  l,
645
651
  n,
646
652
  d
647
- ), this.line.setAttribute("d", g), this.sourceArrow) {
648
- const f = Z(
653
+ );
654
+ if (this.line.setAttribute("d", f), this.sourceArrow) {
655
+ const A = Q(
649
656
  c,
650
657
  w,
651
658
  this.params.arrowLength,
652
659
  this.params.arrowWidth
653
660
  );
654
- this.sourceArrow.setAttribute("d", f);
661
+ this.sourceArrow.setAttribute("d", A);
655
662
  }
656
663
  if (this.targetArrow) {
657
- const f = Z(
658
- y,
664
+ const A = Q(
665
+ g,
659
666
  l,
660
- p,
667
+ y,
661
668
  this.params.arrowWidth
662
669
  );
663
- this.targetArrow.setAttribute("d", f);
670
+ this.targetArrow.setAttribute("d", A);
664
671
  }
665
672
  }
666
673
  }
667
- class De {
674
+ class Re {
668
675
  constructor(e) {
669
- i(this, "svg");
670
- i(this, "arrowLength");
671
- i(this, "arrowWidth");
672
- i(this, "curvature");
673
- i(this, "portCycleRadius");
674
- i(this, "portCycleSmallRadius");
675
- i(this, "detourDirection");
676
- i(this, "detourDistance");
677
- i(this, "hasSourceArrow");
678
- i(this, "hasTargetArrow");
679
- i(this, "genericShape");
680
- i(this, "createCyclePath", (e) => me({
676
+ r(this, "svg");
677
+ r(this, "group");
678
+ r(this, "line");
679
+ r(this, "sourceArrow");
680
+ r(this, "targetArrow");
681
+ r(this, "arrowLength");
682
+ r(this, "arrowWidth");
683
+ r(this, "curvature");
684
+ r(this, "portCycleRadius");
685
+ r(this, "portCycleSmallRadius");
686
+ r(this, "detourDirection");
687
+ r(this, "detourDistance");
688
+ r(this, "hasSourceArrow");
689
+ r(this, "hasTargetArrow");
690
+ r(this, "lineShape");
691
+ r(this, "createCyclePath", (e) => Ne({
681
692
  fromVector: e,
682
693
  radius: this.portCycleRadius,
683
694
  smallRadius: this.portCycleSmallRadius,
@@ -685,8 +696,8 @@ class De {
685
696
  hasSourceArrow: this.hasSourceArrow,
686
697
  hasTargetArrow: this.hasTargetArrow
687
698
  }));
688
- i(this, "createDetourPath", (e, o, r, s, h) => Ee({
689
- to: r,
699
+ r(this, "createDetourPath", (e, o, i, s, h) => be({
700
+ to: i,
690
701
  fromVector: e,
691
702
  toVector: o,
692
703
  flipX: s,
@@ -698,8 +709,8 @@ class De {
698
709
  hasSourceArrow: this.hasSourceArrow,
699
710
  hasTargetArrow: this.hasTargetArrow
700
711
  }));
701
- i(this, "createLinePath", (e, o, r) => xe({
702
- to: r,
712
+ r(this, "createLinePath", (e, o, i) => Se({
713
+ to: i,
703
714
  fromVector: e,
704
715
  toVector: o,
705
716
  arrowLength: this.arrowLength,
@@ -707,7 +718,7 @@ class De {
707
718
  hasSourceArrow: this.hasSourceArrow,
708
719
  hasTargetArrow: this.hasTargetArrow
709
720
  }));
710
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
721
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new I({
711
722
  color: (e == null ? void 0 : e.color) ?? u.color,
712
723
  width: (e == null ? void 0 : e.width) ?? u.width,
713
724
  arrowLength: this.arrowLength,
@@ -717,26 +728,30 @@ class De {
717
728
  createCyclePath: this.createCyclePath,
718
729
  createDetourPath: this.createDetourPath,
719
730
  createLinePath: this.createLinePath
720
- }), this.svg = this.genericShape.svg;
731
+ }), this.svg = this.lineShape.svg, this.group = this.lineShape.group, this.line = this.lineShape.line, this.sourceArrow = this.lineShape.sourceArrow, this.targetArrow = this.lineShape.targetArrow;
721
732
  }
722
733
  render(e) {
723
- this.genericShape.render(e);
734
+ this.lineShape.render(e);
724
735
  }
725
736
  }
726
- class Ve {
737
+ class Be {
727
738
  constructor(e) {
728
- i(this, "svg");
729
- i(this, "arrowLength");
730
- i(this, "arrowWidth");
731
- i(this, "arrowOffset");
732
- i(this, "roundness");
733
- i(this, "cycleSquareSide");
734
- i(this, "detourDirection");
735
- i(this, "detourDistance");
736
- i(this, "hasSourceArrow");
737
- i(this, "hasTargetArrow");
738
- i(this, "genericShape");
739
- i(this, "createCyclePath", (e) => z({
739
+ r(this, "svg");
740
+ r(this, "group");
741
+ r(this, "line");
742
+ r(this, "sourceArrow");
743
+ r(this, "targetArrow");
744
+ r(this, "arrowLength");
745
+ r(this, "arrowWidth");
746
+ r(this, "arrowOffset");
747
+ r(this, "roundness");
748
+ r(this, "cycleSquareSide");
749
+ r(this, "detourDirection");
750
+ r(this, "detourDistance");
751
+ r(this, "hasSourceArrow");
752
+ r(this, "hasTargetArrow");
753
+ r(this, "lineShape");
754
+ r(this, "createCyclePath", (e) => k({
740
755
  fromVector: e,
741
756
  arrowLength: this.arrowLength,
742
757
  side: this.cycleSquareSide,
@@ -745,8 +760,8 @@ class Ve {
745
760
  hasSourceArrow: this.hasSourceArrow,
746
761
  hasTargetArrow: this.hasTargetArrow
747
762
  }));
748
- i(this, "createDetourPath", (e, o, r, s, h) => F({
749
- to: r,
763
+ r(this, "createDetourPath", (e, o, i, s, h) => F({
764
+ to: i,
750
765
  fromVector: e,
751
766
  toVector: o,
752
767
  flipX: s,
@@ -759,8 +774,8 @@ class Ve {
759
774
  hasSourceArrow: this.hasSourceArrow,
760
775
  hasTargetArrow: this.hasTargetArrow
761
776
  }));
762
- i(this, "createLinePath", (e, o, r, s) => Ae({
763
- to: r,
777
+ r(this, "createLinePath", (e, o, i, s) => me({
778
+ to: i,
764
779
  fromVector: e,
765
780
  toVector: o,
766
781
  flipX: s,
@@ -776,7 +791,7 @@ class Ve {
776
791
  o,
777
792
  this.arrowOffset,
778
793
  this.cycleSquareSide / 2
779
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
794
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new I({
780
795
  color: (e == null ? void 0 : e.color) ?? u.color,
781
796
  width: (e == null ? void 0 : e.width) ?? u.width,
782
797
  arrowLength: this.arrowLength,
@@ -786,26 +801,30 @@ class Ve {
786
801
  createCyclePath: this.createCyclePath,
787
802
  createDetourPath: this.createDetourPath,
788
803
  createLinePath: this.createLinePath
789
- }), this.svg = this.genericShape.svg;
804
+ }), this.svg = this.lineShape.svg, this.group = this.lineShape.group, this.line = this.lineShape.line, this.sourceArrow = this.lineShape.sourceArrow, this.targetArrow = this.lineShape.targetArrow;
790
805
  }
791
806
  render(e) {
792
- this.genericShape.render(e);
807
+ this.lineShape.render(e);
793
808
  }
794
809
  }
795
- class Le {
810
+ class Ie {
796
811
  constructor(e) {
797
- i(this, "svg");
798
- i(this, "arrowLength");
799
- i(this, "arrowWidth");
800
- i(this, "arrowOffset");
801
- i(this, "roundness");
802
- i(this, "cycleSquareSide");
803
- i(this, "detourDirection");
804
- i(this, "detourDistance");
805
- i(this, "hasSourceArrow");
806
- i(this, "hasTargetArrow");
807
- i(this, "genericShape");
808
- i(this, "createCyclePath", (e) => z({
812
+ r(this, "svg");
813
+ r(this, "group");
814
+ r(this, "line");
815
+ r(this, "sourceArrow");
816
+ r(this, "targetArrow");
817
+ r(this, "arrowLength");
818
+ r(this, "arrowWidth");
819
+ r(this, "arrowOffset");
820
+ r(this, "roundness");
821
+ r(this, "cycleSquareSide");
822
+ r(this, "detourDirection");
823
+ r(this, "detourDistance");
824
+ r(this, "hasSourceArrow");
825
+ r(this, "hasTargetArrow");
826
+ r(this, "lineShape");
827
+ r(this, "createCyclePath", (e) => k({
809
828
  fromVector: e,
810
829
  arrowLength: this.arrowLength,
811
830
  side: this.cycleSquareSide,
@@ -814,8 +833,8 @@ class Le {
814
833
  hasSourceArrow: this.hasSourceArrow,
815
834
  hasTargetArrow: this.hasTargetArrow
816
835
  }));
817
- i(this, "createDetourPath", (e, o, r, s, h) => F({
818
- to: r,
836
+ r(this, "createDetourPath", (e, o, i, s, h) => F({
837
+ to: i,
819
838
  fromVector: e,
820
839
  toVector: o,
821
840
  flipX: s,
@@ -828,8 +847,8 @@ class Le {
828
847
  hasSourceArrow: this.hasSourceArrow,
829
848
  hasTargetArrow: this.hasTargetArrow
830
849
  }));
831
- i(this, "createLinePath", (e, o, r) => Se({
832
- to: r,
850
+ r(this, "createLinePath", (e, o, i) => Te({
851
+ to: i,
833
852
  fromVector: e,
834
853
  toVector: o,
835
854
  arrowLength: this.arrowLength,
@@ -844,7 +863,7 @@ class Le {
844
863
  o,
845
864
  this.arrowOffset,
846
865
  this.cycleSquareSide / 2
847
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
866
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new I({
848
867
  color: (e == null ? void 0 : e.color) ?? u.color,
849
868
  width: (e == null ? void 0 : e.width) ?? u.width,
850
869
  arrowLength: this.arrowLength,
@@ -854,26 +873,30 @@ class Le {
854
873
  createCyclePath: this.createCyclePath,
855
874
  createDetourPath: this.createDetourPath,
856
875
  createLinePath: this.createLinePath
857
- }), this.svg = this.genericShape.svg;
876
+ }), this.svg = this.lineShape.svg, this.group = this.lineShape.group, this.line = this.lineShape.line, this.sourceArrow = this.lineShape.sourceArrow, this.targetArrow = this.lineShape.targetArrow;
858
877
  }
859
878
  render(e) {
860
- this.genericShape.render(e);
879
+ this.lineShape.render(e);
861
880
  }
862
881
  }
863
- class Re {
882
+ class Ue {
864
883
  constructor(e) {
865
- i(this, "svg");
866
- i(this, "arrowLength");
867
- i(this, "arrowWidth");
868
- i(this, "arrowOffset");
869
- i(this, "roundness");
870
- i(this, "cycleSquareSide");
871
- i(this, "detourDirection");
872
- i(this, "detourDistance");
873
- i(this, "hasSourceArrow");
874
- i(this, "hasTargetArrow");
875
- i(this, "genericShape");
876
- i(this, "createCyclePath", (e) => z({
884
+ r(this, "svg");
885
+ r(this, "group");
886
+ r(this, "line");
887
+ r(this, "sourceArrow");
888
+ r(this, "targetArrow");
889
+ r(this, "arrowLength");
890
+ r(this, "arrowWidth");
891
+ r(this, "arrowOffset");
892
+ r(this, "roundness");
893
+ r(this, "cycleSquareSide");
894
+ r(this, "detourDirection");
895
+ r(this, "detourDistance");
896
+ r(this, "hasSourceArrow");
897
+ r(this, "hasTargetArrow");
898
+ r(this, "lineShape");
899
+ r(this, "createCyclePath", (e) => k({
877
900
  fromVector: e,
878
901
  arrowLength: this.arrowLength,
879
902
  side: this.cycleSquareSide,
@@ -882,8 +905,8 @@ class Re {
882
905
  hasSourceArrow: this.hasSourceArrow,
883
906
  hasTargetArrow: this.hasTargetArrow
884
907
  }));
885
- i(this, "createDetourPath", (e, o, r, s, h) => F({
886
- to: r,
908
+ r(this, "createDetourPath", (e, o, i, s, h) => F({
909
+ to: i,
887
910
  fromVector: e,
888
911
  toVector: o,
889
912
  flipX: s,
@@ -896,8 +919,8 @@ class Re {
896
919
  hasSourceArrow: this.hasSourceArrow,
897
920
  hasTargetArrow: this.hasTargetArrow
898
921
  }));
899
- i(this, "createLinePath", (e, o, r, s, h) => Te({
900
- to: r,
922
+ r(this, "createLinePath", (e, o, i, s, h) => Pe({
923
+ to: i,
901
924
  fromVector: e,
902
925
  toVector: o,
903
926
  flipY: h,
@@ -913,7 +936,7 @@ class Re {
913
936
  o,
914
937
  this.arrowOffset,
915
938
  this.cycleSquareSide / 2
916
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
939
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.lineShape = new I({
917
940
  color: (e == null ? void 0 : e.color) ?? u.color,
918
941
  width: (e == null ? void 0 : e.width) ?? u.width,
919
942
  arrowLength: this.arrowLength,
@@ -923,18 +946,65 @@ class Re {
923
946
  createCyclePath: this.createCyclePath,
924
947
  createDetourPath: this.createDetourPath,
925
948
  createLinePath: this.createLinePath
926
- }), this.svg = this.genericShape.svg;
949
+ }), this.svg = this.lineShape.svg, this.group = this.lineShape.group, this.line = this.lineShape.line, this.sourceArrow = this.lineShape.sourceArrow, this.targetArrow = this.lineShape.targetArrow;
927
950
  }
928
951
  render(e) {
929
- this.genericShape.render(e);
952
+ this.lineShape.render(e);
953
+ }
954
+ }
955
+ const Ce = () => {
956
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
957
+ return t.style.pointerEvents = "auto", t.style.cursor = "pointer", t;
958
+ }, We = (t) => {
959
+ const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
960
+ return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${t}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
961
+ }, ee = (t) => {
962
+ const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
963
+ return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${t}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
964
+ };
965
+ class $e extends Error {
966
+ constructor(e) {
967
+ super(e), this.name = "InteractiveEdgeError";
930
968
  }
931
969
  }
932
- const Be = (t) => {
970
+ class ne {
971
+ constructor(e, o) {
972
+ r(this, "svg");
973
+ r(this, "group");
974
+ r(this, "line");
975
+ r(this, "sourceArrow");
976
+ r(this, "targetArrow");
977
+ r(this, "handle", Ce());
978
+ r(this, "interactiveLine");
979
+ r(this, "interactiveSourceArrow", null);
980
+ r(this, "interactiveTargetArrow", null);
981
+ if (this.structuredEdge = e, e instanceof ne)
982
+ throw new $e(
983
+ "interactive edge can be configured only once"
984
+ );
985
+ this.svg = this.structuredEdge.svg, this.group = this.structuredEdge.group, this.line = this.structuredEdge.line, this.sourceArrow = this.structuredEdge.sourceArrow, this.targetArrow = this.structuredEdge.targetArrow;
986
+ const i = (o == null ? void 0 : o.width) ?? u.interactiveWidth;
987
+ this.interactiveLine = We(i), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = ee(i), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = ee(i), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle);
988
+ }
989
+ render(e) {
990
+ this.structuredEdge.render(e);
991
+ const o = this.line.getAttribute("d");
992
+ if (this.interactiveLine.setAttribute("d", o), this.sourceArrow) {
993
+ const i = this.sourceArrow.getAttribute("d");
994
+ this.interactiveSourceArrow.setAttribute("d", i);
995
+ }
996
+ if (this.targetArrow) {
997
+ const i = this.targetArrow.getAttribute("d");
998
+ this.interactiveTargetArrow.setAttribute("d", i);
999
+ }
1000
+ }
1001
+ }
1002
+ const Fe = (t) => {
933
1003
  if (typeof t == "function")
934
1004
  return t;
935
1005
  switch (t == null ? void 0 : t.type) {
936
1006
  case "straight":
937
- return () => new Le({
1007
+ return () => new Ie({
938
1008
  color: t.color,
939
1009
  width: t.width,
940
1010
  arrowLength: t.arrowLength,
@@ -948,7 +1018,7 @@ const Be = (t) => {
948
1018
  detourDirection: t.detourDirection
949
1019
  });
950
1020
  case "horizontal":
951
- return () => new Ve({
1021
+ return () => new Be({
952
1022
  color: t.color,
953
1023
  width: t.width,
954
1024
  arrowLength: t.arrowLength,
@@ -962,7 +1032,7 @@ const Be = (t) => {
962
1032
  detourDirection: t.detourDirection
963
1033
  });
964
1034
  case "vertical":
965
- return () => new Re({
1035
+ return () => new Ue({
966
1036
  color: t.color,
967
1037
  width: t.width,
968
1038
  arrowLength: t.arrowLength,
@@ -976,7 +1046,7 @@ const Be = (t) => {
976
1046
  detourDirection: t.detourDirection
977
1047
  });
978
1048
  default:
979
- return () => new De({
1049
+ return () => new Re({
980
1050
  color: t.color,
981
1051
  width: t.width,
982
1052
  arrowLength: t.arrowLength,
@@ -990,102 +1060,102 @@ const Be = (t) => {
990
1060
  detourDirection: t.detourDirection
991
1061
  });
992
1062
  }
993
- }, Ie = (t) => {
994
- var o, r, s, h, n;
995
- const e = pe(
1063
+ }, ke = (t) => {
1064
+ var o, i, s, h, n;
1065
+ const e = xe(
996
1066
  (o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
997
- (r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
1067
+ (i = t == null ? void 0 : t.edges) == null ? void 0 : i.priority
998
1068
  );
999
1069
  return {
1000
1070
  nodes: {
1001
- centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? ve,
1071
+ centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? Ae,
1002
1072
  priorityFn: e.nodesPriorityFn
1003
1073
  },
1004
1074
  ports: {
1005
1075
  direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
1006
1076
  },
1007
1077
  edges: {
1008
- shapeFactory: Be(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
1078
+ shapeFactory: Fe(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
1009
1079
  priorityFn: e.edgesPriorityFn
1010
1080
  }
1011
1081
  };
1012
1082
  };
1013
- class se {
1014
- constructor(e, o, r, s, h) {
1083
+ class he {
1084
+ constructor(e, o, i, s, h) {
1015
1085
  /**
1016
1086
  * provides api for accessing model of rendered graph
1017
1087
  */
1018
- i(this, "graph");
1088
+ r(this, "graph");
1019
1089
  /**
1020
1090
  * provides api for accessing viewport state
1021
1091
  */
1022
- i(this, "viewport");
1023
- i(this, "defaults");
1024
- i(this, "nodeIdGenerator", new C(
1092
+ r(this, "viewport");
1093
+ r(this, "defaults");
1094
+ r(this, "nodeIdGenerator", new C(
1025
1095
  (e) => this.graph.getNode(e) !== null
1026
1096
  ));
1027
- i(this, "portIdGenerator", new C(
1097
+ r(this, "portIdGenerator", new C(
1028
1098
  (e) => this.graph.getPort(e) !== null
1029
1099
  ));
1030
- i(this, "edgeIdGenerator", new C(
1100
+ r(this, "edgeIdGenerator", new C(
1031
1101
  (e) => this.graph.getEdge(e) !== null
1032
1102
  ));
1033
- i(this, "onAfterNodeAdded", (e) => {
1103
+ r(this, "onAfterNodeAdded", (e) => {
1034
1104
  this.htmlView.attachNode(e);
1035
1105
  });
1036
- i(this, "onAfterNodeUpdated", (e) => {
1037
- this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((r) => {
1038
- this.htmlView.renderEdge(r);
1106
+ r(this, "onAfterNodeUpdated", (e) => {
1107
+ this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((i) => {
1108
+ this.htmlView.renderEdge(i);
1039
1109
  });
1040
1110
  });
1041
- i(this, "onAfterNodePriorityUpdated", (e) => {
1111
+ r(this, "onAfterNodePriorityUpdated", (e) => {
1042
1112
  this.htmlView.updateNodePriority(e);
1043
1113
  });
1044
- i(this, "onBeforeNodeRemoved", (e) => {
1114
+ r(this, "onBeforeNodeRemoved", (e) => {
1045
1115
  this.graphStore.getNodePortIds(e).forEach((o) => {
1046
1116
  this.unmarkPort(o);
1047
1117
  }), this.htmlView.detachNode(e);
1048
1118
  });
1049
- i(this, "onAfterPortUpdated", (e) => {
1050
- this.graphStore.getPortAdjacentEdgeIds(e).forEach((r) => {
1051
- this.htmlView.renderEdge(r);
1119
+ r(this, "onAfterPortUpdated", (e) => {
1120
+ this.graphStore.getPortAdjacentEdgeIds(e).forEach((i) => {
1121
+ this.htmlView.renderEdge(i);
1052
1122
  });
1053
1123
  });
1054
- i(this, "onBeforePortUnmarked", (e) => {
1124
+ r(this, "onBeforePortUnmarked", (e) => {
1055
1125
  this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
1056
1126
  this.removeEdge(o);
1057
1127
  });
1058
1128
  });
1059
- i(this, "onAfterEdgeAdded", (e) => {
1129
+ r(this, "onAfterEdgeAdded", (e) => {
1060
1130
  this.htmlView.attachEdge(e);
1061
1131
  });
1062
- i(this, "onAfterEdgeShapeUpdated", (e) => {
1132
+ r(this, "onAfterEdgeShapeUpdated", (e) => {
1063
1133
  this.htmlView.updateEdgeShape(e);
1064
1134
  });
1065
- i(this, "onAfterEdgeUpdated", (e) => {
1135
+ r(this, "onAfterEdgeUpdated", (e) => {
1066
1136
  this.htmlView.renderEdge(e);
1067
1137
  });
1068
- i(this, "onAfterEdgePriorityUpdated", (e) => {
1138
+ r(this, "onAfterEdgePriorityUpdated", (e) => {
1069
1139
  this.htmlView.updateEdgePriority(e);
1070
1140
  });
1071
- i(this, "onBeforeEdgeRemoved", (e) => {
1141
+ r(this, "onBeforeEdgeRemoved", (e) => {
1072
1142
  this.htmlView.detachEdge(e);
1073
1143
  });
1074
- i(this, "onBeforeClear", () => {
1144
+ r(this, "onBeforeClear", () => {
1075
1145
  this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
1076
1146
  });
1077
- i(this, "onBeforeDestroyEmitter");
1147
+ r(this, "onBeforeDestroyEmitter");
1078
1148
  /**
1079
1149
  * emits event just before destruction of canvas
1080
1150
  */
1081
- i(this, "onBeforeDestroy");
1082
- this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = Ie(h), this.graph = new fe(this.graphStore), this.viewport = new we(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
1151
+ r(this, "onBeforeDestroy");
1152
+ this.element = e, this.graphStore = o, this.viewportStore = i, this.htmlView = s, this.defaults = ke(h), this.graph = new pe(this.graphStore), this.viewport = new ye(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
1083
1153
  this.onAfterNodePriorityUpdated
1084
1154
  ), 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(
1085
1155
  this.onAfterEdgeShapeUpdated
1086
1156
  ), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
1087
1157
  this.onAfterEdgePriorityUpdated
1088
- ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = A();
1158
+ ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = x();
1089
1159
  }
1090
1160
  /**
1091
1161
  * adds new node
@@ -1102,12 +1172,12 @@ class se {
1102
1172
  centerFn: e.centerFn ?? this.defaults.nodes.centerFn,
1103
1173
  priority: e.priority ?? this.defaults.nodes.priorityFn()
1104
1174
  }), e.ports !== void 0)
1105
- for (const r of e.ports)
1175
+ for (const i of e.ports)
1106
1176
  this.markPort({
1107
- id: r.id,
1108
- element: r.element,
1177
+ id: i.id,
1178
+ element: i.element,
1109
1179
  nodeId: o,
1110
- direction: r.direction
1180
+ direction: i.direction
1111
1181
  });
1112
1182
  return this;
1113
1183
  }
@@ -1177,7 +1247,7 @@ class se {
1177
1247
  id: o,
1178
1248
  from: e.from,
1179
1249
  to: e.to,
1180
- shape: e.shape ?? this.defaults.edges.shapeFactory(),
1250
+ shape: e.shape ?? this.defaults.edges.shapeFactory(o),
1181
1251
  priority: e.priority ?? this.defaults.edges.priorityFn()
1182
1252
  }), this;
1183
1253
  }
@@ -1230,44 +1300,85 @@ class se {
1230
1300
  ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
1231
1301
  }
1232
1302
  }
1233
- class ne {
1303
+ class de {
1234
1304
  constructor() {
1235
- i(this, "nodes", /* @__PURE__ */ new Map());
1236
- i(this, "ports", /* @__PURE__ */ new Map());
1237
- i(this, "edges", /* @__PURE__ */ new Map());
1238
- i(this, "incomingEdges", /* @__PURE__ */ new Map());
1239
- i(this, "outcomingEdges", /* @__PURE__ */ new Map());
1240
- i(this, "cycleEdges", /* @__PURE__ */ new Map());
1241
- i(this, "afterNodeAddedEmitter");
1242
- i(this, "onAfterNodeAdded");
1243
- i(this, "afterNodeUpdatedEmitter");
1244
- i(this, "onAfterNodeUpdated");
1245
- i(this, "afterNodePriorityUpdatedEmitter");
1246
- i(this, "onAfterNodePriorityUpdated");
1247
- i(this, "beforeNodeRemovedEmitter");
1248
- i(this, "onBeforeNodeRemoved");
1249
- i(this, "afterPortAddedEmitter");
1250
- i(this, "onAfterPortAdded");
1251
- i(this, "afterPortUpdatedEmitter");
1252
- i(this, "onAfterPortUpdated");
1253
- i(this, "beforePortRemovedEmitter");
1254
- i(this, "onBeforePortRemoved");
1255
- i(this, "afterEdgeAddedEmitter");
1256
- i(this, "onAfterEdgeAdded");
1257
- i(this, "afterEdgeShapeUpdatedEmitter");
1258
- i(this, "onAfterEdgeShapeUpdated");
1259
- i(this, "afterEdgeUpdatedEmitter");
1260
- i(this, "onAfterEdgeUpdated");
1261
- i(this, "afterEdgePriorityUpdatedEmitter");
1262
- i(this, "onAfterEdgePriorityUpdated");
1263
- i(this, "beforeEdgeRemovedEmitter");
1264
- i(this, "onBeforeEdgeRemoved");
1265
- i(this, "beforeClearEmitter");
1266
- i(this, "onBeforeClear");
1267
- [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();
1305
+ r(this, "singleToMultiMap", /* @__PURE__ */ new Map());
1306
+ r(this, "multiToSingleMap", /* @__PURE__ */ new Map());
1307
+ }
1308
+ addRecord(e, o) {
1309
+ const i = this.singleToMultiMap.get(e);
1310
+ i === void 0 ? this.singleToMultiMap.set(e, /* @__PURE__ */ new Set([o])) : i.add(o), this.multiToSingleMap.set(o, e);
1311
+ }
1312
+ getMultiBySingle(e) {
1313
+ const o = this.singleToMultiMap.get(e) ?? /* @__PURE__ */ new Set();
1314
+ return Array.from(o.values());
1315
+ }
1316
+ removeByMulti(e) {
1317
+ const o = this.multiToSingleMap.get(e), i = this.singleToMultiMap.get(o);
1318
+ i.delete(e), i.size === 0 && this.singleToMultiMap.delete(o), this.multiToSingleMap.delete(e);
1319
+ }
1320
+ getByMulti(e) {
1321
+ return this.multiToSingleMap.get(e);
1322
+ }
1323
+ removeBySingle(e) {
1324
+ this.singleToMultiMap.get(e).forEach((i) => {
1325
+ this.multiToSingleMap.delete(i);
1326
+ }), this.singleToMultiMap.delete(e);
1327
+ }
1328
+ clear() {
1329
+ this.singleToMultiMap.clear(), this.multiToSingleMap.clear();
1330
+ }
1331
+ forEachSingle(e) {
1332
+ this.singleToMultiMap.forEach((o, i) => {
1333
+ e(i);
1334
+ });
1335
+ }
1336
+ hasSingle(e) {
1337
+ return this.singleToMultiMap.get(e) !== void 0;
1338
+ }
1339
+ hasMulti(e) {
1340
+ return this.multiToSingleMap.get(e) !== void 0;
1341
+ }
1342
+ }
1343
+ class ce {
1344
+ constructor() {
1345
+ r(this, "nodes", /* @__PURE__ */ new Map());
1346
+ r(this, "ports", /* @__PURE__ */ new Map());
1347
+ r(this, "edges", /* @__PURE__ */ new Map());
1348
+ r(this, "incomingEdges", /* @__PURE__ */ new Map());
1349
+ r(this, "outcomingEdges", /* @__PURE__ */ new Map());
1350
+ r(this, "cycleEdges", /* @__PURE__ */ new Map());
1351
+ r(this, "elementPorts", new de());
1352
+ r(this, "afterNodeAddedEmitter");
1353
+ r(this, "onAfterNodeAdded");
1354
+ r(this, "afterNodeUpdatedEmitter");
1355
+ r(this, "onAfterNodeUpdated");
1356
+ r(this, "afterNodePriorityUpdatedEmitter");
1357
+ r(this, "onAfterNodePriorityUpdated");
1358
+ r(this, "beforeNodeRemovedEmitter");
1359
+ r(this, "onBeforeNodeRemoved");
1360
+ r(this, "afterPortAddedEmitter");
1361
+ r(this, "onAfterPortAdded");
1362
+ r(this, "afterPortUpdatedEmitter");
1363
+ r(this, "onAfterPortUpdated");
1364
+ r(this, "beforePortRemovedEmitter");
1365
+ r(this, "onBeforePortRemoved");
1366
+ r(this, "afterEdgeAddedEmitter");
1367
+ r(this, "onAfterEdgeAdded");
1368
+ r(this, "afterEdgeShapeUpdatedEmitter");
1369
+ r(this, "onAfterEdgeShapeUpdated");
1370
+ r(this, "afterEdgeUpdatedEmitter");
1371
+ r(this, "onAfterEdgeUpdated");
1372
+ r(this, "afterEdgePriorityUpdatedEmitter");
1373
+ r(this, "onAfterEdgePriorityUpdated");
1374
+ r(this, "beforeEdgeRemovedEmitter");
1375
+ r(this, "onBeforeEdgeRemoved");
1376
+ r(this, "beforeClearEmitter");
1377
+ r(this, "onBeforeClear");
1378
+ [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = x(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = x(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = x(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = x(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = x(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = x(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = x(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = x(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = x(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = x(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = x(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = x(), [this.beforeClearEmitter, this.onBeforeClear] = x();
1268
1379
  }
1269
1380
  addNode(e) {
1270
- const o = /* @__PURE__ */ new Map(), r = {
1381
+ const o = /* @__PURE__ */ new Map(), i = {
1271
1382
  element: e.element,
1272
1383
  x: e.x,
1273
1384
  y: e.y,
@@ -1275,7 +1386,7 @@ class ne {
1275
1386
  priority: e.priority,
1276
1387
  ports: o
1277
1388
  };
1278
- this.nodes.set(e.id, r), this.afterNodeAddedEmitter.emit(e.id);
1389
+ this.nodes.set(e.id, i), this.afterNodeAddedEmitter.emit(e.id);
1279
1390
  }
1280
1391
  getAllNodeIds() {
1281
1392
  return Array.from(this.nodes.keys());
@@ -1284,8 +1395,8 @@ class ne {
1284
1395
  return this.nodes.get(e);
1285
1396
  }
1286
1397
  updateNode(e, o) {
1287
- const r = this.nodes.get(e);
1288
- 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);
1398
+ const i = this.nodes.get(e);
1399
+ i.x = o.x ?? i.x, i.y = o.y ?? i.y, i.centerFn = o.centerFn ?? i.centerFn, o.priority !== void 0 && (i.priority = o.priority, this.afterNodePriorityUpdatedEmitter.emit(e)), this.afterNodeUpdatedEmitter.emit(e);
1289
1400
  }
1290
1401
  removeNode(e) {
1291
1402
  this.beforeNodeRemovedEmitter.emit(e), this.nodes.delete(e);
@@ -1295,18 +1406,21 @@ class ne {
1295
1406
  element: e.element,
1296
1407
  direction: e.direction,
1297
1408
  nodeId: e.nodeId
1298
- }), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
1409
+ }), this.elementPorts.addRecord(e.element, e.id), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
1299
1410
  }
1300
1411
  getPort(e) {
1301
1412
  return this.ports.get(e);
1302
1413
  }
1303
1414
  updatePort(e, o) {
1304
- const r = this.ports.get(e);
1305
- r.direction = o.direction ?? r.direction, this.afterPortUpdatedEmitter.emit(e);
1415
+ const i = this.ports.get(e);
1416
+ i.direction = o.direction ?? i.direction, this.afterPortUpdatedEmitter.emit(e);
1306
1417
  }
1307
1418
  getAllPortIds() {
1308
1419
  return Array.from(this.ports.keys());
1309
1420
  }
1421
+ getElementPortsIds(e) {
1422
+ return this.elementPorts.getMultiBySingle(e);
1423
+ }
1310
1424
  getNodePortIds(e) {
1311
1425
  const o = this.nodes.get(e);
1312
1426
  if (o !== void 0)
@@ -1314,7 +1428,7 @@ class ne {
1314
1428
  }
1315
1429
  removePort(e) {
1316
1430
  const o = this.ports.get(e).nodeId;
1317
- this.beforePortRemovedEmitter.emit(e), this.nodes.get(o).ports.delete(e), this.ports.delete(e);
1431
+ this.beforePortRemovedEmitter.emit(e), this.nodes.get(o).ports.delete(e), this.ports.delete(e), this.elementPorts.removeByMulti(e);
1318
1432
  }
1319
1433
  addEdge(e) {
1320
1434
  this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
@@ -1330,8 +1444,8 @@ class ne {
1330
1444
  priority: s.priority
1331
1445
  });
1332
1446
  }
1333
- const r = this.edges.get(e);
1334
- 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);
1447
+ const i = this.edges.get(e);
1448
+ o.shape !== void 0 && (i.shape = o.shape, this.afterEdgeShapeUpdatedEmitter.emit(e)), o.priority !== void 0 && (i.priority = o.priority, this.afterEdgePriorityUpdatedEmitter.emit(e)), this.afterEdgeUpdatedEmitter.emit(e);
1335
1449
  }
1336
1450
  getAllEdgeIds() {
1337
1451
  return Array.from(this.edges.keys());
@@ -1363,24 +1477,24 @@ class ne {
1363
1477
  }
1364
1478
  getNodeIncomingEdgeIds(e) {
1365
1479
  const o = Array.from(this.nodes.get(e).ports.keys());
1366
- let r = [];
1480
+ let i = [];
1367
1481
  return o.forEach((s) => {
1368
- r = [...r, ...this.getPortIncomingEdgeIds(s)];
1369
- }), r;
1482
+ i = [...i, ...this.getPortIncomingEdgeIds(s)];
1483
+ }), i;
1370
1484
  }
1371
1485
  getNodeOutcomingEdgeIds(e) {
1372
1486
  const o = Array.from(this.nodes.get(e).ports.keys());
1373
- let r = [];
1487
+ let i = [];
1374
1488
  return o.forEach((s) => {
1375
- r = [...r, ...this.getPortOutcomingEdgeIds(s)];
1376
- }), r;
1489
+ i = [...i, ...this.getPortOutcomingEdgeIds(s)];
1490
+ }), i;
1377
1491
  }
1378
1492
  getNodeCycleEdgeIds(e) {
1379
1493
  const o = Array.from(this.nodes.get(e).ports.keys());
1380
- let r = [];
1494
+ let i = [];
1381
1495
  return o.forEach((s) => {
1382
- r = [...r, ...this.getPortCycleEdgeIds(s)];
1383
- }), r;
1496
+ i = [...i, ...this.getPortCycleEdgeIds(s)];
1497
+ }), i;
1384
1498
  }
1385
1499
  getNodeAdjacentEdgeIds(e) {
1386
1500
  return [
@@ -1398,28 +1512,28 @@ class ne {
1398
1512
  }), e.from !== e.to ? (this.outcomingEdges.get(e.from).add(e.id), this.incomingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
1399
1513
  }
1400
1514
  removeEdgeInternal(e) {
1401
- const o = this.edges.get(e), r = o.from, s = o.to;
1402
- this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.incomingEdges.get(r).delete(e), this.incomingEdges.get(s).delete(e), this.outcomingEdges.get(r).delete(e), this.outcomingEdges.get(s).delete(e), this.edges.delete(e);
1515
+ const o = this.edges.get(e), i = o.from, s = o.to;
1516
+ this.cycleEdges.get(i).delete(e), this.cycleEdges.get(s).delete(e), this.incomingEdges.get(i).delete(e), this.incomingEdges.get(s).delete(e), this.outcomingEdges.get(i).delete(e), this.outcomingEdges.get(s).delete(e), this.edges.delete(e);
1403
1517
  }
1404
1518
  }
1405
- const ee = (t) => ({
1519
+ const te = (t) => ({
1406
1520
  scale: 1 / t.scale,
1407
1521
  x: -t.x / t.scale,
1408
1522
  y: -t.y / t.scale
1409
- }), te = {
1523
+ }), oe = {
1410
1524
  scale: 1,
1411
1525
  x: 0,
1412
1526
  y: 0
1413
1527
  };
1414
- class Ue {
1528
+ class ze {
1415
1529
  constructor() {
1416
- i(this, "viewportMatrix", te);
1417
- i(this, "contentMatrix", te);
1418
- i(this, "afterUpdateEmitter");
1419
- i(this, "onAfterUpdated");
1420
- i(this, "beforeUpdateEmitter");
1421
- i(this, "onBeforeUpdated");
1422
- [this.afterUpdateEmitter, this.onAfterUpdated] = A(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = A();
1530
+ r(this, "viewportMatrix", oe);
1531
+ r(this, "contentMatrix", oe);
1532
+ r(this, "afterUpdateEmitter");
1533
+ r(this, "onAfterUpdated");
1534
+ r(this, "beforeUpdateEmitter");
1535
+ r(this, "onBeforeUpdated");
1536
+ [this.afterUpdateEmitter, this.onAfterUpdated] = x(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = x();
1423
1537
  }
1424
1538
  getViewportMatrix() {
1425
1539
  return this.viewportMatrix;
@@ -1432,80 +1546,80 @@ class Ue {
1432
1546
  scale: e.scale ?? this.viewportMatrix.scale,
1433
1547
  x: e.x ?? this.viewportMatrix.x,
1434
1548
  y: e.y ?? this.viewportMatrix.y
1435
- }, this.contentMatrix = ee(this.viewportMatrix), this.afterUpdateEmitter.emit();
1549
+ }, this.contentMatrix = te(this.viewportMatrix), this.afterUpdateEmitter.emit();
1436
1550
  }
1437
1551
  patchContentMatrix(e) {
1438
1552
  this.beforeUpdateEmitter.emit(), this.contentMatrix = {
1439
1553
  scale: e.scale ?? this.contentMatrix.scale,
1440
1554
  x: e.x ?? this.contentMatrix.x,
1441
1555
  y: e.y ?? this.contentMatrix.y
1442
- }, this.viewportMatrix = ee(this.contentMatrix), this.afterUpdateEmitter.emit();
1556
+ }, this.viewportMatrix = te(this.contentMatrix), this.afterUpdateEmitter.emit();
1443
1557
  }
1444
1558
  }
1445
- class k {
1559
+ class z {
1446
1560
  constructor(e) {
1447
- i(this, "elementToNodeId", /* @__PURE__ */ new Map());
1448
- i(this, "nodesResizeObserver");
1449
- i(this, "onAfterNodeAdded", (e) => {
1561
+ r(this, "elementToNodeId", /* @__PURE__ */ new Map());
1562
+ r(this, "nodesResizeObserver");
1563
+ r(this, "onAfterNodeAdded", (e) => {
1450
1564
  const o = this.canvas.graph.getNode(e);
1451
1565
  this.elementToNodeId.set(o.element, e), this.nodesResizeObserver.observe(o.element);
1452
1566
  });
1453
- i(this, "onBeforeNodeRemoved", (e) => {
1567
+ r(this, "onBeforeNodeRemoved", (e) => {
1454
1568
  const o = this.canvas.graph.getNode(e);
1455
1569
  this.elementToNodeId.delete(o.element), this.nodesResizeObserver.unobserve(o.element);
1456
1570
  });
1457
- i(this, "onBeforeClear", () => {
1571
+ r(this, "onBeforeClear", () => {
1458
1572
  this.nodesResizeObserver.disconnect(), this.elementToNodeId.clear();
1459
1573
  });
1460
- i(this, "onBeforeDestroy", () => {
1574
+ r(this, "onBeforeDestroy", () => {
1461
1575
  this.canvas.graph.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
1462
1576
  });
1463
1577
  this.canvas = e, this.nodesResizeObserver = new ResizeObserver((o) => {
1464
- o.forEach((r) => {
1465
- const s = r.target;
1578
+ o.forEach((i) => {
1579
+ const s = i.target;
1466
1580
  this.handleNodeResize(s);
1467
1581
  });
1468
1582
  }), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1469
1583
  }
1470
1584
  static configure(e) {
1471
- new k(e);
1585
+ new z(e);
1472
1586
  }
1473
1587
  handleNodeResize(e) {
1474
1588
  const o = this.elementToNodeId.get(e);
1475
1589
  this.canvas.updateNode(o);
1476
1590
  }
1477
1591
  }
1478
- const Ce = (t) => {
1479
- var g, y, p, f, E, x;
1592
+ const Oe = (t) => {
1593
+ var g, y, p, f, A, E;
1480
1594
  const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
1481
- }), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((p = t == null ? void 0 : t.events) == null ? void 0 : p.onNodeDragFinished) ?? (() => {
1482
- }), s = (t == null ? void 0 : t.moveOnTop) === !1, h = (f = t == null ? void 0 : t.mouse) == null ? void 0 : f.dragCursor, n = h !== void 0 ? h : "grab", d = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (T) => T.button === 0, a = (x = t == null ? void 0 : t.mouse) == null ? void 0 : x.mouseUpEventVerifier;
1595
+ }), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), i = ((p = t == null ? void 0 : t.events) == null ? void 0 : p.onNodeDragFinished) ?? (() => {
1596
+ }), s = (t == null ? void 0 : t.moveOnTop) === !1, h = (f = t == null ? void 0 : t.mouse) == null ? void 0 : f.dragCursor, n = h !== void 0 ? h : "grab", d = (A = t == null ? void 0 : t.mouse) == null ? void 0 : A.mouseDownEventVerifier, c = d !== void 0 ? d : (b) => b.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
1483
1597
  return {
1484
1598
  freezePriority: s,
1485
1599
  dragCursor: n,
1486
1600
  mouseDownEventVerifier: c,
1487
- mouseUpEventVerifier: a !== void 0 ? a : (T) => T.button === 0,
1601
+ mouseUpEventVerifier: a !== void 0 ? a : (b) => b.button === 0,
1488
1602
  onNodeDrag: e,
1489
1603
  onBeforeNodeDrag: o,
1490
- onNodeDragFinished: r
1604
+ onNodeDragFinished: i
1491
1605
  };
1492
- }, We = (t, e, o) => {
1493
- const { x: r, y: s, width: h, height: n } = t.getBoundingClientRect();
1494
- return e >= r && e <= r + h && o >= s && o <= s + n;
1495
- }, $e = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, M = (t, e, o, r) => We(e, o, r) && $e(t, o, r), B = (t, e) => {
1606
+ }, Xe = (t, e, o) => {
1607
+ const { x: i, y: s, width: h, height: n } = t.getBoundingClientRect();
1608
+ return e >= i && e <= i + h && o >= s && o <= s + n;
1609
+ }, Ye = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, M = (t, e, o, i) => Xe(e, o, i) && Ye(t, o, i), B = (t, e) => {
1496
1610
  e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
1497
1611
  }, N = (t, e) => ({
1498
1612
  x: t.scale * e.x + t.x,
1499
1613
  y: t.scale * e.y + t.y
1500
1614
  });
1501
1615
  class O {
1502
- constructor(e, o, r, s) {
1503
- i(this, "grabbedNodeId", null);
1504
- i(this, "maxNodePriority", 0);
1505
- i(this, "previousTouchCoordinates", null);
1506
- i(this, "nodeIds", /* @__PURE__ */ new Map());
1507
- i(this, "graph");
1508
- i(this, "onAfterNodeAdded", (e) => {
1616
+ constructor(e, o, i, s) {
1617
+ r(this, "grabbedNodeId", null);
1618
+ r(this, "maxNodePriority", 0);
1619
+ r(this, "previousTouchCoordinates", null);
1620
+ r(this, "nodeIds", /* @__PURE__ */ new Map());
1621
+ r(this, "graph");
1622
+ r(this, "onAfterNodeAdded", (e) => {
1509
1623
  this.updateMaxNodePriority(e);
1510
1624
  const o = this.graph.getNode(e);
1511
1625
  this.nodeIds.set(o.element, e), o.element.addEventListener("mousedown", this.onMouseDown, {
@@ -1514,50 +1628,50 @@ class O {
1514
1628
  passive: !0
1515
1629
  });
1516
1630
  });
1517
- i(this, "onAfterNodeUpdated", (e) => {
1631
+ r(this, "onAfterNodeUpdated", (e) => {
1518
1632
  this.updateMaxNodePriority(e);
1519
1633
  });
1520
- i(this, "onBeforeNodeRemoved", (e) => {
1634
+ r(this, "onBeforeNodeRemoved", (e) => {
1521
1635
  const o = this.graph.getNode(e);
1522
1636
  this.nodeIds.delete(o.element), o.element.removeEventListener("mousedown", this.onMouseDown), o.element.removeEventListener("touchstart", this.onTouchStart);
1523
1637
  });
1524
- i(this, "onBeforeDestroy", () => {
1638
+ r(this, "onBeforeDestroy", () => {
1525
1639
  this.graph.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy), this.removeMouseDragListeners(), this.removeTouchDragListeners();
1526
1640
  });
1527
- i(this, "onBeforeClear", () => {
1641
+ r(this, "onBeforeClear", () => {
1528
1642
  this.nodeIds.forEach((e, o) => {
1529
1643
  o.removeEventListener("mousedown", this.onMouseDown), o.removeEventListener("touchstart", this.onTouchStart);
1530
1644
  }), this.nodeIds.clear(), this.maxNodePriority = 0;
1531
1645
  });
1532
- i(this, "onMouseDown", (e) => {
1646
+ r(this, "onMouseDown", (e) => {
1533
1647
  if (!this.config.mouseDownEventVerifier(e))
1534
1648
  return;
1535
- const o = e.currentTarget, r = this.nodeIds.get(o), s = this.graph.getNode(r);
1649
+ const o = e.currentTarget, i = this.nodeIds.get(o), s = this.graph.getNode(i);
1536
1650
  this.config.onBeforeNodeDrag({
1537
- nodeId: r,
1651
+ nodeId: i,
1538
1652
  element: s.element,
1539
1653
  x: s.x,
1540
1654
  y: s.y
1541
- }) && (e.stopImmediatePropagation(), this.grabbedNodeId = r, B(this.element, this.config.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
1655
+ }) && (e.stopImmediatePropagation(), this.grabbedNodeId = i, B(this.element, this.config.dragCursor), this.moveNodeOnTop(i), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
1542
1656
  passive: !0
1543
1657
  }), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
1544
1658
  passive: !0
1545
1659
  }));
1546
1660
  });
1547
- i(this, "onTouchStart", (e) => {
1661
+ r(this, "onTouchStart", (e) => {
1548
1662
  if (e.touches.length !== 1)
1549
1663
  return;
1550
1664
  e.stopImmediatePropagation(), this.previousTouchCoordinates = {
1551
1665
  x: e.touches[0].clientX,
1552
1666
  y: e.touches[0].clientY
1553
1667
  };
1554
- const o = e.currentTarget, r = this.nodeIds.get(o), s = this.graph.getNode(r);
1668
+ const o = e.currentTarget, i = this.nodeIds.get(o), s = this.graph.getNode(i);
1555
1669
  this.config.onBeforeNodeDrag({
1556
- nodeId: r,
1670
+ nodeId: i,
1557
1671
  element: s.element,
1558
1672
  x: s.x,
1559
1673
  y: s.y
1560
- }) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
1674
+ }) && (this.grabbedNodeId = i, this.moveNodeOnTop(i), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
1561
1675
  passive: !0
1562
1676
  }), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
1563
1677
  passive: !0
@@ -1565,7 +1679,7 @@ class O {
1565
1679
  passive: !0
1566
1680
  }));
1567
1681
  });
1568
- i(this, "onWindowMouseMove", (e) => {
1682
+ r(this, "onWindowMouseMove", (e) => {
1569
1683
  if (!M(
1570
1684
  this.window,
1571
1685
  this.element,
@@ -1577,10 +1691,10 @@ class O {
1577
1691
  }
1578
1692
  this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
1579
1693
  });
1580
- i(this, "onWindowMouseUp", (e) => {
1694
+ r(this, "onWindowMouseUp", (e) => {
1581
1695
  this.config.mouseUpEventVerifier(e) && this.cancelMouseDrag();
1582
1696
  });
1583
- i(this, "onWindowTouchMove", (e) => {
1697
+ r(this, "onWindowTouchMove", (e) => {
1584
1698
  if (e.touches.length !== 1)
1585
1699
  return;
1586
1700
  const o = e.touches[0];
@@ -1601,16 +1715,16 @@ class O {
1601
1715
  };
1602
1716
  }
1603
1717
  });
1604
- i(this, "onWindowTouchFinish", () => {
1718
+ r(this, "onWindowTouchFinish", () => {
1605
1719
  this.previousTouchCoordinates = null, this.cancelTouchDrag();
1606
1720
  });
1607
- i(this, "config");
1608
- this.canvas = e, this.element = o, this.window = r, this.config = Ce(s), this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1721
+ r(this, "config");
1722
+ this.canvas = e, this.element = o, this.window = i, this.config = Oe(s), this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1609
1723
  }
1610
- static configure(e, o, r, s) {
1611
- new O(e, o, r, s);
1724
+ static configure(e, o, i, s) {
1725
+ new O(e, o, i, s);
1612
1726
  }
1613
- dragNode(e, o, r) {
1727
+ dragNode(e, o, i) {
1614
1728
  const s = this.graph.getNode(e);
1615
1729
  if (s === null)
1616
1730
  return;
@@ -1618,7 +1732,7 @@ class O {
1618
1732
  x: s.x,
1619
1733
  y: s.y
1620
1734
  }), d = N(
1621
- { scale: 1, x: o, y: r },
1735
+ { scale: 1, x: o, y: i },
1622
1736
  n
1623
1737
  ), c = this.canvas.viewport.getViewportMatrix(), a = N(c, d);
1624
1738
  this.canvas.updateNode(e, { x: a.x, y: a.y }), this.config.onNodeDrag({
@@ -1667,18 +1781,18 @@ class O {
1667
1781
  this.maxNodePriority = Math.max(this.maxNodePriority, o);
1668
1782
  }
1669
1783
  }
1670
- const Fe = (t) => {
1671
- 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;
1784
+ const He = (t) => {
1785
+ const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, i = t.minY !== null ? t.minY : -1 / 0, s = t.maxY !== null ? t.maxY : 1 / 0;
1672
1786
  return (h) => {
1673
1787
  let n = h.nextTransform.x, d = h.nextTransform.y;
1674
1788
  n < e && n < h.prevTransform.x && (n = Math.min(h.prevTransform.x, e));
1675
1789
  const c = h.canvasWidth * h.prevTransform.scale, a = o - c;
1676
- n > a && n > h.prevTransform.x && (n = Math.max(h.prevTransform.x, a)), d < r && d < h.prevTransform.y && (d = Math.min(h.prevTransform.y, r));
1790
+ n > a && n > h.prevTransform.x && (n = Math.max(h.prevTransform.x, a)), d < i && d < h.prevTransform.y && (d = Math.min(h.prevTransform.y, i));
1677
1791
  const l = h.canvasHeight * h.prevTransform.scale, g = s - l;
1678
1792
  return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: n, y: d };
1679
1793
  };
1680
- }, ze = (t) => {
1681
- const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
1794
+ }, je = (t) => {
1795
+ const e = t.maxContentScale, o = t.minContentScale, i = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
1682
1796
  return (h) => {
1683
1797
  const n = h.prevTransform, d = h.nextTransform;
1684
1798
  let c = d.scale, a = d.x, l = d.y;
@@ -1687,8 +1801,8 @@ const Fe = (t) => {
1687
1801
  const g = (c - n.scale) / (d.scale - n.scale);
1688
1802
  a = n.x + (d.x - n.x) * g, l = n.y + (d.y - n.y) * g;
1689
1803
  }
1690
- if (d.scale < r && d.scale < n.scale) {
1691
- c = Math.min(n.scale, r), a = n.x, l = n.y;
1804
+ if (d.scale < i && d.scale < n.scale) {
1805
+ c = Math.min(n.scale, i), a = n.x, l = n.y;
1692
1806
  const g = (c - n.scale) / (d.scale - n.scale);
1693
1807
  a = n.x + (d.x - n.x) * g, l = n.y + (d.y - n.y) * g;
1694
1808
  }
@@ -1698,46 +1812,46 @@ const Fe = (t) => {
1698
1812
  y: l
1699
1813
  };
1700
1814
  };
1701
- }, ke = (t) => (e) => t.reduce(
1702
- (o, r) => r({
1815
+ }, Ge = (t) => (e) => t.reduce(
1816
+ (o, i) => i({
1703
1817
  prevTransform: e.prevTransform,
1704
1818
  nextTransform: o,
1705
1819
  canvasWidth: e.canvasWidth,
1706
1820
  canvasHeight: e.canvasHeight
1707
1821
  }),
1708
1822
  e.nextTransform
1709
- ), oe = (t) => {
1823
+ ), re = (t) => {
1710
1824
  if (typeof t == "function")
1711
1825
  return t;
1712
1826
  switch (t.type) {
1713
1827
  case "scale-limit":
1714
- return ze({
1828
+ return je({
1715
1829
  minContentScale: t.minContentScale ?? 0,
1716
1830
  maxContentScale: t.maxContentScale ?? 1 / 0
1717
1831
  });
1718
1832
  case "shift-limit":
1719
- return Fe({
1833
+ return He({
1720
1834
  minX: t.minX ?? -1 / 0,
1721
1835
  maxX: t.maxX ?? 1 / 0,
1722
1836
  minY: t.minY ?? -1 / 0,
1723
1837
  maxY: t.maxY ?? 1 / 0
1724
1838
  });
1725
1839
  }
1726
- }, Oe = (t) => {
1727
- var f, E, x, T, b, m, D, V, j, G, J, K;
1728
- const e = (f = t == null ? void 0 : t.scale) == null ? void 0 : f.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
1840
+ }, Ze = (t) => {
1841
+ var f, A, E, b, T, m, D, L, j, G, Z, J;
1842
+ const e = (f = t == null ? void 0 : t.scale) == null ? void 0 : f.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, i = t == null ? void 0 : t.transformPreprocessor;
1729
1843
  let s;
1730
- r !== void 0 ? Array.isArray(r) ? s = ke(
1731
- r.map(
1732
- (P) => oe(P)
1844
+ i !== void 0 ? Array.isArray(i) ? s = Ge(
1845
+ i.map(
1846
+ (P) => re(P)
1733
1847
  )
1734
- ) : s = oe(r) : s = (P) => P.nextTransform;
1735
- const h = ((E = t == null ? void 0 : t.shift) == null ? void 0 : E.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
1736
- }), d = ((T = t == null ? void 0 : t.events) == null ? void 0 : T.onTransformChange) ?? (() => {
1737
- }), c = (b = t == null ? void 0 : t.shift) == null ? void 0 : b.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, y = (D = t == null ? void 0 : t.scale) == null ? void 0 : D.mouseWheelEventVerifier, p = y !== void 0 ? y : () => !0;
1848
+ ) : s = re(i) : s = (P) => P.nextTransform;
1849
+ const h = ((A = t == null ? void 0 : t.shift) == null ? void 0 : A.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
1850
+ }), d = ((b = t == null ? void 0 : t.events) == null ? void 0 : b.onTransformChange) ?? (() => {
1851
+ }), c = (T = t == null ? void 0 : t.shift) == null ? void 0 : T.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, y = (D = t == null ? void 0 : t.scale) == null ? void 0 : D.mouseWheelEventVerifier, p = y !== void 0 ? y : () => !0;
1738
1852
  return {
1739
1853
  wheelSensitivity: o,
1740
- onTransformStarted: ((V = t == null ? void 0 : t.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
1854
+ onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
1741
1855
  }),
1742
1856
  onTransformFinished: ((j = t == null ? void 0 : t.events) == null ? void 0 : j.onTransformFinished) ?? (() => {
1743
1857
  }),
@@ -1749,27 +1863,27 @@ const Fe = (t) => {
1749
1863
  mouseUpEventVerifier: g,
1750
1864
  mouseWheelEventVerifier: p,
1751
1865
  scaleWheelFinishTimeout: ((G = t == null ? void 0 : t.scale) == null ? void 0 : G.wheelFinishTimeout) ?? 500,
1752
- onResizeTransformStarted: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onResizeTransformStarted) ?? (() => {
1866
+ onResizeTransformStarted: ((Z = t == null ? void 0 : t.events) == null ? void 0 : Z.onResizeTransformStarted) ?? (() => {
1753
1867
  }),
1754
- onResizeTransformFinished: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onResizeTransformFinished) ?? (() => {
1868
+ onResizeTransformFinished: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onResizeTransformFinished) ?? (() => {
1755
1869
  })
1756
1870
  };
1757
- }, Xe = (t, e, o) => ({
1871
+ }, Je = (t, e, o) => ({
1758
1872
  scale: t.scale,
1759
1873
  x: t.x + t.scale * e,
1760
1874
  y: t.y + t.scale * o
1761
- }), Ye = (t, e, o, r) => ({
1875
+ }), Ke = (t, e, o, i) => ({
1762
1876
  scale: t.scale * e,
1763
1877
  x: t.scale * (1 - e) * o + t.x,
1764
- y: t.scale * (1 - e) * r + t.y
1878
+ y: t.scale * (1 - e) * i + t.y
1765
1879
  }), R = (t) => {
1766
1880
  const e = [], o = t.touches.length;
1767
1881
  for (let d = 0; d < o; d++)
1768
1882
  e.push([t.touches[d].clientX, t.touches[d].clientY]);
1769
- const r = e.reduce(
1883
+ const i = e.reduce(
1770
1884
  (d, c) => [d[0] + c[0], d[1] + c[1]],
1771
1885
  [0, 0]
1772
- ), s = [r[0] / o, r[1] / o], n = e.map((d) => [d[0] - s[0], d[1] - s[1]]).reduce(
1886
+ ), s = [i[0] / o, i[1] / o], n = e.map((d) => [d[0] - s[0], d[1] - s[1]]).reduce(
1773
1887
  (d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
1774
1888
  0
1775
1889
  );
@@ -1782,22 +1896,22 @@ const Fe = (t) => {
1782
1896
  };
1783
1897
  };
1784
1898
  class U {
1785
- constructor(e, o, r, s) {
1786
- i(this, "viewport");
1787
- i(this, "prevTouches", null);
1788
- i(this, "wheelFinishTimer", null);
1789
- i(this, "transformInProgress", !1);
1790
- i(this, "onBeforeDestroy", () => {
1899
+ constructor(e, o, i, s) {
1900
+ r(this, "viewport");
1901
+ r(this, "prevTouches", null);
1902
+ r(this, "wheelFinishTimer", null);
1903
+ r(this, "transformInProgress", !1);
1904
+ r(this, "onBeforeDestroy", () => {
1791
1905
  this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element.removeEventListener("wheel", this.preventWheelScaleListener), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
1792
1906
  });
1793
- i(this, "onMouseDown", (e) => {
1907
+ r(this, "onMouseDown", (e) => {
1794
1908
  this.element === null || !this.config.mouseDownEventVerifier(e) || (B(this.element, this.config.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
1795
1909
  passive: !0
1796
1910
  }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
1797
1911
  passive: !0
1798
1912
  }), this.startRegisteredTransform());
1799
1913
  });
1800
- i(this, "onWindowMouseMove", (e) => {
1914
+ r(this, "onWindowMouseMove", (e) => {
1801
1915
  const o = M(
1802
1916
  this.window,
1803
1917
  this.element,
@@ -1808,21 +1922,21 @@ class U {
1808
1922
  this.stopMouseDrag();
1809
1923
  return;
1810
1924
  }
1811
- const r = -e.movementX, s = -e.movementY;
1812
- this.moveViewport(r, s);
1925
+ const i = -e.movementX, s = -e.movementY;
1926
+ this.moveViewport(i, s);
1813
1927
  });
1814
- i(this, "onWindowMouseUp", (e) => {
1928
+ r(this, "onWindowMouseUp", (e) => {
1815
1929
  this.element === null || !this.config.mouseUpEventVerifier(e) || this.stopMouseDrag();
1816
1930
  });
1817
- i(this, "onWheelScroll", (e) => {
1931
+ r(this, "onWheelScroll", (e) => {
1818
1932
  if (!this.config.mouseWheelEventVerifier(e))
1819
1933
  return;
1820
- const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o, h = e.clientY - r, d = 1 / (e.deltaY < 0 ? this.config.wheelSensitivity : 1 / this.config.wheelSensitivity);
1934
+ const { left: o, top: i } = this.element.getBoundingClientRect(), s = e.clientX - o, h = e.clientY - i, d = 1 / (e.deltaY < 0 ? this.config.wheelSensitivity : 1 / this.config.wheelSensitivity);
1821
1935
  this.wheelFinishTimer === null && this.config.onTransformStarted(), this.scaleViewport(d, s, h), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
1822
1936
  this.transformInProgress || this.config.onTransformFinished(), this.wheelFinishTimer = null;
1823
1937
  }, this.config.scaleWheelFinishTimeout);
1824
1938
  });
1825
- i(this, "onTouchStart", (e) => {
1939
+ r(this, "onTouchStart", (e) => {
1826
1940
  if (this.prevTouches !== null) {
1827
1941
  this.prevTouches = R(e);
1828
1942
  return;
@@ -1835,7 +1949,7 @@ class U {
1835
1949
  passive: !0
1836
1950
  }), this.startRegisteredTransform();
1837
1951
  });
1838
- i(this, "onWindowTouchMove", (e) => {
1952
+ r(this, "onWindowTouchMove", (e) => {
1839
1953
  const o = R(e);
1840
1954
  if (!o.touches.every(
1841
1955
  (s) => M(this.window, this.element, s[0], s[1])
@@ -1852,25 +1966,25 @@ class U {
1852
1966
  }
1853
1967
  this.prevTouches = o;
1854
1968
  });
1855
- i(this, "onWindowTouchFinish", (e) => {
1969
+ r(this, "onWindowTouchFinish", (e) => {
1856
1970
  e.touches.length > 0 ? this.prevTouches = R(e) : this.stopTouchDrag();
1857
1971
  });
1858
- i(this, "observer", new ResizeObserver(() => {
1859
- const e = this.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.config.transformPreprocessor({
1972
+ r(this, "observer", new ResizeObserver(() => {
1973
+ const e = this.viewport.getViewportMatrix(), { width: o, height: i } = this.element.getBoundingClientRect(), s = this.config.transformPreprocessor({
1860
1974
  prevTransform: e,
1861
1975
  nextTransform: e,
1862
1976
  canvasWidth: o,
1863
- canvasHeight: r
1977
+ canvasHeight: i
1864
1978
  });
1865
1979
  this.config.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.config.onResizeTransformFinished();
1866
1980
  }));
1867
- i(this, "config");
1868
- i(this, "preventWheelScaleListener", (e) => {
1981
+ r(this, "config");
1982
+ r(this, "preventWheelScaleListener", (e) => {
1869
1983
  e.preventDefault();
1870
1984
  });
1871
- this.canvas = e, this.element = o, this.window = r, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
1985
+ this.canvas = e, this.element = o, this.window = i, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
1872
1986
  passive: !1
1873
- }), this.config = Oe(s), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown, {
1987
+ }), this.config = Ze(s), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown, {
1874
1988
  passive: !0
1875
1989
  }), this.element.addEventListener("wheel", this.onWheelScroll, {
1876
1990
  passive: !0
@@ -1878,25 +1992,25 @@ class U {
1878
1992
  passive: !0
1879
1993
  }), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1880
1994
  }
1881
- static configure(e, o, r, s) {
1995
+ static configure(e, o, i, s) {
1882
1996
  new U(
1883
1997
  e,
1884
1998
  o,
1885
- r,
1999
+ i,
1886
2000
  s
1887
2001
  );
1888
2002
  }
1889
2003
  moveViewport(e, o) {
1890
- const r = this.viewport.getViewportMatrix(), s = Xe(r, e, o), { width: h, height: n } = this.element.getBoundingClientRect(), d = this.config.transformPreprocessor({
1891
- prevTransform: r,
2004
+ const i = this.viewport.getViewportMatrix(), s = Je(i, e, o), { width: h, height: n } = this.element.getBoundingClientRect(), d = this.config.transformPreprocessor({
2005
+ prevTransform: i,
1892
2006
  nextTransform: s,
1893
2007
  canvasWidth: h,
1894
2008
  canvasHeight: n
1895
2009
  });
1896
2010
  this.performTransform(d);
1897
2011
  }
1898
- scaleViewport(e, o, r) {
1899
- const s = this.canvas.viewport.getViewportMatrix(), h = Ye(s, e, o, r), { width: n, height: d } = this.element.getBoundingClientRect(), c = this.config.transformPreprocessor({
2012
+ scaleViewport(e, o, i) {
2013
+ const s = this.canvas.viewport.getViewportMatrix(), h = Ke(s, e, o, i), { width: n, height: d } = this.element.getBoundingClientRect(), c = this.config.transformPreprocessor({
1900
2014
  prevTransform: s,
1901
2015
  nextTransform: h,
1902
2016
  canvasWidth: n,
@@ -1927,21 +2041,21 @@ class U {
1927
2041
  }
1928
2042
  }
1929
2043
  class X {
1930
- constructor(e, o, r, s, h, n) {
1931
- i(this, "canvasResizeObserver");
1932
- i(this, "nodeHorizontal");
1933
- i(this, "nodeVertical");
1934
- i(this, "viewport");
1935
- i(this, "viewportWidth", 0);
1936
- i(this, "viewportHeight", 0);
1937
- i(this, "viewportMatrix");
1938
- i(this, "loadedArea", {
2044
+ constructor(e, o, i, s, h, n) {
2045
+ r(this, "canvasResizeObserver");
2046
+ r(this, "nodeHorizontal");
2047
+ r(this, "nodeVertical");
2048
+ r(this, "viewport");
2049
+ r(this, "viewportWidth", 0);
2050
+ r(this, "viewportHeight", 0);
2051
+ r(this, "viewportMatrix");
2052
+ r(this, "loadedArea", {
1939
2053
  xFrom: 1 / 0,
1940
2054
  xTo: 1 / 0,
1941
2055
  yFrom: 1 / 0,
1942
2056
  yTo: 1 / 0
1943
2057
  });
1944
- i(this, "updateLoadedArea", (e) => {
2058
+ r(this, "updateLoadedArea", (e) => {
1945
2059
  this.loadedArea = {
1946
2060
  xFrom: e.x,
1947
2061
  xTo: e.x + e.width,
@@ -1949,25 +2063,25 @@ class X {
1949
2063
  yTo: e.y + e.height
1950
2064
  };
1951
2065
  });
1952
- i(this, "onBeforeDestroy", () => {
2066
+ r(this, "onBeforeDestroy", () => {
1953
2067
  this.trigger.unsubscribe(this.updateLoadedArea), this.canvasResizeObserver.unobserve(this.element), this.canvas.viewport.onAfterUpdated.unsubscribe(
1954
2068
  this.onAfterViewportUpdated
1955
2069
  ), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
1956
2070
  });
1957
- i(this, "onAfterViewportUpdated", () => {
2071
+ r(this, "onAfterViewportUpdated", () => {
1958
2072
  this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
1959
2073
  });
1960
- i(this, "userTransformInProgress", !1);
1961
- var p, f, E, x, T;
1962
- this.canvas = e, this.element = o, this.window = r, this.trigger = h, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((b) => {
1963
- const m = b[0];
2074
+ r(this, "userTransformInProgress", !1);
2075
+ var p, f, A, E, b;
2076
+ this.canvas = e, this.element = o, this.window = i, this.trigger = h, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((T) => {
2077
+ const m = T[0];
1964
2078
  this.viewportWidth = m.contentRect.width, this.viewportHeight = m.contentRect.height, this.scheduleLoadAreaAroundViewport();
1965
2079
  }), this.viewport = e.viewport;
1966
2080
  const d = ((p = s == null ? void 0 : s.events) == null ? void 0 : p.onResizeTransformStarted) ?? (() => {
1967
2081
  }), c = ((f = s == null ? void 0 : s.events) == null ? void 0 : f.onResizeTransformFinished) ?? (() => {
1968
- }), a = ((E = s == null ? void 0 : s.events) == null ? void 0 : E.onTransformChange) ?? (() => {
1969
- }), l = ((x = s == null ? void 0 : s.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
1970
- }), g = ((T = s == null ? void 0 : s.events) == null ? void 0 : T.onTransformFinished) ?? (() => {
2082
+ }), a = ((A = s == null ? void 0 : s.events) == null ? void 0 : A.onTransformChange) ?? (() => {
2083
+ }), l = ((E = s == null ? void 0 : s.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
2084
+ }), g = ((b = s == null ? void 0 : s.events) == null ? void 0 : b.onTransformFinished) ?? (() => {
1971
2085
  }), y = {
1972
2086
  ...s,
1973
2087
  events: {
@@ -1983,8 +2097,8 @@ class X {
1983
2097
  },
1984
2098
  onTransformChange: () => {
1985
2099
  this.userTransformInProgress = !1;
1986
- const b = this.viewportMatrix;
1987
- this.viewportMatrix = this.viewport.getViewportMatrix(), b.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), a();
2100
+ const T = this.viewportMatrix;
2101
+ this.viewportMatrix = this.viewport.getViewportMatrix(), T.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), a();
1988
2102
  },
1989
2103
  onTransformFinished: () => {
1990
2104
  this.scheduleLoadAreaAroundViewport(), g();
@@ -1998,11 +2112,11 @@ class X {
1998
2112
  y
1999
2113
  ), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2000
2114
  }
2001
- static configure(e, o, r, s, h, n) {
2115
+ static configure(e, o, i, s, h, n) {
2002
2116
  new X(
2003
2117
  e,
2004
2118
  o,
2005
- r,
2119
+ i,
2006
2120
  s,
2007
2121
  h,
2008
2122
  n
@@ -2014,162 +2128,122 @@ class X {
2014
2128
  });
2015
2129
  }
2016
2130
  scheduleEnsureViewportAreaLoaded() {
2017
- 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, h = this.viewportMatrix.x + e + this.nodeHorizontal, n = this.viewportMatrix.y + o + this.nodeVertical;
2018
- this.loadedArea.xFrom < r && this.loadedArea.xTo > h && this.loadedArea.yFrom < s && this.loadedArea.yTo > n || this.scheduleLoadAreaAroundViewport();
2131
+ const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, i = this.viewportMatrix.x - this.nodeHorizontal, s = this.viewportMatrix.y - this.nodeVertical, h = this.viewportMatrix.x + e + this.nodeHorizontal, n = this.viewportMatrix.y + o + this.nodeVertical;
2132
+ this.loadedArea.xFrom < i && this.loadedArea.xTo > h && this.loadedArea.yFrom < s && this.loadedArea.yTo > n || this.scheduleLoadAreaAroundViewport();
2019
2133
  }
2020
2134
  loadAreaAroundViewport() {
2021
- 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, h = 3 * e + 2 * this.nodeHorizontal, n = 3 * o + 2 * this.nodeVertical;
2022
- this.trigger.emit({ x: r, y: s, width: h, height: n });
2135
+ const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, i = this.viewportMatrix.x - e - this.nodeHorizontal, s = this.viewportMatrix.y - o - this.nodeVertical, h = 3 * e + 2 * this.nodeHorizontal, n = 3 * o + 2 * this.nodeVertical;
2136
+ this.trigger.emit({ x: i, y: s, width: h, height: n });
2023
2137
  }
2024
2138
  }
2025
- const He = () => {
2139
+ const Qe = () => {
2026
2140
  const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2027
2141
  return t.style.position = "absolute", t.style.inset = "0", t;
2028
- }, je = () => {
2142
+ }, _e = () => {
2029
2143
  const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2030
2144
  return t.setAttribute("fill", "url(#pattern)"), t;
2031
- }, Ge = () => {
2145
+ }, qe = () => {
2032
2146
  const t = document.createElementNS(
2033
2147
  "http://www.w3.org/2000/svg",
2034
2148
  "pattern"
2035
2149
  );
2036
2150
  return t.setAttribute("id", "pattern"), t;
2037
- }, Je = (t, e) => {
2151
+ }, et = (t, e) => {
2038
2152
  const o = document.createElementNS(
2039
2153
  "http://www.w3.org/2000/svg",
2040
2154
  "circle"
2041
2155
  );
2042
2156
  return o.setAttribute("cx", "0"), o.setAttribute("cy", "0"), o.setAttribute("r", `${t}`), o.setAttribute("fill", `${e}`), o;
2043
- }, Ke = (t) => t instanceof SVGElement ? t : Je(
2157
+ }, tt = (t) => t instanceof SVGElement ? t : et(
2044
2158
  (t == null ? void 0 : t.radius) ?? 1.5,
2045
2159
  (t == null ? void 0 : t.color) ?? "#d8d8d8"
2046
- ), Qe = (t) => {
2047
- const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, r = (e == null ? void 0 : e.height) ?? 25, s = Ke(t.renderer ?? {});
2160
+ ), ot = (t) => {
2161
+ const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, i = (e == null ? void 0 : e.height) ?? 25, s = tt(t.renderer ?? {});
2048
2162
  return {
2049
2163
  tileWidth: o,
2050
- tileHeight: r,
2164
+ tileHeight: i,
2051
2165
  renderer: s,
2052
2166
  maxViewportScale: t.maxViewportScale ?? 10
2053
2167
  };
2054
2168
  };
2055
2169
  class Y {
2056
- constructor(e, o, r) {
2057
- i(this, "svg", He());
2058
- i(this, "patternRenderingRectangle", je());
2059
- i(this, "pattern", Ge());
2060
- i(this, "patternContent");
2061
- i(this, "tileWidth");
2062
- i(this, "tileHeight");
2063
- i(this, "halfTileWidth");
2064
- i(this, "halfTileHeight");
2065
- i(this, "maxViewportScale");
2066
- i(this, "visible", !1);
2067
- i(this, "resizeObserver", new ResizeObserver((e) => {
2068
- const o = e[0], { width: r, height: s } = o.contentRect;
2069
- this.svg.setAttribute("width", `${r}`), this.svg.setAttribute("height", `${s}`), this.patternRenderingRectangle.setAttribute("width", `${r}`), this.patternRenderingRectangle.setAttribute("height", `${s}`);
2070
- const h = this.tileWidth / r, n = this.tileHeight / s;
2170
+ constructor(e, o, i) {
2171
+ r(this, "svg", Qe());
2172
+ r(this, "patternRenderingRectangle", _e());
2173
+ r(this, "pattern", qe());
2174
+ r(this, "patternContent");
2175
+ r(this, "tileWidth");
2176
+ r(this, "tileHeight");
2177
+ r(this, "halfTileWidth");
2178
+ r(this, "halfTileHeight");
2179
+ r(this, "maxViewportScale");
2180
+ r(this, "visible", !1);
2181
+ r(this, "resizeObserver", new ResizeObserver((e) => {
2182
+ const o = e[0], { width: i, height: s } = o.contentRect;
2183
+ this.svg.setAttribute("width", `${i}`), this.svg.setAttribute("height", `${s}`), this.patternRenderingRectangle.setAttribute("width", `${i}`), this.patternRenderingRectangle.setAttribute("height", `${s}`);
2184
+ const h = this.tileWidth / i, n = this.tileHeight / s;
2071
2185
  this.pattern.setAttribute("width", `${h}`), this.pattern.setAttribute("height", `${n}`);
2072
2186
  }));
2073
- i(this, "onAfterTransformUpdated", () => {
2074
- const e = this.canvas.viewport.getContentMatrix(), o = e.x - this.halfTileWidth * e.scale, r = e.y - this.halfTileHeight * e.scale, s = `matrix(${e.scale}, 0, 0, ${e.scale}, ${o}, ${r})`;
2187
+ r(this, "onAfterTransformUpdated", () => {
2188
+ const e = this.canvas.viewport.getContentMatrix(), o = e.x - this.halfTileWidth * e.scale, i = e.y - this.halfTileHeight * e.scale, s = `matrix(${e.scale}, 0, 0, ${e.scale}, ${o}, ${i})`;
2075
2189
  this.pattern.setAttribute("patternTransform", s), this.updateVisibility();
2076
2190
  });
2077
- i(this, "onBeforeDestroy", () => {
2191
+ r(this, "onBeforeDestroy", () => {
2078
2192
  this.resizeObserver.unobserve(this.host), this.host.removeChild(this.svg), this.canvas.viewport.onAfterUpdated.unsubscribe(
2079
2193
  this.onAfterTransformUpdated
2080
2194
  ), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
2081
2195
  });
2082
- this.canvas = e, this.host = r;
2083
- const s = Qe(o);
2196
+ this.canvas = e, this.host = i;
2197
+ const s = ot(o);
2084
2198
  this.tileWidth = s.tileWidth, this.tileHeight = s.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = s.renderer, this.maxViewportScale = s.maxViewportScale;
2085
2199
  const h = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
2086
2200
  this.patternContent.setAttribute("transform", h), this.pattern.appendChild(this.patternContent);
2087
2201
  const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
2088
2202
  n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.host), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated(), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2089
2203
  }
2090
- static configure(e, o, r) {
2091
- new Y(e, o, r);
2204
+ static configure(e, o, i) {
2205
+ new Y(e, o, i);
2092
2206
  }
2093
2207
  updateVisibility() {
2094
2208
  const o = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
2095
2209
  o && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !o && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
2096
2210
  }
2097
2211
  }
2098
- const Ze = (t) => {
2212
+ const rt = (t) => {
2099
2213
  var d, c, a;
2100
- const e = () => "direct", o = (l) => l, r = (l) => l.button === 0, s = () => {
2214
+ const e = () => "direct", o = (l) => l, i = (l) => l.button === 0, s = () => {
2101
2215
  }, h = () => {
2102
2216
  }, n = () => {
2103
2217
  };
2104
2218
  return {
2105
2219
  connectionTypeResolver: t.connectionTypeResolver ?? e,
2106
2220
  connectionPreprocessor: t.connectionPreprocessor ?? o,
2107
- mouseDownEventVerifier: t.mouseDownEventVerifier ?? r,
2108
- mouseUpEventVerifier: t.mouseUpEventVerifier ?? r,
2221
+ mouseDownEventVerifier: t.mouseDownEventVerifier ?? i,
2222
+ mouseUpEventVerifier: t.mouseUpEventVerifier ?? i,
2109
2223
  onAfterEdgeCreated: ((d = t.events) == null ? void 0 : d.onAfterEdgeCreated) ?? s,
2110
2224
  onEdgeCreationInterrupted: ((c = t.events) == null ? void 0 : c.onEdgeCreationInterrupted) ?? n,
2111
2225
  onEdgeCreationPrevented: ((a = t.events) == null ? void 0 : a.onEdgeCreationPrevented) ?? h,
2112
2226
  dragPortDirection: t.dragPortDirection ?? void 0
2113
2227
  };
2114
2228
  };
2115
- class _e {
2116
- constructor() {
2117
- i(this, "singleToMultiMap", /* @__PURE__ */ new Map());
2118
- i(this, "multiToSingleMap", /* @__PURE__ */ new Map());
2119
- }
2120
- addRecord(e, o) {
2121
- const r = this.singleToMultiMap.get(e);
2122
- r === void 0 ? this.singleToMultiMap.set(e, /* @__PURE__ */ new Set([o])) : r.add(o), this.multiToSingleMap.set(o, e);
2123
- }
2124
- getFirstBySingle(e) {
2125
- const o = this.singleToMultiMap.get(e);
2126
- return o === void 0 ? void 0 : Array.from(o.values())[0];
2127
- }
2128
- removeByMulti(e) {
2129
- const o = this.multiToSingleMap.get(e), r = this.singleToMultiMap.get(o);
2130
- r.delete(e), r.size === 0 && this.singleToMultiMap.delete(o), this.multiToSingleMap.delete(e);
2131
- }
2132
- getByMulti(e) {
2133
- return this.multiToSingleMap.get(e);
2134
- }
2135
- removeBySingle(e) {
2136
- this.singleToMultiMap.get(e).forEach((r) => {
2137
- this.multiToSingleMap.delete(r);
2138
- }), this.singleToMultiMap.delete(e);
2139
- }
2140
- clear() {
2141
- this.singleToMultiMap.clear(), this.multiToSingleMap.clear();
2142
- }
2143
- forEachSingle(e) {
2144
- this.singleToMultiMap.forEach((o, r) => {
2145
- e(r);
2146
- });
2147
- }
2148
- hasSingle(e) {
2149
- return this.singleToMultiMap.get(e) !== void 0;
2150
- }
2151
- hasMulti(e) {
2152
- return this.multiToSingleMap.get(e) !== void 0;
2153
- }
2154
- }
2155
2229
  class H {
2156
- constructor(e, o, r, s, h, n) {
2157
- i(this, "config");
2158
- i(this, "overlayCanvas");
2159
- i(this, "ports", new _e());
2160
- i(this, "staticOverlayPortId", "static");
2161
- i(this, "draggingOverlayPortId", "dragging");
2162
- i(this, "staticPortId", null);
2163
- i(this, "isDirect", !0);
2164
- i(this, "onAfterPortMarked", (e) => {
2230
+ constructor(e, o, i, s, h, n) {
2231
+ r(this, "config");
2232
+ r(this, "overlayCanvas");
2233
+ r(this, "ports", new de());
2234
+ r(this, "staticOverlayPortId", "static");
2235
+ r(this, "draggingOverlayPortId", "dragging");
2236
+ r(this, "staticPortId", null);
2237
+ r(this, "isDirect", !0);
2238
+ r(this, "onAfterPortMarked", (e) => {
2165
2239
  const o = this.canvas.graph.getPort(e);
2166
2240
  this.ports.hasSingle(o.element) || this.hookPortEvents(o.element), this.ports.addRecord(o.element, e);
2167
2241
  });
2168
- i(this, "onBeforePortUnmarked", (e) => {
2242
+ r(this, "onBeforePortUnmarked", (e) => {
2169
2243
  const o = this.canvas.graph.getPort(e);
2170
2244
  this.ports.removeByMulti(e), this.ports.hasSingle(o.element) || this.unhookPortEvents(o.element);
2171
2245
  });
2172
- i(this, "onPortMouseDown", (e) => {
2246
+ r(this, "onPortMouseDown", (e) => {
2173
2247
  const o = e.currentTarget;
2174
2248
  this.config.mouseDownEventVerifier(e) && this.isPortConnectionAllowed(o) && (e.stopPropagation(), this.grabPort(o, { x: e.clientX, y: e.clientY }), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2175
2249
  passive: !0
@@ -2177,7 +2251,7 @@ class H {
2177
2251
  passive: !0
2178
2252
  }));
2179
2253
  });
2180
- i(this, "onWindowMouseMove", (e) => {
2254
+ r(this, "onWindowMouseMove", (e) => {
2181
2255
  if (!M(
2182
2256
  this.window,
2183
2257
  this.overlayLayer,
@@ -2189,10 +2263,10 @@ class H {
2189
2263
  }
2190
2264
  this.moveDraggingNode({ x: e.clientX, y: e.clientY });
2191
2265
  });
2192
- i(this, "onWindowMouseUp", (e) => {
2266
+ r(this, "onWindowMouseUp", (e) => {
2193
2267
  this.config.mouseUpEventVerifier(e) && (this.tryCreateConnection({ x: e.clientX, y: e.clientY }), this.stopMouseDrag());
2194
2268
  });
2195
- i(this, "onPortTouchStart", (e) => {
2269
+ r(this, "onPortTouchStart", (e) => {
2196
2270
  const o = e.currentTarget;
2197
2271
  if (!(e.touches.length === 1 && this.isPortConnectionAllowed(o)))
2198
2272
  return;
@@ -2206,7 +2280,7 @@ class H {
2206
2280
  passive: !0
2207
2281
  });
2208
2282
  });
2209
- i(this, "onWindowTouchMove", (e) => {
2283
+ r(this, "onWindowTouchMove", (e) => {
2210
2284
  const o = e.touches[0];
2211
2285
  if (!M(
2212
2286
  this.window,
@@ -2219,30 +2293,30 @@ class H {
2219
2293
  }
2220
2294
  this.moveDraggingNode({ x: o.clientX, y: o.clientY });
2221
2295
  });
2222
- i(this, "onWindowTouchFinish", (e) => {
2296
+ r(this, "onWindowTouchFinish", (e) => {
2223
2297
  const o = e.changedTouches[0];
2224
2298
  this.tryCreateConnection({ x: o.clientX, y: o.clientY }), this.stopTouchDrag();
2225
2299
  });
2226
- i(this, "onBeforeClear", () => {
2300
+ r(this, "onBeforeClear", () => {
2227
2301
  this.ports.forEachSingle((e) => {
2228
2302
  this.unhookPortEvents(e);
2229
2303
  }), this.ports.clear();
2230
2304
  });
2231
- i(this, "onBeforeDestroy", () => {
2305
+ r(this, "onBeforeDestroy", () => {
2232
2306
  this.stopMouseDrag(), this.stopTouchDrag(), this.canvas.graph.onAfterPortMarked.unsubscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.unsubscribe(
2233
2307
  this.onBeforePortUnmarked
2234
2308
  ), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
2235
2309
  });
2236
- i(this, "onEdgeCreated", (e) => {
2310
+ r(this, "onEdgeCreated", (e) => {
2237
2311
  this.config.onAfterEdgeCreated(e);
2238
2312
  });
2239
- this.canvas = e, this.overlayLayer = o, this.viewportStore = r, this.window = s, this.config = Ze(n);
2240
- const d = new ne(), c = new re(
2313
+ this.canvas = e, this.overlayLayer = o, this.viewportStore = i, this.window = s, this.config = rt(n);
2314
+ const d = new ce(), c = new ie(
2241
2315
  d,
2242
2316
  this.viewportStore,
2243
2317
  this.overlayLayer
2244
2318
  );
2245
- this.overlayCanvas = new se(
2319
+ this.overlayCanvas = new he(
2246
2320
  this.overlayLayer,
2247
2321
  d,
2248
2322
  this.viewportStore,
@@ -2250,19 +2324,19 @@ class H {
2250
2324
  h
2251
2325
  ), this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2252
2326
  }
2253
- static configure(e, o, r, s, h, n) {
2327
+ static configure(e, o, i, s, h, n) {
2254
2328
  new H(
2255
2329
  e,
2256
2330
  o,
2257
- r,
2331
+ i,
2258
2332
  s,
2259
2333
  h,
2260
2334
  n
2261
2335
  );
2262
2336
  }
2263
2337
  grabPort(e, o) {
2264
- const r = this.ports.getFirstBySingle(e), s = this.canvas.graph.getPort(r);
2265
- this.staticPortId = r;
2338
+ const i = this.ports.getMultiBySingle(e)[0], s = this.canvas.graph.getPort(i);
2339
+ this.staticPortId = i;
2266
2340
  const h = this.config.connectionTypeResolver(this.staticPortId), n = e.getBoundingClientRect(), d = n.x + n.width / 2, c = n.y + n.height / 2, a = this.overlayLayer.getBoundingClientRect(), l = this.canvas.viewport.getViewportMatrix(), g = N(l, {
2267
2341
  x: d - a.x,
2268
2342
  y: c - a.y
@@ -2279,8 +2353,8 @@ class H {
2279
2353
  portDirection: this.config.dragPortDirection
2280
2354
  };
2281
2355
  this.isDirect = h === "direct";
2282
- const E = this.isDirect ? p : f, x = this.isDirect ? f : p;
2283
- this.createOverlayGraph(E, x);
2356
+ const A = this.isDirect ? p : f, E = this.isDirect ? f : p;
2357
+ this.createOverlayGraph(A, E);
2284
2358
  }
2285
2359
  hookPortEvents(e) {
2286
2360
  e.addEventListener("mousedown", this.onPortMouseDown, {
@@ -2302,8 +2376,8 @@ class H {
2302
2376
  this.staticPortId = null, this.isDirect = !0, this.overlayCanvas.clear();
2303
2377
  }
2304
2378
  createOverlayGraph(e, o) {
2305
- const r = this.createAddNodeRequest(e);
2306
- this.overlayCanvas.addNode(r);
2379
+ const i = this.createAddNodeRequest(e);
2380
+ this.overlayCanvas.addNode(i);
2307
2381
  const s = this.createAddNodeRequest(o);
2308
2382
  this.overlayCanvas.addNode(s), this.overlayCanvas.addEdge({
2309
2383
  from: e.overlayId,
@@ -2332,14 +2406,14 @@ class H {
2332
2406
  this.config.onEdgeCreationInterrupted(this.staticPortId, this.isDirect);
2333
2407
  return;
2334
2408
  }
2335
- const r = this.isDirect ? this.staticPortId : o, s = this.isDirect ? o : this.staticPortId, h = { from: r, to: s }, n = this.config.connectionPreprocessor(h);
2409
+ const i = this.isDirect ? this.staticPortId : o, s = this.isDirect ? o : this.staticPortId, h = { from: i, to: s }, n = this.config.connectionPreprocessor(h);
2336
2410
  n !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(n), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.config.onEdgeCreationPrevented(h);
2337
2411
  }
2338
2412
  moveDraggingNode(e) {
2339
- const o = this.overlayLayer.getBoundingClientRect(), r = {
2413
+ const o = this.overlayLayer.getBoundingClientRect(), i = {
2340
2414
  x: e.x - o.x,
2341
2415
  y: e.y - o.y
2342
- }, s = this.canvas.viewport.getViewportMatrix(), h = N(s, r);
2416
+ }, s = this.canvas.viewport.getViewportMatrix(), h = N(s, i);
2343
2417
  this.overlayCanvas.updateNode(this.draggingOverlayPortId, {
2344
2418
  x: h.x,
2345
2419
  y: h.y
@@ -2347,59 +2421,59 @@ class H {
2347
2421
  }
2348
2422
  findPortAtPoint(e) {
2349
2423
  const o = document.elementsFromPoint(e.x, e.y);
2350
- for (const r of o) {
2351
- const s = this.findPortAtElement(r);
2424
+ for (const i of o) {
2425
+ const s = this.findPortAtElement(i);
2352
2426
  if (s !== null)
2353
2427
  return s;
2354
2428
  }
2355
2429
  return null;
2356
2430
  }
2357
2431
  findPortAtElement(e) {
2358
- let o = e, r = null;
2359
- for (; o !== null && (r = this.ports.getFirstBySingle(o) ?? null, r === null); )
2432
+ let o = e, i = null;
2433
+ for (; o !== null && (i = this.ports.getMultiBySingle(o)[0] ?? null, i === null); )
2360
2434
  o = o.parentElement;
2361
- return r;
2435
+ return i;
2362
2436
  }
2363
2437
  isPortConnectionAllowed(e) {
2364
- const o = this.ports.getFirstBySingle(e);
2438
+ const o = this.ports.getMultiBySingle(e)[0];
2365
2439
  return this.config.connectionTypeResolver(o) !== null;
2366
2440
  }
2367
2441
  }
2368
- const qe = () => {
2442
+ const it = () => {
2369
2443
  const t = document.createElement("div");
2370
2444
  return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t;
2371
2445
  }, W = () => {
2372
2446
  const t = document.createElement("div");
2373
2447
  return t.style.position = "absolute", t.style.inset = "0", t;
2374
2448
  };
2375
- class et {
2449
+ class st {
2376
2450
  constructor(e) {
2377
- i(this, "background", W());
2378
- i(this, "main", W());
2379
- i(this, "overlay", W());
2380
- i(this, "host", qe());
2451
+ r(this, "background", W());
2452
+ r(this, "main", W());
2453
+ r(this, "overlay", W());
2454
+ r(this, "host", it());
2381
2455
  this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.overlay.style.pointerEvents = "none", this.host.appendChild(this.overlay);
2382
2456
  }
2383
2457
  destroy() {
2384
2458
  this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlay), this.element.removeChild(this.host);
2385
2459
  }
2386
2460
  }
2387
- class ot {
2461
+ class ht {
2388
2462
  constructor(e) {
2389
- i(this, "element", null);
2390
- i(this, "canvasDefaults", {});
2391
- i(this, "dragConfig", {});
2392
- i(this, "transformConfig", {});
2393
- i(this, "backgroundConfig", {});
2394
- i(this, "connectablePortsConfig", {});
2395
- i(this, "virtualScrollConfig");
2396
- i(this, "hasDraggableNode", !1);
2397
- i(this, "hasTransformableViewport", !1);
2398
- i(this, "hasResizeReactiveNodes", !1);
2399
- i(this, "hasBackground", !1);
2400
- i(this, "hasUserConnectablePorts", !1);
2401
- i(this, "boxRenderingTrigger");
2402
- i(this, "window", window);
2463
+ r(this, "element", null);
2464
+ r(this, "canvasDefaults", {});
2465
+ r(this, "dragConfig", {});
2466
+ r(this, "transformConfig", {});
2467
+ r(this, "backgroundConfig", {});
2468
+ r(this, "connectablePortsConfig", {});
2469
+ r(this, "virtualScrollConfig");
2470
+ r(this, "hasDraggableNode", !1);
2471
+ r(this, "hasTransformableViewport", !1);
2472
+ r(this, "hasResizeReactiveNodes", !1);
2473
+ r(this, "hasBackground", !1);
2474
+ r(this, "hasUserConnectablePorts", !1);
2475
+ r(this, "boxRenderingTrigger");
2476
+ r(this, "window", window);
2403
2477
  e !== void 0 && (this.element = e);
2404
2478
  }
2405
2479
  /**
@@ -2467,18 +2541,18 @@ class ot {
2467
2541
  "unable to build canvas when no attach element specified"
2468
2542
  );
2469
2543
  let e = this.boxRenderingTrigger;
2470
- this.virtualScrollConfig !== void 0 && e === void 0 && (e = new ie());
2471
- const o = new ne(), r = new Ue(), s = new et(this.element);
2472
- let h = new re(
2544
+ this.virtualScrollConfig !== void 0 && e === void 0 && (e = new se());
2545
+ const o = new ce(), i = new ze(), s = new st(this.element);
2546
+ let h = new ie(
2473
2547
  o,
2474
- r,
2548
+ i,
2475
2549
  s.main
2476
2550
  );
2477
- e !== void 0 && (h = new ue(h, o, e));
2478
- const n = new se(
2551
+ e !== void 0 && (h = new ve(h, o, e));
2552
+ const n = new he(
2479
2553
  this.element,
2480
2554
  o,
2481
- r,
2555
+ i,
2482
2556
  h,
2483
2557
  this.canvasDefaults
2484
2558
  ), d = () => {
@@ -2488,7 +2562,7 @@ class ot {
2488
2562
  n,
2489
2563
  this.backgroundConfig,
2490
2564
  s.background
2491
- ), this.hasResizeReactiveNodes && k.configure(n), this.hasDraggableNode && O.configure(
2565
+ ), this.hasResizeReactiveNodes && z.configure(n), this.hasDraggableNode && O.configure(
2492
2566
  n,
2493
2567
  s.main,
2494
2568
  this.window,
@@ -2496,7 +2570,7 @@ class ot {
2496
2570
  ), this.hasUserConnectablePorts && H.configure(
2497
2571
  n,
2498
2572
  s.overlay,
2499
- r,
2573
+ i,
2500
2574
  this.window,
2501
2575
  this.canvasDefaults,
2502
2576
  this.connectablePortsConfig
@@ -2523,11 +2597,14 @@ class ot {
2523
2597
  }
2524
2598
  }
2525
2599
  export {
2526
- De as BezierEdgeShape,
2527
- ot as CanvasBuilder,
2528
- ie as EventSubject,
2529
- Ve as HorizontalEdgeShape,
2600
+ Re as BezierEdgeShape,
2601
+ ht as CanvasBuilder,
2602
+ se as EventSubject,
2603
+ Be as HorizontalEdgeShape,
2530
2604
  S as HtmlGraphError,
2531
- Le as StraightEdgeShape,
2532
- Re as VerticalEdgeShape
2605
+ $e as InteractiveEdgeError,
2606
+ ne as InteractiveEdgeShape,
2607
+ I as LineEdgeShape,
2608
+ Ie as StraightEdgeShape,
2609
+ Ue as VerticalEdgeShape
2533
2610
  };