@html-graph/html-graph 0.0.57 → 0.0.59

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,19 +1,19 @@
1
- var tt = Object.defineProperty;
2
- var et = (e, t, r) => t in e ? tt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var n = (e, t, r) => et(e, typeof t != "symbol" ? t + "" : t, r);
4
- const K = (e) => ({
5
- scale: 1 / e.scale,
6
- dx: -e.dx / e.scale,
7
- dy: -e.dy / e.scale
8
- }), J = {
1
+ var _ = Object.defineProperty;
2
+ var J = (r, e, t) => e in r ? _(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var a = (r, e, t) => J(r, typeof e != "symbol" ? e + "" : e, t);
4
+ const Y = (r) => ({
5
+ scale: 1 / r.scale,
6
+ dx: -r.dx / r.scale,
7
+ dy: -r.dy / r.scale
8
+ }), X = {
9
9
  scale: 1,
10
10
  dx: 0,
11
11
  dy: 0
12
12
  };
13
- class rt {
13
+ class Q {
14
14
  constructor() {
15
- n(this, "viewportMatrix", J);
16
- n(this, "contentMatrix", J);
15
+ a(this, "viewportMatrix", X);
16
+ a(this, "contentMatrix", X);
17
17
  }
18
18
  getViewportMatrix() {
19
19
  return this.viewportMatrix;
@@ -21,24 +21,24 @@ class rt {
21
21
  getContentMatrix() {
22
22
  return this.contentMatrix;
23
23
  }
24
- patchViewportMatrix(t, r, s) {
24
+ patchViewportMatrix(e, t, s) {
25
25
  this.viewportMatrix = {
26
- scale: t ?? this.viewportMatrix.scale,
27
- dx: r ?? this.viewportMatrix.dx,
26
+ scale: e ?? this.viewportMatrix.scale,
27
+ dx: t ?? this.viewportMatrix.dx,
28
28
  dy: s ?? this.viewportMatrix.dy
29
- }, this.contentMatrix = K(this.viewportMatrix);
29
+ }, this.contentMatrix = Y(this.viewportMatrix);
30
30
  }
31
- patchContentMatrix(t, r, s) {
31
+ patchContentMatrix(e, t, s) {
32
32
  this.contentMatrix = {
33
- scale: t ?? this.contentMatrix.scale,
34
- dx: r ?? this.contentMatrix.dx,
33
+ scale: e ?? this.contentMatrix.scale,
34
+ dx: t ?? this.contentMatrix.dx,
35
35
  dy: s ?? this.contentMatrix.dy
36
- }, this.viewportMatrix = K(this.contentMatrix);
36
+ }, this.viewportMatrix = Y(this.contentMatrix);
37
37
  }
38
38
  }
39
- class st {
40
- constructor(t) {
41
- this.transformer = t;
39
+ class Z {
40
+ constructor(e) {
41
+ this.transformer = e;
42
42
  }
43
43
  getViewportMatrix() {
44
44
  return { ...this.transformer.getViewportMatrix() };
@@ -47,741 +47,708 @@ class st {
47
47
  return { ...this.transformer.getContentMatrix() };
48
48
  }
49
49
  }
50
- class ot {
50
+ class q {
51
51
  constructor() {
52
- n(this, "nodes", /* @__PURE__ */ new Map());
53
- n(this, "ports", /* @__PURE__ */ new Map());
54
- n(this, "nodePorts", /* @__PURE__ */ new Map());
55
- n(this, "portNodeId", /* @__PURE__ */ new Map());
56
- n(this, "edges", /* @__PURE__ */ new Map());
57
- n(this, "incommingEdges", /* @__PURE__ */ new Map());
58
- n(this, "outcommingEdges", /* @__PURE__ */ new Map());
59
- n(this, "cycleEdges", /* @__PURE__ */ new Map());
60
- }
61
- addNode(t, r, s, o, i, h) {
62
- this.nodes.set(t, { element: r, x: s, y: o, centerFn: i, priority: h }), this.nodePorts.set(t, /* @__PURE__ */ new Map());
52
+ a(this, "nodes", /* @__PURE__ */ new Map());
53
+ a(this, "ports", /* @__PURE__ */ new Map());
54
+ a(this, "nodePorts", /* @__PURE__ */ new Map());
55
+ a(this, "portNodeId", /* @__PURE__ */ new Map());
56
+ a(this, "edges", /* @__PURE__ */ new Map());
57
+ a(this, "incommingEdges", /* @__PURE__ */ new Map());
58
+ a(this, "outcommingEdges", /* @__PURE__ */ new Map());
59
+ a(this, "cycleEdges", /* @__PURE__ */ new Map());
60
+ }
61
+ addNode(e, t, s, o, i, n) {
62
+ this.nodes.set(e, { element: t, x: s, y: o, centerFn: i, priority: n }), this.nodePorts.set(e, /* @__PURE__ */ new Map());
63
63
  }
64
64
  getAllNodeIds() {
65
65
  return Array.from(this.nodes.keys());
66
66
  }
67
- getNode(t) {
68
- return this.nodes.get(t);
67
+ getNode(e) {
68
+ return this.nodes.get(e);
69
69
  }
70
- removeNode(t) {
71
- this.nodes.delete(t), this.nodePorts.delete(t);
70
+ removeNode(e) {
71
+ this.nodes.delete(e), this.nodePorts.delete(e);
72
72
  }
73
- addPort(t, r, s, o, i) {
74
- this.ports.set(t, { element: r, centerFn: o, direction: i }), this.cycleEdges.set(t, /* @__PURE__ */ new Set()), this.incommingEdges.set(t, /* @__PURE__ */ new Set()), this.outcommingEdges.set(t, /* @__PURE__ */ new Set()), this.portNodeId.set(t, s), this.nodePorts.get(s).set(t, r);
73
+ addPort(e, t, s, o, i) {
74
+ this.ports.set(e, { element: t, centerFn: o, direction: i }), this.cycleEdges.set(e, /* @__PURE__ */ new Set()), this.incommingEdges.set(e, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e, /* @__PURE__ */ new Set()), this.portNodeId.set(e, s), this.nodePorts.get(s).set(e, t);
75
75
  }
76
- getPort(t) {
77
- return this.ports.get(t);
76
+ getPort(e) {
77
+ return this.ports.get(e);
78
78
  }
79
79
  getAllPortIds() {
80
80
  return Array.from(this.ports.keys());
81
81
  }
82
- getNodePortIds(t) {
83
- const r = this.nodePorts.get(t);
84
- if (r !== void 0)
85
- return Array.from(r.keys());
82
+ getNodePortIds(e) {
83
+ const t = this.nodePorts.get(e);
84
+ if (t !== void 0)
85
+ return Array.from(t.keys());
86
86
  }
87
- getPortNodeId(t) {
88
- return this.portNodeId.get(t);
87
+ getPortNodeId(e) {
88
+ return this.portNodeId.get(e);
89
89
  }
90
- removePort(t) {
91
- const r = this.portNodeId.get(t);
92
- this.portNodeId.delete(t), this.nodePorts.get(r).delete(t), this.ports.delete(t);
90
+ removePort(e) {
91
+ const t = this.portNodeId.get(e);
92
+ this.portNodeId.delete(e), this.nodePorts.get(t).delete(e), this.ports.delete(e);
93
93
  }
94
- addEdge(t, r, s, o, i) {
95
- this.edges.set(t, {
96
- from: r,
94
+ addEdge(e, t, s, o, i) {
95
+ this.edges.set(e, {
96
+ from: t,
97
97
  to: s,
98
98
  shape: o,
99
99
  priority: i
100
- }), r !== s ? (this.outcommingEdges.get(r).add(t), this.incommingEdges.get(s).add(t)) : this.cycleEdges.get(r).add(t);
100
+ }), t !== s ? (this.outcommingEdges.get(t).add(e), this.incommingEdges.get(s).add(e)) : this.cycleEdges.get(t).add(e);
101
101
  }
102
102
  getAllEdgeIds() {
103
103
  return Array.from(this.edges.keys());
104
104
  }
105
- getEdge(t) {
106
- return this.edges.get(t);
105
+ getEdge(e) {
106
+ return this.edges.get(e);
107
107
  }
108
- removeEdge(t) {
109
- const r = this.edges.get(t), s = r.from, o = r.to;
110
- this.cycleEdges.get(s).delete(t), this.cycleEdges.get(o).delete(t), this.incommingEdges.get(s).delete(t), this.incommingEdges.get(o).delete(t), this.outcommingEdges.get(s).delete(t), this.outcommingEdges.get(o).delete(t), this.edges.delete(t);
108
+ removeEdge(e) {
109
+ const t = this.edges.get(e), s = t.from, o = t.to;
110
+ this.cycleEdges.get(s).delete(e), this.cycleEdges.get(o).delete(e), this.incommingEdges.get(s).delete(e), this.incommingEdges.get(o).delete(e), this.outcommingEdges.get(s).delete(e), this.outcommingEdges.get(o).delete(e), this.edges.delete(e);
111
111
  }
112
112
  clear() {
113
113
  this.nodes.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear();
114
114
  }
115
- getPortIncomingEdgeIds(t) {
116
- return Array.from(this.incommingEdges.get(t));
115
+ getPortIncomingEdgeIds(e) {
116
+ return Array.from(this.incommingEdges.get(e));
117
117
  }
118
- getPortOutcomingEdgeIds(t) {
119
- return Array.from(this.outcommingEdges.get(t));
118
+ getPortOutcomingEdgeIds(e) {
119
+ return Array.from(this.outcommingEdges.get(e));
120
120
  }
121
- getPortCycleEdgeIds(t) {
122
- return Array.from(this.cycleEdges.get(t));
121
+ getPortCycleEdgeIds(e) {
122
+ return Array.from(this.cycleEdges.get(e));
123
123
  }
124
- getPortAdjacentEdgeIds(t) {
124
+ getPortAdjacentEdgeIds(e) {
125
125
  return [
126
- ...this.getPortIncomingEdgeIds(t),
127
- ...this.getPortOutcomingEdgeIds(t),
128
- ...this.getPortCycleEdgeIds(t)
126
+ ...this.getPortIncomingEdgeIds(e),
127
+ ...this.getPortOutcomingEdgeIds(e),
128
+ ...this.getPortCycleEdgeIds(e)
129
129
  ];
130
130
  }
131
- getNodeIncomingEdgeIds(t) {
132
- const r = Array.from(this.nodePorts.get(t).keys());
131
+ getNodeIncomingEdgeIds(e) {
132
+ const t = Array.from(this.nodePorts.get(e).keys());
133
133
  let s = [];
134
- return r.forEach((o) => {
134
+ return t.forEach((o) => {
135
135
  s = [...s, ...this.getPortIncomingEdgeIds(o)];
136
136
  }), s;
137
137
  }
138
- getNodeOutcomingEdgeIds(t) {
139
- const r = Array.from(this.nodePorts.get(t).keys());
138
+ getNodeOutcomingEdgeIds(e) {
139
+ const t = Array.from(this.nodePorts.get(e).keys());
140
140
  let s = [];
141
- return r.forEach((o) => {
141
+ return t.forEach((o) => {
142
142
  s = [...s, ...this.getPortOutcomingEdgeIds(o)];
143
143
  }), s;
144
144
  }
145
- getNodeCycleEdgeIds(t) {
146
- const r = Array.from(this.nodePorts.get(t).keys());
145
+ getNodeCycleEdgeIds(e) {
146
+ const t = Array.from(this.nodePorts.get(e).keys());
147
147
  let s = [];
148
- return r.forEach((o) => {
148
+ return t.forEach((o) => {
149
149
  s = [...s, ...this.getPortCycleEdgeIds(o)];
150
150
  }), s;
151
151
  }
152
- getNodeAdjacentEdgeIds(t) {
152
+ getNodeAdjacentEdgeIds(e) {
153
153
  return [
154
- ...this.getNodeIncomingEdgeIds(t),
155
- ...this.getNodeOutcomingEdgeIds(t),
156
- ...this.getNodeCycleEdgeIds(t)
154
+ ...this.getNodeIncomingEdgeIds(e),
155
+ ...this.getNodeOutcomingEdgeIds(e),
156
+ ...this.getNodeCycleEdgeIds(e)
157
157
  ];
158
158
  }
159
159
  }
160
- class it {
161
- constructor(t) {
162
- this.graphStore = t;
160
+ class ee {
161
+ constructor(e) {
162
+ this.graphStore = e;
163
+ }
164
+ getNode(e) {
165
+ const t = this.graphStore.getNode(e);
166
+ return t === void 0 ? null : {
167
+ element: t.element,
168
+ x: t.x,
169
+ y: t.y,
170
+ centerFn: t.centerFn,
171
+ priority: t.priority
172
+ };
163
173
  }
164
174
  getAllNodeIds() {
165
175
  return this.graphStore.getAllNodeIds();
166
176
  }
167
- getAllPortIds() {
168
- return this.graphStore.getAllPortIds();
169
- }
170
- getNode(t) {
171
- const r = this.graphStore.getNode(t);
172
- return r === void 0 ? null : {
173
- element: r.element,
174
- x: r.x,
175
- y: r.y,
176
- centerFn: r.centerFn,
177
- priority: r.priority
177
+ getPort(e) {
178
+ const t = this.graphStore.getPort(e);
179
+ return t === void 0 ? null : {
180
+ element: t.element,
181
+ centerFn: t.centerFn,
182
+ direction: t.direction
178
183
  };
179
184
  }
180
- getNodePortIds(t) {
181
- return this.graphStore.getNodePortIds(t);
185
+ getAllPortIds() {
186
+ return this.graphStore.getAllPortIds();
182
187
  }
183
- getPort(t) {
184
- const r = this.graphStore.getPort(t);
185
- return r === void 0 ? null : {
186
- element: r.element,
187
- centerFn: r.centerFn,
188
- direction: r.direction
189
- };
188
+ getNodePortIds(e) {
189
+ return this.graphStore.getNodePortIds(e);
190
190
  }
191
- getPortNodeId(t) {
192
- return this.graphStore.getPortNodeId(t) ?? null;
191
+ getPortNodeId(e) {
192
+ return this.graphStore.getPortNodeId(e) ?? null;
193
193
  }
194
194
  getAllEdgeIds() {
195
195
  return this.graphStore.getAllEdgeIds();
196
196
  }
197
- getEdge(t) {
198
- const r = this.graphStore.getEdge(t);
199
- return r === void 0 ? null : { from: r.from, to: r.to, priority: r.priority };
197
+ getEdge(e) {
198
+ const t = this.graphStore.getEdge(e);
199
+ return t === void 0 ? null : { from: t.from, to: t.to, priority: t.priority };
200
200
  }
201
- getPortAdjacentEdgeIds(t) {
202
- return this.graphStore.getPortAdjacentEdgeIds(t);
201
+ getPortIncomingEdgeIds(e) {
202
+ return this.graphStore.getPortIncomingEdgeIds(e);
203
203
  }
204
- getNodeAdjacentEdgeIds(t) {
205
- return this.graphStore.getNodeAdjacentEdgeIds(t);
204
+ getPortOutcomingEdgeIds(e) {
205
+ return this.graphStore.getPortOutcomingEdgeIds(e);
206
206
  }
207
- getPortIncomingEdgeIds(t) {
208
- return this.graphStore.getPortIncomingEdgeIds(t);
207
+ getPortCycleEdgeIds(e) {
208
+ return this.graphStore.getPortCycleEdgeIds(e);
209
209
  }
210
- getPortOutcomingEdgeIds(t) {
211
- return this.graphStore.getPortOutcomingEdgeIds(t);
210
+ getPortAdjacentEdgeIds(e) {
211
+ return this.graphStore.getPortAdjacentEdgeIds(e);
212
212
  }
213
- getPortCycleEdgeIds(t) {
214
- return this.graphStore.getPortCycleEdgeIds(t);
213
+ getNodeIncomingEdgeIds(e) {
214
+ return this.graphStore.getNodeIncomingEdgeIds(e);
215
215
  }
216
- getNodeIncomingEdgeIds(t) {
217
- return this.graphStore.getNodeIncomingEdgeIds(t);
216
+ getNodeOutcomingEdgeIds(e) {
217
+ return this.graphStore.getNodeOutcomingEdgeIds(e);
218
218
  }
219
- getNodeOutcomingEdgeIds(t) {
220
- return this.graphStore.getNodeOutcomingEdgeIds(t);
219
+ getNodeCycleEdgeIds(e) {
220
+ return this.graphStore.getNodeCycleEdgeIds(e);
221
221
  }
222
- getNodeCycleEdgeIds(t) {
223
- return this.graphStore.getNodeCycleEdgeIds(t);
222
+ getNodeAdjacentEdgeIds(e) {
223
+ return this.graphStore.getNodeAdjacentEdgeIds(e);
224
224
  }
225
225
  }
226
- const L = (e) => {
227
- const { top: t, left: r, width: s, height: o } = e.element.getBoundingClientRect(), i = e.centerFn(s, o);
228
- return { x: r + i.x, y: t + i.y };
229
- }, E = (e, t, r) => ({
230
- x: t.x * e.x - t.y * e.y + ((1 - t.x) * r.x + t.y * r.y),
231
- y: t.y * e.x + t.x * e.y + ((1 - t.x) * r.y - t.y * r.x)
232
- }), P = (e, t, r) => ({ x: t * Math.cos(e), y: r * Math.sin(e) }), N = (e, t, r, s, o) => {
233
- const h = [
234
- { x: 0, y: 0 },
235
- { x: s, y: o },
236
- { x: s, y: -o }
237
- ].map((l) => E(l, e, { x: 0, y: 0 })).map((l) => ({ x: l.x + t, y: l.y + r })), c = `M ${h[0].x} ${h[0].y}`, a = `L ${h[1].x} ${h[1].y}`, d = `L ${h[2].x} ${h[2].y}`;
238
- return `${c} ${a} ${d}`;
239
- }, k = (e, t) => {
240
- const r = [];
241
- if (e.length > 0 && r.push(`M ${e[0].x} ${e[0].y}`), e.length === 2 && r.push(`L ${e[1].x} ${e[1].y}`), e.length > 2) {
242
- const s = e.length - 1;
243
- let o = 0, i = 0, h = 0;
244
- e.forEach((c, a) => {
245
- let d = 0, l = 0, u = 0;
246
- const w = a > 0, v = a < s, p = w && v;
247
- if (w && (d = -o, l = -i, u = h), v) {
248
- const M = e[a + 1];
249
- o = M.x - c.x, i = M.y - c.y, h = Math.sqrt(o * o + i * i);
226
+ const l = {
227
+ x: 0,
228
+ y: 0
229
+ }, p = (r, e, t) => ({
230
+ x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
231
+ y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
232
+ }), f = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) }), x = (r, e, t, s) => {
233
+ const i = [
234
+ l,
235
+ { x: t, y: s },
236
+ { x: t, y: -s }
237
+ ].map((d) => p(d, r, l)).map((d) => ({ x: d.x + e.x, y: d.y + e.y })), n = `M ${i[0].x} ${i[0].y}`, h = `L ${i[1].x} ${i[1].y}`, c = `L ${i[2].x} ${i[2].y}`;
238
+ return `${n} ${h} ${c}`;
239
+ }, D = (r, e) => {
240
+ const t = [];
241
+ if (r.length > 0 && t.push(`M ${r[0].x} ${r[0].y}`), r.length === 2 && t.push(`L ${r[1].x} ${r[1].y}`), r.length > 2) {
242
+ const s = r.length - 1;
243
+ let o = 0, i = 0, n = 0;
244
+ r.forEach((h, c) => {
245
+ let d = 0, g = 0, w = 0;
246
+ const m = c > 0, y = c < s, v = m && y;
247
+ if (m && (d = -o, g = -i, w = n), y) {
248
+ const j = r[c + 1];
249
+ o = j.x - h.x, i = j.y - h.y, n = Math.sqrt(o * o + i * i);
250
250
  }
251
- const m = Math.min((p ? t : 0) / h, a < s - 1 ? 0.5 : 1), x = p ? { x: c.x + o * m, y: c.y + i * m } : c, C = Math.min((p ? t : 0) / u, a > 1 ? 0.5 : 1), A = p ? { x: c.x + d * C, y: c.y + l * C } : c;
252
- a > 0 && r.push(`L ${A.x} ${A.y}`), p && r.push(
253
- `C ${c.x} ${c.y} ${c.x} ${c.y} ${x.x} ${x.y}`
251
+ const P = Math.min((v ? e : 0) / n, c < s - 1 ? 0.5 : 1), M = v ? { x: h.x + o * P, y: h.y + i * P } : h, T = Math.min((v ? e : 0) / w, c > 1 ? 0.5 : 1), W = v ? { x: h.x + d * T, y: h.y + g * T } : h;
252
+ c > 0 && t.push(`L ${W.x} ${W.y}`), v && t.push(
253
+ `C ${h.x} ${h.y} ${h.x} ${h.y} ${M.x} ${M.y}`
254
254
  );
255
255
  });
256
256
  }
257
- return r.join(" ");
258
- }, V = () => {
259
- const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
260
- return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e;
261
- }, O = () => {
262
- const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
263
- return e.style.transformOrigin = "50% 50%", e;
264
- }, R = (e, t) => {
265
- const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
266
- return r.setAttribute("stroke", e), r.setAttribute("stroke-width", `${t}`), r.setAttribute("fill", "none"), r;
267
- }, b = (e) => {
257
+ return t.join(" ");
258
+ }, N = () => {
259
+ const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
260
+ return r.style.pointerEvents = "none", r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.overflow = "visible", r;
261
+ }, $ = () => {
262
+ const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
263
+ return r.style.transformOrigin = "50% 50%", r;
264
+ }, L = (r, e) => {
268
265
  const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
269
- return t.setAttribute("fill", e), t;
266
+ return t.setAttribute("stroke", r), t.setAttribute("stroke-width", `${e}`), t.setAttribute("fill", "none"), t;
267
+ }, E = (r) => {
268
+ const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
269
+ return e.setAttribute("fill", r), e;
270
270
  };
271
- class nt {
272
- constructor(t, r, s, o, i, h, c) {
273
- n(this, "svg", V());
274
- n(this, "group", O());
275
- n(this, "line");
276
- n(this, "sourceArrow", null);
277
- n(this, "targetArrow", null);
278
- this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.svg.appendChild(this.group), this.line = R(t, r), this.group.appendChild(this.line), h && (this.sourceArrow = b(t), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = b(t), this.group.appendChild(this.targetArrow));
279
- }
280
- update(t, r, s, o, i, h) {
281
- this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`, this.svg.style.transform = `translate(${t}px, ${r}px)`;
282
- const c = L(i), a = L(h), d = c.x <= a.x ? 1 : -1, l = c.y <= a.y ? 1 : -1;
283
- this.group.style.transform = `scale(${d}, ${l})`;
284
- const u = P(i.direction, d, l), w = P(h.direction, d, l), v = E({ x: this.arrowLength, y: 0 }, u, {
285
- x: 0,
286
- y: 0
287
- }), p = E(
288
- { x: s - this.arrowLength, y: o },
289
- w,
290
- {
291
- x: s,
292
- y: o
293
- }
294
- ), f = {
295
- x: v.x + u.x * this.curvature,
296
- y: v.y + u.y * this.curvature
297
- }, m = {
298
- x: p.x - w.x * this.curvature,
299
- y: p.y - w.y * this.curvature
300
- }, x = `M ${v.x} ${v.y} C ${f.x} ${f.y}, ${m.x} ${m.y}, ${p.x} ${p.y}`, y = this.sourceArrow ? "" : `M 0 0 L ${v.x} ${v.y} `, C = this.targetArrow ? "" : ` M ${p.x} ${p.y} L ${s} ${o}`, A = `${y}${x}${C}`;
301
- if (this.line.setAttribute("d", A), this.sourceArrow) {
302
- const M = N(
303
- u,
304
- 0,
305
- 0,
271
+ class te {
272
+ constructor(e, t, s, o, i, n, h) {
273
+ a(this, "svg", N());
274
+ a(this, "group", $());
275
+ a(this, "line");
276
+ a(this, "sourceArrow", null);
277
+ a(this, "targetArrow", null);
278
+ this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
279
+ }
280
+ update(e, t, s, o, i) {
281
+ this.group.style.transform = `scale(${t}, ${s})`;
282
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h);
283
+ if (this.line.setAttribute("d", c), this.sourceArrow) {
284
+ const d = x(
285
+ n,
286
+ l,
306
287
  this.arrowLength,
307
288
  this.arrowWidth
308
289
  );
309
- this.sourceArrow.setAttribute("d", M);
290
+ this.sourceArrow.setAttribute("d", d);
310
291
  }
311
292
  if (this.targetArrow) {
312
- const M = N(
313
- w,
314
- s,
315
- o,
293
+ const d = x(
294
+ h,
295
+ e,
316
296
  -this.arrowLength,
317
297
  this.arrowWidth
318
298
  );
319
- this.targetArrow.setAttribute("d", M);
299
+ this.targetArrow.setAttribute("d", d);
320
300
  }
321
301
  }
302
+ createLinePath(e, t, s) {
303
+ const o = p(
304
+ { x: this.arrowLength, y: l.y },
305
+ t,
306
+ l
307
+ ), i = p(
308
+ { x: e.x - this.arrowLength, y: e.y },
309
+ s,
310
+ e
311
+ ), n = {
312
+ x: o.x + t.x * this.curvature,
313
+ y: o.y + t.y * this.curvature
314
+ }, h = {
315
+ x: i.x - s.x * this.curvature,
316
+ y: i.y - s.y * this.curvature
317
+ }, c = `M ${o.x} ${o.y} C ${n.x} ${n.y}, ${h.x} ${h.y}, ${i.x} ${i.y}`, d = this.sourceArrow ? "" : `M ${l.x} ${l.y} L ${o.x} ${o.y} `, g = this.targetArrow ? "" : ` M ${i.x} ${i.y} L ${e.x} ${e.y}`;
318
+ return `${d}${c}${g}`;
319
+ }
322
320
  }
323
- class at {
324
- constructor(t, r, s, o, i, h, c, a) {
325
- n(this, "svg", V());
326
- n(this, "group", O());
327
- n(this, "line");
328
- n(this, "sourceArrow", null);
329
- n(this, "targetArrow", null);
330
- this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = a, this.svg.appendChild(this.group), this.line = R(t, r), this.group.appendChild(this.line), h && (this.sourceArrow = b(t), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = b(t), this.group.appendChild(this.targetArrow));
331
- }
332
- update(t, r, s, o, i, h) {
333
- this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`, this.svg.style.transform = `translate(${t}px, ${r}px)`;
334
- const c = L(i), a = L(h), d = c.x <= a.x ? 1 : -1, l = c.y <= a.y ? 1 : -1;
335
- this.group.style.transform = `scale(${d}, ${l})`;
336
- const u = P(i.direction, d, l), w = P(h.direction, d, l), v = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, u, {
337
- x: 0,
338
- y: 0
339
- }) : { x: 0, y: 0 }, p = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, w, {
340
- x: s,
341
- y: o
342
- }) : { x: s, y: o }, f = this.arrowLength + this.arrowOffset, m = E({ x: f, y: 0 }, u, { x: 0, y: 0 }), x = E({ x: s - f, y: o }, w, {
343
- x: s,
344
- y: o
345
- }), y = k([v, m, x, p], this.roundness);
346
- if (this.line.setAttribute("d", y), this.sourceArrow) {
347
- const C = N(
348
- u,
349
- 0,
350
- 0,
321
+ class re {
322
+ constructor(e, t, s, o, i, n, h, c) {
323
+ a(this, "svg", N());
324
+ a(this, "group", $());
325
+ a(this, "line");
326
+ a(this, "sourceArrow", null);
327
+ a(this, "targetArrow", null);
328
+ this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
329
+ }
330
+ update(e, t, s, o, i) {
331
+ this.group.style.transform = `scale(${t}, ${s})`;
332
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h);
333
+ if (this.line.setAttribute("d", c), this.sourceArrow) {
334
+ const d = x(
335
+ n,
336
+ l,
351
337
  this.arrowLength,
352
338
  this.arrowWidth
353
339
  );
354
- this.sourceArrow.setAttribute("d", C);
340
+ this.sourceArrow.setAttribute("d", d);
355
341
  }
356
342
  if (this.targetArrow) {
357
- const C = N(
358
- w,
359
- s,
360
- o,
343
+ const d = x(
344
+ h,
345
+ e,
361
346
  -this.arrowLength,
362
347
  this.arrowWidth
363
348
  );
364
- this.targetArrow.setAttribute("d", C);
349
+ this.targetArrow.setAttribute("d", d);
365
350
  }
366
351
  }
352
+ createLinePath(e, t, s) {
353
+ const o = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, i = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, n = this.arrowLength + this.arrowOffset, h = p({ x: n, y: l.y }, t, l), c = p({ x: e.x - n, y: e.y }, s, e);
354
+ return D([o, h, c, i], this.roundness);
355
+ }
367
356
  }
368
- class ht {
369
- constructor(t, r, s, o, i, h, c, a) {
370
- n(this, "svg", V());
371
- n(this, "group", O());
372
- n(this, "line");
373
- n(this, "sourceArrow", null);
374
- n(this, "targetArrow", null);
375
- this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = a, this.svg.appendChild(this.group), this.line = R(t, r), this.group.appendChild(this.line), h && (this.sourceArrow = b(t), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = b(t), this.group.appendChild(this.targetArrow));
376
- }
377
- update(t, r, s, o, i, h) {
378
- this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`, this.svg.style.transform = `translate(${t}px, ${r}px)`;
379
- const c = L(i), a = L(h), d = c.x <= a.x ? 1 : -1, l = c.y <= a.y ? 1 : -1;
380
- this.group.style.transform = `scale(${d}, ${l})`;
381
- const u = P(i.direction, d, l), w = P(h.direction, d, l), v = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, u, {
382
- x: 0,
383
- y: 0
384
- }) : { x: 0, y: 0 }, p = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, w, {
385
- x: s,
386
- y: o
387
- }) : { x: s, y: o }, f = this.arrowLength + this.arrowOffset, m = f - this.roundness, x = E({ x: m, y: 0 }, u, { x: 0, y: 0 }), y = E({ x: s - m, y: o }, w, {
388
- x: s,
389
- y: o
390
- }), C = Math.max((x.x + y.x) / 2, f), A = o / 2, M = { x: d > 0 ? C : -f, y: x.y }, F = { x: M.x, y: A }, D = { x: d > 0 ? s - C : s + f, y: y.y }, W = { x: D.x, y: A }, Y = k(
391
- [v, x, M, F, W, D, y, p],
392
- this.roundness
393
- );
394
- if (this.line.setAttribute("d", Y), this.sourceArrow) {
395
- const $ = N(
396
- u,
397
- 0,
398
- 0,
357
+ class se {
358
+ constructor(e, t, s, o, i, n, h, c) {
359
+ a(this, "svg", N());
360
+ a(this, "group", $());
361
+ a(this, "line");
362
+ a(this, "sourceArrow", null);
363
+ a(this, "targetArrow", null);
364
+ this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
365
+ }
366
+ update(e, t, s, o, i) {
367
+ this.group.style.transform = `scale(${t}, ${s})`;
368
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, t);
369
+ if (this.line.setAttribute("d", c), this.sourceArrow) {
370
+ const d = x(
371
+ n,
372
+ l,
399
373
  this.arrowLength,
400
374
  this.arrowWidth
401
375
  );
402
- this.sourceArrow.setAttribute("d", $);
376
+ this.sourceArrow.setAttribute("d", d);
403
377
  }
404
378
  if (this.targetArrow) {
405
- const $ = N(
406
- w,
407
- s,
408
- o,
379
+ const d = x(
380
+ h,
381
+ e,
409
382
  -this.arrowLength,
410
383
  this.arrowWidth
411
384
  );
412
- this.targetArrow.setAttribute("d", $);
385
+ this.targetArrow.setAttribute("d", d);
413
386
  }
414
387
  }
415
- }
416
- class ct {
417
- constructor(t, r, s, o, i, h, c, a) {
418
- n(this, "svg", V());
419
- n(this, "group", O());
420
- n(this, "line");
421
- n(this, "sourceArrow", null);
422
- n(this, "targetArrow", null);
423
- this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = a, this.svg.appendChild(this.group), this.line = R(t, r), this.group.appendChild(this.line), h && (this.sourceArrow = b(t), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = b(t), this.group.appendChild(this.targetArrow));
424
- }
425
- update(t, r, s, o, i, h) {
426
- this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`, this.svg.style.transform = `translate(${t}px, ${r}px)`;
427
- const c = L(i), a = L(h), d = c.x <= a.x ? 1 : -1, l = c.y <= a.y ? 1 : -1;
428
- this.group.style.transform = `scale(${d}, ${l})`;
429
- const u = P(i.direction, d, l), w = P(h.direction, d, l), v = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, u, {
430
- x: 0,
431
- y: 0
432
- }) : { x: 0, y: 0 }, p = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, w, {
433
- x: s,
434
- y: o
435
- }) : { x: s, y: o }, f = this.arrowLength + this.arrowOffset, m = f - this.roundness, x = E({ x: m, y: 0 }, u, { x: 0, y: 0 }), y = E({ x: s - m, y: o }, w, {
436
- x: s,
437
- y: o
438
- }), C = Math.max((x.y + y.y) / 2, f), A = s / 2, M = { x: x.x, y: l > 0 ? C : -f }, F = { x: A, y: M.y }, D = {
439
- x: y.x,
440
- y: l > 0 ? o - C : o + f
441
- }, W = { x: A, y: D.y }, Y = k(
442
- [v, x, M, F, W, D, y, p],
388
+ createLinePath(e, t, s, o) {
389
+ const i = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, n = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, h = this.arrowLength + this.arrowOffset, c = h - this.roundness, d = p({ x: c, y: l.y }, t, l), g = p({ x: e.x - c, y: e.y }, s, e), w = Math.max((d.x + g.x) / 2, h), m = e.y / 2, y = { x: o > 0 ? w : -h, y: d.y }, v = { x: y.x, y: m }, S = { x: o > 0 ? e.x - w : e.x + h, y: g.y }, P = { x: S.x, y: m };
390
+ return D(
391
+ [i, d, y, v, P, S, g, n],
443
392
  this.roundness
444
393
  );
445
- if (this.line.setAttribute("d", Y), this.sourceArrow) {
446
- const $ = N(
447
- u,
448
- 0,
449
- 0,
394
+ }
395
+ }
396
+ class oe {
397
+ constructor(e, t, s, o, i, n, h, c) {
398
+ a(this, "svg", N());
399
+ a(this, "group", $());
400
+ a(this, "line");
401
+ a(this, "sourceArrow", null);
402
+ a(this, "targetArrow", null);
403
+ this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
404
+ }
405
+ update(e, t, s, o, i) {
406
+ this.group.style.transform = `scale(${t}, ${s})`;
407
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, s);
408
+ if (this.line.setAttribute("d", c), this.sourceArrow) {
409
+ const d = x(
410
+ n,
411
+ l,
450
412
  this.arrowLength,
451
413
  this.arrowWidth
452
414
  );
453
- this.sourceArrow.setAttribute("d", $);
415
+ this.sourceArrow.setAttribute("d", d);
454
416
  }
455
417
  if (this.targetArrow) {
456
- const $ = N(
457
- w,
458
- s,
459
- o,
418
+ const d = x(
419
+ h,
420
+ e,
460
421
  -this.arrowLength,
461
422
  this.arrowWidth
462
423
  );
463
- this.targetArrow.setAttribute("d", $);
424
+ this.targetArrow.setAttribute("d", d);
464
425
  }
465
426
  }
427
+ createLinePath(e, t, s, o) {
428
+ const i = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, n = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, h = this.arrowLength + this.arrowOffset, c = h - this.roundness, d = p({ x: c, y: l.y }, t, l), g = p({ x: e.x - c, y: e.y }, s, e), w = Math.max((d.y + g.y) / 2, h), m = e.x / 2, y = { x: d.x, y: o > 0 ? w : -h }, v = { x: m, y: y.y }, S = {
429
+ x: g.x,
430
+ y: o > 0 ? e.y - w : e.y + h
431
+ }, P = { x: m, y: S.y };
432
+ return D(
433
+ [i, d, y, v, P, S, g, n],
434
+ this.roundness
435
+ );
436
+ }
466
437
  }
467
- class dt {
468
- constructor(t, r, s, o, i, h, c) {
469
- n(this, "svg", V());
470
- n(this, "group", O());
471
- n(this, "line");
472
- n(this, "arrow", null);
473
- this.arrowLength = s, this.arrowWidth = o, this.radius = h, this.smallRadius = c, this.svg.appendChild(this.group), this.line = R(t, r), this.group.appendChild(this.line), i && (this.arrow = b(t), this.group.appendChild(this.arrow)), this.svg.style.width = "0px", this.svg.style.height = "0px";
474
- }
475
- update(t, r, s, o, i) {
476
- this.svg.style.transform = `translate(${t}px, ${r}px)`;
477
- const h = P(i.direction, 1, 1), c = this.smallRadius, a = this.radius, d = Math.sqrt(c * c + a * a), l = c + a, u = this.arrowLength + d * (1 - a / l), w = c * a / l, p = [
478
- { x: this.arrowLength, y: 0 },
479
- { x: u, y: w },
480
- { x: u, y: -w }
481
- ].map(
482
- (y) => E(y, h, { x: 0, y: 0 })
483
- ), f = [
484
- `M ${p[0].x} ${p[0].y}`,
485
- `A ${c} ${c} 0 0 1 ${p[1].x} ${p[1].y}`,
486
- `A ${a} ${a} 0 1 0 ${p[2].x} ${p[2].y}`,
487
- `A ${c} ${c} 0 0 1 ${p[0].x} ${p[0].y}`
488
- ].join(" "), m = `M 0 0 L ${p[0].x} ${p[0].y} `, x = `${this.arrow !== null ? "" : m}${f}`;
489
- if (this.line.setAttribute("d", x), this.arrow) {
490
- const y = N(
491
- h,
492
- 0,
493
- 0,
438
+ class ie {
439
+ constructor(e, t, s, o, i, n, h) {
440
+ a(this, "svg", N());
441
+ a(this, "line");
442
+ a(this, "arrow", null);
443
+ this.arrowLength = s, this.arrowWidth = o, this.radius = n, this.smallRadius = h, this.line = L(e, t), this.svg.appendChild(this.line), i && (this.arrow = E(e), this.svg.appendChild(this.arrow));
444
+ }
445
+ update(e, t, s, o) {
446
+ const i = f(o, t, s), n = this.createLinePath(i);
447
+ if (this.line.setAttribute("d", n), this.arrow) {
448
+ const h = x(
449
+ i,
450
+ l,
494
451
  this.arrowLength,
495
452
  this.arrowWidth
496
453
  );
497
- this.arrow.setAttribute("d", y);
454
+ this.arrow.setAttribute("d", h);
498
455
  }
499
456
  }
457
+ createLinePath(e) {
458
+ const t = this.smallRadius, s = this.radius, o = Math.sqrt(t * t + s * s), i = t + s, n = this.arrowLength + o * (1 - s / i), h = t * s / i, d = [
459
+ { x: this.arrowLength, y: l.y },
460
+ { x: n, y: h },
461
+ { x: n, y: -h }
462
+ ].map((m) => p(m, e, l)), g = [
463
+ `M ${d[0].x} ${d[0].y}`,
464
+ `A ${t} ${t} 0 0 1 ${d[1].x} ${d[1].y}`,
465
+ `A ${s} ${s} 0 1 0 ${d[2].x} ${d[2].y}`,
466
+ `A ${t} ${t} 0 0 1 ${d[0].x} ${d[0].y}`
467
+ ].join(" "), w = `M 0 0 L ${d[0].x} ${d[0].y} `;
468
+ return `${this.arrow !== null ? "" : w}${g}`;
469
+ }
500
470
  }
501
- class U {
502
- constructor(t, r, s, o, i, h, c, a) {
503
- n(this, "svg", V());
504
- n(this, "group", O());
505
- n(this, "line");
506
- n(this, "arrow", null);
507
- n(this, "roundness");
508
- n(this, "linePoints");
509
- this.arrowLength = s, this.arrowWidth = o, this.side = h, this.minPortOffset = c, this.roundness = Math.min(a, this.minPortOffset, this.side / 2), this.svg.appendChild(this.group), this.line = R(t, r), this.group.appendChild(this.line), i && (this.arrow = b(t), this.group.appendChild(this.arrow)), this.svg.style.width = "0px", this.svg.style.height = "0px";
510
- const d = this.minPortOffset, l = this.side, u = this.arrowLength + d, w = this.roundness, v = u + 2 * l;
511
- console.log(w), this.linePoints = [
512
- { x: this.arrowLength, y: 0 },
513
- { x: u, y: 0 },
514
- { x: u, y: this.side },
515
- { x: v, y: this.side },
516
- { x: v, y: -this.side },
517
- { x: u, y: -this.side },
518
- { x: u, y: 0 },
519
- { x: this.arrowLength, y: 0 }
471
+ class B {
472
+ constructor(e, t, s, o, i, n, h, c) {
473
+ a(this, "svg", N());
474
+ a(this, "line");
475
+ a(this, "arrow", null);
476
+ a(this, "roundness");
477
+ a(this, "linePoints");
478
+ this.arrowLength = s, this.arrowWidth = o, this.side = n, this.minPortOffset = h, this.roundness = Math.min(c, this.minPortOffset, this.side / 2), this.line = L(e, t), this.svg.appendChild(this.line), i && (this.arrow = E(e), this.svg.appendChild(this.arrow));
479
+ const d = this.minPortOffset, g = this.side, w = this.arrowLength + d, m = w + 2 * g;
480
+ this.linePoints = [
481
+ { x: this.arrowLength, y: l.y },
482
+ { x: w, y: l.y },
483
+ { x: w, y: this.side },
484
+ { x: m, y: this.side },
485
+ { x: m, y: -this.side },
486
+ { x: w, y: -this.side },
487
+ { x: w, y: l.y },
488
+ { x: this.arrowLength, y: l.y }
520
489
  ];
521
490
  }
522
- update(t, r, s, o, i) {
523
- this.svg.style.transform = `translate(${t}px, ${r}px)`;
524
- const h = P(i.direction, 1, 1), c = this.linePoints.map(
525
- (l) => E(l, h, { x: 0, y: 0 })
526
- ), a = `M 0 0 L ${c[0].x} ${c[0].y} `, d = `${this.arrow ? "" : a}${k(c, this.roundness)}`;
527
- if (this.line.setAttribute("d", d), this.arrow) {
528
- const l = N(
529
- h,
530
- 0,
531
- 0,
491
+ update(e, t, s, o) {
492
+ const i = f(o, t, s), n = this.createLinePath(i);
493
+ if (this.line.setAttribute("d", n), this.arrow) {
494
+ const h = x(
495
+ i,
496
+ l,
532
497
  this.arrowLength,
533
498
  this.arrowWidth
534
499
  );
535
- this.arrow.setAttribute("d", l);
500
+ this.arrow.setAttribute("d", h);
536
501
  }
537
502
  }
503
+ createLinePath(e) {
504
+ const t = this.linePoints.map(
505
+ (o) => p(o, e, l)
506
+ ), s = `M ${l.x} ${l.y} L ${t[0].x} ${t[0].y} `;
507
+ return `${this.arrow ? "" : s}${D(t, this.roundness)}`;
508
+ }
538
509
  }
539
- class _ {
540
- constructor(t, r, s, o, i, h, c, a, d, l) {
541
- n(this, "svg", V());
542
- n(this, "group", O());
543
- n(this, "line");
544
- n(this, "sourceArrow", null);
545
- n(this, "targetArrow", null);
546
- n(this, "detourX");
547
- n(this, "detourY");
548
- this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = a, this.detourX = Math.cos(l) * d, this.detourY = Math.sin(l) * d, this.svg.appendChild(this.group), this.line = R(t, r), this.group.appendChild(this.line), h && (this.sourceArrow = b(t), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = b(t), this.group.appendChild(this.targetArrow));
549
- }
550
- update(t, r, s, o, i, h) {
551
- this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`, this.svg.style.transform = `translate(${t}px, ${r}px)`;
552
- const c = L(i), a = L(h), d = c.x <= a.x ? 1 : -1, l = c.y <= a.y ? 1 : -1;
553
- this.group.style.transform = `scale(${d}, ${l})`;
554
- const u = P(i.direction, d, l), w = P(h.direction, d, l), v = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, u, {
555
- x: 0,
556
- y: 0
557
- }) : { x: 0, y: 0 }, p = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, w, {
558
- x: s,
559
- y: o
560
- }) : { x: s, y: o }, f = this.arrowLength + this.arrowOffset, m = E({ x: f, y: 0 }, u, {
561
- x: 0,
562
- y: 0
563
- }), x = { x: m.x + this.detourX, y: m.y + this.detourY }, y = E(
564
- { x: s - f, y: o },
565
- w,
566
- {
567
- x: s,
568
- y: o
569
- }
570
- ), C = { x: y.x + this.detourX, y: y.y + this.detourY }, A = k(
571
- [v, m, x, C, y, p],
572
- this.roundness
573
- );
574
- if (this.line.setAttribute("d", A), this.sourceArrow) {
575
- const M = N(
576
- u,
577
- 0,
578
- 0,
510
+ class ne {
511
+ constructor(e, t, s, o, i, n, h, c, d) {
512
+ a(this, "svg", N());
513
+ a(this, "group", $());
514
+ a(this, "line");
515
+ a(this, "sourceArrow", null);
516
+ a(this, "targetArrow", null);
517
+ a(this, "detourX");
518
+ a(this, "detourY");
519
+ this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.detourX = Math.cos(d) * c, this.detourY = Math.sin(d) * c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
520
+ }
521
+ update(e, t, s, o, i) {
522
+ this.group.style.transform = `scale(${t}, ${s})`;
523
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, t, s);
524
+ if (this.line.setAttribute("d", c), this.sourceArrow) {
525
+ const d = x(
526
+ n,
527
+ l,
579
528
  this.arrowLength,
580
529
  this.arrowWidth
581
530
  );
582
- this.sourceArrow.setAttribute("d", M);
531
+ this.sourceArrow.setAttribute("d", d);
583
532
  }
584
533
  if (this.targetArrow) {
585
- const M = N(
586
- w,
587
- s,
588
- o,
534
+ const d = x(
535
+ h,
536
+ e,
589
537
  -this.arrowLength,
590
538
  this.arrowWidth
591
539
  );
592
- this.targetArrow.setAttribute("d", M);
540
+ this.targetArrow.setAttribute("d", d);
593
541
  }
594
542
  }
595
- }
596
- var T = /* @__PURE__ */ ((e) => (e.Regular = "regular", e.PortCycle = "port-cycle", e.NodeCycle = "node-cycle", e))(T || {});
597
- class lt {
598
- constructor(t, r, s, o, i, h, c, a, d) {
599
- n(this, "svg", V());
600
- n(this, "group", O());
601
- n(this, "line");
602
- n(this, "sourceArrow", null);
603
- n(this, "targetArrow", null);
604
- n(this, "detourX");
605
- n(this, "detourY");
606
- this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.detourX = Math.cos(d) * a, this.detourY = Math.sin(d) * a, this.svg.appendChild(this.group), this.line = R(t, r), this.group.appendChild(this.line), h && (this.sourceArrow = b(t), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = b(t), this.group.appendChild(this.targetArrow));
607
- }
608
- update(t, r, s, o, i, h) {
609
- this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`, this.svg.style.transform = `translate(${t}px, ${r}px)`;
610
- const c = L(i), a = L(h), d = c.x <= a.x ? 1 : -1, l = c.y <= a.y ? 1 : -1;
611
- this.group.style.transform = `scale(${d}, ${l})`;
612
- const u = P(i.direction, d, l), w = P(h.direction, d, l), v = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, u, {
613
- x: 0,
614
- y: 0
615
- }) : { x: 0, y: 0 }, p = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, w, {
616
- x: s,
617
- y: o
618
- }) : { x: s, y: o }, f = this.arrowLength, m = E({ x: f, y: 0 }, u, {
619
- x: 0,
620
- y: 0
621
- }), x = { x: m.x + this.detourX, y: m.y + this.detourY }, y = E(
622
- { x: s - f, y: o },
623
- w,
624
- {
625
- x: s,
626
- y: o
627
- }
628
- ), C = { x: y.x + this.detourX, y: y.y + this.detourY }, A = { x: (x.x + C.x) / 2, y: (x.y + C.y) / 2 }, M = {
629
- x: m.x - this.curvature * Math.cos(i.direction),
630
- y: m.y - this.curvature * Math.sin(i.direction)
631
- }, F = {
632
- x: y.x + this.curvature * Math.cos(h.direction),
633
- y: y.y + this.curvature * Math.sin(h.direction)
634
- }, D = { x: m.x + this.detourX, y: m.y + this.detourY }, W = { x: y.x + this.detourX, y: y.y + this.detourY }, Y = [
635
- `M ${v.x} ${v.y}`,
636
- `L ${m.x} ${m.y}`,
637
- `C ${M.x} ${M.y} ${D.x} ${D.y} ${A.x} ${A.y}`,
638
- `C ${W.x} ${W.y} ${F.x} ${F.y} ${y.x} ${y.y}`,
639
- `L ${p.x} ${p.y}`
543
+ createLinePath(e, t, s, o, i) {
544
+ const n = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, c = this.arrowLength, d = this.detourX * o, g = this.detourY * i, w = p(
545
+ { x: c, y: l.y },
546
+ t,
547
+ l
548
+ ), m = {
549
+ x: w.x + d,
550
+ y: w.y + g
551
+ }, y = p(
552
+ { x: e.x - c, y: e.y },
553
+ s,
554
+ e
555
+ ), v = {
556
+ x: y.x + d,
557
+ y: y.y + g
558
+ }, S = { x: (m.x + v.x) / 2, y: (m.y + v.y) / 2 }, P = {
559
+ x: w.x + this.curvature * t.x,
560
+ y: w.y + this.curvature * t.y
561
+ }, M = {
562
+ x: y.x - this.curvature * s.x,
563
+ y: y.y - this.curvature * s.y
564
+ }, b = {
565
+ x: w.x + d,
566
+ y: w.y + g
567
+ }, T = {
568
+ x: y.x + d,
569
+ y: y.y + g
570
+ };
571
+ return [
572
+ `M ${n.x} ${n.y}`,
573
+ `L ${w.x} ${w.y}`,
574
+ `C ${P.x} ${P.y} ${b.x} ${b.y} ${S.x} ${S.y}`,
575
+ `C ${T.x} ${T.y} ${M.x} ${M.y} ${y.x} ${y.y}`,
576
+ `L ${h.x} ${h.y}`
640
577
  ].join(" ");
641
- if (this.line.setAttribute("d", Y), this.sourceArrow) {
642
- const $ = N(
643
- u,
644
- 0,
645
- 0,
578
+ }
579
+ }
580
+ class G {
581
+ constructor(e, t, s, o, i, n, h, c, d, g) {
582
+ a(this, "svg", N());
583
+ a(this, "group", $());
584
+ a(this, "line");
585
+ a(this, "sourceArrow", null);
586
+ a(this, "targetArrow", null);
587
+ a(this, "detourX");
588
+ a(this, "detourY");
589
+ this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.detourX = Math.cos(g) * d, this.detourY = Math.sin(g) * d, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
590
+ }
591
+ update(e, t, s, o, i) {
592
+ this.group.style.transform = `scale(${t}, ${s})`;
593
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, t, s);
594
+ if (this.line.setAttribute("d", c), this.sourceArrow) {
595
+ const d = x(
596
+ n,
597
+ l,
646
598
  this.arrowLength,
647
599
  this.arrowWidth
648
600
  );
649
- this.sourceArrow.setAttribute("d", $);
601
+ this.sourceArrow.setAttribute("d", d);
650
602
  }
651
603
  if (this.targetArrow) {
652
- const $ = N(
653
- w,
654
- s,
655
- o,
604
+ const d = x(
605
+ h,
606
+ e,
656
607
  -this.arrowLength,
657
608
  this.arrowWidth
658
609
  );
659
- this.targetArrow.setAttribute("d", $);
610
+ this.targetArrow.setAttribute("d", d);
660
611
  }
661
612
  }
613
+ createLinePath(e, t, s, o, i) {
614
+ const n = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, c = this.arrowLength + this.arrowOffset, d = p(
615
+ { x: c, y: l.y },
616
+ t,
617
+ l
618
+ ), g = this.detourX * o, w = this.detourY * i, m = { x: d.x + g, y: d.y + w }, y = p(
619
+ { x: e.x - c, y: e.y },
620
+ s,
621
+ e
622
+ ), v = { x: y.x + g, y: y.y + w };
623
+ return D(
624
+ [n, d, m, v, y, h],
625
+ this.roundness
626
+ );
627
+ }
662
628
  }
663
- const ut = (e) => (t) => t === T.PortCycle ? new dt(
664
- e.color,
665
- e.width,
666
- e.arrowLength,
667
- e.arrowWidth,
668
- e.hasSourceArrow || e.hasTargetArrow,
669
- e.cycleRadius,
670
- e.smallCycleRadius
671
- ) : t === T.NodeCycle ? new lt(
672
- e.color,
673
- e.width,
674
- e.curvature,
675
- e.arrowLength,
676
- e.arrowWidth,
677
- e.hasSourceArrow,
678
- e.hasTargetArrow,
679
- e.detourDistance,
680
- e.detourDirection
681
- ) : new nt(
682
- e.color,
683
- e.width,
684
- e.curvature,
685
- e.arrowLength,
686
- e.arrowWidth,
687
- e.hasSourceArrow,
688
- e.hasTargetArrow
689
- ), gt = (e) => (t) => t === T.PortCycle ? new U(
690
- e.color,
691
- e.width,
692
- e.arrowLength,
693
- e.arrowWidth,
694
- e.hasSourceArrow || e.hasTargetArrow,
695
- e.cycleSquareSide,
696
- e.arrowOffset,
697
- e.roundness
698
- ) : t === T.NodeCycle ? new _(
699
- e.color,
700
- e.width,
701
- e.arrowLength,
702
- e.arrowWidth,
703
- e.arrowOffset,
704
- e.hasSourceArrow,
705
- e.hasTargetArrow,
706
- e.roundness,
707
- e.detourDistance,
708
- e.detourDirection
709
- ) : new at(
710
- e.color,
711
- e.width,
712
- e.arrowLength,
713
- e.arrowWidth,
714
- e.arrowOffset,
715
- e.hasSourceArrow,
716
- e.hasTargetArrow,
717
- e.roundness
718
- ), wt = (e) => (t) => t === T.PortCycle ? new U(
719
- e.color,
720
- e.width,
721
- e.arrowLength,
722
- e.arrowWidth,
723
- e.hasSourceArrow || e.hasTargetArrow,
724
- e.cycleSquareSide,
725
- e.arrowOffset,
726
- e.roundness
727
- ) : t === T.NodeCycle ? new _(
728
- e.color,
729
- e.width,
730
- e.arrowLength,
731
- e.arrowWidth,
732
- e.arrowOffset,
733
- e.hasSourceArrow,
734
- e.hasTargetArrow,
735
- e.roundness,
736
- e.detourDistance,
737
- e.detourDirection
738
- ) : new ht(
739
- e.color,
740
- e.width,
741
- e.arrowLength,
742
- e.arrowWidth,
743
- e.arrowOffset,
744
- e.hasSourceArrow,
745
- e.hasTargetArrow,
746
- e.roundness
747
- ), pt = (e) => (t) => t === T.PortCycle ? new U(
748
- e.color,
749
- e.width,
750
- e.arrowLength,
751
- e.arrowWidth,
752
- e.hasSourceArrow || e.hasTargetArrow,
753
- e.cycleSquareSide,
754
- e.arrowOffset,
755
- e.roundness
756
- ) : t === T.NodeCycle ? new _(
757
- e.color,
758
- e.width,
759
- e.arrowLength,
760
- e.arrowWidth,
761
- e.arrowOffset,
762
- e.hasSourceArrow,
763
- e.hasTargetArrow,
764
- e.roundness,
765
- e.detourDistance,
766
- e.detourDirection
767
- ) : new ct(
768
- e.color,
769
- e.width,
770
- e.arrowLength,
771
- e.arrowWidth,
772
- e.arrowOffset,
773
- e.hasSourceArrow,
774
- e.hasTargetArrow,
775
- e.roundness
629
+ var A = /* @__PURE__ */ ((r) => (r.Regular = "regular", r.PortCycle = "port-cycle", r.NodeCycle = "node-cycle", r))(A || {});
630
+ const ae = (r) => (e) => e === A.PortCycle ? new ie(
631
+ r.color,
632
+ r.width,
633
+ r.arrowLength,
634
+ r.arrowWidth,
635
+ r.hasSourceArrow || r.hasTargetArrow,
636
+ r.cycleRadius,
637
+ r.smallCycleRadius
638
+ ) : e === A.NodeCycle ? new ne(
639
+ r.color,
640
+ r.width,
641
+ r.curvature,
642
+ r.arrowLength,
643
+ r.arrowWidth,
644
+ r.hasSourceArrow,
645
+ r.hasTargetArrow,
646
+ r.detourDistance,
647
+ r.detourDirection
648
+ ) : new te(
649
+ r.color,
650
+ r.width,
651
+ r.curvature,
652
+ r.arrowLength,
653
+ r.arrowWidth,
654
+ r.hasSourceArrow,
655
+ r.hasTargetArrow
656
+ ), he = (r) => (e) => e === A.PortCycle ? new B(
657
+ r.color,
658
+ r.width,
659
+ r.arrowLength,
660
+ r.arrowWidth,
661
+ r.hasSourceArrow || r.hasTargetArrow,
662
+ r.cycleSquareSide,
663
+ r.arrowOffset,
664
+ r.roundness
665
+ ) : e === A.NodeCycle ? new G(
666
+ r.color,
667
+ r.width,
668
+ r.arrowLength,
669
+ r.arrowWidth,
670
+ r.arrowOffset,
671
+ r.hasSourceArrow,
672
+ r.hasTargetArrow,
673
+ r.roundness,
674
+ r.detourDistance,
675
+ r.detourDirection
676
+ ) : new re(
677
+ r.color,
678
+ r.width,
679
+ r.arrowLength,
680
+ r.arrowWidth,
681
+ r.arrowOffset,
682
+ r.hasSourceArrow,
683
+ r.hasTargetArrow,
684
+ r.roundness
685
+ ), ce = (r) => (e) => e === A.PortCycle ? new B(
686
+ r.color,
687
+ r.width,
688
+ r.arrowLength,
689
+ r.arrowWidth,
690
+ r.hasSourceArrow || r.hasTargetArrow,
691
+ r.cycleSquareSide,
692
+ r.arrowOffset,
693
+ r.roundness
694
+ ) : e === A.NodeCycle ? new G(
695
+ r.color,
696
+ r.width,
697
+ r.arrowLength,
698
+ r.arrowWidth,
699
+ r.arrowOffset,
700
+ r.hasSourceArrow,
701
+ r.hasTargetArrow,
702
+ r.roundness,
703
+ r.detourDistance,
704
+ r.detourDirection
705
+ ) : new oe(
706
+ r.color,
707
+ r.width,
708
+ r.arrowLength,
709
+ r.arrowWidth,
710
+ r.arrowOffset,
711
+ r.hasSourceArrow,
712
+ r.hasTargetArrow,
713
+ r.roundness
714
+ ), de = (r) => (e) => e === A.PortCycle ? new B(
715
+ r.color,
716
+ r.width,
717
+ r.arrowLength,
718
+ r.arrowWidth,
719
+ r.hasSourceArrow || r.hasTargetArrow,
720
+ r.cycleSquareSide,
721
+ r.arrowOffset,
722
+ r.roundness
723
+ ) : e === A.NodeCycle ? new G(
724
+ r.color,
725
+ r.width,
726
+ r.arrowLength,
727
+ r.arrowWidth,
728
+ r.arrowOffset,
729
+ r.hasSourceArrow,
730
+ r.hasTargetArrow,
731
+ r.roundness,
732
+ r.detourDistance,
733
+ r.detourDirection
734
+ ) : new se(
735
+ r.color,
736
+ r.width,
737
+ r.arrowLength,
738
+ r.arrowWidth,
739
+ r.arrowOffset,
740
+ r.hasSourceArrow,
741
+ r.hasTargetArrow,
742
+ r.roundness
776
743
  );
777
- class X {
778
- constructor(t) {
779
- n(this, "counter", 0);
780
- this.checkExists = t;
781
- }
782
- create(t) {
783
- if (t !== void 0)
784
- return t;
744
+ class F {
745
+ constructor(e) {
746
+ a(this, "counter", 0);
747
+ this.checkExists = e;
748
+ }
749
+ create(e) {
750
+ if (e !== void 0)
751
+ return e;
785
752
  for (; this.checkExists(this.counter); )
786
753
  this.counter++;
787
754
  return this.counter;
@@ -790,123 +757,123 @@ class X {
790
757
  this.counter = 0;
791
758
  }
792
759
  }
793
- class S extends Error {
760
+ class C extends Error {
794
761
  constructor() {
795
762
  super(...arguments);
796
- n(this, "name", "HtmlGraphError");
763
+ a(this, "name", "HtmlGraphError");
797
764
  }
798
765
  }
799
- class yt {
800
- constructor(t, r, s, o, i, h, c, a) {
801
- n(this, "nodeIdGenerator", new X(
802
- (t) => this.graphStore.getNode(t) !== void 0
766
+ class le {
767
+ constructor(e, t, s, o, i, n, h, c) {
768
+ a(this, "nodeIdGenerator", new F(
769
+ (e) => this.graphStore.getNode(e) !== void 0
803
770
  ));
804
- n(this, "portIdGenerator", new X(
805
- (t) => this.graphStore.getPort(t) !== void 0
771
+ a(this, "portIdGenerator", new F(
772
+ (e) => this.graphStore.getPort(e) !== void 0
806
773
  ));
807
- n(this, "edgeIdGenerator", new X(
808
- (t) => this.graphStore.getEdge(t) !== void 0
774
+ a(this, "edgeIdGenerator", new F(
775
+ (e) => this.graphStore.getEdge(e) !== void 0
809
776
  ));
810
- this.graphStore = t, this.htmlController = r, this.viewportTransformer = s, this.defaultNodesCenterFn = o, this.defaultPortsCenterFn = i, this.defaultPortsDirection = h, this.defaultNodesPriorityFn = c, this.defaultEdgesPriorityFn = a;
777
+ this.graphStore = e, this.htmlController = t, this.viewportTransformer = s, this.defaultNodesCenterFn = o, this.defaultPortsCenterFn = i, this.defaultPortsDirection = n, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = c;
811
778
  }
812
- addNode(t, r, s, o, i, h, c) {
813
- if (t = this.nodeIdGenerator.create(t), this.graphStore.getNode(t) !== void 0)
814
- throw new S("failed to add node with existing id");
779
+ addNode(e, t, s, o, i, n, h) {
780
+ if (e = this.nodeIdGenerator.create(e), this.graphStore.getNode(e) !== void 0)
781
+ throw new C("failed to add node with existing id");
815
782
  this.graphStore.addNode(
783
+ e,
816
784
  t,
817
- r,
818
785
  s,
819
786
  o,
820
- h ?? this.defaultNodesCenterFn,
821
- c ?? this.defaultNodesPriorityFn()
822
- ), this.htmlController.attachNode(t), Array.from(i ?? []).forEach((a) => {
787
+ n ?? this.defaultNodesCenterFn,
788
+ h ?? this.defaultNodesPriorityFn()
789
+ ), this.htmlController.attachNode(e), Array.from(i ?? []).forEach((c) => {
823
790
  this.markPort(
824
- a.id,
825
- a.element,
826
- t,
827
- a.centerFn ?? this.defaultPortsCenterFn,
828
- a.direction ?? this.defaultPortsDirection
791
+ c.id,
792
+ c.element,
793
+ e,
794
+ c.centerFn ?? this.defaultPortsCenterFn,
795
+ c.direction ?? this.defaultPortsDirection
829
796
  );
830
797
  });
831
798
  }
832
- updateNode(t, r, s, o, i) {
833
- const h = this.graphStore.getNode(t);
834
- if (h === void 0)
835
- throw new S("failed to update nonexisting node");
836
- h.x = r ?? h.x, h.y = s ?? h.y, h.centerFn = i ?? h.centerFn, this.htmlController.updateNodeCoordinates(t), o !== void 0 && (h.priority = o, this.htmlController.updateNodePriority(t));
837
- }
838
- removeNode(t) {
839
- if (this.graphStore.getNode(t) === void 0)
840
- throw new S("failed to remove nonexisting node");
841
- (this.graphStore.getNodePortIds(t) ?? []).forEach((r) => {
842
- this.unmarkPort(r);
843
- }), this.htmlController.detachNode(t), this.graphStore.removeNode(t);
844
- }
845
- markPort(t, r, s, o, i) {
846
- if (t = this.portIdGenerator.create(t), this.graphStore.getNode(s) === void 0)
847
- throw new S("failed to set port on nonexisting node");
848
- if (this.graphStore.getPort(t) !== void 0)
849
- throw new S("failed to add port with existing id");
799
+ updateNode(e, t, s, o, i) {
800
+ const n = this.graphStore.getNode(e);
801
+ if (n === void 0)
802
+ throw new C("failed to update nonexisting node");
803
+ n.x = t ?? n.x, n.y = s ?? n.y, n.centerFn = i ?? n.centerFn, this.htmlController.updateNodeCoordinates(e), o !== void 0 && (n.priority = o, this.htmlController.updateNodePriority(e));
804
+ }
805
+ removeNode(e) {
806
+ if (this.graphStore.getNode(e) === void 0)
807
+ throw new C("failed to remove nonexisting node");
808
+ (this.graphStore.getNodePortIds(e) ?? []).forEach((t) => {
809
+ this.unmarkPort(t);
810
+ }), this.htmlController.detachNode(e), this.graphStore.removeNode(e);
811
+ }
812
+ markPort(e, t, s, o, i) {
813
+ if (e = this.portIdGenerator.create(e), this.graphStore.getNode(s) === void 0)
814
+ throw new C("failed to set port on nonexisting node");
815
+ if (this.graphStore.getPort(e) !== void 0)
816
+ throw new C("failed to add port with existing id");
850
817
  this.graphStore.addPort(
818
+ e,
851
819
  t,
852
- r,
853
820
  s,
854
821
  o ?? this.defaultPortsCenterFn,
855
822
  i ?? this.defaultPortsDirection
856
823
  );
857
824
  }
858
- updatePort(t, r, s) {
859
- const o = this.graphStore.getPort(t);
825
+ updatePort(e, t, s) {
826
+ const o = this.graphStore.getPort(e);
860
827
  if (o === void 0)
861
- throw new S("failed to unset nonexisting port");
862
- o.direction = r ?? o.direction, o.centerFn = s ?? o.centerFn, this.htmlController.updatePortEdges(t);
863
- }
864
- unmarkPort(t) {
865
- if (this.graphStore.getPort(t) === void 0)
866
- throw new S("failed to unset nonexisting port");
867
- this.graphStore.getPortAdjacentEdgeIds(t).forEach((r) => {
868
- this.removeEdge(r);
869
- }), this.graphStore.removePort(t);
870
- }
871
- addEdge(t, r, s, o, i) {
872
- if (t = this.edgeIdGenerator.create(t), this.graphStore.getPort(r) === void 0)
873
- throw new S("failed to add edge from nonexisting port");
828
+ throw new C("failed to unset nonexisting port");
829
+ o.direction = t ?? o.direction, o.centerFn = s ?? o.centerFn, this.htmlController.updatePortEdges(e);
830
+ }
831
+ unmarkPort(e) {
832
+ if (this.graphStore.getPort(e) === void 0)
833
+ throw new C("failed to unset nonexisting port");
834
+ this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
835
+ this.removeEdge(t);
836
+ }), this.graphStore.removePort(e);
837
+ }
838
+ addEdge(e, t, s, o, i) {
839
+ if (e = this.edgeIdGenerator.create(e), this.graphStore.getPort(t) === void 0)
840
+ throw new C("failed to add edge from nonexisting port");
874
841
  if (this.graphStore.getPort(s) === void 0)
875
- throw new S("failed to add edge to nonexisting port");
876
- if (this.graphStore.getEdge(t) !== void 0)
877
- throw new S("failed to add edge with existing id");
878
- const h = this.resolveEdgeType(r, s);
842
+ throw new C("failed to add edge to nonexisting port");
843
+ if (this.graphStore.getEdge(e) !== void 0)
844
+ throw new C("failed to add edge with existing id");
845
+ const n = this.resolveEdgeType(t, s);
879
846
  this.graphStore.addEdge(
847
+ e,
880
848
  t,
881
- r,
882
849
  s,
883
- o(h),
850
+ o(n),
884
851
  i ?? this.defaultEdgesPriorityFn()
885
- ), this.htmlController.attachEdge(t);
852
+ ), this.htmlController.attachEdge(e);
886
853
  }
887
- updateEdge(t, r, s) {
888
- const o = this.graphStore.getEdge(t);
854
+ updateEdge(e, t, s) {
855
+ const o = this.graphStore.getEdge(e);
889
856
  if (o === void 0)
890
- throw new S("failed to update nonexisting edge");
891
- if (r !== void 0) {
857
+ throw new C("failed to update nonexisting edge");
858
+ if (t !== void 0) {
892
859
  const i = this.resolveEdgeType(o.from, o.to);
893
- o.shape = r(i), this.htmlController.updateEdgeShape(t);
860
+ o.shape = t(i), this.htmlController.updateEdgeShape(e);
894
861
  }
895
- s !== void 0 && (o.priority = s, this.htmlController.updateEdgePriority(t));
862
+ s !== void 0 && (o.priority = s, this.htmlController.updateEdgePriority(e));
896
863
  }
897
- removeEdge(t) {
898
- if (this.graphStore.getEdge(t) === void 0)
899
- throw new S("failed to remove nonexisting edge");
900
- this.htmlController.detachEdge(t), this.graphStore.removeEdge(t);
864
+ removeEdge(e) {
865
+ if (this.graphStore.getEdge(e) === void 0)
866
+ throw new C("failed to remove nonexisting edge");
867
+ this.htmlController.detachEdge(e), this.graphStore.removeEdge(e);
901
868
  }
902
- patchViewportMatrix(t, r, s) {
903
- this.viewportTransformer.patchViewportMatrix(t, r, s), this.htmlController.applyTransform();
869
+ patchViewportMatrix(e, t, s) {
870
+ this.viewportTransformer.patchViewportMatrix(e, t, s), this.htmlController.applyTransform();
904
871
  }
905
- patchContentMatrix(t, r, s) {
906
- this.viewportTransformer.patchContentMatrix(t, r, s), this.htmlController.applyTransform();
872
+ patchContentMatrix(e, t, s) {
873
+ this.viewportTransformer.patchContentMatrix(e, t, s), this.htmlController.applyTransform();
907
874
  }
908
- attach(t) {
909
- this.htmlController.attach(t);
875
+ attach(e) {
876
+ this.htmlController.attach(e);
910
877
  }
911
878
  detach() {
912
879
  this.htmlController.detach();
@@ -917,238 +884,197 @@ class yt {
917
884
  destroy() {
918
885
  this.htmlController.destroy();
919
886
  }
920
- resolveEdgeType(t, r) {
921
- if (t === r)
922
- return T.PortCycle;
923
- const s = this.graphStore.getPortNodeId(t), o = this.graphStore.getPortNodeId(r);
924
- return s === o ? T.NodeCycle : T.Regular;
887
+ resolveEdgeType(e, t) {
888
+ if (e === t)
889
+ return A.PortCycle;
890
+ const s = this.graphStore.getPortNodeId(e), o = this.graphStore.getPortNodeId(t);
891
+ return s === o ? A.NodeCycle : A.Regular;
925
892
  }
926
893
  }
927
- const mt = () => {
928
- const e = document.createElement("div");
929
- return e.style.width = "100%", e.style.height = "100%", e.style.position = "relative", e.style.overflow = "hidden", e;
930
- }, vt = () => {
931
- const e = document.createElement("canvas");
932
- return e.style.position = "absolute", e.style.inset = "0", e;
933
- }, ft = () => {
934
- const e = document.createElement("div");
935
- return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.width = "0", e.style.height = "0", e;
936
- }, xt = () => {
937
- const e = document.createElement("div");
938
- return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.visibility = "hidden", e;
894
+ const ue = () => {
895
+ const r = document.createElement("div");
896
+ return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
897
+ }, ge = () => {
898
+ const r = document.createElement("div");
899
+ return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
900
+ }, we = () => {
901
+ const r = document.createElement("div");
902
+ return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden", r;
939
903
  };
940
- class Ct {
904
+ class ye {
941
905
  constructor() {
942
- n(this, "keyMap", /* @__PURE__ */ new Map());
943
- n(this, "valueMap", /* @__PURE__ */ new Map());
906
+ a(this, "keyMap", /* @__PURE__ */ new Map());
907
+ a(this, "valueMap", /* @__PURE__ */ new Map());
944
908
  }
945
- set(t, r) {
946
- this.keyMap.set(t, r), this.valueMap.set(r, t);
909
+ set(e, t) {
910
+ this.keyMap.set(e, t), this.valueMap.set(t, e);
947
911
  }
948
- getByKey(t) {
949
- return this.keyMap.get(t);
912
+ getByKey(e) {
913
+ return this.keyMap.get(e);
950
914
  }
951
- getByValue(t) {
952
- return this.valueMap.get(t);
915
+ getByValue(e) {
916
+ return this.valueMap.get(e);
953
917
  }
954
- deleteByKey(t) {
955
- const r = this.keyMap.get(t);
956
- r !== void 0 && this.valueMap.delete(r), this.keyMap.delete(t);
918
+ deleteByKey(e) {
919
+ const t = this.keyMap.get(e);
920
+ t !== void 0 && this.valueMap.delete(t), this.keyMap.delete(e);
957
921
  }
958
- deleteByValue(t) {
959
- const r = this.valueMap.get(t);
960
- r !== void 0 && this.keyMap.delete(r), this.valueMap.delete(t);
922
+ deleteByValue(e) {
923
+ const t = this.valueMap.get(e);
924
+ t !== void 0 && this.keyMap.delete(t), this.valueMap.delete(e);
961
925
  }
962
- forEach(t) {
963
- this.keyMap.forEach((r, s) => {
964
- t(r, s);
926
+ forEach(e) {
927
+ this.keyMap.forEach((t, s) => {
928
+ e(t, s);
965
929
  });
966
930
  }
967
931
  clear() {
968
932
  this.keyMap.clear(), this.valueMap.clear();
969
933
  }
970
934
  }
971
- class Et {
972
- constructor(t, r, s, o) {
973
- n(this, "canvasWrapper", null);
974
- n(this, "host", mt());
975
- n(this, "canvas", vt());
976
- n(this, "container", ft());
977
- n(this, "canvasCtx");
978
- n(this, "canvasResizeObserver");
979
- n(this, "nodesResizeObserver");
980
- n(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
981
- n(this, "nodeIdToWrapperElementMap", new Ct());
982
- n(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
983
- this.graphStore = t, this.viewportTransformer = r, this.publicViewportTransformer = s, this.backgroundDrawingFn = o;
984
- const i = this.canvas.getContext("2d");
985
- if (i === null)
986
- throw new S("unable to get canvas context");
987
- this.canvasCtx = i, this.host.appendChild(this.canvas), this.host.appendChild(this.container), this.canvasResizeObserver = this.createHostResizeObserver(), this.nodesResizeObserver = this.createNodesResizeObserver();
935
+ class me {
936
+ constructor(e, t) {
937
+ a(this, "canvasWrapper", null);
938
+ a(this, "host", ue());
939
+ a(this, "container", ge());
940
+ a(this, "nodesResizeObserver");
941
+ a(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
942
+ a(this, "nodeIdToWrapperElementMap", new ye());
943
+ a(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
944
+ this.graphStore = e, this.viewportTransformer = t, this.host.appendChild(this.container), this.nodesResizeObserver = this.createNodesResizeObserver();
945
+ }
946
+ attach(e) {
947
+ this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host);
988
948
  }
989
- clear() {
990
- this.edgeIdToElementMap.forEach((t, r) => {
991
- this.detachEdge(r);
992
- }), this.nodeIdToWrapperElementMap.forEach((t, r) => {
993
- this.detachNode(r);
994
- });
949
+ detach() {
950
+ this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
995
951
  }
996
- attach(t) {
997
- this.detach(), this.canvasWrapper = t, this.canvasWrapper.appendChild(this.host), this.canvasResizeObserver.observe(this.canvasWrapper);
952
+ applyTransform() {
953
+ const e = this.viewportTransformer.getContentMatrix();
954
+ this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.dx}, ${e.dy})`;
998
955
  }
999
- detach() {
1000
- this.canvasWrapper !== null && (this.canvasResizeObserver.unobserve(this.canvasWrapper), this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
956
+ attachNode(e) {
957
+ const t = this.graphStore.getNode(e), s = we();
958
+ s.appendChild(t.element), this.container.appendChild(s), this.nodeElementToIdMap.set(t.element, e), this.nodeIdToWrapperElementMap.set(e, s), this.updateNodeCoordinatesInternal(e), this.updateNodePriority(e), this.nodesResizeObserver.observe(s), s.style.visibility = "visible";
1001
959
  }
1002
- destroy() {
1003
- this.canvasResizeObserver.disconnect(), this.nodesResizeObserver.disconnect(), this.host.removeChild(this.canvas), this.host.removeChild(this.container), this.clear(), this.detach();
960
+ detachNode(e) {
961
+ const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.getByKey(e);
962
+ this.nodesResizeObserver.unobserve(s), s.removeChild(t.element), this.container.removeChild(s), this.nodeElementToIdMap.delete(t.element), this.nodeIdToWrapperElementMap.deleteByKey(e);
1004
963
  }
1005
- applyTransform() {
1006
- this.backgroundDrawingFn(this.canvasCtx, this.publicViewportTransformer);
1007
- const t = this.viewportTransformer.getContentMatrix();
1008
- this.container.style.transform = `matrix(${t.scale}, 0, 0, ${t.scale}, ${t.dx}, ${t.dy})`;
1009
- }
1010
- attachNode(t) {
1011
- const r = this.graphStore.getNode(t), s = xt();
1012
- s.appendChild(r.element), this.container.appendChild(s), this.nodeElementToIdMap.set(r.element, t), this.nodeIdToWrapperElementMap.set(t, s), this.updateNodeCoords(t), this.updateNodePriority(t), this.nodesResizeObserver.observe(s), s.style.visibility = "visible";
1013
- }
1014
- detachNode(t) {
1015
- const r = this.graphStore.getNode(t), s = this.nodeIdToWrapperElementMap.getByKey(t);
1016
- this.nodesResizeObserver.unobserve(s), s.removeChild(r.element), this.container.removeChild(s), this.nodeElementToIdMap.delete(r.element), this.nodeIdToWrapperElementMap.deleteByKey(t);
1017
- }
1018
- attachEdge(t) {
1019
- const r = this.graphStore.getEdge(t);
1020
- this.edgeIdToElementMap.set(t, r.shape.svg), this.container.appendChild(r.shape.svg), this.updateEdgeCoords(t), this.updateEdgePriority(t);
1021
- }
1022
- detachEdge(t) {
1023
- const r = this.graphStore.getEdge(t);
1024
- this.container.removeChild(r.shape.svg), this.edgeIdToElementMap.delete(t);
1025
- }
1026
- updateNodeCoordinates(t) {
1027
- const r = this.graphStore.getNodeAdjacentEdgeIds(t);
1028
- this.updateNodeCoords(t), r.forEach((s) => {
1029
- this.updateEdgeCoords(s);
1030
- });
964
+ attachEdge(e) {
965
+ const t = this.graphStore.getEdge(e);
966
+ this.edgeIdToElementMap.set(e, t.shape.svg), this.container.appendChild(t.shape.svg), this.updateEdgeCoordinates(e), this.updateEdgePriority(e);
1031
967
  }
1032
- updateNodePriority(t) {
1033
- const r = this.graphStore.getNode(t), s = this.nodeIdToWrapperElementMap.getByKey(t);
1034
- s.style.zIndex = `${r.priority}`;
968
+ detachEdge(e) {
969
+ const t = this.graphStore.getEdge(e);
970
+ this.container.removeChild(t.shape.svg), this.edgeIdToElementMap.delete(e);
1035
971
  }
1036
- updateEdgeShape(t) {
1037
- const r = this.edgeIdToElementMap.get(t);
1038
- this.container.removeChild(r);
1039
- const s = this.graphStore.getEdge(t);
1040
- this.edgeIdToElementMap.set(t, s.shape.svg), this.container.appendChild(s.shape.svg), this.updateEdgeCoords(t), this.updateEdgePriority(t);
972
+ clear() {
973
+ this.edgeIdToElementMap.forEach((e, t) => {
974
+ this.detachEdge(t);
975
+ }), this.nodeIdToWrapperElementMap.forEach((e, t) => {
976
+ this.detachNode(t);
977
+ });
1041
978
  }
1042
- updateEdgePriority(t) {
1043
- const r = this.graphStore.getEdge(t);
1044
- r.shape.svg.style.zIndex = `${r.priority}`;
979
+ destroy() {
980
+ this.nodesResizeObserver.disconnect(), this.host.removeChild(this.container), this.clear(), this.detach();
1045
981
  }
1046
- updatePortEdges(t) {
1047
- this.graphStore.getPortAdjacentEdgeIds(t).forEach((s) => {
1048
- this.updateEdgeCoords(s);
982
+ updateNodeCoordinates(e) {
983
+ const t = this.graphStore.getNodeAdjacentEdgeIds(e);
984
+ this.updateNodeCoordinatesInternal(e), t.forEach((s) => {
985
+ this.updateEdgeCoordinates(s);
1049
986
  });
1050
987
  }
1051
- createHostResizeObserver() {
1052
- return new ResizeObserver(() => {
1053
- this.updateCanvasDimensions(), this.applyTransform();
988
+ updateNodePriority(e) {
989
+ const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.getByKey(e);
990
+ s.style.zIndex = `${t.priority}`;
991
+ }
992
+ updateEdgeShape(e) {
993
+ const t = this.edgeIdToElementMap.get(e);
994
+ this.container.removeChild(t);
995
+ const s = this.graphStore.getEdge(e);
996
+ this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg), this.updateEdgeCoordinates(e), this.updateEdgePriority(e);
997
+ }
998
+ updateEdgePriority(e) {
999
+ const t = this.graphStore.getEdge(e);
1000
+ t.shape.svg.style.zIndex = `${t.priority}`;
1001
+ }
1002
+ updatePortEdges(e) {
1003
+ this.graphStore.getPortAdjacentEdgeIds(e).forEach((s) => {
1004
+ this.updateEdgeCoordinates(s);
1054
1005
  });
1055
1006
  }
1056
1007
  createNodesResizeObserver() {
1057
- return new ResizeObserver((t) => {
1058
- t.forEach((r) => {
1059
- const s = r.target, o = this.nodeIdToWrapperElementMap.getByValue(s);
1060
- this.updateNodeCoords(o), this.graphStore.getNodeAdjacentEdgeIds(o).forEach((h) => {
1061
- this.updateEdgeCoords(h);
1008
+ return new ResizeObserver((e) => {
1009
+ e.forEach((t) => {
1010
+ const s = t.target, o = this.nodeIdToWrapperElementMap.getByValue(s);
1011
+ this.updateNodeCoordinatesInternal(o), this.graphStore.getNodeAdjacentEdgeIds(o).forEach((n) => {
1012
+ this.updateEdgeCoordinates(n);
1062
1013
  });
1063
1014
  });
1064
1015
  });
1065
1016
  }
1066
- updateCanvasDimensions() {
1067
- const { width: t, height: r } = this.host.getBoundingClientRect();
1068
- this.canvas.width = t, this.canvas.height = r;
1069
- }
1070
- updateNodeCoords(t) {
1071
- const r = this.nodeIdToWrapperElementMap.getByKey(t), { width: s, height: o } = r.getBoundingClientRect(), i = this.viewportTransformer.getViewportMatrix().scale, h = this.graphStore.getNode(t), { x: c, y: a } = h.centerFn(s, o), d = h.x - i * c, l = h.y - i * a;
1072
- r.style.transform = `matrix(1, 0, 0, 1, ${d}, ${l})`;
1073
- }
1074
- updateEdgeCoords(t) {
1075
- const r = this.graphStore.getEdge(t), s = this.graphStore.getPort(r.from), o = this.graphStore.getPort(r.to), i = s.element.getBoundingClientRect(), h = o.element.getBoundingClientRect(), c = this.host.getBoundingClientRect(), a = this.viewportTransformer.getViewportMatrix(), d = a.scale * (i.left - c.left) + a.dx, l = a.scale * (i.top - c.top) + a.dy, u = a.scale * (h.left - c.left) + a.dx, w = a.scale * (h.top - c.top) + a.dy, { x: v, y: p } = s.centerFn(
1076
- i.width * a.scale,
1077
- i.height * a.scale
1078
- ), { x: f, y: m } = o.centerFn(
1079
- h.width * a.scale,
1080
- h.height * a.scale
1081
- ), x = v + d, y = p + l, C = f + u, A = m + w, M = Math.min(x, C), F = Math.min(y, A), D = Math.abs(C - x), W = Math.abs(A - y);
1082
- r.shape.update(M, F, D, W, s, o);
1017
+ updateNodeCoordinatesInternal(e) {
1018
+ const t = this.nodeIdToWrapperElementMap.getByKey(e), { width: s, height: o } = t.getBoundingClientRect(), i = this.viewportTransformer.getViewportMatrix().scale, n = this.graphStore.getNode(e), { x: h, y: c } = n.centerFn(s, o), d = n.x - i * h, g = n.y - i * c;
1019
+ t.style.transform = `matrix(1, 0, 0, 1, ${d}, ${g})`;
1020
+ }
1021
+ updateEdgeCoordinates(e) {
1022
+ const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), o = this.graphStore.getPort(t.to), i = s.element.getBoundingClientRect(), n = o.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix(), d = {
1023
+ x: c.scale * (i.left - h.left) + c.dx,
1024
+ y: c.scale * (i.top - h.top) + c.dy
1025
+ }, g = {
1026
+ x: c.scale * (n.left - h.left) + c.dx,
1027
+ y: c.scale * (n.top - h.top) + c.dy
1028
+ }, w = s.centerFn(
1029
+ i.width * c.scale,
1030
+ i.height * c.scale
1031
+ ), m = o.centerFn(
1032
+ n.width * c.scale,
1033
+ n.height * c.scale
1034
+ ), y = {
1035
+ x: d.x + w.x,
1036
+ y: d.y + w.y
1037
+ }, v = {
1038
+ x: g.x + m.x,
1039
+ y: g.y + m.y
1040
+ }, S = Math.min(y.x, v.x), P = Math.min(y.y, v.y), M = Math.abs(v.x - y.x), b = Math.abs(v.y - y.y);
1041
+ t.shape.svg.style.width = `${M}px`, t.shape.svg.style.height = `${b}px`, t.shape.svg.style.transform = `translate(${S}px, ${P}px)`;
1042
+ const T = y.x <= v.x ? 1 : -1, W = y.y <= v.y ? 1 : -1;
1043
+ t.shape.update(
1044
+ { x: M, y: b },
1045
+ T,
1046
+ W,
1047
+ s.direction,
1048
+ o.direction
1049
+ );
1083
1050
  }
1084
1051
  }
1085
- class At {
1086
- constructor(t, r, s, o, i, h) {
1087
- n(this, "publicViewportTransformer");
1088
- n(this, "publicGraphStore");
1089
- n(this, "canvasController");
1090
- const c = new rt(), a = new ot();
1091
- this.publicGraphStore = new it(a), this.publicViewportTransformer = new st(
1092
- c
1093
- );
1094
- const d = new Et(
1095
- a,
1096
- c,
1097
- this.publicViewportTransformer,
1098
- t
1052
+ class pe {
1053
+ constructor(e, t, s, o, i) {
1054
+ a(this, "publicViewportTransformer");
1055
+ a(this, "publicGraphStore");
1056
+ a(this, "canvasController");
1057
+ const n = new Q(), h = new q();
1058
+ this.publicGraphStore = new ee(h), this.publicViewportTransformer = new Z(
1059
+ n
1099
1060
  );
1100
- this.canvasController = new yt(
1101
- a,
1102
- d,
1061
+ const c = new me(h, n);
1062
+ this.canvasController = new le(
1063
+ h,
1103
1064
  c,
1104
- r,
1065
+ n,
1066
+ e,
1067
+ t,
1105
1068
  s,
1106
1069
  o,
1107
- i,
1108
- h
1070
+ i
1109
1071
  );
1110
1072
  }
1111
1073
  }
1112
- const Q = (e, t) => ({
1113
- x: e / 2,
1114
- y: t / 2
1115
- }), Mt = () => () => {
1116
- }, St = (e, t, r, s, o, i, h) => {
1117
- e.clearRect(0, 0, e.canvas.width, e.canvas.height), e.fillStyle = i, e.fillRect(0, 0, e.canvas.width, e.canvas.height);
1118
- const c = t.getContentMatrix(), a = s * c.scale, d = e.canvas.width / a, l = e.canvas.height / a;
1119
- if (d * l > h)
1120
- return;
1121
- const u = c.dx - Math.floor(c.dx / a) * a, w = c.dy - Math.floor(c.dy / a) * a, v = o * c.scale, p = 2 * Math.PI, f = u - a, m = w - a, x = e.canvas.width + u, y = e.canvas.height + w;
1122
- e.fillStyle = r;
1123
- for (let C = f; C <= x; C += a)
1124
- for (let A = m; A <= y; A += a)
1125
- e.beginPath(), e.arc(C, A, v, 0, p), e.closePath(), e.fill();
1126
- }, Pt = (e, t, r, s, o) => (i, h) => {
1127
- St(
1128
- i,
1129
- h,
1130
- e,
1131
- t,
1132
- r,
1133
- s,
1134
- o
1135
- );
1136
- }, Nt = (e) => {
1137
- switch (e == null ? void 0 : e.type) {
1138
- case "custom":
1139
- return e.drawingFn;
1140
- case "dots":
1141
- return Pt(
1142
- e.dotColor ?? "#d8d8d8",
1143
- e.dotGap ?? 25,
1144
- e.dotRadius ?? 1.5,
1145
- e.color ?? "#ffffff",
1146
- e.limit ?? 1e4
1147
- );
1148
- default:
1149
- return Mt();
1150
- }
1151
- }, g = {
1074
+ const H = (r, e) => ({
1075
+ x: r / 2,
1076
+ y: e / 2
1077
+ }), u = {
1152
1078
  edgeColor: "#5c5c5c",
1153
1079
  edgeWidth: 1,
1154
1080
  edgeArrowLength: 15,
@@ -1162,199 +1088,193 @@ const Q = (e, t) => ({
1162
1088
  detourDirection: -Math.PI / 2,
1163
1089
  smallCycleSize: 15,
1164
1090
  curvature: 90
1165
- }, j = (e) => {
1166
- switch (e == null ? void 0 : e.type) {
1091
+ }, R = (r) => {
1092
+ switch (r == null ? void 0 : r.type) {
1167
1093
  case "custom":
1168
- return e.factory;
1094
+ return r.factory;
1169
1095
  case "straight":
1170
- return gt({
1171
- color: e.color ?? g.edgeColor,
1172
- width: e.width ?? g.edgeWidth,
1173
- arrowLength: e.arrowLength ?? g.edgeArrowLength,
1174
- arrowWidth: e.arrowWidth ?? g.edgeArrowWidth,
1175
- arrowOffset: e.arrowOffset ?? g.edgeArrowOffset,
1176
- hasSourceArrow: e.hasSourceArrow ?? g.hasSourceArrow,
1177
- hasTargetArrow: e.hasTargetArrow ?? g.hasTargetArrow,
1178
- cycleSquareSide: e.cycleSquareSide ?? g.cycleSize,
1179
- roundness: e.roundness ?? g.roundness,
1180
- detourDistance: e.detourDistance ?? g.detourDistance,
1181
- detourDirection: e.detourDirection ?? g.detourDirection
1096
+ return he({
1097
+ color: r.color ?? u.edgeColor,
1098
+ width: r.width ?? u.edgeWidth,
1099
+ arrowLength: r.arrowLength ?? u.edgeArrowLength,
1100
+ arrowWidth: r.arrowWidth ?? u.edgeArrowWidth,
1101
+ arrowOffset: r.arrowOffset ?? u.edgeArrowOffset,
1102
+ hasSourceArrow: r.hasSourceArrow ?? u.hasSourceArrow,
1103
+ hasTargetArrow: r.hasTargetArrow ?? u.hasTargetArrow,
1104
+ cycleSquareSide: r.cycleSquareSide ?? u.cycleSize,
1105
+ roundness: r.roundness ?? u.roundness,
1106
+ detourDistance: r.detourDistance ?? u.detourDistance,
1107
+ detourDirection: r.detourDirection ?? u.detourDirection
1182
1108
  });
1183
1109
  case "horizontal":
1184
- return wt({
1185
- color: e.color ?? g.edgeColor,
1186
- width: e.width ?? g.edgeWidth,
1187
- arrowLength: e.arrowLength ?? g.edgeArrowLength,
1188
- arrowWidth: e.arrowWidth ?? g.edgeArrowWidth,
1189
- arrowOffset: e.arrowOffset ?? g.edgeArrowOffset,
1190
- hasSourceArrow: e.hasSourceArrow ?? g.hasSourceArrow,
1191
- hasTargetArrow: e.hasTargetArrow ?? g.hasTargetArrow,
1192
- cycleSquareSide: e.cycleSquareSide ?? g.cycleSize,
1193
- roundness: e.roundness ?? g.roundness,
1194
- detourDistance: e.detourDistance ?? g.detourDistance,
1195
- detourDirection: e.detourDirection ?? g.detourDirection
1110
+ return de({
1111
+ color: r.color ?? u.edgeColor,
1112
+ width: r.width ?? u.edgeWidth,
1113
+ arrowLength: r.arrowLength ?? u.edgeArrowLength,
1114
+ arrowWidth: r.arrowWidth ?? u.edgeArrowWidth,
1115
+ arrowOffset: r.arrowOffset ?? u.edgeArrowOffset,
1116
+ hasSourceArrow: r.hasSourceArrow ?? u.hasSourceArrow,
1117
+ hasTargetArrow: r.hasTargetArrow ?? u.hasTargetArrow,
1118
+ cycleSquareSide: r.cycleSquareSide ?? u.cycleSize,
1119
+ roundness: r.roundness ?? u.roundness,
1120
+ detourDistance: r.detourDistance ?? u.detourDistance,
1121
+ detourDirection: r.detourDirection ?? u.detourDirection
1196
1122
  });
1197
1123
  case "vertical":
1198
- return pt({
1199
- color: e.color ?? g.edgeColor,
1200
- width: e.width ?? g.edgeWidth,
1201
- arrowLength: e.arrowLength ?? g.edgeArrowLength,
1202
- arrowWidth: e.arrowWidth ?? g.edgeArrowWidth,
1203
- arrowOffset: e.arrowOffset ?? g.edgeArrowOffset,
1204
- hasSourceArrow: e.hasSourceArrow ?? g.hasSourceArrow,
1205
- hasTargetArrow: e.hasTargetArrow ?? g.hasTargetArrow,
1206
- cycleSquareSide: e.cycleSquareSide ?? g.cycleSize,
1207
- roundness: e.roundness ?? g.roundness,
1208
- detourDistance: e.detourDistance ?? g.detourDistance,
1209
- detourDirection: e.detourDirection ?? g.detourDirection
1124
+ return ce({
1125
+ color: r.color ?? u.edgeColor,
1126
+ width: r.width ?? u.edgeWidth,
1127
+ arrowLength: r.arrowLength ?? u.edgeArrowLength,
1128
+ arrowWidth: r.arrowWidth ?? u.edgeArrowWidth,
1129
+ arrowOffset: r.arrowOffset ?? u.edgeArrowOffset,
1130
+ hasSourceArrow: r.hasSourceArrow ?? u.hasSourceArrow,
1131
+ hasTargetArrow: r.hasTargetArrow ?? u.hasTargetArrow,
1132
+ cycleSquareSide: r.cycleSquareSide ?? u.cycleSize,
1133
+ roundness: r.roundness ?? u.roundness,
1134
+ detourDistance: r.detourDistance ?? u.detourDistance,
1135
+ detourDirection: r.detourDirection ?? u.detourDirection
1210
1136
  });
1211
1137
  default:
1212
- return ut({
1213
- color: e.color ?? g.edgeColor,
1214
- width: e.width ?? g.edgeWidth,
1215
- arrowLength: e.arrowLength ?? g.edgeArrowLength,
1216
- arrowWidth: e.arrowWidth ?? g.edgeArrowWidth,
1217
- hasSourceArrow: e.hasSourceArrow ?? g.hasSourceArrow,
1218
- hasTargetArrow: e.hasTargetArrow ?? g.hasTargetArrow,
1219
- cycleRadius: e.cycleRadius ?? g.cycleSize,
1220
- detourDistance: e.detourDistance ?? g.detourDistance,
1221
- detourDirection: e.detourDirection ?? g.detourDirection,
1222
- smallCycleRadius: e.smallCycleRadius ?? g.smallCycleSize,
1223
- curvature: e.curvature ?? g.curvature
1138
+ return ae({
1139
+ color: r.color ?? u.edgeColor,
1140
+ width: r.width ?? u.edgeWidth,
1141
+ arrowLength: r.arrowLength ?? u.edgeArrowLength,
1142
+ arrowWidth: r.arrowWidth ?? u.edgeArrowWidth,
1143
+ hasSourceArrow: r.hasSourceArrow ?? u.hasSourceArrow,
1144
+ hasTargetArrow: r.hasTargetArrow ?? u.hasTargetArrow,
1145
+ cycleRadius: r.cycleRadius ?? u.cycleSize,
1146
+ detourDistance: r.detourDistance ?? u.detourDistance,
1147
+ detourDirection: r.detourDirection ?? u.detourDirection,
1148
+ smallCycleRadius: r.smallCycleRadius ?? u.smallCycleSize,
1149
+ curvature: r.curvature ?? u.curvature
1224
1150
  });
1225
1151
  }
1226
- }, H = (e) => () => e, Z = H(0), G = () => {
1227
- let e = 0;
1228
- return () => e++;
1229
- }, bt = (e, t) => {
1230
- const r = [
1231
- Z,
1232
- Z
1152
+ }, z = (r) => () => r, U = z(0), k = () => {
1153
+ let r = 0;
1154
+ return () => r++;
1155
+ }, ve = (r, e) => {
1156
+ const t = [
1157
+ U,
1158
+ U
1233
1159
  ];
1234
- e === "incremental" && (r[0] = G()), t === "incremental" && (r[1] = G());
1235
- const s = G();
1236
- return e === "shared-incremental" && (r[0] = s), t === "shared-incremental" && (r[1] = s), typeof e == "number" && (r[0] = H(e)), typeof t == "number" && (r[1] = H(t)), typeof e == "function" && (r[0] = e), typeof t == "function" && (r[1] = t), r;
1237
- }, Tt = (e) => {
1238
- var s, o, i, h, c, a;
1239
- const [t, r] = bt(
1240
- (s = e.nodes) == null ? void 0 : s.priority,
1241
- (o = e.edges) == null ? void 0 : o.priority
1160
+ r === "incremental" && (t[0] = k()), e === "incremental" && (t[1] = k());
1161
+ const s = k();
1162
+ return r === "shared-incremental" && (t[0] = s), e === "shared-incremental" && (t[1] = s), typeof r == "number" && (t[0] = z(r)), typeof e == "number" && (t[1] = z(e)), typeof r == "function" && (t[0] = r), typeof e == "function" && (t[1] = e), t;
1163
+ }, fe = (r) => {
1164
+ var s, o, i, n, h, c;
1165
+ const [e, t] = ve(
1166
+ (s = r.nodes) == null ? void 0 : s.priority,
1167
+ (o = r.edges) == null ? void 0 : o.priority
1242
1168
  );
1243
1169
  return {
1244
- background: {
1245
- drawingFn: Nt(
1246
- e.background ?? { type: "none" }
1247
- )
1248
- },
1249
1170
  nodes: {
1250
- centerFn: ((i = e.nodes) == null ? void 0 : i.centerFn) ?? Q,
1251
- priorityFn: t
1171
+ centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ?? H,
1172
+ priorityFn: e
1252
1173
  },
1253
1174
  ports: {
1254
- centerFn: ((h = e.ports) == null ? void 0 : h.centerFn) ?? Q,
1255
- direction: ((c = e.ports) == null ? void 0 : c.direction) ?? 0
1175
+ centerFn: ((n = r.ports) == null ? void 0 : n.centerFn) ?? H,
1176
+ direction: ((h = r.ports) == null ? void 0 : h.direction) ?? 0
1256
1177
  },
1257
1178
  edges: {
1258
- shapeFactory: j(((a = e.edges) == null ? void 0 : a.shape) ?? {}),
1259
- priorityFn: r
1179
+ shapeFactory: R(((c = r.edges) == null ? void 0 : c.shape) ?? {}),
1180
+ priorityFn: t
1260
1181
  }
1261
1182
  };
1262
1183
  };
1263
- class Lt {
1264
- constructor(t) {
1265
- n(this, "transformation");
1266
- n(this, "model");
1267
- n(this, "di");
1268
- n(this, "edgeShapeFactory");
1269
- this.apiOptions = t;
1270
- const r = Tt(this.apiOptions ?? {});
1271
- this.di = new At(
1272
- r.background.drawingFn,
1273
- r.nodes.centerFn,
1274
- r.ports.centerFn,
1275
- r.ports.direction,
1276
- r.nodes.priorityFn,
1277
- r.edges.priorityFn
1278
- ), this.transformation = this.di.publicViewportTransformer, this.model = this.di.publicGraphStore, this.edgeShapeFactory = r.edges.shapeFactory;
1279
- }
1280
- addNode(t) {
1184
+ class xe {
1185
+ constructor(e) {
1186
+ a(this, "transformation");
1187
+ a(this, "model");
1188
+ a(this, "di");
1189
+ a(this, "edgeShapeFactory");
1190
+ this.apiOptions = e;
1191
+ const t = fe(this.apiOptions ?? {});
1192
+ this.di = new pe(
1193
+ t.nodes.centerFn,
1194
+ t.ports.centerFn,
1195
+ t.ports.direction,
1196
+ t.nodes.priorityFn,
1197
+ t.edges.priorityFn
1198
+ ), this.transformation = this.di.publicViewportTransformer, this.model = this.di.publicGraphStore, this.edgeShapeFactory = t.edges.shapeFactory;
1199
+ }
1200
+ addNode(e) {
1281
1201
  return this.di.canvasController.addNode(
1282
- t.id,
1283
- t.element,
1284
- t.x,
1285
- t.y,
1286
- t.ports,
1287
- t.centerFn,
1288
- t.priority
1202
+ e.id,
1203
+ e.element,
1204
+ e.x,
1205
+ e.y,
1206
+ e.ports,
1207
+ e.centerFn,
1208
+ e.priority
1289
1209
  ), this;
1290
1210
  }
1291
- updateNode(t, r) {
1211
+ updateNode(e, t) {
1292
1212
  return this.di.canvasController.updateNode(
1293
- t,
1294
- r.x,
1295
- r.y,
1296
- r.priority,
1297
- r.centerFn
1213
+ e,
1214
+ t.x,
1215
+ t.y,
1216
+ t.priority,
1217
+ t.centerFn
1298
1218
  ), this;
1299
1219
  }
1300
- removeNode(t) {
1301
- return this.di.canvasController.removeNode(t), this;
1220
+ removeNode(e) {
1221
+ return this.di.canvasController.removeNode(e), this;
1302
1222
  }
1303
- markPort(t) {
1223
+ markPort(e) {
1304
1224
  return this.di.canvasController.markPort(
1305
- t.id,
1306
- t.element,
1307
- t.nodeId,
1308
- t.centerFn,
1309
- t.direction
1225
+ e.id,
1226
+ e.element,
1227
+ e.nodeId,
1228
+ e.centerFn,
1229
+ e.direction
1310
1230
  ), this;
1311
1231
  }
1312
- updatePort(t, r) {
1232
+ updatePort(e, t) {
1313
1233
  return this.di.canvasController.updatePort(
1314
- t,
1315
- r.direction,
1316
- r.centerFn
1234
+ e,
1235
+ t == null ? void 0 : t.direction,
1236
+ t == null ? void 0 : t.centerFn
1317
1237
  ), this;
1318
1238
  }
1319
- unmarkPort(t) {
1320
- return this.di.canvasController.unmarkPort(t), this;
1239
+ unmarkPort(e) {
1240
+ return this.di.canvasController.unmarkPort(e), this;
1321
1241
  }
1322
- addEdge(t) {
1323
- const r = t.shape !== void 0 ? j(t.shape) : this.edgeShapeFactory;
1242
+ addEdge(e) {
1243
+ const t = e.shape !== void 0 ? R(e.shape) : this.edgeShapeFactory;
1324
1244
  return this.di.canvasController.addEdge(
1325
- t.id,
1326
- t.from,
1327
- t.to,
1328
- r,
1329
- t.priority
1245
+ e.id,
1246
+ e.from,
1247
+ e.to,
1248
+ t,
1249
+ e.priority
1330
1250
  ), this;
1331
1251
  }
1332
- updateEdge(t, r) {
1333
- const s = r.shape !== void 0 ? j(r.shape) : void 0;
1334
- return this.di.canvasController.updateEdge(t, s, r.priority), this;
1252
+ updateEdge(e, t) {
1253
+ const s = t.shape !== void 0 ? R(t.shape) : void 0;
1254
+ return this.di.canvasController.updateEdge(e, s, t.priority), this;
1335
1255
  }
1336
- removeEdge(t) {
1337
- return this.di.canvasController.removeEdge(t), this;
1256
+ removeEdge(e) {
1257
+ return this.di.canvasController.removeEdge(e), this;
1338
1258
  }
1339
- patchViewportMatrix(t) {
1259
+ patchViewportMatrix(e) {
1340
1260
  return this.di.canvasController.patchViewportMatrix(
1341
- t.scale ?? null,
1342
- t.dx ?? null,
1343
- t.dy ?? null
1261
+ e.scale ?? null,
1262
+ e.dx ?? null,
1263
+ e.dy ?? null
1344
1264
  ), this;
1345
1265
  }
1346
- patchContentMatrix(t) {
1266
+ patchContentMatrix(e) {
1347
1267
  return this.di.canvasController.patchContentMatrix(
1348
- t.scale ?? null,
1349
- t.dx ?? null,
1350
- t.dy ?? null
1268
+ e.scale ?? null,
1269
+ e.dx ?? null,
1270
+ e.dy ?? null
1351
1271
  ), this;
1352
1272
  }
1353
1273
  clear() {
1354
1274
  return this.di.canvasController.clear(), this;
1355
1275
  }
1356
- attach(t) {
1357
- return this.di.canvasController.attach(t), this;
1276
+ attach(e) {
1277
+ return this.di.canvasController.attach(e), this;
1358
1278
  }
1359
1279
  detach() {
1360
1280
  return this.di.canvasController.detach(), this;
@@ -1363,178 +1283,178 @@ class Lt {
1363
1283
  this.di.canvasController.destroy();
1364
1284
  }
1365
1285
  }
1366
- const z = (e, t, r) => {
1367
- const { x: s, y: o, width: i, height: h } = e.getBoundingClientRect();
1368
- return t >= s && t < s + i && r >= o && r <= o + h;
1369
- }, I = (e, t, r) => t >= 0 && t < e.innerWidth && r >= 0 && r <= e.innerHeight, B = (e, t) => {
1370
- t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
1286
+ const V = (r, e, t) => {
1287
+ const { x: s, y: o, width: i, height: n } = r.getBoundingClientRect();
1288
+ return e >= s && e < s + i && t >= o && t <= o + n;
1289
+ }, O = (r, e, t) => e >= 0 && e < r.innerWidth && t >= 0 && t <= r.innerHeight, I = (r, e) => {
1290
+ e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
1371
1291
  };
1372
- class $t {
1373
- constructor(t, r) {
1374
- n(this, "model");
1375
- n(this, "transformation");
1376
- n(this, "maxNodePriority", 0);
1377
- n(this, "nodes", /* @__PURE__ */ new Map());
1378
- n(this, "grabbedNodeId", null);
1379
- n(this, "onNodeDrag");
1380
- n(this, "onBeforeNodeDrag");
1381
- n(this, "nodeIdGenerator", new X(
1382
- (t) => this.nodes.has(t)
1292
+ class Ee {
1293
+ constructor(e, t) {
1294
+ a(this, "model");
1295
+ a(this, "transformation");
1296
+ a(this, "maxNodePriority", 0);
1297
+ a(this, "nodes", /* @__PURE__ */ new Map());
1298
+ a(this, "grabbedNodeId", null);
1299
+ a(this, "onNodeDrag");
1300
+ a(this, "onBeforeNodeDrag");
1301
+ a(this, "nodeIdGenerator", new F(
1302
+ (e) => this.nodes.has(e)
1383
1303
  ));
1384
- n(this, "element", null);
1385
- n(this, "onCanvasMouseUp", () => {
1304
+ a(this, "element", null);
1305
+ a(this, "onCanvasMouseUp", () => {
1386
1306
  this.cancelMouseDrag();
1387
1307
  });
1388
- n(this, "onCanvasMouseMove", (t) => {
1389
- if (this.element !== null && (!z(this.element, t.clientX, t.clientY) || !I(this.window, t.clientX, t.clientY))) {
1308
+ a(this, "onCanvasMouseMove", (e) => {
1309
+ if (this.element !== null && (!V(this.element, e.clientX, e.clientY) || !O(this.window, e.clientX, e.clientY))) {
1390
1310
  this.cancelMouseDrag();
1391
1311
  return;
1392
1312
  }
1393
- this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
1313
+ this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
1394
1314
  });
1395
- n(this, "onCanvasTouchStart", (t) => {
1315
+ a(this, "onCanvasTouchStart", (e) => {
1396
1316
  this.previousTouchCoords = [
1397
- t.touches[0].clientX,
1398
- t.touches[0].clientY
1317
+ e.touches[0].clientX,
1318
+ e.touches[0].clientY
1399
1319
  ];
1400
1320
  });
1401
- n(this, "onCanvasTouchMove", (t) => {
1402
- if (t.touches.length === 1) {
1403
- const r = t.touches[0];
1404
- if (this.element !== null && (!z(this.element, r.clientX, r.clientY) || !I(this.window, r.clientX, r.clientY))) {
1321
+ a(this, "onCanvasTouchMove", (e) => {
1322
+ if (e.touches.length === 1) {
1323
+ const t = e.touches[0];
1324
+ if (this.element !== null && (!V(this.element, t.clientX, t.clientY) || !O(this.window, t.clientX, t.clientY))) {
1405
1325
  this.cancelTouchDrag();
1406
1326
  return;
1407
1327
  }
1408
1328
  if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
1409
- t.stopImmediatePropagation();
1410
- const s = r.clientX - this.previousTouchCoords[0], o = r.clientY - this.previousTouchCoords[1];
1329
+ e.stopImmediatePropagation();
1330
+ const s = t.clientX - this.previousTouchCoords[0], o = t.clientY - this.previousTouchCoords[1];
1411
1331
  this.dragNode(this.grabbedNodeId, s, o), this.previousTouchCoords = [
1412
- t.touches[0].clientX,
1413
- t.touches[0].clientY
1332
+ e.touches[0].clientX,
1333
+ e.touches[0].clientY
1414
1334
  ];
1415
1335
  }
1416
1336
  }
1417
1337
  });
1418
- n(this, "onCanvasTouchEnd", (t) => {
1419
- t.touches.length > 0 ? this.previousTouchCoords = [
1420
- t.touches[0].clientX,
1421
- t.touches[0].clientY
1338
+ a(this, "onCanvasTouchEnd", (e) => {
1339
+ e.touches.length > 0 ? this.previousTouchCoords = [
1340
+ e.touches[0].clientX,
1341
+ e.touches[0].clientY
1422
1342
  ] : this.cancelTouchDrag();
1423
1343
  });
1424
- n(this, "previousTouchCoords", null);
1425
- n(this, "freezePriority");
1426
- n(this, "window", window);
1427
- n(this, "dragCursor");
1428
- var i, h;
1429
- this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1344
+ a(this, "previousTouchCoords", null);
1345
+ a(this, "freezePriority");
1346
+ a(this, "window", window);
1347
+ a(this, "dragCursor");
1348
+ var i, n;
1349
+ this.canvas = e, this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1430
1350
  const s = () => {
1431
1351
  };
1432
- this.onNodeDrag = ((i = r == null ? void 0 : r.events) == null ? void 0 : i.onNodeDrag) ?? s;
1352
+ this.onNodeDrag = ((i = t == null ? void 0 : t.events) == null ? void 0 : i.onNodeDrag) ?? s;
1433
1353
  const o = () => !0;
1434
- this.onBeforeNodeDrag = ((h = r == null ? void 0 : r.events) == null ? void 0 : h.onBeforeNodeDrag) ?? o, this.freezePriority = (r == null ? void 0 : r.grabPriorityStrategy) === "freeze", this.dragCursor = (r == null ? void 0 : r.dragCursor) !== void 0 ? r.dragCursor : "grab";
1354
+ this.onBeforeNodeDrag = ((n = t == null ? void 0 : t.events) == null ? void 0 : n.onBeforeNodeDrag) ?? o, this.freezePriority = (t == null ? void 0 : t.grabPriorityStrategy) === "freeze", this.dragCursor = (t == null ? void 0 : t.dragCursor) !== void 0 ? t.dragCursor : "grab";
1435
1355
  }
1436
- addNode(t) {
1437
- const r = this.nodeIdGenerator.create(t.id);
1438
- this.canvas.addNode({ ...t, id: r }), this.updateMaxNodePriority(r);
1356
+ addNode(e) {
1357
+ const t = this.nodeIdGenerator.create(e.id);
1358
+ this.canvas.addNode({ ...e, id: t }), this.updateMaxNodePriority(t);
1439
1359
  const s = (i) => {
1440
1360
  if (this.element === null)
1441
1361
  return;
1442
- const h = this.model.getNode(r);
1362
+ const n = this.model.getNode(t);
1443
1363
  this.onBeforeNodeDrag({
1444
- nodeId: r,
1445
- element: t.element,
1446
- x: h.x,
1447
- y: h.y
1448
- }) && (i.stopImmediatePropagation(), this.grabbedNodeId = r, B(this.element, this.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onCanvasMouseUp), this.window.addEventListener("mousemove", this.onCanvasMouseMove));
1364
+ nodeId: t,
1365
+ element: e.element,
1366
+ x: n.x,
1367
+ y: n.y
1368
+ }) && (i.stopImmediatePropagation(), this.grabbedNodeId = t, I(this.element, this.dragCursor), this.moveNodeOnTop(t), this.window.addEventListener("mouseup", this.onCanvasMouseUp), this.window.addEventListener("mousemove", this.onCanvasMouseMove));
1449
1369
  }, o = (i) => {
1450
- const h = this.model.getNode(r);
1370
+ const n = this.model.getNode(t);
1451
1371
  this.onBeforeNodeDrag({
1452
- nodeId: r,
1453
- element: t.element,
1454
- x: h.x,
1455
- y: h.y
1456
- }) && i.touches.length === 1 && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onCanvasTouchMove), this.window.addEventListener("touchend", this.onCanvasTouchEnd), this.window.addEventListener("touchcancel", this.onCanvasTouchEnd));
1372
+ nodeId: t,
1373
+ element: e.element,
1374
+ x: n.x,
1375
+ y: n.y
1376
+ }) && i.touches.length === 1 && (this.grabbedNodeId = t, this.moveNodeOnTop(t), this.window.addEventListener("touchmove", this.onCanvasTouchMove), this.window.addEventListener("touchend", this.onCanvasTouchEnd), this.window.addEventListener("touchcancel", this.onCanvasTouchEnd));
1457
1377
  };
1458
- return this.nodes.set(r, {
1459
- element: t.element,
1378
+ return this.nodes.set(t, {
1379
+ element: e.element,
1460
1380
  onMouseDown: s,
1461
1381
  onTouchStart: o
1462
- }), t.element.addEventListener("mousedown", s), t.element.addEventListener("touchstart", o), this;
1382
+ }), e.element.addEventListener("mousedown", s), e.element.addEventListener("touchstart", o), this;
1463
1383
  }
1464
- updateNode(t, r) {
1465
- return this.canvas.updateNode(t, r), this.updateMaxNodePriority(t), this;
1384
+ updateNode(e, t) {
1385
+ return this.canvas.updateNode(e, t), this.updateMaxNodePriority(e), this;
1466
1386
  }
1467
- removeNode(t) {
1468
- const r = this.nodes.get(t);
1469
- return r !== void 0 && (r.element.removeEventListener("mousedown", r.onMouseDown), r.element.removeEventListener("touchstart", r.onTouchStart)), this.canvas.removeNode(t), this.nodes.delete(t), this;
1387
+ removeNode(e) {
1388
+ const t = this.nodes.get(e);
1389
+ return t !== void 0 && (t.element.removeEventListener("mousedown", t.onMouseDown), t.element.removeEventListener("touchstart", t.onTouchStart)), this.canvas.removeNode(e), this.nodes.delete(e), this;
1470
1390
  }
1471
- markPort(t) {
1472
- return this.canvas.markPort(t), this;
1391
+ markPort(e) {
1392
+ return this.canvas.markPort(e), this;
1473
1393
  }
1474
- updatePort(t, r) {
1475
- return this.canvas.updatePort(t, r), this;
1394
+ updatePort(e, t) {
1395
+ return this.canvas.updatePort(e, t), this;
1476
1396
  }
1477
- unmarkPort(t) {
1478
- return this.canvas.unmarkPort(t), this;
1397
+ unmarkPort(e) {
1398
+ return this.canvas.unmarkPort(e), this;
1479
1399
  }
1480
- addEdge(t) {
1481
- return this.canvas.addEdge(t), this;
1400
+ addEdge(e) {
1401
+ return this.canvas.addEdge(e), this;
1482
1402
  }
1483
- updateEdge(t, r) {
1484
- return this.canvas.updateEdge(t, r), this;
1403
+ updateEdge(e, t) {
1404
+ return this.canvas.updateEdge(e, t), this;
1485
1405
  }
1486
- removeEdge(t) {
1487
- return this.canvas.removeEdge(t), this;
1406
+ removeEdge(e) {
1407
+ return this.canvas.removeEdge(e), this;
1488
1408
  }
1489
- patchViewportMatrix(t) {
1490
- return this.canvas.patchViewportMatrix(t), this;
1409
+ patchViewportMatrix(e) {
1410
+ return this.canvas.patchViewportMatrix(e), this;
1491
1411
  }
1492
- patchContentMatrix(t) {
1493
- return this.canvas.patchContentMatrix(t), this;
1412
+ patchContentMatrix(e) {
1413
+ return this.canvas.patchContentMatrix(e), this;
1494
1414
  }
1495
1415
  clear() {
1496
- return this.canvas.clear(), this.nodes.forEach((t) => {
1497
- t.element.removeEventListener("mousedown", t.onMouseDown), t.element.removeEventListener("touchstart", t.onTouchStart);
1416
+ return this.canvas.clear(), this.nodes.forEach((e) => {
1417
+ e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart);
1498
1418
  }), this.nodes.clear(), this.maxNodePriority = 0, this;
1499
1419
  }
1500
- attach(t) {
1501
- return this.detach(), this.element = t, this.element.addEventListener("touchstart", this.onCanvasTouchStart), this.canvas.attach(this.element), this;
1420
+ attach(e) {
1421
+ return this.detach(), this.element = e, this.element.addEventListener("touchstart", this.onCanvasTouchStart), this.canvas.attach(this.element), this;
1502
1422
  }
1503
1423
  detach() {
1504
1424
  return this.canvas.detach(), this.element !== null && (this.element.removeEventListener("touchstart", this.onCanvasTouchStart), this.element = null), this;
1505
1425
  }
1506
1426
  destroy() {
1507
- this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.nodes.forEach((t) => {
1508
- t.element.removeEventListener("mousedown", t.onMouseDown), t.element.removeEventListener("touchstart", t.onTouchStart);
1427
+ this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.nodes.forEach((e) => {
1428
+ e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart);
1509
1429
  }), this.nodes.clear(), this.canvas.destroy();
1510
1430
  }
1511
- dragNode(t, r, s) {
1512
- const o = this.model.getNode(t);
1431
+ dragNode(e, t, s) {
1432
+ const o = this.model.getNode(e);
1513
1433
  if (o === null)
1514
- throw new S("failed to drag nonexisting node");
1515
- const i = this.canvas.transformation.getContentMatrix(), h = i.scale * o.x + i.dx, c = i.scale * o.y + i.dy, a = h + r, d = c + s, l = this.canvas.transformation.getViewportMatrix(), u = l.scale * a + l.dx, w = l.scale * d + l.dy;
1516
- this.canvas.updateNode(t, { x: u, y: w }), this.onNodeDrag({
1517
- nodeId: t,
1434
+ throw new C("failed to drag nonexisting node");
1435
+ const i = this.canvas.transformation.getContentMatrix(), n = i.scale * o.x + i.dx, h = i.scale * o.y + i.dy, c = n + t, d = h + s, g = this.canvas.transformation.getViewportMatrix(), w = g.scale * c + g.dx, m = g.scale * d + g.dy;
1436
+ this.canvas.updateNode(e, { x: w, y: m }), this.onNodeDrag({
1437
+ nodeId: e,
1518
1438
  element: o.element,
1519
1439
  x: o.x,
1520
1440
  y: o.y
1521
1441
  });
1522
1442
  }
1523
- updateMaxNodePriority(t) {
1524
- const r = this.model.getNode(t).priority;
1525
- this.maxNodePriority = Math.max(this.maxNodePriority, r);
1443
+ updateMaxNodePriority(e) {
1444
+ const t = this.model.getNode(e).priority;
1445
+ this.maxNodePriority = Math.max(this.maxNodePriority, t);
1526
1446
  }
1527
- moveNodeOnTop(t) {
1447
+ moveNodeOnTop(e) {
1528
1448
  if (this.freezePriority)
1529
1449
  return;
1530
- this.maxNodePriority += 2, this.updateNode(t, { priority: this.maxNodePriority });
1531
- const r = this.maxNodePriority - 1;
1532
- this.model.getNodeAdjacentEdgeIds(t).forEach((o) => {
1533
- this.updateEdge(o, { priority: r });
1450
+ this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
1451
+ const t = this.maxNodePriority - 1;
1452
+ this.model.getNodeAdjacentEdgeIds(e).forEach((o) => {
1453
+ this.updateEdge(o, { priority: t });
1534
1454
  });
1535
1455
  }
1536
1456
  cancelMouseDrag() {
1537
- this.grabbedNodeId = null, this.element !== null && B(this.element, null), this.removeMouseDragListeners();
1457
+ this.grabbedNodeId = null, this.element !== null && I(this.element, null), this.removeMouseDragListeners();
1538
1458
  }
1539
1459
  removeMouseDragListeners() {
1540
1460
  this.window.removeEventListener("mouseup", this.onCanvasMouseUp), this.window.removeEventListener("mousemove", this.onCanvasMouseMove);
@@ -1546,159 +1466,159 @@ class $t {
1546
1466
  this.window.removeEventListener("touchmove", this.onCanvasTouchMove), this.window.removeEventListener("touchend", this.onCanvasTouchEnd), this.window.removeEventListener("touchcancel", this.onCanvasTouchEnd);
1547
1467
  }
1548
1468
  }
1549
- const Dt = () => {
1550
- }, Ft = (e, t) => t, Wt = (e, t) => {
1551
- const r = t !== null ? 1 / t : null, s = e !== null ? 1 / e : null;
1552
- return (o, i) => s !== null && i.scale > s && i.scale > o.scale || r !== null && i.scale < r && i.scale < o.scale ? o : i;
1553
- }, Vt = (e, t, r, s) => (o, i, h, c) => {
1554
- let a = i.dx, d = i.dy;
1555
- e !== null && a < e && a < o.dx && (a = o.dx);
1556
- const l = h * o.scale;
1557
- t !== null && a > t - l && a > o.dx && (a = o.dx), r !== null && d < r && d < o.dy && (d = o.dy);
1558
- const u = c * o.scale;
1559
- return s !== null && d > s - u && d > o.dy && (d = o.dy), { scale: i.scale, dx: a, dy: d };
1560
- }, q = (e) => {
1561
- switch (e.type) {
1469
+ const Ce = () => {
1470
+ }, Ae = (r, e) => e, Se = (r, e) => {
1471
+ const t = e !== null ? 1 / e : null, s = r !== null ? 1 / r : null;
1472
+ return (o, i) => s !== null && i.scale > s && i.scale > o.scale || t !== null && i.scale < t && i.scale < o.scale ? o : i;
1473
+ }, Pe = (r, e, t, s) => (o, i, n, h) => {
1474
+ let c = i.dx, d = i.dy;
1475
+ r !== null && c < r && c < o.dx && (c = o.dx);
1476
+ const g = n * o.scale;
1477
+ e !== null && c > e - g && c > o.dx && (c = o.dx), t !== null && d < t && d < o.dy && (d = o.dy);
1478
+ const w = h * o.scale;
1479
+ return s !== null && d > s - w && d > o.dy && (d = o.dy), { scale: i.scale, dx: c, dy: d };
1480
+ }, K = (r) => {
1481
+ switch (r.type) {
1562
1482
  case "scale-limit":
1563
- return Wt(
1564
- e.minContentScale ?? null,
1565
- e.maxContentScale ?? null
1483
+ return Se(
1484
+ r.minContentScale ?? null,
1485
+ r.maxContentScale ?? null
1566
1486
  );
1567
1487
  case "shift-limit":
1568
- return Vt(
1569
- e.minX ?? null,
1570
- e.maxX ?? null,
1571
- e.minY ?? null,
1572
- e.maxY ?? null
1488
+ return Pe(
1489
+ r.minX ?? null,
1490
+ r.maxX ?? null,
1491
+ r.minY ?? null,
1492
+ r.maxY ?? null
1573
1493
  );
1574
1494
  default:
1575
- return e.preprocessorFn;
1495
+ return r.preprocessorFn;
1576
1496
  }
1577
- }, Ot = (e) => (t, r, s, o) => e.reduce(
1578
- (i, h) => h(t, i, s, o),
1579
- r
1497
+ }, Me = (r) => (e, t, s, o) => r.reduce(
1498
+ (i, n) => n(e, i, s, o),
1499
+ t
1580
1500
  );
1581
- class Rt {
1582
- constructor(t, r) {
1583
- n(this, "model");
1584
- n(this, "transformation");
1585
- n(this, "element", null);
1586
- n(this, "prevTouches", null);
1587
- n(this, "onTransformFinished");
1588
- n(this, "transformPreprocessor");
1589
- n(this, "isScalable");
1590
- n(this, "isShiftable");
1591
- n(this, "wheelSensitivity");
1592
- n(this, "window", window);
1593
- n(this, "onMouseDown", () => {
1594
- this.element !== null && (B(this.element, this.shiftCursor), this.window.addEventListener("mousemove", this.onMouseMove), this.window.addEventListener("mouseup", this.onMouseUp));
1501
+ class Ne {
1502
+ constructor(e, t) {
1503
+ a(this, "model");
1504
+ a(this, "transformation");
1505
+ a(this, "element", null);
1506
+ a(this, "prevTouches", null);
1507
+ a(this, "onTransformFinished");
1508
+ a(this, "transformPreprocessor");
1509
+ a(this, "isScalable");
1510
+ a(this, "isShiftable");
1511
+ a(this, "wheelSensitivity");
1512
+ a(this, "window", window);
1513
+ a(this, "onMouseDown", () => {
1514
+ this.element !== null && (I(this.element, this.shiftCursor), this.window.addEventListener("mousemove", this.onMouseMove), this.window.addEventListener("mouseup", this.onMouseUp));
1595
1515
  });
1596
- n(this, "onMouseMove", (t) => {
1516
+ a(this, "onMouseMove", (e) => {
1597
1517
  if (!this.isShiftable || this.element === null)
1598
1518
  return;
1599
- if (!z(this.element, t.clientX, t.clientY) || !I(this.window, t.clientX, t.clientY)) {
1519
+ if (!V(this.element, e.clientX, e.clientY) || !O(this.window, e.clientX, e.clientY)) {
1600
1520
  this.stopMouseDrag();
1601
1521
  return;
1602
1522
  }
1603
- const r = -t.movementX, s = -t.movementY;
1604
- this.moveViewport(r, s);
1523
+ const t = -e.movementX, s = -e.movementY;
1524
+ this.moveViewport(t, s);
1605
1525
  });
1606
- n(this, "onMouseUp", () => {
1526
+ a(this, "onMouseUp", () => {
1607
1527
  this.stopMouseDrag();
1608
1528
  });
1609
- n(this, "onWheelScroll", (t) => {
1529
+ a(this, "onWheelScroll", (e) => {
1610
1530
  if (this.element === null || this.isScalable === !1)
1611
1531
  return;
1612
- t.preventDefault();
1613
- const { left: r, top: s } = this.element.getBoundingClientRect(), o = t.clientX - r, i = t.clientY - s, c = 1 / (t.deltaY < 0 ? this.wheelSensitivity : 1 / this.wheelSensitivity);
1614
- this.scaleViewport(c, o, i);
1532
+ e.preventDefault();
1533
+ const { left: t, top: s } = this.element.getBoundingClientRect(), o = e.clientX - t, i = e.clientY - s, h = 1 / (e.deltaY < 0 ? this.wheelSensitivity : 1 / this.wheelSensitivity);
1534
+ this.scaleViewport(h, o, i);
1615
1535
  });
1616
- n(this, "onTouchStart", (t) => {
1617
- this.prevTouches = this.getAverageTouch(t), this.window.addEventListener("touchmove", this.onTouchMove), this.window.addEventListener("touchend", this.onTouchEnd), this.window.addEventListener("touchcancel", this.onTouchEnd);
1536
+ a(this, "onTouchStart", (e) => {
1537
+ this.prevTouches = this.getAverageTouch(e), this.window.addEventListener("touchmove", this.onTouchMove), this.window.addEventListener("touchend", this.onTouchEnd), this.window.addEventListener("touchcancel", this.onTouchEnd);
1618
1538
  });
1619
- n(this, "onTouchMove", (t) => {
1539
+ a(this, "onTouchMove", (e) => {
1620
1540
  if (this.prevTouches === null || !this.isShiftable || this.element === null)
1621
1541
  return;
1622
- const r = this.getAverageTouch(t);
1623
- if (!r.touches.every(
1624
- (o) => z(this.element, o[0], o[1]) && I(this.window, o[0], o[1])
1542
+ const t = this.getAverageTouch(e);
1543
+ if (!t.touches.every(
1544
+ (o) => V(this.element, o[0], o[1]) && O(this.window, o[0], o[1])
1625
1545
  )) {
1626
1546
  this.stopTouchDrag();
1627
1547
  return;
1628
1548
  }
1629
- if ((r.touchesCnt === 1 || r.touchesCnt === 2) && this.moveViewport(
1630
- -(r.x - this.prevTouches.x),
1631
- -(r.y - this.prevTouches.y)
1632
- ), r.touchesCnt === 2 && this.isScalable) {
1633
- const { left: o, top: i } = this.element.getBoundingClientRect(), h = this.prevTouches.x - o, c = this.prevTouches.y - i, d = 1 / (r.scale / this.prevTouches.scale);
1634
- this.scaleViewport(d, h, c);
1549
+ if ((t.touchesCnt === 1 || t.touchesCnt === 2) && this.moveViewport(
1550
+ -(t.x - this.prevTouches.x),
1551
+ -(t.y - this.prevTouches.y)
1552
+ ), t.touchesCnt === 2 && this.isScalable) {
1553
+ const { left: o, top: i } = this.element.getBoundingClientRect(), n = this.prevTouches.x - o, h = this.prevTouches.y - i, d = 1 / (t.scale / this.prevTouches.scale);
1554
+ this.scaleViewport(d, n, h);
1635
1555
  }
1636
- this.prevTouches = r;
1556
+ this.prevTouches = t;
1637
1557
  });
1638
- n(this, "onTouchEnd", (t) => {
1639
- t.touches.length > 0 ? this.prevTouches = this.getAverageTouch(t) : this.stopTouchDrag();
1558
+ a(this, "onTouchEnd", (e) => {
1559
+ e.touches.length > 0 ? this.prevTouches = this.getAverageTouch(e) : this.stopTouchDrag();
1640
1560
  });
1641
- n(this, "observer", new ResizeObserver(() => {
1561
+ a(this, "observer", new ResizeObserver(() => {
1642
1562
  if (this.element !== null) {
1643
- const t = this.canvas.transformation.getViewportMatrix(), { width: r, height: s } = this.element.getBoundingClientRect(), o = this.transformPreprocessor(
1563
+ const e = this.canvas.transformation.getViewportMatrix(), { width: t, height: s } = this.element.getBoundingClientRect(), o = this.transformPreprocessor(
1564
+ e,
1565
+ e,
1644
1566
  t,
1645
- t,
1646
- r,
1647
1567
  s
1648
1568
  );
1649
- this.canvas.patchViewportMatrix(o), this.onTransformFinished(o);
1569
+ this.canvas.patchViewportMatrix(o), this.onTransformFinished();
1650
1570
  }
1651
1571
  }));
1652
- n(this, "shiftCursor");
1653
- var i, h, c, a, d, l, u, w;
1654
- this.canvas = t, this.options = r, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.isScalable = ((h = (i = this.options) == null ? void 0 : i.scale) == null ? void 0 : h.enabled) !== !1, this.isShiftable = ((a = (c = this.options) == null ? void 0 : c.shift) == null ? void 0 : a.enabled) !== !1;
1655
- const s = (l = (d = this.options) == null ? void 0 : d.scale) == null ? void 0 : l.wheelSensitivity;
1656
- this.wheelSensitivity = s !== void 0 ? s : 1.2, this.onTransformFinished = ((u = r == null ? void 0 : r.events) == null ? void 0 : u.onTransformFinished) ?? Dt;
1657
- const o = r == null ? void 0 : r.transformPreprocessor;
1658
- o !== void 0 ? Array.isArray(o) ? this.transformPreprocessor = Ot(
1572
+ a(this, "shiftCursor");
1573
+ var i, n, h, c, d, g, w, m;
1574
+ this.canvas = e, this.options = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.isScalable = ((n = (i = this.options) == null ? void 0 : i.scale) == null ? void 0 : n.enabled) !== !1, this.isShiftable = ((c = (h = this.options) == null ? void 0 : h.shift) == null ? void 0 : c.enabled) !== !1;
1575
+ const s = (g = (d = this.options) == null ? void 0 : d.scale) == null ? void 0 : g.wheelSensitivity;
1576
+ this.wheelSensitivity = s !== void 0 ? s : 1.2, this.onTransformFinished = ((w = t == null ? void 0 : t.events) == null ? void 0 : w.onTransformFinished) ?? Ce;
1577
+ const o = t == null ? void 0 : t.transformPreprocessor;
1578
+ o !== void 0 ? Array.isArray(o) ? this.transformPreprocessor = Me(
1659
1579
  o.map(
1660
- (v) => q(v)
1580
+ (y) => K(y)
1661
1581
  )
1662
- ) : this.transformPreprocessor = q(o) : this.transformPreprocessor = Ft, this.shiftCursor = ((w = r == null ? void 0 : r.shift) == null ? void 0 : w.cursor) !== void 0 ? r.shift.cursor : "grab";
1582
+ ) : this.transformPreprocessor = K(o) : this.transformPreprocessor = Ae, this.shiftCursor = ((m = t == null ? void 0 : t.shift) == null ? void 0 : m.cursor) !== void 0 ? t.shift.cursor : "grab";
1663
1583
  }
1664
- addNode(t) {
1665
- return this.canvas.addNode(t), this;
1584
+ addNode(e) {
1585
+ return this.canvas.addNode(e), this;
1666
1586
  }
1667
- updateNode(t, r) {
1668
- return this.canvas.updateNode(t, r), this;
1587
+ updateNode(e, t) {
1588
+ return this.canvas.updateNode(e, t), this;
1669
1589
  }
1670
- removeNode(t) {
1671
- return this.canvas.removeNode(t), this;
1590
+ removeNode(e) {
1591
+ return this.canvas.removeNode(e), this;
1672
1592
  }
1673
- markPort(t) {
1674
- return this.canvas.markPort(t), this;
1593
+ markPort(e) {
1594
+ return this.canvas.markPort(e), this;
1675
1595
  }
1676
- updatePort(t, r) {
1677
- return this.canvas.updatePort(t, r), this;
1596
+ updatePort(e, t) {
1597
+ return this.canvas.updatePort(e, t), this;
1678
1598
  }
1679
- unmarkPort(t) {
1680
- return this.canvas.unmarkPort(t), this;
1599
+ unmarkPort(e) {
1600
+ return this.canvas.unmarkPort(e), this;
1681
1601
  }
1682
- addEdge(t) {
1683
- return this.canvas.addEdge(t), this;
1602
+ addEdge(e) {
1603
+ return this.canvas.addEdge(e), this;
1684
1604
  }
1685
- updateEdge(t, r) {
1686
- return this.canvas.updateEdge(t, r), this;
1605
+ updateEdge(e, t) {
1606
+ return this.canvas.updateEdge(e, t), this;
1687
1607
  }
1688
- removeEdge(t) {
1689
- return this.canvas.removeEdge(t), this;
1608
+ removeEdge(e) {
1609
+ return this.canvas.removeEdge(e), this;
1690
1610
  }
1691
- patchViewportMatrix(t) {
1692
- return this.canvas.patchViewportMatrix(t), this;
1611
+ patchViewportMatrix(e) {
1612
+ return this.canvas.patchViewportMatrix(e), this;
1693
1613
  }
1694
- patchContentMatrix(t) {
1695
- return this.canvas.patchContentMatrix(t), this;
1614
+ patchContentMatrix(e) {
1615
+ return this.canvas.patchContentMatrix(e), this;
1696
1616
  }
1697
1617
  clear() {
1698
1618
  return this.canvas.clear(), this;
1699
1619
  }
1700
- attach(t) {
1701
- 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;
1620
+ attach(e) {
1621
+ 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;
1702
1622
  }
1703
1623
  detach() {
1704
1624
  return this.canvas.detach(), this.element !== null && (this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element = null), this;
@@ -1706,58 +1626,58 @@ class Rt {
1706
1626
  destroy() {
1707
1627
  this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
1708
1628
  }
1709
- getAverageTouch(t) {
1710
- const r = [], s = t.touches.length;
1711
- for (let a = 0; a < s; a++)
1712
- r.push([t.touches[a].clientX, t.touches[a].clientY]);
1713
- const o = r.reduce(
1714
- (a, d) => [a[0] + d[0], a[1] + d[1]],
1629
+ getAverageTouch(e) {
1630
+ const t = [], s = e.touches.length;
1631
+ for (let c = 0; c < s; c++)
1632
+ t.push([e.touches[c].clientX, e.touches[c].clientY]);
1633
+ const o = t.reduce(
1634
+ (c, d) => [c[0] + d[0], c[1] + d[1]],
1715
1635
  [0, 0]
1716
- ), i = [o[0] / s, o[1] / s], c = r.map((a) => [a[0] - i[0], a[1] - i[1]]).reduce(
1717
- (a, d) => a + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
1636
+ ), i = [o[0] / s, o[1] / s], h = t.map((c) => [c[0] - i[0], c[1] - i[1]]).reduce(
1637
+ (c, d) => c + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
1718
1638
  0
1719
1639
  );
1720
1640
  return {
1721
1641
  x: i[0],
1722
1642
  y: i[1],
1723
- scale: c / s,
1643
+ scale: h / s,
1724
1644
  touchesCnt: s,
1725
- touches: r
1645
+ touches: t
1726
1646
  };
1727
1647
  }
1728
- moveViewport(t, r) {
1648
+ moveViewport(e, t) {
1729
1649
  const s = this.transformation.getViewportMatrix(), o = {
1730
1650
  scale: s.scale,
1731
- dx: s.dx + s.scale * t,
1732
- dy: s.dy + s.scale * r
1651
+ dx: s.dx + s.scale * e,
1652
+ dy: s.dy + s.scale * t
1733
1653
  };
1734
1654
  if (this.element !== null) {
1735
- const { width: i, height: h } = this.element.getBoundingClientRect(), c = this.transformPreprocessor(
1655
+ const { width: i, height: n } = this.element.getBoundingClientRect(), h = this.transformPreprocessor(
1736
1656
  s,
1737
1657
  o,
1738
1658
  i,
1739
- h
1659
+ n
1740
1660
  );
1741
- this.canvas.patchViewportMatrix(c), this.onTransformFinished(c);
1661
+ this.canvas.patchViewportMatrix(h), this.onTransformFinished();
1742
1662
  }
1743
1663
  }
1744
- scaleViewport(t, r, s) {
1664
+ scaleViewport(e, t, s) {
1745
1665
  if (this.element === null)
1746
1666
  return;
1747
1667
  const o = this.canvas.transformation.getViewportMatrix(), i = {
1748
- scale: o.scale * t,
1749
- dx: o.scale * (1 - t) * r + o.dx,
1750
- dy: o.scale * (1 - t) * s + o.dy
1751
- }, { width: h, height: c } = this.element.getBoundingClientRect(), a = this.transformPreprocessor(
1668
+ scale: o.scale * e,
1669
+ dx: o.scale * (1 - e) * t + o.dx,
1670
+ dy: o.scale * (1 - e) * s + o.dy
1671
+ }, { width: n, height: h } = this.element.getBoundingClientRect(), c = this.transformPreprocessor(
1752
1672
  o,
1753
1673
  i,
1754
- h,
1755
- c
1674
+ n,
1675
+ h
1756
1676
  );
1757
- this.canvas.patchViewportMatrix(a), this.onTransformFinished(a);
1677
+ this.canvas.patchViewportMatrix(c), this.onTransformFinished();
1758
1678
  }
1759
1679
  stopMouseDrag() {
1760
- this.element !== null && B(this.element, null), this.removeMouseDragListeners();
1680
+ this.element !== null && I(this.element, null), this.removeMouseDragListeners();
1761
1681
  }
1762
1682
  removeMouseDragListeners() {
1763
1683
  this.window.removeEventListener("mousemove", this.onMouseMove), this.window.removeEventListener("mouseup", this.onMouseUp);
@@ -1769,44 +1689,45 @@ class Rt {
1769
1689
  this.window.removeEventListener("touchmove", this.onTouchMove), this.window.removeEventListener("touchend", this.onTouchEnd), this.window.removeEventListener("touchcancel", this.onTouchEnd);
1770
1690
  }
1771
1691
  }
1772
- class kt {
1692
+ class Te {
1773
1693
  constructor() {
1774
- n(this, "coreOptions");
1775
- n(this, "dragOptions");
1776
- n(this, "transformOptions");
1777
- n(this, "isDraggable", !1);
1778
- n(this, "isTransformable", !1);
1694
+ a(this, "coreOptions");
1695
+ a(this, "dragOptions");
1696
+ a(this, "transformOptions");
1697
+ a(this, "isDraggable", !1);
1698
+ a(this, "isTransformable", !1);
1779
1699
  }
1780
- setOptions(t) {
1781
- return this.coreOptions = t, this;
1700
+ setOptions(e) {
1701
+ return this.coreOptions = e, this;
1782
1702
  }
1783
- setUserDraggableNodes(t) {
1784
- return this.isDraggable = !0, this.dragOptions = t, this;
1703
+ setUserDraggableNodes(e) {
1704
+ return this.isDraggable = !0, this.dragOptions = e, this;
1785
1705
  }
1786
- setUserTransformableCanvas(t) {
1787
- return this.isTransformable = !0, this.transformOptions = t, this;
1706
+ setUserTransformableCanvas(e) {
1707
+ return this.isTransformable = !0, this.transformOptions = e, this;
1788
1708
  }
1789
1709
  build() {
1790
- let t = new Lt(this.coreOptions);
1791
- return this.isDraggable && (t = new $t(t, this.dragOptions)), this.isTransformable && (t = new Rt(t, this.transformOptions)), t;
1710
+ let e = new xe(this.coreOptions);
1711
+ return this.isDraggable && (e = new Ee(e, this.dragOptions)), this.isTransformable && (e = new Ne(e, this.transformOptions)), e;
1792
1712
  }
1793
1713
  }
1794
1714
  export {
1795
- nt as BezierEdgeShape,
1796
- Lt as CanvasCore,
1797
- dt as CycleCircleEdgeShape,
1798
- U as CycleSquareEdgeShape,
1799
- _ as DetourStraightEdgeShape,
1800
- T as EdgeType,
1801
- ht as HorizontalEdgeShape,
1802
- kt as HtmlGraphBuilder,
1803
- S as HtmlGraphError,
1804
- at as StraightEdgeShape,
1805
- $t as UserDraggableNodesCanvas,
1806
- Rt as UserTransformableCanvas,
1807
- ct as VerticalEdgeShape,
1808
- ut as createBezierEdgeShapeFactory,
1809
- wt as createHorizontalEdgeShapeFactory,
1810
- gt as createStraightEdgeShareFactory,
1811
- pt as createVerticalEdgeShapeFactory
1715
+ te as BezierEdgeShape,
1716
+ xe as CanvasCore,
1717
+ ie as CycleCircleEdgeShape,
1718
+ B as CycleSquareEdgeShape,
1719
+ ne as DetourBezierEdgeShape,
1720
+ G as DetourStraightEdgeShape,
1721
+ A as EdgeType,
1722
+ se as HorizontalEdgeShape,
1723
+ Te as HtmlGraphBuilder,
1724
+ C as HtmlGraphError,
1725
+ re as StraightEdgeShape,
1726
+ Ee as UserDraggableNodesCanvas,
1727
+ Ne as UserTransformableCanvas,
1728
+ oe as VerticalEdgeShape,
1729
+ ae as createBezierEdgeShapeFactory,
1730
+ de as createHorizontalEdgeShapeFactory,
1731
+ he as createStraightEdgeShareFactory,
1732
+ ce as createVerticalEdgeShapeFactory
1812
1733
  };