@html-graph/html-graph 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
- var ie = Object.defineProperty;
2
- var se = (t, e, o) => e in t ? ie(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
- var i = (t, e, o) => se(t, typeof e != "symbol" ? e + "" : e, o);
4
- const ne = () => {
5
- const t = document.createElement("div");
6
- return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
7
- }, he = () => {
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 i = (t, e, o) => le(t, typeof e != "symbol" ? e + "" : e, o);
4
+ const ge = () => {
8
5
  const t = document.createElement("div");
9
6
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
10
- }, de = () => {
7
+ }, ue = () => {
11
8
  const t = document.createElement("div");
12
9
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
10
+ }, we = () => {
11
+ const t = document.createElement("div");
12
+ return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
13
13
  };
14
- class ce {
14
+ class ne {
15
15
  constructor(e, o, r) {
16
- i(this, "host", ne());
17
- i(this, "container", he());
16
+ i(this, "host", we());
17
+ i(this, "container", ge());
18
18
  i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
19
19
  i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
20
20
  i(this, "applyTransform", () => {
@@ -24,7 +24,7 @@ class ce {
24
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);
25
25
  }
26
26
  attachNode(e) {
27
- const o = this.graphStore.getNode(e), r = de();
27
+ const o = this.graphStore.getNode(e), r = ue();
28
28
  r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodePosition(e), this.updateNodePriority(e), r.style.visibility = "visible";
29
29
  }
30
30
  detachNode(e) {
@@ -50,7 +50,7 @@ class ce {
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: d } = r.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, h = r.centerFn(s, d), c = r.x - n * h.x, a = r.y - n * h.y;
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;
54
54
  o.style.transform = `translate(${c}px, ${a}px)`;
55
55
  }
56
56
  updateNodePriority(e) {
@@ -64,40 +64,37 @@ class ce {
64
64
  this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.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), d = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = {
68
- x: c.scale * (d.left - h.left) + c.x,
69
- y: c.scale * (d.top - h.top) + c.y
70
- }, l = {
71
- x: c.scale * (n.left - h.left) + c.x,
72
- y: c.scale * (n.top - h.top) + c.y
73
- }, g = {
74
- x: a.x,
75
- y: a.y,
76
- width: d.width * c.scale,
77
- height: d.height * c.scale,
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, v = {
68
+ x: c.scale * a + c.x,
69
+ y: c.scale * l + c.y
70
+ }, f = {
71
+ x: c.scale * g + c.x,
72
+ y: c.scale * y + c.y
73
+ }, p = {
74
+ x: v.x,
75
+ y: v.y,
76
+ width: h.width * c.scale,
77
+ height: h.height * c.scale,
78
78
  direction: r.direction,
79
79
  portId: o.from,
80
80
  nodeId: r.nodeId
81
- }, f = {
82
- x: l.x,
83
- y: l.y,
81
+ }, A = {
82
+ x: f.x,
83
+ y: f.y,
84
84
  width: n.width * c.scale,
85
85
  height: n.height * c.scale,
86
86
  direction: s.direction,
87
87
  portId: o.to,
88
88
  nodeId: s.nodeId
89
89
  };
90
- o.shape.render({
91
- from: g,
92
- to: f
93
- });
90
+ o.shape.render({ from: p, to: A });
94
91
  }
95
92
  updateEdgePriority(e) {
96
93
  const o = this.graphStore.getEdge(e);
97
94
  o.shape.svg.style.zIndex = `${o.priority}`;
98
95
  }
99
96
  }
100
- class ae {
97
+ class fe {
101
98
  constructor(e) {
102
99
  i(this, "xFrom", 1 / 0);
103
100
  i(this, "yFrom", 1 / 0);
@@ -113,25 +110,25 @@ class ae {
113
110
  return o.x >= this.xFrom && o.x <= this.xTo && o.y >= this.yFrom && o.y <= this.yTo;
114
111
  }
115
112
  hasEdge(e) {
116
- const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from).nodeId, s = this.graphStore.getPort(o.to).nodeId, d = this.graphStore.getNode(r), n = this.graphStore.getNode(s), h = Math.min(d.x, n.x), c = Math.max(d.x, n.x), a = Math.min(d.y, n.y), l = Math.max(d.y, n.y);
117
- return h <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
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);
114
+ return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
118
115
  }
119
116
  }
120
- class le {
117
+ class ye {
121
118
  constructor(e, o, r) {
122
119
  i(this, "attachedNodes", /* @__PURE__ */ new Set());
123
120
  i(this, "attachedEdges", /* @__PURE__ */ new Set());
124
121
  i(this, "renderingBox");
125
122
  i(this, "updateViewport", (e) => {
126
123
  this.renderingBox.setRenderingBox(e);
127
- const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
124
+ const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
128
125
  this.graphStore.getAllNodeIds().forEach((n) => {
129
- const h = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
130
- h && !c ? o.add(n) : !h && c && r.add(n);
126
+ const d = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
127
+ d && !c ? o.add(n) : !d && c && r.add(n);
131
128
  }), this.graphStore.getAllEdgeIds().forEach((n) => {
132
- const h = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
133
- h && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), h && !c ? s.add(n) : !h && c && d.add(n);
134
- }), d.forEach((n) => {
129
+ const d = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPort(a.from).nodeId, g = this.graphStore.getPort(a.to).nodeId;
130
+ d && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), d && !c ? s.add(n) : !d && c && h.add(n);
131
+ }), h.forEach((n) => {
135
132
  this.handleDetachEdge(n);
136
133
  }), r.forEach((n) => {
137
134
  this.handleDetachNode(n);
@@ -141,7 +138,7 @@ class le {
141
138
  this.handleAttachEdge(n);
142
139
  });
143
140
  });
144
- this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new ae(this.graphStore), this.trigger.subscribe(this.updateViewport);
141
+ this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new fe(this.graphStore), this.trigger.subscribe(this.updateViewport);
145
142
  }
146
143
  attachNode(e) {
147
144
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -195,7 +192,7 @@ class le {
195
192
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
196
193
  }
197
194
  }
198
- class re {
195
+ class he {
199
196
  constructor() {
200
197
  i(this, "callbacks", /* @__PURE__ */ new Set());
201
198
  }
@@ -211,24 +208,24 @@ class re {
211
208
  });
212
209
  }
213
210
  }
214
- const A = () => {
215
- const t = new re();
211
+ const E = () => {
212
+ const t = new he();
216
213
  return [t, t];
217
214
  };
218
- class ge {
215
+ class ve {
219
216
  constructor(e) {
220
217
  i(this, "onBeforeUpdated");
221
218
  i(this, "onAfterUpdated");
222
- this.transformer = e, this.onBeforeUpdated = this.transformer.onBeforeUpdated, this.onAfterUpdated = this.transformer.onAfterUpdated;
219
+ this.viewportStore = e, this.onBeforeUpdated = this.viewportStore.onBeforeUpdated, this.onAfterUpdated = this.viewportStore.onAfterUpdated;
223
220
  }
224
221
  getViewportMatrix() {
225
- return { ...this.transformer.getViewportMatrix() };
222
+ return { ...this.viewportStore.getViewportMatrix() };
226
223
  }
227
224
  getContentMatrix() {
228
- return { ...this.transformer.getContentMatrix() };
225
+ return { ...this.viewportStore.getContentMatrix() };
229
226
  }
230
227
  }
231
- class ue {
228
+ class xe {
232
229
  constructor(e) {
233
230
  i(this, "onAfterNodeAdded");
234
231
  i(this, "onAfterNodeUpdated");
@@ -304,7 +301,7 @@ class ue {
304
301
  return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
305
302
  }
306
303
  }
307
- class X {
304
+ class Y {
308
305
  constructor(e) {
309
306
  i(this, "counter", 0);
310
307
  this.checkExists = e;
@@ -326,219 +323,237 @@ class S extends Error {
326
323
  i(this, "name", "HtmlGraphError");
327
324
  }
328
325
  }
329
- const we = (t, e) => ({
326
+ const Ae = (t, e) => ({
330
327
  x: t / 2,
331
328
  y: e / 2
332
- }), k = (t) => () => t, O = k(0), fe = () => {
329
+ }), H = (t) => () => t, oe = H(0), pe = () => {
333
330
  let t = 0;
334
331
  return () => t++;
335
- }, ye = (t, e) => {
336
- let o = O, r = O;
337
- const s = fe();
338
- return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = k(t)), typeof e == "number" && (r = k(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
332
+ }, Ee = (t, e) => {
333
+ let o = oe, r = oe;
334
+ const s = pe();
335
+ return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = H(t)), typeof e == "number" && (r = H(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
339
336
  nodesPriorityFn: o,
340
337
  edgesPriorityFn: r
341
338
  };
342
339
  }, x = (t, e, o) => ({
343
340
  x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
344
341
  y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
345
- }), b = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
342
+ }), T = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
346
343
  x: 0,
347
344
  y: 0
348
345
  }, N = (t, e, o, r) => {
349
- const d = [
346
+ const h = [
350
347
  w,
351
348
  { x: o, y: r },
352
349
  { x: o, y: -r }
353
- ].map((a) => x(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${d[0].x} ${d[0].y}`, h = `L ${d[1].x} ${d[1].y}`, c = `L ${d[2].x} ${d[2].y}`;
354
- return `${n} ${h} ${c}`;
355
- }, L = (t, e) => {
350
+ ].map((a) => x(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}`;
351
+ return `${n} ${d} ${c}`;
352
+ }, I = (t, e) => {
356
353
  const o = [];
357
354
  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) {
358
355
  const r = t.length - 1;
359
- let s = 0, d = 0, n = 0;
360
- t.forEach((h, c) => {
356
+ let s = 0, h = 0, n = 0;
357
+ t.forEach((d, c) => {
361
358
  let a = 0, l = 0, g = 0;
362
- const f = c > 0, v = c < r, y = f && v;
363
- if (f && (a = -s, l = -d, g = n), v) {
364
- const V = t[c + 1];
365
- s = V.x - h.x, d = V.y - h.y, n = Math.sqrt(s * s + d * d);
359
+ const y = c > 0, v = c < r, f = y && v;
360
+ if (y && (a = -s, l = -h, g = n), v) {
361
+ const R = t[c + 1];
362
+ s = R.x - d.x, h = R.y - d.y, n = Math.sqrt(s * s + h * h);
366
363
  }
367
- const E = n !== 0 ? Math.min((y ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, T = y ? { x: h.x + s * E, y: h.y + d * E } : h, D = g !== 0 ? Math.min((y ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, M = y ? { x: h.x + a * D, y: h.y + l * D } : h;
368
- c > 0 && o.push(`L ${M.x} ${M.y}`), y && o.push(
369
- `C ${h.x} ${h.y} ${h.x} ${h.y} ${T.x} ${T.y}`
364
+ const A = n !== 0 ? Math.min((f ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, b = f ? { x: d.x + s * A, y: d.y + h * A } : d, m = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, L = f ? { x: d.x + a * m, y: d.y + l * m } : d;
365
+ c > 0 && o.push(`L ${L.x} ${L.y}`), f && o.push(
366
+ `C ${d.x} ${d.y} ${d.x} ${d.y} ${b.x} ${b.y}`
370
367
  );
371
368
  });
372
369
  }
373
370
  return o.join(" ");
374
- }, B = () => {
371
+ }, $ = () => {
375
372
  const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
376
373
  return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
377
- }, $ = () => {
374
+ }, W = () => {
378
375
  const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
379
376
  return t.style.transformOrigin = "50% 50%", t;
380
- }, W = (t, e) => {
377
+ }, F = (t, e) => {
381
378
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
382
379
  return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
383
- }, m = (t) => {
380
+ }, P = (t) => {
384
381
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
385
382
  return e.setAttribute("fill", t), e;
386
- }, F = (t, e) => {
383
+ }, z = (t, e) => {
387
384
  const o = {
388
385
  x: t.x + t.width / 2,
389
386
  y: t.y + t.height / 2
390
387
  }, r = {
391
388
  x: e.x + e.width / 2,
392
389
  y: e.y + e.height / 2
393
- }, s = Math.min(o.x, r.x), d = Math.min(o.y, r.y), n = Math.abs(r.x - o.x), h = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
390
+ }, 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;
394
391
  return {
395
392
  x: s,
396
- y: d,
393
+ y: h,
397
394
  width: n,
398
- height: h,
395
+ height: d,
399
396
  flipX: c,
400
397
  flipY: a
401
398
  };
402
- }, ve = (t) => {
399
+ }, Se = (t) => {
403
400
  const e = x(
404
401
  { x: t.arrowLength, y: w.y },
405
- t.fromVect,
402
+ t.fromVector,
406
403
  w
407
404
  ), o = x(
408
405
  { x: t.to.x - t.arrowLength, y: t.to.y },
409
- t.toVect,
406
+ t.toVector,
410
407
  t.to
411
408
  ), r = {
412
- x: e.x + t.fromVect.x * t.curvature,
413
- y: e.y + t.fromVect.y * t.curvature
409
+ x: e.x + t.fromVector.x * t.curvature,
410
+ y: e.y + t.fromVector.y * t.curvature
414
411
  }, s = {
415
- x: o.x - t.toVect.x * t.curvature,
416
- y: o.y - t.toVect.y * t.curvature
417
- }, d = `M ${e.x} ${e.y} C ${r.x} ${r.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, h = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
418
- return `${n}${d}${h}`;
419
- }, xe = (t) => {
412
+ x: o.x - t.toVector.x * t.curvature,
413
+ y: o.y - t.toVector.y * t.curvature
414
+ }, 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}`;
415
+ return `${n}${h}${d}`;
416
+ }, be = (t) => {
420
417
  const e = t.hasSourceArrow ? x(
421
418
  { x: t.arrowLength, y: w.y },
422
- t.fromVect,
419
+ t.fromVector,
423
420
  w
424
421
  ) : w, o = t.hasTargetArrow ? x(
425
422
  { x: t.to.x - t.arrowLength, y: t.to.y },
426
- t.toVect,
423
+ t.toVector,
427
424
  t.to
428
- ) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, d = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, h = d * t.flipY, c = x(
425
+ ) : 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 = x(
429
426
  { x: r, y: w.y },
430
- t.fromVect,
427
+ t.fromVector,
431
428
  w
432
429
  ), a = {
433
430
  x: c.x + n,
434
- y: c.y + h
431
+ y: c.y + d
435
432
  }, l = x(
436
433
  { x: t.to.x - r, y: t.to.y },
437
- t.toVect,
434
+ t.toVector,
438
435
  t.to
439
436
  ), g = {
440
437
  x: l.x + n,
441
- y: l.y + h
442
- }, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, v = {
443
- x: c.x + t.curvature * t.fromVect.x,
444
- y: c.y + t.curvature * t.fromVect.y
445
- }, y = {
446
- x: l.x - t.curvature * t.toVect.x,
447
- y: l.y - t.curvature * t.toVect.y
438
+ y: l.y + d
439
+ }, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, v = {
440
+ x: c.x + t.curvature * t.fromVector.x,
441
+ y: c.y + t.curvature * t.fromVector.y
442
+ }, f = {
443
+ x: l.x - t.curvature * t.toVector.x,
444
+ y: l.y - t.curvature * t.toVector.y
448
445
  }, p = {
449
446
  x: c.x + n,
450
- y: c.y + h
451
- }, E = {
447
+ y: c.y + d
448
+ }, A = {
452
449
  x: l.x + n,
453
- y: l.y + h
450
+ y: l.y + d
454
451
  };
455
452
  return [
456
453
  `M ${e.x} ${e.y}`,
457
454
  `L ${c.x} ${c.y}`,
458
- `C ${v.x} ${v.y} ${p.x} ${p.y} ${f.x} ${f.y}`,
459
- `C ${E.x} ${E.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
455
+ `C ${v.x} ${v.y} ${p.x} ${p.y} ${y.x} ${y.y}`,
456
+ `C ${A.x} ${A.y} ${f.x} ${f.y} ${l.x} ${l.y}`,
460
457
  `L ${o.x} ${o.y}`
461
458
  ].join(" ");
462
- }, Ae = (t) => {
459
+ }, me = (t) => {
463
460
  const e = t.hasSourceArrow ? x(
464
461
  { x: t.arrowLength, y: w.y },
465
- t.fromVect,
462
+ t.fromVector,
466
463
  w
467
464
  ) : w, o = t.hasTargetArrow ? x(
468
465
  { x: t.to.x - t.arrowLength, y: t.to.y },
469
- t.toVect,
466
+ t.toVector,
470
467
  t.to
471
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = x({ x: s, y: w.y }, t.fromVect, w), n = x(
468
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = x(
469
+ { x: s, y: w.y },
470
+ t.fromVector,
471
+ w
472
+ ), n = x(
472
473
  { x: t.to.x - s, y: t.to.y },
473
- t.toVect,
474
+ t.toVector,
474
475
  t.to
475
- ), h = Math.max((d.x + n.x) / 2, r), c = t.to.y / 2, a = { x: t.flipX > 0 ? h : -r, y: d.y }, l = { x: a.x, y: c }, g = {
476
- x: t.flipX > 0 ? t.to.x - h : t.to.x + r,
476
+ ), d = Math.max((h.x + n.x) / 2, r), c = t.to.y / 2, a = {
477
+ x: t.flipX > 0 ? d : -r,
478
+ y: h.y
479
+ }, l = { x: a.x, y: c }, g = {
480
+ x: t.flipX > 0 ? t.to.x - d : t.to.x + r,
477
481
  y: n.y
478
- }, f = { x: g.x, y: c };
479
- return L(
480
- [e, d, a, l, f, g, n, o],
482
+ }, y = { x: g.x, y: c };
483
+ return I(
484
+ [e, h, a, l, y, g, n, o],
481
485
  t.roundness
482
486
  );
483
- }, H = (t) => {
487
+ }, j = (t) => {
484
488
  const e = t.hasSourceArrow ? x(
485
489
  { x: t.arrowLength, y: w.y },
486
- t.fromVect,
490
+ t.fromVector,
487
491
  w
488
492
  ) : w, o = t.hasTargetArrow ? x(
489
493
  { x: t.to.x - t.arrowLength, y: t.to.y },
490
- t.toVect,
494
+ t.toVector,
491
495
  t.to
492
496
  ) : t.to, r = t.arrowLength + t.arrowOffset, s = x(
493
497
  { x: r, y: w.y },
494
- t.fromVect,
498
+ t.fromVector,
495
499
  w
496
- ), d = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, h = d * t.flipX, c = n * t.flipY, a = { x: s.x + h, y: s.y + c }, l = x(
500
+ ), 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 = x(
497
501
  { x: t.to.x - r, y: t.to.y },
498
- t.toVect,
502
+ t.toVector,
499
503
  t.to
500
- ), g = { x: l.x + h, y: l.y + c };
501
- return L(
504
+ ), g = { x: l.x + d, y: l.y + c };
505
+ return I(
502
506
  [e, s, a, g, l, o],
503
507
  t.roundness
504
508
  );
505
- }, Ee = (t) => {
509
+ }, Te = (t) => {
506
510
  const e = t.hasSourceArrow ? x(
507
511
  { x: t.arrowLength, y: w.y },
508
- t.fromVect,
512
+ t.fromVector,
509
513
  w
510
514
  ) : w, o = t.hasTargetArrow ? x(
511
515
  { x: t.to.x - t.arrowLength, y: t.to.y },
512
- t.toVect,
516
+ t.toVector,
513
517
  t.to
514
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = x({ x: r, y: w.y }, t.fromVect, w), d = x(
518
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = x(
519
+ { x: r, y: w.y },
520
+ t.fromVector,
521
+ w
522
+ ), h = x(
515
523
  { x: t.to.x - r, y: t.to.y },
516
- t.toVect,
524
+ t.toVector,
517
525
  t.to
518
526
  );
519
- return L([e, s, d, o], t.roundness);
520
- }, Se = (t) => {
527
+ return I([e, s, h, o], t.roundness);
528
+ }, Ne = (t) => {
521
529
  const e = t.hasSourceArrow ? x(
522
530
  { x: t.arrowLength, y: w.y },
523
- t.fromVect,
531
+ t.fromVector,
524
532
  w
525
533
  ) : w, o = t.hasTargetArrow ? x(
526
534
  { x: t.to.x - t.arrowLength, y: t.to.y },
527
- t.toVect,
535
+ t.toVector,
528
536
  t.to
529
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = x({ x: s, y: w.y }, t.fromVect, w), n = x(
537
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = x(
538
+ { x: s, y: w.y },
539
+ t.fromVector,
540
+ w
541
+ ), n = x(
530
542
  { x: t.to.x - s, y: t.to.y },
531
- t.toVect,
543
+ t.toVector,
532
544
  t.to
533
- ), h = Math.max((d.y + n.y) / 2, r), c = t.to.x / 2, a = { x: d.x, y: t.flipY > 0 ? h : -r }, l = { x: c, y: a.y }, g = {
545
+ ), d = Math.max((h.y + n.y) / 2, r), c = t.to.x / 2, a = {
546
+ x: h.x,
547
+ y: t.flipY > 0 ? d : -r
548
+ }, l = { x: c, y: a.y }, g = {
534
549
  x: n.x,
535
- y: t.flipY > 0 ? t.to.y - h : t.to.y + r
536
- }, f = { x: c, y: g.y };
537
- return L(
538
- [e, d, a, l, f, g, n, o],
550
+ y: t.flipY > 0 ? t.to.y - d : t.to.y + r
551
+ }, y = { x: c, y: g.y };
552
+ return I(
553
+ [e, h, a, l, y, g, n, o],
539
554
  t.roundness
540
555
  );
541
- }, j = (t) => {
556
+ }, G = (t) => {
542
557
  const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, s = r + 2 * o, n = [
543
558
  { x: t.arrowLength, y: w.y },
544
559
  { x: r, y: w.y },
@@ -549,15 +564,17 @@ const we = (t, e) => ({
549
564
  { x: r, y: w.y },
550
565
  { x: t.arrowLength, y: w.y }
551
566
  ].map(
552
- (c) => x(c, t.fromVect, w)
553
- ), h = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
554
- return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${L(n, t.roundness)}`;
555
- }, pe = (t) => {
556
- const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o, d = t.arrowLength + r * (1 - o / s), n = e * o / s, c = [
567
+ (c) => x(c, t.fromVector, w)
568
+ ), d = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
569
+ return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${I(n, t.roundness)}`;
570
+ }, Pe = (t) => {
571
+ 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 = [
557
572
  { x: t.arrowLength, y: w.y },
558
- { x: d, y: n },
559
- { x: d, y: -n }
560
- ].map((g) => x(g, t.fromVect, w)), a = [
573
+ { x: h, y: n },
574
+ { x: h, y: -n }
575
+ ].map(
576
+ (g) => x(g, t.fromVector, w)
577
+ ), a = [
561
578
  `M ${c[0].x} ${c[0].y}`,
562
579
  `A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
563
580
  `A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
@@ -581,10 +598,10 @@ const we = (t, e) => ({
581
598
  smallCycleRadius: 15,
582
599
  curvature: 90
583
600
  });
584
- class Te {
601
+ class De {
585
602
  constructor(e) {
586
- i(this, "svg", B());
587
- i(this, "group", $());
603
+ i(this, "svg", $());
604
+ i(this, "group", W());
588
605
  i(this, "line");
589
606
  i(this, "sourceArrow", null);
590
607
  i(this, "targetArrow", null);
@@ -599,74 +616,74 @@ class Te {
599
616
  i(this, "hasTargetArrow");
600
617
  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;
601
618
  const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
602
- this.svg.appendChild(this.group), this.line = W(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(o), this.group.appendChild(this.targetArrow));
619
+ this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(o), this.group.appendChild(this.targetArrow));
603
620
  }
604
621
  render(e) {
605
- const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
622
+ const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
606
623
  e.from,
607
624
  e.to
608
625
  );
609
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
610
- const c = b(
626
+ 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})`;
627
+ const c = T(
611
628
  e.from.direction,
612
629
  n,
613
- h
614
- ), a = b(e.to.direction, n, h), l = {
630
+ d
631
+ ), a = T(e.to.direction, n, d), l = {
615
632
  x: s,
616
- y: d
633
+ y: h
617
634
  };
618
- let g, f = a, v = -this.arrowLength;
619
- if (e.from.portId === e.to.portId ? (g = pe({
620
- fromVect: c,
635
+ let g, y = a, v = -this.arrowLength;
636
+ if (e.from.portId === e.to.portId ? (g = Pe({
637
+ fromVector: c,
621
638
  radius: this.portCycleRadius,
622
639
  smallRadius: this.portCycleSmallRadius,
623
640
  arrowLength: this.arrowLength,
624
641
  hasSourceArrow: this.hasSourceArrow,
625
642
  hasTargetArrow: this.hasTargetArrow
626
- }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = xe({
643
+ }), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = be({
627
644
  to: l,
628
- fromVect: c,
629
- toVect: a,
645
+ fromVector: c,
646
+ toVector: a,
630
647
  flipX: n,
631
- flipY: h,
648
+ flipY: d,
632
649
  arrowLength: this.arrowLength,
633
650
  detourDirection: this.detourDirection,
634
651
  detourDistance: this.detourDistance,
635
652
  curvature: this.curvature,
636
653
  hasSourceArrow: this.hasSourceArrow,
637
654
  hasTargetArrow: this.hasTargetArrow
638
- }) : g = ve({
655
+ }) : g = Se({
639
656
  to: l,
640
- fromVect: c,
641
- toVect: a,
657
+ fromVector: c,
658
+ toVector: a,
642
659
  arrowLength: this.arrowLength,
643
660
  curvature: this.curvature,
644
661
  hasSourceArrow: this.hasSourceArrow,
645
662
  hasTargetArrow: this.hasTargetArrow
646
663
  }), this.line.setAttribute("d", g), this.sourceArrow) {
647
- const y = N(
664
+ const f = N(
648
665
  c,
649
666
  w,
650
667
  this.arrowLength,
651
668
  this.arrowWidth
652
669
  );
653
- this.sourceArrow.setAttribute("d", y);
670
+ this.sourceArrow.setAttribute("d", f);
654
671
  }
655
672
  if (this.targetArrow) {
656
- const y = N(
657
- f,
673
+ const f = N(
674
+ y,
658
675
  l,
659
676
  v,
660
677
  this.arrowWidth
661
678
  );
662
- this.targetArrow.setAttribute("d", y);
679
+ this.targetArrow.setAttribute("d", f);
663
680
  }
664
681
  }
665
682
  }
666
- class be {
683
+ class Me {
667
684
  constructor(e) {
668
- i(this, "svg", B());
669
- i(this, "group", $());
685
+ i(this, "svg", $());
686
+ i(this, "group", W());
670
687
  i(this, "line");
671
688
  i(this, "sourceArrow", null);
672
689
  i(this, "targetArrow", null);
@@ -687,37 +704,37 @@ class be {
687
704
  this.cycleSquareSide / 2
688
705
  ), 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;
689
706
  const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
690
- this.svg.appendChild(this.group), this.line = W(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(r), this.group.appendChild(this.targetArrow));
707
+ this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
691
708
  }
692
709
  render(e) {
693
- const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
710
+ const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
694
711
  e.from,
695
712
  e.to
696
713
  );
697
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
698
- const c = b(
714
+ 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})`;
715
+ const c = T(
699
716
  e.from.direction,
700
717
  n,
701
- h
702
- ), a = b(e.to.direction, n, h), l = {
718
+ d
719
+ ), a = T(e.to.direction, n, d), l = {
703
720
  x: s,
704
- y: d
721
+ y: h
705
722
  };
706
- let g, f = a, v = -this.arrowLength;
707
- if (e.from.portId === e.to.portId ? (g = j({
708
- fromVect: c,
723
+ let g, y = a, v = -this.arrowLength;
724
+ if (e.from.portId === e.to.portId ? (g = G({
725
+ fromVector: c,
709
726
  arrowLength: this.arrowLength,
710
727
  side: this.cycleSquareSide,
711
728
  arrowOffset: this.arrowOffset,
712
729
  roundness: this.roundness,
713
730
  hasSourceArrow: this.hasSourceArrow,
714
731
  hasTargetArrow: this.hasTargetArrow
715
- }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
732
+ }), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
716
733
  to: l,
717
- fromVect: c,
718
- toVect: a,
734
+ fromVector: c,
735
+ toVector: a,
719
736
  flipX: n,
720
- flipY: h,
737
+ flipY: d,
721
738
  arrowLength: this.arrowLength,
722
739
  arrowOffset: this.arrowOffset,
723
740
  roundness: this.roundness,
@@ -725,10 +742,10 @@ class be {
725
742
  detourDistance: this.detourDistance,
726
743
  hasSourceArrow: this.hasSourceArrow,
727
744
  hasTargetArrow: this.hasTargetArrow
728
- }) : g = Ae({
745
+ }) : g = me({
729
746
  to: l,
730
- fromVect: c,
731
- toVect: a,
747
+ fromVector: c,
748
+ toVector: a,
732
749
  flipX: n,
733
750
  arrowLength: this.arrowLength,
734
751
  arrowOffset: this.arrowOffset,
@@ -736,29 +753,29 @@ class be {
736
753
  hasSourceArrow: this.hasSourceArrow,
737
754
  hasTargetArrow: this.hasTargetArrow
738
755
  }), this.line.setAttribute("d", g), this.sourceArrow) {
739
- const y = N(
756
+ const f = N(
740
757
  c,
741
758
  w,
742
759
  this.arrowLength,
743
760
  this.arrowWidth
744
761
  );
745
- this.sourceArrow.setAttribute("d", y);
762
+ this.sourceArrow.setAttribute("d", f);
746
763
  }
747
764
  if (this.targetArrow) {
748
- const y = N(
749
- f,
765
+ const f = N(
766
+ y,
750
767
  l,
751
768
  v,
752
769
  this.arrowWidth
753
770
  );
754
- this.targetArrow.setAttribute("d", y);
771
+ this.targetArrow.setAttribute("d", f);
755
772
  }
756
773
  }
757
774
  }
758
- class Ne {
775
+ class Ce {
759
776
  constructor(e) {
760
- i(this, "svg", B());
761
- i(this, "group", $());
777
+ i(this, "svg", $());
778
+ i(this, "group", W());
762
779
  i(this, "line");
763
780
  i(this, "sourceArrow", null);
764
781
  i(this, "targetArrow", null);
@@ -779,37 +796,37 @@ class Ne {
779
796
  this.cycleSquareSide / 2
780
797
  ), 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;
781
798
  const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
782
- this.svg.appendChild(this.group), this.line = W(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(r), this.group.appendChild(this.targetArrow));
799
+ this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
783
800
  }
784
801
  render(e) {
785
- const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
802
+ const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
786
803
  e.from,
787
804
  e.to
788
805
  );
789
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
790
- const c = b(
806
+ 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})`;
807
+ const c = T(
791
808
  e.from.direction,
792
809
  n,
793
- h
794
- ), a = b(e.to.direction, n, h), l = {
810
+ d
811
+ ), a = T(e.to.direction, n, d), l = {
795
812
  x: s,
796
- y: d
813
+ y: h
797
814
  };
798
- let g, f = a, v = -this.arrowLength;
799
- if (e.from.portId === e.to.portId ? (g = j({
800
- fromVect: c,
815
+ let g, y = a, v = -this.arrowLength;
816
+ if (e.from.portId === e.to.portId ? (g = G({
817
+ fromVector: c,
801
818
  arrowLength: this.arrowLength,
802
819
  side: this.cycleSquareSide,
803
820
  arrowOffset: this.arrowOffset,
804
821
  roundness: this.roundness,
805
822
  hasSourceArrow: this.hasSourceArrow,
806
823
  hasTargetArrow: this.hasTargetArrow
807
- }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
824
+ }), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
808
825
  to: l,
809
- fromVect: c,
810
- toVect: a,
826
+ fromVector: c,
827
+ toVector: a,
811
828
  flipX: n,
812
- flipY: h,
829
+ flipY: d,
813
830
  arrowLength: this.arrowLength,
814
831
  arrowOffset: this.arrowOffset,
815
832
  roundness: this.roundness,
@@ -817,39 +834,39 @@ class Ne {
817
834
  detourDistance: this.detourDistance,
818
835
  hasSourceArrow: this.hasSourceArrow,
819
836
  hasTargetArrow: this.hasTargetArrow
820
- }) : g = Ee({
837
+ }) : g = Te({
821
838
  to: l,
822
- fromVect: c,
823
- toVect: a,
839
+ fromVector: c,
840
+ toVector: a,
824
841
  arrowLength: this.arrowLength,
825
842
  arrowOffset: this.arrowOffset,
826
843
  roundness: this.roundness,
827
844
  hasSourceArrow: this.hasSourceArrow,
828
845
  hasTargetArrow: this.hasTargetArrow
829
846
  }), this.line.setAttribute("d", g), this.sourceArrow) {
830
- const y = N(
847
+ const f = N(
831
848
  c,
832
849
  w,
833
850
  this.arrowLength,
834
851
  this.arrowWidth
835
852
  );
836
- this.sourceArrow.setAttribute("d", y);
853
+ this.sourceArrow.setAttribute("d", f);
837
854
  }
838
855
  if (this.targetArrow) {
839
- const y = N(
840
- f,
856
+ const f = N(
857
+ y,
841
858
  l,
842
859
  v,
843
860
  this.arrowWidth
844
861
  );
845
- this.targetArrow.setAttribute("d", y);
862
+ this.targetArrow.setAttribute("d", f);
846
863
  }
847
864
  }
848
865
  }
849
- class me {
866
+ class Ve {
850
867
  constructor(e) {
851
- i(this, "svg", B());
852
- i(this, "group", $());
868
+ i(this, "svg", $());
869
+ i(this, "group", W());
853
870
  i(this, "line");
854
871
  i(this, "sourceArrow", null);
855
872
  i(this, "targetArrow", null);
@@ -870,37 +887,37 @@ class me {
870
887
  this.cycleSquareSide / 2
871
888
  ), 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;
872
889
  const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
873
- this.svg.appendChild(this.group), this.line = W(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(r), this.group.appendChild(this.targetArrow));
890
+ this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
874
891
  }
875
892
  render(e) {
876
- const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
893
+ const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
877
894
  e.from,
878
895
  e.to
879
896
  );
880
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
881
- const c = b(
897
+ 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})`;
898
+ const c = T(
882
899
  e.from.direction,
883
900
  n,
884
- h
885
- ), a = b(e.to.direction, n, h), l = {
901
+ d
902
+ ), a = T(e.to.direction, n, d), l = {
886
903
  x: s,
887
- y: d
904
+ y: h
888
905
  };
889
- let g, f = a, v = -this.arrowLength;
890
- if (e.from.portId === e.to.portId ? (g = j({
891
- fromVect: c,
906
+ let g, y = a, v = -this.arrowLength;
907
+ if (e.from.portId === e.to.portId ? (g = G({
908
+ fromVector: c,
892
909
  arrowLength: this.arrowLength,
893
910
  side: this.cycleSquareSide,
894
911
  arrowOffset: this.arrowOffset,
895
912
  roundness: this.roundness,
896
913
  hasSourceArrow: this.hasSourceArrow,
897
914
  hasTargetArrow: this.hasTargetArrow
898
- }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
915
+ }), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
899
916
  to: l,
900
- fromVect: c,
901
- toVect: a,
917
+ fromVector: c,
918
+ toVector: a,
902
919
  flipX: n,
903
- flipY: h,
920
+ flipY: d,
904
921
  arrowLength: this.arrowLength,
905
922
  arrowOffset: this.arrowOffset,
906
923
  roundness: this.roundness,
@@ -908,42 +925,42 @@ class me {
908
925
  detourDistance: this.detourDistance,
909
926
  hasSourceArrow: this.hasSourceArrow,
910
927
  hasTargetArrow: this.hasTargetArrow
911
- }) : g = Se({
928
+ }) : g = Ne({
912
929
  to: l,
913
- fromVect: c,
914
- toVect: a,
915
- flipY: h,
930
+ fromVector: c,
931
+ toVector: a,
932
+ flipY: d,
916
933
  arrowLength: this.arrowLength,
917
934
  arrowOffset: this.arrowOffset,
918
935
  roundness: this.roundness,
919
936
  hasSourceArrow: this.hasSourceArrow,
920
937
  hasTargetArrow: this.hasTargetArrow
921
938
  }), this.line.setAttribute("d", g), this.sourceArrow) {
922
- const y = N(
939
+ const f = N(
923
940
  c,
924
941
  w,
925
942
  this.arrowLength,
926
943
  this.arrowWidth
927
944
  );
928
- this.sourceArrow.setAttribute("d", y);
945
+ this.sourceArrow.setAttribute("d", f);
929
946
  }
930
947
  if (this.targetArrow) {
931
- const y = N(
932
- f,
948
+ const f = N(
949
+ y,
933
950
  l,
934
951
  v,
935
952
  this.arrowWidth
936
953
  );
937
- this.targetArrow.setAttribute("d", y);
954
+ this.targetArrow.setAttribute("d", f);
938
955
  }
939
956
  }
940
957
  }
941
- const Pe = (t) => {
958
+ const Le = (t) => {
942
959
  if (typeof t == "function")
943
960
  return t;
944
961
  switch (t == null ? void 0 : t.type) {
945
962
  case "straight":
946
- return () => new Ne({
963
+ return () => new Ce({
947
964
  color: t.color,
948
965
  width: t.width,
949
966
  arrowLength: t.arrowLength,
@@ -957,7 +974,7 @@ const Pe = (t) => {
957
974
  detourDirection: t.detourDirection
958
975
  });
959
976
  case "horizontal":
960
- return () => new be({
977
+ return () => new Me({
961
978
  color: t.color,
962
979
  width: t.width,
963
980
  arrowLength: t.arrowLength,
@@ -971,7 +988,7 @@ const Pe = (t) => {
971
988
  detourDirection: t.detourDirection
972
989
  });
973
990
  case "vertical":
974
- return () => new me({
991
+ return () => new Ve({
975
992
  color: t.color,
976
993
  width: t.width,
977
994
  arrowLength: t.arrowLength,
@@ -985,7 +1002,7 @@ const Pe = (t) => {
985
1002
  detourDirection: t.detourDirection
986
1003
  });
987
1004
  default:
988
- return () => new Te({
1005
+ return () => new De({
989
1006
  color: t.color,
990
1007
  width: t.width,
991
1008
  arrowLength: t.arrowLength,
@@ -999,30 +1016,30 @@ const Pe = (t) => {
999
1016
  detourDirection: t.detourDirection
1000
1017
  });
1001
1018
  }
1002
- }, De = (t) => {
1003
- var o, r, s, d, n;
1004
- const e = ye(
1019
+ }, Re = (t) => {
1020
+ var o, r, s, h, n;
1021
+ const e = Ee(
1005
1022
  (o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
1006
1023
  (r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
1007
1024
  );
1008
1025
  return {
1009
1026
  nodes: {
1010
- centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? we,
1027
+ centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? Ae,
1011
1028
  priorityFn: e.nodesPriorityFn
1012
1029
  },
1013
1030
  ports: {
1014
- direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
1031
+ direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
1015
1032
  },
1016
1033
  edges: {
1017
- shapeFactory: Pe(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
1034
+ shapeFactory: Le(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
1018
1035
  priorityFn: e.edgesPriorityFn
1019
1036
  }
1020
1037
  };
1021
1038
  };
1022
- class Me {
1023
- constructor(e, o, r, s, d) {
1039
+ class de {
1040
+ constructor(e, o, r, s, h) {
1024
1041
  /**
1025
- * provides api for accessing graph model
1042
+ * provides api for accessing model of rendered graph
1026
1043
  */
1027
1044
  i(this, "graph");
1028
1045
  /**
@@ -1030,13 +1047,13 @@ class Me {
1030
1047
  */
1031
1048
  i(this, "viewport");
1032
1049
  i(this, "defaults");
1033
- i(this, "nodeIdGenerator", new X(
1050
+ i(this, "nodeIdGenerator", new Y(
1034
1051
  (e) => this.graph.getNode(e) !== null
1035
1052
  ));
1036
- i(this, "portIdGenerator", new X(
1053
+ i(this, "portIdGenerator", new Y(
1037
1054
  (e) => this.graph.getPort(e) !== null
1038
1055
  ));
1039
- i(this, "edgeIdGenerator", new X(
1056
+ i(this, "edgeIdGenerator", new Y(
1040
1057
  (e) => this.graph.getEdge(e) !== null
1041
1058
  ));
1042
1059
  i(this, "onAfterNodeAdded", (e) => {
@@ -1084,17 +1101,20 @@ class Me {
1084
1101
  this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
1085
1102
  });
1086
1103
  i(this, "onBeforeDestroyEmitter");
1104
+ /**
1105
+ * emits event just before destruction of canvas
1106
+ */
1087
1107
  i(this, "onBeforeDestroy");
1088
- this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = De(d), this.graph = new ue(this.graphStore), this.viewport = new ge(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
1108
+ this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = Re(h), this.graph = new xe(this.graphStore), this.viewport = new ve(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
1089
1109
  this.onAfterNodePriorityUpdated
1090
1110
  ), 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(
1091
1111
  this.onAfterEdgeShapeUpdated
1092
1112
  ), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
1093
1113
  this.onAfterEdgePriorityUpdated
1094
- ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = A();
1114
+ ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = E();
1095
1115
  }
1096
1116
  /**
1097
- * adds node to graph
1117
+ * adds new node
1098
1118
  */
1099
1119
  addNode(e) {
1100
1120
  const o = this.nodeIdGenerator.create(e.id);
@@ -1122,28 +1142,28 @@ class Me {
1122
1142
  */
1123
1143
  updateNode(e, o) {
1124
1144
  if (this.graph.getNode(e) === null)
1125
- throw new S("failed to update nonexisting node");
1145
+ throw new S("failed to update non existing node");
1126
1146
  return this.graphStore.updateNode(e, o ?? {}), this;
1127
1147
  }
1128
1148
  /**
1129
- * removes node from graph
1149
+ * removes specified node
1130
1150
  * all the ports of node get unmarked
1131
1151
  * all the edges adjacent to node get removed
1132
1152
  */
1133
1153
  removeNode(e) {
1134
1154
  if (this.graph.getNode(e) === null)
1135
- throw new S("failed to remove nonexisting node");
1155
+ throw new S("failed to remove non existing node");
1136
1156
  return this.graphStore.removeNode(e), this;
1137
1157
  }
1138
1158
  /**
1139
- * marks element as port of node
1159
+ * marks specified element as a port for specified node
1140
1160
  */
1141
1161
  markPort(e) {
1142
1162
  const o = this.portIdGenerator.create(e.id);
1143
1163
  if (this.graph.getPort(o) !== null)
1144
1164
  throw new S("failed to add port with existing id");
1145
1165
  if (this.graph.getNode(e.nodeId) === null)
1146
- throw new S("failed to mark port for nonexisting node");
1166
+ throw new S("failed to mark port for nonexistent node");
1147
1167
  return this.graphStore.addPort({
1148
1168
  id: o,
1149
1169
  element: e.element,
@@ -1152,33 +1172,33 @@ class Me {
1152
1172
  }), this;
1153
1173
  }
1154
1174
  /**
1155
- * updates port and attached edges
1175
+ * updates port and edges attached to it
1156
1176
  */
1157
1177
  updatePort(e, o) {
1158
1178
  if (this.graph.getPort(e) === null)
1159
- throw new S("failed to update nonexisting port");
1179
+ throw new S("failed to update nonexistent port");
1160
1180
  return this.graphStore.updatePort(e, o ?? {}), this;
1161
1181
  }
1162
1182
  /**
1163
- * ummarks element as port of node
1164
- * all the edges adjacent to port get removed
1183
+ * unmarks specified port
1184
+ * all the edges adjacent to the port get removed
1165
1185
  */
1166
1186
  unmarkPort(e) {
1167
1187
  if (this.graph.getPort(e) === null)
1168
- throw new S("failed to unmark nonexisting port");
1188
+ throw new S("failed to unmark non existing port");
1169
1189
  return this.graphStore.removePort(e), this;
1170
1190
  }
1171
1191
  /**
1172
- * adds edge to graph
1192
+ * adds new edge
1173
1193
  */
1174
1194
  addEdge(e) {
1175
1195
  const o = this.edgeIdGenerator.create(e.id);
1176
1196
  if (this.graph.getEdge(o) !== null)
1177
1197
  throw new S("failed to add edge with existing id");
1178
1198
  if (this.graph.getPort(e.from) === null)
1179
- throw new S("failed to add edge from nonexisting port");
1199
+ throw new S("failed to add edge from nonexistent port");
1180
1200
  if (this.graph.getPort(e.to) === null)
1181
- throw new S("failed to add edge to nonexisting port");
1201
+ throw new S("failed to add edge to nonexistent port");
1182
1202
  return this.graphStore.addEdge({
1183
1203
  id: o,
1184
1204
  from: e.from,
@@ -1188,29 +1208,29 @@ class Me {
1188
1208
  }), this;
1189
1209
  }
1190
1210
  /**
1191
- * updates edge
1211
+ * updates specified edge
1192
1212
  */
1193
1213
  updateEdge(e, o) {
1194
1214
  if (this.graph.getEdge(e) === null)
1195
- throw new S("failed to update nonexisting edge");
1215
+ throw new S("failed to update nonexistent edge");
1196
1216
  return this.graphStore.updateEdge(e, o ?? {}), this;
1197
1217
  }
1198
1218
  /**
1199
- * removes edge from graph
1219
+ * removes specified edge
1200
1220
  */
1201
1221
  removeEdge(e) {
1202
1222
  if (this.graph.getEdge(e) === null)
1203
- throw new S("failed to remove nonexisting edge");
1223
+ throw new S("failed to remove nonexistent edge");
1204
1224
  return this.graphStore.removeEdge(e), this;
1205
1225
  }
1206
1226
  /**
1207
- * applies transformation for viewport
1227
+ * applies transformation for viewport matrix
1208
1228
  */
1209
1229
  patchViewportMatrix(e) {
1210
1230
  return this.viewportStore.patchViewportMatrix(e), this;
1211
1231
  }
1212
1232
  /**
1213
- * applies transformation for content
1233
+ * applies transformation for content matrix
1214
1234
  */
1215
1235
  patchContentMatrix(e) {
1216
1236
  return this.viewportStore.patchContentMatrix(e), this;
@@ -1227,22 +1247,22 @@ class Me {
1227
1247
  * canvas element gets rolled back to initial state, and can not be reused
1228
1248
  */
1229
1249
  destroy() {
1230
- this.onBeforeDestroyEmitter.emit(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
1250
+ this.onBeforeDestroyEmitter.emit(), this.clear(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
1231
1251
  this.onAfterNodePriorityUpdated
1232
1252
  ), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
1233
1253
  this.onAfterEdgeShapeUpdated
1234
1254
  ), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
1235
1255
  this.onAfterEdgePriorityUpdated
1236
- ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.clear(), this.htmlView.destroy();
1256
+ ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
1237
1257
  }
1238
1258
  }
1239
- class Ve {
1259
+ class ce {
1240
1260
  constructor() {
1241
1261
  i(this, "nodes", /* @__PURE__ */ new Map());
1242
1262
  i(this, "ports", /* @__PURE__ */ new Map());
1243
1263
  i(this, "edges", /* @__PURE__ */ new Map());
1244
- i(this, "incommingEdges", /* @__PURE__ */ new Map());
1245
- i(this, "outcommingEdges", /* @__PURE__ */ new Map());
1264
+ i(this, "incomingEdges", /* @__PURE__ */ new Map());
1265
+ i(this, "outcomingEdges", /* @__PURE__ */ new Map());
1246
1266
  i(this, "cycleEdges", /* @__PURE__ */ new Map());
1247
1267
  i(this, "afterNodeAddedEmitter");
1248
1268
  i(this, "onAfterNodeAdded");
@@ -1270,7 +1290,7 @@ class Ve {
1270
1290
  i(this, "onBeforeEdgeRemoved");
1271
1291
  i(this, "beforeClearEmitter");
1272
1292
  i(this, "onBeforeClear");
1273
- [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();
1293
+ [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = E(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = E(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = E(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = E(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = E(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = E(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = E(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = E(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = E(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = E(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = E(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = E(), [this.beforeClearEmitter, this.onBeforeClear] = E();
1274
1294
  }
1275
1295
  addNode(e) {
1276
1296
  const o = /* @__PURE__ */ new Map(), r = {
@@ -1301,7 +1321,7 @@ class Ve {
1301
1321
  element: e.element,
1302
1322
  direction: e.direction,
1303
1323
  nodeId: e.nodeId
1304
- }), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
1324
+ }), 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);
1305
1325
  }
1306
1326
  getPort(e) {
1307
1327
  return this.ports.get(e);
@@ -1349,13 +1369,13 @@ class Ve {
1349
1369
  this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
1350
1370
  }
1351
1371
  clear() {
1352
- this.beforeClearEmitter.emit(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
1372
+ this.beforeClearEmitter.emit(), this.incomingEdges.clear(), this.outcomingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
1353
1373
  }
1354
1374
  getPortIncomingEdgeIds(e) {
1355
- return Array.from(this.incommingEdges.get(e));
1375
+ return Array.from(this.incomingEdges.get(e));
1356
1376
  }
1357
1377
  getPortOutcomingEdgeIds(e) {
1358
- return Array.from(this.outcommingEdges.get(e));
1378
+ return Array.from(this.outcomingEdges.get(e));
1359
1379
  }
1360
1380
  getPortCycleEdgeIds(e) {
1361
1381
  return Array.from(this.cycleEdges.get(e));
@@ -1401,31 +1421,31 @@ class Ve {
1401
1421
  to: e.to,
1402
1422
  shape: e.shape,
1403
1423
  priority: e.priority
1404
- }), e.from !== e.to ? (this.outcommingEdges.get(e.from).add(e.id), this.incommingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
1424
+ }), 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);
1405
1425
  }
1406
1426
  removeEdgeInternal(e) {
1407
1427
  const o = this.edges.get(e), r = o.from, s = o.to;
1408
- this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.incommingEdges.get(r).delete(e), this.incommingEdges.get(s).delete(e), this.outcommingEdges.get(r).delete(e), this.outcommingEdges.get(s).delete(e), this.edges.delete(e);
1428
+ 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);
1409
1429
  }
1410
1430
  }
1411
- const ee = (t) => ({
1431
+ const re = (t) => ({
1412
1432
  scale: 1 / t.scale,
1413
1433
  x: -t.x / t.scale,
1414
1434
  y: -t.y / t.scale
1415
- }), te = {
1435
+ }), ie = {
1416
1436
  scale: 1,
1417
1437
  x: 0,
1418
1438
  y: 0
1419
1439
  };
1420
- class Le {
1440
+ class Ie {
1421
1441
  constructor() {
1422
- i(this, "viewportMatrix", te);
1423
- i(this, "contentMatrix", te);
1442
+ i(this, "viewportMatrix", ie);
1443
+ i(this, "contentMatrix", ie);
1424
1444
  i(this, "afterUpdateEmitter");
1425
1445
  i(this, "onAfterUpdated");
1426
1446
  i(this, "beforeUpdateEmitter");
1427
1447
  i(this, "onBeforeUpdated");
1428
- [this.afterUpdateEmitter, this.onAfterUpdated] = A(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = A();
1448
+ [this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E();
1429
1449
  }
1430
1450
  getViewportMatrix() {
1431
1451
  return this.viewportMatrix;
@@ -1438,17 +1458,17 @@ class Le {
1438
1458
  scale: e.scale ?? this.viewportMatrix.scale,
1439
1459
  x: e.x ?? this.viewportMatrix.x,
1440
1460
  y: e.y ?? this.viewportMatrix.y
1441
- }, this.contentMatrix = ee(this.viewportMatrix), this.afterUpdateEmitter.emit();
1461
+ }, this.contentMatrix = re(this.viewportMatrix), this.afterUpdateEmitter.emit();
1442
1462
  }
1443
1463
  patchContentMatrix(e) {
1444
1464
  this.beforeUpdateEmitter.emit(), this.contentMatrix = {
1445
1465
  scale: e.scale ?? this.contentMatrix.scale,
1446
1466
  x: e.x ?? this.contentMatrix.x,
1447
1467
  y: e.y ?? this.contentMatrix.y
1448
- }, this.viewportMatrix = ee(this.contentMatrix), this.afterUpdateEmitter.emit();
1468
+ }, this.viewportMatrix = re(this.contentMatrix), this.afterUpdateEmitter.emit();
1449
1469
  }
1450
1470
  }
1451
- class G {
1471
+ class J {
1452
1472
  constructor(e) {
1453
1473
  i(this, "elementToNodeId", /* @__PURE__ */ new Map());
1454
1474
  i(this, "nodesResizeObserver");
@@ -1474,7 +1494,7 @@ class G {
1474
1494
  }), 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);
1475
1495
  }
1476
1496
  static configure(e) {
1477
- new G(e);
1497
+ new J(e);
1478
1498
  }
1479
1499
  handleNodeResize(e) {
1480
1500
  const o = this.elementToNodeId.get(e);
@@ -1483,35 +1503,36 @@ class G {
1483
1503
  });
1484
1504
  }
1485
1505
  }
1486
- const Ce = (t) => {
1487
- var g, f, v, y, p, E;
1506
+ const Be = (t) => {
1507
+ var g, y, v, f, p, A;
1488
1508
  const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
1489
- }), o = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), r = ((v = t == null ? void 0 : t.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
1490
- }), s = (t == null ? void 0 : t.moveOnTop) === !1, d = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, n = d !== void 0 ? d : "grab", h = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseDownEventVerifier, c = h !== void 0 ? h : (T) => T.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
1509
+ }), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((v = t == null ? void 0 : t.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
1510
+ }), 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 = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseDownEventVerifier, c = d !== void 0 ? d : (b) => b.button === 0, a = (A = t == null ? void 0 : t.mouse) == null ? void 0 : A.mouseUpEventVerifier;
1491
1511
  return {
1492
1512
  freezePriority: s,
1493
1513
  dragCursor: n,
1494
1514
  mouseDownEventVerifier: c,
1495
- mouseUpEventVerifier: a !== void 0 ? a : (T) => T.button === 0,
1515
+ mouseUpEventVerifier: a !== void 0 ? a : (b) => b.button === 0,
1496
1516
  onNodeDrag: e,
1497
1517
  onBeforeNodeDrag: o,
1498
1518
  onNodeDragFinished: r
1499
1519
  };
1500
- }, R = (t, e, o) => {
1501
- const { x: r, y: s, width: d, height: n } = t.getBoundingClientRect();
1502
- return e >= r && e <= r + d && o >= s && o <= s + n;
1503
- }, U = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, I = (t, e) => {
1520
+ }, Ue = (t, e, o) => {
1521
+ const { x: r, y: s, width: h, height: n } = t.getBoundingClientRect();
1522
+ return e >= r && e <= r + h && o >= s && o <= s + n;
1523
+ }, $e = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, V = (t, e, o, r) => Ue(e, o, r) && $e(t, o, r), U = (t, e) => {
1504
1524
  e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
1505
- };
1506
- class J {
1507
- constructor(e, o) {
1525
+ }, C = (t, e) => ({
1526
+ x: t.scale * e.x + t.x,
1527
+ y: t.scale * e.y + t.y
1528
+ });
1529
+ class K {
1530
+ constructor(e, o, r, s) {
1508
1531
  i(this, "grabbedNodeId", null);
1509
1532
  i(this, "maxNodePriority", 0);
1510
- i(this, "previousTouchCoords", null);
1533
+ i(this, "previousTouchCoordinates", null);
1511
1534
  i(this, "nodeIds", /* @__PURE__ */ new Map());
1512
- i(this, "window", window);
1513
1535
  i(this, "graph");
1514
- i(this, "element");
1515
1536
  i(this, "onAfterNodeAdded", (e) => {
1516
1537
  this.updateMaxNodePriority(e);
1517
1538
  const o = this.graph.getNode(e);
@@ -1541,12 +1562,12 @@ class J {
1541
1562
  element: s.element,
1542
1563
  x: s.x,
1543
1564
  y: s.y
1544
- }) && (e.stopImmediatePropagation(), this.grabbedNodeId = r, I(this.element, this.options.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1565
+ }) && (e.stopImmediatePropagation(), this.grabbedNodeId = r, U(this.element, this.options.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1545
1566
  });
1546
1567
  i(this, "onTouchStart", (e) => {
1547
1568
  if (e.touches.length !== 1)
1548
1569
  return;
1549
- e.stopImmediatePropagation(), this.previousTouchCoords = {
1570
+ e.stopImmediatePropagation(), this.previousTouchCoordinates = {
1550
1571
  x: e.touches[0].clientX,
1551
1572
  y: e.touches[0].clientY
1552
1573
  };
@@ -1559,7 +1580,12 @@ class J {
1559
1580
  }) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
1560
1581
  });
1561
1582
  i(this, "onWindowMouseMove", (e) => {
1562
- if (!R(this.element, e.clientX, e.clientY) || !U(this.window, e.clientX, e.clientY)) {
1583
+ if (!V(
1584
+ this.window,
1585
+ this.element,
1586
+ e.clientX,
1587
+ e.clientY
1588
+ )) {
1563
1589
  this.cancelMouseDrag();
1564
1590
  return;
1565
1591
  }
@@ -1572,37 +1598,48 @@ class J {
1572
1598
  if (e.touches.length !== 1)
1573
1599
  return;
1574
1600
  const o = e.touches[0];
1575
- if (!R(this.element, o.clientX, o.clientY) || !U(this.window, o.clientX, o.clientY)) {
1601
+ if (!V(
1602
+ this.window,
1603
+ this.element,
1604
+ o.clientX,
1605
+ o.clientY
1606
+ )) {
1576
1607
  this.cancelTouchDrag();
1577
1608
  return;
1578
1609
  }
1579
- if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
1580
- const r = o.clientX - this.previousTouchCoords.x, s = o.clientY - this.previousTouchCoords.y;
1581
- this.dragNode(this.grabbedNodeId, r, s), this.previousTouchCoords = {
1610
+ if (this.grabbedNodeId !== null && this.previousTouchCoordinates !== null) {
1611
+ const s = o.clientX - this.previousTouchCoordinates.x, h = o.clientY - this.previousTouchCoordinates.y;
1612
+ this.dragNode(this.grabbedNodeId, s, h), this.previousTouchCoordinates = {
1582
1613
  x: e.touches[0].clientX,
1583
1614
  y: e.touches[0].clientY
1584
1615
  };
1585
1616
  }
1586
1617
  });
1587
1618
  i(this, "onWindowTouchFinish", () => {
1588
- this.previousTouchCoords = null, this.cancelTouchDrag();
1619
+ this.previousTouchCoordinates = null, this.cancelTouchDrag();
1589
1620
  });
1590
1621
  i(this, "options");
1591
- this.canvas = e, this.options = Ce(o), this.graph = e.graph, this.element = e.element, 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);
1622
+ this.canvas = e, this.element = o, this.window = r, this.options = Be(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);
1592
1623
  }
1593
- static configure(e, o) {
1594
- new J(e, o);
1624
+ static configure(e, o, r, s) {
1625
+ new K(e, o, r, s);
1595
1626
  }
1596
1627
  dragNode(e, o, r) {
1597
1628
  const s = this.graph.getNode(e);
1598
1629
  if (s === null)
1599
1630
  return;
1600
- const d = this.canvas.viewport.getContentMatrix(), n = d.scale * s.x + d.x, h = d.scale * s.y + d.y, c = n + o, a = h + r, l = this.canvas.viewport.getViewportMatrix(), g = l.scale * c + l.x, f = l.scale * a + l.y;
1601
- this.canvas.updateNode(e, { x: g, y: f }), this.options.onNodeDrag({
1631
+ const h = this.canvas.viewport.getContentMatrix(), n = C(h, {
1632
+ x: s.x,
1633
+ y: s.y
1634
+ }), d = C(
1635
+ { scale: 1, x: o, y: r },
1636
+ n
1637
+ ), c = this.canvas.viewport.getViewportMatrix(), a = C(c, d);
1638
+ this.canvas.updateNode(e, { x: a.x, y: a.y }), this.options.onNodeDrag({
1602
1639
  nodeId: e,
1603
1640
  element: s.element,
1604
- x: g,
1605
- y: f
1641
+ x: a.x,
1642
+ y: a.y
1606
1643
  });
1607
1644
  }
1608
1645
  moveNodeOnTop(e) {
@@ -1621,13 +1658,13 @@ class J {
1621
1658
  element: e.element,
1622
1659
  x: e.x,
1623
1660
  y: e.y
1624
- }), this.grabbedNodeId = null, I(this.canvas.element, null), this.removeMouseDragListeners();
1661
+ }), this.grabbedNodeId = null, U(this.element, null), this.removeMouseDragListeners();
1625
1662
  }
1626
1663
  removeMouseDragListeners() {
1627
1664
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
1628
1665
  }
1629
1666
  cancelTouchDrag() {
1630
- this.previousTouchCoords = null;
1667
+ this.previousTouchCoordinates = null;
1631
1668
  const e = this.graph.getNode(this.grabbedNodeId);
1632
1669
  e !== null && this.options.onNodeDragFinished({
1633
1670
  nodeId: this.grabbedNodeId,
@@ -1644,30 +1681,30 @@ class J {
1644
1681
  this.maxNodePriority = Math.max(this.maxNodePriority, o);
1645
1682
  }
1646
1683
  }
1647
- const Re = (t) => {
1684
+ const We = (t) => {
1648
1685
  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;
1649
- return (d) => {
1650
- let n = d.nextTransform.x, h = d.nextTransform.y;
1651
- n < e && n < d.prevTransform.x && (n = Math.min(d.prevTransform.x, e));
1652
- const c = d.canvasWidth * d.prevTransform.scale, a = o - c;
1653
- n > a && n > d.prevTransform.x && (n = Math.max(d.prevTransform.x, a)), h < r && h < d.prevTransform.y && (h = Math.min(d.prevTransform.y, r));
1654
- const l = d.canvasHeight * d.prevTransform.scale, g = s - l;
1655
- return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x: n, y: h };
1686
+ return (h) => {
1687
+ let n = h.nextTransform.x, d = h.nextTransform.y;
1688
+ n < e && n < h.prevTransform.x && (n = Math.min(h.prevTransform.x, e));
1689
+ const c = h.canvasWidth * h.prevTransform.scale, a = o - c;
1690
+ 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));
1691
+ const l = h.canvasHeight * h.prevTransform.scale, g = s - l;
1692
+ return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: n, y: d };
1656
1693
  };
1657
- }, Ue = (t) => {
1694
+ }, Fe = (t) => {
1658
1695
  const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
1659
- return (d) => {
1660
- const n = d.prevTransform, h = d.nextTransform;
1661
- let c = h.scale, a = h.x, l = h.y;
1662
- if (h.scale > s && h.scale > n.scale) {
1696
+ return (h) => {
1697
+ const n = h.prevTransform, d = h.nextTransform;
1698
+ let c = d.scale, a = d.x, l = d.y;
1699
+ if (d.scale > s && d.scale > n.scale) {
1663
1700
  c = Math.max(n.scale, s), a = n.x, l = n.y;
1664
- const g = (c - n.scale) / (h.scale - n.scale);
1665
- a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
1701
+ const g = (c - n.scale) / (d.scale - n.scale);
1702
+ a = n.x + (d.x - n.x) * g, l = n.y + (d.y - n.y) * g;
1666
1703
  }
1667
- if (h.scale < r && h.scale < n.scale) {
1704
+ if (d.scale < r && d.scale < n.scale) {
1668
1705
  c = Math.min(n.scale, r), a = n.x, l = n.y;
1669
- const g = (c - n.scale) / (h.scale - n.scale);
1670
- a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
1706
+ const g = (c - n.scale) / (d.scale - n.scale);
1707
+ a = n.x + (d.x - n.x) * g, l = n.y + (d.y - n.y) * g;
1671
1708
  }
1672
1709
  return {
1673
1710
  scale: c,
@@ -1675,7 +1712,7 @@ const Re = (t) => {
1675
1712
  y: l
1676
1713
  };
1677
1714
  };
1678
- }, Ie = (t) => (e) => t.reduce(
1715
+ }, ze = (t) => (e) => t.reduce(
1679
1716
  (o, r) => r({
1680
1717
  prevTransform: e.prevTransform,
1681
1718
  nextTransform: o,
@@ -1683,71 +1720,71 @@ const Re = (t) => {
1683
1720
  canvasHeight: e.canvasHeight
1684
1721
  }),
1685
1722
  e.nextTransform
1686
- ), oe = (t) => {
1723
+ ), se = (t) => {
1687
1724
  if (typeof t == "function")
1688
1725
  return t;
1689
1726
  switch (t.type) {
1690
1727
  case "scale-limit":
1691
- return Ue({
1728
+ return Fe({
1692
1729
  minContentScale: t.minContentScale ?? 0,
1693
1730
  maxContentScale: t.maxContentScale ?? 1 / 0
1694
1731
  });
1695
1732
  case "shift-limit":
1696
- return Re({
1733
+ return We({
1697
1734
  minX: t.minX ?? -1 / 0,
1698
1735
  maxX: t.maxX ?? 1 / 0,
1699
1736
  minY: t.minY ?? -1 / 0,
1700
1737
  maxY: t.maxY ?? 1 / 0
1701
1738
  });
1702
1739
  }
1703
- }, Be = (t) => {
1704
- var y, p, E, T, Y, D, M, V, Q, Z, _, q;
1705
- const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
1740
+ }, ke = (t) => {
1741
+ var f, p, A, b, D, m, L, R, q, O, ee, te;
1742
+ 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;
1706
1743
  let s;
1707
- r !== void 0 ? Array.isArray(r) ? s = Ie(
1744
+ r !== void 0 ? Array.isArray(r) ? s = ze(
1708
1745
  r.map(
1709
- (P) => oe(P)
1746
+ (M) => se(M)
1710
1747
  )
1711
- ) : s = oe(r) : s = (P) => P.nextTransform;
1712
- const d = ((p = t == null ? void 0 : t.shift) == null ? void 0 : p.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
1713
- }), h = ((T = t == null ? void 0 : t.events) == null ? void 0 : T.onTransformChange) ?? (() => {
1714
- }), c = (Y = t == null ? void 0 : t.shift) == null ? void 0 : Y.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (D = t == null ? void 0 : t.shift) == null ? void 0 : D.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, f = (M = t == null ? void 0 : t.scale) == null ? void 0 : M.mouseWheelEventVerifier, v = f !== void 0 ? f : () => !0;
1748
+ ) : s = se(r) : s = (M) => M.nextTransform;
1749
+ const h = ((p = t == null ? void 0 : t.shift) == null ? void 0 : p.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((A = t == null ? void 0 : t.events) == null ? void 0 : A.onBeforeTransformChange) ?? (() => {
1750
+ }), d = ((b = t == null ? void 0 : t.events) == null ? void 0 : b.onTransformChange) ?? (() => {
1751
+ }), c = (D = t == null ? void 0 : t.shift) == null ? void 0 : D.mouseDownEventVerifier, a = c !== void 0 ? c : (M) => M.button === 0, l = (m = t == null ? void 0 : t.shift) == null ? void 0 : m.mouseUpEventVerifier, g = l !== void 0 ? l : (M) => M.button === 0, y = (L = t == null ? void 0 : t.scale) == null ? void 0 : L.mouseWheelEventVerifier, v = y !== void 0 ? y : () => !0;
1715
1752
  return {
1716
1753
  wheelSensitivity: o,
1717
- onTransformStarted: ((V = t == null ? void 0 : t.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
1754
+ onTransformStarted: ((R = t == null ? void 0 : t.events) == null ? void 0 : R.onTransformStarted) ?? (() => {
1718
1755
  }),
1719
- onTransformFinished: ((Q = t == null ? void 0 : t.events) == null ? void 0 : Q.onTransformFinished) ?? (() => {
1756
+ onTransformFinished: ((q = t == null ? void 0 : t.events) == null ? void 0 : q.onTransformFinished) ?? (() => {
1720
1757
  }),
1721
1758
  onBeforeTransformChange: n,
1722
- onTransformChange: h,
1759
+ onTransformChange: d,
1723
1760
  transformPreprocessor: s,
1724
- shiftCursor: d,
1761
+ shiftCursor: h,
1725
1762
  mouseDownEventVerifier: a,
1726
1763
  mouseUpEventVerifier: g,
1727
1764
  mouseWheelEventVerifier: v,
1728
- scaleWheelFinishTimeout: ((Z = t == null ? void 0 : t.scale) == null ? void 0 : Z.wheelFinishTimeout) ?? 500,
1729
- onResizeTransformStarted: ((_ = t == null ? void 0 : t.events) == null ? void 0 : _.onResizeTransformStarted) ?? (() => {
1765
+ scaleWheelFinishTimeout: ((O = t == null ? void 0 : t.scale) == null ? void 0 : O.wheelFinishTimeout) ?? 500,
1766
+ onResizeTransformStarted: ((ee = t == null ? void 0 : t.events) == null ? void 0 : ee.onResizeTransformStarted) ?? (() => {
1730
1767
  }),
1731
- onResizeTransformFinished: ((q = t == null ? void 0 : t.events) == null ? void 0 : q.onResizeTransformFinished) ?? (() => {
1768
+ onResizeTransformFinished: ((te = t == null ? void 0 : t.events) == null ? void 0 : te.onResizeTransformFinished) ?? (() => {
1732
1769
  })
1733
1770
  };
1734
- }, $e = (t, e, o) => ({
1771
+ }, Ye = (t, e, o) => ({
1735
1772
  scale: t.scale,
1736
1773
  x: t.x + t.scale * e,
1737
1774
  y: t.y + t.scale * o
1738
- }), We = (t, e, o, r) => ({
1775
+ }), Xe = (t, e, o, r) => ({
1739
1776
  scale: t.scale * e,
1740
1777
  x: t.scale * (1 - e) * o + t.x,
1741
1778
  y: t.scale * (1 - e) * r + t.y
1742
- }), C = (t) => {
1779
+ }), B = (t) => {
1743
1780
  const e = [], o = t.touches.length;
1744
- for (let h = 0; h < o; h++)
1745
- e.push([t.touches[h].clientX, t.touches[h].clientY]);
1781
+ for (let d = 0; d < o; d++)
1782
+ e.push([t.touches[d].clientX, t.touches[d].clientY]);
1746
1783
  const r = e.reduce(
1747
- (h, c) => [h[0] + c[0], h[1] + c[1]],
1784
+ (d, c) => [d[0] + c[0], d[1] + c[1]],
1748
1785
  [0, 0]
1749
- ), s = [r[0] / o, r[1] / o], n = e.map((h) => [h[0] - s[0], h[1] - s[1]]).reduce(
1750
- (h, c) => h + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
1786
+ ), s = [r[0] / o, r[1] / o], n = e.map((d) => [d[0] - s[0], d[1] - s[1]]).reduce(
1787
+ (d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
1751
1788
  0
1752
1789
  );
1753
1790
  return {
@@ -1758,10 +1795,8 @@ const Re = (t) => {
1758
1795
  touches: e
1759
1796
  };
1760
1797
  };
1761
- class z {
1762
- constructor(e, o) {
1763
- i(this, "element");
1764
- i(this, "window", window);
1798
+ class k {
1799
+ constructor(e, o, r, s) {
1765
1800
  i(this, "viewport");
1766
1801
  i(this, "prevTouches", null);
1767
1802
  i(this, "wheelFinishTimer", null);
@@ -1770,15 +1805,21 @@ class z {
1770
1805
  this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
1771
1806
  });
1772
1807
  i(this, "onMouseDown", (e) => {
1773
- this.element === null || !this.options.mouseDownEventVerifier(e) || (I(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.startRegisteredTransform());
1808
+ this.element === null || !this.options.mouseDownEventVerifier(e) || (U(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.startRegisteredTransform());
1774
1809
  });
1775
1810
  i(this, "onWindowMouseMove", (e) => {
1776
- if (this.element === null || !R(this.element, e.clientX, e.clientY) || !U(this.window, e.clientX, e.clientY)) {
1811
+ const o = V(
1812
+ this.window,
1813
+ this.element,
1814
+ e.clientX,
1815
+ e.clientY
1816
+ );
1817
+ if (this.element === null || !o) {
1777
1818
  this.stopMouseDrag();
1778
1819
  return;
1779
1820
  }
1780
- const o = -e.movementX, r = -e.movementY;
1781
- this.moveViewport(o, r);
1821
+ const r = -e.movementX, s = -e.movementY;
1822
+ this.moveViewport(r, s);
1782
1823
  });
1783
1824
  i(this, "onWindowMouseUp", (e) => {
1784
1825
  this.element === null || !this.options.mouseUpEventVerifier(e) || this.stopMouseDrag();
@@ -1787,22 +1828,22 @@ class z {
1787
1828
  if (!this.options.mouseWheelEventVerifier(e))
1788
1829
  return;
1789
1830
  e.preventDefault();
1790
- const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o, d = e.clientY - r, h = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
1791
- this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(h, s, d), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
1831
+ const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o, h = e.clientY - r, d = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
1832
+ this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(d, s, h), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
1792
1833
  this.transformInProgress || this.options.onTransformFinished(), this.wheelFinishTimer = null;
1793
1834
  }, this.options.scaleWheelFinishTimeout);
1794
1835
  });
1795
1836
  i(this, "onTouchStart", (e) => {
1796
1837
  if (this.prevTouches !== null) {
1797
- this.prevTouches = C(e);
1838
+ this.prevTouches = B(e);
1798
1839
  return;
1799
1840
  }
1800
- this.prevTouches = C(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.startRegisteredTransform();
1841
+ this.prevTouches = B(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.startRegisteredTransform();
1801
1842
  });
1802
1843
  i(this, "onWindowTouchMove", (e) => {
1803
- const o = C(e);
1844
+ const o = B(e);
1804
1845
  if (!o.touches.every(
1805
- (s) => R(this.element, s[0], s[1]) && U(this.window, s[0], s[1])
1846
+ (s) => V(this.window, this.element, s[0], s[1])
1806
1847
  )) {
1807
1848
  this.stopTouchDrag();
1808
1849
  return;
@@ -1811,13 +1852,13 @@ class z {
1811
1852
  -(o.x - this.prevTouches.x),
1812
1853
  -(o.y - this.prevTouches.y)
1813
1854
  ), o.touchesCnt === 2) {
1814
- const { left: s, top: d } = this.element.getBoundingClientRect(), n = this.prevTouches.x - s, h = this.prevTouches.y - d, a = 1 / (o.scale / this.prevTouches.scale);
1815
- this.scaleViewport(a, n, h);
1855
+ const { left: s, top: h } = this.element.getBoundingClientRect(), n = this.prevTouches.x - s, d = this.prevTouches.y - h, a = 1 / (o.scale / this.prevTouches.scale);
1856
+ this.scaleViewport(a, n, d);
1816
1857
  }
1817
1858
  this.prevTouches = o;
1818
1859
  });
1819
1860
  i(this, "onWindowTouchFinish", (e) => {
1820
- e.touches.length > 0 ? this.prevTouches = C(e) : this.stopTouchDrag();
1861
+ e.touches.length > 0 ? this.prevTouches = B(e) : this.stopTouchDrag();
1821
1862
  });
1822
1863
  i(this, "observer", new ResizeObserver(() => {
1823
1864
  const e = this.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.options.transformPreprocessor({
@@ -1829,31 +1870,36 @@ class z {
1829
1870
  this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.options.onResizeTransformFinished();
1830
1871
  }));
1831
1872
  i(this, "options");
1832
- this.canvas = e, this.options = Be(o), this.element = e.element, this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1873
+ this.canvas = e, this.element = o, this.window = r, this.options = ke(s), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1833
1874
  }
1834
- static configure(e, o) {
1835
- new z(e, o);
1875
+ static configure(e, o, r, s) {
1876
+ new k(
1877
+ e,
1878
+ o,
1879
+ r,
1880
+ s
1881
+ );
1836
1882
  }
1837
1883
  moveViewport(e, o) {
1838
- const r = this.viewport.getViewportMatrix(), s = $e(r, e, o), { width: d, height: n } = this.element.getBoundingClientRect(), h = this.options.transformPreprocessor({
1884
+ const r = this.viewport.getViewportMatrix(), s = Ye(r, e, o), { width: h, height: n } = this.element.getBoundingClientRect(), d = this.options.transformPreprocessor({
1839
1885
  prevTransform: r,
1840
1886
  nextTransform: s,
1841
- canvasWidth: d,
1887
+ canvasWidth: h,
1842
1888
  canvasHeight: n
1843
1889
  });
1844
- this.performTransform(h);
1890
+ this.performTransform(d);
1845
1891
  }
1846
1892
  scaleViewport(e, o, r) {
1847
- const s = this.canvas.viewport.getViewportMatrix(), d = We(s, e, o, r), { width: n, height: h } = this.element.getBoundingClientRect(), c = this.options.transformPreprocessor({
1893
+ const s = this.canvas.viewport.getViewportMatrix(), h = Xe(s, e, o, r), { width: n, height: d } = this.element.getBoundingClientRect(), c = this.options.transformPreprocessor({
1848
1894
  prevTransform: s,
1849
- nextTransform: d,
1895
+ nextTransform: h,
1850
1896
  canvasWidth: n,
1851
- canvasHeight: h
1897
+ canvasHeight: d
1852
1898
  });
1853
1899
  this.performTransform(c);
1854
1900
  }
1855
1901
  stopMouseDrag() {
1856
- I(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
1902
+ U(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
1857
1903
  }
1858
1904
  removeMouseDragListeners() {
1859
1905
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -1874,14 +1920,12 @@ class z {
1874
1920
  this.transformInProgress = !1, this.options.onTransformFinished();
1875
1921
  }
1876
1922
  }
1877
- class K {
1878
- constructor(e, o, r, s) {
1923
+ class Q {
1924
+ constructor(e, o, r, s, h, n) {
1879
1925
  i(this, "canvasResizeObserver");
1880
- i(this, "window", window);
1881
1926
  i(this, "nodeHorizontal");
1882
1927
  i(this, "nodeVertical");
1883
1928
  i(this, "viewport");
1884
- i(this, "element");
1885
1929
  i(this, "viewportWidth", 0);
1886
1930
  i(this, "viewportHeight", 0);
1887
1931
  i(this, "viewportMatrix");
@@ -1908,50 +1952,54 @@ class K {
1908
1952
  this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
1909
1953
  });
1910
1954
  i(this, "userTransformInProgress", !1);
1911
- var g, f, v, y, p;
1912
- this.canvas = e, this.trigger = r, this.virtualScrollOptions = s, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new this.window.ResizeObserver((E) => {
1913
- const T = E[0];
1914
- this.viewportWidth = T.contentRect.width, this.viewportHeight = T.contentRect.height, this.scheduleLoadAreaAroundViewport();
1915
- }), this.viewport = e.viewport, this.element = e.element;
1916
- const d = ((g = o == null ? void 0 : o.events) == null ? void 0 : g.onResizeTransformStarted) ?? (() => {
1917
- }), n = ((f = o == null ? void 0 : o.events) == null ? void 0 : f.onResizeTransformFinished) ?? (() => {
1918
- }), h = ((v = o == null ? void 0 : o.events) == null ? void 0 : v.onTransformChange) ?? (() => {
1919
- }), c = ((y = o == null ? void 0 : o.events) == null ? void 0 : y.onBeforeTransformChange) ?? (() => {
1920
- }), a = ((p = o == null ? void 0 : o.events) == null ? void 0 : p.onTransformFinished) ?? (() => {
1921
- }), l = {
1922
- ...o,
1955
+ var v, f, p, A, b;
1956
+ 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((D) => {
1957
+ const m = D[0];
1958
+ this.viewportWidth = m.contentRect.width, this.viewportHeight = m.contentRect.height, this.scheduleLoadAreaAroundViewport();
1959
+ }), this.viewport = e.viewport;
1960
+ const d = ((v = s == null ? void 0 : s.events) == null ? void 0 : v.onResizeTransformStarted) ?? (() => {
1961
+ }), c = ((f = s == null ? void 0 : s.events) == null ? void 0 : f.onResizeTransformFinished) ?? (() => {
1962
+ }), a = ((p = s == null ? void 0 : s.events) == null ? void 0 : p.onTransformChange) ?? (() => {
1963
+ }), l = ((A = s == null ? void 0 : s.events) == null ? void 0 : A.onBeforeTransformChange) ?? (() => {
1964
+ }), g = ((b = s == null ? void 0 : s.events) == null ? void 0 : b.onTransformFinished) ?? (() => {
1965
+ }), y = {
1966
+ ...s,
1923
1967
  events: {
1924
- ...o == null ? void 0 : o.events,
1968
+ ...s == null ? void 0 : s.events,
1925
1969
  onResizeTransformStarted: () => {
1926
1970
  this.userTransformInProgress = !0, d();
1927
1971
  },
1928
1972
  onResizeTransformFinished: () => {
1929
- this.userTransformInProgress = !1, n();
1973
+ this.userTransformInProgress = !1, c();
1930
1974
  },
1931
1975
  onBeforeTransformChange: () => {
1932
- this.userTransformInProgress = !0, c();
1976
+ this.userTransformInProgress = !0, l();
1933
1977
  },
1934
1978
  onTransformChange: () => {
1935
1979
  this.userTransformInProgress = !1;
1936
- const E = this.viewportMatrix;
1937
- this.viewportMatrix = this.viewport.getViewportMatrix(), E.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), h();
1980
+ const D = this.viewportMatrix;
1981
+ this.viewportMatrix = this.viewport.getViewportMatrix(), D.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), a();
1938
1982
  },
1939
1983
  onTransformFinished: () => {
1940
- this.scheduleLoadAreaAroundViewport(), a();
1984
+ this.scheduleLoadAreaAroundViewport(), g();
1941
1985
  }
1942
1986
  }
1943
1987
  };
1944
- z.configure(
1988
+ k.configure(
1945
1989
  e,
1946
- l
1990
+ this.element,
1991
+ this.window,
1992
+ y
1947
1993
  ), 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);
1948
1994
  }
1949
- static configure(e, o, r, s) {
1950
- new K(
1995
+ static configure(e, o, r, s, h, n) {
1996
+ new Q(
1951
1997
  e,
1952
1998
  o,
1953
1999
  r,
1954
- s
2000
+ s,
2001
+ h,
2002
+ n
1955
2003
  );
1956
2004
  }
1957
2005
  scheduleLoadAreaAroundViewport() {
@@ -1960,25 +2008,329 @@ class K {
1960
2008
  });
1961
2009
  }
1962
2010
  scheduleEnsureViewportAreaLoaded() {
1963
- const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal, s = this.viewportMatrix.y - this.nodeVertical, d = this.viewportMatrix.x + e + this.nodeHorizontal, n = this.viewportMatrix.y + o + this.nodeVertical;
1964
- this.loadedArea.xFrom < r && this.loadedArea.xTo > d && this.loadedArea.yFrom < s && this.loadedArea.yTo > n || this.scheduleLoadAreaAroundViewport();
2011
+ 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;
2012
+ this.loadedArea.xFrom < r && this.loadedArea.xTo > h && this.loadedArea.yFrom < s && this.loadedArea.yTo > n || this.scheduleLoadAreaAroundViewport();
1965
2013
  }
1966
2014
  loadAreaAroundViewport() {
1967
- const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - e - this.nodeHorizontal, s = this.viewportMatrix.y - o - this.nodeVertical, d = 3 * e + 2 * this.nodeHorizontal, n = 3 * o + 2 * this.nodeVertical;
1968
- this.trigger.emit({ x: r, y: s, width: d, height: n });
2015
+ 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;
2016
+ this.trigger.emit({ x: r, y: s, width: h, height: n });
2017
+ }
2018
+ }
2019
+ const He = () => {
2020
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2021
+ return t.style.position = "absolute", t.style.inset = "0", t;
2022
+ }, je = () => {
2023
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2024
+ return t.setAttribute("fill", "url(#pattern)"), t;
2025
+ }, Ge = () => {
2026
+ const t = document.createElementNS(
2027
+ "http://www.w3.org/2000/svg",
2028
+ "pattern"
2029
+ );
2030
+ return t.setAttribute("id", "pattern"), t;
2031
+ }, Je = (t, e) => {
2032
+ const o = document.createElementNS(
2033
+ "http://www.w3.org/2000/svg",
2034
+ "circle"
2035
+ );
2036
+ return o.setAttribute("cx", "0"), o.setAttribute("cy", "0"), o.setAttribute("r", `${t}`), o.setAttribute("fill", `${e}`), o;
2037
+ }, Ke = (t) => t instanceof SVGElement ? t : Je(
2038
+ (t == null ? void 0 : t.radius) ?? 1.5,
2039
+ (t == null ? void 0 : t.color) ?? "#d8d8d8"
2040
+ ), Qe = (t) => {
2041
+ const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, r = (e == null ? void 0 : e.height) ?? 25, s = Ke(t.renderer ?? {});
2042
+ return {
2043
+ tileWidth: o,
2044
+ tileHeight: r,
2045
+ renderer: s,
2046
+ maxViewportScale: t.maxViewportScale ?? 10
2047
+ };
2048
+ };
2049
+ class Z {
2050
+ constructor(e, o, r) {
2051
+ i(this, "svg", He());
2052
+ i(this, "patternRenderingRectangle", je());
2053
+ i(this, "pattern", Ge());
2054
+ i(this, "patternContent");
2055
+ i(this, "tileWidth");
2056
+ i(this, "tileHeight");
2057
+ i(this, "halfTileWidth");
2058
+ i(this, "halfTileHeight");
2059
+ i(this, "maxViewportScale");
2060
+ i(this, "visible", !1);
2061
+ i(this, "resizeObserver", new ResizeObserver((e) => {
2062
+ const o = e[0], { width: r, height: s } = o.contentRect;
2063
+ this.svg.setAttribute("width", `${r}`), this.svg.setAttribute("height", `${s}`), this.patternRenderingRectangle.setAttribute("width", `${r}`), this.patternRenderingRectangle.setAttribute("height", `${s}`);
2064
+ const h = this.tileWidth / r, n = this.tileHeight / s;
2065
+ this.pattern.setAttribute("width", `${h}`), this.pattern.setAttribute("height", `${n}`);
2066
+ }));
2067
+ i(this, "onAfterTransformUpdated", () => {
2068
+ 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})`;
2069
+ this.pattern.setAttribute("patternTransform", s), this.updateVisibility();
2070
+ });
2071
+ i(this, "onBeforeDestroy", () => {
2072
+ this.resizeObserver.unobserve(this.host), this.host.removeChild(this.svg), this.canvas.viewport.onAfterUpdated.unsubscribe(
2073
+ this.onAfterTransformUpdated
2074
+ ), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
2075
+ });
2076
+ this.canvas = e, this.host = r;
2077
+ const s = Qe(o);
2078
+ 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;
2079
+ const h = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
2080
+ this.patternContent.setAttribute("transform", h), this.pattern.appendChild(this.patternContent);
2081
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
2082
+ 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);
2083
+ }
2084
+ static configure(e, o, r) {
2085
+ new Z(e, o, r);
2086
+ }
2087
+ updateVisibility() {
2088
+ const o = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
2089
+ o && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !o && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
1969
2090
  }
1970
2091
  }
1971
- class ze {
2092
+ const Ze = () => "direct", _e = (t) => t, qe = (t) => t.button === 0, Oe = () => {
2093
+ }, et = (t) => {
2094
+ var e;
2095
+ return {
2096
+ connectionTypeResolver: t.connectionTypeResolver ?? Ze,
2097
+ connectionPreprocessor: t.connectionPreprocessor ?? _e,
2098
+ mouseDownEventVerifier: t.mouseDownEventVerifier ?? qe,
2099
+ onAfterEdgeCreated: ((e = t.events) == null ? void 0 : e.onAfterEdgeCreated) ?? Oe
2100
+ };
2101
+ };
2102
+ class _ {
2103
+ constructor(e, o, r, s, h, n) {
2104
+ i(this, "options");
2105
+ i(this, "overlayCanvas");
2106
+ i(this, "ports", /* @__PURE__ */ new Map());
2107
+ i(this, "staticOverlayPortId", "static");
2108
+ i(this, "draggingOverlayPortId", "dragging");
2109
+ i(this, "staticPortId", null);
2110
+ i(this, "isDirect", !0);
2111
+ i(this, "onAfterPortMarked", (e) => {
2112
+ const o = this.canvas.graph.getPort(e);
2113
+ this.hookPortEvents(o.element), this.ports.set(o.element, e);
2114
+ });
2115
+ i(this, "onBeforePortUnmarked", (e) => {
2116
+ const o = this.canvas.graph.getPort(e);
2117
+ this.unhookPortEvents(o.element), this.ports.delete(o.element);
2118
+ });
2119
+ i(this, "onPortMouseDown", (e) => {
2120
+ const o = e.currentTarget;
2121
+ this.options.mouseDownEventVerifier(e) && this.isPortConnectionAllowed(o) && (e.stopPropagation(), this.grabPort(o, { x: e.clientX, y: e.clientY }), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp));
2122
+ });
2123
+ i(this, "onWindowMouseMove", (e) => {
2124
+ if (!V(
2125
+ this.window,
2126
+ this.overlayLayer,
2127
+ e.clientX,
2128
+ e.clientY
2129
+ )) {
2130
+ this.stopMouseDrag();
2131
+ return;
2132
+ }
2133
+ this.moveDraggingNode({ x: e.clientX, y: e.clientY });
2134
+ });
2135
+ i(this, "onWindowMouseUp", (e) => {
2136
+ this.tryCreateConnection({ x: e.clientX, y: e.clientY }), this.stopMouseDrag();
2137
+ });
2138
+ i(this, "onPortTouchStart", (e) => {
2139
+ const o = e.currentTarget;
2140
+ if (!(e.touches.length === 1 && this.isPortConnectionAllowed(o)))
2141
+ return;
2142
+ e.stopPropagation();
2143
+ const s = e.touches[0];
2144
+ this.grabPort(o, { x: s.clientX, y: s.clientY }), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
2145
+ });
2146
+ i(this, "onWindowTouchMove", (e) => {
2147
+ const o = e.touches[0];
2148
+ if (!V(
2149
+ this.window,
2150
+ this.overlayLayer,
2151
+ o.clientX,
2152
+ o.clientY
2153
+ )) {
2154
+ this.stopTouchDrag();
2155
+ return;
2156
+ }
2157
+ this.moveDraggingNode({ x: o.clientX, y: o.clientY });
2158
+ });
2159
+ i(this, "onWindowTouchFinish", (e) => {
2160
+ const o = e.changedTouches[0];
2161
+ this.tryCreateConnection({ x: o.clientX, y: o.clientY }), this.stopTouchDrag();
2162
+ });
2163
+ i(this, "onBeforeClear", () => {
2164
+ this.ports.forEach((e, o) => {
2165
+ this.unhookPortEvents(o);
2166
+ }), this.ports.clear();
2167
+ });
2168
+ i(this, "onBeforeDestroy", () => {
2169
+ this.stopMouseDrag(), this.stopTouchDrag(), this.canvas.graph.onAfterPortMarked.unsubscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.unsubscribe(
2170
+ this.onBeforePortUnmarked
2171
+ ), this.canvas.graph.onBeforeClear.unsubscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
2172
+ });
2173
+ i(this, "onEdgeCreated", (e) => {
2174
+ this.options.onAfterEdgeCreated(e);
2175
+ });
2176
+ this.canvas = e, this.overlayLayer = o, this.viewportStore = r, this.window = s, this.options = et(n);
2177
+ const d = new ce(), c = new ne(
2178
+ d,
2179
+ this.viewportStore,
2180
+ this.overlayLayer
2181
+ );
2182
+ this.overlayCanvas = new de(
2183
+ this.overlayLayer,
2184
+ d,
2185
+ this.viewportStore,
2186
+ c,
2187
+ h
2188
+ ), 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);
2189
+ }
2190
+ static configure(e, o, r, s, h, n) {
2191
+ new _(
2192
+ e,
2193
+ o,
2194
+ r,
2195
+ s,
2196
+ h,
2197
+ n
2198
+ );
2199
+ }
2200
+ grabPort(e, o) {
2201
+ const r = this.ports.get(e), s = this.canvas.graph.getPort(r);
2202
+ this.staticPortId = r;
2203
+ const h = this.options.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 = C(l, {
2204
+ x: d - a.x,
2205
+ y: c - a.y
2206
+ }), y = C(l, {
2207
+ x: o.x - a.x,
2208
+ y: o.y - a.y
2209
+ }), v = {
2210
+ overlayId: this.staticOverlayPortId,
2211
+ portCoords: g,
2212
+ portDirection: s.direction
2213
+ }, f = {
2214
+ overlayId: this.draggingOverlayPortId,
2215
+ portCoords: y,
2216
+ portDirection: void 0
2217
+ };
2218
+ this.isDirect = h === "direct";
2219
+ const p = this.isDirect ? v : f, A = this.isDirect ? f : v;
2220
+ this.createOverlayGraph(p, A);
2221
+ }
2222
+ hookPortEvents(e) {
2223
+ e.addEventListener("mousedown", this.onPortMouseDown), e.addEventListener("touchstart", this.onPortTouchStart);
2224
+ }
2225
+ unhookPortEvents(e) {
2226
+ e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
2227
+ }
2228
+ stopMouseDrag() {
2229
+ this.resetDragState(), this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
2230
+ }
2231
+ stopTouchDrag() {
2232
+ this.resetDragState(), this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
2233
+ }
2234
+ resetDragState() {
2235
+ this.staticPortId = null, this.isDirect = !0, this.overlayCanvas.clear();
2236
+ }
2237
+ createOverlayGraph(e, o) {
2238
+ const r = this.createAddNodeRequest(e);
2239
+ this.overlayCanvas.addNode(r);
2240
+ const s = this.createAddNodeRequest(o);
2241
+ this.overlayCanvas.addNode(s), this.overlayCanvas.addEdge({
2242
+ from: e.overlayId,
2243
+ to: o.overlayId
2244
+ });
2245
+ }
2246
+ createAddNodeRequest(e) {
2247
+ const o = document.createElement("div");
2248
+ return {
2249
+ id: e.overlayId,
2250
+ element: o,
2251
+ x: e.portCoords.x,
2252
+ y: e.portCoords.y,
2253
+ ports: [
2254
+ {
2255
+ id: e.overlayId,
2256
+ element: o,
2257
+ direction: e.portDirection
2258
+ }
2259
+ ]
2260
+ };
2261
+ }
2262
+ tryCreateConnection(e) {
2263
+ const o = this.findPortAtPoint(e);
2264
+ if (o === null)
2265
+ return;
2266
+ const r = this.isDirect ? this.staticPortId : o, s = this.isDirect ? o : this.staticPortId, h = { from: r, to: s }, n = this.options.connectionPreprocessor(h);
2267
+ n !== null && (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(n), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated));
2268
+ }
2269
+ moveDraggingNode(e) {
2270
+ const o = this.overlayLayer.getBoundingClientRect(), r = {
2271
+ x: e.x - o.x,
2272
+ y: e.y - o.y
2273
+ }, s = this.canvas.viewport.getViewportMatrix(), h = C(s, r);
2274
+ this.overlayCanvas.updateNode(this.draggingOverlayPortId, {
2275
+ x: h.x,
2276
+ y: h.y
2277
+ });
2278
+ }
2279
+ findPortAtPoint(e) {
2280
+ const o = document.elementsFromPoint(e.x, e.y);
2281
+ for (const r of o) {
2282
+ const s = this.findPortAtElement(r);
2283
+ if (s !== null)
2284
+ return s;
2285
+ }
2286
+ return null;
2287
+ }
2288
+ findPortAtElement(e) {
2289
+ let o = e, r = null;
2290
+ for (; o !== null && (r = this.ports.get(o) ?? null, r === null); )
2291
+ o = o.parentElement;
2292
+ return r;
2293
+ }
2294
+ isPortConnectionAllowed(e) {
2295
+ const o = this.ports.get(e);
2296
+ return this.options.connectionTypeResolver(o) !== null;
2297
+ }
2298
+ }
2299
+ const tt = () => {
2300
+ const t = document.createElement("div");
2301
+ return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t;
2302
+ }, X = () => {
2303
+ const t = document.createElement("div");
2304
+ return t.style.position = "absolute", t.style.inset = "0", t;
2305
+ };
2306
+ class ot {
2307
+ constructor(e) {
2308
+ i(this, "background", X());
2309
+ i(this, "main", X());
2310
+ i(this, "overlay", X());
2311
+ i(this, "host", tt());
2312
+ 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);
2313
+ }
2314
+ destroy() {
2315
+ this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlay), this.element.removeChild(this.host);
2316
+ }
2317
+ }
2318
+ class it {
1972
2319
  constructor() {
1973
2320
  i(this, "element", null);
1974
2321
  i(this, "canvasDefaults", {});
1975
2322
  i(this, "dragOptions", {});
1976
2323
  i(this, "transformOptions", {});
2324
+ i(this, "backgroundOptions", {});
2325
+ i(this, "connectablePortsOptions", {});
1977
2326
  i(this, "virtualScrollOptions");
1978
2327
  i(this, "hasDraggableNode", !1);
1979
2328
  i(this, "hasTransformableViewport", !1);
1980
2329
  i(this, "hasResizeReactiveNodes", !1);
2330
+ i(this, "hasBackground", !1);
2331
+ i(this, "hasUserConnectablePorts", !1);
1981
2332
  i(this, "boxRenderingTrigger");
2333
+ i(this, "window", window);
1982
2334
  }
1983
2335
  setElement(e) {
1984
2336
  return this.element = e, this;
@@ -2013,9 +2365,25 @@ class ze {
2013
2365
  enableBoxAreaRendering(e) {
2014
2366
  return this.boxRenderingTrigger = e, this;
2015
2367
  }
2368
+ /**
2369
+ * enables built-in virtual scroll behavior, when only nodes and edges close
2370
+ * to viewport are rendered
2371
+ */
2016
2372
  enableVirtualScroll(e) {
2017
2373
  return this.virtualScrollOptions = e, this;
2018
2374
  }
2375
+ /**
2376
+ * enables built-in background rendering
2377
+ */
2378
+ enableBackground(e) {
2379
+ return this.hasBackground = !0, this.backgroundOptions = e ?? {}, this;
2380
+ }
2381
+ /**
2382
+ * enables edge creation by dragging one port to another
2383
+ */
2384
+ enableUserConnectablePorts(e) {
2385
+ return this.connectablePortsOptions = e ?? {}, this.hasUserConnectablePorts = !0, this;
2386
+ }
2019
2387
  /**
2020
2388
  * builds final canvas
2021
2389
  */
@@ -2025,41 +2393,67 @@ class ze {
2025
2393
  "unable to build canvas when no attach element specified"
2026
2394
  );
2027
2395
  let e = this.boxRenderingTrigger;
2028
- this.virtualScrollOptions !== void 0 && e === void 0 && (e = new re());
2029
- const o = new Ve(), r = new Le();
2030
- let s = new ce(
2396
+ this.virtualScrollOptions !== void 0 && e === void 0 && (e = new he());
2397
+ const o = new ce(), r = new Ie(), s = new ot(this.element);
2398
+ let h = new ne(
2031
2399
  o,
2032
2400
  r,
2033
- this.element
2401
+ s.main
2034
2402
  );
2035
- e !== void 0 && (s = new le(s, o, e));
2036
- const d = new Me(
2403
+ e !== void 0 && (h = new ye(h, o, e));
2404
+ const n = new de(
2037
2405
  this.element,
2038
2406
  o,
2039
2407
  r,
2040
- s,
2408
+ h,
2041
2409
  this.canvasDefaults
2042
- );
2043
- return this.hasResizeReactiveNodes && G.configure(d), this.hasDraggableNode && J.configure(d, this.dragOptions), this.virtualScrollOptions !== void 0 ? K.configure(
2044
- d,
2410
+ ), d = () => {
2411
+ s.destroy(), n.onBeforeDestroy.unsubscribe(d);
2412
+ };
2413
+ return n.onBeforeDestroy.subscribe(d), this.hasBackground && Z.configure(
2414
+ n,
2415
+ this.backgroundOptions,
2416
+ s.background
2417
+ ), this.hasResizeReactiveNodes && J.configure(n), this.hasDraggableNode && K.configure(
2418
+ n,
2419
+ s.main,
2420
+ this.window,
2421
+ this.dragOptions
2422
+ ), this.hasUserConnectablePorts && _.configure(
2423
+ n,
2424
+ s.overlay,
2425
+ r,
2426
+ this.window,
2427
+ this.canvasDefaults,
2428
+ this.connectablePortsOptions
2429
+ ), this.virtualScrollOptions !== void 0 ? Q.configure(
2430
+ n,
2431
+ s.main,
2432
+ this.window,
2045
2433
  this.transformOptions,
2046
2434
  e,
2047
2435
  this.virtualScrollOptions
2048
- ) : this.hasTransformableViewport && z.configure(
2049
- d,
2436
+ ) : this.hasTransformableViewport && k.configure(
2437
+ n,
2438
+ s.main,
2439
+ this.window,
2050
2440
  this.transformOptions
2051
- ), this.reset(), d;
2441
+ ), this.reset(), n;
2052
2442
  }
2443
+ /**
2444
+ * @deprecated
2445
+ * CanvasBuilder should be single use object
2446
+ */
2053
2447
  reset() {
2054
- this.element = null, this.canvasDefaults = {}, this.dragOptions = {}, this.transformOptions = {}, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.boxRenderingTrigger = void 0;
2448
+ this.element = null, this.canvasDefaults = {}, this.dragOptions = {}, this.transformOptions = {}, this.backgroundOptions = {}, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.hasBackground = !1, this.boxRenderingTrigger = void 0, this.hasUserConnectablePorts = !1;
2055
2449
  }
2056
2450
  }
2057
2451
  export {
2058
- Te as BezierEdgeShape,
2059
- ze as CanvasBuilder,
2060
- re as EventSubject,
2061
- be as HorizontalEdgeShape,
2452
+ De as BezierEdgeShape,
2453
+ it as CanvasBuilder,
2454
+ he as EventSubject,
2455
+ Me as HorizontalEdgeShape,
2062
2456
  S as HtmlGraphError,
2063
- Ne as StraightEdgeShape,
2064
- me as VerticalEdgeShape
2457
+ Ce as StraightEdgeShape,
2458
+ Ve as VerticalEdgeShape
2065
2459
  };