@html-graph/html-graph 1.1.1 → 1.2.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.
package/dist/main.js CHANGED
@@ -1,13 +1,13 @@
1
1
  var de = Object.defineProperty;
2
2
  var ce = (t, e, r) => e in t ? de(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var i = (t, e, r) => ce(t, typeof e != "symbol" ? e + "" : e, r);
4
- const Z = (t, e) => ({
4
+ const q = (t, e) => ({
5
5
  x: t / 2,
6
6
  y: e / 2
7
7
  }), v = (t, e, r) => ({
8
8
  x: e.x * t.x - e.y * t.y + ((1 - e.x) * r.x + e.y * r.y),
9
9
  y: e.y * t.x + e.x * t.y + ((1 - e.x) * r.y - e.y * r.x)
10
- }), N = (t, e, r) => ({ x: e * Math.cos(t), y: r * Math.sin(t) }), w = {
10
+ }), p = (t, e, r) => ({ x: e * Math.cos(t), y: r * Math.sin(t) }), w = {
11
11
  x: 0,
12
12
  y: 0
13
13
  }, T = (t, e, r, o) => {
@@ -15,23 +15,23 @@ const Z = (t, e) => ({
15
15
  w,
16
16
  { x: r, y: o },
17
17
  { x: r, y: -o }
18
- ].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), s = `M ${d[0].x} ${d[0].y}`, h = `L ${d[1].x} ${d[1].y}`, c = `L ${d[2].x} ${d[2].y}`;
19
- return `${s} ${h} ${c}`;
20
- }, $ = (t, e) => {
18
+ ].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${d[0].x} ${d[0].y}`, h = `L ${d[1].x} ${d[1].y}`, c = `L ${d[2].x} ${d[2].y}`;
19
+ return `${n} ${h} ${c}`;
20
+ }, U = (t, e) => {
21
21
  const r = [];
22
22
  if (t.length > 0 && r.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && r.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
23
23
  const o = t.length - 1;
24
- let n = 0, d = 0, s = 0;
24
+ let s = 0, d = 0, n = 0;
25
25
  t.forEach((h, c) => {
26
- let a = 0, l = 0, u = 0;
27
- const f = c > 0, A = c < o, y = f && A;
28
- if (f && (a = -n, l = -d, u = s), A) {
29
- const L = t[c + 1];
30
- n = L.x - h.x, d = L.y - h.y, s = Math.sqrt(n * n + d * d);
26
+ let a = 0, l = 0, g = 0;
27
+ const f = c > 0, x = c < o, y = f && x;
28
+ if (f && (a = -s, l = -d, g = n), x) {
29
+ const D = t[c + 1];
30
+ s = D.x - h.x, d = D.y - h.y, n = Math.sqrt(s * s + d * d);
31
31
  }
32
- const E = s !== 0 ? Math.min((y ? e : 0) / s, c < o - 1 ? 0.5 : 1) : 0, C = y ? { x: h.x + n * E, y: h.y + d * E } : h, P = u !== 0 ? Math.min((y ? e : 0) / u, c > 1 ? 0.5 : 1) : 0, D = y ? { x: h.x + a * P, y: h.y + l * P } : h;
33
- c > 0 && r.push(`L ${D.x} ${D.y}`), y && r.push(
34
- `C ${h.x} ${h.y} ${h.x} ${h.y} ${C.x} ${C.y}`
32
+ const E = n !== 0 ? Math.min((y ? e : 0) / n, c < o - 1 ? 0.5 : 1) : 0, N = y ? { x: h.x + s * E, y: h.y + d * E } : h, M = g !== 0 ? Math.min((y ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, V = y ? { x: h.x + a * M, y: h.y + l * M } : h;
33
+ c > 0 && r.push(`L ${V.x} ${V.y}`), y && r.push(
34
+ `C ${h.x} ${h.y} ${h.x} ${h.y} ${N.x} ${N.y}`
35
35
  );
36
36
  });
37
37
  }
@@ -45,7 +45,7 @@ const Z = (t, e) => ({
45
45
  }, Y = (t, e) => {
46
46
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
47
47
  return r.setAttribute("stroke", t), r.setAttribute("stroke-width", `${e}`), r.setAttribute("fill", "none"), r;
48
- }, p = (t) => {
48
+ }, b = (t) => {
49
49
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
50
50
  return e.setAttribute("fill", t), e;
51
51
  }, X = (t, e) => {
@@ -55,11 +55,11 @@ const Z = (t, e) => ({
55
55
  }, o = {
56
56
  x: e.x + e.width / 2,
57
57
  y: e.y + e.height / 2
58
- }, n = Math.min(r.x, o.x), d = Math.min(r.y, o.y), s = Math.abs(o.x - r.x), h = Math.abs(o.y - r.y), c = r.x <= o.x ? 1 : -1, a = r.y <= o.y ? 1 : -1;
58
+ }, s = Math.min(r.x, o.x), d = Math.min(r.y, o.y), n = Math.abs(o.x - r.x), h = Math.abs(o.y - r.y), c = r.x <= o.x ? 1 : -1, a = r.y <= o.y ? 1 : -1;
59
59
  return {
60
- x: n,
60
+ x: s,
61
61
  y: d,
62
- width: s,
62
+ width: n,
63
63
  height: h,
64
64
  flipX: c,
65
65
  flipY: a
@@ -76,11 +76,11 @@ const Z = (t, e) => ({
76
76
  ), o = {
77
77
  x: e.x + t.fromVect.x * t.curvature,
78
78
  y: e.y + t.fromVect.y * t.curvature
79
- }, n = {
79
+ }, s = {
80
80
  x: r.x - t.toVect.x * t.curvature,
81
81
  y: r.y - t.toVect.y * t.curvature
82
- }, d = `M ${e.x} ${e.y} C ${o.x} ${o.y}, ${n.x} ${n.y}, ${r.x} ${r.y}`, s = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, h = t.hasTargetArrow ? "" : ` M ${r.x} ${r.y} L ${t.to.x} ${t.to.y}`;
83
- return `${s}${d}${h}`;
82
+ }, d = `M ${e.x} ${e.y} C ${o.x} ${o.y}, ${s.x} ${s.y}, ${r.x} ${r.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, h = t.hasTargetArrow ? "" : ` M ${r.x} ${r.y} L ${t.to.x} ${t.to.y}`;
83
+ return `${n}${d}${h}`;
84
84
  }, le = (t) => {
85
85
  const e = t.hasSourceArrow ? v(
86
86
  { x: t.arrowLength, y: w.y },
@@ -90,41 +90,41 @@ const Z = (t, e) => ({
90
90
  { x: t.to.x - t.arrowLength, y: t.to.y },
91
91
  t.toVect,
92
92
  t.to
93
- ) : t.to, o = t.arrowLength, n = Math.cos(t.detourDirection) * t.detourDistance, d = Math.sin(t.detourDirection) * t.detourDistance, s = n * t.flipX, h = d * t.flipY, c = v(
93
+ ) : t.to, o = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, d = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, h = d * t.flipY, c = v(
94
94
  { x: o, y: w.y },
95
95
  t.fromVect,
96
96
  w
97
97
  ), a = {
98
- x: c.x + s,
98
+ x: c.x + n,
99
99
  y: c.y + h
100
100
  }, l = v(
101
101
  { x: t.to.x - o, y: t.to.y },
102
102
  t.toVect,
103
103
  t.to
104
- ), u = {
105
- x: l.x + s,
104
+ ), g = {
105
+ x: l.x + n,
106
106
  y: l.y + h
107
- }, f = { x: (a.x + u.x) / 2, y: (a.y + u.y) / 2 }, A = {
107
+ }, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, x = {
108
108
  x: c.x + t.curvature * t.fromVect.x,
109
109
  y: c.y + t.curvature * t.fromVect.y
110
110
  }, y = {
111
111
  x: l.x - t.curvature * t.toVect.x,
112
112
  y: l.y - t.curvature * t.toVect.y
113
113
  }, m = {
114
- x: c.x + s,
114
+ x: c.x + n,
115
115
  y: c.y + h
116
116
  }, E = {
117
- x: l.x + s,
117
+ x: l.x + n,
118
118
  y: l.y + h
119
119
  };
120
120
  return [
121
121
  `M ${e.x} ${e.y}`,
122
122
  `L ${c.x} ${c.y}`,
123
- `C ${A.x} ${A.y} ${m.x} ${m.y} ${f.x} ${f.y}`,
123
+ `C ${x.x} ${x.y} ${m.x} ${m.y} ${f.x} ${f.y}`,
124
124
  `C ${E.x} ${E.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
125
125
  `L ${r.x} ${r.y}`
126
126
  ].join(" ");
127
- }, ue = (t) => {
127
+ }, ge = (t) => {
128
128
  const e = t.hasSourceArrow ? v(
129
129
  { x: t.arrowLength, y: w.y },
130
130
  t.fromVect,
@@ -133,16 +133,16 @@ const Z = (t, e) => ({
133
133
  { x: t.to.x - t.arrowLength, y: t.to.y },
134
134
  t.toVect,
135
135
  t.to
136
- ) : t.to, o = t.arrowLength + t.arrowOffset, n = o - t.roundness, d = v({ x: n, y: w.y }, t.fromVect, w), s = v(
137
- { x: t.to.x - n, y: t.to.y },
136
+ ) : t.to, o = t.arrowLength + t.arrowOffset, s = o - t.roundness, d = v({ x: s, y: w.y }, t.fromVect, w), n = v(
137
+ { x: t.to.x - s, y: t.to.y },
138
138
  t.toVect,
139
139
  t.to
140
- ), h = Math.max((d.x + s.x) / 2, o), c = t.to.y / 2, a = { x: t.flipX > 0 ? h : -o, y: d.y }, l = { x: a.x, y: c }, u = {
140
+ ), h = Math.max((d.x + n.x) / 2, o), c = t.to.y / 2, a = { x: t.flipX > 0 ? h : -o, y: d.y }, l = { x: a.x, y: c }, g = {
141
141
  x: t.flipX > 0 ? t.to.x - h : t.to.x + o,
142
- y: s.y
143
- }, f = { x: u.x, y: c };
144
- return $(
145
- [e, d, a, l, f, u, s, r],
142
+ y: n.y
143
+ }, f = { x: g.x, y: c };
144
+ return U(
145
+ [e, d, a, l, f, g, n, r],
146
146
  t.roundness
147
147
  );
148
148
  }, j = (t) => {
@@ -154,20 +154,20 @@ const Z = (t, e) => ({
154
154
  { x: t.to.x - t.arrowLength, y: t.to.y },
155
155
  t.toVect,
156
156
  t.to
157
- ) : t.to, o = t.arrowLength + t.arrowOffset, n = v(
157
+ ) : t.to, o = t.arrowLength + t.arrowOffset, s = v(
158
158
  { x: o, y: w.y },
159
159
  t.fromVect,
160
160
  w
161
- ), d = Math.cos(t.detourDirection) * t.detourDistance, s = Math.sin(t.detourDirection) * t.detourDistance, h = d * t.flipX, c = s * t.flipY, a = { x: n.x + h, y: n.y + c }, l = v(
161
+ ), d = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, h = d * t.flipX, c = n * t.flipY, a = { x: s.x + h, y: s.y + c }, l = v(
162
162
  { x: t.to.x - o, y: t.to.y },
163
163
  t.toVect,
164
164
  t.to
165
- ), u = { x: l.x + h, y: l.y + c };
166
- return $(
167
- [e, n, a, u, l, r],
165
+ ), g = { x: l.x + h, y: l.y + c };
166
+ return U(
167
+ [e, s, a, g, l, r],
168
168
  t.roundness
169
169
  );
170
- }, ge = (t) => {
170
+ }, ue = (t) => {
171
171
  const e = t.hasSourceArrow ? v(
172
172
  { x: t.arrowLength, y: w.y },
173
173
  t.fromVect,
@@ -176,12 +176,12 @@ const Z = (t, e) => ({
176
176
  { x: t.to.x - t.arrowLength, y: t.to.y },
177
177
  t.toVect,
178
178
  t.to
179
- ) : t.to, o = t.arrowLength + t.arrowOffset, n = v({ x: o, y: w.y }, t.fromVect, w), d = v(
179
+ ) : t.to, o = t.arrowLength + t.arrowOffset, s = v({ x: o, y: w.y }, t.fromVect, w), d = v(
180
180
  { x: t.to.x - o, y: t.to.y },
181
181
  t.toVect,
182
182
  t.to
183
183
  );
184
- return $([e, n, d, r], t.roundness);
184
+ return U([e, s, d, r], t.roundness);
185
185
  }, we = (t) => {
186
186
  const e = t.hasSourceArrow ? v(
187
187
  { x: t.arrowLength, y: w.y },
@@ -191,45 +191,45 @@ const Z = (t, e) => ({
191
191
  { x: t.to.x - t.arrowLength, y: t.to.y },
192
192
  t.toVect,
193
193
  t.to
194
- ) : t.to, o = t.arrowLength + t.arrowOffset, n = o - t.roundness, d = v({ x: n, y: w.y }, t.fromVect, w), s = v(
195
- { x: t.to.x - n, y: t.to.y },
194
+ ) : t.to, o = t.arrowLength + t.arrowOffset, s = o - t.roundness, d = v({ x: s, y: w.y }, t.fromVect, w), n = v(
195
+ { x: t.to.x - s, y: t.to.y },
196
196
  t.toVect,
197
197
  t.to
198
- ), h = Math.max((d.y + s.y) / 2, o), c = t.to.x / 2, a = { x: d.x, y: t.flipY > 0 ? h : -o }, l = { x: c, y: a.y }, u = {
199
- x: s.x,
198
+ ), h = Math.max((d.y + n.y) / 2, o), c = t.to.x / 2, a = { x: d.x, y: t.flipY > 0 ? h : -o }, l = { x: c, y: a.y }, g = {
199
+ x: n.x,
200
200
  y: t.flipY > 0 ? t.to.y - h : t.to.y + o
201
- }, f = { x: c, y: u.y };
202
- return $(
203
- [e, d, a, l, f, u, s, r],
201
+ }, f = { x: c, y: g.y };
202
+ return U(
203
+ [e, d, a, l, f, g, n, r],
204
204
  t.roundness
205
205
  );
206
206
  }, H = (t) => {
207
- const e = t.arrowOffset, r = t.side, o = t.arrowLength + e, n = o + 2 * r, s = [
207
+ const e = t.arrowOffset, r = t.side, o = t.arrowLength + e, s = o + 2 * r, n = [
208
208
  { x: t.arrowLength, y: w.y },
209
209
  { x: o, y: w.y },
210
210
  { x: o, y: t.side },
211
- { x: n, y: t.side },
212
- { x: n, y: -t.side },
211
+ { x: s, y: t.side },
212
+ { x: s, y: -t.side },
213
213
  { x: o, y: -t.side },
214
214
  { x: o, y: w.y },
215
215
  { x: t.arrowLength, y: w.y }
216
216
  ].map(
217
217
  (c) => v(c, t.fromVect, w)
218
- ), h = `M ${w.x} ${w.y} L ${s[0].x} ${s[0].y} `;
219
- return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${$(s, t.roundness)}`;
218
+ ), h = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
219
+ return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${U(n, t.roundness)}`;
220
220
  }, fe = (t) => {
221
- const e = t.smallRadius, r = t.radius, o = Math.sqrt(e * e + r * r), n = e + r, d = t.arrowLength + o * (1 - r / n), s = e * r / n, c = [
221
+ const e = t.smallRadius, r = t.radius, o = Math.sqrt(e * e + r * r), s = e + r, d = t.arrowLength + o * (1 - r / s), n = e * r / s, c = [
222
222
  { x: t.arrowLength, y: w.y },
223
- { x: d, y: s },
224
- { x: d, y: -s }
225
- ].map((u) => v(u, t.fromVect, w)), a = [
223
+ { x: d, y: n },
224
+ { x: d, y: -n }
225
+ ].map((g) => v(g, t.fromVect, w)), a = [
226
226
  `M ${c[0].x} ${c[0].y}`,
227
227
  `A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
228
228
  `A ${r} ${r} 0 1 0 ${c[2].x} ${c[2].y}`,
229
229
  `A ${e} ${e} 0 0 1 ${c[0].x} ${c[0].y}`
230
230
  ].join(" "), l = `M 0 0 L ${c[0].x} ${c[0].y} `;
231
231
  return `${t.hasSourceArrow || t.hasTargetArrow ? "" : l}${a}`;
232
- }, g = Object.freeze({
232
+ }, u = Object.freeze({
233
233
  color: "#777777",
234
234
  width: 1,
235
235
  arrowLength: 15,
@@ -246,7 +246,7 @@ const Z = (t, e) => ({
246
246
  smallCycleRadius: 15,
247
247
  curvature: 90
248
248
  });
249
- class q {
249
+ class O {
250
250
  constructor(e) {
251
251
  i(this, "svg", B());
252
252
  i(this, "group", k());
@@ -262,37 +262,37 @@ class q {
262
262
  i(this, "detourDistance");
263
263
  i(this, "hasSourceArrow");
264
264
  i(this, "hasTargetArrow");
265
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? g.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? g.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? g.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? g.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? g.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? g.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? g.hasTargetArrow;
266
- const r = (e == null ? void 0 : e.color) ?? g.color, o = (e == null ? void 0 : e.width) ?? g.width;
267
- this.svg.appendChild(this.group), this.line = Y(r, o), 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));
265
+ 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;
266
+ const r = (e == null ? void 0 : e.color) ?? u.color, o = (e == null ? void 0 : e.width) ?? u.width;
267
+ this.svg.appendChild(this.group), this.line = Y(r, o), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(r), this.group.appendChild(this.targetArrow));
268
268
  }
269
269
  render(e) {
270
- const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = X(
270
+ const { x: r, y: o, width: s, height: d, flipX: n, flipY: h } = X(
271
271
  e.from,
272
272
  e.to
273
273
  );
274
- this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
275
- const c = N(
274
+ this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
275
+ const c = p(
276
276
  e.from.direction,
277
- s,
277
+ n,
278
278
  h
279
- ), a = N(e.to.direction, s, h), l = {
280
- x: n,
279
+ ), a = p(e.to.direction, n, h), l = {
280
+ x: s,
281
281
  y: d
282
282
  };
283
- let u, f = a, A = -this.arrowLength;
284
- if (e.from.portId === e.to.portId ? (u = fe({
283
+ let g, f = a, x = -this.arrowLength;
284
+ if (e.from.portId === e.to.portId ? (g = fe({
285
285
  fromVect: c,
286
286
  radius: this.portCycleRadius,
287
287
  smallRadius: this.portCycleSmallRadius,
288
288
  arrowLength: this.arrowLength,
289
289
  hasSourceArrow: this.hasSourceArrow,
290
290
  hasTargetArrow: this.hasTargetArrow
291
- }), f = c, A = this.arrowLength) : e.from.nodeId === e.to.nodeId ? u = le({
291
+ }), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = le({
292
292
  to: l,
293
293
  fromVect: c,
294
294
  toVect: a,
295
- flipX: s,
295
+ flipX: n,
296
296
  flipY: h,
297
297
  arrowLength: this.arrowLength,
298
298
  detourDirection: this.detourDirection,
@@ -300,7 +300,7 @@ class q {
300
300
  curvature: this.curvature,
301
301
  hasSourceArrow: this.hasSourceArrow,
302
302
  hasTargetArrow: this.hasTargetArrow
303
- }) : u = ae({
303
+ }) : g = ae({
304
304
  to: l,
305
305
  fromVect: c,
306
306
  toVect: a,
@@ -308,7 +308,7 @@ class q {
308
308
  curvature: this.curvature,
309
309
  hasSourceArrow: this.hasSourceArrow,
310
310
  hasTargetArrow: this.hasTargetArrow
311
- }), this.line.setAttribute("d", u), this.sourceArrow) {
311
+ }), this.line.setAttribute("d", g), this.sourceArrow) {
312
312
  const y = T(
313
313
  c,
314
314
  w,
@@ -321,14 +321,14 @@ class q {
321
321
  const y = T(
322
322
  f,
323
323
  l,
324
- A,
324
+ x,
325
325
  this.arrowWidth
326
326
  );
327
327
  this.targetArrow.setAttribute("d", y);
328
328
  }
329
329
  }
330
330
  }
331
- class O {
331
+ class ee {
332
332
  constructor(e) {
333
333
  i(this, "svg", B());
334
334
  i(this, "group", k());
@@ -344,32 +344,32 @@ class O {
344
344
  i(this, "detourDistance");
345
345
  i(this, "hasSourceArrow");
346
346
  i(this, "hasTargetArrow");
347
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? g.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? g.cycleSquareSide;
348
- const r = (e == null ? void 0 : e.roundness) ?? g.roundness;
347
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
348
+ const r = (e == null ? void 0 : e.roundness) ?? u.roundness;
349
349
  this.roundness = Math.min(
350
350
  r,
351
351
  this.arrowOffset,
352
352
  this.cycleSquareSide / 2
353
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? g.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? g.hasTargetArrow;
354
- const o = (e == null ? void 0 : e.color) ?? g.color, n = (e == null ? void 0 : e.width) ?? g.width;
355
- this.svg.appendChild(this.group), this.line = Y(o, n), 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));
353
+ ), 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;
354
+ const o = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
355
+ this.svg.appendChild(this.group), this.line = Y(o, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(o), this.group.appendChild(this.targetArrow));
356
356
  }
357
357
  render(e) {
358
- const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = X(
358
+ const { x: r, y: o, width: s, height: d, flipX: n, flipY: h } = X(
359
359
  e.from,
360
360
  e.to
361
361
  );
362
- this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
363
- const c = N(
362
+ this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
363
+ const c = p(
364
364
  e.from.direction,
365
- s,
365
+ n,
366
366
  h
367
- ), a = N(e.to.direction, s, h), l = {
368
- x: n,
367
+ ), a = p(e.to.direction, n, h), l = {
368
+ x: s,
369
369
  y: d
370
370
  };
371
- let u, f = a, A = -this.arrowLength;
372
- if (e.from.portId === e.to.portId ? (u = H({
371
+ let g, f = a, x = -this.arrowLength;
372
+ if (e.from.portId === e.to.portId ? (g = H({
373
373
  fromVect: c,
374
374
  arrowLength: this.arrowLength,
375
375
  side: this.cycleSquareSide,
@@ -377,11 +377,11 @@ class O {
377
377
  roundness: this.roundness,
378
378
  hasSourceArrow: this.hasSourceArrow,
379
379
  hasTargetArrow: this.hasTargetArrow
380
- }), f = c, A = this.arrowLength) : e.from.nodeId === e.to.nodeId ? u = j({
380
+ }), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
381
381
  to: l,
382
382
  fromVect: c,
383
383
  toVect: a,
384
- flipX: s,
384
+ flipX: n,
385
385
  flipY: h,
386
386
  arrowLength: this.arrowLength,
387
387
  arrowOffset: this.arrowOffset,
@@ -390,17 +390,17 @@ class O {
390
390
  detourDistance: this.detourDistance,
391
391
  hasSourceArrow: this.hasSourceArrow,
392
392
  hasTargetArrow: this.hasTargetArrow
393
- }) : u = ue({
393
+ }) : g = ge({
394
394
  to: l,
395
395
  fromVect: c,
396
396
  toVect: a,
397
- flipX: s,
397
+ flipX: n,
398
398
  arrowLength: this.arrowLength,
399
399
  arrowOffset: this.arrowOffset,
400
400
  roundness: this.roundness,
401
401
  hasSourceArrow: this.hasSourceArrow,
402
402
  hasTargetArrow: this.hasTargetArrow
403
- }), this.line.setAttribute("d", u), this.sourceArrow) {
403
+ }), this.line.setAttribute("d", g), this.sourceArrow) {
404
404
  const y = T(
405
405
  c,
406
406
  w,
@@ -413,14 +413,14 @@ class O {
413
413
  const y = T(
414
414
  f,
415
415
  l,
416
- A,
416
+ x,
417
417
  this.arrowWidth
418
418
  );
419
419
  this.targetArrow.setAttribute("d", y);
420
420
  }
421
421
  }
422
422
  }
423
- class ee {
423
+ class te {
424
424
  constructor(e) {
425
425
  i(this, "svg", B());
426
426
  i(this, "group", k());
@@ -436,32 +436,32 @@ class ee {
436
436
  i(this, "detourDistance");
437
437
  i(this, "hasSourceArrow");
438
438
  i(this, "hasTargetArrow");
439
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? g.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? g.cycleSquareSide;
440
- const r = (e == null ? void 0 : e.roundness) ?? g.roundness;
439
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
440
+ const r = (e == null ? void 0 : e.roundness) ?? u.roundness;
441
441
  this.roundness = Math.min(
442
442
  r,
443
443
  this.arrowOffset,
444
444
  this.cycleSquareSide / 2
445
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? g.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? g.hasTargetArrow;
446
- const o = (e == null ? void 0 : e.color) ?? g.color, n = (e == null ? void 0 : e.width) ?? g.width;
447
- this.svg.appendChild(this.group), this.line = Y(o, n), 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));
445
+ ), 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;
446
+ const o = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
447
+ this.svg.appendChild(this.group), this.line = Y(o, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(o), this.group.appendChild(this.targetArrow));
448
448
  }
449
449
  render(e) {
450
- const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = X(
450
+ const { x: r, y: o, width: s, height: d, flipX: n, flipY: h } = X(
451
451
  e.from,
452
452
  e.to
453
453
  );
454
- this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
455
- const c = N(
454
+ this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
455
+ const c = p(
456
456
  e.from.direction,
457
- s,
457
+ n,
458
458
  h
459
- ), a = N(e.to.direction, s, h), l = {
460
- x: n,
459
+ ), a = p(e.to.direction, n, h), l = {
460
+ x: s,
461
461
  y: d
462
462
  };
463
- let u, f = a, A = -this.arrowLength;
464
- if (e.from.portId === e.to.portId ? (u = H({
463
+ let g, f = a, x = -this.arrowLength;
464
+ if (e.from.portId === e.to.portId ? (g = H({
465
465
  fromVect: c,
466
466
  arrowLength: this.arrowLength,
467
467
  side: this.cycleSquareSide,
@@ -469,11 +469,11 @@ class ee {
469
469
  roundness: this.roundness,
470
470
  hasSourceArrow: this.hasSourceArrow,
471
471
  hasTargetArrow: this.hasTargetArrow
472
- }), f = c, A = this.arrowLength) : e.from.nodeId === e.to.nodeId ? u = j({
472
+ }), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
473
473
  to: l,
474
474
  fromVect: c,
475
475
  toVect: a,
476
- flipX: s,
476
+ flipX: n,
477
477
  flipY: h,
478
478
  arrowLength: this.arrowLength,
479
479
  arrowOffset: this.arrowOffset,
@@ -482,7 +482,7 @@ class ee {
482
482
  detourDistance: this.detourDistance,
483
483
  hasSourceArrow: this.hasSourceArrow,
484
484
  hasTargetArrow: this.hasTargetArrow
485
- }) : u = ge({
485
+ }) : g = ue({
486
486
  to: l,
487
487
  fromVect: c,
488
488
  toVect: a,
@@ -491,7 +491,7 @@ class ee {
491
491
  roundness: this.roundness,
492
492
  hasSourceArrow: this.hasSourceArrow,
493
493
  hasTargetArrow: this.hasTargetArrow
494
- }), this.line.setAttribute("d", u), this.sourceArrow) {
494
+ }), this.line.setAttribute("d", g), this.sourceArrow) {
495
495
  const y = T(
496
496
  c,
497
497
  w,
@@ -504,14 +504,14 @@ class ee {
504
504
  const y = T(
505
505
  f,
506
506
  l,
507
- A,
507
+ x,
508
508
  this.arrowWidth
509
509
  );
510
510
  this.targetArrow.setAttribute("d", y);
511
511
  }
512
512
  }
513
513
  }
514
- class te {
514
+ class re {
515
515
  constructor(e) {
516
516
  i(this, "svg", B());
517
517
  i(this, "group", k());
@@ -527,32 +527,32 @@ class te {
527
527
  i(this, "detourDistance");
528
528
  i(this, "hasSourceArrow");
529
529
  i(this, "hasTargetArrow");
530
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? g.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? g.cycleSquareSide;
531
- const r = (e == null ? void 0 : e.roundness) ?? g.roundness;
530
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
531
+ const r = (e == null ? void 0 : e.roundness) ?? u.roundness;
532
532
  this.roundness = Math.min(
533
533
  r,
534
534
  this.arrowOffset,
535
535
  this.cycleSquareSide / 2
536
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? g.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? g.hasTargetArrow;
537
- const o = (e == null ? void 0 : e.color) ?? g.color, n = (e == null ? void 0 : e.width) ?? g.width;
538
- this.svg.appendChild(this.group), this.line = Y(o, n), 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));
536
+ ), 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;
537
+ const o = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
538
+ this.svg.appendChild(this.group), this.line = Y(o, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = b(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = b(o), this.group.appendChild(this.targetArrow));
539
539
  }
540
540
  render(e) {
541
- const { x: r, y: o, width: n, height: d, flipX: s, flipY: h } = X(
541
+ const { x: r, y: o, width: s, height: d, flipX: n, flipY: h } = X(
542
542
  e.from,
543
543
  e.to
544
544
  );
545
- this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
546
- const c = N(
545
+ this.svg.style.transform = `translate(${r}px, ${o}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
546
+ const c = p(
547
547
  e.from.direction,
548
- s,
548
+ n,
549
549
  h
550
- ), a = N(e.to.direction, s, h), l = {
551
- x: n,
550
+ ), a = p(e.to.direction, n, h), l = {
551
+ x: s,
552
552
  y: d
553
553
  };
554
- let u, f = a, A = -this.arrowLength;
555
- if (e.from.portId === e.to.portId ? (u = H({
554
+ let g, f = a, x = -this.arrowLength;
555
+ if (e.from.portId === e.to.portId ? (g = H({
556
556
  fromVect: c,
557
557
  arrowLength: this.arrowLength,
558
558
  side: this.cycleSquareSide,
@@ -560,11 +560,11 @@ class te {
560
560
  roundness: this.roundness,
561
561
  hasSourceArrow: this.hasSourceArrow,
562
562
  hasTargetArrow: this.hasTargetArrow
563
- }), f = c, A = this.arrowLength) : e.from.nodeId === e.to.nodeId ? u = j({
563
+ }), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = j({
564
564
  to: l,
565
565
  fromVect: c,
566
566
  toVect: a,
567
- flipX: s,
567
+ flipX: n,
568
568
  flipY: h,
569
569
  arrowLength: this.arrowLength,
570
570
  arrowOffset: this.arrowOffset,
@@ -573,7 +573,7 @@ class te {
573
573
  detourDistance: this.detourDistance,
574
574
  hasSourceArrow: this.hasSourceArrow,
575
575
  hasTargetArrow: this.hasTargetArrow
576
- }) : u = we({
576
+ }) : g = we({
577
577
  to: l,
578
578
  fromVect: c,
579
579
  toVect: a,
@@ -583,7 +583,7 @@ class te {
583
583
  roundness: this.roundness,
584
584
  hasSourceArrow: this.hasSourceArrow,
585
585
  hasTargetArrow: this.hasTargetArrow
586
- }), this.line.setAttribute("d", u), this.sourceArrow) {
586
+ }), this.line.setAttribute("d", g), this.sourceArrow) {
587
587
  const y = T(
588
588
  c,
589
589
  w,
@@ -596,7 +596,7 @@ class te {
596
596
  const y = T(
597
597
  f,
598
598
  l,
599
- A,
599
+ x,
600
600
  this.arrowWidth
601
601
  );
602
602
  this.targetArrow.setAttribute("d", y);
@@ -608,7 +608,7 @@ const ye = (t) => {
608
608
  return t;
609
609
  switch (t == null ? void 0 : t.type) {
610
610
  case "straight":
611
- return () => new ee({
611
+ return () => new te({
612
612
  color: t.color,
613
613
  width: t.width,
614
614
  arrowLength: t.arrowLength,
@@ -622,7 +622,7 @@ const ye = (t) => {
622
622
  detourDirection: t.detourDirection
623
623
  });
624
624
  case "horizontal":
625
- return () => new O({
625
+ return () => new ee({
626
626
  color: t.color,
627
627
  width: t.width,
628
628
  arrowLength: t.arrowLength,
@@ -636,7 +636,7 @@ const ye = (t) => {
636
636
  detourDirection: t.detourDirection
637
637
  });
638
638
  case "vertical":
639
- return () => new te({
639
+ return () => new re({
640
640
  color: t.color,
641
641
  width: t.width,
642
642
  arrowLength: t.arrowLength,
@@ -650,7 +650,7 @@ const ye = (t) => {
650
650
  detourDirection: t.detourDirection
651
651
  });
652
652
  default:
653
- return () => new q({
653
+ return () => new O({
654
654
  color: t.color,
655
655
  width: t.width,
656
656
  arrowLength: t.arrowLength,
@@ -664,38 +664,38 @@ const ye = (t) => {
664
664
  detourDirection: t.detourDirection
665
665
  });
666
666
  }
667
- }, V = (t) => () => t, I = V(0), M = () => {
667
+ }, $ = (t) => () => t, I = $(0), P = () => {
668
668
  let t = 0;
669
669
  return () => t++;
670
670
  }, ve = (t, e) => {
671
671
  let r = I, o = I;
672
- t === "incremental" && (r = M()), e === "incremental" && (o = M());
673
- const n = M();
674
- return t === "shared-incremental" && (r = n), e === "shared-incremental" && (o = n), typeof t == "number" && (r = V(t)), typeof e == "number" && (o = V(e)), typeof t == "function" && (r = t), typeof e == "function" && (o = e), {
672
+ t === "incremental" && (r = P()), e === "incremental" && (o = P());
673
+ const s = P();
674
+ return t === "shared-incremental" && (r = s), e === "shared-incremental" && (o = s), typeof t == "number" && (r = $(t)), typeof e == "number" && (o = $(e)), typeof t == "function" && (r = t), typeof e == "function" && (o = e), {
675
675
  nodesPriorityFn: r,
676
676
  edgesPriorityFn: o
677
677
  };
678
- }, Ae = (t) => {
679
- var r, o, n, d, s;
678
+ }, xe = (t) => {
679
+ var r, o, s, d, n;
680
680
  const e = ve(
681
681
  (r = t == null ? void 0 : t.nodes) == null ? void 0 : r.priority,
682
682
  (o = t == null ? void 0 : t.edges) == null ? void 0 : o.priority
683
683
  );
684
684
  return {
685
685
  nodes: {
686
- centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? Z,
686
+ centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? q,
687
687
  priorityFn: e.nodesPriorityFn
688
688
  },
689
689
  ports: {
690
690
  direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
691
691
  },
692
692
  edges: {
693
- shapeFactory: ye(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
693
+ shapeFactory: ye(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
694
694
  priorityFn: e.edgesPriorityFn
695
695
  }
696
696
  };
697
697
  };
698
- class re {
698
+ class oe {
699
699
  constructor() {
700
700
  i(this, "nodes", /* @__PURE__ */ new Map());
701
701
  i(this, "ports", /* @__PURE__ */ new Map());
@@ -783,8 +783,8 @@ class re {
783
783
  return this.edges.get(e);
784
784
  }
785
785
  removeEdge(e) {
786
- const r = this.edges.get(e), o = r.from, n = r.to;
787
- this.cycleEdges.get(o).delete(e), this.cycleEdges.get(n).delete(e), this.incommingEdges.get(o).delete(e), this.incommingEdges.get(n).delete(e), this.outcommingEdges.get(o).delete(e), this.outcommingEdges.get(n).delete(e), this.edges.delete(e);
786
+ const r = this.edges.get(e), o = r.from, s = r.to;
787
+ this.cycleEdges.get(o).delete(e), this.cycleEdges.get(s).delete(e), this.incommingEdges.get(o).delete(e), this.incommingEdges.get(s).delete(e), this.outcommingEdges.get(o).delete(e), this.outcommingEdges.get(s).delete(e), this.edges.delete(e);
788
788
  }
789
789
  clear() {
790
790
  this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.nodes.clear();
@@ -808,22 +808,22 @@ class re {
808
808
  getNodeIncomingEdgeIds(e) {
809
809
  const r = Array.from(this.nodePorts.get(e).keys());
810
810
  let o = [];
811
- return r.forEach((n) => {
812
- o = [...o, ...this.getPortIncomingEdgeIds(n)];
811
+ return r.forEach((s) => {
812
+ o = [...o, ...this.getPortIncomingEdgeIds(s)];
813
813
  }), o;
814
814
  }
815
815
  getNodeOutcomingEdgeIds(e) {
816
816
  const r = Array.from(this.nodePorts.get(e).keys());
817
817
  let o = [];
818
- return r.forEach((n) => {
819
- o = [...o, ...this.getPortOutcomingEdgeIds(n)];
818
+ return r.forEach((s) => {
819
+ o = [...o, ...this.getPortOutcomingEdgeIds(s)];
820
820
  }), o;
821
821
  }
822
822
  getNodeCycleEdgeIds(e) {
823
823
  const r = Array.from(this.nodePorts.get(e).keys());
824
824
  let o = [];
825
- return r.forEach((n) => {
826
- o = [...o, ...this.getPortCycleEdgeIds(n)];
825
+ return r.forEach((s) => {
826
+ o = [...o, ...this.getPortCycleEdgeIds(s)];
827
827
  }), o;
828
828
  }
829
829
  getNodeAdjacentEdgeIds(e) {
@@ -834,7 +834,7 @@ class re {
834
834
  ];
835
835
  }
836
836
  }
837
- class xe {
837
+ class Ae {
838
838
  constructor() {
839
839
  i(this, "callbacks", /* @__PURE__ */ new Set());
840
840
  }
@@ -851,21 +851,21 @@ class xe {
851
851
  }
852
852
  }
853
853
  const S = () => {
854
- const t = new xe();
854
+ const t = new Ae();
855
855
  return [t, t];
856
- }, _ = (t) => ({
856
+ }, J = (t) => ({
857
857
  scale: 1 / t.scale,
858
858
  x: -t.x / t.scale,
859
859
  y: -t.y / t.scale
860
- }), J = {
860
+ }), Q = {
861
861
  scale: 1,
862
862
  x: 0,
863
863
  y: 0
864
864
  };
865
- class oe {
865
+ class ie {
866
866
  constructor() {
867
- i(this, "viewportMatrix", J);
868
- i(this, "contentMatrix", J);
867
+ i(this, "viewportMatrix", Q);
868
+ i(this, "contentMatrix", Q);
869
869
  i(this, "emitter");
870
870
  i(this, "onAfterUpdate");
871
871
  [this.emitter, this.onAfterUpdate] = S();
@@ -881,17 +881,17 @@ class oe {
881
881
  scale: e.scale ?? this.viewportMatrix.scale,
882
882
  x: e.x ?? this.viewportMatrix.x,
883
883
  y: e.y ?? this.viewportMatrix.y
884
- }, this.contentMatrix = _(this.viewportMatrix), this.emitter.emit();
884
+ }, this.contentMatrix = J(this.viewportMatrix), this.emitter.emit();
885
885
  }
886
886
  patchContentMatrix(e) {
887
887
  this.contentMatrix = {
888
888
  scale: e.scale ?? this.contentMatrix.scale,
889
889
  x: e.x ?? this.contentMatrix.x,
890
890
  y: e.y ?? this.contentMatrix.y
891
- }, this.viewportMatrix = _(this.contentMatrix), this.emitter.emit();
891
+ }, this.viewportMatrix = J(this.contentMatrix), this.emitter.emit();
892
892
  }
893
893
  }
894
- class ie {
894
+ class ne {
895
895
  constructor(e) {
896
896
  this.transformer = e;
897
897
  }
@@ -912,14 +912,18 @@ const Ee = () => {
912
912
  const t = document.createElement("div");
913
913
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
914
914
  };
915
- class ne {
915
+ class K {
916
916
  constructor(e, r) {
917
917
  i(this, "canvasWrapper", null);
918
918
  i(this, "host", Ee());
919
919
  i(this, "container", Se());
920
920
  i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
921
921
  i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
922
- this.graphStore = e, this.viewportTransformer = r, this.host.appendChild(this.container);
922
+ i(this, "applyTransform", () => {
923
+ const e = this.viewportTransformer.getContentMatrix();
924
+ this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
925
+ });
926
+ this.graphStore = e, this.viewportTransformer = r, this.host.appendChild(this.container), this.viewportTransformer.onAfterUpdate.subscribe(this.applyTransform);
923
927
  }
924
928
  attach(e) {
925
929
  this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host);
@@ -927,10 +931,6 @@ class ne {
927
931
  detach() {
928
932
  this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
929
933
  }
930
- applyTransform() {
931
- const e = this.viewportTransformer.getContentMatrix();
932
- this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
933
- }
934
934
  attachNode(e) {
935
935
  const r = this.graphStore.getNode(e), o = me();
936
936
  o.appendChild(r.element), this.container.appendChild(o), this.nodeIdToWrapperElementMap.set(e, o), this.updateNodeCoordinates(e), this.updateNodePriority(e), o.style.visibility = "visible";
@@ -955,10 +955,10 @@ class ne {
955
955
  });
956
956
  }
957
957
  destroy() {
958
- this.clear(), this.detach(), this.host.removeChild(this.container);
958
+ this.clear(), this.detach(), this.viewportTransformer.onAfterUpdate.unsubscribe(this.applyTransform), this.host.removeChild(this.container);
959
959
  }
960
960
  updateNodeCoordinates(e) {
961
- const r = this.nodeIdToWrapperElementMap.get(e), o = this.graphStore.getNode(e), { width: n, height: d } = o.element.getBoundingClientRect(), s = this.viewportTransformer.getViewportMatrix().scale, h = o.centerFn(n, d), c = o.x - s * h.x, a = o.y - s * h.y;
961
+ const r = this.nodeIdToWrapperElementMap.get(e), o = this.graphStore.getNode(e), { width: s, height: d } = o.element.getBoundingClientRect(), n = this.viewportTransformer.getViewportMatrix().scale, h = o.centerFn(s, d), c = o.x - n * h.x, a = o.y - n * h.y;
962
962
  r.style.transform = `translate(${c}px, ${a}px)`;
963
963
  }
964
964
  updateNodePriority(e) {
@@ -972,13 +972,13 @@ class ne {
972
972
  this.edgeIdToElementMap.set(e, o.shape.svg), this.container.appendChild(o.shape.svg);
973
973
  }
974
974
  renderEdge(e) {
975
- const r = this.graphStore.getEdge(e), o = this.graphStore.getPort(r.from), n = this.graphStore.getPort(r.to), d = o.element.getBoundingClientRect(), s = n.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix(), a = {
975
+ const r = this.graphStore.getEdge(e), o = this.graphStore.getPort(r.from), s = this.graphStore.getPort(r.to), d = o.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix(), a = {
976
976
  x: c.scale * (d.left - h.left) + c.x,
977
977
  y: c.scale * (d.top - h.top) + c.y
978
978
  }, l = {
979
- x: c.scale * (s.left - h.left) + c.x,
980
- y: c.scale * (s.top - h.top) + c.y
981
- }, u = {
979
+ x: c.scale * (n.left - h.left) + c.x,
980
+ y: c.scale * (n.top - h.top) + c.y
981
+ }, g = {
982
982
  x: a.x,
983
983
  y: a.y,
984
984
  width: d.width * c.scale,
@@ -989,14 +989,14 @@ class ne {
989
989
  }, f = {
990
990
  x: l.x,
991
991
  y: l.y,
992
- width: s.width * c.scale,
993
- height: s.height * c.scale,
994
- direction: n.direction,
992
+ width: n.width * c.scale,
993
+ height: n.height * c.scale,
994
+ direction: s.direction,
995
995
  portId: r.to,
996
996
  nodeId: this.graphStore.getPortNodeId(r.to)
997
997
  };
998
998
  r.shape.render({
999
- from: u,
999
+ from: g,
1000
1000
  to: f
1001
1001
  });
1002
1002
  }
@@ -1005,7 +1005,111 @@ class ne {
1005
1005
  r.shape.svg.style.zIndex = `${r.priority}`;
1006
1006
  }
1007
1007
  }
1008
- class U {
1008
+ class Ne {
1009
+ constructor(e) {
1010
+ i(this, "xFrom", 1 / 0);
1011
+ i(this, "yFrom", 1 / 0);
1012
+ i(this, "xTo", 1 / 0);
1013
+ i(this, "yTo", 1 / 0);
1014
+ this.graphStore = e;
1015
+ }
1016
+ setRenderingBox(e) {
1017
+ this.xFrom = e.x, this.xTo = e.x + e.width, this.yFrom = e.y, this.yTo = e.y + e.height;
1018
+ }
1019
+ hasNode(e) {
1020
+ const r = this.graphStore.getNode(e);
1021
+ return r.x >= this.xFrom && r.x <= this.xTo && r.y >= this.yFrom && r.y <= this.yTo;
1022
+ }
1023
+ hasEdge(e) {
1024
+ const r = this.graphStore.getEdge(e), o = this.graphStore.getPortNodeId(r.from), s = this.graphStore.getPortNodeId(r.to), d = this.graphStore.getNode(o), 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);
1025
+ return h <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
1026
+ }
1027
+ }
1028
+ class pe {
1029
+ constructor(e, r, o) {
1030
+ i(this, "attachedNodes", /* @__PURE__ */ new Set());
1031
+ i(this, "attachedEdges", /* @__PURE__ */ new Set());
1032
+ i(this, "renderingBox");
1033
+ i(this, "updateViewport", (e) => {
1034
+ this.renderingBox.setRenderingBox(e);
1035
+ const r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
1036
+ this.graphStore.getAllNodeIds().forEach((n) => {
1037
+ const h = this.renderingBox.hasNode(n), c = this.attachedNodes.has(n);
1038
+ h && !c ? r.add(n) : !h && c && o.add(n);
1039
+ }), this.graphStore.getAllEdgeIds().forEach((n) => {
1040
+ const h = this.renderingBox.hasEdge(n), c = this.attachedEdges.has(n), a = this.graphStore.getEdge(n), l = this.graphStore.getPortNodeId(a.from), g = this.graphStore.getPortNodeId(a.to);
1041
+ h && (this.renderingBox.hasNode(l) || (r.add(l), o.delete(l)), this.renderingBox.hasNode(g) || (r.add(g), o.delete(g))), h && !c ? s.add(n) : !h && c && d.add(n);
1042
+ }), d.forEach((n) => {
1043
+ this.handleDetachEdge(n);
1044
+ }), o.forEach((n) => {
1045
+ this.handleDetachNode(n);
1046
+ }), r.forEach((n) => {
1047
+ this.handleAttachNode(n);
1048
+ }), s.forEach((n) => {
1049
+ this.handleAttachEdge(n);
1050
+ });
1051
+ });
1052
+ this.htmlView = e, this.graphStore = r, this.trigger = o, this.renderingBox = new Ne(this.graphStore), this.trigger.subscribe(this.updateViewport);
1053
+ }
1054
+ attach(e) {
1055
+ this.htmlView.attach(e);
1056
+ }
1057
+ detach() {
1058
+ this.htmlView.detach();
1059
+ }
1060
+ attachNode(e) {
1061
+ this.renderingBox.hasNode(e) && this.handleAttachNode(e);
1062
+ }
1063
+ detachNode(e) {
1064
+ this.attachedNodes.has(e) && this.handleDetachNode(e);
1065
+ }
1066
+ attachEdge(e) {
1067
+ this.renderingBox.hasEdge(e) && this.attachSingleEdge(e);
1068
+ }
1069
+ detachEdge(e) {
1070
+ this.attachedEdges.has(e) && this.handleDetachEdge(e);
1071
+ }
1072
+ updateNodeCoordinates(e) {
1073
+ this.attachedNodes.has(e) ? this.htmlView.updateNodeCoordinates(e) : this.renderingBox.hasNode(e) && (this.handleAttachNode(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((r) => {
1074
+ this.attachSingleEdge(r);
1075
+ }));
1076
+ }
1077
+ updateNodePriority(e) {
1078
+ this.attachedNodes.has(e) && this.htmlView.updateNodePriority(e);
1079
+ }
1080
+ updateEdgeShape(e) {
1081
+ this.attachedEdges.has(e) && this.htmlView.updateEdgeShape(e);
1082
+ }
1083
+ renderEdge(e) {
1084
+ this.attachedEdges.has(e) && this.htmlView.renderEdge(e);
1085
+ }
1086
+ updateEdgePriority(e) {
1087
+ this.attachedEdges.has(e) && this.htmlView.updateEdgePriority(e);
1088
+ }
1089
+ clear() {
1090
+ this.htmlView.clear(), this.attachedNodes.clear(), this.attachedEdges.clear();
1091
+ }
1092
+ destroy() {
1093
+ this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
1094
+ }
1095
+ attachSingleEdge(e) {
1096
+ const r = this.graphStore.getEdge(e), o = this.graphStore.getPortNodeId(r.from), s = this.graphStore.getPortNodeId(r.to);
1097
+ this.attachedNodes.has(o) || this.handleAttachNode(o), this.attachedNodes.has(s) || this.handleAttachNode(s), this.handleAttachEdge(e);
1098
+ }
1099
+ handleAttachNode(e) {
1100
+ this.attachedNodes.add(e), this.htmlView.attachNode(e);
1101
+ }
1102
+ handleDetachNode(e) {
1103
+ this.htmlView.detachNode(e), this.attachedNodes.delete(e);
1104
+ }
1105
+ handleAttachEdge(e) {
1106
+ this.attachedEdges.add(e), this.htmlView.attachEdge(e);
1107
+ }
1108
+ handleDetachEdge(e) {
1109
+ this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
1110
+ }
1111
+ }
1112
+ class L {
1009
1113
  constructor(e) {
1010
1114
  i(this, "counter", 0);
1011
1115
  this.checkExists = e;
@@ -1021,7 +1125,7 @@ class U {
1021
1125
  this.counter = 0;
1022
1126
  }
1023
1127
  }
1024
- class x extends Error {
1128
+ class A extends Error {
1025
1129
  constructor() {
1026
1130
  super(...arguments);
1027
1131
  i(this, "name", "HtmlGraphError");
@@ -1029,13 +1133,13 @@ class x extends Error {
1029
1133
  }
1030
1134
  class se {
1031
1135
  constructor(e, r) {
1032
- i(this, "nodeIdGenerator", new U(
1136
+ i(this, "nodeIdGenerator", new L(
1033
1137
  (e) => this.graphStore.getNode(e) !== void 0
1034
1138
  ));
1035
- i(this, "portIdGenerator", new U(
1139
+ i(this, "portIdGenerator", new L(
1036
1140
  (e) => this.graphStore.getPort(e) !== void 0
1037
1141
  ));
1038
- i(this, "edgeIdGenerator", new U(
1142
+ i(this, "edgeIdGenerator", new L(
1039
1143
  (e) => this.graphStore.getEdge(e) !== void 0
1040
1144
  ));
1041
1145
  i(this, "onAfterNodeAdded");
@@ -1063,7 +1167,7 @@ class se {
1063
1167
  addNode(e) {
1064
1168
  const r = this.nodeIdGenerator.create(e.id);
1065
1169
  if (this.graphStore.getNode(r) !== void 0)
1066
- throw new x("failed to add node with existing id");
1170
+ throw new A("failed to add node with existing id");
1067
1171
  this.graphStore.addNode({
1068
1172
  nodeId: r,
1069
1173
  element: e.element,
@@ -1083,9 +1187,9 @@ class se {
1083
1187
  markPort(e) {
1084
1188
  const r = this.portIdGenerator.create(e.id);
1085
1189
  if (this.graphStore.getPort(r) !== void 0)
1086
- throw new x("failed to add port with existing id");
1190
+ throw new A("failed to add port with existing id");
1087
1191
  if (this.graphStore.getNode(e.nodeId) === void 0)
1088
- throw new x("failed to set port on nonexisting node");
1192
+ throw new A("failed to set port on nonexisting node");
1089
1193
  this.graphStore.addPort({
1090
1194
  portId: r,
1091
1195
  element: e.element,
@@ -1096,11 +1200,11 @@ class se {
1096
1200
  addEdge(e) {
1097
1201
  const r = this.edgeIdGenerator.create(e.id);
1098
1202
  if (this.graphStore.getEdge(r) !== void 0)
1099
- throw new x("failed to add edge with existing id");
1203
+ throw new A("failed to add edge with existing id");
1100
1204
  if (this.graphStore.getPort(e.from) === void 0)
1101
- throw new x("failed to add edge from nonexisting port");
1205
+ throw new A("failed to add edge from nonexisting port");
1102
1206
  if (this.graphStore.getPort(e.to) === void 0)
1103
- throw new x("failed to add edge to nonexisting port");
1207
+ throw new A("failed to add edge to nonexisting port");
1104
1208
  this.graphStore.addEdge({
1105
1209
  edgeId: r,
1106
1210
  from: e.from,
@@ -1112,36 +1216,36 @@ class se {
1112
1216
  updateEdge(e, r) {
1113
1217
  const o = this.graphStore.getEdge(e);
1114
1218
  if (o === void 0)
1115
- throw new x("failed to update nonexisting edge");
1219
+ throw new A("failed to update nonexisting edge");
1116
1220
  r.shape !== void 0 && (o.shape = r.shape, this.onAfterEdgeShapeUpdatedEmitter.emit(e)), r.from !== void 0 && this.graphStore.updateEdgeFrom(e, r.from), r.to !== void 0 && this.graphStore.updateEdgeTo(e, r.to), this.onAfterEdgeUpdatedEmitter.emit(e), r.priority !== void 0 && (o.priority = r.priority, this.onAfterEdgePriorityUpdatedEmitter.emit(e));
1117
1221
  }
1118
1222
  updatePort(e, r) {
1119
1223
  const o = this.graphStore.getPort(e);
1120
1224
  if (o === void 0)
1121
- throw new x("failed to unset nonexisting port");
1225
+ throw new A("failed to unset nonexisting port");
1122
1226
  o.direction = r.direction ?? o.direction, this.onAfterPortUpdatedEmitter.emit(e);
1123
1227
  }
1124
1228
  updateNode(e, r) {
1125
1229
  const o = this.graphStore.getNode(e);
1126
1230
  if (o === void 0)
1127
- throw new x("failed to update nonexisting node");
1231
+ throw new A("failed to update nonexisting node");
1128
1232
  o.x = (r == null ? void 0 : r.x) ?? o.x, o.y = (r == null ? void 0 : r.y) ?? o.y, o.centerFn = r.centerFn ?? o.centerFn, this.onAfterNodeUpdatedEmitter.emit(e), r.priority !== void 0 && (o.priority = r.priority, this.onAfterNodePriorityUpdatedEmitter.emit(e));
1129
1233
  }
1130
1234
  removeEdge(e) {
1131
1235
  if (this.graphStore.getEdge(e) === void 0)
1132
- throw new x("failed to remove nonexisting edge");
1236
+ throw new A("failed to remove nonexisting edge");
1133
1237
  this.onBeforeEdgeRemovedEmitter.emit(e), this.graphStore.removeEdge(e);
1134
1238
  }
1135
1239
  unmarkPort(e) {
1136
1240
  if (this.graphStore.getPort(e) === void 0)
1137
- throw new x("failed to unset nonexisting port");
1241
+ throw new A("failed to unset nonexisting port");
1138
1242
  this.graphStore.getPortAdjacentEdgeIds(e).forEach((r) => {
1139
1243
  this.removeEdge(r);
1140
1244
  }), this.graphStore.removePort(e);
1141
1245
  }
1142
1246
  removeNode(e) {
1143
1247
  if (this.graphStore.getNode(e) === void 0)
1144
- throw new x("failed to remove nonexisting node");
1248
+ throw new A("failed to remove nonexisting node");
1145
1249
  this.graphStore.getNodePortIds(e).forEach((r) => {
1146
1250
  this.unmarkPort(r);
1147
1251
  }), this.onBeforeNodeRemovedEmitter.emit(e), this.graphStore.removeNode(e);
@@ -1215,61 +1319,56 @@ class he {
1215
1319
  return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
1216
1320
  }
1217
1321
  }
1218
- class ke {
1322
+ class Ge {
1219
1323
  constructor(e) {
1220
1324
  i(this, "transformation");
1221
1325
  i(this, "model");
1222
1326
  i(this, "internalTransformation");
1223
1327
  i(this, "internalModel");
1224
1328
  i(this, "graphStoreController");
1225
- i(this, "htmlController");
1329
+ i(this, "htmlView");
1226
1330
  i(this, "onAfterNodeAdded", (e) => {
1227
- this.htmlController.attachNode(e);
1331
+ this.htmlView.attachNode(e);
1228
1332
  });
1229
1333
  i(this, "onAfterEdgeAdded", (e) => {
1230
- this.htmlController.attachEdge(e);
1334
+ this.htmlView.attachEdge(e);
1231
1335
  });
1232
1336
  i(this, "onAfterEdgeShapeUpdated", (e) => {
1233
- this.htmlController.updateEdgeShape(e);
1337
+ this.htmlView.updateEdgeShape(e);
1234
1338
  });
1235
1339
  i(this, "onAfterEdgePriorityUpdated", (e) => {
1236
- this.htmlController.updateEdgePriority(e);
1340
+ this.htmlView.updateEdgePriority(e);
1237
1341
  });
1238
1342
  i(this, "onAfterEdgeUpdated", (e) => {
1239
- this.htmlController.renderEdge(e);
1343
+ this.htmlView.renderEdge(e);
1240
1344
  });
1241
1345
  i(this, "onAfterPortUpdated", (e) => {
1242
1346
  this.internalModel.getPortAdjacentEdgeIds(e).forEach((o) => {
1243
- this.htmlController.renderEdge(o);
1347
+ this.htmlView.renderEdge(o);
1244
1348
  });
1245
1349
  });
1246
1350
  i(this, "onAfterNodePriorityUpdated", (e) => {
1247
- this.htmlController.updateNodePriority(e);
1351
+ this.htmlView.updateNodePriority(e);
1248
1352
  });
1249
1353
  i(this, "onAfterNodeUpdated", (e) => {
1250
- this.htmlController.updateNodeCoordinates(e), this.internalModel.getNodeAdjacentEdgeIds(e).forEach((o) => {
1251
- this.htmlController.renderEdge(o);
1354
+ this.htmlView.updateNodeCoordinates(e), this.internalModel.getNodeAdjacentEdgeIds(e).forEach((o) => {
1355
+ this.htmlView.renderEdge(o);
1252
1356
  });
1253
1357
  });
1254
1358
  i(this, "onBeforeEdgeRemoved", (e) => {
1255
- this.htmlController.detachEdge(e);
1359
+ this.htmlView.detachEdge(e);
1256
1360
  });
1257
1361
  i(this, "onBeforeNodeRemoved", (e) => {
1258
- this.htmlController.detachNode(e);
1259
- });
1260
- i(this, "onAfterTransformUpdate", () => {
1261
- this.htmlController.applyTransform();
1362
+ this.htmlView.detachNode(e);
1262
1363
  });
1263
- this.internalModel = new re(), this.model = new he(this.internalModel), this.internalTransformation = new oe(), this.transformation = new ie(
1364
+ this.internalModel = new oe(), this.model = new he(this.internalModel), this.internalTransformation = new ie(), this.transformation = new ne(
1264
1365
  this.internalTransformation
1265
- ), this.htmlController = new ne(
1366
+ ), this.htmlView = new K(
1266
1367
  this.internalModel,
1267
1368
  this.internalTransformation
1268
1369
  ), this.graphStoreController = new se(
1269
1370
  this.internalModel,
1270
- Ae(e)
1271
- ), this.internalTransformation.onAfterUpdate.subscribe(
1272
- this.onAfterTransformUpdate
1371
+ xe(e)
1273
1372
  ), this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(
1274
1373
  this.onAfterEdgeShapeUpdated
1275
1374
  ), this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(
@@ -1289,10 +1388,10 @@ class ke {
1289
1388
  );
1290
1389
  }
1291
1390
  attach(e) {
1292
- return this.htmlController.attach(e), this;
1391
+ return this.htmlView.attach(e), this;
1293
1392
  }
1294
1393
  detach() {
1295
- return this.htmlController.detach(), this;
1394
+ return this.htmlView.detach(), this;
1296
1395
  }
1297
1396
  addNode(e) {
1298
1397
  return this.graphStoreController.addNode(e), this;
@@ -1328,12 +1427,10 @@ class ke {
1328
1427
  return this.internalTransformation.patchContentMatrix(e), this;
1329
1428
  }
1330
1429
  clear() {
1331
- return this.htmlController.clear(), this.graphStoreController.clear(), this;
1430
+ return this.htmlView.clear(), this.graphStoreController.clear(), this;
1332
1431
  }
1333
1432
  destroy() {
1334
- this.htmlController.destroy(), this.graphStoreController.clear(), this.internalTransformation.onAfterUpdate.unsubscribe(
1335
- this.onAfterTransformUpdate
1336
- ), this.graphStoreController.onAfterNodeAdded.unsubscribe(
1433
+ this.htmlView.destroy(), this.graphStoreController.clear(), this.graphStoreController.onAfterNodeAdded.unsubscribe(
1337
1434
  this.onAfterNodeAdded
1338
1435
  ), this.graphStoreController.onAfterEdgeAdded.unsubscribe(
1339
1436
  this.onAfterEdgeAdded
@@ -1356,54 +1453,49 @@ class ke {
1356
1453
  );
1357
1454
  }
1358
1455
  }
1359
- class Ce {
1456
+ class Te {
1360
1457
  constructor(e) {
1361
1458
  i(this, "transformation");
1362
1459
  i(this, "model");
1363
1460
  i(this, "internalTransformation");
1364
1461
  i(this, "internalModel");
1365
1462
  i(this, "graphStoreController");
1366
- i(this, "htmlController");
1463
+ i(this, "htmlView");
1367
1464
  i(this, "onAfterNodeAdded", (e) => {
1368
- this.htmlController.attachNode(e);
1465
+ this.htmlView.attachNode(e);
1369
1466
  });
1370
1467
  i(this, "onAfterEdgeAdded", (e) => {
1371
- this.htmlController.attachEdge(e);
1468
+ this.htmlView.attachEdge(e);
1372
1469
  });
1373
1470
  i(this, "onAfterEdgeShapeUpdated", (e) => {
1374
- this.htmlController.updateEdgeShape(e);
1471
+ this.htmlView.updateEdgeShape(e);
1375
1472
  });
1376
1473
  i(this, "onAfterEdgePriorityUpdated", (e) => {
1377
- this.htmlController.updateEdgePriority(e);
1474
+ this.htmlView.updateEdgePriority(e);
1378
1475
  });
1379
1476
  i(this, "onAfterEdgeUpdated", (e) => {
1380
- this.htmlController.renderEdge(e);
1477
+ this.htmlView.renderEdge(e);
1381
1478
  });
1382
1479
  i(this, "onAfterPortUpdated", (e) => {
1383
1480
  this.internalModel.getPortAdjacentEdgeIds(e).forEach((o) => {
1384
- this.htmlController.renderEdge(o);
1481
+ this.htmlView.renderEdge(o);
1385
1482
  });
1386
1483
  });
1387
1484
  i(this, "onAfterNodePriorityUpdated", (e) => {
1388
- this.htmlController.updateNodePriority(e);
1485
+ this.htmlView.updateNodePriority(e);
1389
1486
  });
1390
1487
  i(this, "onAfterNodeUpdated", (e) => {
1391
- this.htmlController.updateNodeCoordinates(e), this.internalModel.getNodeAdjacentEdgeIds(e).forEach((o) => {
1392
- this.htmlController.renderEdge(o);
1488
+ this.htmlView.updateNodeCoordinates(e), this.internalModel.getNodeAdjacentEdgeIds(e).forEach((o) => {
1489
+ this.htmlView.renderEdge(o);
1393
1490
  });
1394
1491
  });
1395
1492
  i(this, "onBeforeEdgeRemoved", (e) => {
1396
- this.htmlController.detachEdge(e);
1493
+ this.htmlView.detachEdge(e);
1397
1494
  });
1398
1495
  i(this, "onBeforeNodeRemoved", (e) => {
1399
- this.htmlController.detachNode(e);
1496
+ this.htmlView.detachNode(e);
1400
1497
  });
1401
- i(this, "onAfterTransformUpdate", () => {
1402
- this.htmlController.applyTransform();
1403
- });
1404
- this.model = e.publicGraphStore, this.internalModel = e.graphStore, this.internalTransformation = e.viewportTransformer, this.transformation = e.publicViewportTransformer, this.htmlController = e.htmlController, this.graphStoreController = e.graphStoreController, this.internalTransformation.onAfterUpdate.subscribe(
1405
- this.onAfterTransformUpdate
1406
- ), this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(
1498
+ this.model = e.publicGraphStore, this.internalModel = e.graphStore, this.internalTransformation = e.viewportTransformer, this.transformation = e.publicViewportTransformer, this.htmlView = e.htmlView, this.graphStoreController = e.graphStoreController, this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(
1407
1499
  this.onAfterEdgeShapeUpdated
1408
1500
  ), this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(
1409
1501
  this.onAfterEdgePriorityUpdated
@@ -1422,10 +1514,10 @@ class Ce {
1422
1514
  );
1423
1515
  }
1424
1516
  attach(e) {
1425
- return this.htmlController.attach(e), this;
1517
+ return this.htmlView.attach(e), this;
1426
1518
  }
1427
1519
  detach() {
1428
- return this.htmlController.detach(), this;
1520
+ return this.htmlView.detach(), this;
1429
1521
  }
1430
1522
  addNode(e) {
1431
1523
  return this.graphStoreController.addNode(e), this;
@@ -1461,12 +1553,10 @@ class Ce {
1461
1553
  return this.internalTransformation.patchContentMatrix(e), this;
1462
1554
  }
1463
1555
  clear() {
1464
- return this.htmlController.clear(), this.graphStoreController.clear(), this;
1556
+ return this.htmlView.clear(), this.graphStoreController.clear(), this;
1465
1557
  }
1466
1558
  destroy() {
1467
- this.htmlController.destroy(), this.graphStoreController.clear(), this.internalTransformation.onAfterUpdate.unsubscribe(
1468
- this.onAfterTransformUpdate
1469
- ), this.graphStoreController.onAfterNodeAdded.unsubscribe(
1559
+ this.htmlView.destroy(), this.graphStoreController.clear(), this.graphStoreController.onAfterNodeAdded.unsubscribe(
1470
1560
  this.onAfterNodeAdded
1471
1561
  ), this.graphStoreController.onAfterEdgeAdded.unsubscribe(
1472
1562
  this.onAfterEdgeAdded
@@ -1489,12 +1579,12 @@ class Ce {
1489
1579
  );
1490
1580
  }
1491
1581
  }
1492
- const Ne = (t) => {
1582
+ const be = (t) => {
1493
1583
  if (typeof t == "function")
1494
1584
  return t;
1495
1585
  switch (t == null ? void 0 : t.type) {
1496
1586
  case "straight":
1497
- return () => new ee({
1587
+ return () => new te({
1498
1588
  color: t.color,
1499
1589
  width: t.width,
1500
1590
  arrowLength: t.arrowLength,
@@ -1508,7 +1598,7 @@ const Ne = (t) => {
1508
1598
  detourDirection: t.detourDirection
1509
1599
  });
1510
1600
  case "horizontal":
1511
- return () => new O({
1601
+ return () => new ee({
1512
1602
  color: t.color,
1513
1603
  width: t.width,
1514
1604
  arrowLength: t.arrowLength,
@@ -1522,7 +1612,7 @@ const Ne = (t) => {
1522
1612
  detourDirection: t.detourDirection
1523
1613
  });
1524
1614
  case "vertical":
1525
- return () => new te({
1615
+ return () => new re({
1526
1616
  color: t.color,
1527
1617
  width: t.width,
1528
1618
  arrowLength: t.arrowLength,
@@ -1536,7 +1626,7 @@ const Ne = (t) => {
1536
1626
  detourDirection: t.detourDirection
1537
1627
  });
1538
1628
  default:
1539
- return () => new q({
1629
+ return () => new O({
1540
1630
  color: t.color,
1541
1631
  width: t.width,
1542
1632
  arrowLength: t.arrowLength,
@@ -1550,81 +1640,82 @@ const Ne = (t) => {
1550
1640
  detourDirection: t.detourDirection
1551
1641
  });
1552
1642
  }
1553
- }, Te = (t, e) => {
1643
+ }, Ce = (t, e) => {
1554
1644
  let r = I, o = I;
1555
- t === "incremental" && (r = M()), e === "incremental" && (o = M());
1556
- const n = M();
1557
- return t === "shared-incremental" && (r = n), e === "shared-incremental" && (o = n), typeof t == "number" && (r = V(t)), typeof e == "number" && (o = V(e)), typeof t == "function" && (r = t), typeof e == "function" && (o = e), {
1645
+ t === "incremental" && (r = P()), e === "incremental" && (o = P());
1646
+ const s = P();
1647
+ return t === "shared-incremental" && (r = s), e === "shared-incremental" && (o = s), typeof t == "number" && (r = $(t)), typeof e == "number" && (o = $(e)), typeof t == "function" && (r = t), typeof e == "function" && (o = e), {
1558
1648
  nodesPriorityFn: r,
1559
1649
  edgesPriorityFn: o
1560
1650
  };
1561
- }, pe = (t) => {
1562
- var r, o, n, d, s;
1563
- const e = Te(
1651
+ }, Pe = (t) => {
1652
+ var r, o, s, d, n;
1653
+ const e = Ce(
1564
1654
  (r = t == null ? void 0 : t.nodes) == null ? void 0 : r.priority,
1565
1655
  (o = t == null ? void 0 : t.edges) == null ? void 0 : o.priority
1566
1656
  );
1567
1657
  return {
1568
1658
  nodes: {
1569
- centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? Z,
1659
+ centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? q,
1570
1660
  priorityFn: e.nodesPriorityFn
1571
1661
  },
1572
1662
  ports: {
1573
1663
  direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
1574
1664
  },
1575
1665
  edges: {
1576
- shapeFactory: Ne(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
1666
+ shapeFactory: be(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
1577
1667
  priorityFn: e.edgesPriorityFn
1578
1668
  }
1579
1669
  };
1580
1670
  };
1581
- class be {
1582
- constructor(e) {
1671
+ class Me {
1672
+ constructor(e, r) {
1583
1673
  i(this, "publicViewportTransformer");
1584
1674
  i(this, "publicGraphStore");
1585
1675
  i(this, "viewportTransformer");
1586
1676
  i(this, "graphStore");
1587
- i(this, "htmlController");
1677
+ i(this, "htmlView");
1588
1678
  i(this, "graphStoreController");
1589
- this.graphStore = new re(), this.publicGraphStore = new he(this.graphStore), this.viewportTransformer = new oe(), this.publicViewportTransformer = new ie(
1679
+ this.graphStore = new oe(), this.publicGraphStore = new he(this.graphStore), this.viewportTransformer = new ie(), this.publicViewportTransformer = new ne(
1590
1680
  this.viewportTransformer
1591
- ), this.htmlController = new ne(
1592
- this.graphStore,
1593
- this.viewportTransformer
1594
- ), this.graphStoreController = new se(
1681
+ ), this.htmlView = r(this.graphStore, this.viewportTransformer), this.graphStoreController = new se(
1595
1682
  this.graphStore,
1596
- pe(e)
1683
+ Pe(e)
1597
1684
  );
1598
1685
  }
1599
1686
  }
1600
- const W = (t, e, r) => {
1601
- const { x: o, y: n, width: d, height: s } = t.getBoundingClientRect();
1602
- return e >= o && e <= o + d && r >= n && r <= n + s;
1687
+ const Ve = (t, e) => new K(t, e), De = (t) => (e, r) => new pe(
1688
+ new K(e, r),
1689
+ e,
1690
+ t
1691
+ ), W = (t, e, r) => {
1692
+ const { x: o, y: s, width: d, height: n } = t.getBoundingClientRect();
1693
+ return e >= o && e <= o + d && r >= s && r <= s + n;
1603
1694
  }, R = (t, e, r) => e >= 0 && e <= t.innerWidth && r >= 0 && r <= t.innerHeight, F = (t, e) => {
1604
1695
  e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
1605
- }, Me = (t) => {
1606
- var u, f, A, y, m, E;
1607
- const e = ((u = t == null ? void 0 : t.events) == null ? void 0 : u.onNodeDrag) ?? (() => {
1608
- }), r = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), o = ((A = t == null ? void 0 : t.events) == null ? void 0 : A.onNodeDragFinished) ?? (() => {
1609
- }), n = (t == null ? void 0 : t.moveOnTop) === !1, d = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, s = d !== void 0 ? d : "grab", h = (m = t == null ? void 0 : t.mouse) == null ? void 0 : m.mouseDownEventVerifier, c = h !== void 0 ? h : (C) => C.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
1696
+ }, Le = (t) => {
1697
+ var g, f, x, y, m, E;
1698
+ const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
1699
+ }), r = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), o = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
1700
+ }), 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 = (m = t == null ? void 0 : t.mouse) == null ? void 0 : m.mouseDownEventVerifier, c = h !== void 0 ? h : (N) => N.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
1610
1701
  return {
1611
- freezePriority: n,
1612
- dragCursor: s,
1702
+ freezePriority: s,
1703
+ dragCursor: n,
1613
1704
  mouseDownEventVerifier: c,
1614
- mouseUpEventVerifier: a !== void 0 ? a : (C) => C.button === 0,
1705
+ mouseUpEventVerifier: a !== void 0 ? a : (N) => N.button === 0,
1615
1706
  onNodeDrag: e,
1616
1707
  onBeforeNodeDrag: r,
1617
1708
  onNodeDragFinished: o
1618
1709
  };
1619
1710
  };
1620
- class Pe {
1711
+ class $e {
1621
1712
  constructor(e, r) {
1622
1713
  i(this, "model");
1623
1714
  i(this, "transformation");
1624
1715
  i(this, "maxNodePriority", 0);
1625
1716
  i(this, "nodes", /* @__PURE__ */ new Map());
1626
1717
  i(this, "grabbedNodeId", null);
1627
- i(this, "nodeIdGenerator", new U(
1718
+ i(this, "nodeIdGenerator", new L(
1628
1719
  (e) => this.nodes.has(e)
1629
1720
  ));
1630
1721
  i(this, "element", null);
@@ -1647,8 +1738,8 @@ class Pe {
1647
1738
  return;
1648
1739
  }
1649
1740
  if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
1650
- const o = r.clientX - this.previousTouchCoords.x, n = r.clientY - this.previousTouchCoords.y;
1651
- this.dragNode(this.grabbedNodeId, o, n), this.previousTouchCoords = {
1741
+ const o = r.clientX - this.previousTouchCoords.x, s = r.clientY - this.previousTouchCoords.y;
1742
+ this.dragNode(this.grabbedNodeId, o, s), this.previousTouchCoords = {
1652
1743
  x: e.touches[0].clientX,
1653
1744
  y: e.touches[0].clientY
1654
1745
  };
@@ -1660,7 +1751,7 @@ class Pe {
1660
1751
  i(this, "previousTouchCoords", null);
1661
1752
  i(this, "window", window);
1662
1753
  i(this, "options");
1663
- this.canvas = e, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.options = Me(r ?? {});
1754
+ this.canvas = e, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.options = Le(r ?? {});
1664
1755
  }
1665
1756
  attach(e) {
1666
1757
  return this.detach(), this.element = e, this.canvas.attach(this.element), this;
@@ -1674,33 +1765,33 @@ class Pe {
1674
1765
  const o = (d) => {
1675
1766
  if (this.element === null || !this.options.mouseDownEventVerifier(d))
1676
1767
  return;
1677
- const s = this.model.getNode(r);
1768
+ const n = this.model.getNode(r);
1678
1769
  this.options.onBeforeNodeDrag({
1679
1770
  nodeId: r,
1680
1771
  element: e.element,
1681
- x: s.x,
1682
- y: s.y
1772
+ x: n.x,
1773
+ y: n.y
1683
1774
  }) && (d.stopImmediatePropagation(), this.grabbedNodeId = r, F(this.element, this.options.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1684
- }, n = (d) => {
1775
+ }, s = (d) => {
1685
1776
  if (d.touches.length !== 1)
1686
1777
  return;
1687
1778
  d.stopImmediatePropagation(), this.previousTouchCoords = {
1688
1779
  x: d.touches[0].clientX,
1689
1780
  y: d.touches[0].clientY
1690
1781
  };
1691
- const s = this.model.getNode(r);
1782
+ const n = this.model.getNode(r);
1692
1783
  this.options.onBeforeNodeDrag({
1693
1784
  nodeId: r,
1694
1785
  element: e.element,
1695
- x: s.x,
1696
- y: s.y
1786
+ x: n.x,
1787
+ y: n.y
1697
1788
  }) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
1698
1789
  };
1699
1790
  return this.nodes.set(r, {
1700
1791
  element: e.element,
1701
1792
  onMouseDown: o,
1702
- onTouchStart: n
1703
- }), e.element.addEventListener("mousedown", o), e.element.addEventListener("touchstart", n), this;
1793
+ onTouchStart: s
1794
+ }), e.element.addEventListener("mousedown", o), e.element.addEventListener("touchstart", s), this;
1704
1795
  }
1705
1796
  updateNode(e, r) {
1706
1797
  return this.canvas.updateNode(e, r), this.updateMaxNodePriority(e), this;
@@ -1742,14 +1833,14 @@ class Pe {
1742
1833
  this.detach(), this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
1743
1834
  }
1744
1835
  dragNode(e, r, o) {
1745
- const n = this.model.getNode(e);
1746
- if (n === null)
1836
+ const s = this.model.getNode(e);
1837
+ if (s === null)
1747
1838
  return;
1748
- const d = this.canvas.transformation.getContentMatrix(), s = d.scale * n.x + d.x, h = d.scale * n.y + d.y, c = s + r, a = h + o, l = this.canvas.transformation.getViewportMatrix(), u = l.scale * c + l.x, f = l.scale * a + l.y;
1749
- this.canvas.updateNode(e, { x: u, y: f }), this.options.onNodeDrag({
1839
+ const d = this.canvas.transformation.getContentMatrix(), n = d.scale * s.x + d.x, h = d.scale * s.y + d.y, c = n + r, a = h + o, l = this.canvas.transformation.getViewportMatrix(), g = l.scale * c + l.x, f = l.scale * a + l.y;
1840
+ this.canvas.updateNode(e, { x: g, y: f }), this.options.onNodeDrag({
1750
1841
  nodeId: e,
1751
- element: n.element,
1752
- x: u,
1842
+ element: s.element,
1843
+ x: g,
1753
1844
  y: f
1754
1845
  });
1755
1846
  }
@@ -1762,8 +1853,8 @@ class Pe {
1762
1853
  return;
1763
1854
  this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
1764
1855
  const r = this.maxNodePriority - 1;
1765
- this.model.getNodeAdjacentEdgeIds(e).forEach((n) => {
1766
- this.updateEdge(n, { priority: r });
1856
+ this.model.getNodeAdjacentEdgeIds(e).forEach((s) => {
1857
+ this.updateEdge(s, { priority: r });
1767
1858
  });
1768
1859
  }
1769
1860
  cancelMouseDrag() {
@@ -1792,30 +1883,30 @@ class Pe {
1792
1883
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
1793
1884
  }
1794
1885
  }
1795
- const De = (t) => {
1796
- const e = t.minX !== null ? t.minX : -1 / 0, r = t.maxX !== null ? t.maxX : 1 / 0, o = t.minY !== null ? t.minY : -1 / 0, n = t.maxY !== null ? t.maxY : 1 / 0;
1886
+ const Ue = (t) => {
1887
+ const e = t.minX !== null ? t.minX : -1 / 0, r = t.maxX !== null ? t.maxX : 1 / 0, o = t.minY !== null ? t.minY : -1 / 0, s = t.maxY !== null ? t.maxY : 1 / 0;
1797
1888
  return (d) => {
1798
- let s = d.nextTransform.x, h = d.nextTransform.y;
1799
- s < e && s < d.prevTransform.x && (s = Math.min(d.prevTransform.x, e));
1889
+ let n = d.nextTransform.x, h = d.nextTransform.y;
1890
+ n < e && n < d.prevTransform.x && (n = Math.min(d.prevTransform.x, e));
1800
1891
  const c = d.canvasWidth * d.prevTransform.scale, a = r - c;
1801
- s > a && s > d.prevTransform.x && (s = Math.max(d.prevTransform.x, a)), h < o && h < d.prevTransform.y && (h = Math.min(d.prevTransform.y, o));
1802
- const l = d.canvasHeight * d.prevTransform.scale, u = n - l;
1803
- return h > u && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, u)), { scale: d.nextTransform.scale, x: s, y: h };
1892
+ n > a && n > d.prevTransform.x && (n = Math.max(d.prevTransform.x, a)), h < o && h < d.prevTransform.y && (h = Math.min(d.prevTransform.y, o));
1893
+ const l = d.canvasHeight * d.prevTransform.scale, g = s - l;
1894
+ return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x: n, y: h };
1804
1895
  };
1805
- }, Le = (t) => {
1806
- const e = t.maxContentScale, r = t.minContentScale, o = e !== null ? 1 / e : 0, n = r !== null ? 1 / r : 1 / 0;
1896
+ }, Ie = (t) => {
1897
+ const e = t.maxContentScale, r = t.minContentScale, o = e !== null ? 1 / e : 0, s = r !== null ? 1 / r : 1 / 0;
1807
1898
  return (d) => {
1808
- const s = d.prevTransform, h = d.nextTransform;
1899
+ const n = d.prevTransform, h = d.nextTransform;
1809
1900
  let c = h.scale, a = h.x, l = h.y;
1810
- if (h.scale > n && h.scale > s.scale) {
1811
- c = Math.max(s.scale, n), a = s.x, l = s.y;
1812
- const u = (c - s.scale) / (h.scale - s.scale);
1813
- a = s.x + (h.x - s.x) * u, l = s.y + (h.y - s.y) * u;
1901
+ if (h.scale > s && h.scale > n.scale) {
1902
+ c = Math.max(n.scale, s), a = n.x, l = n.y;
1903
+ const g = (c - n.scale) / (h.scale - n.scale);
1904
+ a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
1814
1905
  }
1815
- if (h.scale < o && h.scale < s.scale) {
1816
- c = Math.min(s.scale, o), a = s.x, l = s.y;
1817
- const u = (c - s.scale) / (h.scale - s.scale);
1818
- a = s.x + (h.x - s.x) * u, l = s.y + (h.y - s.y) * u;
1906
+ if (h.scale < o && h.scale < n.scale) {
1907
+ c = Math.min(n.scale, o), a = n.x, l = n.y;
1908
+ const g = (c - n.scale) / (h.scale - n.scale);
1909
+ a = n.x + (h.x - n.x) * g, l = n.y + (h.y - n.y) * g;
1819
1910
  }
1820
1911
  return {
1821
1912
  scale: c,
@@ -1823,7 +1914,7 @@ const De = (t) => {
1823
1914
  y: l
1824
1915
  };
1825
1916
  };
1826
- }, Ue = (t) => (e) => t.reduce(
1917
+ }, We = (t) => (e) => t.reduce(
1827
1918
  (r, o) => o({
1828
1919
  prevTransform: e.prevTransform,
1829
1920
  nextTransform: r,
@@ -1831,48 +1922,48 @@ const De = (t) => {
1831
1922
  canvasHeight: e.canvasHeight
1832
1923
  }),
1833
1924
  e.nextTransform
1834
- ), Q = (t) => {
1925
+ ), Z = (t) => {
1835
1926
  if (typeof t == "function")
1836
1927
  return t;
1837
1928
  switch (t.type) {
1838
1929
  case "scale-limit":
1839
- return Le({
1930
+ return Ie({
1840
1931
  minContentScale: t.minContentScale ?? 0,
1841
1932
  maxContentScale: t.maxContentScale ?? 1 / 0
1842
1933
  });
1843
1934
  case "shift-limit":
1844
- return De({
1935
+ return Ue({
1845
1936
  minX: t.minX ?? -1 / 0,
1846
1937
  maxX: t.maxX ?? 1 / 0,
1847
1938
  minY: t.minY ?? -1 / 0,
1848
1939
  maxY: t.maxY ?? 1 / 0
1849
1940
  });
1850
1941
  }
1851
- }, Ve = (t) => {
1852
- var y, m, E, C, z, P, D, L, K;
1942
+ }, Re = (t) => {
1943
+ var y, m, E, N, z, M, V, D, _;
1853
1944
  const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity, r = e !== void 0 ? e : 1.2, o = t == null ? void 0 : t.transformPreprocessor;
1854
- let n;
1855
- o !== void 0 ? Array.isArray(o) ? n = Ue(
1945
+ let s;
1946
+ o !== void 0 ? Array.isArray(o) ? s = We(
1856
1947
  o.map(
1857
- (b) => Q(b)
1948
+ (C) => Z(C)
1858
1949
  )
1859
- ) : n = Q(o) : n = (b) => b.nextTransform;
1860
- const d = ((m = t == null ? void 0 : t.shift) == null ? void 0 : m.cursor) !== void 0 ? t.shift.cursor : "grab", s = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
1861
- }), h = ((C = t == null ? void 0 : t.events) == null ? void 0 : C.onTransformChange) ?? (() => {
1862
- }), c = (z = t == null ? void 0 : t.shift) == null ? void 0 : z.mouseDownEventVerifier, a = c !== void 0 ? c : (b) => b.button === 0, l = (P = t == null ? void 0 : t.shift) == null ? void 0 : P.mouseUpEventVerifier, u = l !== void 0 ? l : (b) => b.button === 0, f = (D = t == null ? void 0 : t.scale) == null ? void 0 : D.mouseWheelEventVerifier, A = f !== void 0 ? f : () => !0;
1950
+ ) : s = Z(o) : s = (C) => C.nextTransform;
1951
+ const d = ((m = t == null ? void 0 : t.shift) == null ? void 0 : m.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
1952
+ }), h = ((N = t == null ? void 0 : t.events) == null ? void 0 : N.onTransformChange) ?? (() => {
1953
+ }), c = (z = t == null ? void 0 : t.shift) == null ? void 0 : z.mouseDownEventVerifier, a = c !== void 0 ? c : (C) => C.button === 0, l = (M = t == null ? void 0 : t.shift) == null ? void 0 : M.mouseUpEventVerifier, g = l !== void 0 ? l : (C) => C.button === 0, f = (V = t == null ? void 0 : t.scale) == null ? void 0 : V.mouseWheelEventVerifier, x = f !== void 0 ? f : () => !0;
1863
1954
  return {
1864
1955
  wheelSensitivity: r,
1865
- onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
1956
+ onTransformStarted: ((D = t == null ? void 0 : t.events) == null ? void 0 : D.onTransformStarted) ?? (() => {
1866
1957
  }),
1867
- onTransformFinished: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onTransformFinished) ?? (() => {
1958
+ onTransformFinished: ((_ = t == null ? void 0 : t.events) == null ? void 0 : _.onTransformFinished) ?? (() => {
1868
1959
  }),
1869
- onBeforeTransformChange: s,
1960
+ onBeforeTransformChange: n,
1870
1961
  onTransformChange: h,
1871
- transformPreprocessor: n,
1962
+ transformPreprocessor: s,
1872
1963
  shiftCursor: d,
1873
1964
  mouseDownEventVerifier: a,
1874
- mouseUpEventVerifier: u,
1875
- mouseWheelEventVerifier: A
1965
+ mouseUpEventVerifier: g,
1966
+ mouseWheelEventVerifier: x
1876
1967
  };
1877
1968
  }, G = (t) => {
1878
1969
  const e = [], r = t.touches.length;
@@ -1881,27 +1972,27 @@ const De = (t) => {
1881
1972
  const o = e.reduce(
1882
1973
  (h, c) => [h[0] + c[0], h[1] + c[1]],
1883
1974
  [0, 0]
1884
- ), n = [o[0] / r, o[1] / r], s = e.map((h) => [h[0] - n[0], h[1] - n[1]]).reduce(
1975
+ ), s = [o[0] / r, o[1] / r], n = e.map((h) => [h[0] - s[0], h[1] - s[1]]).reduce(
1885
1976
  (h, c) => h + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
1886
1977
  0
1887
1978
  );
1888
1979
  return {
1889
- x: n[0],
1890
- y: n[1],
1891
- scale: s / r,
1980
+ x: s[0],
1981
+ y: s[1],
1982
+ scale: n / r,
1892
1983
  touchesCnt: r,
1893
1984
  touches: e
1894
1985
  };
1895
- }, $e = (t, e, r) => ({
1986
+ }, Fe = (t, e, r) => ({
1896
1987
  scale: t.scale,
1897
1988
  x: t.x + t.scale * e,
1898
1989
  y: t.y + t.scale * r
1899
- }), Ie = (t, e, r, o) => ({
1990
+ }), Be = (t, e, r, o) => ({
1900
1991
  scale: t.scale * e,
1901
1992
  x: t.scale * (1 - e) * r + t.x,
1902
1993
  y: t.scale * (1 - e) * o + t.y
1903
1994
  });
1904
- class We {
1995
+ class ke {
1905
1996
  constructor(e, r) {
1906
1997
  i(this, "model");
1907
1998
  i(this, "transformation");
@@ -1926,8 +2017,8 @@ class We {
1926
2017
  if (!this.options.mouseWheelEventVerifier(e))
1927
2018
  return;
1928
2019
  e.preventDefault(), this.options.onTransformStarted();
1929
- const { left: r, top: o } = this.element.getBoundingClientRect(), n = e.clientX - r, d = e.clientY - o, h = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
1930
- this.scaleViewport(this.element, h, n, d), this.options.onTransformFinished();
2020
+ const { left: r, top: o } = this.element.getBoundingClientRect(), s = e.clientX - r, d = e.clientY - o, h = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
2021
+ this.scaleViewport(this.element, h, s, d), this.options.onTransformFinished();
1931
2022
  });
1932
2023
  i(this, "onTouchStart", (e) => {
1933
2024
  this.prevTouches = G(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
@@ -1948,7 +2039,7 @@ class We {
1948
2039
  -(o.x - this.prevTouches.x),
1949
2040
  -(o.y - this.prevTouches.y)
1950
2041
  ), o.touchesCnt === 2) {
1951
- const { left: d, top: s } = r.getBoundingClientRect(), h = this.prevTouches.x - d, c = this.prevTouches.y - s, l = 1 / (o.scale / this.prevTouches.scale);
2042
+ const { left: d, top: n } = r.getBoundingClientRect(), h = this.prevTouches.x - d, c = this.prevTouches.y - n, l = 1 / (o.scale / this.prevTouches.scale);
1952
2043
  this.scaleViewport(r, l, h, c);
1953
2044
  }
1954
2045
  this.prevTouches = o;
@@ -1957,16 +2048,16 @@ class We {
1957
2048
  e.touches.length > 0 ? this.prevTouches = G(e) : this.stopTouchDrag();
1958
2049
  });
1959
2050
  i(this, "observer", new ResizeObserver(() => {
1960
- const e = this.canvas.transformation.getViewportMatrix(), { width: r, height: o } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
2051
+ const e = this.canvas.transformation.getViewportMatrix(), { width: r, height: o } = this.element.getBoundingClientRect(), s = this.options.transformPreprocessor({
1961
2052
  prevTransform: e,
1962
2053
  nextTransform: e,
1963
2054
  canvasWidth: r,
1964
2055
  canvasHeight: o
1965
2056
  });
1966
- this.canvas.patchViewportMatrix(n), this.options.onTransformChange();
2057
+ this.canvas.patchViewportMatrix(s), this.options.onTransformChange();
1967
2058
  }));
1968
2059
  i(this, "options");
1969
- this.canvas = e, this.options = Ve(r), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
2060
+ this.canvas = e, this.options = Re(r), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1970
2061
  }
1971
2062
  attach(e) {
1972
2063
  return this.detach(), this.element = e, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element), this;
@@ -2015,19 +2106,19 @@ class We {
2015
2106
  }
2016
2107
  moveViewport(e, r, o) {
2017
2108
  this.options.onBeforeTransformChange();
2018
- const n = this.transformation.getViewportMatrix(), d = $e(n, r, o), { width: s, height: h } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
2019
- prevTransform: n,
2109
+ const s = this.transformation.getViewportMatrix(), d = Fe(s, r, o), { width: n, height: h } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
2110
+ prevTransform: s,
2020
2111
  nextTransform: d,
2021
- canvasWidth: s,
2112
+ canvasWidth: n,
2022
2113
  canvasHeight: h
2023
2114
  });
2024
2115
  this.canvas.patchViewportMatrix(c), this.options.onTransformChange();
2025
2116
  }
2026
- scaleViewport(e, r, o, n) {
2117
+ scaleViewport(e, r, o, s) {
2027
2118
  this.options.onBeforeTransformChange();
2028
- const d = this.canvas.transformation.getViewportMatrix(), s = Ie(d, r, o, n), { width: h, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
2119
+ const d = this.canvas.transformation.getViewportMatrix(), n = Be(d, r, o, s), { width: h, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
2029
2120
  prevTransform: d,
2030
- nextTransform: s,
2121
+ nextTransform: n,
2031
2122
  canvasWidth: h,
2032
2123
  canvasHeight: c
2033
2124
  });
@@ -2046,7 +2137,7 @@ class We {
2046
2137
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
2047
2138
  }
2048
2139
  }
2049
- class Re {
2140
+ class Ye {
2050
2141
  constructor() {
2051
2142
  i(this, "keyMap", /* @__PURE__ */ new Map());
2052
2143
  i(this, "valueMap", /* @__PURE__ */ new Map());
@@ -2083,19 +2174,19 @@ class Re {
2083
2174
  this.keyMap.clear(), this.valueMap.clear();
2084
2175
  }
2085
2176
  }
2086
- class Fe {
2177
+ class Xe {
2087
2178
  constructor(e) {
2088
2179
  i(this, "transformation");
2089
2180
  i(this, "model");
2090
- i(this, "nodes", new Re());
2091
- i(this, "nodeIdGenerator", new U(
2181
+ i(this, "nodes", new Ye());
2182
+ i(this, "nodeIdGenerator", new L(
2092
2183
  (e) => this.nodes.hasKey(e)
2093
2184
  ));
2094
2185
  i(this, "nodesResizeObserver");
2095
2186
  this.canvas = e, this.nodesResizeObserver = new window.ResizeObserver((r) => {
2096
2187
  r.forEach((o) => {
2097
- const n = o.target;
2098
- this.handleNodeResize(n);
2188
+ const s = o.target;
2189
+ this.handleNodeResize(s);
2099
2190
  });
2100
2191
  }), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
2101
2192
  }
@@ -2152,12 +2243,12 @@ class Fe {
2152
2243
  }
2153
2244
  handleNodeResize(e) {
2154
2245
  const r = this.nodes.getByValue(e);
2155
- this.canvas.updateNode(r), this.model.getNodeAdjacentEdgeIds(r).forEach((n) => {
2156
- this.canvas.updateEdge(n);
2246
+ this.canvas.updateNode(r), this.model.getNodeAdjacentEdgeIds(r).forEach((s) => {
2247
+ this.canvas.updateEdge(s);
2157
2248
  });
2158
2249
  }
2159
2250
  }
2160
- class Ye {
2251
+ class je {
2161
2252
  constructor() {
2162
2253
  i(this, "coreOptions", {});
2163
2254
  i(this, "dragOptions");
@@ -2165,10 +2256,17 @@ class Ye {
2165
2256
  i(this, "hasDraggableNode", !1);
2166
2257
  i(this, "hasTransformableViewport", !1);
2167
2258
  i(this, "hasResizeReactiveNodes", !1);
2259
+ i(this, "boxRenderingTrigger", null);
2168
2260
  }
2261
+ /**
2262
+ * specifies options for fundamental aspects of visualization
2263
+ */
2169
2264
  setOptions(e) {
2170
2265
  return this.coreOptions = e, this;
2171
2266
  }
2267
+ /**
2268
+ * enables nodes draggable bu user
2269
+ */
2172
2270
  setUserDraggableNodes(e) {
2173
2271
  return this.hasDraggableNode = !0, this.dragOptions = e, this;
2174
2272
  }
@@ -2179,32 +2277,48 @@ class Ye {
2179
2277
  setUserTransformableCanvas(e) {
2180
2278
  return this.setUserTransformableViewport(e);
2181
2279
  }
2280
+ /**
2281
+ * enables viewport transformable by user
2282
+ */
2182
2283
  setUserTransformableViewport(e) {
2183
2284
  return this.hasTransformableViewport = !0, this.transformOptions = e, this;
2184
2285
  }
2286
+ /**
2287
+ * enables automatic edges update on node resize
2288
+ */
2185
2289
  setResizeReactiveNodes() {
2186
2290
  return this.hasResizeReactiveNodes = !0, this;
2187
2291
  }
2292
+ /**
2293
+ * sets emitter for rendering graph inside bounded area
2294
+ */
2295
+ setBoxRenderingTrigger(e) {
2296
+ return this.boxRenderingTrigger = e, this;
2297
+ }
2298
+ /**
2299
+ * builds final canvas
2300
+ */
2188
2301
  build() {
2189
- const e = new be(this.coreOptions);
2190
- let r = new Ce(e);
2191
- return this.hasResizeReactiveNodes && (r = new Fe(r)), this.hasDraggableNode && (r = new Pe(r, this.dragOptions)), this.hasTransformableViewport && (r = new We(
2192
- r,
2302
+ const e = this.boxRenderingTrigger !== null ? De(this.boxRenderingTrigger) : Ve, r = new Me(this.coreOptions, e);
2303
+ let o = new Te(r);
2304
+ return this.hasResizeReactiveNodes && (o = new Xe(o)), this.hasDraggableNode && (o = new $e(o, this.dragOptions)), this.hasTransformableViewport && (o = new ke(
2305
+ o,
2193
2306
  this.transformOptions
2194
- )), r;
2307
+ )), o;
2195
2308
  }
2196
2309
  }
2197
2310
  export {
2198
- q as BezierEdgeShape,
2199
- Ye as CanvasBuilder,
2200
- ke as CanvasCore,
2201
- O as HorizontalEdgeShape,
2202
- Ye as HtmlGraphBuilder,
2203
- x as HtmlGraphError,
2204
- Fe as ResizeReactiveNodesCanvas,
2205
- ee as StraightEdgeShape,
2206
- Pe as UserDraggableNodesCanvas,
2207
- We as UserTransformableCanvas,
2208
- We as UserTransformableViewportCanvas,
2209
- te as VerticalEdgeShape
2311
+ O as BezierEdgeShape,
2312
+ je as CanvasBuilder,
2313
+ Ge as CanvasCore,
2314
+ Ae as EventSubject,
2315
+ ee as HorizontalEdgeShape,
2316
+ je as HtmlGraphBuilder,
2317
+ A as HtmlGraphError,
2318
+ Xe as ResizeReactiveNodesCanvas,
2319
+ te as StraightEdgeShape,
2320
+ $e as UserDraggableNodesCanvas,
2321
+ ke as UserTransformableCanvas,
2322
+ ke as UserTransformableViewportCanvas,
2323
+ re as VerticalEdgeShape
2210
2324
  };