@html-graph/html-graph 0.0.57 → 0.0.58

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