@floegence/floe-webapp-core 0.86.10 → 0.86.12

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