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