@sourcegraph/amp 0.0.1749585689-g82b91d → 0.0.1749600114-g5c00b8

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 (61) hide show
  1. package/dist/amp.js +3 -3
  2. package/dist/architectureDiagram-RWNHDUBN-1v8WgxdD.js +4635 -0
  3. package/dist/blockDiagram-XZSR5OGQ-XFBYN-jB.js +2243 -0
  4. package/dist/c4Diagram-6R2MQUNL-B0L0pltn.js +1587 -0
  5. package/dist/chunk-COUQ6RZ3-qd4eG6tc.js +17852 -0
  6. package/dist/chunk-CRQPXCKQ-yjI467Bq.js +65 -0
  7. package/dist/chunk-EFPBJHX4-DdHmqd0M.js +1378 -0
  8. package/dist/chunk-EOAU2GW5-CpRNAcjo.js +253 -0
  9. package/dist/chunk-IHYUGLNO-DJcRQIf7.js +1365 -0
  10. package/dist/chunk-K2ZEYYM2-CbqHhUqy.js +9 -0
  11. package/dist/chunk-Q7VUVKE6-gBSSbdjU.js +24 -0
  12. package/dist/chunk-T2M37SMK-Br8mK30k.js +1411 -0
  13. package/dist/chunk-TGZYFRKZ-BYBLXoJz.js +1331 -0
  14. package/dist/chunk-YJGJQOYZ-BGiSkWF0.js +19 -0
  15. package/dist/classDiagram-LB37KKQG-DhFsEyDS.js +17 -0
  16. package/dist/classDiagram-v2-KFQJBC22-DhFsEyDS.js +17 -0
  17. package/dist/{client-C1WG2nEf.js → client-D-YAg8x6.js} +6 -6
  18. package/dist/{console-DK0gDzNQ.js → console-CoE5Qzyz.js} +41106 -22971
  19. package/dist/create_file.node-Co0Uh1F3.js +21 -0
  20. package/dist/dagre-CMTPJJKG-UDPzd9Iy.js +446 -0
  21. package/dist/diagram-BIPOGRU5-B7TV59-n.js +128 -0
  22. package/dist/diagram-YF4VECWA-LsAZsciQ.js +219 -0
  23. package/dist/{edit_file.node-BH524GkF.js → edit_file.node-CmTZeBc2.js} +11 -11
  24. package/dist/erDiagram-AK44R45H-BWpeEu7D.js +843 -0
  25. package/dist/{executable-5cBRGrsC.js → executable-BE7tfoX5.js} +1 -1
  26. package/dist/{files-CybxYgbE.js → files-DqpRf5q4.js} +10 -10
  27. package/dist/flowDiagram-XARHJDSH-DzpV02UB.js +1618 -0
  28. package/dist/ganttDiagram-H5QQZTZ5-C0BhJTzn.js +1605 -0
  29. package/dist/gitGraphDiagram-XHLTLO3W-0EiOmv44.js +701 -0
  30. package/dist/{glob.node-C6HbLuPt.js → glob.node-DNei8bFS.js} +11 -11
  31. package/dist/{index-C2wo7rRZ.js → index-BcjxaWOc.js} +31 -31
  32. package/dist/infoDiagram-TP2HPDHO-CQX5a0Fc.js +24 -0
  33. package/dist/journeyDiagram-VHRN44N3-C82dEe4G.js +809 -0
  34. package/dist/kanban-definition-K5J3OUUV-xilJcrom.js +718 -0
  35. package/dist/katex-5N2NCDMP-CAsrnb6_.js +11703 -0
  36. package/dist/{list_directory.node-ZQscizpi.js → list_directory.node-CMiNNbXP.js} +1 -1
  37. package/dist/{load-profile-BbmyxO_7.js → load-profile-Cg8XaTx6.js} +1 -1
  38. package/dist/{main-CiUaVPC2.js → main-Dy2VZM_S.js} +15 -15
  39. package/dist/mindmap-definition-TI5ONXTW-BNaRba4R.js +3221 -0
  40. package/dist/{node-DvmQAW7h.js → node-BtG1o_DD.js} +2 -2
  41. package/dist/{node-VrazB_nQ.js → node-BulbxvrV.js} +58 -58
  42. package/dist/{node-Cpbjmhrj.js → node-Cp3D7_hw.js} +71 -71
  43. package/dist/{node-GgocwWwI.js → node-CtoBdTQT.js} +3 -3
  44. package/dist/{node-CiFAW-F3.js → node-Ctw1i0nl.js} +12 -12
  45. package/dist/{node-CgVq0JJ9.js → node-D1zxOCuN.js} +1 -1
  46. package/dist/pieDiagram-FPR3CNQC-_30_tQz0.js +120 -0
  47. package/dist/quadrantDiagram-RLP5YTJ2-CTD43GTk.js +1028 -0
  48. package/dist/radar-MK3ICKWK-55CS4JTO-afihMdR4.js +14398 -0
  49. package/dist/{read_file.node-CIdAFiJ6.js → read_file.node-QZ0VCmB2.js} +1 -1
  50. package/dist/requirementDiagram-P5NVWGNK-Sd2_6g8e.js +853 -0
  51. package/dist/sankeyDiagram-C6NZRJHT-D1EcCYaw.js +864 -0
  52. package/dist/sequenceDiagram-6SLVIXKN-CghQTpGf.js +2283 -0
  53. package/dist/stateDiagram-WI5ZVJ5I-Bv21MlSK.js +272 -0
  54. package/dist/stateDiagram-v2-KVDSFUFK-BgP0D8xL.js +17 -0
  55. package/dist/{stdio-D9HyubOc.js → stdio-CCCGI3C7.js} +8 -8
  56. package/dist/storybook.js +7 -7
  57. package/dist/timeline-definition-65575674-BUqRZdJ-.js +800 -0
  58. package/dist/{undo_edit.node-VYuTxRwd.js → undo_edit.node-BkletvTZ.js} +5 -5
  59. package/dist/xychartDiagram-674MFTBU-DjBabATx.js +1291 -0
  60. package/package.json +1 -1
  61. package/dist/create_file.node-DtVTaHj5.js +0 -21
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ import p from "node:path";
3
+ import { b as u, d as f, r as l } from "./console-CoE5Qzyz.js";
4
+ const w = ({ args: t }, { dir: n, dirs: a, trackFileChange: c, filesystem: r }) => u(async (e) => {
5
+ if (f(n), typeof t.content != "string")
6
+ throw new Error("create_file: content must be specified");
7
+ e.throwIfAborted();
8
+ const o = await l(r, a, t.path, e), i = p.dirname(o);
9
+ await r.mkdirp(i, e);
10
+ const s = t.content;
11
+ return await c(o, async (d) => {
12
+ await r.writeFile(d, s, e);
13
+ }), {
14
+ status: "done",
15
+ result: `Successfully created file ${t.path}`,
16
+ files: [t.path]
17
+ };
18
+ });
19
+ export {
20
+ w as nodeCreateFileTool
21
+ };
@@ -0,0 +1,446 @@
1
+ #!/usr/bin/env node
2
+ import { l as F } from "./chunk-IHYUGLNO-DJcRQIf7.js";
3
+ import { G as k } from "./chunk-EOAU2GW5-CpRNAcjo.js";
4
+ import { _ as g, bS as H, bT as V, bU as U, bV as W, A as i, y as Z, bW as $, bX as q, bC as z, bH as K, bD as P, bB as Q, bY as I, bZ as L, b_ as ee } from "./console-CoE5Qzyz.js";
5
+ import { i as N, B as ne, b as A } from "./chunk-TGZYFRKZ-BYBLXoJz.js";
6
+ function h(e) {
7
+ var t = {
8
+ options: {
9
+ directed: e.isDirected(),
10
+ multigraph: e.isMultigraph(),
11
+ compound: e.isCompound()
12
+ },
13
+ nodes: J(e),
14
+ edges: T(e)
15
+ };
16
+ return N(e.graph()) || (t.value = ne(e.graph())), t;
17
+ }
18
+ g(h, "write");
19
+ function J(e) {
20
+ return A(e.nodes(), function(t) {
21
+ var n = e.node(t), a = e.parent(t), r = { v: t };
22
+ return N(n) || (r.value = n), N(a) || (r.parent = a), r;
23
+ });
24
+ }
25
+ g(J, "writeNodes");
26
+ function T(e) {
27
+ return A(e.edges(), function(t) {
28
+ var n = e.edge(t), a = { v: t.v, w: t.w };
29
+ return N(t.name) || (a.name = t.name), N(n) || (a.value = n), a;
30
+ });
31
+ }
32
+ g(T, "writeEdges");
33
+ var d = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), G = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ g(() => {
34
+ X.clear(), G.clear(), d.clear();
35
+ }, "clear"), D = /* @__PURE__ */ g((e, t) => {
36
+ const n = X.get(t) || [];
37
+ return i.trace("In isDescendant", t, " ", e, " = ", n.includes(e)), n.includes(e);
38
+ }, "isDescendant"), se = /* @__PURE__ */ g((e, t) => {
39
+ const n = X.get(t) || [];
40
+ return i.info("Descendants of ", t, " is ", n), i.info("Edge is ", e), e.v === t || e.w === t ? !1 : n ? n.includes(e.v) || D(e.v, t) || D(e.w, t) || n.includes(e.w) : (i.debug("Tilt, ", t, ",not in descendants"), !1);
41
+ }, "edgeInCluster"), R = /* @__PURE__ */ g((e, t, n, a) => {
42
+ i.warn(
43
+ "Copying children of ",
44
+ e,
45
+ "root",
46
+ a,
47
+ "data",
48
+ t.node(e),
49
+ a
50
+ );
51
+ const r = t.children(e) || [];
52
+ e !== a && r.push(e), i.warn("Copying (nodes) clusterId", e, "nodes", r), r.forEach((o) => {
53
+ if (t.children(o).length > 0)
54
+ R(o, t, n, a);
55
+ else {
56
+ const l = t.node(o);
57
+ i.info("cp ", o, " to ", a, " with parent ", e), n.setNode(o, l), a !== t.parent(o) && (i.warn("Setting parent", o, t.parent(o)), n.setParent(o, t.parent(o))), e !== a && o !== e ? (i.debug("Setting parent", o, e), n.setParent(o, e)) : (i.info("In copy ", e, "root", a, "data", t.node(e), a), i.debug(
58
+ "Not Setting parent for node=",
59
+ o,
60
+ "cluster!==rootId",
61
+ e !== a,
62
+ "node!==clusterId",
63
+ o !== e
64
+ ));
65
+ const u = t.edges(o);
66
+ i.debug("Copying Edges", u), u.forEach((c) => {
67
+ i.info("Edge", c);
68
+ const m = t.edge(c.v, c.w, c.name);
69
+ i.info("Edge data", m, a);
70
+ try {
71
+ se(c, a) ? (i.info("Copying as ", c.v, c.w, m, c.name), n.setEdge(c.v, c.w, m, c.name), i.info("newGraph edges ", n.edges(), n.edge(n.edges()[0]))) : i.info(
72
+ "Skipping copy of edge ",
73
+ c.v,
74
+ "-->",
75
+ c.w,
76
+ " rootId: ",
77
+ a,
78
+ " clusterId:",
79
+ e
80
+ );
81
+ } catch (v) {
82
+ i.error(v);
83
+ }
84
+ });
85
+ }
86
+ i.debug("Removing node", o), t.removeNode(o);
87
+ });
88
+ }, "copy"), _ = /* @__PURE__ */ g((e, t) => {
89
+ const n = t.children(e);
90
+ let a = [...n];
91
+ for (const r of n)
92
+ G.set(r, e), a = [...a, ..._(r, t)];
93
+ return a;
94
+ }, "extractDescendants"), ie = /* @__PURE__ */ g((e, t, n) => {
95
+ const a = e.edges().filter((c) => c.v === t || c.w === t), r = e.edges().filter((c) => c.v === n || c.w === n), o = a.map((c) => ({ v: c.v === t ? n : c.v, w: c.w === t ? t : c.w })), l = r.map((c) => ({ v: c.v, w: c.w }));
96
+ return o.filter((c) => l.some((m) => c.v === m.v && c.w === m.w));
97
+ }, "findCommonEdges"), C = /* @__PURE__ */ g((e, t, n) => {
98
+ const a = t.children(e);
99
+ if (i.trace("Searching children of id ", e, a), a.length < 1)
100
+ return e;
101
+ let r;
102
+ for (const o of a) {
103
+ const l = C(o, t, n), u = ie(t, n, l);
104
+ if (l)
105
+ if (u.length > 0)
106
+ r = l;
107
+ else
108
+ return l;
109
+ }
110
+ return r;
111
+ }, "findNonClusterChild"), B = /* @__PURE__ */ g((e) => !d.has(e) || !d.get(e).externalConnections ? e : d.has(e) ? d.get(e).id : e, "getAnchorId"), re = /* @__PURE__ */ g((e, t) => {
112
+ if (!e || t > 10) {
113
+ i.debug("Opting out, no graph ");
114
+ return;
115
+ } else
116
+ i.debug("Opting in, graph ");
117
+ e.nodes().forEach(function(n) {
118
+ e.children(n).length > 0 && (i.warn(
119
+ "Cluster identified",
120
+ n,
121
+ " Replacement id in edges: ",
122
+ C(n, e, n)
123
+ ), X.set(n, _(n, e)), d.set(n, { id: C(n, e, n), clusterData: e.node(n) }));
124
+ }), e.nodes().forEach(function(n) {
125
+ const a = e.children(n), r = e.edges();
126
+ a.length > 0 ? (i.debug("Cluster identified", n, X), r.forEach((o) => {
127
+ const l = D(o.v, n), u = D(o.w, n);
128
+ l ^ u && (i.warn("Edge: ", o, " leaves cluster ", n), i.warn("Descendants of XXX ", n, ": ", X.get(n)), d.get(n).externalConnections = !0);
129
+ })) : i.debug("Not a cluster ", n, X);
130
+ });
131
+ for (let n of d.keys()) {
132
+ const a = d.get(n).id, r = e.parent(a);
133
+ r !== n && d.has(r) && !d.get(r).externalConnections && (d.get(n).id = r);
134
+ }
135
+ e.edges().forEach(function(n) {
136
+ const a = e.edge(n);
137
+ i.warn("Edge " + n.v + " -> " + n.w + ": " + JSON.stringify(n)), i.warn("Edge " + n.v + " -> " + n.w + ": " + JSON.stringify(e.edge(n)));
138
+ let r = n.v, o = n.w;
139
+ if (i.warn(
140
+ "Fix XXX",
141
+ d,
142
+ "ids:",
143
+ n.v,
144
+ n.w,
145
+ "Translating: ",
146
+ d.get(n.v),
147
+ " --- ",
148
+ d.get(n.w)
149
+ ), d.get(n.v) || d.get(n.w)) {
150
+ if (i.warn("Fixing and trying - removing XXX", n.v, n.w, n.name), r = B(n.v), o = B(n.w), e.removeEdge(n.v, n.w, n.name), r !== n.v) {
151
+ const l = e.parent(r);
152
+ d.get(l).externalConnections = !0, a.fromCluster = n.v;
153
+ }
154
+ if (o !== n.w) {
155
+ const l = e.parent(o);
156
+ d.get(l).externalConnections = !0, a.toCluster = n.w;
157
+ }
158
+ i.warn("Fix Replacing with XXX", r, o, n.name), e.setEdge(r, o, a, n.name);
159
+ }
160
+ }), i.warn("Adjusted Graph", h(e)), M(e, 0), i.trace(d);
161
+ }, "adjustClustersAndEdges"), M = /* @__PURE__ */ g((e, t) => {
162
+ if (i.warn("extractor - ", t, h(e), e.children("D")), t > 10) {
163
+ i.error("Bailing out");
164
+ return;
165
+ }
166
+ let n = e.nodes(), a = !1;
167
+ for (const r of n) {
168
+ const o = e.children(r);
169
+ a = a || o.length > 0;
170
+ }
171
+ if (!a) {
172
+ i.debug("Done, no node has children", e.nodes());
173
+ return;
174
+ }
175
+ i.debug("Nodes = ", n, t);
176
+ for (const r of n)
177
+ if (i.debug(
178
+ "Extracting node",
179
+ r,
180
+ d,
181
+ d.has(r) && !d.get(r).externalConnections,
182
+ !e.parent(r),
183
+ e.node(r),
184
+ e.children("D"),
185
+ " Depth ",
186
+ t
187
+ ), !d.has(r))
188
+ i.debug("Not a cluster", r, t);
189
+ else if (!d.get(r).externalConnections && e.children(r) && e.children(r).length > 0) {
190
+ i.warn(
191
+ "Cluster without external connections, without a parent and with children",
192
+ r,
193
+ t
194
+ );
195
+ let l = e.graph().rankdir === "TB" ? "LR" : "TB";
196
+ d.get(r)?.clusterData?.dir && (l = d.get(r).clusterData.dir, i.warn("Fixing dir", d.get(r).clusterData.dir, l));
197
+ const u = new k({
198
+ multigraph: !0,
199
+ compound: !0
200
+ }).setGraph({
201
+ rankdir: l,
202
+ nodesep: 50,
203
+ ranksep: 50,
204
+ marginx: 8,
205
+ marginy: 8
206
+ }).setDefaultEdgeLabel(function() {
207
+ return {};
208
+ });
209
+ i.warn("Old graph before copy", h(e)), R(r, e, u, r), e.setNode(r, {
210
+ clusterNode: !0,
211
+ id: r,
212
+ clusterData: d.get(r).clusterData,
213
+ label: d.get(r).label,
214
+ graph: u
215
+ }), i.warn("New graph after copy node: (", r, ")", h(u)), i.debug("Old graph after copy", h(e));
216
+ } else
217
+ i.warn(
218
+ "Cluster ** ",
219
+ r,
220
+ " **not meeting the criteria !externalConnections:",
221
+ !d.get(r).externalConnections,
222
+ " no parent: ",
223
+ !e.parent(r),
224
+ " children ",
225
+ e.children(r) && e.children(r).length > 0,
226
+ e.children("D"),
227
+ t
228
+ ), i.debug(d);
229
+ n = e.nodes(), i.warn("New list of nodes", n);
230
+ for (const r of n) {
231
+ const o = e.node(r);
232
+ i.warn(" Now next level", r, o), o?.clusterNode && M(o.graph, t + 1);
233
+ }
234
+ }, "extractor"), Y = /* @__PURE__ */ g((e, t) => {
235
+ if (t.length === 0)
236
+ return [];
237
+ let n = Object.assign([], t);
238
+ return t.forEach((a) => {
239
+ const r = e.children(a), o = Y(e, r);
240
+ n = [...n, ...o];
241
+ }), n;
242
+ }, "sorter"), oe = /* @__PURE__ */ g((e) => Y(e, e.children()), "sortNodesByHierarchy"), j = /* @__PURE__ */ g(async (e, t, n, a, r, o) => {
243
+ i.warn("Graph in recursive render:XAX", h(t), r);
244
+ const l = t.graph().rankdir;
245
+ i.trace("Dir in recursive render - dir:", l);
246
+ const u = e.insert("g").attr("class", "root");
247
+ t.nodes() ? i.info("Recursive render XXX", t.nodes()) : i.info("No nodes found for", t), t.edges().length > 0 && i.info("Recursive edges", t.edge(t.edges()[0]));
248
+ const c = u.insert("g").attr("class", "clusters"), m = u.insert("g").attr("class", "edgePaths"), v = u.insert("g").attr("class", "edgeLabels"), b = u.insert("g").attr("class", "nodes");
249
+ await Promise.all(
250
+ t.nodes().map(async function(f) {
251
+ const s = t.node(f);
252
+ if (r !== void 0) {
253
+ const w = JSON.parse(JSON.stringify(r.clusterData));
254
+ i.trace(
255
+ `Setting data for parent cluster XXX
256
+ Node.id = `,
257
+ f,
258
+ `
259
+ data=`,
260
+ w.height,
261
+ `
262
+ Parent cluster`,
263
+ r.height
264
+ ), t.setNode(r.id, w), t.parent(f) || (i.trace("Setting parent", f, r.id), t.setParent(f, r.id, w));
265
+ }
266
+ if (i.info("(Insert) Node XXX" + f + ": " + JSON.stringify(t.node(f))), s?.clusterNode) {
267
+ i.info("Cluster identified XBX", f, s.width, t.node(f));
268
+ const { ranksep: w, nodesep: E } = t.graph();
269
+ s.graph.setGraph({
270
+ ...s.graph.graph(),
271
+ ranksep: w + 25,
272
+ nodesep: E
273
+ });
274
+ const p = await j(
275
+ b,
276
+ s.graph,
277
+ n,
278
+ a,
279
+ t.node(f),
280
+ o
281
+ ), x = p.elem;
282
+ $(s, x), s.diff = p.diff || 0, i.info(
283
+ "New compound node after recursive render XAX",
284
+ f,
285
+ "width",
286
+ // node,
287
+ s.width,
288
+ "height",
289
+ s.height
290
+ // node.x,
291
+ // node.y
292
+ ), q(x, s);
293
+ } else
294
+ t.children(f).length > 0 ? (i.trace(
295
+ "Cluster - the non recursive path XBX",
296
+ f,
297
+ s.id,
298
+ s,
299
+ s.width,
300
+ "Graph:",
301
+ t
302
+ ), i.trace(C(s.id, t)), d.set(s.id, { id: C(s.id, t), node: s })) : (i.trace("Node - the non recursive path XAX", f, b, t.node(f), l), await z(b, t.node(f), { config: o, dir: l }));
303
+ })
304
+ ), await (/* @__PURE__ */ g(async () => {
305
+ const f = t.edges().map(async function(s) {
306
+ const w = t.edge(s.v, s.w, s.name);
307
+ i.info("Edge " + s.v + " -> " + s.w + ": " + JSON.stringify(s)), i.info("Edge " + s.v + " -> " + s.w + ": ", s, " ", JSON.stringify(t.edge(s))), i.info(
308
+ "Fix",
309
+ d,
310
+ "ids:",
311
+ s.v,
312
+ s.w,
313
+ "Translating: ",
314
+ d.get(s.v),
315
+ d.get(s.w)
316
+ ), await ee(v, w);
317
+ });
318
+ await Promise.all(f);
319
+ }, "processEdges"))(), i.info("Graph before layout:", JSON.stringify(h(t))), i.info("############################################# XXX"), i.info("### Layout ### XXX"), i.info("############################################# XXX"), F(t), i.info("Graph after layout:", JSON.stringify(h(t)));
320
+ let O = 0, { subGraphTitleTotalMargin: S } = K(o);
321
+ return await Promise.all(
322
+ oe(t).map(async function(f) {
323
+ const s = t.node(f);
324
+ if (i.info(
325
+ "Position XBX => " + f + ": (" + s.x,
326
+ "," + s.y,
327
+ ") width: ",
328
+ s.width,
329
+ " height: ",
330
+ s.height
331
+ ), s?.clusterNode)
332
+ s.y += S, i.info(
333
+ "A tainted cluster node XBX1",
334
+ f,
335
+ s.id,
336
+ s.width,
337
+ s.height,
338
+ s.x,
339
+ s.y,
340
+ t.parent(f)
341
+ ), d.get(s.id).node = s, P(s);
342
+ else if (t.children(f).length > 0) {
343
+ i.info(
344
+ "A pure cluster node XBX1",
345
+ f,
346
+ s.id,
347
+ s.x,
348
+ s.y,
349
+ s.width,
350
+ s.height,
351
+ t.parent(f)
352
+ ), s.height += S, t.node(s.parentId);
353
+ const w = s?.padding / 2 || 0, E = s?.labelBBox?.height || 0, p = E - w || 0;
354
+ i.debug("OffsetY", p, "labelHeight", E, "halfPadding", w), await Q(c, s), d.get(s.id).node = s;
355
+ } else {
356
+ const w = t.node(s.parentId);
357
+ s.y += S / 2, i.info(
358
+ "A regular node XBX1 - using the padding",
359
+ s.id,
360
+ "parent",
361
+ s.parentId,
362
+ s.width,
363
+ s.height,
364
+ s.x,
365
+ s.y,
366
+ "offsetY",
367
+ s.offsetY,
368
+ "parent",
369
+ w,
370
+ w?.offsetY,
371
+ s
372
+ ), P(s);
373
+ }
374
+ })
375
+ ), t.edges().forEach(function(f) {
376
+ const s = t.edge(f);
377
+ i.info("Edge " + f.v + " -> " + f.w + ": " + JSON.stringify(s), s), s.points.forEach((x) => x.y += S / 2);
378
+ const w = t.node(f.v);
379
+ var E = t.node(f.w);
380
+ const p = I(m, s, d, n, w, E, a);
381
+ L(s, p);
382
+ }), t.nodes().forEach(function(f) {
383
+ const s = t.node(f);
384
+ i.info(f, s.type, s.diff), s.isGroup && (O = s.diff);
385
+ }), i.warn("Returning from recursive render XAX", u, O), { elem: u, diff: O };
386
+ }, "recursiveRender"), fe = /* @__PURE__ */ g(async (e, t) => {
387
+ const n = new k({
388
+ multigraph: !0,
389
+ compound: !0
390
+ }).setGraph({
391
+ rankdir: e.direction,
392
+ nodesep: e.config?.nodeSpacing || e.config?.flowchart?.nodeSpacing || e.nodeSpacing,
393
+ ranksep: e.config?.rankSpacing || e.config?.flowchart?.rankSpacing || e.rankSpacing,
394
+ marginx: 8,
395
+ marginy: 8
396
+ }).setDefaultEdgeLabel(function() {
397
+ return {};
398
+ }), a = t.select("g");
399
+ H(a, e.markers, e.type, e.diagramId), V(), U(), W(), te(), e.nodes.forEach((o) => {
400
+ n.setNode(o.id, { ...o }), o.parentId && n.setParent(o.id, o.parentId);
401
+ }), i.debug("Edges:", e.edges), e.edges.forEach((o) => {
402
+ if (o.start === o.end) {
403
+ const l = o.start, u = l + "---" + l + "---1", c = l + "---" + l + "---2", m = n.node(l);
404
+ n.setNode(u, {
405
+ domId: u,
406
+ id: u,
407
+ parentId: m.parentId,
408
+ labelStyle: "",
409
+ label: "",
410
+ padding: 0,
411
+ shape: "labelRect",
412
+ // shape: 'rect',
413
+ style: "",
414
+ width: 10,
415
+ height: 10
416
+ }), n.setParent(u, m.parentId), n.setNode(c, {
417
+ domId: c,
418
+ id: c,
419
+ parentId: m.parentId,
420
+ labelStyle: "",
421
+ padding: 0,
422
+ // shape: 'rect',
423
+ shape: "labelRect",
424
+ label: "",
425
+ style: "",
426
+ width: 10,
427
+ height: 10
428
+ }), n.setParent(c, m.parentId);
429
+ const v = structuredClone(o), b = structuredClone(o), y = structuredClone(o);
430
+ v.label = "", v.arrowTypeEnd = "none", v.id = l + "-cyclic-special-1", b.arrowTypeStart = "none", b.arrowTypeEnd = "none", b.id = l + "-cyclic-special-mid", y.label = "", m.isGroup && (v.fromCluster = l, y.toCluster = l), y.id = l + "-cyclic-special-2", y.arrowTypeStart = "none", n.setEdge(l, u, v, l + "-cyclic-special-0"), n.setEdge(u, c, b, l + "-cyclic-special-1"), n.setEdge(c, l, y, l + "-cyc<lic-special-2");
431
+ } else
432
+ n.setEdge(o.start, o.end, { ...o }, o.id);
433
+ }), i.warn("Graph at first:", JSON.stringify(h(n))), re(n), i.warn("Graph after XAX:", JSON.stringify(h(n)));
434
+ const r = Z();
435
+ await j(
436
+ a,
437
+ n,
438
+ e.type,
439
+ e.diagramId,
440
+ void 0,
441
+ r
442
+ );
443
+ }, "render");
444
+ export {
445
+ fe as render
446
+ };
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env node
2
+ import { p as y } from "./chunk-K2ZEYYM2-CbqHhUqy.js";
3
+ import { p as B } from "./radar-MK3ICKWK-55CS4JTO-afihMdR4.js";
4
+ import { _ as n, u as S, v as F, U as z, T as P, w as T, x as W, a4 as x, av as A, C as D, Z as _, a5 as E, a6 as N, A as m } from "./console-CoE5Qzyz.js";
5
+ import "./chunk-TGZYFRKZ-BYBLXoJz.js";
6
+ var C = {
7
+ packet: []
8
+ }, v = structuredClone(C), L = N.packet, Y = /* @__PURE__ */ n(() => {
9
+ const t = x({
10
+ ...L,
11
+ ...E().packet
12
+ });
13
+ return t.showBits && (t.paddingY += 10), t;
14
+ }, "getConfig"), I = /* @__PURE__ */ n(() => v.packet, "getPacket"), M = /* @__PURE__ */ n((t) => {
15
+ t.length > 0 && v.packet.push(t);
16
+ }, "pushWord"), O = /* @__PURE__ */ n(() => {
17
+ _(), v = structuredClone(C);
18
+ }, "clear"), h = {
19
+ pushWord: M,
20
+ getPacket: I,
21
+ getConfig: Y,
22
+ clear: O,
23
+ setAccTitle: W,
24
+ getAccTitle: T,
25
+ setDiagramTitle: P,
26
+ getDiagramTitle: z,
27
+ getAccDescription: F,
28
+ setAccDescription: S
29
+ }, U = 1e4, G = /* @__PURE__ */ n((t) => {
30
+ y(t, h);
31
+ let e = -1, o = [], s = 1;
32
+ const { bitsPerRow: i } = h.getConfig();
33
+ for (let { start: a, end: r, label: p } of t.blocks) {
34
+ if (r && r < a)
35
+ throw new Error(`Packet block ${a} - ${r} is invalid. End must be greater than start.`);
36
+ if (a !== e + 1)
37
+ throw new Error(
38
+ `Packet block ${a} - ${r ?? a} is not contiguous. It should start from ${e + 1}.`
39
+ );
40
+ for (e = r ?? a, m.debug(`Packet block ${a} - ${e} with label ${p}`); o.length <= i + 1 && h.getPacket().length < U; ) {
41
+ const [b, c] = H({ start: a, end: r, label: p }, s, i);
42
+ if (o.push(b), b.end + 1 === s * i && (h.pushWord(o), o = [], s++), !c)
43
+ break;
44
+ ({ start: a, end: r, label: p } = c);
45
+ }
46
+ }
47
+ h.pushWord(o);
48
+ }, "populate"), H = /* @__PURE__ */ n((t, e, o) => {
49
+ if (t.end === void 0 && (t.end = t.start), t.start > t.end)
50
+ throw new Error(`Block start ${t.start} is greater than block end ${t.end}.`);
51
+ return t.end + 1 <= e * o ? [t, void 0] : [
52
+ {
53
+ start: t.start,
54
+ end: e * o - 1,
55
+ label: t.label
56
+ },
57
+ {
58
+ start: e * o,
59
+ end: t.end,
60
+ label: t.label
61
+ }
62
+ ];
63
+ }, "getNextFittingBlock"), K = {
64
+ parse: /* @__PURE__ */ n(async (t) => {
65
+ const e = await B("packet", t);
66
+ m.debug(e), G(e);
67
+ }, "parse")
68
+ }, R = /* @__PURE__ */ n((t, e, o, s) => {
69
+ const i = s.db, a = i.getConfig(), { rowHeight: r, paddingY: p, bitWidth: b, bitsPerRow: c } = a, u = i.getPacket(), l = i.getDiagramTitle(), g = r + p, d = g * (u.length + 1) - (l ? 0 : r), k = b * c + 2, f = A(e);
70
+ f.attr("viewbox", `0 0 ${k} ${d}`), D(f, d, k, a.useMaxWidth);
71
+ for (const [$, w] of u.entries())
72
+ X(f, w, $, a);
73
+ f.append("text").text(l).attr("x", k / 2).attr("y", d - g / 2).attr("dominant-baseline", "middle").attr("text-anchor", "middle").attr("class", "packetTitle");
74
+ }, "draw"), X = /* @__PURE__ */ n((t, e, o, { rowHeight: s, paddingX: i, paddingY: a, bitWidth: r, bitsPerRow: p, showBits: b }) => {
75
+ const c = t.append("g"), u = o * (s + a) + a;
76
+ for (const l of e) {
77
+ const g = l.start % p * r + 1, d = (l.end - l.start + 1) * r - i;
78
+ if (c.append("rect").attr("x", g).attr("y", u).attr("width", d).attr("height", s).attr("class", "packetBlock"), c.append("text").attr("x", g + d / 2).attr("y", u + s / 2).attr("class", "packetLabel").attr("dominant-baseline", "middle").attr("text-anchor", "middle").text(l.label), !b)
79
+ continue;
80
+ const k = l.end === l.start, f = u - 2;
81
+ c.append("text").attr("x", g + (k ? d / 2 : 0)).attr("y", f).attr("class", "packetByte start").attr("dominant-baseline", "auto").attr("text-anchor", k ? "middle" : "start").text(l.start), k || c.append("text").attr("x", g + d).attr("y", f).attr("class", "packetByte end").attr("dominant-baseline", "auto").attr("text-anchor", "end").text(l.end);
82
+ }
83
+ }, "drawWord"), Z = { draw: R }, j = {
84
+ byteFontSize: "10px",
85
+ startByteColor: "black",
86
+ endByteColor: "black",
87
+ labelColor: "black",
88
+ labelFontSize: "12px",
89
+ titleColor: "black",
90
+ titleFontSize: "14px",
91
+ blockStrokeColor: "black",
92
+ blockStrokeWidth: "1",
93
+ blockFillColor: "#efefef"
94
+ }, q = /* @__PURE__ */ n(({ packet: t } = {}) => {
95
+ const e = x(j, t);
96
+ return `
97
+ .packetByte {
98
+ font-size: ${e.byteFontSize};
99
+ }
100
+ .packetByte.start {
101
+ fill: ${e.startByteColor};
102
+ }
103
+ .packetByte.end {
104
+ fill: ${e.endByteColor};
105
+ }
106
+ .packetLabel {
107
+ fill: ${e.labelColor};
108
+ font-size: ${e.labelFontSize};
109
+ }
110
+ .packetTitle {
111
+ fill: ${e.titleColor};
112
+ font-size: ${e.titleFontSize};
113
+ }
114
+ .packetBlock {
115
+ stroke: ${e.blockStrokeColor};
116
+ stroke-width: ${e.blockStrokeWidth};
117
+ fill: ${e.blockFillColor};
118
+ }
119
+ `;
120
+ }, "styles"), et = {
121
+ parser: K,
122
+ db: h,
123
+ renderer: Z,
124
+ styles: q
125
+ };
126
+ export {
127
+ et as diagram
128
+ };