@html-graph/html-graph 0.0.53 → 0.0.54

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