@html-graph/html-graph 0.0.51 → 0.0.53

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