@draftably/runtime 0.3.0 → 0.5.0

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.
Files changed (38) hide show
  1. package/README.md +2 -1
  2. package/dist/assets/render.worker-D11vTqoO.js +8548 -0
  3. package/dist/compile-BAIrdu-8.js +7405 -0
  4. package/dist/element.js +275 -125
  5. package/dist/{font-data-DLXJur0j.js → font-data-DME3E71S.js} +1 -1
  6. package/dist/geometry-DfUVE8b2.js +79 -0
  7. package/dist/graph.js +336 -373
  8. package/dist/host.css +37 -0
  9. package/dist/host.js +24 -0
  10. package/dist/index.js +3 -3
  11. package/dist/render-CsJYFD3o.js +1188 -0
  12. package/dist/types/src/dsl/cells.d.ts +1 -0
  13. package/dist/types/src/dsl/compile.d.ts +2 -1
  14. package/dist/types/src/dsl/legend-notes.d.ts +14 -0
  15. package/dist/types/src/dsl/syntax.d.ts +2 -0
  16. package/dist/types/src/model/appearance.d.ts +27 -1
  17. package/dist/types/src/model/colors.d.ts +10 -2
  18. package/dist/types/src/model/labels.d.ts +22 -6
  19. package/dist/types/src/runtime/anchors.d.ts +46 -0
  20. package/dist/types/src/runtime/camera.d.ts +41 -0
  21. package/dist/types/src/runtime/color-scheme.d.ts +15 -0
  22. package/dist/types/src/runtime/element-base.d.ts +40 -0
  23. package/dist/types/src/runtime/element.d.ts +7 -0
  24. package/dist/types/src/runtime/geometry.d.ts +72 -0
  25. package/dist/types/src/runtime/host.d.ts +78 -0
  26. package/dist/types/src/runtime/index.d.ts +1 -0
  27. package/dist/types/src/runtime/page-shared.d.ts +24 -0
  28. package/dist/types/src/runtime/schemes.d.ts +2 -0
  29. package/dist/types/src/runtime/svg-renderer.d.ts +12 -0
  30. package/dist/types/src/runtime/types.d.ts +13 -0
  31. package/dist/types/src/runtime/viewer.d.ts +41 -7
  32. package/dist/version-CO7i33cq.js +4 -0
  33. package/dist/viewer.css +72 -9
  34. package/dist/viewer.js +713 -346
  35. package/package.json +6 -1
  36. package/dist/assets/render.worker-dvseyGmC.js +0 -8310
  37. package/dist/compile-Csfz4rk4.js +0 -7267
  38. package/dist/render-Dgo42PR4.js +0 -1146
package/dist/graph.js CHANGED
@@ -1,153 +1,116 @@
1
- import { c as se, a as re, b as S, q as F, p as ae, d as de, e as le, f as ce, v as ue, g as N, r as pe } from "./compile-Csfz4rk4.js";
1
+ import { c as ne, a as re, b as m, q as F, p as se, d as ae, e as de, f as le, v as ce, g as N, r as ue } from "./compile-BAIrdu-8.js";
2
+ import { p as pe } from "./geometry-DfUVE8b2.js";
2
3
  const _ = /^[A-Za-z_][A-Za-z0-9_.-]*$/;
