@html-graph/html-graph 0.0.49 → 0.0.51

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,12 +1,12 @@
1
- var D = Object.defineProperty;
2
- var F = (o, t, e) => t in o ? D(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var n = (o, t, e) => F(o, typeof t != "symbol" ? t + "" : t, e);
4
- class k {
5
- constructor(t, e, s, r, a) {
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
6
  n(this, "canvasWrapper", null);
7
7
  n(this, "host");
8
8
  n(this, "nodesContainer");
9
- n(this, "connectionsContainer");
9
+ n(this, "edgesContainer");
10
10
  n(this, "canvas");
11
11
  n(this, "canvasCtx");
12
12
  n(this, "hostResizeObserver");
@@ -14,15 +14,15 @@ class k {
14
14
  n(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
15
15
  n(this, "nodeWrapperElementToIdMap", /* @__PURE__ */ new Map());
16
16
  n(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
17
- n(this, "connectionIdToElementMap", /* @__PURE__ */ new Map());
17
+ n(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
18
18
  n(this, "currentZIndex", 0);
19
19
  n(this, "layers", {
20
20
  "edges-on-top": {
21
21
  create: () => {
22
- this.host.appendChild(this.nodesContainer), this.host.appendChild(this.connectionsContainer);
22
+ this.host.appendChild(this.nodesContainer), this.host.appendChild(this.edgesContainer);
23
23
  },
24
24
  update: (t, e, s) => {
25
- this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`, this.connectionsContainer.style.transform = `matrix(${t}, 0, 0, ${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
26
  },
27
27
  moveOnTop: (t) => {
28
28
  this.currentZIndex += 1;
@@ -32,24 +32,24 @@ class k {
32
32
  },
33
33
  "edges-follow-node": {
34
34
  create: () => {
35
- this.host.appendChild(this.nodesContainer), this.connectionsContainer = this.nodesContainer;
35
+ this.host.appendChild(this.nodesContainer), this.edgesContainer = this.nodesContainer;
36
36
  },
37
37
  update: (t, e, s) => {
38
38
  this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`;
39
39
  },
40
40
  moveOnTop: (t) => {
41
41
  const e = this.nodeIdToWrapperElementMap.get(t);
42
- this.currentZIndex += 2, e.style.zIndex = `${this.currentZIndex}`, this.graphStore.getNodeAdjacentConnections(t).forEach((r) => {
43
- this.connectionIdToElementMap.get(r).style.zIndex = `${this.currentZIndex - 1}`;
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
44
  });
45
45
  }
46
46
  },
47
47
  "nodes-on-top": {
48
48
  create: () => {
49
- this.host.appendChild(this.connectionsContainer), this.host.appendChild(this.nodesContainer);
49
+ this.host.appendChild(this.edgesContainer), this.host.appendChild(this.nodesContainer);
50
50
  },
51
51
  update: (t, e, s) => {
52
- this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`, this.connectionsContainer.style.transform = `matrix(${t}, 0, 0, ${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
53
  },
54
54
  moveOnTop: (t) => {
55
55
  this.currentZIndex += 1;
@@ -58,15 +58,15 @@ class k {
58
58
  }
59
59
  }
60
60
  });
61
- this.graphStore = t, this.viewportTransformer = e, this.publicViewportTransformer = s, this.layersMode = r, this.backgroundDrawingFn = a, this.host = this.createHost(), this.canvas = this.createCanvas(), this.nodesContainer = this.createNodesContainer(), this.connectionsContainer = this.createConnectionsContainer();
62
- const c = this.canvas.getContext("2d");
63
- if (c === null)
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)
64
64
  throw new Error("unable to get canvas context");
65
- this.canvasCtx = c, this.host.appendChild(this.canvas), this.layers[this.layersMode].create(), this.hostResizeObserver = this.createHostResizeObserver(), this.hostResizeObserver.observe(this.host), this.nodesResizeObserver = this.createNodesResizeObserver();
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();
66
66
  }
67
67
  clear() {
68
- Array.from(this.connectionIdToElementMap.keys()).forEach((t) => {
69
- this.detachConnection(t);
68
+ Array.from(this.edgeIdToElementMap.keys()).forEach((t) => {
69
+ this.detachEdge(t);
70
70
  }), Array.from(this.nodeElementToIdMap.values()).forEach((t) => {
71
71
  this.detachNode(t);
72
72
  });
@@ -78,7 +78,7 @@ class k {
78
78
  this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
79
79
  }
80
80
  destroy() {
81
- this.hostResizeObserver.disconnect(), this.nodesResizeObserver.disconnect(), this.host.removeChild(this.canvas), this.host.removeChild(this.connectionsContainer), this.host.removeChild(this.nodesContainer), this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
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);
82
82
  }
83
83
  applyTransform() {
84
84
  this.backgroundDrawingFn(this.canvasCtx, this.publicViewportTransformer);
@@ -95,26 +95,26 @@ class k {
95
95
  const s = this.nodeIdToWrapperElementMap.get(t);
96
96
  s.removeChild(e.element), this.nodeElementToIdMap.delete(e.element), this.nodeWrapperElementToIdMap.delete(s), this.nodeIdToWrapperElementMap.delete(t);
97
97
  }
98
- attachConnection(t) {
99
- const s = this.graphStore.getConnection(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.connectionIdToElementMap.set(t, s), this.updateConnectionCoords(t), this.connectionsContainer.appendChild(s);
98
+ 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);
101
101
  }
102
- detachConnection(t) {
103
- const e = this.connectionIdToElementMap.get(t);
104
- this.connectionIdToElementMap.delete(t), this.connectionsContainer.removeChild(e);
102
+ detachEdge(t) {
103
+ const e = this.edgeIdToElementMap.get(t);
104
+ this.edgeIdToElementMap.delete(t), this.edgesContainer.removeChild(e);
105
105
  }
106
106
  moveNodeOnTop(t) {
107
107
  this.layers[this.layersMode].moveOnTop(t);
108
108
  }
109
109
  updateNodeCoordinates(t) {
110
- const e = this.graphStore.getNode(t), s = this.graphStore.getNodeAdjacentConnections(t);
111
- this.updateNodeCoords(t, e.x, e.y), s.forEach((r) => {
112
- this.updateConnectionCoords(r);
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);
113
113
  });
114
114
  }
115
- updatePortConnections(t) {
116
- this.graphStore.getPortAdjacentConnections(t).forEach((s) => {
117
- this.updateConnectionCoords(s);
115
+ updatePortEdges(t) {
116
+ this.graphStore.getPortAdjacentEdges(t).forEach((s) => {
117
+ this.updateEdgeCoords(s);
118
118
  });
119
119
  }
120
120
  getViewportDimensions() {
@@ -133,7 +133,7 @@ class k {
133
133
  const t = document.createElement("div");
134
134
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
135
135
  }
136
- createConnectionsContainer() {
136
+ createEdgesContainer() {
137
137
  const t = document.createElement("div");
138
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
139
  }
@@ -145,9 +145,9 @@ class k {
145
145
  createNodesResizeObserver() {
146
146
  return new ResizeObserver((t) => {
147
147
  t.forEach((e) => {
148
- const s = e.target, r = this.nodeWrapperElementToIdMap.get(s), a = this.graphStore.getNode(r);
149
- this.updateNodeCoords(r, a.x, a.y), this.graphStore.getNodeAdjacentConnections(r).forEach((h) => {
150
- this.updateConnectionCoords(h);
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);
151
151
  });
152
152
  });
153
153
  });
@@ -157,27 +157,27 @@ class k {
157
157
  this.canvas.width = t, this.canvas.height = e;
158
158
  }
159
159
  updateNodeCoords(t, e, s) {
160
- const r = this.nodeIdToWrapperElementMap.get(t), { width: a, height: c } = r.getBoundingClientRect(), h = this.viewportTransformer.getAbsScale(), i = this.graphStore.getNode(t), [d, g] = i.centerFn(a, c);
161
- r.style.transform = `matrix(1, 0, 0, 1, ${e - h * d}, ${s - h * g})`;
162
- }
163
- updateConnectionCoords(t) {
164
- const e = this.graphStore.getConnection(t), s = this.graphStore.getPort(e.from), r = this.graphStore.getPort(e.to), a = s.element.getBoundingClientRect(), c = r.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), [i, d] = this.viewportTransformer.getAbsCoords(
165
- a.left - h.left,
166
- a.top - h.top
167
- ), [g, l] = this.viewportTransformer.getAbsCoords(
168
- c.left - h.left,
169
- c.top - h.top
170
- ), u = this.viewportTransformer.getAbsScale(), [w, m] = s.centerFn(
171
- a.width * u,
172
- a.height * u
173
- ), [p, C] = r.centerFn(
174
- c.width * u,
175
- c.height * u
176
- ), f = w + i, y = m + d, b = p + g, E = C + l, $ = Math.min(f, b), N = Math.min(y, E), A = Math.abs(b - f), P = Math.abs(E - y);
177
- e.controller.update($, N, A, P, s, r);
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})`;
162
+ }
163
+ 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(
165
+ i.left - a.left,
166
+ 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);
178
178
  }
179
179
  }
180
- class W {
180
+ class B {
181
181
  constructor() {
182
182
  n(this, "state", {
183
183
  scale: 1,
@@ -211,7 +211,7 @@ class W {
211
211
  };
212
212
  }
213
213
  }
214
- class j {
214
+ class Y {
215
215
  constructor(t) {
216
216
  this.transformer = t;
217
217
  }
@@ -244,22 +244,19 @@ class j {
244
244
  return this.transformer.getAbsScale();
245
245
  }
246
246
  }
247
- class R {
247
+ class X {
248
248
  constructor() {
249
249
  n(this, "nodes", /* @__PURE__ */ Object.create(null));
250
250
  n(this, "ports", /* @__PURE__ */ Object.create(null));
251
251
  n(this, "nodePorts", /* @__PURE__ */ Object.create(null));
252
252
  n(this, "portNodeId", /* @__PURE__ */ Object.create(null));
253
- n(this, "connections", /* @__PURE__ */ Object.create(null));
254
- n(this, "incommingConnections", /* @__PURE__ */ Object.create(null));
255
- n(this, "outcommingConnections", /* @__PURE__ */ Object.create(null));
256
- n(this, "cycleConnections", /* @__PURE__ */ Object.create(null));
257
- }
258
- getAllNodes() {
259
- return this.nodes;
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));
260
257
  }
261
- addNode(t, e, s, r, a) {
262
- this.nodes[t] = { element: e, x: s, y: r, centerFn: a }, this.nodePorts[t] = /* @__PURE__ */ Object.create(null);
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);
263
260
  }
264
261
  hasNode(t) {
265
262
  return this.nodes[t] !== void 0;
@@ -270,22 +267,22 @@ class R {
270
267
  updateNodeCoords(t, e, s) {
271
268
  this.nodes[t].x = e, this.nodes[t].y = s;
272
269
  }
273
- updateConnectionController(t, e) {
274
- this.connections[t].controller = e;
270
+ updateEdgeController(t, e) {
271
+ this.edges[t].controller = e;
275
272
  }
276
273
  removeNode(t) {
277
- this.getNodeAdjacentConnections(t).forEach((r) => {
278
- this.removeConnection(r);
274
+ this.getNodeAdjacentEdges(t).forEach((o) => {
275
+ this.removeEdge(o);
279
276
  }), delete this.nodes[t];
280
277
  const s = this.nodePorts[t];
281
- Object.keys(s).forEach((r) => {
282
- delete this.portNodeId[r];
278
+ Object.keys(s).forEach((o) => {
279
+ delete this.portNodeId[o];
283
280
  }), delete this.nodePorts[t];
284
281
  }
285
- addPort(t, e, s, r, a) {
286
- this.ports[t] = { element: e, centerFn: r, direction: a }, this.cycleConnections[t] = {}, this.incommingConnections[t] = {}, this.outcommingConnections[t] = {}, this.portNodeId[t] = s;
287
- const c = this.nodePorts[s];
288
- c !== void 0 && (c[t] = e);
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);
289
286
  }
290
287
  getPort(t) {
291
288
  return this.ports[t];
@@ -297,363 +294,465 @@ class R {
297
294
  return this.portNodeId[t] !== void 0;
298
295
  }
299
296
  removePort(t) {
300
- Object.keys(this.cycleConnections[t]).forEach((r) => {
301
- this.removeConnection(r);
302
- }), delete this.cycleConnections[t], Object.keys(this.incommingConnections[t]).forEach((r) => {
303
- this.removeConnection(r);
304
- }), delete this.incommingConnections[t], Object.keys(this.outcommingConnections[t]).forEach((r) => {
305
- this.removeConnection(r);
306
- }), delete this.outcommingConnections[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];
307
304
  const e = this.portNodeId[t];
308
305
  delete this.portNodeId[t];
309
306
  const s = this.nodePorts[e];
310
307
  delete s[t], delete this.ports[t];
311
308
  }
312
- addConnection(t, e, s, r) {
313
- this.connections[t] = {
309
+ addEdge(t, e, s, o) {
310
+ this.edges[t] = {
314
311
  from: e,
315
312
  to: s,
316
- controller: r
317
- }, e !== s ? (this.outcommingConnections[e][t] = !0, this.incommingConnections[s][t] = !0) : this.cycleConnections[e][t] = !0;
313
+ controller: o
314
+ }, e !== s ? (this.outcommingEdges[e][t] = !0, this.incommingEdges[s][t] = !0) : this.cycleEdges[e][t] = !0;
318
315
  }
319
- getConnection(t) {
320
- return this.connections[t];
316
+ getEdge(t) {
317
+ return this.edges[t];
321
318
  }
322
- hasConnection(t) {
323
- return this.connections[t] !== void 0;
319
+ hasEdge(t) {
320
+ return this.edges[t] !== void 0;
324
321
  }
325
- removeConnection(t) {
326
- const e = this.connections[t], s = e.from, r = e.to;
327
- delete this.cycleConnections[s][t], delete this.cycleConnections[r][t], delete this.incommingConnections[s][t], delete this.incommingConnections[r][t], delete this.outcommingConnections[s][t], delete this.outcommingConnections[r][t], delete this.connections[t];
322
+ 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];
328
325
  }
329
- getPortAdjacentConnections(t) {
326
+ getPortAdjacentEdges(t) {
330
327
  return [
331
- ...this.getPortIncomingConnections(t),
332
- ...this.getPortOutcomingConnections(t),
333
- ...this.getPortCycleConnections(t)
328
+ ...this.getPortIncomingEdges(t),
329
+ ...this.getPortOutcomingEdges(t),
330
+ ...this.getPortCycleEdges(t)
334
331
  ];
335
332
  }
336
- getNodeAdjacentConnections(t) {
333
+ getNodeAdjacentEdges(t) {
337
334
  return [
338
- ...this.getNodeIncomingConnections(t),
339
- ...this.getNodeOutcomingConnections(t),
340
- ...this.getNodeCycleConnections(t)
335
+ ...this.getNodeIncomingEdges(t),
336
+ ...this.getNodeOutcomingEdges(t),
337
+ ...this.getNodeCycleEdges(t)
341
338
  ];
342
339
  }
343
340
  clear() {
344
- 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.connections = /* @__PURE__ */ Object.create(null), this.incommingConnections = /* @__PURE__ */ Object.create(null), this.outcommingConnections = /* @__PURE__ */ Object.create(null), this.cycleConnections = /* @__PURE__ */ Object.create(null);
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);
345
342
  }
346
- getPortIncomingConnections(t) {
347
- return Object.keys(this.incommingConnections[t] ?? {});
343
+ getPortIncomingEdges(t) {
344
+ return Object.keys(this.incommingEdges[t] ?? {});
348
345
  }
349
- getPortOutcomingConnections(t) {
350
- return Object.keys(this.outcommingConnections[t] ?? {});
346
+ getPortOutcomingEdges(t) {
347
+ return Object.keys(this.outcommingEdges[t] ?? {});
351
348
  }
352
- getPortCycleConnections(t) {
353
- return Object.keys(this.cycleConnections[t] ?? {});
349
+ getPortCycleEdges(t) {
350
+ return Object.keys(this.cycleEdges[t] ?? {});
354
351
  }
355
- getNodeIncomingConnections(t) {
352
+ getNodeIncomingEdges(t) {
356
353
  const e = Object.keys(this.nodePorts[t]);
357
354
  let s = [];
358
- return e.forEach((r) => {
359
- s = [...s, ...this.getPortIncomingConnections(r)];
355
+ return e.forEach((o) => {
356
+ s = [...s, ...this.getPortIncomingEdges(o)];
360
357
  }), s;
361
358
  }
362
- getNodeOutcomingConnections(t) {
359
+ getNodeOutcomingEdges(t) {
363
360
  const e = Object.keys(this.nodePorts[t]);
364
361
  let s = [];
365
- return e.forEach((r) => {
366
- s = [...s, ...this.getPortOutcomingConnections(r)];
362
+ return e.forEach((o) => {
363
+ s = [...s, ...this.getPortOutcomingEdges(o)];
367
364
  }), s;
368
365
  }
369
- getNodeCycleConnections(t) {
366
+ getNodeCycleEdges(t) {
370
367
  const e = Object.keys(this.nodePorts[t]);
371
368
  let s = [];
372
- return e.forEach((r) => {
373
- s = [...s, ...this.getPortCycleConnections(r)];
369
+ return e.forEach((o) => {
370
+ s = [...s, ...this.getPortCycleEdges(o)];
374
371
  }), s;
375
372
  }
376
373
  }
377
- class v {
378
- static getPortCenter(t) {
379
- const { top: e, left: s, width: r, height: a } = t.element.getBoundingClientRect(), c = t.centerFn(r, a);
380
- return [s + c[0], e + c[1]];
381
- }
382
- static rotate(t, e, s) {
383
- return [
384
- e[0] * t[0] - e[1] * t[1] + ((1 - e[0]) * s[0] + e[1] * s[1]),
385
- e[1] * t[0] + e[0] * t[1] + ((1 - e[0]) * s[1] - e[1] * s[0])
386
- ];
387
- }
388
- static getDirectionVector(t, e, s) {
389
- return [e * Math.cos(t ?? 0), s * Math.sin(t ?? 0)];
390
- }
391
- static getArrowPath(t, e, s, r, a) {
392
- const h = [
393
- [0, 0],
394
- [r, a],
395
- [r, -a]
396
- ].map((l) => this.rotate(l, t, [0, 0])).map((l) => [l[0] + e, l[1] + s]), i = `M ${h[0][0]} ${h[0][1]}`, d = `L ${h[1][0]} ${h[1][1]}`, g = `L ${h[2][0]} ${h[2][1]}`;
397
- return `${i} ${d} ${g}`;
398
- }
399
- static getArrowOffsetPath(t, e, s, r, a) {
400
- const h = [
401
- [r, 0],
402
- [r + a, 0]
403
- ].map((i) => this.rotate(i, t, [0, 0])).map((i) => [i[0] + e, i[1] + s]);
404
- return `M ${h[0][0]} ${h[0][1]} L ${h[1][0]} ${h[1][1]}`;
405
- }
406
- static createStraightPath(t) {
407
- return t.map((e, s) => `${s === 0 ? "M" : "L"} ${e[0]} ${e[1]}`).join(" ");
408
- }
409
- }
410
- class B {
411
- constructor(t, e, s, r, a, c, h) {
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) => [
378
+ t[0] * r[0] - t[1] * r[1] + ((1 - t[0]) * e[0] + t[1] * e[1]),
379
+ 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 = [
382
+ [0, 0],
383
+ [s, o],
384
+ [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]}`;
386
+ return `${a} ${c} ${l}`;
387
+ };
388
+ class z {
389
+ constructor(t, e, s, o, i, h, a) {
412
390
  n(this, "svg");
413
391
  n(this, "group");
414
392
  n(this, "line");
415
393
  n(this, "sourceArrow", null);
416
394
  n(this, "targetArrow", null);
417
- this.color = t, this.width = e, this.curvature = s, this.arrowLength = r, this.arrowWidth = 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%", c && (this.sourceArrow = document.createElementNS(
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(
418
396
  "http://www.w3.org/2000/svg",
419
397
  "path"
420
- ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = document.createElementNS(
398
+ ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
421
399
  "http://www.w3.org/2000/svg",
422
400
  "path"
423
401
  ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
424
402
  }
425
- update(t, e, s, r, a, c) {
426
- this.svg.style.width = `${s}px`, this.svg.style.height = `${r}px`;
427
- const h = v.getPortCenter(a), i = v.getPortCenter(c), d = h[0] <= i[0] ? 1 : -1, g = h[1] <= i[1] ? 1 : -1;
428
- this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${d}, ${g})`;
429
- const l = v.getDirectionVector(a.direction, d, g), u = v.getDirectionVector(c.direction, d, g), w = v.rotate([this.arrowLength, 0], l, [0, 0]), m = v.rotate([s - this.arrowLength, r], u, [
403
+ update(t, e, s, o, i, h) {
404
+ 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;
406
+ 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, [
430
408
  s,
431
- r
432
- ]), p = [
433
- w[0] + l[0] * this.curvature,
434
- w[1] + l[1] * this.curvature
435
- ], C = [
436
- m[0] - u[0] * this.curvature,
437
- m[1] - u[1] * this.curvature
438
- ], f = `M ${w[0]} ${w[1]} C ${p[0]} ${p[1]}, ${C[0]} ${C[1]}, ${m[0]} ${m[1]}`, y = this.sourceArrow ? "" : `M 0 0 L ${w[0]} ${w[1]} `, b = this.targetArrow ? "" : ` M ${m[0]} ${m[1]} L ${s} ${r}`, E = `${y}${f}${b}`;
439
- if (this.line.setAttribute("d", E), this.sourceArrow) {
440
- const $ = v.getArrowPath(
441
- l,
409
+ o
410
+ ]), 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,
442
420
  0,
443
421
  0,
444
422
  this.arrowLength,
445
423
  this.arrowWidth
446
424
  );
447
- this.sourceArrow.setAttribute("d", $);
425
+ this.sourceArrow.setAttribute("d", y);
448
426
  }
449
427
  if (this.targetArrow) {
450
- const $ = v.getArrowPath(
451
- u,
428
+ const y = S(
429
+ g,
452
430
  s,
453
- r,
431
+ o,
454
432
  -this.arrowLength,
455
433
  this.arrowWidth
456
434
  );
457
- this.targetArrow.setAttribute("d", $);
435
+ this.targetArrow.setAttribute("d", y);
458
436
  }
459
437
  }
460
438
  }
461
- class z {
462
- constructor(t, e, s, r, a, c, h, i) {
439
+ const V = (r, t) => {
440
+ const e = [];
441
+ 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
+ const s = r.length - 1;
443
+ let o = 0, i = 0, h = 0;
444
+ 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);
450
+ }
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]}`
454
+ );
455
+ });
456
+ }
457
+ return e.join(" ");
458
+ };
459
+ class G {
460
+ constructor(t, e, s, o, i, h, a, c) {
463
461
  n(this, "svg");
464
462
  n(this, "group");
465
463
  n(this, "line");
466
464
  n(this, "sourceArrow", null);
467
465
  n(this, "targetArrow", null);
468
- n(this, "roundness");
469
- this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = r, this.minPortOffset = a, this.roundness = Math.min(this.minPortOffset, 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%", c && (this.sourceArrow = document.createElementNS(
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(
470
467
  "http://www.w3.org/2000/svg",
471
468
  "path"
472
- ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = document.createElementNS(
469
+ ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
473
470
  "http://www.w3.org/2000/svg",
474
471
  "path"
475
472
  ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
476
473
  }
477
- update(t, e, s, r, a, c) {
478
- this.svg.style.width = `${s}px`, this.svg.style.height = `${r}px`;
479
- const h = v.getPortCenter(a), i = v.getPortCenter(c), d = h[0] <= i[0] ? 1 : -1, g = h[1] <= i[1] ? 1 : -1;
480
- this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${d}, ${g})`;
481
- const l = v.getDirectionVector(a.direction, d, g), u = v.getDirectionVector(c.direction, d, g);
482
- console.log(this.roundness);
483
- const w = this.arrowLength + this.minPortOffset, m = v.rotate([w, 0], l, [0, 0]), p = v.rotate([s - w, r], u, [s, r]), [C, f] = [s / 2, r / 2], b = d * (p[0] - m[0]) > 0 ? v.createStraightPath([
484
- [m[0], m[1]],
485
- [C, m[1]],
486
- [C, p[1]],
487
- [p[0], p[1]]
488
- ]) : v.createStraightPath([
489
- [m[0], m[1]],
490
- [m[0], f],
491
- [p[0], f],
492
- [p[0], p[1]]
493
- ]), E = v.getArrowOffsetPath(
494
- l,
495
- 0,
496
- 0,
497
- this.arrowLength,
498
- this.minPortOffset
499
- ), $ = v.getArrowOffsetPath(
500
- u,
474
+ update(t, e, s, o, i, h) {
475
+ 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;
477
+ 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, [
479
+ s,
480
+ o
481
+ ]) : [s, o], f = this.arrowLength + this.arrowOffset, p = b([f, 0], u, [0, 0]), C = b([s - f, o], g, [
501
482
  s,
502
- r,
503
- -this.arrowLength,
504
- -this.minPortOffset
505
- ), N = `M 0 0 L ${m[0]} ${m[1]} `, A = ` M ${p[0]} ${p[1]} L ${s} ${r}`, P = this.sourceArrow ? E : N, L = this.targetArrow ? $ : A, V = `${P}${b}${L}`;
506
- if (this.line.setAttribute("d", V), this.sourceArrow) {
507
- const x = v.getArrowPath(
508
- l,
483
+ o
484
+ ]), v = V([w, p, C, m], this.roundness);
485
+ if (this.line.setAttribute("d", v), this.sourceArrow) {
486
+ const E = S(
487
+ u,
509
488
  0,
510
489
  0,
511
490
  this.arrowLength,
512
491
  this.arrowWidth
513
492
  );
514
- this.sourceArrow.setAttribute("d", x);
493
+ this.sourceArrow.setAttribute("d", E);
515
494
  }
516
495
  if (this.targetArrow) {
517
- const x = v.getArrowPath(
518
- u,
496
+ const E = S(
497
+ g,
519
498
  s,
520
- r,
499
+ o,
521
500
  -this.arrowLength,
522
501
  this.arrowWidth
523
502
  );
524
- this.targetArrow.setAttribute("d", x);
503
+ this.targetArrow.setAttribute("d", E);
525
504
  }
526
505
  }
527
506
  }
528
- class Y {
529
- constructor(t, e, s, r, a, c, h) {
507
+ class Z {
508
+ constructor(t, e, s, o, i, h, a) {
530
509
  n(this, "svg");
531
510
  n(this, "group");
532
511
  n(this, "line");
533
512
  n(this, "arrow", null);
534
- this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = r, this.radius = c, this.smallRadius = h, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", a && (this.arrow = document.createElementNS(
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(
535
514
  "http://www.w3.org/2000/svg",
536
515
  "path"
537
516
  ), 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";
538
517
  }
539
- update(t, e, s, r, a) {
518
+ update(t, e, s, o, i) {
540
519
  this.svg.style.transform = `translate(${t}px, ${e}px)`;
541
- const c = v.getDirectionVector(a.direction, 1, 1), h = this.smallRadius, i = this.radius, d = Math.sqrt(h * h + i * i), g = h + i, l = this.arrowLength + d * (1 - i / g), u = h * i / g, m = [
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 = [
542
521
  [this.arrowLength, 0],
543
- [l, u],
544
- [l, -u]
545
- ].map((y) => v.rotate(y, c, [0, 0])), p = [
522
+ [u, g],
523
+ [u, -g]
524
+ ].map((v) => b(v, h, [0, 0])), f = [
546
525
  `M ${m[0][0]} ${m[0][1]}`,
547
- `A ${h} ${h} 0 0 1 ${m[1][0]} ${m[1][1]}`,
548
- `A ${i} ${i} 0 1 0 ${m[2][0]} ${m[2][1]}`,
549
- `A ${h} ${h} 0 0 1 ${m[0][0]} ${m[0][1]}`
550
- ].join(" "), C = `M 0 0 L ${m[0][0]} ${m[0][1]} `, f = `${this.arrow !== null ? "" : C}${p}`;
551
- if (this.line.setAttribute("d", f), this.arrow) {
552
- const y = v.getArrowPath(
553
- c,
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,
554
533
  0,
555
534
  0,
556
535
  this.arrowLength,
557
536
  this.arrowWidth
558
537
  );
559
- this.arrow.setAttribute("d", y);
538
+ this.arrow.setAttribute("d", v);
560
539
  }
561
540
  }
562
541
  }
563
- class G {
564
- constructor(t, e, s, r, a, c, h, i) {
542
+ class U {
543
+ constructor(t, e, s, o, i, h, a, c) {
565
544
  n(this, "svg");
566
545
  n(this, "group");
567
546
  n(this, "line");
568
547
  n(this, "arrow", null);
569
548
  n(this, "roundness");
570
- n(this, "points");
571
- this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = r, this.side = c, this.minPortOffset = h, this.roundness = Math.min(i, 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%", a && (this.arrow = document.createElementNS(
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(
572
551
  "http://www.w3.org/2000/svg",
573
552
  "path"
574
553
  ), 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";
575
- const d = this.minPortOffset, g = this.side, l = this.arrowLength + d, u = this.roundness, w = l - u, m = l + u, p = g - u, C = l + 2 * g, f = C - u;
576
- console.log(u), this.points = [
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 = [
577
556
  [this.arrowLength, 0],
578
- [w, 0],
579
- [l, u],
580
- [l, p],
581
- [m, g],
582
- [f, g],
583
- [C, p],
584
- [C, -p],
585
- [f, -g],
586
- [m, -g],
587
- [l, -p],
588
- [l, -u]
557
+ [u, 0],
558
+ [u, this.side],
559
+ [w, this.side],
560
+ [w, -this.side],
561
+ [u, -this.side],
562
+ [u, 0],
563
+ [this.arrowLength, 0]
589
564
  ];
590
565
  }
591
- update(t, e, s, r, a) {
566
+ update(t, e, s, o, i) {
592
567
  this.svg.style.transform = `translate(${t}px, ${e}px)`;
593
- const c = v.getDirectionVector(a.direction, 1, 1), h = this.roundness, i = this.points.map((u) => v.rotate(u, c, [0, 0])), d = [
594
- `M ${i[0][0]} ${i[0][1]}`,
595
- `L ${i[1][0]} ${i[1][1]}`,
596
- `A ${h} ${h} 0 0 1 ${i[2][0]} ${i[2][1]}`,
597
- `L ${i[3][0]} ${i[3][1]}`,
598
- `A ${h} ${h} 0 0 0 ${i[4][0]} ${i[4][1]}`,
599
- `L ${i[5][0]} ${i[5][1]}`,
600
- `A ${h} ${h} 0 0 0 ${i[6][0]} ${i[6][1]}`,
601
- `L ${i[7][0]} ${i[7][1]}`,
602
- `A ${h} ${h} 0 0 0 ${i[8][0]} ${i[8][1]}`,
603
- `L ${i[9][0]} ${i[9][1]}`,
604
- `A ${h} ${h} 0 0 0 ${i[10][0]} ${i[10][1]}`,
605
- `L ${i[11][0]} ${i[11][1]}`,
606
- `A ${h} ${h} 0 0 1 ${i[1][0]} ${i[1][1]}`
607
- ].join(" "), g = `M 0 0 L ${i[0][0]} ${i[0][1]} `, l = `${this.arrow ? "" : g}${d}`;
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)}`;
608
571
  if (this.line.setAttribute("d", l), this.arrow) {
609
- const u = v.getArrowPath(
610
- c,
572
+ const d = S(
573
+ h,
574
+ 0,
575
+ 0,
576
+ this.arrowLength,
577
+ this.arrowWidth
578
+ );
579
+ this.arrow.setAttribute("d", d);
580
+ }
581
+ }
582
+ }
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(
593
+ "http://www.w3.org/2000/svg",
594
+ "path"
595
+ ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
596
+ "http://www.w3.org/2000/svg",
597
+ "path"
598
+ ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
599
+ }
600
+ update(t, e, s, o, i, h) {
601
+ 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;
603
+ 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, [
605
+ s,
606
+ 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, [
608
+ s,
609
+ o
610
+ ]), E = [v[0] + this.detourX, v[1] + this.detourY], A = V(
611
+ [w, p, C, E, v, m],
612
+ this.roundness
613
+ );
614
+ if (this.line.setAttribute("d", A), this.sourceArrow) {
615
+ const y = S(
616
+ u,
617
+ 0,
618
+ 0,
619
+ this.arrowLength,
620
+ this.arrowWidth
621
+ );
622
+ this.sourceArrow.setAttribute("d", y);
623
+ }
624
+ if (this.targetArrow) {
625
+ const y = S(
626
+ g,
627
+ s,
628
+ o,
629
+ -this.arrowLength,
630
+ this.arrowWidth
631
+ );
632
+ this.targetArrow.setAttribute("d", y);
633
+ }
634
+ }
635
+ }
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(
647
+ "http://www.w3.org/2000/svg",
648
+ "path"
649
+ ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
650
+ "http://www.w3.org/2000/svg",
651
+ "path"
652
+ ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
653
+ }
654
+ update(t, e, s, o, i, h) {
655
+ 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;
657
+ 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, [
659
+ s,
660
+ 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, [
662
+ s,
663
+ 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]}`
676
+ ].join(" ");
677
+ if (this.line.setAttribute("d", k), this.sourceArrow) {
678
+ const O = S(
679
+ u,
611
680
  0,
612
681
  0,
613
682
  this.arrowLength,
614
683
  this.arrowWidth
615
684
  );
616
- this.arrow.setAttribute("d", u);
685
+ this.sourceArrow.setAttribute("d", O);
686
+ }
687
+ if (this.targetArrow) {
688
+ const O = S(
689
+ g,
690
+ s,
691
+ o,
692
+ -this.arrowLength,
693
+ this.arrowWidth
694
+ );
695
+ this.targetArrow.setAttribute("d", O);
617
696
  }
618
697
  }
619
698
  }
620
- var T = /* @__PURE__ */ ((o) => (o.Regular = "regular", o.Cycle = "cycle", o))(T || {});
621
- const X = (o) => (t) => t === "cycle" ? new Y(
622
- o.color,
623
- o.width,
624
- o.arrowLength,
625
- o.arrowWidth,
626
- o.hasSourceArrow || o.hasTargetArrow,
627
- o.cycleRadius,
628
- o.smallCycleRadius
629
- ) : new B(
630
- o.color,
631
- o.width,
632
- o.curvature,
633
- o.arrowLength,
634
- o.arrowWidth,
635
- o.hasSourceArrow,
636
- o.hasTargetArrow
637
- ), Z = (o) => (t) => t === T.Cycle && t === "cycle" ? new G(
638
- o.color,
639
- o.width,
640
- o.arrowLength,
641
- o.arrowWidth,
642
- o.hasSourceArrow || o.hasTargetArrow,
643
- o.cycleSquareSide,
644
- o.minPortOffset,
645
- o.roundness
699
+ const _ = (r) => (t) => t === T.PortCycle ? new Z(
700
+ r.color,
701
+ r.width,
702
+ r.arrowLength,
703
+ r.arrowWidth,
704
+ r.hasSourceArrow || r.hasTargetArrow,
705
+ r.cycleRadius,
706
+ r.smallCycleRadius
707
+ ) : t === T.NodeCycle ? new q(
708
+ r.color,
709
+ r.width,
710
+ r.curvature,
711
+ r.arrowLength,
712
+ r.arrowWidth,
713
+ r.hasSourceArrow,
714
+ r.hasTargetArrow,
715
+ r.detourDistance,
716
+ r.detourDirection
646
717
  ) : new z(
647
- o.color,
648
- o.width,
649
- o.arrowLength,
650
- o.arrowWidth,
651
- o.minPortOffset,
652
- o.hasSourceArrow,
653
- o.hasTargetArrow,
654
- o.roundness
718
+ r.color,
719
+ r.width,
720
+ r.curvature,
721
+ r.arrowLength,
722
+ r.arrowWidth,
723
+ r.hasSourceArrow,
724
+ r.hasTargetArrow
725
+ ), J = (r) => (t) => t === T.PortCycle ? new U(
726
+ r.color,
727
+ r.width,
728
+ r.arrowLength,
729
+ r.arrowWidth,
730
+ r.hasSourceArrow || r.hasTargetArrow,
731
+ r.cycleSquareSide,
732
+ r.arrowOffset,
733
+ r.roundness
734
+ ) : t === T.NodeCycle ? new H(
735
+ r.color,
736
+ r.width,
737
+ r.arrowLength,
738
+ r.arrowWidth,
739
+ r.arrowOffset,
740
+ r.hasSourceArrow,
741
+ r.hasTargetArrow,
742
+ r.roundness,
743
+ r.detourDistance,
744
+ r.detourDirection
745
+ ) : new G(
746
+ r.color,
747
+ r.width,
748
+ r.arrowLength,
749
+ r.arrowWidth,
750
+ r.arrowOffset,
751
+ r.hasSourceArrow,
752
+ r.hasTargetArrow,
753
+ r.roundness
655
754
  );
656
- class S {
755
+ class L {
657
756
  constructor() {
658
757
  n(this, "counter", 0);
659
758
  }
@@ -665,19 +764,19 @@ class S {
665
764
  this.counter = 0;
666
765
  }
667
766
  }
668
- class U {
669
- constructor(t, e, s, r, a) {
670
- n(this, "nodeIdGenerator", new S());
671
- n(this, "portIdGenerator", new S());
672
- n(this, "connectionIdGenerator", new S());
673
- this.graphStore = t, this.htmlController = e, this.viewportTransformer = s, this.nodesCenterFn = r, this.portsCenterFn = a;
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;
674
773
  }
675
774
  moveNodeOnTop(t) {
676
775
  if (!this.graphStore.hasNode(t))
677
776
  throw new Error("failed to move on top nonexisting node");
678
777
  this.htmlController.moveNodeOnTop(t);
679
778
  }
680
- addNode(t, e, s, r, a, c) {
779
+ addNode(t, e, s, o, i, h) {
681
780
  if (t === void 0)
682
781
  do
683
782
  t = this.nodeIdGenerator.next();
@@ -688,19 +787,25 @@ class U {
688
787
  t,
689
788
  e,
690
789
  s,
691
- r,
692
- c ?? this.nodesCenterFn
693
- ), this.htmlController.attachNode(t), a !== void 0 && Object.entries(a).forEach(([h, i]) => {
694
- i instanceof HTMLElement ? this.markPort(h, i, t, this.portsCenterFn, null) : this.markPort(
695
- h,
696
- i.element,
790
+ 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,
697
796
  t,
698
- i.centerFn ?? this.portsCenterFn,
699
- i.direction ?? null
797
+ this.portsCenterFn,
798
+ this.portsDirection
799
+ ) : this.markPort(
800
+ a,
801
+ c.element,
802
+ t,
803
+ c.centerFn ?? this.portsCenterFn,
804
+ c.direction ?? this.portsDirection
700
805
  );
701
806
  });
702
807
  }
703
- markPort(t, e, s, r, a) {
808
+ markPort(t, e, s, o, i) {
704
809
  if (t === void 0)
705
810
  do
706
811
  t = this.portIdGenerator.next();
@@ -713,43 +818,44 @@ class U {
713
818
  t,
714
819
  e,
715
820
  s,
716
- r ?? this.portsCenterFn,
717
- a ?? null
821
+ o ?? this.portsCenterFn,
822
+ i ?? 0
718
823
  );
719
824
  }
720
- updatePortConnections(t) {
825
+ updatePortEdges(t) {
721
826
  if (!this.graphStore.hasPort(t))
722
827
  throw new Error("failed to unset nonexisting port");
723
- this.htmlController.updatePortConnections(t);
828
+ this.htmlController.updatePortEdges(t);
724
829
  }
725
830
  unmarkPort(t) {
726
831
  if (!this.graphStore.hasPort(t))
727
832
  throw new Error("failed to unset nonexisting port");
728
- this.graphStore.getPortAdjacentConnections(t).forEach((e) => {
729
- this.removeConnection(e);
833
+ this.graphStore.getPortAdjacentEdges(t).forEach((e) => {
834
+ this.removeEdge(e);
730
835
  }), this.graphStore.removePort(t);
731
836
  }
732
- addConnection(t, e, s, r) {
837
+ addEdge(t, e, s, o) {
733
838
  if (t === void 0)
734
839
  do
735
- t = this.connectionIdGenerator.next();
736
- while (this.graphStore.hasConnection(t));
840
+ t = this.edgeIdGenerator.next();
841
+ while (this.graphStore.hasEdge(t));
737
842
  if (!this.graphStore.hasPort(e))
738
- throw new Error("failed to add connection from nonexisting port");
843
+ throw new Error("failed to add edge from nonexisting port");
739
844
  if (!this.graphStore.hasPort(s))
740
- throw new Error("failed to add connection to nonexisting port");
741
- let a = T.Regular;
742
- e === s && (a = T.Cycle), this.graphStore.addConnection(
845
+ 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(
743
849
  t,
744
850
  e,
745
851
  s,
746
- r(a)
747
- ), this.htmlController.attachConnection(t);
852
+ o(i)
853
+ ), this.htmlController.attachEdge(t);
748
854
  }
749
- removeConnection(t) {
750
- if (!this.graphStore.hasConnection(t))
751
- throw new Error("failed to remove nonexisting connection");
752
- this.htmlController.detachConnection(t), this.graphStore.removeConnection(t);
855
+ removeEdge(t) {
856
+ if (!this.graphStore.hasEdge(t))
857
+ throw new Error("failed to remove nonexisting edge");
858
+ this.htmlController.detachEdge(t), this.graphStore.removeEdge(t);
753
859
  }
754
860
  removeNode(t) {
755
861
  if (!this.graphStore.hasNode(t))
@@ -762,24 +868,24 @@ class U {
762
868
  moveToNodes(t) {
763
869
  if (t.length === 0)
764
870
  return;
765
- const e = t.map((u) => this.graphStore.getNode(u)).filter((u) => u !== void 0);
871
+ const e = t.map((g) => this.graphStore.getNode(g)).filter((g) => g !== void 0);
766
872
  if (e.length < t.length)
767
873
  throw new Error("failed to move to nonexisting node");
768
- const [s, r] = e.reduce(
769
- (u, w) => [u[0] + w.x, u[1] + w.y],
874
+ const [s, o] = e.reduce(
875
+ (g, w) => [g[0] + w.x, g[1] + w.y],
770
876
  [0, 0]
771
- ), a = s / e.length, c = r / e.length, [h, i] = this.htmlController.getViewportDimensions(), d = this.viewportTransformer.getAbsScale(), g = a - d * h / 2, l = c - d * i / 2;
772
- this.patchViewportState(null, g, l);
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);
773
879
  }
774
880
  updateNodeCoordinates(t, e, s) {
775
881
  if (!this.graphStore.hasNode(t))
776
882
  throw new Error("failed to update coordinates of nonexisting node");
777
883
  this.graphStore.updateNodeCoords(t, e, s), this.htmlController.updateNodeCoordinates(t);
778
884
  }
779
- updateConnectionController(t, e) {
780
- if (!this.graphStore.hasConnection(t))
781
- throw new Error("failed to update nonexisting connection");
782
- this.htmlController.detachConnection(t), this.graphStore.updateConnectionController(t, e), this.htmlController.attachConnection(t);
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);
783
889
  }
784
890
  attach(t) {
785
891
  this.htmlController.attach(t);
@@ -788,145 +894,152 @@ class U {
788
894
  this.htmlController.detach();
789
895
  }
790
896
  clear() {
791
- this.htmlController.clear(), this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.connectionIdGenerator.reset();
897
+ this.htmlController.clear(), this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset();
792
898
  }
793
899
  destroy() {
794
900
  this.htmlController.destroy();
795
901
  }
796
902
  }
797
- class H {
798
- constructor(t, e, s, r) {
903
+ class Q {
904
+ constructor(t, e, s, o, i) {
799
905
  n(this, "publicViewportTransformer");
800
906
  n(this, "canvasController");
801
- const a = new W(), c = new R();
802
- this.publicViewportTransformer = new j(
803
- a
907
+ const h = new B(), a = new X();
908
+ this.publicViewportTransformer = new Y(
909
+ h
804
910
  );
805
- const h = new k(
806
- c,
911
+ const c = new R(
807
912
  a,
913
+ h,
808
914
  this.publicViewportTransformer,
809
915
  t,
810
916
  e
811
917
  );
812
- this.canvasController = new U(
918
+ this.canvasController = new K(
919
+ a,
813
920
  c,
814
921
  h,
815
- a,
816
922
  s,
817
- r
923
+ o,
924
+ i
818
925
  );
819
926
  }
820
927
  }
821
- const M = (o, t) => [
822
- o / 2,
928
+ const D = (r, t) => [
929
+ r / 2,
823
930
  t / 2
824
- ], _ = () => () => {
825
- }, q = (o, t, e, s, r, a) => {
826
- o.clearRect(0, 0, o.canvas.width, o.canvas.height), o.fillStyle = a, o.fillRect(0, 0, o.canvas.width, o.canvas.height);
827
- const c = t.getViewCoords(0, 0), h = t.getViewScale(), i = s * h;
828
- let d = 0, g = 0, l = i / 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;
829
936
  do
830
- l *= 2, d = o.canvas.width / l, g = o.canvas.height / l;
831
- while (d * g > 1e4);
832
- const u = c[0] - Math.floor(c[0] / l) * l, w = c[1] - Math.floor(c[1] / l) * l, m = r * h, p = 2 * Math.PI, C = u - l, f = w - l, y = o.canvas.width + u, b = o.canvas.height + w;
833
- o.fillStyle = e;
834
- for (let E = C; E <= y; E += l)
835
- for (let $ = f; $ <= b; $ += l)
836
- o.beginPath(), o.arc(E, $, m, 0, p), o.closePath(), o.fill();
837
- }, J = (o, t, e, s) => (r, a) => {
838
- q(
839
- r,
840
- a,
937
+ u *= 2, l = r.canvas.width / u, d = r.canvas.height / u;
938
+ 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;
940
+ 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(
841
946
  o,
947
+ i,
948
+ r,
842
949
  t,
843
950
  e,
844
951
  s
845
952
  );
846
- }, K = (o, t) => {
847
- o.fillStyle = t, o.fillRect(0, 0, o.canvas.width, o.canvas.height);
848
- }, Q = (o) => (t) => {
849
- K(t, o);
850
- }, I = (o) => {
851
- switch (o == null ? void 0 : o.type) {
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) => {
958
+ switch (r == null ? void 0 : r.type) {
852
959
  case "custom":
853
- return o.drawingFn;
960
+ return r.drawingFn;
854
961
  case "dots":
855
- return J(
856
- o.dotColor ?? "#d8d8d8",
857
- o.dotGap ?? 25,
858
- o.dotRadius ?? 1.5,
859
- o.color ?? "#ffffff"
962
+ return et(
963
+ r.dotColor ?? "#d8d8d8",
964
+ r.dotGap ?? 25,
965
+ r.dotRadius ?? 1.5,
966
+ r.color ?? "#ffffff"
860
967
  );
861
968
  case "color":
862
- return Q(o.color ?? "#ffffff");
969
+ return rt(r.color ?? "#ffffff");
863
970
  default:
864
- return _();
971
+ return I();
865
972
  }
866
- }, O = (o) => {
867
- switch (o == null ? void 0 : o.type) {
973
+ }, F = (r) => {
974
+ switch (r == null ? void 0 : r.type) {
868
975
  case "custom":
869
- return o.controllerFactory;
976
+ return r.controllerFactory;
870
977
  case "straight":
871
- return Z({
872
- color: o.color ?? "#5c5c5c",
873
- width: o.width ?? 1,
874
- arrowLength: o.arrowLength ?? 15,
875
- arrowWidth: o.arrowWidth ?? 4,
876
- minPortOffset: o.minPortOffset ?? 15,
877
- hasSourceArrow: o.hasSourceArrow ?? !1,
878
- hasTargetArrow: o.hasTargetArrow ?? !1,
879
- cycleSquareSide: o.cycleSquareSide ?? 30,
880
- roundness: o.roundness ?? 5
978
+ return J({
979
+ color: r.color ?? "#5c5c5c",
980
+ width: r.width ?? 1,
981
+ arrowLength: r.arrowLength ?? 15,
982
+ arrowWidth: r.arrowWidth ?? 4,
983
+ arrowOffset: r.arrowOffset ?? 15,
984
+ hasSourceArrow: r.hasSourceArrow ?? !1,
985
+ hasTargetArrow: r.hasTargetArrow ?? !1,
986
+ cycleSquareSide: r.cycleSquareSide ?? 30,
987
+ roundness: r.roundness ?? 10,
988
+ detourDistance: r.detourDistance ?? 100,
989
+ detourDirection: r.detourDirection ?? -Math.PI / 2
881
990
  });
882
991
  default:
883
- return X({
884
- color: o.color ?? "#5c5c5c",
885
- width: o.width ?? 1,
886
- curvature: o.curvature ?? 90,
887
- arrowLength: o.arrowLength ?? 15,
888
- arrowWidth: o.arrowWidth ?? 4,
889
- hasSourceArrow: o.hasSourceArrow ?? !1,
890
- hasTargetArrow: o.hasTargetArrow ?? !1,
891
- cycleRadius: o.cycleRadius ?? 30,
892
- smallCycleRadius: o.smallCycleRadius ?? 15
992
+ return _({
993
+ color: r.color ?? "#5c5c5c",
994
+ width: r.width ?? 1,
995
+ curvature: r.curvature ?? 90,
996
+ arrowLength: r.arrowLength ?? 15,
997
+ arrowWidth: r.arrowWidth ?? 4,
998
+ hasSourceArrow: r.hasSourceArrow ?? !1,
999
+ hasTargetArrow: r.hasTargetArrow ?? !1,
1000
+ cycleRadius: r.cycleRadius ?? 30,
1001
+ smallCycleRadius: r.smallCycleRadius ?? 15,
1002
+ detourDistance: r.detourDistance ?? 100,
1003
+ detourDirection: r.detourDirection ?? -Math.PI / 2
893
1004
  });
894
1005
  }
895
- }, tt = (o) => {
896
- var t, e, s;
1006
+ }, nt = (r) => {
1007
+ var t, e, s, o;
897
1008
  return {
898
1009
  background: {
899
- drawingFn: I(
900
- o.background ?? { type: "none" }
1010
+ drawingFn: ot(
1011
+ r.background ?? { type: "none" }
901
1012
  )
902
1013
  },
903
1014
  nodes: {
904
- centerFn: ((t = o.nodes) == null ? void 0 : t.centerFn) ?? M
1015
+ centerFn: ((t = r.nodes) == null ? void 0 : t.centerFn) ?? D
905
1016
  },
906
1017
  ports: {
907
- centerFn: ((e = o.ports) == null ? void 0 : e.centerFn) ?? M
1018
+ centerFn: ((e = r.ports) == null ? void 0 : e.centerFn) ?? D,
1019
+ direction: ((s = r.ports) == null ? void 0 : s.direction) ?? 0
908
1020
  },
909
1021
  edges: {
910
- controllerFactory: O(o.edges ?? {})
1022
+ controllerFactory: F(r.edges ?? {})
911
1023
  },
912
1024
  layers: {
913
- mode: ((s = o.layers) == null ? void 0 : s.mode) ?? "edges-follow-node"
1025
+ mode: ((o = r.layers) == null ? void 0 : o.mode) ?? "edges-follow-node"
914
1026
  }
915
1027
  };
916
1028
  };
917
- class et {
1029
+ class it {
918
1030
  constructor(t) {
919
1031
  n(this, "transformation");
920
1032
  n(this, "di");
921
- n(this, "connectionControllerFactory");
1033
+ n(this, "edgeControllerFactory");
922
1034
  this.apiOptions = t;
923
- const e = tt(this.apiOptions ?? {});
924
- this.di = new H(
1035
+ const e = nt(this.apiOptions ?? {});
1036
+ this.di = new Q(
925
1037
  e.layers.mode,
926
1038
  e.background.drawingFn,
927
1039
  e.nodes.centerFn,
928
- e.ports.centerFn
929
- ), this.transformation = this.di.publicViewportTransformer, this.connectionControllerFactory = e.edges.controllerFactory;
1040
+ e.ports.centerFn,
1041
+ e.ports.direction
1042
+ ), this.transformation = this.di.publicViewportTransformer, this.edgeControllerFactory = e.edges.controllerFactory;
930
1043
  }
931
1044
  addNode(t) {
932
1045
  return this.di.canvasController.addNode(
@@ -954,14 +1067,14 @@ class et {
954
1067
  ), this;
955
1068
  }
956
1069
  updatePortEdges(t) {
957
- return this.di.canvasController.updatePortConnections(t), this;
1070
+ return this.di.canvasController.updatePortEdges(t), this;
958
1071
  }
959
1072
  unmarkPort(t) {
960
1073
  return this.di.canvasController.unmarkPort(t), this;
961
1074
  }
962
1075
  addEdge(t) {
963
- const e = t.options !== void 0 ? O(t.options) : this.connectionControllerFactory;
964
- return this.di.canvasController.addConnection(
1076
+ const e = t.options !== void 0 ? F(t.options) : this.edgeControllerFactory;
1077
+ return this.di.canvasController.addEdge(
965
1078
  t.id,
966
1079
  t.from,
967
1080
  t.to,
@@ -969,7 +1082,7 @@ class et {
969
1082
  ), this;
970
1083
  }
971
1084
  removeEdge(t) {
972
- return this.di.canvasController.removeConnection(t), this;
1085
+ return this.di.canvasController.removeEdge(t), this;
973
1086
  }
974
1087
  patchViewportState(t) {
975
1088
  return this.di.canvasController.patchViewportState(
@@ -984,11 +1097,8 @@ class et {
984
1097
  updateNodeCoordinates(t, e, s) {
985
1098
  return this.di.canvasController.updateNodeCoordinates(t, e, s), this;
986
1099
  }
987
- updateConnection(t, e) {
988
- return e.controller !== void 0 && this.di.canvasController.updateConnectionController(
989
- t,
990
- e.controller
991
- ), this;
1100
+ updateEdge(t, e) {
1101
+ return e.controller !== void 0 && this.di.canvasController.updateEdgeController(t, e.controller), this;
992
1102
  }
993
1103
  clear() {
994
1104
  return this.di.canvasController.clear(), this;
@@ -1003,14 +1113,14 @@ class et {
1003
1113
  this.di.canvasController.destroy();
1004
1114
  }
1005
1115
  }
1006
- class st {
1116
+ class ht {
1007
1117
  constructor(t, e) {
1008
1118
  n(this, "transformation");
1009
1119
  n(this, "nodes", /* @__PURE__ */ new Map());
1010
1120
  n(this, "grabbedNodeId", null);
1011
1121
  n(this, "onNodeDrag");
1012
1122
  n(this, "onBeforeNodeDrag");
1013
- n(this, "nodeIdGenerator", new S());
1123
+ n(this, "nodeIdGenerator", new L());
1014
1124
  n(this, "element", null);
1015
1125
  n(this, "onCanvasMouseUp", () => {
1016
1126
  this.setCursor(null), this.grabbedNodeId = null;
@@ -1044,13 +1154,13 @@ class st {
1044
1154
  ] : (this.previousTouchCoords = null, this.grabbedNodeId = null);
1045
1155
  });
1046
1156
  n(this, "previousTouchCoords", null);
1047
- var a, c;
1157
+ var i, h;
1048
1158
  this.canvas = t, this.transformation = this.canvas.transformation;
1049
1159
  const s = () => {
1050
1160
  };
1051
- this.onNodeDrag = ((a = e == null ? void 0 : e.events) == null ? void 0 : a.onNodeDrag) ?? s;
1052
- const r = () => !0;
1053
- this.onBeforeNodeDrag = ((c = e == null ? void 0 : e.events) == null ? void 0 : c.onBeforeNodeDrag) ?? r;
1161
+ this.onNodeDrag = ((i = e == null ? void 0 : e.events) == null ? void 0 : i.onNodeDrag) ?? s;
1162
+ const o = () => !0;
1163
+ this.onBeforeNodeDrag = ((h = e == null ? void 0 : e.events) == null ? void 0 : h.onBeforeNodeDrag) ?? o;
1054
1164
  }
1055
1165
  addNode(t) {
1056
1166
  let e = t.id;
@@ -1059,28 +1169,28 @@ class st {
1059
1169
  e = this.nodeIdGenerator.next();
1060
1170
  while (this.nodes.has(e));
1061
1171
  this.canvas.addNode(t);
1062
- const s = (a) => {
1172
+ const s = (i) => {
1063
1173
  this.onBeforeNodeDrag({
1064
1174
  nodeId: e,
1065
1175
  element: t.element,
1066
1176
  x: t.x,
1067
1177
  y: t.y
1068
- }) && (a.stopImmediatePropagation(), this.grabbedNodeId = e, this.setCursor("grab"), this.canvas.moveNodeOnTop(e));
1069
- }, r = (a) => {
1178
+ }) && (i.stopImmediatePropagation(), this.grabbedNodeId = e, this.setCursor("grab"), this.canvas.moveNodeOnTop(e));
1179
+ }, o = (i) => {
1070
1180
  this.onBeforeNodeDrag({
1071
1181
  nodeId: e,
1072
1182
  element: t.element,
1073
1183
  x: t.x,
1074
1184
  y: t.y
1075
- }) && a.touches.length === 1 && (this.grabbedNodeId = e, this.canvas.moveNodeOnTop(e));
1185
+ }) && i.touches.length === 1 && (this.grabbedNodeId = e, this.canvas.moveNodeOnTop(e));
1076
1186
  };
1077
1187
  return this.nodes.set(e, {
1078
1188
  element: t.element,
1079
1189
  onMouseDown: s,
1080
- onTouchStart: r,
1190
+ onTouchStart: o,
1081
1191
  x: t.x,
1082
1192
  y: t.y
1083
- }), t.element.addEventListener("mousedown", s), t.element.addEventListener("touchstart", r), this;
1193
+ }), t.element.addEventListener("mousedown", s), t.element.addEventListener("touchstart", o), this;
1084
1194
  }
1085
1195
  removeNode(t) {
1086
1196
  const e = this.nodes.get(t);
@@ -1110,8 +1220,8 @@ class st {
1110
1220
  updateNodeCoordinates(t, e, s) {
1111
1221
  return this.canvas.updateNodeCoordinates(t, e, s), this;
1112
1222
  }
1113
- updateConnection(t, e) {
1114
- return this.canvas.updateConnection(t, e), this;
1223
+ updateEdge(t, e) {
1224
+ return this.canvas.updateEdge(t, e), this;
1115
1225
  }
1116
1226
  moveNodeOnTop(t) {
1117
1227
  return this.canvas.moveNodeOnTop(t), this;
@@ -1136,19 +1246,19 @@ class st {
1136
1246
  this.element !== null && (t !== null ? this.element.style.cursor = t : this.element.style.removeProperty("cursor"));
1137
1247
  }
1138
1248
  dragNode(t, e, s) {
1139
- const r = this.nodes.get(t);
1140
- if (r === void 0)
1249
+ const o = this.nodes.get(t);
1250
+ if (o === void 0)
1141
1251
  throw new Error("failed to drag nonexisting node");
1142
- const [a, c] = this.transformation.getViewCoords(r.x, r.y), h = a + e, i = c + s, [d, g] = this.transformation.getAbsCoords(h, i);
1143
- r.x = d, r.y = g, this.canvas.updateNodeCoordinates(t, d, g), this.onNodeDrag({
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({
1144
1254
  nodeId: t,
1145
- element: r.element,
1146
- x: r.x,
1147
- y: r.y
1255
+ element: o.element,
1256
+ x: o.x,
1257
+ y: o.y
1148
1258
  });
1149
1259
  }
1150
1260
  }
1151
- class ot {
1261
+ class at {
1152
1262
  constructor(t, e) {
1153
1263
  n(this, "transformation");
1154
1264
  n(this, "element", null);
@@ -1177,8 +1287,8 @@ class ot {
1177
1287
  if (this.element === null || this.isScalable === !1)
1178
1288
  return;
1179
1289
  t.preventDefault();
1180
- const { left: e, top: s } = this.element.getBoundingClientRect(), r = t.clientX - e, a = t.clientY - s, h = 1 / (t.deltaY < 0 ? this.wheelSensitivity : 1 / this.wheelSensitivity);
1181
- this.scaleViewport(h, r, a);
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);
1182
1292
  });
1183
1293
  n(this, "onTouchStart", (t) => {
1184
1294
  this.prevTouches = this.getAverageTouch(t);
@@ -1191,25 +1301,25 @@ class ot {
1191
1301
  -(e.x - this.prevTouches.x),
1192
1302
  -(e.y - this.prevTouches.y)
1193
1303
  ), e.touchesCnt === 2 && this.isScalable) {
1194
- const { left: s, top: r } = this.element.getBoundingClientRect(), a = this.prevTouches.x - s, c = this.prevTouches.y - r, i = 1 / (e.scale / this.prevTouches.scale);
1195
- this.scaleViewport(i, a, c);
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);
1196
1306
  }
1197
1307
  this.prevTouches = e, t.preventDefault();
1198
1308
  });
1199
1309
  n(this, "onTouchEnd", (t) => {
1200
1310
  t.touches.length > 0 ? this.prevTouches = this.getAverageTouch(t) : this.prevTouches = null;
1201
1311
  });
1202
- var i, d, g, l, u, w, m, p, C, f, y, b;
1312
+ var c, l, d, u, g, w, m, f, p, C, v, E;
1203
1313
  this.canvas = t, this.options = e, this.transformation = this.canvas.transformation;
1204
- const s = ((d = (i = this.options) == null ? void 0 : i.scale) == null ? void 0 : d.min) ?? null, r = ((l = (g = this.options) == null ? void 0 : g.scale) == null ? void 0 : l.max) ?? null;
1205
- this.isScalable = ((w = (u = this.options) == null ? void 0 : u.scale) == null ? void 0 : w.enabled) !== !1, this.minViewScale = r !== null ? 1 / r : null, this.maxViewScale = s !== null ? 1 / s : null, this.isShiftable = ((p = (m = this.options) == null ? void 0 : m.shift) == null ? void 0 : p.enabled) !== !1;
1206
- const a = (f = (C = this.options) == null ? void 0 : C.scale) == null ? void 0 : f.wheelSensitivity;
1207
- this.wheelSensitivity = a !== void 0 ? a : 1.2;
1208
- const c = () => {
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 = () => {
1209
1319
  };
1210
- this.onTransform = ((y = e == null ? void 0 : e.events) == null ? void 0 : y.onTransform) ?? c;
1211
- const h = () => !0;
1212
- this.onBeforeTransform = ((b = e == null ? void 0 : e.events) == null ? void 0 : b.onBeforeTransform) ?? h;
1320
+ this.onTransform = ((v = e == null ? void 0 : e.events) == null ? void 0 : v.onTransform) ?? h;
1321
+ const a = () => !0;
1322
+ this.onBeforeTransform = ((E = e == null ? void 0 : e.events) == null ? void 0 : E.onBeforeTransform) ?? a;
1213
1323
  }
1214
1324
  addNode(t) {
1215
1325
  return this.canvas.addNode(t), this;
@@ -1241,8 +1351,8 @@ class ot {
1241
1351
  updateNodeCoordinates(t, e, s) {
1242
1352
  return this.canvas.updateNodeCoordinates(t, e, s), this;
1243
1353
  }
1244
- updateConnection(t, e) {
1245
- return this.canvas.updateConnection(t, e), this;
1354
+ updateEdge(t, e) {
1355
+ return this.canvas.updateEdge(t, e), this;
1246
1356
  }
1247
1357
  moveNodeOnTop(t) {
1248
1358
  return this.canvas.moveNodeOnTop(t), this;
@@ -1261,37 +1371,37 @@ class ot {
1261
1371
  }
1262
1372
  getAverageTouch(t) {
1263
1373
  const e = [], s = t.touches.length;
1264
- for (let i = 0; i < s; i++)
1265
- e.push([t.touches[i].clientX, t.touches[i].clientY]);
1266
- const r = e.reduce(
1267
- (i, d) => [i[0] + d[0], i[1] + d[1]],
1374
+ for (let c = 0; c < s; c++)
1375
+ e.push([t.touches[c].clientX, t.touches[c].clientY]);
1376
+ const o = e.reduce(
1377
+ (c, l) => [c[0] + l[0], c[1] + l[1]],
1268
1378
  [0, 0]
1269
- ), a = [r[0] / s, r[1] / s], h = e.map((i) => [i[0] - a[0], i[1] - a[1]]).reduce(
1270
- (i, d) => i + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
1379
+ ), i = [o[0] / s, o[1] / s], a = e.map((c) => [c[0] - i[0], c[1] - i[1]]).reduce(
1380
+ (c, l) => c + Math.sqrt(l[0] * l[0] + l[1] * l[1]),
1271
1381
  0
1272
1382
  );
1273
- return { x: a[0], y: a[1], scale: h / s, touchesCnt: s };
1383
+ return { x: i[0], y: i[1], scale: a / s, touchesCnt: s };
1274
1384
  }
1275
1385
  setCursor(t) {
1276
1386
  this.element !== null && (t !== null ? this.element.style.cursor = t : this.element.style.removeProperty("cursor"));
1277
1387
  }
1278
1388
  moveViewport(t, e) {
1279
- const [s, r] = this.transformation.getAbsCoords(0, 0), a = this.canvas.transformation.getAbsScale(), c = {
1280
- scale: a,
1281
- x: s + a * t,
1282
- y: r + a * 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
1283
1393
  };
1284
- this.onBeforeTransform({ ...c }) && (this.canvas.patchViewportState(c), this.onTransform(c));
1394
+ this.onBeforeTransform({ ...h }) && (this.canvas.patchViewportState(h), this.onTransform(h));
1285
1395
  }
1286
1396
  scaleViewport(t, e, s) {
1287
- const [r, a] = this.canvas.transformation.getAbsCoords(0, 0), c = this.canvas.transformation.getAbsScale(), h = c * t, i = c * (1 - t) * e + r, d = c * (1 - t) * s + a;
1288
- if (this.maxViewScale !== null && h > this.maxViewScale && h > c || this.minViewScale !== null && h < this.minViewScale && h < c)
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)
1289
1399
  return;
1290
- const g = { scale: h, x: i, y: d };
1291
- this.onBeforeTransform({ ...g }) && (this.canvas.patchViewportState(g), this.onTransform(g));
1400
+ const d = { scale: a, x: c, y: l };
1401
+ this.onBeforeTransform({ ...d }) && (this.canvas.patchViewportState(d), this.onTransform(d));
1292
1402
  }
1293
1403
  }
1294
- class nt {
1404
+ class lt {
1295
1405
  constructor() {
1296
1406
  n(this, "coreOptions");
1297
1407
  n(this, "dragOptions");
@@ -1309,21 +1419,21 @@ class nt {
1309
1419
  return this.isTransformable = !0, this.transformOptions = t, this;
1310
1420
  }
1311
1421
  build() {
1312
- let t = new et(this.coreOptions);
1313
- return this.isDraggable && (t = new st(t, this.dragOptions)), this.isTransformable && (t = new ot(t, this.transformOptions)), t;
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;
1314
1424
  }
1315
1425
  }
1316
1426
  export {
1317
- B as BezierEdgeController,
1318
- et as CanvasCore,
1319
- Y as CycleCircleEdgeController,
1320
- G as CycleSquareEdgeController,
1427
+ z as BezierEdgeController,
1428
+ it as CanvasCore,
1429
+ Z as CycleCircleEdgeController,
1430
+ U as CycleSquareEdgeController,
1431
+ H as DetourStraightEdgeController,
1321
1432
  T as EdgeType,
1322
- v as EdgeUtils,
1323
- nt as HtmlGraphBuilder,
1324
- z as StraightEdgeController,
1325
- st as UserDraggableNodesCanvas,
1326
- ot as UserTransformableCanvas,
1327
- X as createBezierEdgeControllerFactory,
1328
- Z as createStraightEdgeControllerFactory
1433
+ lt as HtmlGraphBuilder,
1434
+ G as StraightEdgeController,
1435
+ ht as UserDraggableNodesCanvas,
1436
+ at as UserTransformableCanvas,
1437
+ _ as createBezierEdgeControllerFactory,
1438
+ J as createStraightEdgeControllerFactory
1329
1439
  };