@html-graph/html-graph 0.1.5 → 0.1.6

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,70 +1,70 @@
1
- var K = Object.defineProperty;
2
- var _ = (e, t, o) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
- var n = (e, t, o) => _(e, typeof t != "symbol" ? t + "" : t, o);
4
- const J = (e, t) => ({
1
+ var Q = Object.defineProperty;
2
+ var Z = (e, t, o) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var n = (e, t, o) => Z(e, typeof t != "symbol" ? t + "" : t, o);
4
+ const O = (e, t) => ({
5
5
  x: e / 2,
6
6
  y: t / 2
7
7
  }), v = (e, t, o) => ({
8
8
  x: t.x * e.x - t.y * e.y + ((1 - t.x) * o.x + t.y * o.y),
9
9
  y: t.y * e.x + t.x * e.y + ((1 - t.x) * o.y - t.y * o.x)
10
- }), A = (e, t, o) => ({ x: t * Math.cos(e), y: o * Math.sin(e) }), w = {
10
+ }), M = (e, t, o) => ({ x: t * Math.cos(e), y: o * Math.sin(e) }), w = {
11
11
  x: 0,
12
12
  y: 0
13
- }, T = (e, t, o, r) => {
13
+ }, C = (e, t, o, r) => {
14
14
  const s = [
15
15
  w,
16
16
  { x: o, y: r },
17
17
  { x: o, y: -r }
18
- ].map((l) => v(l, e, w)).map((l) => ({ x: l.x + t.x, y: l.y + t.y })), h = `M ${s[0].x} ${s[0].y}`, c = `L ${s[1].x} ${s[1].y}`, d = `L ${s[2].x} ${s[2].y}`;
19
- return `${h} ${c} ${d}`;
20
- }, P = (e, t) => {
18
+ ].map((l) => v(l, e, w)).map((l) => ({ x: l.x + t.x, y: l.y + t.y })), h = `M ${s[0].x} ${s[0].y}`, d = `L ${s[1].x} ${s[1].y}`, c = `L ${s[2].x} ${s[2].y}`;
19
+ return `${h} ${d} ${c}`;
20
+ }, $ = (e, t) => {
21
21
  const o = [];
22
22
  if (e.length > 0 && o.push(`M ${e[0].x} ${e[0].y}`), e.length === 2 && o.push(`L ${e[1].x} ${e[1].y}`), e.length > 2) {
23
23
  const r = e.length - 1;
24
24
  let i = 0, s = 0, h = 0;
25
- e.forEach((c, d) => {
25
+ e.forEach((d, c) => {
26
26
  let l = 0, a = 0, g = 0;
27
- const y = d > 0, x = d < r, f = y && x;
27
+ const y = c > 0, x = c < r, f = y && x;
28
28
  if (y && (l = -i, a = -s, g = h), x) {
29
- const z = e[d + 1];
30
- i = z.x - c.x, s = z.y - c.y, h = Math.sqrt(i * i + s * s);
29
+ const I = e[c + 1];
30
+ i = I.x - d.x, s = I.y - d.y, h = Math.sqrt(i * i + s * s);
31
31
  }
32
- const E = h !== 0 ? Math.min((f ? t : 0) / h, d < r - 1 ? 0.5 : 1) : 0, N = f ? { x: c.x + i * E, y: c.y + s * E } : c, k = g !== 0 ? Math.min((f ? t : 0) / g, d > 1 ? 0.5 : 1) : 0, B = f ? { x: c.x + l * k, y: c.y + a * k } : c;
33
- d > 0 && o.push(`L ${B.x} ${B.y}`), f && o.push(
34
- `C ${c.x} ${c.y} ${c.x} ${c.y} ${N.x} ${N.y}`
32
+ const S = h !== 0 ? Math.min((f ? t : 0) / h, c < r - 1 ? 0.5 : 1) : 0, T = f ? { x: d.x + i * S, y: d.y + s * S } : d, P = g !== 0 ? Math.min((f ? t : 0) / g, c > 1 ? 0.5 : 1) : 0, D = f ? { x: d.x + l * P, y: d.y + a * P } : d;
33
+ c > 0 && o.push(`L ${D.x} ${D.y}`), f && o.push(
34
+ `C ${d.x} ${d.y} ${d.x} ${d.y} ${T.x} ${T.y}`
35
35
  );
36
36
  });
37
37
  }
38
38
  return o.join(" ");
39
- }, $ = () => {
39
+ }, W = () => {
40
40
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
41
41
  return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e;
42
- }, p = () => {
42
+ }, F = () => {
43
43
  const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
44
44
  return e.style.transformOrigin = "50% 50%", e;
45
- }, b = (e, t) => {
45
+ }, R = (e, t) => {
46
46
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
47
47
  return o.setAttribute("stroke", e), o.setAttribute("stroke-width", `${t}`), o.setAttribute("fill", "none"), o;
48
- }, M = (e) => {
48
+ }, N = (e) => {
49
49
  const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
50
50
  return t.setAttribute("fill", e), t;
51
- }, V = (e, t) => {
51
+ }, Y = (e, t) => {
52
52
  const o = {
53
53
  x: e.x + e.width / 2,
54
54
  y: e.y + e.height / 2
55
55
  }, r = {
56
56
  x: t.x + t.width / 2,
57
57
  y: t.y + t.height / 2
58
- }, i = Math.min(o.x, r.x), s = Math.min(o.y, r.y), h = Math.abs(r.x - o.x), c = Math.abs(r.y - o.y), d = o.x <= r.x ? 1 : -1, l = o.y <= r.y ? 1 : -1;
58
+ }, i = Math.min(o.x, r.x), s = Math.min(o.y, r.y), h = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, l = o.y <= r.y ? 1 : -1;
59
59
  return {
60
60
  x: i,
61
61
  y: s,
62
62
  width: h,
63
- height: c,
64
- flipX: d,
63
+ height: d,
64
+ flipX: c,
65
65
  flipY: l
66
66
  };
67
- }, Q = (e) => {
67
+ }, q = (e) => {
68
68
  const t = v(
69
69
  { x: e.arrowLength, y: w.y },
70
70
  e.fromVect,
@@ -79,9 +79,9 @@ const J = (e, t) => ({
79
79
  }, i = {
80
80
  x: o.x - e.toVect.x * e.curvature,
81
81
  y: o.y - e.toVect.y * e.curvature
82
- }, s = `M ${t.x} ${t.y} C ${r.x} ${r.y}, ${i.x} ${i.y}, ${o.x} ${o.y}`, h = e.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${t.x} ${t.y} `, c = e.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;
83
- return `${h}${s}${c}`;
84
- }, Z = (e) => {
82
+ }, s = `M ${t.x} ${t.y} C ${r.x} ${r.y}, ${i.x} ${i.y}, ${o.x} ${o.y}`, h = e.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${t.x} ${t.y} `, d = e.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;
83
+ return `${h}${s}${d}`;
84
+ }, tt = (e) => {
85
85
  const t = e.hasSourceArrow ? v(
86
86
  { x: e.arrowLength, y: w.y },
87
87
  e.fromVect,
@@ -90,41 +90,41 @@ const J = (e, t) => ({
90
90
  { x: e.to.x - e.arrowLength, y: e.to.y },
91
91
  e.toVect,
92
92
  e.to
93
- ) : e.to, r = e.arrowLength, i = Math.cos(e.detourDirection) * e.detourDistance, s = Math.sin(e.detourDirection) * e.detourDistance, h = i * e.flipX, c = s * e.flipY, d = v(
93
+ ) : e.to, r = e.arrowLength, i = Math.cos(e.detourDirection) * e.detourDistance, s = Math.sin(e.detourDirection) * e.detourDistance, h = i * e.flipX, d = s * e.flipY, c = v(
94
94
  { x: r, y: w.y },
95
95
  e.fromVect,
96
96
  w
97
97
  ), l = {
98
- x: d.x + h,
99
- y: d.y + c
98
+ x: c.x + h,
99
+ y: c.y + d
100
100
  }, a = v(
101
101
  { x: e.to.x - r, y: e.to.y },
102
102
  e.toVect,
103
103
  e.to
104
104
  ), g = {
105
105
  x: a.x + h,
106
- y: a.y + c
106
+ y: a.y + d
107
107
  }, y = { x: (l.x + g.x) / 2, y: (l.y + g.y) / 2 }, x = {
108
- x: d.x + e.curvature * e.fromVect.x,
109
- y: d.y + e.curvature * e.fromVect.y
108
+ x: c.x + e.curvature * e.fromVect.x,
109
+ y: c.y + e.curvature * e.fromVect.y
110
110
  }, f = {
111
111
  x: a.x - e.curvature * e.toVect.x,
112
112
  y: a.y - e.curvature * e.toVect.y
113
- }, C = {
114
- x: d.x + h,
115
- y: d.y + c
116
- }, E = {
113
+ }, A = {
114
+ x: c.x + h,
115
+ y: c.y + d
116
+ }, S = {
117
117
  x: a.x + h,
118
- y: a.y + c
118
+ y: a.y + d
119
119
  };
120
120
  return [
121
121
  `M ${t.x} ${t.y}`,
122
- `L ${d.x} ${d.y}`,
123
- `C ${x.x} ${x.y} ${C.x} ${C.y} ${y.x} ${y.y}`,
124
- `C ${E.x} ${E.y} ${f.x} ${f.y} ${a.x} ${a.y}`,
122
+ `L ${c.x} ${c.y}`,
123
+ `C ${x.x} ${x.y} ${A.x} ${A.y} ${y.x} ${y.y}`,
124
+ `C ${S.x} ${S.y} ${f.x} ${f.y} ${a.x} ${a.y}`,
125
125
  `L ${o.x} ${o.y}`
126
126
  ].join(" ");
127
- }, O = (e) => {
127
+ }, et = (e) => {
128
128
  const t = e.hasSourceArrow ? v(
129
129
  { x: e.arrowLength, y: w.y },
130
130
  e.fromVect,
@@ -137,15 +137,15 @@ const J = (e, t) => ({
137
137
  { x: e.to.x - i, y: e.to.y },
138
138
  e.toVect,
139
139
  e.to
140
- ), c = Math.max((s.x + h.x) / 2, r), d = e.to.y / 2, l = { x: e.flipX > 0 ? c : -r, y: s.y }, a = { x: l.x, y: d }, g = {
141
- x: e.flipX > 0 ? e.to.x - c : e.to.x + r,
140
+ ), d = Math.max((s.x + h.x) / 2, r), c = e.to.y / 2, l = { x: e.flipX > 0 ? d : -r, y: s.y }, a = { x: l.x, y: c }, g = {
141
+ x: e.flipX > 0 ? e.to.x - d : e.to.x + r,
142
142
  y: h.y
143
- }, y = { x: g.x, y: d };
144
- return P(
143
+ }, y = { x: g.x, y: c };
144
+ return $(
145
145
  [t, s, l, a, y, g, h, o],
146
146
  e.roundness
147
147
  );
148
- }, Y = (e) => {
148
+ }, G = (e) => {
149
149
  const t = e.hasSourceArrow ? v(
150
150
  { x: e.arrowLength, y: w.y },
151
151
  e.fromVect,
@@ -158,16 +158,16 @@ const J = (e, t) => ({
158
158
  { x: r, y: w.y },
159
159
  e.fromVect,
160
160
  w
161
- ), s = Math.cos(e.detourDirection) * e.detourDistance, h = Math.sin(e.detourDirection) * e.detourDistance, c = s * e.flipX, d = h * e.flipY, l = { x: i.x + c, y: i.y + d }, a = v(
161
+ ), s = Math.cos(e.detourDirection) * e.detourDistance, h = Math.sin(e.detourDirection) * e.detourDistance, d = s * e.flipX, c = h * e.flipY, l = { x: i.x + d, y: i.y + c }, a = v(
162
162
  { x: e.to.x - r, y: e.to.y },
163
163
  e.toVect,
164
164
  e.to
165
- ), g = { x: a.x + c, y: a.y + d };
166
- return P(
165
+ ), g = { x: a.x + d, y: a.y + c };
166
+ return $(
167
167
  [t, i, l, g, a, o],
168
168
  e.roundness
169
169
  );
170
- }, q = (e) => {
170
+ }, ot = (e) => {
171
171
  const t = e.hasSourceArrow ? v(
172
172
  { x: e.arrowLength, y: w.y },
173
173
  e.fromVect,
@@ -181,8 +181,8 @@ const J = (e, t) => ({
181
181
  e.toVect,
182
182
  e.to
183
183
  );
184
- return P([t, i, s, o], e.roundness);
185
- }, tt = (e) => {
184
+ return $([t, i, s, o], e.roundness);
185
+ }, rt = (e) => {
186
186
  const t = e.hasSourceArrow ? v(
187
187
  { x: e.arrowLength, y: w.y },
188
188
  e.fromVect,
@@ -195,15 +195,15 @@ const J = (e, t) => ({
195
195
  { x: e.to.x - i, y: e.to.y },
196
196
  e.toVect,
197
197
  e.to
198
- ), c = Math.max((s.y + h.y) / 2, r), d = e.to.x / 2, l = { x: s.x, y: e.flipY > 0 ? c : -r }, a = { x: d, y: l.y }, g = {
198
+ ), d = Math.max((s.y + h.y) / 2, r), c = e.to.x / 2, l = { x: s.x, y: e.flipY > 0 ? d : -r }, a = { x: c, y: l.y }, g = {
199
199
  x: h.x,
200
- y: e.flipY > 0 ? e.to.y - c : e.to.y + r
201
- }, y = { x: d, y: g.y };
202
- return P(
200
+ y: e.flipY > 0 ? e.to.y - d : e.to.y + r
201
+ }, y = { x: c, y: g.y };
202
+ return $(
203
203
  [t, s, l, a, y, g, h, o],
204
204
  e.roundness
205
205
  );
206
- }, X = (e) => {
206
+ }, U = (e) => {
207
207
  const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, i = r + 2 * o, h = [
208
208
  { x: e.arrowLength, y: w.y },
209
209
  { x: r, y: w.y },
@@ -214,23 +214,23 @@ const J = (e, t) => ({
214
214
  { x: r, y: w.y },
215
215
  { x: e.arrowLength, y: w.y }
216
216
  ].map(
217
- (d) => v(d, e.fromVect, w)
218
- ), c = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
219
- return `${e.hasSourceArrow || e.hasTargetArrow ? "" : c}${P(h, e.roundness)}`;
220
- }, et = (e) => {
221
- const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), i = t + o, s = e.arrowLength + r * (1 - o / i), h = t * o / i, d = [
217
+ (c) => v(c, e.fromVect, w)
218
+ ), d = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
219
+ return `${e.hasSourceArrow || e.hasTargetArrow ? "" : d}${$(h, e.roundness)}`;
220
+ }, it = (e) => {
221
+ const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), i = t + o, s = e.arrowLength + r * (1 - o / i), h = t * o / i, c = [
222
222
  { x: e.arrowLength, y: w.y },
223
223
  { x: s, y: h },
224
224
  { x: s, y: -h }
225
225
  ].map((g) => v(g, e.fromVect, w)), l = [
226
- `M ${d[0].x} ${d[0].y}`,
227
- `A ${t} ${t} 0 0 1 ${d[1].x} ${d[1].y}`,
228
- `A ${o} ${o} 0 1 0 ${d[2].x} ${d[2].y}`,
229
- `A ${t} ${t} 0 0 1 ${d[0].x} ${d[0].y}`
230
- ].join(" "), a = `M 0 0 L ${d[0].x} ${d[0].y} `;
226
+ `M ${c[0].x} ${c[0].y}`,
227
+ `A ${t} ${t} 0 0 1 ${c[1].x} ${c[1].y}`,
228
+ `A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
229
+ `A ${t} ${t} 0 0 1 ${c[0].x} ${c[0].y}`
230
+ ].join(" "), a = `M 0 0 L ${c[0].x} ${c[0].y} `;
231
231
  return `${e.hasSourceArrow || e.hasTargetArrow ? "" : a}${l}`;
232
232
  }, u = Object.freeze({
233
- color: "#5c5c5c",
233
+ color: "#777777",
234
234
  width: 1,
235
235
  arrowLength: 15,
236
236
  arrowWidth: 4,
@@ -246,10 +246,10 @@ const J = (e, t) => ({
246
246
  smallCycleRadius: 15,
247
247
  curvature: 90
248
248
  });
249
- class ot {
249
+ class nt {
250
250
  constructor(t) {
251
- n(this, "svg", $());
252
- n(this, "group", p());
251
+ n(this, "svg", W());
252
+ n(this, "group", F());
253
253
  n(this, "line");
254
254
  n(this, "sourceArrow", null);
255
255
  n(this, "targetArrow", null);
@@ -264,57 +264,57 @@ class ot {
264
264
  n(this, "hasTargetArrow");
265
265
  this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.curvature = (t == null ? void 0 : t.curvature) ?? u.curvature, this.portCycleRadius = (t == null ? void 0 : t.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (t == null ? void 0 : t.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
266
266
  const o = (t == null ? void 0 : t.color) ?? u.color, r = (t == null ? void 0 : t.width) ?? u.width;
267
- this.svg.appendChild(this.group), this.line = b(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(o), this.group.appendChild(this.targetArrow));
267
+ this.svg.appendChild(this.group), this.line = R(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(o), this.group.appendChild(this.targetArrow));
268
268
  }
269
269
  render(t) {
270
- const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
270
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = Y(
271
271
  t.source,
272
272
  t.target
273
273
  );
274
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${c})`;
275
- const d = A(
274
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
275
+ const c = M(
276
276
  t.source.direction,
277
277
  h,
278
- c
279
- ), l = A(
278
+ d
279
+ ), l = M(
280
280
  t.target.direction,
281
281
  h,
282
- c
282
+ d
283
283
  ), a = {
284
284
  x: i,
285
285
  y: s
286
286
  };
287
287
  let g, y = l, x = -this.arrowLength;
288
- if (t.source.portId === t.target.portId ? (g = et({
289
- fromVect: d,
288
+ if (t.source.portId === t.target.portId ? (g = it({
289
+ fromVect: c,
290
290
  radius: this.portCycleRadius,
291
291
  smallRadius: this.portCycleSmallRadius,
292
292
  arrowLength: this.arrowLength,
293
293
  hasSourceArrow: this.hasSourceArrow,
294
294
  hasTargetArrow: this.hasTargetArrow
295
- }), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Z({
295
+ }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = tt({
296
296
  to: a,
297
- fromVect: d,
297
+ fromVect: c,
298
298
  toVect: l,
299
299
  flipX: h,
300
- flipY: c,
300
+ flipY: d,
301
301
  arrowLength: this.arrowLength,
302
302
  detourDirection: this.detourDirection,
303
303
  detourDistance: this.detourDistance,
304
304
  curvature: this.curvature,
305
305
  hasSourceArrow: this.hasSourceArrow,
306
306
  hasTargetArrow: this.hasTargetArrow
307
- }) : g = Q({
307
+ }) : g = q({
308
308
  to: a,
309
- fromVect: d,
309
+ fromVect: c,
310
310
  toVect: l,
311
311
  arrowLength: this.arrowLength,
312
312
  curvature: this.curvature,
313
313
  hasSourceArrow: this.hasSourceArrow,
314
314
  hasTargetArrow: this.hasTargetArrow
315
315
  }), this.line.setAttribute("d", g), this.sourceArrow) {
316
- const f = T(
317
- d,
316
+ const f = C(
317
+ c,
318
318
  w,
319
319
  this.arrowLength,
320
320
  this.arrowWidth
@@ -322,7 +322,7 @@ class ot {
322
322
  this.sourceArrow.setAttribute("d", f);
323
323
  }
324
324
  if (this.targetArrow) {
325
- const f = T(
325
+ const f = C(
326
326
  y,
327
327
  a,
328
328
  x,
@@ -332,10 +332,10 @@ class ot {
332
332
  }
333
333
  }
334
334
  }
335
- class rt {
335
+ class st {
336
336
  constructor(t) {
337
- n(this, "svg", $());
338
- n(this, "group", p());
337
+ n(this, "svg", W());
338
+ n(this, "group", F());
339
339
  n(this, "line");
340
340
  n(this, "sourceArrow", null);
341
341
  n(this, "targetArrow", null);
@@ -356,41 +356,41 @@ class rt {
356
356
  this.cycleSquareSide / 2
357
357
  ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
358
358
  const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
359
- this.svg.appendChild(this.group), this.line = b(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
359
+ this.svg.appendChild(this.group), this.line = R(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
360
360
  }
361
361
  render(t) {
362
- const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
362
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = Y(
363
363
  t.source,
364
364
  t.target
365
365
  );
366
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${c})`;
367
- const d = A(
366
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
367
+ const c = M(
368
368
  t.source.direction,
369
369
  h,
370
- c
371
- ), l = A(
370
+ d
371
+ ), l = M(
372
372
  t.target.direction,
373
373
  h,
374
- c
374
+ d
375
375
  ), a = {
376
376
  x: i,
377
377
  y: s
378
378
  };
379
379
  let g, y = l, x = -this.arrowLength;
380
- if (t.source.portId === t.target.portId ? (g = X({
381
- fromVect: d,
380
+ if (t.source.portId === t.target.portId ? (g = U({
381
+ fromVect: c,
382
382
  arrowLength: this.arrowLength,
383
383
  side: this.cycleSquareSide,
384
384
  arrowOffset: this.arrowOffset,
385
385
  roundness: this.roundness,
386
386
  hasSourceArrow: this.hasSourceArrow,
387
387
  hasTargetArrow: this.hasTargetArrow
388
- }), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Y({
388
+ }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = G({
389
389
  to: a,
390
- fromVect: d,
390
+ fromVect: c,
391
391
  toVect: l,
392
392
  flipX: h,
393
- flipY: c,
393
+ flipY: d,
394
394
  arrowLength: this.arrowLength,
395
395
  arrowOffset: this.arrowOffset,
396
396
  roundness: this.roundness,
@@ -398,9 +398,9 @@ class rt {
398
398
  detourDistance: this.detourDistance,
399
399
  hasSourceArrow: this.hasSourceArrow,
400
400
  hasTargetArrow: this.hasTargetArrow
401
- }) : g = O({
401
+ }) : g = et({
402
402
  to: a,
403
- fromVect: d,
403
+ fromVect: c,
404
404
  toVect: l,
405
405
  flipX: h,
406
406
  arrowLength: this.arrowLength,
@@ -409,8 +409,8 @@ class rt {
409
409
  hasSourceArrow: this.hasSourceArrow,
410
410
  hasTargetArrow: this.hasTargetArrow
411
411
  }), this.line.setAttribute("d", g), this.sourceArrow) {
412
- const f = T(
413
- d,
412
+ const f = C(
413
+ c,
414
414
  w,
415
415
  this.arrowLength,
416
416
  this.arrowWidth
@@ -418,7 +418,7 @@ class rt {
418
418
  this.sourceArrow.setAttribute("d", f);
419
419
  }
420
420
  if (this.targetArrow) {
421
- const f = T(
421
+ const f = C(
422
422
  y,
423
423
  a,
424
424
  x,
@@ -428,10 +428,10 @@ class rt {
428
428
  }
429
429
  }
430
430
  }
431
- class it {
431
+ class ht {
432
432
  constructor(t) {
433
- n(this, "svg", $());
434
- n(this, "group", p());
433
+ n(this, "svg", W());
434
+ n(this, "group", F());
435
435
  n(this, "line");
436
436
  n(this, "sourceArrow", null);
437
437
  n(this, "targetArrow", null);
@@ -452,41 +452,41 @@ class it {
452
452
  this.cycleSquareSide / 2
453
453
  ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
454
454
  const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
455
- this.svg.appendChild(this.group), this.line = b(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
455
+ this.svg.appendChild(this.group), this.line = R(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
456
456
  }
457
457
  render(t) {
458
- const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
458
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = Y(
459
459
  t.source,
460
460
  t.target
461
461
  );
462
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${c})`;
463
- const d = A(
462
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
463
+ const c = M(
464
464
  t.source.direction,
465
465
  h,
466
- c
467
- ), l = A(
466
+ d
467
+ ), l = M(
468
468
  t.target.direction,
469
469
  h,
470
- c
470
+ d
471
471
  ), a = {
472
472
  x: i,
473
473
  y: s
474
474
  };
475
475
  let g, y = l, x = -this.arrowLength;
476
- if (t.source.portId === t.target.portId ? (g = X({
477
- fromVect: d,
476
+ if (t.source.portId === t.target.portId ? (g = U({
477
+ fromVect: c,
478
478
  arrowLength: this.arrowLength,
479
479
  side: this.cycleSquareSide,
480
480
  arrowOffset: this.arrowOffset,
481
481
  roundness: this.roundness,
482
482
  hasSourceArrow: this.hasSourceArrow,
483
483
  hasTargetArrow: this.hasTargetArrow
484
- }), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Y({
484
+ }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = G({
485
485
  to: a,
486
- fromVect: d,
486
+ fromVect: c,
487
487
  toVect: l,
488
488
  flipX: h,
489
- flipY: c,
489
+ flipY: d,
490
490
  arrowLength: this.arrowLength,
491
491
  arrowOffset: this.arrowOffset,
492
492
  roundness: this.roundness,
@@ -494,9 +494,9 @@ class it {
494
494
  detourDistance: this.detourDistance,
495
495
  hasSourceArrow: this.hasSourceArrow,
496
496
  hasTargetArrow: this.hasTargetArrow
497
- }) : g = q({
497
+ }) : g = ot({
498
498
  to: a,
499
- fromVect: d,
499
+ fromVect: c,
500
500
  toVect: l,
501
501
  arrowLength: this.arrowLength,
502
502
  arrowOffset: this.arrowOffset,
@@ -504,8 +504,8 @@ class it {
504
504
  hasSourceArrow: this.hasSourceArrow,
505
505
  hasTargetArrow: this.hasTargetArrow
506
506
  }), this.line.setAttribute("d", g), this.sourceArrow) {
507
- const f = T(
508
- d,
507
+ const f = C(
508
+ c,
509
509
  w,
510
510
  this.arrowLength,
511
511
  this.arrowWidth
@@ -513,7 +513,7 @@ class it {
513
513
  this.sourceArrow.setAttribute("d", f);
514
514
  }
515
515
  if (this.targetArrow) {
516
- const f = T(
516
+ const f = C(
517
517
  y,
518
518
  a,
519
519
  x,
@@ -523,10 +523,10 @@ class it {
523
523
  }
524
524
  }
525
525
  }
526
- class nt {
526
+ class dt {
527
527
  constructor(t) {
528
- n(this, "svg", $());
529
- n(this, "group", p());
528
+ n(this, "svg", W());
529
+ n(this, "group", F());
530
530
  n(this, "line");
531
531
  n(this, "sourceArrow", null);
532
532
  n(this, "targetArrow", null);
@@ -547,41 +547,41 @@ class nt {
547
547
  this.cycleSquareSide / 2
548
548
  ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
549
549
  const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
550
- this.svg.appendChild(this.group), this.line = b(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
550
+ this.svg.appendChild(this.group), this.line = R(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
551
551
  }
552
552
  render(t) {
553
- const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
553
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = Y(
554
554
  t.source,
555
555
  t.target
556
556
  );
557
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${c})`;
558
- const d = A(
557
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
558
+ const c = M(
559
559
  t.source.direction,
560
560
  h,
561
- c
562
- ), l = A(
561
+ d
562
+ ), l = M(
563
563
  t.target.direction,
564
564
  h,
565
- c
565
+ d
566
566
  ), a = {
567
567
  x: i,
568
568
  y: s
569
569
  };
570
570
  let g, y = l, x = -this.arrowLength;
571
- if (t.source.portId === t.target.portId ? (g = X({
572
- fromVect: d,
571
+ if (t.source.portId === t.target.portId ? (g = U({
572
+ fromVect: c,
573
573
  arrowLength: this.arrowLength,
574
574
  side: this.cycleSquareSide,
575
575
  arrowOffset: this.arrowOffset,
576
576
  roundness: this.roundness,
577
577
  hasSourceArrow: this.hasSourceArrow,
578
578
  hasTargetArrow: this.hasTargetArrow
579
- }), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Y({
579
+ }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = G({
580
580
  to: a,
581
- fromVect: d,
581
+ fromVect: c,
582
582
  toVect: l,
583
583
  flipX: h,
584
- flipY: c,
584
+ flipY: d,
585
585
  arrowLength: this.arrowLength,
586
586
  arrowOffset: this.arrowOffset,
587
587
  roundness: this.roundness,
@@ -589,19 +589,19 @@ class nt {
589
589
  detourDistance: this.detourDistance,
590
590
  hasSourceArrow: this.hasSourceArrow,
591
591
  hasTargetArrow: this.hasTargetArrow
592
- }) : g = tt({
592
+ }) : g = rt({
593
593
  to: a,
594
- fromVect: d,
594
+ fromVect: c,
595
595
  toVect: l,
596
- flipY: c,
596
+ flipY: d,
597
597
  arrowLength: this.arrowLength,
598
598
  arrowOffset: this.arrowOffset,
599
599
  roundness: this.roundness,
600
600
  hasSourceArrow: this.hasSourceArrow,
601
601
  hasTargetArrow: this.hasTargetArrow
602
602
  }), this.line.setAttribute("d", g), this.sourceArrow) {
603
- const f = T(
604
- d,
603
+ const f = C(
604
+ c,
605
605
  w,
606
606
  this.arrowLength,
607
607
  this.arrowWidth
@@ -609,7 +609,7 @@ class nt {
609
609
  this.sourceArrow.setAttribute("d", f);
610
610
  }
611
611
  if (this.targetArrow) {
612
- const f = T(
612
+ const f = C(
613
613
  y,
614
614
  a,
615
615
  x,
@@ -619,12 +619,12 @@ class nt {
619
619
  }
620
620
  }
621
621
  }
622
- const st = (e) => {
622
+ const ct = (e) => {
623
623
  if (typeof e == "function")
624
624
  return e;
625
625
  switch (e == null ? void 0 : e.type) {
626
626
  case "straight":
627
- return () => new it({
627
+ return () => new ht({
628
628
  color: e.color,
629
629
  width: e.width,
630
630
  arrowLength: e.arrowLength,
@@ -638,7 +638,7 @@ const st = (e) => {
638
638
  detourDirection: e.detourDirection
639
639
  });
640
640
  case "horizontal":
641
- return () => new rt({
641
+ return () => new st({
642
642
  color: e.color,
643
643
  width: e.width,
644
644
  arrowLength: e.arrowLength,
@@ -652,7 +652,7 @@ const st = (e) => {
652
652
  detourDirection: e.detourDirection
653
653
  });
654
654
  case "vertical":
655
- return () => new nt({
655
+ return () => new dt({
656
656
  color: e.color,
657
657
  width: e.width,
658
658
  arrowLength: e.arrowLength,
@@ -666,7 +666,7 @@ const st = (e) => {
666
666
  detourDirection: e.detourDirection
667
667
  });
668
668
  default:
669
- return () => new ot({
669
+ return () => new nt({
670
670
  color: e.color,
671
671
  width: e.width,
672
672
  arrowLength: e.arrowLength,
@@ -680,38 +680,38 @@ const st = (e) => {
680
680
  detourDirection: e.detourDirection
681
681
  });
682
682
  }
683
- }, R = (e) => () => e, G = R(0), W = () => {
683
+ }, z = (e) => () => e, H = z(0), k = () => {
684
684
  let e = 0;
685
685
  return () => e++;
686
- }, ht = (e, t) => {
687
- let o = G, r = G;
688
- e === "incremental" && (o = W()), t === "incremental" && (r = W());
689
- const i = W();
690
- return e === "shared-incremental" && (o = i), t === "shared-incremental" && (r = i), typeof e == "number" && (o = R(e)), typeof t == "number" && (r = R(t)), typeof e == "function" && (o = e), typeof t == "function" && (r = t), {
686
+ }, lt = (e, t) => {
687
+ let o = H, r = H;
688
+ e === "incremental" && (o = k()), t === "incremental" && (r = k());
689
+ const i = k();
690
+ return e === "shared-incremental" && (o = i), t === "shared-incremental" && (r = i), typeof e == "number" && (o = z(e)), typeof t == "number" && (r = z(t)), typeof e == "function" && (o = e), typeof t == "function" && (r = t), {
691
691
  nodesPriorityFn: o,
692
692
  edgesPriorityFn: r
693
693
  };
694
- }, ct = (e) => {
694
+ }, at = (e) => {
695
695
  var o, r, i, s, h;
696
- const t = ht(
696
+ const t = lt(
697
697
  (o = e == null ? void 0 : e.nodes) == null ? void 0 : o.priority,
698
698
  (r = e == null ? void 0 : e.edges) == null ? void 0 : r.priority
699
699
  );
700
700
  return {
701
701
  nodes: {
702
- centerFn: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ?? J,
702
+ centerFn: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ?? O,
703
703
  priorityFn: t.nodesPriorityFn
704
704
  },
705
705
  ports: {
706
706
  direction: ((s = e == null ? void 0 : e.ports) == null ? void 0 : s.direction) ?? 0
707
707
  },
708
708
  edges: {
709
- shapeFactory: st(((h = e == null ? void 0 : e.edges) == null ? void 0 : h.shape) ?? {}),
709
+ shapeFactory: ct(((h = e == null ? void 0 : e.edges) == null ? void 0 : h.shape) ?? {}),
710
710
  priorityFn: t.edgesPriorityFn
711
711
  }
712
712
  };
713
713
  };
714
- class dt {
714
+ class gt {
715
715
  constructor() {
716
716
  n(this, "nodes", /* @__PURE__ */ new Map());
717
717
  n(this, "ports", /* @__PURE__ */ new Map());
@@ -850,84 +850,19 @@ class dt {
850
850
  ];
851
851
  }
852
852
  }
853
- class lt {
854
- constructor(t) {
855
- this.graphStore = t;
856
- }
857
- getNode(t) {
858
- const o = this.graphStore.getNode(t);
859
- return o === void 0 ? null : {
860
- element: o.element,
861
- x: o.x,
862
- y: o.y,
863
- centerFn: o.centerFn,
864
- priority: o.priority
865
- };
866
- }
867
- getAllNodeIds() {
868
- return this.graphStore.getAllNodeIds();
869
- }
870
- getPort(t) {
871
- const o = this.graphStore.getPort(t);
872
- return o === void 0 ? null : {
873
- element: o.element,
874
- direction: o.direction
875
- };
876
- }
877
- getAllPortIds() {
878
- return this.graphStore.getAllPortIds();
879
- }
880
- getNodePortIds(t) {
881
- return this.graphStore.getNodePortIds(t);
882
- }
883
- getPortNodeId(t) {
884
- return this.graphStore.getPortNodeId(t) ?? null;
885
- }
886
- getAllEdgeIds() {
887
- return this.graphStore.getAllEdgeIds();
888
- }
889
- getEdge(t) {
890
- const o = this.graphStore.getEdge(t);
891
- return o === void 0 ? null : { from: o.from, to: o.to, priority: o.priority };
892
- }
893
- getPortIncomingEdgeIds(t) {
894
- return this.graphStore.getPortIncomingEdgeIds(t);
895
- }
896
- getPortOutcomingEdgeIds(t) {
897
- return this.graphStore.getPortOutcomingEdgeIds(t);
898
- }
899
- getPortCycleEdgeIds(t) {
900
- return this.graphStore.getPortCycleEdgeIds(t);
901
- }
902
- getPortAdjacentEdgeIds(t) {
903
- return this.graphStore.getPortAdjacentEdgeIds(t);
904
- }
905
- getNodeIncomingEdgeIds(t) {
906
- return this.graphStore.getNodeIncomingEdgeIds(t);
907
- }
908
- getNodeOutcomingEdgeIds(t) {
909
- return this.graphStore.getNodeOutcomingEdgeIds(t);
910
- }
911
- getNodeCycleEdgeIds(t) {
912
- return this.graphStore.getNodeCycleEdgeIds(t);
913
- }
914
- getNodeAdjacentEdgeIds(t) {
915
- return this.graphStore.getNodeAdjacentEdgeIds(t);
916
- }
917
- }
918
- const j = (e) => ({
853
+ const K = (e) => ({
919
854
  scale: 1 / e.scale,
920
855
  dx: -e.dx / e.scale,
921
856
  dy: -e.dy / e.scale
922
- }), H = {
857
+ }), _ = {
923
858
  scale: 1,
924
859
  dx: 0,
925
860
  dy: 0
926
861
  };
927
- class at {
862
+ class ut {
928
863
  constructor() {
929
- n(this, "viewportMatrix", H);
930
- n(this, "contentMatrix", H);
864
+ n(this, "viewportMatrix", _);
865
+ n(this, "contentMatrix", _);
931
866
  }
932
867
  getViewportMatrix() {
933
868
  return this.viewportMatrix;
@@ -940,17 +875,17 @@ class at {
940
875
  scale: t.scale ?? this.viewportMatrix.scale,
941
876
  dx: t.dx ?? this.viewportMatrix.dx,
942
877
  dy: t.dy ?? this.viewportMatrix.dy
943
- }, this.contentMatrix = j(this.viewportMatrix);
878
+ }, this.contentMatrix = K(this.viewportMatrix);
944
879
  }
945
880
  patchContentMatrix(t) {
946
881
  this.contentMatrix = {
947
882
  scale: t.scale ?? this.contentMatrix.scale,
948
883
  dx: t.dx ?? this.contentMatrix.dx,
949
884
  dy: t.dy ?? this.contentMatrix.dy
950
- }, this.viewportMatrix = j(this.contentMatrix);
885
+ }, this.viewportMatrix = K(this.contentMatrix);
951
886
  }
952
887
  }
953
- class gt {
888
+ class wt {
954
889
  constructor(t) {
955
890
  this.transformer = t;
956
891
  }
@@ -961,21 +896,21 @@ class gt {
961
896
  return { ...this.transformer.getContentMatrix() };
962
897
  }
963
898
  }
964
- const ut = () => {
899
+ const yt = () => {
965
900
  const e = document.createElement("div");
966
901
  return e.style.width = "100%", e.style.height = "100%", e.style.position = "relative", e.style.overflow = "hidden", e;
967
- }, wt = () => {
902
+ }, ft = () => {
968
903
  const e = document.createElement("div");
969
904
  return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.width = "0", e.style.height = "0", e;
970
- }, yt = () => {
905
+ }, vt = () => {
971
906
  const e = document.createElement("div");
972
907
  return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.visibility = "hidden", e;
973
908
  };
974
- class ft {
909
+ class xt {
975
910
  constructor(t, o) {
976
911
  n(this, "canvasWrapper", null);
977
- n(this, "host", ut());
978
- n(this, "container", wt());
912
+ n(this, "host", yt());
913
+ n(this, "container", ft());
979
914
  n(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
980
915
  n(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
981
916
  this.graphStore = t, this.viewportTransformer = o, this.host.appendChild(this.container);
@@ -991,7 +926,7 @@ class ft {
991
926
  this.container.style.transform = `matrix(${t.scale}, 0, 0, ${t.scale}, ${t.dx}, ${t.dy})`;
992
927
  }
993
928
  attachNode(t) {
994
- const o = this.graphStore.getNode(t), r = yt();
929
+ const o = this.graphStore.getNode(t), r = vt();
995
930
  r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(t, r), this.updateNodeCoordinates(t), this.updateNodePriority(t), r.style.visibility = "visible";
996
931
  }
997
932
  detachNode(t) {
@@ -1017,8 +952,8 @@ class ft {
1017
952
  this.clear(), this.detach(), this.host.removeChild(this.container);
1018
953
  }
1019
954
  updateNodeCoordinates(t) {
1020
- const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: i, height: s } = r.element.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix().scale, c = r.centerFn(i, s), d = r.x - h * c.x, l = r.y - h * c.y;
1021
- o.style.transform = `translate(${d}px, ${l}px)`;
955
+ const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: i, height: s } = r.element.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix().scale, d = r.centerFn(i, s), c = r.x - h * d.x, l = r.y - h * d.y;
956
+ o.style.transform = `translate(${c}px, ${l}px)`;
1022
957
  }
1023
958
  updateNodePriority(t) {
1024
959
  const o = this.graphStore.getNode(t), r = this.nodeIdToWrapperElementMap.get(t);
@@ -1031,25 +966,25 @@ class ft {
1031
966
  this.edgeIdToElementMap.set(t, r.shape.svg), this.container.appendChild(r.shape.svg);
1032
967
  }
1033
968
  renderEdge(t) {
1034
- const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from), i = this.graphStore.getPort(o.to), s = r.element.getBoundingClientRect(), h = i.element.getBoundingClientRect(), c = this.host.getBoundingClientRect(), d = this.viewportTransformer.getViewportMatrix(), l = {
1035
- x: d.scale * (s.left - c.left) + d.dx,
1036
- y: d.scale * (s.top - c.top) + d.dy
969
+ const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from), i = this.graphStore.getPort(o.to), s = r.element.getBoundingClientRect(), h = i.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix(), l = {
970
+ x: c.scale * (s.left - d.left) + c.dx,
971
+ y: c.scale * (s.top - d.top) + c.dy
1037
972
  }, a = {
1038
- x: d.scale * (h.left - c.left) + d.dx,
1039
- y: d.scale * (h.top - c.top) + d.dy
973
+ x: c.scale * (h.left - d.left) + c.dx,
974
+ y: c.scale * (h.top - d.top) + c.dy
1040
975
  }, g = {
1041
976
  x: l.x,
1042
977
  y: l.y,
1043
- width: s.width * d.scale,
1044
- height: s.height * d.scale,
978
+ width: s.width * c.scale,
979
+ height: s.height * c.scale,
1045
980
  direction: r.direction,
1046
981
  portId: o.from,
1047
982
  nodeId: this.graphStore.getPortNodeId(o.from)
1048
983
  }, y = {
1049
984
  x: a.x,
1050
985
  y: a.y,
1051
- width: h.width * d.scale,
1052
- height: h.height * d.scale,
986
+ width: h.width * c.scale,
987
+ height: h.height * c.scale,
1053
988
  direction: i.direction,
1054
989
  portId: o.to,
1055
990
  nodeId: this.graphStore.getPortNodeId(o.to)
@@ -1064,7 +999,7 @@ class ft {
1064
999
  o.shape.svg.style.zIndex = `${o.priority}`;
1065
1000
  }
1066
1001
  }
1067
- class L {
1002
+ class m {
1068
1003
  constructor(t) {
1069
1004
  n(this, "counter", 0);
1070
1005
  this.checkExists = t;
@@ -1080,24 +1015,24 @@ class L {
1080
1015
  this.counter = 0;
1081
1016
  }
1082
1017
  }
1083
- class S extends Error {
1018
+ class E extends Error {
1084
1019
  constructor() {
1085
1020
  super(...arguments);
1086
1021
  n(this, "name", "HtmlGraphError");
1087
1022
  }
1088
1023
  }
1089
- class vt {
1090
- constructor(t, o, r, i, s, h, c) {
1091
- n(this, "nodeIdGenerator", new L(
1024
+ class Et {
1025
+ constructor(t, o, r, i, s, h, d) {
1026
+ n(this, "nodeIdGenerator", new m(
1092
1027
  (t) => this.graphStore.getNode(t) !== void 0
1093
1028
  ));
1094
- n(this, "portIdGenerator", new L(
1029
+ n(this, "portIdGenerator", new m(
1095
1030
  (t) => this.graphStore.getPort(t) !== void 0
1096
1031
  ));
1097
- n(this, "edgeIdGenerator", new L(
1032
+ n(this, "edgeIdGenerator", new m(
1098
1033
  (t) => this.graphStore.getEdge(t) !== void 0
1099
1034
  ));
1100
- this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = s, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = c;
1035
+ this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = s, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = d;
1101
1036
  }
1102
1037
  attach(t) {
1103
1038
  this.htmlController.attach(t);
@@ -1108,7 +1043,7 @@ class vt {
1108
1043
  addNode(t) {
1109
1044
  const o = this.nodeIdGenerator.create(t.nodeId);
1110
1045
  if (this.graphStore.getNode(o) !== void 0)
1111
- throw new S("failed to add node with existing id");
1046
+ throw new E("failed to add node with existing id");
1112
1047
  this.graphStore.addNode({
1113
1048
  nodeId: o,
1114
1049
  element: t.element,
@@ -1128,9 +1063,9 @@ class vt {
1128
1063
  markPort(t) {
1129
1064
  const o = this.portIdGenerator.create(t.portId);
1130
1065
  if (this.graphStore.getPort(o) !== void 0)
1131
- throw new S("failed to add port with existing id");
1066
+ throw new E("failed to add port with existing id");
1132
1067
  if (this.graphStore.getNode(t.nodeId) === void 0)
1133
- throw new S("failed to set port on nonexisting node");
1068
+ throw new E("failed to set port on nonexisting node");
1134
1069
  this.graphStore.addPort({
1135
1070
  portId: o,
1136
1071
  element: t.element,
@@ -1141,11 +1076,11 @@ class vt {
1141
1076
  addEdge(t) {
1142
1077
  const o = this.edgeIdGenerator.create(t.edgeId);
1143
1078
  if (this.graphStore.getEdge(o) !== void 0)
1144
- throw new S("failed to add edge with existing id");
1079
+ throw new E("failed to add edge with existing id");
1145
1080
  if (this.graphStore.getPort(t.from) === void 0)
1146
- throw new S("failed to add edge from nonexisting port");
1081
+ throw new E("failed to add edge from nonexisting port");
1147
1082
  if (this.graphStore.getPort(t.to) === void 0)
1148
- throw new S("failed to add edge to nonexisting port");
1083
+ throw new E("failed to add edge to nonexisting port");
1149
1084
  this.graphStore.addEdge({
1150
1085
  edgeId: o,
1151
1086
  from: t.from,
@@ -1157,13 +1092,13 @@ class vt {
1157
1092
  updateEdge(t) {
1158
1093
  const o = this.graphStore.getEdge(t.edgeId);
1159
1094
  if (o === void 0)
1160
- throw new S("failed to update nonexisting edge");
1095
+ throw new E("failed to update nonexisting edge");
1161
1096
  t.shape !== void 0 && (o.shape = t.shape, this.htmlController.updateEdgeShape(t.edgeId)), t.priority !== void 0 && (o.priority = t.priority, this.htmlController.updateEdgePriority(t.edgeId)), t.from !== void 0 && this.graphStore.updateEdgeFrom(t.edgeId, t.from), t.to !== void 0 && this.graphStore.updateEdgeTo(t.edgeId, t.to), this.htmlController.renderEdge(t.edgeId);
1162
1097
  }
1163
1098
  updatePort(t, o) {
1164
1099
  const r = this.graphStore.getPort(t);
1165
1100
  if (r === void 0)
1166
- throw new S("failed to unset nonexisting port");
1101
+ throw new E("failed to unset nonexisting port");
1167
1102
  r.direction = o.direction ?? r.direction, this.graphStore.getPortAdjacentEdgeIds(t).forEach((s) => {
1168
1103
  this.htmlController.renderEdge(s);
1169
1104
  });
@@ -1171,26 +1106,26 @@ class vt {
1171
1106
  updateNode(t, o) {
1172
1107
  const r = this.graphStore.getNode(t);
1173
1108
  if (r === void 0)
1174
- throw new S("failed to update nonexisting node");
1109
+ throw new E("failed to update nonexisting node");
1175
1110
  r.x = (o == null ? void 0 : o.x) ?? r.x, r.y = (o == null ? void 0 : o.y) ?? r.y, r.centerFn = (o == null ? void 0 : o.centerFn) ?? r.centerFn, r.priority = (o == null ? void 0 : o.priority) ?? r.priority, this.htmlController.updateNodeCoordinates(t), this.htmlController.updateNodePriority(t), this.graphStore.getNodeAdjacentEdgeIds(t).forEach((s) => {
1176
1111
  this.htmlController.renderEdge(s);
1177
1112
  });
1178
1113
  }
1179
1114
  removeEdge(t) {
1180
1115
  if (this.graphStore.getEdge(t) === void 0)
1181
- throw new S("failed to remove nonexisting edge");
1116
+ throw new E("failed to remove nonexisting edge");
1182
1117
  this.htmlController.detachEdge(t), this.graphStore.removeEdge(t);
1183
1118
  }
1184
1119
  unmarkPort(t) {
1185
1120
  if (this.graphStore.getPort(t) === void 0)
1186
- throw new S("failed to unset nonexisting port");
1121
+ throw new E("failed to unset nonexisting port");
1187
1122
  this.graphStore.getPortAdjacentEdgeIds(t).forEach((o) => {
1188
1123
  this.removeEdge(o);
1189
1124
  }), this.graphStore.removePort(t);
1190
1125
  }
1191
1126
  removeNode(t) {
1192
1127
  if (this.graphStore.getNode(t) === void 0)
1193
- throw new S("failed to remove nonexisting node");
1128
+ throw new E("failed to remove nonexisting node");
1194
1129
  this.graphStore.getNodePortIds(t).forEach((o) => {
1195
1130
  this.unmarkPort(o);
1196
1131
  }), this.htmlController.detachNode(t), this.graphStore.removeNode(t);
@@ -1208,17 +1143,82 @@ class vt {
1208
1143
  this.clear(), this.htmlController.destroy();
1209
1144
  }
1210
1145
  }
1211
- class xt {
1146
+ class St {
1147
+ constructor(t) {
1148
+ this.graphStore = t;
1149
+ }
1150
+ getNode(t) {
1151
+ const o = this.graphStore.getNode(t);
1152
+ return o === void 0 ? null : {
1153
+ element: o.element,
1154
+ x: o.x,
1155
+ y: o.y,
1156
+ centerFn: o.centerFn,
1157
+ priority: o.priority
1158
+ };
1159
+ }
1160
+ getAllNodeIds() {
1161
+ return this.graphStore.getAllNodeIds();
1162
+ }
1163
+ getPort(t) {
1164
+ const o = this.graphStore.getPort(t);
1165
+ return o === void 0 ? null : {
1166
+ element: o.element,
1167
+ direction: o.direction
1168
+ };
1169
+ }
1170
+ getAllPortIds() {
1171
+ return this.graphStore.getAllPortIds();
1172
+ }
1173
+ getNodePortIds(t) {
1174
+ return this.graphStore.getNodePortIds(t);
1175
+ }
1176
+ getPortNodeId(t) {
1177
+ return this.graphStore.getPortNodeId(t) ?? null;
1178
+ }
1179
+ getAllEdgeIds() {
1180
+ return this.graphStore.getAllEdgeIds();
1181
+ }
1182
+ getEdge(t) {
1183
+ const o = this.graphStore.getEdge(t);
1184
+ return o === void 0 ? null : { from: o.from, to: o.to, priority: o.priority };
1185
+ }
1186
+ getPortIncomingEdgeIds(t) {
1187
+ return this.graphStore.getPortIncomingEdgeIds(t);
1188
+ }
1189
+ getPortOutcomingEdgeIds(t) {
1190
+ return this.graphStore.getPortOutcomingEdgeIds(t);
1191
+ }
1192
+ getPortCycleEdgeIds(t) {
1193
+ return this.graphStore.getPortCycleEdgeIds(t);
1194
+ }
1195
+ getPortAdjacentEdgeIds(t) {
1196
+ return this.graphStore.getPortAdjacentEdgeIds(t);
1197
+ }
1198
+ getNodeIncomingEdgeIds(t) {
1199
+ return this.graphStore.getNodeIncomingEdgeIds(t);
1200
+ }
1201
+ getNodeOutcomingEdgeIds(t) {
1202
+ return this.graphStore.getNodeOutcomingEdgeIds(t);
1203
+ }
1204
+ getNodeCycleEdgeIds(t) {
1205
+ return this.graphStore.getNodeCycleEdgeIds(t);
1206
+ }
1207
+ getNodeAdjacentEdgeIds(t) {
1208
+ return this.graphStore.getNodeAdjacentEdgeIds(t);
1209
+ }
1210
+ }
1211
+ class At {
1212
1212
  constructor(t) {
1213
1213
  n(this, "transformation");
1214
1214
  n(this, "model");
1215
1215
  n(this, "canvasController");
1216
1216
  n(this, "edgeShapeFactory");
1217
1217
  this.apiOptions = t;
1218
- const o = ct(this.apiOptions), r = new at(), i = new dt();
1219
- this.model = new lt(i), this.transformation = new gt(r);
1220
- const s = new ft(i, r);
1221
- this.canvasController = new vt(
1218
+ const o = at(this.apiOptions), r = new ut(), i = new gt();
1219
+ this.model = new St(i), this.transformation = new wt(r);
1220
+ const s = new xt(i, r);
1221
+ this.canvasController = new Et(
1222
1222
  i,
1223
1223
  s,
1224
1224
  r,
@@ -1306,39 +1306,39 @@ class xt {
1306
1306
  this.clear(), this.canvasController.destroy();
1307
1307
  }
1308
1308
  }
1309
- const D = (e, t, o) => {
1309
+ const V = (e, t, o) => {
1310
1310
  const { x: r, y: i, width: s, height: h } = e.getBoundingClientRect();
1311
1311
  return t >= r && t <= r + s && o >= i && o <= i + h;
1312
- }, I = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, m = (e, t) => {
1312
+ }, b = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, p = (e, t) => {
1313
1313
  t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
1314
- }, St = (e) => {
1315
- var g, y, x, f, C, E;
1314
+ }, Tt = (e) => {
1315
+ var g, y, x, f, A, S;
1316
1316
  const t = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
1317
1317
  }), o = ((y = e == null ? void 0 : e.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((x = e == null ? void 0 : e.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
1318
- }), i = (e == null ? void 0 : e.moveOnTop) === !1, s = (f = e == null ? void 0 : e.mouse) == null ? void 0 : f.dragCursor, h = s !== void 0 ? s : "grab", c = (C = e == null ? void 0 : e.mouse) == null ? void 0 : C.mouseDownEventValidator, d = c !== void 0 ? c : (N) => N.button === 0, l = (E = e == null ? void 0 : e.mouse) == null ? void 0 : E.mouseUpEventValidator;
1318
+ }), i = (e == null ? void 0 : e.moveOnTop) === !1, s = (f = e == null ? void 0 : e.mouse) == null ? void 0 : f.dragCursor, h = s !== void 0 ? s : "grab", d = (A = e == null ? void 0 : e.mouse) == null ? void 0 : A.mouseDownEventValidator, c = d !== void 0 ? d : (T) => T.button === 0, l = (S = e == null ? void 0 : e.mouse) == null ? void 0 : S.mouseUpEventValidator;
1319
1319
  return {
1320
1320
  freezePriority: i,
1321
1321
  dragCursor: h,
1322
- mouseDownEventValidator: d,
1323
- mouseUpEventValidator: l !== void 0 ? l : (N) => N.button === 0,
1322
+ mouseDownEventValidator: c,
1323
+ mouseUpEventValidator: l !== void 0 ? l : (T) => T.button === 0,
1324
1324
  onNodeDrag: t,
1325
1325
  onBeforeNodeDrag: o,
1326
1326
  onNodeDragFinished: r
1327
1327
  };
1328
1328
  };
1329
- class Et {
1329
+ class Mt {
1330
1330
  constructor(t, o) {
1331
1331
  n(this, "model");
1332
1332
  n(this, "transformation");
1333
1333
  n(this, "maxNodePriority", 0);
1334
1334
  n(this, "nodes", /* @__PURE__ */ new Map());
1335
1335
  n(this, "grabbedNodeId", null);
1336
- n(this, "nodeIdGenerator", new L(
1336
+ n(this, "nodeIdGenerator", new m(
1337
1337
  (t) => this.nodes.has(t)
1338
1338
  ));
1339
1339
  n(this, "element", null);
1340
1340
  n(this, "onWindowMouseMove", (t) => {
1341
- if (this.element !== null && (!D(this.element, t.clientX, t.clientY) || !I(this.window, t.clientX, t.clientY))) {
1341
+ if (this.element !== null && (!V(this.element, t.clientX, t.clientY) || !b(this.window, t.clientX, t.clientY))) {
1342
1342
  this.cancelMouseDrag();
1343
1343
  return;
1344
1344
  }
@@ -1351,7 +1351,7 @@ class Et {
1351
1351
  if (t.touches.length !== 1)
1352
1352
  return;
1353
1353
  const o = t.touches[0];
1354
- if (this.element !== null && (!D(this.element, o.clientX, o.clientY) || !I(this.window, o.clientX, o.clientY))) {
1354
+ if (this.element !== null && (!V(this.element, o.clientX, o.clientY) || !b(this.window, o.clientX, o.clientY))) {
1355
1355
  this.cancelTouchDrag();
1356
1356
  return;
1357
1357
  }
@@ -1369,7 +1369,7 @@ class Et {
1369
1369
  n(this, "previousTouchCoords", null);
1370
1370
  n(this, "window", window);
1371
1371
  n(this, "options");
1372
- this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.options = St(o ?? {});
1372
+ this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.options = Tt(o ?? {});
1373
1373
  }
1374
1374
  attach(t) {
1375
1375
  return this.detach(), this.element = t, this.canvas.attach(this.element), this;
@@ -1389,7 +1389,7 @@ class Et {
1389
1389
  element: t.element,
1390
1390
  x: h.x,
1391
1391
  y: h.y
1392
- }) && (s.stopImmediatePropagation(), this.grabbedNodeId = o, m(this.element, this.options.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1392
+ }) && (s.stopImmediatePropagation(), this.grabbedNodeId = o, p(this.element, this.options.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1393
1393
  }, i = (s) => {
1394
1394
  if (s.touches.length !== 1)
1395
1395
  return;
@@ -1454,7 +1454,7 @@ class Et {
1454
1454
  const i = this.model.getNode(t);
1455
1455
  if (i === null)
1456
1456
  return;
1457
- const s = this.canvas.transformation.getContentMatrix(), h = s.scale * i.x + s.dx, c = s.scale * i.y + s.dy, d = h + o, l = c + r, a = this.canvas.transformation.getViewportMatrix(), g = a.scale * d + a.dx, y = a.scale * l + a.dy;
1457
+ const s = this.canvas.transformation.getContentMatrix(), h = s.scale * i.x + s.dx, d = s.scale * i.y + s.dy, c = h + o, l = d + r, a = this.canvas.transformation.getViewportMatrix(), g = a.scale * c + a.dx, y = a.scale * l + a.dy;
1458
1458
  this.canvas.updateNode(t, { x: g, y }), this.options.onNodeDrag({
1459
1459
  nodeId: t,
1460
1460
  element: i.element,
@@ -1482,7 +1482,7 @@ class Et {
1482
1482
  element: t.element,
1483
1483
  x: t.x,
1484
1484
  y: t.y
1485
- }), this.grabbedNodeId = null, this.element !== null && m(this.element, null), this.removeMouseDragListeners();
1485
+ }), this.grabbedNodeId = null, this.element !== null && p(this.element, null), this.removeMouseDragListeners();
1486
1486
  }
1487
1487
  removeMouseDragListeners() {
1488
1488
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
@@ -1501,38 +1501,38 @@ class Et {
1501
1501
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
1502
1502
  }
1503
1503
  }
1504
- const At = (e) => {
1504
+ const Ct = (e) => {
1505
1505
  const t = e.minX !== null ? e.minX : -1 / 0, o = e.maxX !== null ? e.maxX : 1 / 0, r = e.minY !== null ? e.minY : -1 / 0, i = e.maxY !== null ? e.maxY : 1 / 0;
1506
1506
  return (s) => {
1507
- let h = s.nextTransform.dx, c = s.nextTransform.dy;
1507
+ let h = s.nextTransform.dx, d = s.nextTransform.dy;
1508
1508
  h < t && h < s.prevTransform.dx && (h = Math.min(s.prevTransform.dx, t));
1509
- const d = s.canvasWidth * s.prevTransform.scale;
1510
- h > o - d && h > s.prevTransform.dx && (h = Math.max(s.prevTransform.dx, o - d)), c < r && c < s.prevTransform.dy && (c = Math.min(s.prevTransform.dy, r));
1509
+ const c = s.canvasWidth * s.prevTransform.scale;
1510
+ h > o - c && h > s.prevTransform.dx && (h = Math.max(s.prevTransform.dx, o - c)), d < r && d < s.prevTransform.dy && (d = Math.min(s.prevTransform.dy, r));
1511
1511
  const l = s.canvasHeight * s.prevTransform.scale;
1512
- return c > i - l && c > s.prevTransform.dy && (c = Math.max(s.prevTransform.dy, i - l)), { scale: s.nextTransform.scale, dx: h, dy: c };
1512
+ return d > i - l && d > s.prevTransform.dy && (d = Math.max(s.prevTransform.dy, i - l)), { scale: s.nextTransform.scale, dx: h, dy: d };
1513
1513
  };
1514
- }, Tt = (e) => {
1514
+ }, Nt = (e) => {
1515
1515
  const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0, i = o !== null ? 1 / o : 1 / 0;
1516
1516
  return (s) => {
1517
- const h = s.prevTransform, c = s.nextTransform;
1518
- let d = c.scale, l = c.dx, a = c.dy;
1519
- if (c.scale > i && c.scale > h.scale) {
1520
- d = Math.max(h.scale, i), l = h.dx, a = h.dy;
1521
- const g = (d - h.scale) / (c.scale - h.scale);
1522
- l = h.dx + (c.dx - h.dx) * g, a = h.dy + (c.dy - h.dy) * g;
1517
+ const h = s.prevTransform, d = s.nextTransform;
1518
+ let c = d.scale, l = d.dx, a = d.dy;
1519
+ if (d.scale > i && d.scale > h.scale) {
1520
+ c = Math.max(h.scale, i), l = h.dx, a = h.dy;
1521
+ const g = (c - h.scale) / (d.scale - h.scale);
1522
+ l = h.dx + (d.dx - h.dx) * g, a = h.dy + (d.dy - h.dy) * g;
1523
1523
  }
1524
- if (c.scale < r && c.scale < h.scale) {
1525
- d = Math.min(h.scale, r), l = h.dx, a = h.dy;
1526
- const g = (d - h.scale) / (c.scale - h.scale);
1527
- l = h.dx + (c.dx - h.dx) * g, a = h.dy + (c.dy - h.dy) * g;
1524
+ if (d.scale < r && d.scale < h.scale) {
1525
+ c = Math.min(h.scale, r), l = h.dx, a = h.dy;
1526
+ const g = (c - h.scale) / (d.scale - h.scale);
1527
+ l = h.dx + (d.dx - h.dx) * g, a = h.dy + (d.dy - h.dy) * g;
1528
1528
  }
1529
1529
  return {
1530
- scale: d,
1530
+ scale: c,
1531
1531
  dx: l,
1532
1532
  dy: a
1533
1533
  };
1534
1534
  };
1535
- }, Mt = (e) => (t) => e.reduce(
1535
+ }, Lt = (e) => (t) => e.reduce(
1536
1536
  (o, r) => r({
1537
1537
  prevTransform: t.prevTransform,
1538
1538
  nextTransform: o,
@@ -1540,55 +1540,58 @@ const At = (e) => {
1540
1540
  canvasHeight: t.canvasHeight
1541
1541
  }),
1542
1542
  t.nextTransform
1543
- ), U = (e) => {
1543
+ ), J = (e) => {
1544
1544
  if (typeof e == "function")
1545
1545
  return e;
1546
1546
  switch (e.type) {
1547
1547
  case "scale-limit":
1548
- return Tt({
1548
+ return Nt({
1549
1549
  minContentScale: e.minContentScale ?? 0,
1550
1550
  maxContentScale: e.maxContentScale ?? 1 / 0
1551
1551
  });
1552
1552
  case "shift-limit":
1553
- return At({
1553
+ return Ct({
1554
1554
  minX: e.minX ?? -1 / 0,
1555
1555
  maxX: e.maxX ?? 1 / 0,
1556
1556
  minY: e.minY ?? -1 / 0,
1557
1557
  maxY: e.maxY ?? 1 / 0
1558
1558
  });
1559
1559
  }
1560
- }, Ct = (e) => {
1561
- var d, l, a, g, y, x;
1562
- const t = (d = e == null ? void 0 : e.scale) == null ? void 0 : d.mouseWheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
1560
+ }, Pt = (e) => {
1561
+ var f, A, S, T, X, P, D, I, j;
1562
+ const t = (f = e == null ? void 0 : e.scale) == null ? void 0 : f.mouseWheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
1563
1563
  let i;
1564
- r !== void 0 ? Array.isArray(r) ? i = Mt(
1564
+ r !== void 0 ? Array.isArray(r) ? i = Lt(
1565
1565
  r.map(
1566
- (f) => U(f)
1566
+ (L) => J(L)
1567
1567
  )
1568
- ) : i = U(r) : i = (f) => f.nextTransform;
1569
- const s = ((l = e == null ? void 0 : e.shift) == null ? void 0 : l.cursor) !== void 0 ? e.shift.cursor : "grab", h = ((a = e == null ? void 0 : e.events) == null ? void 0 : a.onBeforeTransformChange) ?? (() => {
1570
- }), c = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onTransformChange) ?? (() => {
1571
- });
1568
+ ) : i = J(r) : i = (L) => L.nextTransform;
1569
+ const s = ((A = e == null ? void 0 : e.shift) == null ? void 0 : A.cursor) !== void 0 ? e.shift.cursor : "grab", h = ((S = e == null ? void 0 : e.events) == null ? void 0 : S.onBeforeTransformChange) ?? (() => {
1570
+ }), d = ((T = e == null ? void 0 : e.events) == null ? void 0 : T.onTransformChange) ?? (() => {
1571
+ }), c = (X = e == null ? void 0 : e.shift) == null ? void 0 : X.mouseDownEventValidator, l = c !== void 0 ? c : (L) => L.button === 0, a = (P = e == null ? void 0 : e.shift) == null ? void 0 : P.mouseUpEventValidator, g = a !== void 0 ? a : (L) => L.button === 0, y = (D = e == null ? void 0 : e.scale) == null ? void 0 : D.mouseWheelEventValidator, x = y !== void 0 ? y : () => !0;
1572
1572
  return {
1573
1573
  wheelSensitivity: o,
1574
- onTransformStarted: ((y = e == null ? void 0 : e.events) == null ? void 0 : y.onTransformStarted) ?? (() => {
1574
+ onTransformStarted: ((I = e == null ? void 0 : e.events) == null ? void 0 : I.onTransformStarted) ?? (() => {
1575
1575
  }),
1576
- onTransformFinished: ((x = e == null ? void 0 : e.events) == null ? void 0 : x.onTransformFinished) ?? (() => {
1576
+ onTransformFinished: ((j = e == null ? void 0 : e.events) == null ? void 0 : j.onTransformFinished) ?? (() => {
1577
1577
  }),
1578
1578
  onBeforeTransformChange: h,
1579
- onTransformChange: c,
1579
+ onTransformChange: d,
1580
1580
  transformPreprocessor: i,
1581
- shiftCursor: s
1581
+ shiftCursor: s,
1582
+ mouseDownEventValidator: l,
1583
+ mouseUpEventValidator: g,
1584
+ mouseWheelEventValidator: x
1582
1585
  };
1583
- }, F = (e) => {
1586
+ }, B = (e) => {
1584
1587
  const t = [], o = e.touches.length;
1585
- for (let c = 0; c < o; c++)
1586
- t.push([e.touches[c].clientX, e.touches[c].clientY]);
1588
+ for (let d = 0; d < o; d++)
1589
+ t.push([e.touches[d].clientX, e.touches[d].clientY]);
1587
1590
  const r = t.reduce(
1588
- (c, d) => [c[0] + d[0], c[1] + d[1]],
1591
+ (d, c) => [d[0] + c[0], d[1] + c[1]],
1589
1592
  [0, 0]
1590
- ), i = [r[0] / o, r[1] / o], h = t.map((c) => [c[0] - i[0], c[1] - i[1]]).reduce(
1591
- (c, d) => c + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
1593
+ ), i = [r[0] / o, r[1] / o], h = t.map((d) => [d[0] - i[0], d[1] - i[1]]).reduce(
1594
+ (d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
1592
1595
  0
1593
1596
  );
1594
1597
  return {
@@ -1598,16 +1601,16 @@ const At = (e) => {
1598
1601
  touchesCnt: o,
1599
1602
  touches: t
1600
1603
  };
1601
- }, Nt = (e, t, o) => ({
1604
+ }, Dt = (e, t, o) => ({
1602
1605
  scale: e.scale,
1603
1606
  dx: e.dx + e.scale * t,
1604
1607
  dy: e.dy + e.scale * o
1605
- }), Lt = (e, t, o, r) => ({
1608
+ }), It = (e, t, o, r) => ({
1606
1609
  scale: e.scale * t,
1607
1610
  dx: e.scale * (1 - t) * o + e.dx,
1608
1611
  dy: e.scale * (1 - t) * r + e.dy
1609
1612
  });
1610
- class Pt {
1613
+ class mt {
1611
1614
  constructor(t, o) {
1612
1615
  n(this, "model");
1613
1616
  n(this, "transformation");
@@ -1615,10 +1618,10 @@ class Pt {
1615
1618
  n(this, "prevTouches", null);
1616
1619
  n(this, "window", window);
1617
1620
  n(this, "onMouseDown", (t) => {
1618
- this.element === null || t.button !== 0 || (m(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
1621
+ this.element === null || !this.options.mouseDownEventValidator(t) || (p(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
1619
1622
  });
1620
1623
  n(this, "onWindowMouseMove", (t) => {
1621
- if (this.element === null || !D(this.element, t.clientX, t.clientY) || !I(this.window, t.clientX, t.clientY)) {
1624
+ if (this.element === null || !V(this.element, t.clientX, t.clientY) || !b(this.window, t.clientX, t.clientY)) {
1622
1625
  this.stopMouseDrag();
1623
1626
  return;
1624
1627
  }
@@ -1626,23 +1629,25 @@ class Pt {
1626
1629
  this.moveViewport(this.element, o, r);
1627
1630
  });
1628
1631
  n(this, "onWindowMouseUp", (t) => {
1629
- this.element === null || t.button !== 0 || this.stopMouseDrag();
1632
+ this.element === null || !this.options.mouseUpEventValidator(t) || this.stopMouseDrag();
1630
1633
  });
1631
1634
  n(this, "onWheelScroll", (t) => {
1635
+ if (!this.options.mouseWheelEventValidator(t))
1636
+ return;
1632
1637
  t.preventDefault();
1633
- const { left: o, top: r } = this.element.getBoundingClientRect(), i = t.clientX - o, s = t.clientY - r, c = 1 / (t.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
1634
- this.scaleViewport(this.element, c, i, s);
1638
+ const { left: o, top: r } = this.element.getBoundingClientRect(), i = t.clientX - o, s = t.clientY - r, d = 1 / (t.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
1639
+ this.scaleViewport(this.element, d, i, s);
1635
1640
  });
1636
1641
  n(this, "onTouchStart", (t) => {
1637
- this.prevTouches = F(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
1642
+ this.prevTouches = B(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
1638
1643
  });
1639
1644
  n(this, "onWindowTouchMove", (t) => {
1640
1645
  const o = this.element;
1641
1646
  if (o === null)
1642
1647
  return;
1643
- const r = F(t);
1648
+ const r = B(t);
1644
1649
  if (!r.touches.every(
1645
- (s) => D(o, s[0], s[1]) && I(this.window, s[0], s[1])
1650
+ (s) => V(o, s[0], s[1]) && b(this.window, s[0], s[1])
1646
1651
  )) {
1647
1652
  this.stopTouchDrag();
1648
1653
  return;
@@ -1652,13 +1657,13 @@ class Pt {
1652
1657
  -(r.x - this.prevTouches.x),
1653
1658
  -(r.y - this.prevTouches.y)
1654
1659
  ), r.touchesCnt === 2) {
1655
- const { left: s, top: h } = o.getBoundingClientRect(), c = this.prevTouches.x - s, d = this.prevTouches.y - h, a = 1 / (r.scale / this.prevTouches.scale);
1656
- this.scaleViewport(o, a, c, d);
1660
+ const { left: s, top: h } = o.getBoundingClientRect(), d = this.prevTouches.x - s, c = this.prevTouches.y - h, a = 1 / (r.scale / this.prevTouches.scale);
1661
+ this.scaleViewport(o, a, d, c);
1657
1662
  }
1658
1663
  this.prevTouches = r;
1659
1664
  });
1660
1665
  n(this, "onWindowTouchFinish", (t) => {
1661
- t.touches.length > 0 ? this.prevTouches = F(t) : this.stopTouchDrag();
1666
+ t.touches.length > 0 ? this.prevTouches = B(t) : this.stopTouchDrag();
1662
1667
  });
1663
1668
  n(this, "observer", new ResizeObserver(() => {
1664
1669
  const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), i = this.options.transformPreprocessor({
@@ -1670,7 +1675,7 @@ class Pt {
1670
1675
  this.canvas.patchViewportMatrix(i), this.options.onTransformChange();
1671
1676
  }));
1672
1677
  n(this, "options");
1673
- this.canvas = t, this.options = Ct(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1678
+ this.canvas = t, this.options = Pt(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1674
1679
  }
1675
1680
  attach(t) {
1676
1681
  return this.detach(), this.element = t, 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;
@@ -1719,26 +1724,26 @@ class Pt {
1719
1724
  }
1720
1725
  moveViewport(t, o, r) {
1721
1726
  this.options.onBeforeTransformChange();
1722
- const i = this.transformation.getViewportMatrix(), s = Nt(i, o, r), { width: h, height: c } = t.getBoundingClientRect(), d = this.options.transformPreprocessor({
1727
+ const i = this.transformation.getViewportMatrix(), s = Dt(i, o, r), { width: h, height: d } = t.getBoundingClientRect(), c = this.options.transformPreprocessor({
1723
1728
  prevTransform: i,
1724
1729
  nextTransform: s,
1725
1730
  canvasWidth: h,
1726
- canvasHeight: c
1731
+ canvasHeight: d
1727
1732
  });
1728
- this.canvas.patchViewportMatrix(d), this.options.onTransformChange();
1733
+ this.canvas.patchViewportMatrix(c), this.options.onTransformChange();
1729
1734
  }
1730
1735
  scaleViewport(t, o, r, i) {
1731
1736
  this.options.onBeforeTransformChange();
1732
- const s = this.canvas.transformation.getViewportMatrix(), h = Lt(s, o, r, i), { width: c, height: d } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
1737
+ const s = this.canvas.transformation.getViewportMatrix(), h = It(s, o, r, i), { width: d, height: c } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
1733
1738
  prevTransform: s,
1734
1739
  nextTransform: h,
1735
- canvasWidth: c,
1736
- canvasHeight: d
1740
+ canvasWidth: d,
1741
+ canvasHeight: c
1737
1742
  });
1738
1743
  this.canvas.patchViewportMatrix(l), this.options.onTransformChange();
1739
1744
  }
1740
1745
  stopMouseDrag() {
1741
- this.element !== null && m(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
1746
+ this.element !== null && p(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
1742
1747
  }
1743
1748
  removeMouseDragListeners() {
1744
1749
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -1750,7 +1755,7 @@ class Pt {
1750
1755
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
1751
1756
  }
1752
1757
  }
1753
- class Dt {
1758
+ class $t {
1754
1759
  constructor() {
1755
1760
  n(this, "keyMap", /* @__PURE__ */ new Map());
1756
1761
  n(this, "valueMap", /* @__PURE__ */ new Map());
@@ -1787,12 +1792,12 @@ class Dt {
1787
1792
  this.keyMap.clear(), this.valueMap.clear();
1788
1793
  }
1789
1794
  }
1790
- class It {
1795
+ class Vt {
1791
1796
  constructor(t) {
1792
1797
  n(this, "transformation");
1793
1798
  n(this, "model");
1794
- n(this, "nodes", new Dt());
1795
- n(this, "nodeIdGenerator", new L(
1799
+ n(this, "nodes", new $t());
1800
+ n(this, "nodeIdGenerator", new m(
1796
1801
  (t) => this.nodes.hasKey(t)
1797
1802
  ));
1798
1803
  n(this, "nodesResizeObserver");
@@ -1883,19 +1888,19 @@ class pt {
1883
1888
  return this.hasResizeReactiveNodes = !0, this;
1884
1889
  }
1885
1890
  build() {
1886
- let t = new xt(this.coreOptions);
1887
- return this.hasResizeReactiveNodes && (t = new It(t)), this.isDraggable && (t = new Et(t, this.dragOptions)), this.isTransformable && (t = new Pt(t, this.transformOptions)), t;
1891
+ let t = new At(this.coreOptions);
1892
+ return this.hasResizeReactiveNodes && (t = new Vt(t)), this.isDraggable && (t = new Mt(t, this.dragOptions)), this.isTransformable && (t = new mt(t, this.transformOptions)), t;
1888
1893
  }
1889
1894
  }
1890
1895
  export {
1891
- ot as BezierEdgeShape,
1892
- xt as CanvasCore,
1893
- rt as HorizontalEdgeShape,
1896
+ nt as BezierEdgeShape,
1897
+ At as CanvasCore,
1898
+ st as HorizontalEdgeShape,
1894
1899
  pt as HtmlGraphBuilder,
1895
- S as HtmlGraphError,
1896
- It as ResizeReactiveNodesCanvas,
1897
- it as StraightEdgeShape,
1898
- Et as UserDraggableNodesCanvas,
1899
- Pt as UserTransformableCanvas,
1900
- nt as VerticalEdgeShape
1900
+ E as HtmlGraphError,
1901
+ Vt as ResizeReactiveNodesCanvas,
1902
+ ht as StraightEdgeShape,
1903
+ Mt as UserDraggableNodesCanvas,
1904
+ mt as UserTransformableCanvas,
1905
+ dt as VerticalEdgeShape
1901
1906
  };