3
4
  function H(e, t) {
4
- const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = new Set(e.filter((r) => _.test(r)));
5
- let d = 0;
6
- for (const r of e) {
7
- if (typeof r != "string" || !r) throw Error(`Every ${t} needs a string id.`);
8
- if (n.has(r)) throw Error(`Duplicate ${t} id "${r}".`);
9
- let p = r;
10
- if (!_.test(r)) {
5
+ const r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), n = new Set(e.filter((s) => _.test(s)));
6
+ let a = 0;
7
+ for (const s of e) {
8
+ if (typeof s != "string" || !s) throw Error(`Every ${t} needs a string id.`);
9
+ if (r.has(s)) throw Error(`Duplicate ${t} id "${s}".`);
10
+ let u = s;
11
+ if (!_.test(s)) {
11
12
  do
12
- p = `_${d++}`;
13
- while (s.has(p));
14
- s.add(p);
13
+ u = `_${a++}`;
14
+ while (n.has(u));
15
+ n.add(u);
15
16
  }
16
- n.set(r, p), o.set(p, r);
17
+ r.set(s, u), o.set(u, s);
17
18
  }
18
19
  return {
19
- of: (r, p) => {
20
- const c = n.get(r);
21
- if (!c) throw Error(`${p} refers to unknown id "${r}".`);
22
- return c;
20
+ of: (s, u) => {
21
+ const l = r.get(s);
22
+ if (!l) throw Error(`${u} refers to unknown id "${s}".`);
23
+ return l;
23
24
  },
24
- back: (r) => o.get(r) ?? r
25
+ back: (s) => o.get(s) ?? s
25
26
  };
26
27
  }
27
- function G(e) {
28
+ function C(e) {
28
29
  const t = new Set(e.flatMap((o) => o.id ? [o.id] : []));
29
- let n = 0;
30
+ let r = 0;
30
31
  return e.map((o) => {
31
32
  if (o.id) return o.id;
32
- let s;
33
+ let n;
33
34
  do
34
- s = `e${++n}`;
35
- while (t.has(s));
36
- return s;
35
+ n = `e${++r}`;
36
+ while (t.has(n));
37
+ return n;
37
38
  });
38
39
  }
39
40
  const he = (e) => e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
40
- function M(e, t, n = {}) {
41
+ function M(e, t, r = {}) {
41
42
  return {
42
43
  kind: "statement",
43
44
  command: e,
44
45
  args: t,
45
- attrs: Object.entries(n).filter(([, o]) => o !== void 0 && o !== "").map(([o, s]) => [
46
+ attrs: Object.entries(r).filter(([, o]) => o !== void 0 && o !== "").map(([o, n]) => [
46
47
  o,
47
- typeof s == "string" && !/^[\w.-]+$/.test(s) ? F(s) : S(String(s))
48
+ typeof n == "string" && !/^[\w.-]+$/.test(n) ? F(n) : m(String(n))
48
49
  ]),
49
50
  line: 0
50
51
  };
51
52
  }
52
- function A(e, t, n) {
53
+ function A(e, t, r) {
53
54
  const o = t.startsWith("engine:") ? t.slice(7) : void 0;
54
- return M("layout", o ? [S(e)] : [S(e), S(t)], {
55
+ return M("layout", o ? [m(e)] : [m(e), m(t)], {
55
56
  ...o ? { engine: o } : {},
56
- ...n
57
+ ...r
57
58
  });
58
59
  }
59
- function U(e) {
60
- if (!e.length) return { x: 0, y: 0, width: 0, height: 0 };
61
- const t = Math.min(...e.map((o) => o.x)), n = Math.min(...e.map((o) => o.y));
62
- return {
63
- x: t,
64
- y: n,
65
- width: Math.max(...e.map((o) => o.x + o.width)) - t,
66
- height: Math.max(...e.map((o) => o.y + o.height)) - n
67
- };
68
- }
69
60
  const ge = 1200;
70
- function fe(e, t, n, o = "auto") {
61
+ function fe(e, t, r, o = "auto") {
71
62
  if (o === "full")
72
- return { ...N(e, t, n, { previous: [] }), quality: "full" };
73
- const s = N(e, t, n, { previous: [], quick: !0 }), { edges: d, crossings: r, lanePairs: p, shared: c } = s.result.report, y = d * (1 + r + p + (c ? 1 : 0));
74
- return o === "quick" || y > ge ? { ...s, quality: "quick" } : { ...N(e, t, n, { previous: [] }), quality: "full" };
63
+ return { ...N(e, t, r, { previous: [] }), quality: "full" };
64
+ const n = N(e, t, r, { previous: [], quick: !0 }), { edges: a, crossings: s, lanePairs: u, shared: l } = n.result.report, f = a * (1 + s + u + (l ? 1 : 0));
65
+ return o === "quick" || f > ge ? { ...n, quality: "quick" } : { ...N(e, t, r, { previous: [] }), quality: "full" };
75
66
  }
76
- function K(e, t, n, o) {
77
- const { vg: s, rects: d } = ue(e), r = fe(e, s, d, t), p = new Map([...e.graph.nodes, ...e.graph.groups].map((u) => [u.id, u.parentId])), c = new Map(e.graph.edges.map((u) => [u.id, u])), y = (u) => {
78
- const w = d.get(u), m = p.get(u);
79
- return { x: w.x, y: w.y, width: w.w, height: w.h, ...m ? { parent: n(m) } : {} };
80
- }, f = Object.fromEntries(s.nodes.map((u) => [n(u.id), y(u.id)])), i = Object.fromEntries(s.groups.map((u) => [n(u.id), y(u.id)])), l = Object.fromEntries(
81
- r.routes.map((u) => [
82
- o(u.id),
83
- {
84
- source: n(c.get(u.id)?.from ?? u.from),
85
- target: n(c.get(u.id)?.to ?? u.to),
86
- sourceSide: u.fromSide,
87
- targetSide: u.toSide,
88
- points: u.points,
89
- path: u.path,
90
- label: u.label ? {
91
- x: u.label.x - u.label.w / 2,
92
- y: u.label.y - u.label.h / 2,
93
- width: u.label.w,
94
- height: u.label.h
95
- } : null,
96
- blocked: u.blocked
97
- }
98
- ])
99
- ), a = [...Object.values(f), ...Object.values(i)];
100
- for (const u of Object.values(l))
101
- u.label && a.push(u.label), a.push(U(u.points.map((w) => ({ ...w, width: 0, height: 0 }))));
102
- const g = Object.values(l).filter((u) => u.blocked).length;
67
+ function G(e, t, r, o) {
68
+ const { vg: n, rects: a } = ce(e), s = fe(e, n, a, t), u = pe(e, a, s.routes, r, o), l = Object.values(u.edges).filter((f) => f.blocked).length;
103
69
  return {
104
- nodes: f,
105
- groups: i,
106
- edges: l,
107
- bounds: U(a),
108
- quality: r.quality,
109
- warnings: g ? [`${g} line${g > 1 ? "s" : ""} found no clear way.`] : []
70
+ ...u,
71
+ quality: s.quality,
72
+ warnings: l ? [`${l} line${l > 1 ? "s" : ""} found no clear way.`] : []
110
73
  };
111
74
  }
112
- function ye(e, t, n) {
75
+ function ye(e, t, r) {
113
76
  let o = e;
114
- for (const s of t)
115
- n(s) !== s && (o = o.replace(new RegExp(`\\b${s}\\b`, "g"), `"${n(s)}"`));
77
+ for (const n of t)
78
+ r(n) !== n && (o = o.replace(new RegExp(`\\b${n}\\b`, "g"), `"${r(n)}"`));
116
79
  return o;
117
80
  }
118
81
  function be(e, t) {
119
- const n = (o, s, d, r) => {
82
+ const r = (o, n, a, s) => {
120
83
  if (o === void 0 || !Number.isFinite(o)) return;
121
- const p = Math.round(Math.min(d, Math.max(s, o)));
122
- return p !== Math.round(o) && t.push(`Node "${e.id}" ${r} ${o} is outside ${s}–${d}; drawn at ${p}.`), p;
84
+ const u = Math.round(Math.min(a, Math.max(n, o)));
85
+ return u !== Math.round(o) && t.push(`Node "${e.id}" ${s} ${o} is outside ${n}–${a}; drawn at ${u}.`), u;
123
86
  };
124
- return { width: n(e.width, 40, 1200, "width"), height: n(e.height, 24, 1200, "height") };
87
+ return { width: r(e.width, 40, 1200, "width"), height: r(e.height, 24, 1200, "height") };
125
88
  }
126
- function Z(e) {
127
- const t = e.groups ?? [], n = e.nodes ?? [], o = e.edges ?? [], s = G(o), d = H([...t.map((a) => a.id), ...n.map((a) => a.id)], "node or group"), r = H(s, "edge"), p = d.of, { quality: c, ...y } = e.routing ?? {}, f = [], i = [
89
+ function K(e) {
90
+ const t = e.groups ?? [], r = e.nodes ?? [], o = e.edges ?? [], n = C(o), a = H([...t.map((d) => d.id), ...r.map((d) => d.id)], "node or group"), s = H(n, "edge"), u = a.of, { quality: l, ...f } = e.routing ?? {}, h = [], i = [
128
91
  ...t.map(
129
- (a) => M("group", [S(p(a.id, "group")), F(a.label ?? a.id)], {
130
- in: a.parent && p(a.parent, `Group "${a.id}"`),
92
+ (d) => M("group", [m(u(d.id, "group")), F(d.label ?? d.id)], {
93
+ in: d.parent && u(d.parent, `Group "${d.id}"`),
131
94
  fold: e.fold === "never" ? "never" : void 0
132
95
  })
133
96
  ),
134
- ...n.map(
135
- (a) => M("node", [S(p(a.id, "node")), F(a.label ?? a.id)], {
136
- in: a.parent && p(a.parent, `Node "${a.id}"`),
137
- shape: a.shape
97
+ ...r.map(
98
+ (d) => M("node", [m(u(d.id, "node")), F(d.label ?? d.id)], {
99
+ in: d.parent && u(d.parent, `Node "${d.id}"`),
100
+ shape: d.shape
138
101
  })
139
102
  ),
140
103
  ...o.map(
141
- (a, g) => M(
104
+ (d, g) => M(
142
105
  "edge",
143
106
  [
144
- S(r.of(s[g], "edge")),
145
- S(p(a.source, `Edge "${s[g]}"`)),
146
- S("->"),
147
- S(p(a.target, `Edge "${s[g]}"`)),
148
- ...a.label ? [F(a.label)] : []
107
+ m(s.of(n[g], "edge")),
108
+ m(u(d.source, `Edge "${n[g]}"`)),
109
+ m("->"),
110
+ m(u(d.target, `Edge "${n[g]}"`)),
111
+ ...d.label ? [F(d.label)] : []
149
112
  ],
150
- { kind: a.dashed ? "async" : void 0, from: a.sourceSide, to: a.targetSide }
113
+ { kind: d.dashed ? "async" : void 0, from: d.sourceSide, to: d.targetSide }
151
114
  )
152
115
  ),
153
116
  // A file with no layout line spaces its root flow 48px apart; a layout line without `gap=`
@@ -158,141 +121,141 @@ function Z(e) {
158
121
  fit: e.fit,
159
122
  fold: e.fold === "never" ? "never" : void 0
160
123
  }),
161
- ...t.filter((a) => a.arrange || a.direction || a.gap).map(
162
- (a) => A(p(a.id, "group"), a.arrange ?? "column", {
163
- gap: a.gap,
164
- direction: a.direction
124
+ ...t.filter((d) => d.arrange || d.direction || d.gap).map(
125
+ (d) => A(u(d.id, "group"), d.arrange ?? "column", {
126
+ gap: d.gap,
127
+ direction: d.direction
165
128
  })
166
129
  ),
167
- ...n.flatMap((a) => {
168
- const { width: g, height: u } = be(a, f);
169
- return g || u ? [
170
- M("size", [S(p(a.id, "node"))], {
130
+ ...r.flatMap((d) => {
131
+ const { width: g, height: y } = be(d, h);
132
+ return g || y ? [
133
+ M("size", [m(u(d.id, "node"))], {
171
134
  width: g ?? 176,
172
- height: u ?? "auto"
135
+ height: y ?? "auto"
173
136
  })
174
137
  ] : [];
175
138
  }),
176
- ...Object.keys(y).length ? [
139
+ ...Object.keys(f).length ? [
177
140
  M(
178
141
  "routing",
179
142
  [],
180
- Object.fromEntries(Object.entries(y).map(([a, g]) => [he(a), g]))
143
+ Object.fromEntries(Object.entries(f).map(([d, g]) => [he(d), g]))
181
144
  )
182
145
  ] : []
183
146
  ];
184
- return { draft: ae({ lines: i }), model: de({ lines: i }), quality: c, objects: d, lines: r, warnings: f };
147
+ return { draft: se({ lines: i }), model: ae({ lines: i }), quality: l, objects: a, lines: s, warnings: h };
185
148
  }
186
- function J({ draft: e, model: t, quality: n, objects: o, lines: s, warnings: d }, r) {
187
- const p = K(le(r), n, o.back, s.back);
149
+ function Z({ draft: e, model: t, quality: r, objects: o, lines: n, warnings: a }, s) {
150
+ const u = G(de(s), r, o.back, n.back);
188
151
  return {
189
- ...p,
152
+ ...u,
190
153
  draft: e,
191
154
  warnings: [
192
- ...d,
193
- ...t.warnings.map((c) => c.message),
155
+ ...a,
156
+ ...t.warnings.map((l) => l.message),
194
157
  // A caller's size is the host's to fill: whether draftably's text fits it says nothing.
195
- ...r.diagnostics.filter((c) => c.level !== "info" && c.code !== "text-overflow").map((c) => ye(c.message, c.ids, o.back)),
196
- ...p.warnings
158
+ ...s.diagnostics.filter((l) => l.level !== "info" && l.code !== "text-overflow").map((l) => ye(l.message, l.ids, o.back)),
159
+ ...u.warnings
197
160
  ]
198
161
  };
199
162
  }
200
163
  async function T(e) {
201
- const t = Z(e);
202
- return J(t, await re(t.draft));
164
+ const t = K(e);
165
+ return Z(t, await re(t.draft));
203
166
  }
204
- function Q(e) {
205
- const t = Z(e);
206
- if (t.model.layouts.some((n) => n.engine || n.fit))
167
+ function J(e) {
168
+ const t = K(e);
169
+ if (t.model.layouts.some((r) => r.engine || r.fit))
207
170
  throw Error("layoutSync cannot run layout engines or fit; use layout().");
208
- return J(t, se(t.draft));
171
+ return Z(t, ne(t.draft));
209
172
  }
210
- function W(e) {
211
- const t = ce(), n = e.groups ?? [], o = /* @__PURE__ */ new Set(), { quality: s, ...d } = e.routing ?? {}, r = G(e.edges);
212
- t.settings.routing = { ...t.settings.routing, ...d };
213
- for (const i of [...n, ...e.nodes]) {
173
+ function U(e) {
174
+ const t = le(), r = e.groups ?? [], o = /* @__PURE__ */ new Set(), { quality: n, ...a } = e.routing ?? {}, s = C(e.edges);
175
+ t.settings.routing = { ...t.settings.routing, ...a };
176
+ for (const i of [...r, ...e.nodes]) {
214
177
  if (o.has(i.id)) throw Error(`Duplicate node or group id "${i.id}".`);
215
178
  o.add(i.id);
216
179
  }
217
- const p = (i, l) => {
218
- if (i !== void 0 && !o.has(i)) throw Error(`${l} refers to unknown id "${i}".`);
180
+ const u = (i, c) => {
181
+ if (i !== void 0 && !o.has(i)) throw Error(`${c} refers to unknown id "${i}".`);
219
182
  };
220
- for (const i of n)
221
- p(i.parent, `Group "${i.id}"`), t.graph.groups.push({
183
+ for (const i of r)
184
+ u(i.parent, `Group "${i.id}"`), t.graph.groups.push({
222
185
  id: i.id,
223
186
  title: i.label ?? "",
224
187
  ...i.parent ? { parentId: i.parent } : {}
225
188
  }), t.layout.containers[i.id] = { direction: "inherit", padding: 0, manualSize: !0 };
226
189
  for (const i of e.nodes)
227
- p(i.parent, `Node "${i.id}"`), t.graph.nodes.push({ id: i.id, title: "", ...i.parent ? { parentId: i.parent } : {} }), t.styles[i.id] = { shape: i.shape ?? "box", color: "auto", icon: "" };
228
- for (const i of [...n, ...e.nodes])
190
+ u(i.parent, `Node "${i.id}"`), t.graph.nodes.push({ id: i.id, title: "", ...i.parent ? { parentId: i.parent } : {} }), t.styles[i.id] = { shape: i.shape ?? "box", color: "auto", icon: "" };
191
+ for (const i of [...r, ...e.nodes])
229
192
  t.layout.nodes[i.id] = { x: i.x, y: i.y, w: i.width, h: i.height };
230
- e.edges.forEach((i, l) => {
231
- const a = r[l];
232
- p(i.source, `Edge "${a}"`), p(i.target, `Edge "${a}"`), t.graph.edges.push({
233
- id: a,
193
+ e.edges.forEach((i, c) => {
194
+ const d = s[c];
195
+ u(i.source, `Edge "${d}"`), u(i.target, `Edge "${d}"`), t.graph.edges.push({
196
+ id: d,
234
197
  from: i.source,
235
198
  to: i.target,
236
199
  label: i.label ?? "",
237
200
  directed: !0,
238
201
  emphasis: !1,
239
202
  dashed: !!i.dashed
240
- }), t.layout.edges[a] = {
203
+ }), t.layout.edges[d] = {
241
204
  ...i.sourceSide ? { fromSide: i.sourceSide } : {},
242
205
  ...i.targetSide ? { toSide: i.targetSide } : {}
243
206
  };
244
207
  });
245
208
  const {
246
- edges: c,
247
- quality: y,
248
- warnings: f
249
- } = K(
209
+ edges: l,
210
+ quality: f,
211
+ warnings: h
212
+ } = G(
250
213
  t,
251
- s,
214
+ n,
252
215
  (i) => i,
253
216
  (i) => i
254
217
  );
255
- return { edges: c, quality: y, warnings: f };
218
+ return { edges: l, quality: f, warnings: h };
256
219
  }
257
- const we = /* @__PURE__ */ new Set(["left", "right", "top", "bottom"]), B = (e) => e && we.has(e) ? e : void 0, E = (e) => typeof e == "number" && e > 0 ? e : void 0, k = (e) => e.parentId ?? e.parentNode, R = (e) => typeof e.data?.label == "string" ? e.data.label : e.id, V = (e) => {
220
+ const we = /* @__PURE__ */ new Set(["left", "right", "top", "bottom"]), W = (e) => e && we.has(e) ? e : void 0, E = (e) => typeof e == "number" && e > 0 ? e : void 0, k = (e) => e.parentId ?? e.parentNode, I = (e) => typeof e.data?.label == "string" ? e.data.label : e.id, Q = (e) => {
258
221
  const t = typeof e.style == "object" ? e.style : void 0;
259
222
  return {
260
223
  width: E(e.measured?.width) ?? E(e.width) ?? E(t?.width),
261
224
  height: E(e.measured?.height) ?? E(e.height) ?? E(t?.height)
262
225
  };
263
- }, X = (e) => /* @__PURE__ */ new Set([
226
+ }, V = (e) => /* @__PURE__ */ new Set([
264
227
  ...e.flatMap((t) => k(t) ? [k(t)] : []),
265
228
  ...e.filter((t) => t.type === "group").map((t) => t.id)
266
229
  ]);
267
- function Y({ nodes: e, edges: t }, n = {}) {
268
- const o = X(e);
230
+ function X({ nodes: e, edges: t }, r = {}) {
231
+ const o = V(e);
269
232
  return {
270
- groups: e.filter((s) => o.has(s.id)).map((s) => ({ id: s.id, label: R(s), parent: k(s) })),
271
- nodes: e.filter((s) => !o.has(s.id)).map((s) => {
272
- const { width: d, height: r } = V(s);
233
+ groups: e.filter((n) => o.has(n.id)).map((n) => ({ id: n.id, label: I(n), parent: k(n) })),
234
+ nodes: e.filter((n) => !o.has(n.id)).map((n) => {
235
+ const { width: a, height: s } = Q(n);
273
236
  return {
274
- id: s.id,
275
- label: R(s),
276
- parent: k(s),
277
- shape: n.shape?.(s),
278
- ...d ? { width: d } : {},
279
- ...r ? { height: r } : {}
237
+ id: n.id,
238
+ label: I(n),
239
+ parent: k(n),
240
+ shape: r.shape?.(n),
241
+ ...a ? { width: a } : {},
242
+ ...s ? { height: s } : {}
280
243
  };
281
244
  }),
282
- edges: t.map((s) => ({
283
- id: s.id,
284
- source: s.source,
285
- target: s.target,
286
- label: typeof s.label == "string" ? s.label : void 0,
287
- dashed: s.animated,
288
- sourceSide: B(s.sourceHandle),
289
- targetSide: B(s.targetHandle)
245
+ edges: t.map((n) => ({
246
+ id: n.id,
247
+ source: n.source,
248
+ target: n.target,
249
+ label: typeof n.label == "string" ? n.label : void 0,
250
+ dashed: n.animated,
251
+ sourceSide: W(n.sourceHandle),
252
+ targetSide: W(n.targetHandle)
290
253
  }))
291
254
  };
292
255
  }
293
- function ee(e, t) {
294
- return e.map((n) => {
295
- const o = t[n.id], s = o ? {
256
+ function Y(e, t) {
257
+ return e.map((r) => {
258
+ const o = t[r.id], n = o ? {
296
259
  path: o.path,
297
260
  points: o.points,
298
261
  label: o.label,
@@ -307,96 +270,96 @@ function ee(e, t) {
307
270
  targetSide: "left",
308
271
  blocked: !0
309
272
  };
310
- return { ...n, type: n.type ?? "draftably", data: { ...n.data, draftably: s } };
273
+ return { ...r, type: r.type ?? "draftably", data: { ...r.data, draftably: n } };
311
274
  });
312
275
  }
313
- function me({ nodes: e, edges: t }, n, o = !1) {
314
- const s = (d) => n.nodes[d] ?? n.groups[d];
276
+ function me({ nodes: e, edges: t }, r, o = !1) {
277
+ const n = (a) => r.nodes[a] ?? r.groups[a];
315
278
  return {
316
- nodes: e.map((d) => {
317
- const r = s(d.id), p = k(d) ? s(k(d)) : void 0;
318
- if (!r) return d;
319
- const c = { width: r.width, height: r.height };
279
+ nodes: e.map((a) => {
280
+ const s = n(a.id), u = k(a) ? n(k(a)) : void 0;
281
+ if (!s) return a;
282
+ const l = { width: s.width, height: s.height };
320
283
  return {
321
- ...d,
322
- position: { x: r.x - (p?.x ?? 0), y: r.y - (p?.y ?? 0) },
323
- ...c,
324
- ...o || typeof d.style == "string" ? {} : { style: { ...d.style, ...c } }
284
+ ...a,
285
+ position: { x: s.x - (u?.x ?? 0), y: s.y - (u?.y ?? 0) },
286
+ ...l,
287
+ ...o || typeof a.style == "string" ? {} : { style: { ...a.style, ...l } }
325
288
  };
326
289
  }),
327
- edges: ee(t, n.edges)
290
+ edges: Y(t, r.edges)
328
291
  };
329
292
  }
330
- function xe({ nodes: e, edges: t }, n = {}) {
331
- const o = new Map(e.map((c) => [c.id, c])), s = X(e), d = (c) => {
332
- const y = k(c) ? o.get(k(c)) : void 0, f = y ? d(y) : { x: 0, y: 0 };
333
- return { x: f.x + (c.position?.x ?? 0), y: f.y + (c.position?.y ?? 0) };
334
- }, r = e.flatMap((c) => {
335
- const { width: y, height: f } = V(c);
336
- return y && f ? [{ n: c, box: { ...d(c), width: y, height: f } }] : [];
337
- }), p = new Set(r.map((c) => c.n.id));
293
+ function Se({ nodes: e, edges: t }, r = {}) {
294
+ const o = new Map(e.map((l) => [l.id, l])), n = V(e), a = (l) => {
295
+ const f = k(l) ? o.get(k(l)) : void 0, h = f ? a(f) : { x: 0, y: 0 };
296
+ return { x: h.x + (l.position?.x ?? 0), y: h.y + (l.position?.y ?? 0) };
297
+ }, s = e.flatMap((l) => {
298
+ const { width: f, height: h } = Q(l);
299
+ return f && h ? [{ n: l, box: { ...a(l), width: f, height: h } }] : [];
300
+ }), u = new Set(s.map((l) => l.n.id));
338
301
  return {
339
- groups: r.filter(({ n: c }) => s.has(c.id)).map(({ n: c, box: y }) => ({ id: c.id, label: R(c), parent: k(c), ...y })),
340
- nodes: r.filter(({ n: c }) => !s.has(c.id)).map(({ n: c, box: y }) => ({
341
- id: c.id,
342
- parent: k(c),
343
- shape: n.shape?.(c),
344
- ...y
302
+ groups: s.filter(({ n: l }) => n.has(l.id)).map(({ n: l, box: f }) => ({ id: l.id, label: I(l), parent: k(l), ...f })),
303
+ nodes: s.filter(({ n: l }) => !n.has(l.id)).map(({ n: l, box: f }) => ({
304
+ id: l.id,
305
+ parent: k(l),
306
+ shape: r.shape?.(l),
307
+ ...f
345
308
  })),
346
- edges: Y({ nodes: [], edges: t }).edges.filter(
347
- (c) => p.has(c.source) && p.has(c.target)
309
+ edges: X({ nodes: [], edges: t }).edges.filter(
310
+ (l) => u.has(l.source) && u.has(l.target)
348
311
  )
349
312
  };
350
313
  }
351
- function Se(e, t) {
352
- return ee(e, t.edges).map(
353
- (n, o) => t.edges[n.id] || !e[o].data?.draftably ? n : e[o]
314
+ function ke(e, t) {
315
+ return Y(e, t.edges).map(
316
+ (r, o) => t.edges[r.id] || !e[o].data?.draftably ? r : e[o]
354
317
  );
355
318
  }
356
- const P = (e, t) => Object.fromEntries(Object.entries(e).map(([n, o]) => [n, t(o)]));
357
- function te(e, t, n, o, s = e.bounds) {
319
+ const P = (e, t) => Object.fromEntries(Object.entries(e).map(([r, o]) => [r, t(o)]));
320
+ function ee(e, t, r, o, n = e.bounds) {
358
321
  return {
359
322
  ...e,
360
- bounds: s,
323
+ bounds: n,
361
324
  nodes: P(e.nodes, t),
362
325
  groups: P(e.groups, t),
363
- edges: P(e.edges, (d) => {
364
- const r = d.points.map(n);
326
+ edges: P(e.edges, (a) => {
327
+ const s = a.points.map(r);
365
328
  return {
366
- ...d,
367
- points: r,
368
- path: pe(r, 6),
369
- label: d.label && t(d.label),
370
- sourceSide: o(d.sourceSide),
371
- targetSide: o(d.targetSide)
329
+ ...a,
330
+ points: s,
331
+ path: ue(s, 6),
332
+ label: a.label && t(a.label),
333
+ sourceSide: o(a.sourceSide),
334
+ targetSide: o(a.targetSide)
372
335
  };
373
336
  })
374
337
  };
375
338
  }
376
- function oe(e) {
377
- const t = -e.bounds.x, n = -e.bounds.y;
378
- return !t && !n ? e : te(
339
+ function te(e) {
340
+ const t = -e.bounds.x, r = -e.bounds.y;
341
+ return !t && !r ? e : ee(
379
342
  e,
380
- (o) => ({ ...o, x: o.x + t, y: o.y + n }),
381
- (o) => ({ x: o.x + t, y: o.y + n }),
343
+ (o) => ({ ...o, x: o.x + t, y: o.y + r }),
344
+ (o) => ({ x: o.x + t, y: o.y + r }),
382
345
  (o) => o,
383
346
  { ...e.bounds, x: 0, y: 0 }
384
347
  );
385
348
  }
386
- const ke = { left: "right", right: "left", top: "bottom", bottom: "top" };
387
- function D(e, t) {
388
- const n = t === "x" ? "width" : "height", o = 2 * e.bounds[t] + e.bounds[n], s = t === "x" ? ["left", "right"] : ["top", "bottom"];
389
- return te(
349
+ const xe = { left: "right", right: "left", top: "bottom", bottom: "top" };
350
+ function R(e, t) {
351
+ const r = t === "x" ? "width" : "height", o = 2 * e.bounds[t] + e.bounds[r], n = t === "x" ? ["left", "right"] : ["top", "bottom"];
352
+ return ee(
390
353
  e,
391
- (d) => ({ ...d, [t]: o - d[t] - d[n] }),
392
- (d) => ({ ...d, [t]: o - d[t] }),
393
- (d) => s.includes(d) ? ke[d] : d
354
+ (a) => ({ ...a, [t]: o - a[t] - a[r] }),
355
+ (a) => ({ ...a, [t]: o - a[t] }),
356
+ (a) => n.includes(a) ? xe[a] : a
394
357
  );
395
358
  }
396
359
  function j(e, t) {
397
360
  return e?.[`elk.${t}`] ?? e?.[`org.eclipse.elk.${t}`] ?? e?.[t];
398
361
  }
399
- const C = (e) => e.replace(/^(org\.eclipse\.)?elk\./, ""), $e = /* @__PURE__ */ new Set([
362
+ const B = (e) => e.replace(/^(org\.eclipse\.)?elk\./, ""), $e = /* @__PURE__ */ new Set([
400
363
  "algorithm",
401
364
  "direction",
402
365
  "spacing.nodeNode",
@@ -414,43 +377,43 @@ const C = (e) => e.replace(/^(org\.eclipse\.)?elk\./, ""), $e = /* @__PURE__ */
414
377
  WEST: "left"
415
378
  };
416
379
  function Ee(e, t) {
417
- const n = [], o = [], s = [], d = [], r = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), y = { ...t, ...e.layoutOptions }, f = (h) => {
418
- for (const b of Object.keys(h ?? {})) $e.has(C(b)) || r.add(C(b));
380
+ const r = [], o = [], n = [], a = [], s = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), f = { ...t, ...e.layoutOptions }, h = (p) => {
381
+ for (const b of Object.keys(p ?? {})) $e.has(B(b)) || s.add(B(b));
419
382
  };
420
- f(y);
421
- const i = { nodes: n, groups: o, edges: s, fold: "never" }, l = j(y, "direction");
422
- let a;
423
- l === "DOWN" || l === "UP" ? i.direction = "down" : (l === "RIGHT" || l === "LEFT") && (i.direction = "right"), l === "LEFT" && (a = "x"), l === "UP" && (a = "y");
383
+ h(f);
384
+ const i = { nodes: r, groups: o, edges: n, fold: "never" }, c = j(f, "direction");
385
+ let d;
386
+ c === "DOWN" || c === "UP" ? i.direction = "down" : (c === "RIGHT" || c === "LEFT") && (i.direction = "right"), c === "LEFT" && (d = "x"), c === "UP" && (d = "y");
424
387
  const g = Number(
425
- j(y, "layered.spacing.nodeNodeBetweenLayers") ?? j(y, "spacing.nodeNode")
388
+ j(f, "layered.spacing.nodeNodeBetweenLayers") ?? j(f, "spacing.nodeNode")
426
389
  );
427
390
  g > 0 && (i.gap = Math.min(300, Math.max(8, g)));
428
- const u = j(y, "algorithm");
429
- u && /force|stress/.test(u) ? i.arrange = "engine:stress" : u && /mrtree/.test(u) ? i.arrange = "engine:tree" : u && /rectpacking|box/.test(u) && (i.arrange = "engine:grid");
430
- const w = (h, b) => {
431
- for (const x of h.ports ?? [])
432
- f(x.layoutOptions), p.set(x.id, { node: h.id, side: Oe[j(x.layoutOptions, "port.side") ?? ""] });
433
- if (h !== e) {
434
- f(h.layoutOptions);
435
- const x = h.labels?.[0]?.text ?? h.id;
436
- h.children?.length ? o.push({ id: h.id, label: x, parent: b, arrange: "flow" }) : n.push({
437
- id: h.id,
438
- label: x,
391
+ const y = j(f, "algorithm");
392
+ y && /force|stress/.test(y) ? i.arrange = "engine:stress" : y && /mrtree/.test(y) ? i.arrange = "engine:tree" : y && /rectpacking|box/.test(y) && (i.arrange = "engine:grid");
393
+ const S = (p, b) => {
394
+ for (const w of p.ports ?? [])
395
+ h(w.layoutOptions), u.set(w.id, { node: p.id, side: Oe[j(w.layoutOptions, "port.side") ?? ""] });
396
+ if (p !== e) {
397
+ h(p.layoutOptions);
398
+ const w = p.labels?.[0]?.text ?? p.id;
399
+ p.children?.length ? o.push({ id: p.id, label: w, parent: b, arrange: "flow" }) : r.push({
400
+ id: p.id,
401
+ label: w,
439
402
  parent: b,
440
- ...h.width ? { width: h.width } : {},
441
- ...h.height ? { height: h.height } : {}
403
+ ...p.width ? { width: p.width } : {},
404
+ ...p.height ? { height: p.height } : {}
442
405
  });
443
406
  }
444
- for (const x of h.children ?? []) w(x, h === e ? void 0 : h.id);
407
+ for (const w of p.children ?? []) S(w, p === e ? void 0 : p.id);
445
408
  };
446
- w(e);
447
- const m = (h) => p.get(h) ?? { node: h, side: void 0 }, $ = (h) => {
448
- for (const b of h.edges ?? []) {
449
- f(b.layoutOptions);
450
- const x = b.sources.flatMap((L) => b.targets.map((O) => [m(L), m(O)])), I = x.map((L, O) => x.length > 1 ? `${b.id}#${O}` : b.id);
451
- c.set(b.id, I), x.forEach(
452
- ([L, O], ne) => s.push({
453
- id: I[ne],
409
+ S(e);
410
+ const x = (p) => u.get(p) ?? { node: p, side: void 0 }, $ = (p) => {
411
+ for (const b of p.edges ?? []) {
412
+ h(b.layoutOptions);
413
+ const w = b.sources.flatMap((L) => b.targets.map((O) => [x(L), x(O)])), z = w.map((L, O) => w.length > 1 ? `${b.id}#${O}` : b.id);
414
+ l.set(b.id, z), w.forEach(
415
+ ([L, O], ie) => n.push({
416
+ id: z[ie],
454
417
  source: L.node,
455
418
  target: O.node,
456
419
  label: b.labels?.[0]?.text,
@@ -459,82 +422,82 @@ function Ee(e, t) {
459
422
  })
460
423
  );
461
424
  }
462
- for (const b of h.children ?? []) $(b);
425
+ for (const b of p.children ?? []) $(b);
463
426
  };
464
- return $(e), r.size && d.push(`These ELK options are not used: ${[...r].sort().join(", ")}.`), { graph: i, warnings: d, pieces: c, mirror: a };
465
- }
466
- function ve(e, t, { pieces: n }) {
467
- const o = /* @__PURE__ */ new Map([[e.id, { x: 0, y: 0 }]]), s = /* @__PURE__ */ new Map(), d = (l, a) => {
468
- const g = l === e ? void 0 : t.nodes[l.id] ?? t.groups[l.id], u = g ? { x: g.x, y: g.y } : a;
469
- o.set(l.id, u);
470
- for (const m of l.children ?? []) s.set(m.id, l.id);
471
- const w = l.children?.map((m) => d(m, u));
427
+ return $(e), s.size && a.push(`These ELK options are not used: ${[...s].sort().join(", ")}.`), { graph: i, warnings: a, pieces: l, mirror: d };
428
+ }
429
+ function ve(e, t, { pieces: r }) {
430
+ const o = /* @__PURE__ */ new Map([[e.id, { x: 0, y: 0 }]]), n = /* @__PURE__ */ new Map(), a = (c, d) => {
431
+ const g = c === e ? void 0 : t.nodes[c.id] ?? t.groups[c.id], y = g ? { x: g.x, y: g.y } : d;
432
+ o.set(c.id, y);
433
+ for (const x of c.children ?? []) n.set(x.id, c.id);
434
+ const S = c.children?.map((x) => a(x, y));
472
435
  return {
473
- ...l,
474
- ...l === e ? {
436
+ ...c,
437
+ ...c === e ? {
475
438
  x: 0,
476
439
  y: 0,
477
440
  width: t.bounds.x + t.bounds.width,
478
441
  height: t.bounds.y + t.bounds.height
479
- } : { x: u.x - a.x, y: u.y - a.y, width: g?.width, height: g?.height },
480
- ...w ? { children: w } : {}
442
+ } : { x: y.x - d.x, y: y.y - d.y, width: g?.width, height: g?.height },
443
+ ...S ? { children: S } : {}
481
444
  };
482
- }, r = d(e, { x: 0, y: 0 }), p = /* @__PURE__ */ new Map(), c = (l) => {
483
- for (const a of l.ports ?? []) p.set(a.id, l.id);
484
- l.children?.forEach(c);
445
+ }, s = a(e, { x: 0, y: 0 }), u = /* @__PURE__ */ new Map(), l = (c) => {
446
+ for (const d of c.ports ?? []) u.set(d.id, c.id);
447
+ c.children?.forEach(l);
485
448
  };
486
- c(e);
487
- const y = (l) => {
488
- const a = [];
489
- for (let g = s.get(p.get(l) ?? l); g; g = s.get(g)) a.push(g);
490
- return a;
491
- }, f = (l) => {
492
- const a = y(l.sources[0]), g = new Set(y(l.targets[0]));
493
- return a.find((u) => g.has(u)) ?? e.id;
494
- }, i = (l) => ({
495
- ...l,
496
- ...l.edges ? {
497
- edges: l.edges.map((a) => {
498
- const g = f(a), u = o.get(g) ?? { x: 0, y: 0 }, w = (h) => ({ x: h.x - u.x, y: h.y - u.y }), m = (n.get(a.id) ?? [a.id]).map((h) => t.edges[h]).filter(Boolean), $ = m[0]?.label;
449
+ l(e);
450
+ const f = (c) => {
451
+ const d = [];
452
+ for (let g = n.get(u.get(c) ?? c); g; g = n.get(g)) d.push(g);
453
+ return d;
454
+ }, h = (c) => {
455
+ const d = f(c.sources[0]), g = new Set(f(c.targets[0]));
456
+ return d.find((y) => g.has(y)) ?? e.id;
457
+ }, i = (c) => ({
458
+ ...c,
459
+ ...c.edges ? {
460
+ edges: c.edges.map((d) => {
461
+ const g = h(d), y = o.get(g) ?? { x: 0, y: 0 }, S = (p) => ({ x: p.x - y.x, y: p.y - y.y }), x = (r.get(d.id) ?? [d.id]).map((p) => t.edges[p]).filter(Boolean), $ = x[0]?.label;
499
462
  return {
500
- ...a,
463
+ ...d,
501
464
  container: g,
502
- sections: m.map((h, b) => ({
503
- id: `${a.id}_s${b}`,
504
- startPoint: w(h.points[0]),
505
- endPoint: w(h.points.at(-1)),
506
- bendPoints: h.points.slice(1, -1).map(w),
507
- incomingShape: h.source,
508
- outgoingShape: h.target
465
+ sections: x.map((p, b) => ({
466
+ id: `${d.id}_s${b}`,
467
+ startPoint: S(p.points[0]),
468
+ endPoint: S(p.points.at(-1)),
469
+ bendPoints: p.points.slice(1, -1).map(S),
470
+ incomingShape: p.source,
471
+ outgoingShape: p.target
509
472
  })),
510
- ...a.labels?.length && $ ? {
511
- labels: a.labels.map(
512
- (h, b) => b ? h : { ...h, ...w($), width: $.width, height: $.height }
473
+ ...d.labels?.length && $ ? {
474
+ labels: d.labels.map(
475
+ (p, b) => b ? p : { ...p, ...S($), width: $.width, height: $.height }
513
476
  )
514
477
  } : {}
515
478
  };
516
479
  })
517
480
  } : {},
518
- ...l.children ? { children: l.children.map(i) } : {}
481
+ ...c.children ? { children: c.children.map(i) } : {}
519
482
  });
520
- return i(r);
483
+ return i(s);
521
484
  }
522
- async function ie(e, t, n) {
523
- const o = Ee(e, t), s = await T({ ...o.graph, ...n }), d = oe(o.mirror ? D(s, o.mirror) : s);
524
- return d.warnings.unshift(...o.warnings), { elk: ve(e, d, o), result: d };
485
+ async function oe(e, t, r) {
486
+ const o = Ee(e, t), n = await T({ ...o.graph, ...r }), a = te(o.mirror ? R(n, o.mirror) : n);
487
+ return a.warnings.unshift(...o.warnings), { elk: ve(e, a, o), result: a };
525
488
  }
526
- class Le {
489
+ class je {
527
490
  constructor(t = {}) {
528
491
  this.options = t;
529
492
  }
530
493
  /** Warnings from the last `layout` call, such as ELK options that were not used. */
531
494
  warnings = [];
532
- async layout(t, n = {}) {
533
- const { elk: o, result: s } = await ie(t, {
495
+ async layout(t, r = {}) {
496
+ const { elk: o, result: n } = await oe(t, {
534
497
  ...this.options.defaultLayoutOptions,
535
- ...n.layoutOptions
498
+ ...r.layoutOptions
536
499
  });
537
- return this.warnings = s.warnings, o;
500
+ return this.warnings = n.warnings, o;
538
501
  }
539
502
  knownLayoutAlgorithms() {
540
503
  return Promise.resolve([{ id: "draftably.flow", name: "Draftably flow" }]);
@@ -543,127 +506,127 @@ class Le {
543
506
  }
544
507
  }
545
508
  const v = (e) => typeof e == "number" && e > 0 ? e : void 0, q = (e) => typeof e == "string" ? e : void 0;
546
- function je(e, t = {}) {
547
- const n = e.nodes(), o = (i) => e.parent?.(i) || void 0, s = new Set(n.filter((i) => e.children?.(i)?.length)), d = e.graph() ?? {}, r = q(d.rankdir)?.toUpperCase() ?? "TB", p = e.edges(), c = (i) => `${i.v}->${i.w}${i.name ? `:${i.name}` : ""}`, y = {
509
+ function qe(e, t = {}) {
510
+ const r = e.nodes(), o = (i) => e.parent?.(i) || void 0, n = new Set(r.filter((i) => e.children?.(i)?.length)), a = e.graph() ?? {}, s = q(a.rankdir)?.toUpperCase() ?? "TB", u = e.edges(), l = (i) => `${i.v}->${i.w}${i.name ? `:${i.name}` : ""}`, f = {
548
511
  // dagre never folds a long drawing into rows, and its clusters flow like the rest.
549
512
  fold: "never",
550
- direction: r === "LR" || r === "RL" ? "right" : "down",
551
- ...v(d.ranksep) ? { gap: Math.min(300, Math.max(8, v(d.ranksep))) } : {},
552
- groups: n.filter((i) => s.has(i)).map((i) => ({
513
+ direction: s === "LR" || s === "RL" ? "right" : "down",
514
+ ...v(a.ranksep) ? { gap: Math.min(300, Math.max(8, v(a.ranksep))) } : {},
515
+ groups: r.filter((i) => n.has(i)).map((i) => ({
553
516
  id: i,
554
517
  label: q(e.node(i)?.label) ?? i,
555
518
  parent: o(i),
556
519
  arrange: "flow"
557
520
  })),
558
- nodes: n.filter((i) => !s.has(i)).map((i) => {
559
- const l = e.node(i) ?? {};
521
+ nodes: r.filter((i) => !n.has(i)).map((i) => {
522
+ const c = e.node(i) ?? {};
560
523
  return {
561
524
  id: i,
562
- label: q(l.label) ?? i,
525
+ label: q(c.label) ?? i,
563
526
  parent: o(i),
564
- ...v(l.width) ? { width: v(l.width) } : {},
565
- ...v(l.height) ? { height: v(l.height) } : {}
527
+ ...v(c.width) ? { width: v(c.width) } : {},
528
+ ...v(c.height) ? { height: v(c.height) } : {}
566
529
  };
567
530
  }),
568
- edges: p.map((i) => ({
569
- id: c(i),
531
+ edges: u.map((i) => ({
532
+ id: l(i),
570
533
  source: i.v,
571
534
  target: i.w,
572
535
  label: q(e.edge(i)?.label)
573
536
  })),
574
537
  routing: t.routing
575
538
  };
576
- let f = Q(y);
577
- r === "BT" && (f = D(f, "y")), r === "RL" && (f = D(f, "x")), f = oe(f);
578
- for (const i of n) {
579
- const l = f.nodes[i] ?? f.groups[i], a = e.node(i);
580
- !l || !a || Object.assign(a, {
581
- x: l.x + l.width / 2,
582
- y: l.y + l.height / 2,
583
- width: l.width,
584
- height: l.height
539
+ let h = J(f);
540
+ s === "BT" && (h = R(h, "y")), s === "RL" && (h = R(h, "x")), h = te(h);
541
+ for (const i of r) {
542
+ const c = h.nodes[i] ?? h.groups[i], d = e.node(i);
543
+ !c || !d || Object.assign(d, {
544
+ x: c.x + c.width / 2,
545
+ y: c.y + c.height / 2,
546
+ width: c.width,
547
+ height: c.height
585
548
  });
586
549
  }
587
- for (const i of p) {
588
- const l = f.edges[c(i)], a = e.edge(i);
589
- !l || !a || Object.assign(a, {
590
- points: l.points.map((g) => ({ x: g.x, y: g.y })),
591
- ...l.label ? { x: l.label.x + l.label.width / 2, y: l.label.y + l.label.height / 2 } : {}
550
+ for (const i of u) {
551
+ const c = h.edges[l(i)], d = e.edge(i);
552
+ !c || !d || Object.assign(d, {
553
+ points: c.points.map((g) => ({ x: g.x, y: g.y })),
554
+ ...c.label ? { x: c.label.x + c.label.width / 2, y: c.label.y + c.label.height / 2 } : {}
592
555
  });
593
556
  }
594
- return Object.assign(d, { width: f.bounds.width, height: f.bounds.height }), f;
557
+ return Object.assign(a, { width: h.bounds.width, height: h.bounds.height }), h;
595
558
  }
596
- function z(e) {
559
+ function D(e) {
597
560
  this.options = e;
598
561
  }
599
- z.prototype.run = function() {
600
- const e = this.options, t = e.eles.nodes(), n = (r) => {
601
- const p = r.data("label");
602
- return typeof p == "string" ? p : r.id();
603
- }, o = (r) => r.parent().length ? r.parent().id() : void 0, s = {
562
+ D.prototype.run = function() {
563
+ const e = this.options, t = e.eles.nodes(), r = (s) => {
564
+ const u = s.data("label");
565
+ return typeof u == "string" ? u : s.id();
566
+ }, o = (s) => s.parent().length ? s.parent().id() : void 0, n = {
604
567
  direction: e.direction,
605
568
  gap: e.gap,
606
569
  routing: e.routing,
607
- groups: t.filter((r) => r.isParent()).map((r) => ({ id: r.id(), label: n(r), parent: o(r) })),
608
- nodes: t.filter((r) => !r.isParent()).map((r) => ({
609
- id: r.id(),
610
- label: n(r),
611
- parent: o(r),
612
- width: r.outerWidth(),
613
- height: r.outerHeight()
570
+ groups: t.filter((s) => s.isParent()).map((s) => ({ id: s.id(), label: r(s), parent: o(s) })),
571
+ nodes: t.filter((s) => !s.isParent()).map((s) => ({
572
+ id: s.id(),
573
+ label: r(s),
574
+ parent: o(s),
575
+ width: s.outerWidth(),
576
+ height: s.outerHeight()
614
577
  })),
615
- edges: e.eles.edges().map((r) => ({
616
- id: r.id(),
617
- source: r.source().id(),
618
- target: r.target().id(),
619
- label: typeof r.data("label") == "string" ? r.data("label") : void 0
578
+ edges: e.eles.edges().map((s) => ({
579
+ id: s.id(),
580
+ source: s.source().id(),
581
+ target: s.target().id(),
582
+ label: typeof s.data("label") == "string" ? s.data("label") : void 0
620
583
  }))
621
- }, d = Q(s);
622
- return this.result = d, t.layoutPositions(this, { fit: !0, padding: 30, animate: !1, ...e }, (r) => {
623
- const p = d.nodes[r.id()] ?? d.groups[r.id()];
624
- return p ? { x: p.x + p.width / 2, y: p.y + p.height / 2 } : { x: 0, y: 0 };
584
+ }, a = J(n);
585
+ return this.result = a, t.layoutPositions(this, { fit: !0, padding: 30, animate: !1, ...e }, (s) => {
586
+ const u = a.nodes[s.id()] ?? a.groups[s.id()];
587
+ return u ? { x: u.x + u.width / 2, y: u.y + u.height / 2 } : { x: 0, y: 0 };
625
588
  }), this;
626
589
  };
627
- z.prototype.stop = function() {
590
+ D.prototype.stop = function() {
628
591
  return this;
629
592
  };
630
- function qe(e) {
631
- e("layout", "draftably", z);
593
+ function Fe(e) {
594
+ e("layout", "draftably", D);
632
595
  }
633
- async function Fe(e) {
596
+ async function Ne(e) {
634
597
  if ("elk" in e) {
635
- const { elk: t, ...n } = e;
636
- return ie(t, void 0, n);
598
+ const { elk: t, ...r } = e;
599
+ return oe(t, void 0, r);
637
600
  }
638
601
  for (const t of ["reactFlow", "svelteFlow"])
639
602
  if (t in e) {
640
603
  const {
641
- [t]: n,
604
+ [t]: r,
642
605
  shape: o,
643
- ...s
644
- } = e, d = await T({ ...Y(n, { shape: o }), ...s });
645
- return { [t]: me(n, d, t === "svelteFlow"), result: d };
606
+ ...n
607
+ } = e, a = await T({ ...X(r, { shape: o }), ...n });
608
+ return { [t]: me(r, a, t === "svelteFlow"), result: a };
646
609
  }
647
610
  return T(e);
648
611
  }
649
- function Ne(e) {
612
+ function Pe(e) {
650
613
  for (const t of ["reactFlow", "svelteFlow"])
651
614
  if (t in e) {
652
615
  const {
653
- [t]: n,
616
+ [t]: r,
654
617
  shape: o,
655
- routing: s
656
- } = e, d = W({ ...xe(n, { shape: o }), routing: s });
657
- return { [t]: { nodes: n.nodes, edges: Se(n.edges, d) }, result: d };
618
+ routing: n
619
+ } = e, a = U({ ...Se(r, { shape: o }), routing: n });
620
+ return { [t]: { nodes: r.nodes, edges: ke(r.edges, a) }, result: a };
658
621
  }
659
- return W(e);
622
+ return U(e);
660
623
  }
661
624
  export {
662
625
  ge as AUTO_FULL_LIMIT,
663
- Le as DraftablyELK,
664
- je as dagreLayout,
665
- qe as draftablyLayout,
666
- Fe as layout,
667
- Q as layoutSync,
668
- Ne as route
626
+ je as DraftablyELK,
627
+ qe as dagreLayout,
628
+ Fe as draftablyLayout,
629
+ Ne as layout,
630
+ J as layoutSync,
631
+ Pe as route
669
632
  };