@floegence/floe-webapp-core 0.86.12 → 0.86.14

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.
@@ -1,277 +1,280 @@
1
- import { AvoidLib as J } from "../../node_modules/.pnpm/libavoid-js@0.5.0-beta.5/node_modules/libavoid-js/dist/index.js";
2
- import Y from "../../node_modules/.pnpm/libavoid-js@0.5.0-beta.5/node_modules/libavoid-js/dist/libavoid.wasm.js";
3
- let j;
4
- const V = { NORTH: 1, SOUTH: 2, WEST: 4, EAST: 8 }, b = ["NORTH", "EAST", "SOUTH", "WEST"], E = (t) => t.delete();
5
- async function I(t, c = {}) {
6
- const p = c.edgeClearance ?? 4;
7
- if (!Number.isFinite(p) || p < 0)
1
+ import { AvoidLib as X } from "../../node_modules/.pnpm/libavoid-js@0.5.0-beta.5/node_modules/libavoid-js/dist/index.js";
2
+ import I from "../../node_modules/.pnpm/libavoid-js@0.5.0-beta.5/node_modules/libavoid-js/dist/libavoid.wasm.js";
3
+ let Y;
4
+ const _ = { NORTH: 1, SOUTH: 2, WEST: 4, EAST: 8 }, v = ["NORTH", "EAST", "SOUTH", "WEST"], T = (i) => i.delete();
5
+ async function st(i, o = {}) {
6
+ const a = o.edgeClearance ?? 4;
7
+ if (!Number.isFinite(a) || a < 0)
8
8
  throw new Error("Graph edge clearance must be finite and nonnegative");
9
- if (!t.nodes.length) return t;
10
- if (!t.edges.length) return X(t);
11
- await (j ??= J.load(Y).catch((o) => {
12
- throw j = void 0, o;
9
+ if (!i.nodes.length) return i;
10
+ if (!i.edges.length) return L(i);
11
+ await (Y ??= X.load(I).catch((r) => {
12
+ throw Y = void 0, r;
13
13
  }));
14
- const s = J.getInstance(), r = new Map(t.nodes.map((o) => [o.id, o])), m = (o) => {
15
- const e = [];
16
- for (let i = r.get(o).parentId; i; i = r.get(i).parentId)
17
- e.push(i);
18
- return e;
19
- }, d = /* @__PURE__ */ new Map();
20
- for (const o of t.edges) {
21
- const e = /* @__PURE__ */ new Set([...m(o.source), ...m(o.target)]), i = JSON.stringify([...e].sort()), u = d.get(i) ?? { open: e, edges: [] };
22
- u.edges.push(o), d.set(i, u);
14
+ const n = X.getInstance(), c = new Map(i.nodes.map((r) => [r.id, r])), l = (r) => {
15
+ const h = [];
16
+ for (let s = c.get(r).parentId; s; s = c.get(s).parentId)
17
+ h.push(s);
18
+ return h;
19
+ }, f = /* @__PURE__ */ new Map();
20
+ for (const r of i.edges) {
21
+ const h = /* @__PURE__ */ new Set([...l(r.source), ...l(r.target)]), s = JSON.stringify([...h].sort()), M = f.get(s) ?? { open: h, edges: [] };
22
+ M.edges.push(r), f.set(s, M);
23
23
  }
24
- const S = /* @__PURE__ */ new Map();
25
- for (const { open: o, edges: e } of d.values()) {
26
- const i = new s.Router(2);
24
+ const P = /* @__PURE__ */ new Map();
25
+ for (const { open: r, edges: h } of f.values()) {
26
+ const s = new n.Router(2);
27
27
  try {
28
- i.setRoutingParameter(s.RoutingParameter.shapeBufferDistance, p), i.setRoutingParameter(s.RoutingParameter.idealNudgingDistance, 8), i.setRoutingParameter(s.RoutingParameter.crossingPenalty, 80), i.setRoutingParameter(s.RoutingParameter.fixedSharedPathPenalty, 120), i.setRoutingParameter(s.RoutingParameter.portDirectionPenalty, 0), i.setRoutingOption(s.RoutingOption.nudgeOrthogonalSegmentsConnectedToShapes, !1), i.setRoutingOption(s.RoutingOption.nudgeSharedPathsWithCommonEndPoint, !0);
29
- const u = new Map(
30
- t.nodes.filter((n) => !o.has(n.id) && m(n.id).every((x) => o.has(x))).map((n) => {
31
- const x = new s.Point(n.x, n.y), y = new s.Point(n.x + n.width, n.y + n.height), a = new s.Rectangle(x, y), h = new s.ShapeRef(i, a);
32
- return E(x), E(y), E(a), [n.id, h];
28
+ s.setRoutingParameter(n.RoutingParameter.shapeBufferDistance, a), s.setRoutingParameter(n.RoutingParameter.idealNudgingDistance, 8), s.setRoutingParameter(n.RoutingParameter.crossingPenalty, 80), s.setRoutingParameter(n.RoutingParameter.fixedSharedPathPenalty, 120), s.setRoutingParameter(n.RoutingParameter.portDirectionPenalty, 0), s.setRoutingOption(
29
+ n.RoutingOption.nudgeOrthogonalSegmentsConnectedToShapes,
30
+ !h.some((t) => t.sourcePort || t.targetPort || t.source === t.target)
31
+ ), s.setRoutingOption(n.RoutingOption.nudgeSharedPathsWithCommonEndPoint, !0);
32
+ const M = new Map(
33
+ i.nodes.filter((t) => !r.has(t.id) && l(t.id).every((e) => r.has(e))).map((t) => {
34
+ const e = new n.Point(t.x, t.y), g = new n.Point(t.x + t.width, t.y + t.height), p = new n.Rectangle(e, g), x = new n.ShapeRef(s, p);
35
+ return T(e), T(g), T(p), [t.id, x];
33
36
  })
34
- ), v = /* @__PURE__ */ new Map(), l = t.nodes.filter((n) => u.has(n.id)), G = /* @__PURE__ */ new Map();
35
- e.forEach((n) => {
36
- const x = r.get(n.source), y = r.get(n.target), a = z(x, y), h = n.sourcePort ? x.ports.find((T) => T.id === n.sourcePort).side : n.targetPort ? D(y.ports.find((T) => T.id === n.targetPort).side) : a.source, g = n.targetPort ? y.ports.find((T) => T.id === n.targetPort).side : n.sourcePort ? D(x.ports.find((T) => T.id === n.sourcePort).side) : a.target, f = [n.source, n.target].sort().join("\0"), w = G.get(f) ?? 0;
37
- G.set(f, w + 1);
38
- const M = w % 2 === 0 ? -6 : 6, R = n.source === n.target ? void 0 : _(
39
- x,
40
- y,
41
- l,
42
- a,
43
- M,
44
- n.sourcePort ? h : void 0,
45
- n.targetPort ? g : void 0
46
- );
47
- v.set(n.id, {
48
- sourceSide: R?.source ?? h,
49
- targetSide: R?.target ?? g,
50
- offset: M
51
- });
52
- });
53
- let U = b.length + 2;
54
- const O = /* @__PURE__ */ new Map(), P = (n, x) => Math.max(0, Math.min(1, n / x));
55
- for (const n of t.nodes) {
56
- const x = u.get(n.id);
57
- if (!x) continue;
58
- const y = (a, h, g, f, w) => {
59
- const M = new s.ShapeConnectionPin(
60
- x,
61
- a,
62
- P(h, n.width),
63
- P(g, n.height),
37
+ ), O = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map();
38
+ for (const t of h) {
39
+ const e = [t.source, t.target].sort().join("\0"), g = O.get(e) ?? 0;
40
+ O.set(e, g + 1), C.set(t.id, g % 2 === 0 ? -6 : 6);
41
+ }
42
+ let K = v.length + 2;
43
+ const W = /* @__PURE__ */ new Map(), b = (t, e) => Math.max(0, Math.min(1, t / e));
44
+ for (const t of i.nodes) {
45
+ const e = M.get(t.id);
46
+ if (!e) continue;
47
+ const g = (p, x, w, y, u) => {
48
+ const N = new n.ShapeConnectionPin(
49
+ e,
50
+ p,
51
+ b(x, t.width),
52
+ b(w, t.height),
64
53
  !0,
65
54
  0,
66
- f
55
+ y
67
56
  );
68
- M.setExclusive(w), M.setConnectionCost(
69
- n.width / 2 + n.height / 2 - Math.abs(h - n.width / 2) - Math.abs(g - n.height / 2)
57
+ N.setExclusive(u), N.setConnectionCost(
58
+ t.width / 2 + t.height / 2 - Math.abs(x - t.width / 2) - Math.abs(w - t.height / 2)
70
59
  );
71
60
  };
72
- for (const a of new Set(n.ports?.map((h) => h.side))) {
73
- const { x: h, y: g } = W(n, a), f = b.indexOf(a) + 2;
74
- y(f, h - n.x, g - n.y, V[a], !1), O.set(
61
+ for (const p of new Set(t.ports?.map((x) => x.side))) {
62
+ const { x, y: w } = $(t, p), y = v.indexOf(p) + 2;
63
+ g(y, x - t.x, w - t.y, _[p], !1), W.set(
75
64
  JSON.stringify([
76
- n.id,
77
- P(h - n.x, n.width),
78
- P(g - n.y, n.height),
79
- a
65
+ t.id,
66
+ b(x - t.x, t.width),
67
+ b(w - t.y, t.height),
68
+ p
80
69
  ]),
81
- f
70
+ y
82
71
  );
83
72
  }
84
73
  }
85
- const C = (n, x, y, a) => {
86
- const h = r.get(n), g = u.get(n);
87
- if (g && x)
88
- return new s.ConnEnd(
89
- g,
90
- b.indexOf(h.ports.find((R) => R.id === x).side) + 2
74
+ const Q = i.nodes.filter((t) => M.has(t.id)), F = (t, e, g, p, x, w = !1) => {
75
+ const y = M.get(t.id);
76
+ if (y && g)
77
+ return new n.ConnEnd(
78
+ y,
79
+ v.indexOf(t.ports.find((d) => d.id === g).side) + 2
91
80
  );
92
- if (g) {
93
- const R = P(y.x - h.x, h.width), T = P(y.y - h.y, h.height), A = JSON.stringify([n, R, T, a]), F = O.get(A);
94
- if (F !== void 0) return new s.ConnEnd(g, F);
95
- const B = U++;
96
- return O.set(A, B), new s.ShapeConnectionPin(
97
- g,
81
+ const u = g ? [
82
+ {
83
+ side: t.ports.find((d) => d.id === g).side,
84
+ position: $(t, t.ports.find((d) => d.id === g).side)
85
+ }
86
+ ] : x ? [{ side: "EAST", position: x }] : (w ? [q(t, e).source] : v).flatMap((d) => {
87
+ const H = tt(t, d, e, p);
88
+ if (w) return [{ side: d, position: H }];
89
+ const R = d === "NORTH" || d === "SOUTH", A = R ? t.x : t.y, S = R ? t.width : t.height, E = A + Math.min(8, S / 4), B = A + S - Math.min(8, S / 4);
90
+ return [
91
+ R ? H.x : H.y,
92
+ E,
98
93
  B,
99
- R,
100
- T,
101
- !0,
102
- 0,
103
- V[a]
104
- ).setExclusive(!1), new s.ConnEnd(g, B);
94
+ ...Q.flatMap((m) => {
95
+ const k = R ? m.x : m.y, V = k + (R ? m.width : m.height);
96
+ return [k - a, V + a, k - a - 8, V + a + 8];
97
+ }).filter((m) => m >= E && m <= B)
98
+ ].map((m) => ({
99
+ side: d,
100
+ position: R ? { x: m, y: H.y } : { x: H.x, y: m }
101
+ }));
102
+ });
103
+ if (y) {
104
+ const d = (S, E) => JSON.stringify([
105
+ t.id,
106
+ b(E.x - t.x, t.width),
107
+ b(E.y - t.y, t.height),
108
+ S
109
+ ]), R = !!(g || x || w) || u.every(
110
+ (S) => W.has(d(S.side, S.position))
111
+ ) ? W.get(d(u[0].side, u[0].position)) : void 0;
112
+ if (R !== void 0) return new n.ConnEnd(y, R);
113
+ const A = R ?? K++;
114
+ for (const { side: S, position: E } of u) {
115
+ const B = d(S, E);
116
+ if (W.has(B)) continue;
117
+ W.set(B, A);
118
+ const D = E.x - t.x, m = E.y - t.y, k = new n.ShapeConnectionPin(
119
+ y,
120
+ A,
121
+ b(D, t.width),
122
+ b(m, t.height),
123
+ !0,
124
+ 0,
125
+ _[S]
126
+ );
127
+ k.setExclusive(!1), k.setConnectionCost(
128
+ t.width / 2 + t.height / 2 - Math.abs(D - t.width / 2) - Math.abs(m - t.height / 2)
129
+ );
130
+ }
131
+ return new n.ConnEnd(y, A);
105
132
  }
106
- const f = x ? W(h, h.ports.find((R) => R.id === x).side) : y, w = new s.Point(f.x, f.y), M = new s.ConnEnd(w);
107
- return E(w), M;
108
- }, N = e.map((n) => {
109
- const x = r.get(n.source), y = r.get(n.target), a = v.get(n.id), h = C(
110
- n.source,
111
- n.sourcePort,
112
- n.source === n.target ? { x: x.x + x.width, y: x.y + x.height / 3 } : k(x, a.sourceSide, y, a.offset),
113
- n.source === n.target ? "EAST" : a.sourceSide
114
- ), g = C(
115
- n.target,
116
- n.targetPort,
117
- n.source === n.target ? {
118
- x: y.x + y.width,
119
- y: y.y + y.height * 2 / 3
120
- } : k(y, a.targetSide, x, a.offset),
121
- n.source === n.target ? "EAST" : a.targetSide
122
- ), f = new s.ConnRef(i, h, g);
123
- if (E(h), E(g), n.source === n.target) {
124
- const w = r.get(n.source), M = new s.CheckpointVector();
125
- for (const R of [w.y + w.height / 3, w.y + w.height * 2 / 3]) {
126
- const T = new s.Point(w.x + w.width + Math.max(24, p + 4), R), A = new s.Checkpoint(T);
127
- M.push_back(A), E(T), E(A);
133
+ const N = q(t, e).source, G = u.find((d) => d.side === N)?.position ?? u[0].position, j = new n.Point(G.x, G.y), z = new n.ConnEnd(j);
134
+ return T(j), z;
135
+ }, J = (t) => +!!(t.sourcePort || t.targetPort || t.source === t.target || O.get([t.source, t.target].sort().join("\0")) > 1), Z = [...h].sort((t, e) => J(e) - J(t)).map((t) => {
136
+ const e = c.get(t.source), g = c.get(t.target), p = t.source === t.target, x = O.get([t.source, t.target].sort().join("\0")) > 1, w = F(
137
+ e,
138
+ g,
139
+ t.sourcePort,
140
+ C.get(t.id),
141
+ p ? { x: e.x + e.width, y: e.y + e.height / 3 } : void 0,
142
+ x
143
+ ), y = F(
144
+ g,
145
+ e,
146
+ t.targetPort,
147
+ C.get(t.id),
148
+ p ? {
149
+ x: g.x + g.width,
150
+ y: g.y + g.height * 2 / 3
151
+ } : void 0,
152
+ x
153
+ ), u = new n.ConnRef(s, w, y);
154
+ if (T(w), T(y), p) {
155
+ const N = new n.CheckpointVector();
156
+ for (const G of [
157
+ e.y + e.height / 3,
158
+ e.y + e.height * 2 / 3
159
+ ]) {
160
+ const j = new n.Point(
161
+ e.x + e.width + Math.max(24, a + 4),
162
+ G
163
+ ), z = new n.Checkpoint(j);
164
+ N.push_back(z), T(j), T(z);
128
165
  }
129
- f.setRoutingCheckpoints(M), E(M);
166
+ u.setRoutingCheckpoints(N), T(N);
130
167
  }
131
- return { edge: n, connection: f };
168
+ return { edge: t, connection: u };
132
169
  });
133
- i.processTransaction();
134
- for (const { edge: n, connection: x } of N) {
135
- const y = x.displayRoute(), a = Array.from({ length: y.size() }, (h, g) => {
136
- const f = y.at(g), w = { x: f.x, y: f.y };
137
- return E(f), w;
170
+ s.processTransaction();
171
+ for (const { edge: t, connection: e } of Z) {
172
+ const g = e.displayRoute(), p = Array.from({ length: g.size() }, (x, w) => {
173
+ const y = g.at(w), u = { x: y.x, y: y.y };
174
+ return T(y), u;
138
175
  });
139
- if (E(y), !x.hasValidRoute() || a.length < 2 || a.some((h) => !Number.isFinite(h.x) || !Number.isFinite(h.y)) || a.some((h, g) => g > 0 && h.x !== a[g - 1].x && h.y !== a[g - 1].y))
140
- throw new Error(`Graph edge cannot be routed: ${n.id}`);
141
- S.set(n.id, a);
176
+ if (T(g), !e.hasValidRoute() || p.length < 2 || p.some((x) => !Number.isFinite(x.x) || !Number.isFinite(x.y)) || p.some((x, w) => w > 0 && x.x !== p[w - 1].x && x.y !== p[w - 1].y))
177
+ throw new Error(`Graph edge cannot be routed: ${t.id}`);
178
+ P.set(t.id, p);
142
179
  }
143
180
  } finally {
144
- i.delete();
181
+ s.delete();
145
182
  }
146
183
  }
147
- const H = t.edges.map((o) => ({ ...o, sections: [S.get(o.id)] }));
148
- return X({
149
- nodes: t.nodes,
150
- edges: H,
151
- bounds: t.bounds
184
+ const U = i.edges.map((r) => ({ ...r, sections: [P.get(r.id)] }));
185
+ return L({
186
+ nodes: i.nodes,
187
+ edges: U,
188
+ bounds: i.bounds
152
189
  });
153
190
  }
154
- function X(t) {
155
- const c = [
156
- ...t.nodes.flatMap((r) => [
157
- { x: r.x, y: r.y },
158
- { x: r.x + r.width, y: r.y + r.height }
191
+ function L(i) {
192
+ const o = [
193
+ ...i.nodes.flatMap((c) => [
194
+ { x: c.x, y: c.y },
195
+ { x: c.x + c.width, y: c.y + c.height }
159
196
  ]),
160
- ...t.edges.flatMap((r) => r.sections.flat())
161
- ], p = Math.min(...c.map((r) => r.x)), s = Math.min(...c.map((r) => r.y));
197
+ ...i.edges.flatMap((c) => c.sections.flat())
198
+ ], a = Math.min(...o.map((c) => c.x)), n = Math.min(...o.map((c) => c.y));
162
199
  return {
163
- nodes: t.nodes,
164
- edges: t.edges,
200
+ nodes: i.nodes,
201
+ edges: i.edges,
165
202
  bounds: {
166
- x: p,
167
- y: s,
168
- width: Math.max(...c.map((r) => r.x)) - p,
169
- height: Math.max(...c.map((r) => r.y)) - s
203
+ x: a,
204
+ y: n,
205
+ width: Math.max(...o.map((c) => c.x)) - a,
206
+ height: Math.max(...o.map((c) => c.y)) - n
170
207
  }
171
208
  };
172
209
  }
173
- function W(t, c) {
210
+ function $(i, o) {
174
211
  return {
175
- x: c === "WEST" ? t.x : c === "EAST" ? t.x + t.width : t.x + t.width / 2,
176
- y: c === "NORTH" ? t.y : c === "SOUTH" ? t.y + t.height : t.y + t.height / 2
212
+ x: o === "WEST" ? i.x : o === "EAST" ? i.x + i.width : i.x + i.width / 2,
213
+ y: o === "NORTH" ? i.y : o === "SOUTH" ? i.y + i.height : i.y + i.height / 2
177
214
  };
178
215
  }
179
- function D(t) {
180
- return {
181
- NORTH: "SOUTH",
182
- EAST: "WEST",
183
- SOUTH: "NORTH",
184
- WEST: "EAST"
185
- }[t];
186
- }
187
- function _(t, c, p, s, r, m, d) {
188
- let S;
189
- const H = (o, e, i) => i === "NORTH" ? e.x === o.x && e.y < o.y : i === "SOUTH" ? e.x === o.x && e.y > o.y : i === "WEST" ? e.y === o.y && e.x < o.x : e.y === o.y && e.x > o.x;
190
- for (const o of m ? [m] : b)
191
- for (const e of d ? [d] : b) {
192
- const i = m ? W(t, o) : k(t, o, c, r), u = d ? W(c, e) : k(c, e, t, r), v = i.x === u.x || i.y === u.y ? [[i, u]] : [
193
- [i, { x: u.x, y: i.y }, u],
194
- [i, { x: i.x, y: u.y }, u]
195
- ];
196
- for (const l of v) {
197
- if (p.includes(t) && !H(i, l[1], o) || p.includes(c) && !H(u, l.at(-2), e) || l.slice(1).some((O, P) => {
198
- const C = l[P];
199
- return p.some(
200
- (N) => Math.max(C.x, O.x) > N.x && Math.min(C.x, O.x) < N.x + N.width && Math.max(C.y, O.y) > N.y && Math.min(C.y, O.y) < N.y + N.height
201
- );
202
- }))
203
- continue;
204
- const U = l.slice(1).reduce(
205
- (O, P, C) => O + Math.abs(P.x - l[C].x) + Math.abs(P.y - l[C].y),
206
- 0
207
- ) + (l.length - 2) * 32 + (o === s.source ? 0 : 16) + (e === s.target ? 0 : 16);
208
- (!S || U < S.score) && (S = { source: o, target: e, score: U });
209
- }
210
- }
211
- return S;
212
- }
213
- function z(t, c) {
214
- const p = (e, i) => i.x >= e.x && i.y >= e.y && i.x + i.width <= e.x + e.width && i.y + i.height <= e.y + e.height, s = p(t, c) ? t : p(c, t) ? c : void 0;
215
- if (s) {
216
- const e = s === t ? c : t, i = {
217
- NORTH: e.y - s.y,
218
- EAST: s.x + s.width - e.x - e.width,
219
- SOUTH: s.y + s.height - e.y - e.height,
220
- WEST: e.x - s.x
221
- }, u = [...b].sort((v, l) => i[v] - i[l])[0];
222
- return { source: u, target: u };
216
+ function q(i, o) {
217
+ const a = (h, s) => s.x >= h.x && s.y >= h.y && s.x + s.width <= h.x + h.width && s.y + s.height <= h.y + h.height, n = a(i, o) ? i : a(o, i) ? o : void 0;
218
+ if (n) {
219
+ const h = n === i ? o : i, s = {
220
+ NORTH: h.y - n.y,
221
+ EAST: n.x + n.width - h.x - h.width,
222
+ SOUTH: n.y + n.height - h.y - h.height,
223
+ WEST: h.x - n.x
224
+ }, M = [...v].sort((O, C) => s[O] - s[C])[0];
225
+ return { source: M, target: M };
223
226
  }
224
- const r = c.x + c.width / 2 - (t.x + t.width / 2), m = c.y + c.height / 2 - (t.y + t.height / 2), d = Math.max(t.x - (c.x + c.width), c.x - (t.x + t.width), 0), S = Math.max(
225
- t.y - (c.y + c.height),
226
- c.y - (t.y + t.height),
227
+ const c = o.x + o.width / 2 - (i.x + i.width / 2), l = o.y + o.height / 2 - (i.y + i.height / 2), f = Math.max(i.x - (o.x + o.width), o.x - (i.x + i.width), 0), P = Math.max(
228
+ i.y - (o.y + o.height),
229
+ o.y - (i.y + i.height),
227
230
  0
228
- ), o = (S === 0 && d > 0 ? !0 : d === 0 && S > 0 ? !1 : d === 0 && S === 0 ? Math.abs(r) >= Math.abs(m) : d <= S) ? r >= 0 ? "EAST" : "WEST" : m >= 0 ? "SOUTH" : "NORTH";
229
- return { source: o, target: D(o) };
231
+ ), r = (P === 0 && f > 0 ? !0 : f === 0 && P > 0 ? !1 : f === 0 && P === 0 ? Math.abs(c) >= Math.abs(l) : f <= P) ? c >= 0 ? "EAST" : "WEST" : l >= 0 ? "SOUTH" : "NORTH";
232
+ return { source: r, target: v[(v.indexOf(r) + 2) % 4] };
230
233
  }
231
- function k(t, c, p, s = 0) {
232
- const r = (o) => Math.min(8, o / 4), m = (o, e, i) => Math.max(e + r(i), Math.min(e + i - r(i), o)), d = (o, e, i, u) => {
233
- const v = Math.max(o, i), l = Math.min(o + e, i + u);
234
- return v < l ? (v + l) / 2 + s : void 0;
235
- }, S = p.x + p.width / 2, H = p.y + p.height / 2;
236
- switch (c) {
234
+ function tt(i, o, a, n = 0) {
235
+ const c = (r) => Math.min(8, r / 4), l = (r, h, s) => Math.max(h + c(s), Math.min(h + s - c(s), r)), f = (r, h, s, M) => {
236
+ const O = Math.max(r, s), C = Math.min(r + h, s + M);
237
+ return O < C ? (O + C) / 2 + n : void 0;
238
+ }, P = a.x + a.width / 2, U = a.y + a.height / 2;
239
+ switch (o) {
237
240
  case "NORTH":
238
241
  return {
239
- x: m(
240
- d(t.x, t.width, p.x, p.width) ?? S + s,
241
- t.x,
242
- t.width
242
+ x: l(
243
+ f(i.x, i.width, a.x, a.width) ?? P + n,
244
+ i.x,
245
+ i.width
243
246
  ),
244
- y: t.y
247
+ y: i.y
245
248
  };
246
249
  case "EAST":
247
250
  return {
248
- x: t.x + t.width,
249
- y: m(
250
- d(t.y, t.height, p.y, p.height) ?? H + s,
251
- t.y,
252
- t.height
251
+ x: i.x + i.width,
252
+ y: l(
253
+ f(i.y, i.height, a.y, a.height) ?? U + n,
254
+ i.y,
255
+ i.height
253
256
  )
254
257
  };
255
258
  case "SOUTH":
256
259
  return {
257
- x: m(
258
- d(t.x, t.width, p.x, p.width) ?? S + s,
259
- t.x,
260
- t.width
260
+ x: l(
261
+ f(i.x, i.width, a.x, a.width) ?? P + n,
262
+ i.x,
263
+ i.width
261
264
  ),
262
- y: t.y + t.height
265
+ y: i.y + i.height
263
266
  };
264
267
  case "WEST":
265
268
  return {
266
- x: t.x,
267
- y: m(
268
- d(t.y, t.height, p.y, p.height) ?? H + s,
269
- t.y,
270
- t.height
269
+ x: i.x,
270
+ y: l(
271
+ f(i.y, i.height, a.y, a.height) ?? U + n,
272
+ i.y,
273
+ i.height
271
274
  )
272
275
  };
273
276
  }
274
277
  }
275
278
  export {
276
- I as routeGraphGeometry
279
+ st as routeGraphGeometry
277
280
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.86.12",
3
+ "version": "0.86.14",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",