@prisma-next/cli 0.12.0-dev.67 → 0.12.0-dev.69

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 (41) hide show
  1. package/dist/cli.mjs +5 -5
  2. package/dist/commands/migrate.d.mts.map +1 -1
  3. package/dist/commands/migrate.mjs +17 -11
  4. package/dist/commands/migrate.mjs.map +1 -1
  5. package/dist/commands/migration-check.mjs +1 -1
  6. package/dist/commands/migration-graph.mjs +2 -2
  7. package/dist/commands/migration-graph.mjs.map +1 -1
  8. package/dist/commands/migration-list.mjs +1 -1
  9. package/dist/commands/migration-log.mjs +1 -1
  10. package/dist/commands/migration-status.d.mts.map +1 -1
  11. package/dist/commands/migration-status.mjs +1 -1
  12. package/dist/{migration-check-soB5uZEQ.mjs → migration-check-VwM8xCZV.mjs} +2 -1
  13. package/dist/{migration-check-soB5uZEQ.mjs.map → migration-check-VwM8xCZV.mjs.map} +1 -1
  14. package/dist/migration-graph-command-render-BAOzyYF6.mjs +1822 -0
  15. package/dist/migration-graph-command-render-BAOzyYF6.mjs.map +1 -0
  16. package/dist/{migration-list-CyLslAtv.mjs → migration-list-CihF6w5z.mjs} +2 -2
  17. package/dist/migration-list-CihF6w5z.mjs.map +1 -0
  18. package/dist/{migration-log-BYt18y2H.mjs → migration-log-B75IArji.mjs} +2 -2
  19. package/dist/{migration-log-BYt18y2H.mjs.map → migration-log-B75IArji.mjs.map} +1 -1
  20. package/dist/{migration-status-ciYpjhtu.mjs → migration-status-CSVe6ZlD.mjs} +4 -3
  21. package/dist/migration-status-CSVe6ZlD.mjs.map +1 -0
  22. package/package.json +19 -18
  23. package/src/commands/migrate.ts +35 -26
  24. package/src/commands/migration-graph.ts +1 -1
  25. package/src/commands/migration-list.ts +1 -1
  26. package/src/commands/migration-status-overlay.ts +1 -1
  27. package/src/commands/migration-status.ts +4 -2
  28. package/src/utils/formatters/migration-graph-command-render.ts +239 -0
  29. package/src/utils/formatters/migration-graph-grid-layout.ts +857 -0
  30. package/src/utils/formatters/migration-graph-labels.ts +406 -0
  31. package/src/utils/formatters/migration-graph-model.ts +94 -0
  32. package/src/utils/formatters/migration-graph-occlusion-render.ts +245 -0
  33. package/src/utils/formatters/migration-graph-space-render.ts +73 -33
  34. package/src/utils/formatters/migration-list-render.ts +1 -1
  35. package/dist/migration-graph-space-render-Cpg0ql8v.mjs +0 -2370
  36. package/dist/migration-graph-space-render-Cpg0ql8v.mjs.map +0 -1
  37. package/dist/migration-list-CyLslAtv.mjs.map +0 -1
  38. package/dist/migration-status-ciYpjhtu.mjs.map +0 -1
  39. package/src/utils/formatters/migration-graph-lane-colors.ts +0 -194
  40. package/src/utils/formatters/migration-graph-layout.ts +0 -1308
  41. package/src/utils/formatters/migration-graph-tree-render.ts +0 -1337
@@ -0,0 +1,1822 @@
1
+ import { ifDefined } from "@prisma-next/utils/defined";
2
+ import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
3
+ import stringWidth from "string-width";
4
+ import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
5
+ //#region src/utils/formatters/migration-graph-occlusion-render.ts
6
+ /**
7
+ * Occlusion renderer for the line/plane/occlusion migration-graph.
8
+ *
9
+ * Per cell: pick the topmost-plane line (lowest plane number = drawn on top),
10
+ * look up its glyph, apply colour from the line's lane or role. Lower-plane
11
+ * lines are occluded (not drawn).
12
+ *
13
+ * Colour is forced via createColors({ useColor: true }) regardless of NO_COLOR.
14
+ */
15
+ const palette = createColors({ useColor: true });
16
+ const LANE_COLORIZERS = [
17
+ palette.white,
18
+ palette.cyan,
19
+ palette.yellow,
20
+ palette.blueBright,
21
+ palette.magenta,
22
+ palette.green
23
+ ];
24
+ function laneColor(lane) {
25
+ return LANE_COLORIZERS[lane % LANE_COLORIZERS.length] ?? ((t) => t);
26
+ }
27
+ /**
28
+ * The colourizer for a lane's hue (lane0 = white, lane1 = cyan, …). Exported
29
+ * so the per-row LABEL renderer can tint a migration name in its lane's colour,
30
+ * matching the node `○`, the edges, and the arrows drawn in the gutter — one
31
+ * colour per lane across glyph and text.
32
+ */
33
+ function laneColorizer(lane) {
34
+ return laneColor(lane);
35
+ }
36
+ function roleColor(role) {
37
+ return role === "on-path" ? palette.greenBright : palette.dim;
38
+ }
39
+ const UNICODE_ALPHABET = {
40
+ vertical: "│",
41
+ horizontal: "─",
42
+ cornerUpRight: "╰",
43
+ cornerDownRight: "╭",
44
+ cornerUpLeft: "╯",
45
+ cornerDownLeft: "╮",
46
+ arrowUp: "↑",
47
+ arrowDown: "↓",
48
+ node: "○",
49
+ selfLoop: "⟲",
50
+ landingArrow: "◂",
51
+ fallback: "?"
52
+ };
53
+ const ASCII_ALPHABET = {
54
+ vertical: "|",
55
+ horizontal: "-",
56
+ cornerUpRight: "\\",
57
+ cornerDownRight: "/",
58
+ cornerUpLeft: "/",
59
+ cornerDownLeft: "\\",
60
+ arrowUp: "^",
61
+ arrowDown: "v",
62
+ node: "*",
63
+ selfLoop: "@",
64
+ landingArrow: "<",
65
+ fallback: "?"
66
+ };
67
+ function alphabetFor(mode) {
68
+ return mode === "ascii" ? ASCII_ALPHABET : UNICODE_ALPHABET;
69
+ }
70
+ function glyphFor(dirs, alphabet) {
71
+ const has = (d) => dirs.has(d);
72
+ if (has("up") && has("down") && !has("left") && !has("right")) return alphabet.vertical;
73
+ if (has("left") && has("right") && !has("up") && !has("down")) return alphabet.horizontal;
74
+ if (has("up") && has("right") && !has("down") && !has("left")) return alphabet.cornerUpRight;
75
+ if (has("down") && has("right") && !has("up") && !has("left")) return alphabet.cornerDownRight;
76
+ if (has("up") && has("left") && !has("down") && !has("right")) return alphabet.cornerUpLeft;
77
+ if (has("down") && has("left") && !has("up") && !has("right")) return alphabet.cornerDownLeft;
78
+ if (has("up") && !has("down") && !has("left") && !has("right")) return alphabet.arrowUp;
79
+ if (has("down") && !has("up") && !has("left") && !has("right")) return alphabet.arrowDown;
80
+ return alphabet.fallback;
81
+ }
82
+ const NO_COLOR = (t) => t;
83
+ function renderCell(cell, colorEnabled, alphabet) {
84
+ if (cell.node !== void 0) return (!colorEnabled ? NO_COLOR : cell.node.role !== void 0 ? roleColor(cell.node.role) : laneColor(cell.node.lane))(alphabet.node);
85
+ if (cell.lines.length === 0) return " ";
86
+ const topLine = cell.lines.reduce((best, current) => {
87
+ if (current.plane < best.plane) return current;
88
+ if (current.plane > best.plane) return best;
89
+ if (current.line.role === "on-path" && best.line.role !== "on-path") return current;
90
+ return best;
91
+ }, cell.lines[0]);
92
+ const glyph = topLine.selfLoop === true ? alphabet.selfLoop : topLine.landingArrow === true ? alphabet.landingArrow : glyphFor(topLine.directions, alphabet);
93
+ return (!colorEnabled ? NO_COLOR : topLine.line.role !== void 0 ? roleColor(topLine.line.role) : laneColor(topLine.line.lane))(glyph);
94
+ }
95
+ /**
96
+ * Render a single grid row to a coloured string. A completely empty row returns
97
+ * the empty string (the row is NOT dropped) so callers that pair grid rows with
98
+ * an external per-row label list keep a 1:1 index correspondence. `renderGrid`
99
+ * itself drops empty rows for its standalone output.
100
+ */
101
+ function renderGridRow(row, opts = {}) {
102
+ let lastNonEmpty = -1;
103
+ for (let i = row.length - 1; i >= 0; i--) {
104
+ const cell = row[i];
105
+ if (cell !== void 0 && (cell.lines.length > 0 || cell.node !== void 0)) {
106
+ lastNonEmpty = i;
107
+ break;
108
+ }
109
+ }
110
+ if (lastNonEmpty < 0) return "";
111
+ const colsPerLane = opts.colsPerLane ?? 2;
112
+ const colorEnabled = opts.colorize ?? true;
113
+ const alphabet = alphabetFor(opts.glyphMode ?? "unicode");
114
+ const lastConnectorCol = Math.floor(lastNonEmpty / colsPerLane) * colsPerLane + (colsPerLane - 1);
115
+ const renderThrough = Math.max(lastNonEmpty, lastConnectorCol);
116
+ let line = "";
117
+ for (let col = 0; col <= Math.min(renderThrough, row.length - 1); col++) {
118
+ const cell = row[col];
119
+ line += cell === void 0 ? " " : renderCell(cell, colorEnabled, alphabet);
120
+ }
121
+ return line;
122
+ }
123
+ function migrationListForwardArrow(glyphMode) {
124
+ return glyphMode === "ascii" ? "->" : "→";
125
+ }
126
+ function migrationListEmptySource(glyphMode) {
127
+ return glyphMode === "ascii" ? "-" : "∅";
128
+ }
129
+ function abbreviateContractHash(hash) {
130
+ return (hash.startsWith("sha256:") ? hash.slice(7) : hash).slice(0, 7);
131
+ }
132
+ function padFromHashColumn(text, width) {
133
+ const padding = Math.max(0, width - stringWidth(text));
134
+ return `${" ".repeat(padding)}${text}`;
135
+ }
136
+ //#endregion
137
+ //#region src/utils/formatters/migration-graph-grid-layout.ts
138
+ /**
139
+ * Grid layout for the line/plane/occlusion migration-graph renderer.
140
+ *
141
+ * Produces a Grid (rows × cells) from a MigrationGraphRowModel. Each node
142
+ * emits: fork connector, self-loop rows, node row, merge connector, and
143
+ * inbound migration rows — in display order (tips first, then roots).
144
+ */
145
+ function buildLaneAssignment(nodes, edges) {
146
+ const allNodes = /* @__PURE__ */ new Set();
147
+ for (const n of nodes) if (n !== null) allNodes.add(n);
148
+ const fwdEdges = edges.filter((e) => e.kind === "forward" && e.from !== e.to);
149
+ const outbound = /* @__PURE__ */ new Map();
150
+ const inbound = /* @__PURE__ */ new Map();
151
+ for (const edge of fwdEdges) {
152
+ const ob = outbound.get(edge.from);
153
+ if (ob) ob.push(edge);
154
+ else outbound.set(edge.from, [edge]);
155
+ const ib = inbound.get(edge.to);
156
+ if (ib) ib.push(edge);
157
+ else inbound.set(edge.to, [edge]);
158
+ }
159
+ for (const list of outbound.values()) list.sort((a, b) => a.dirName.localeCompare(b.dirName));
160
+ for (const list of inbound.values()) list.sort((a, b) => a.dirName.localeCompare(b.dirName));
161
+ const nodeRank = /* @__PURE__ */ new Map();
162
+ for (const n of allNodes) nodeRank.set(n, 0);
163
+ for (let pass = 0; pass < allNodes.size; pass++) {
164
+ let changed = false;
165
+ for (const [from, edges] of outbound) {
166
+ const base = nodeRank.get(from) ?? 0;
167
+ for (const e of edges) {
168
+ const next = base + 1;
169
+ if (next > (nodeRank.get(e.to) ?? 0)) {
170
+ nodeRank.set(e.to, next);
171
+ changed = true;
172
+ }
173
+ }
174
+ }
175
+ if (!changed) break;
176
+ }
177
+ const nodeLane = /* @__PURE__ */ new Map();
178
+ let nextLane = 0;
179
+ const roots = [];
180
+ for (const n of allNodes) if ((inbound.get(n) ?? []).length === 0) roots.push(n);
181
+ roots.sort((a, b) => {
182
+ if (a === EMPTY_CONTRACT_HASH) return -1;
183
+ if (b === EMPTY_CONTRACT_HASH) return 1;
184
+ return a.localeCompare(b);
185
+ });
186
+ const bfsQueue = [];
187
+ for (const root of roots) if (!nodeLane.has(root)) {
188
+ nodeLane.set(root, nextLane++);
189
+ bfsQueue.push({
190
+ node: root,
191
+ lane: nodeLane.get(root)
192
+ });
193
+ }
194
+ let head = 0;
195
+ while (head < bfsQueue.length) {
196
+ const { node, lane } = bfsQueue[head++];
197
+ const children = outbound.get(node) ?? [];
198
+ let first = true;
199
+ for (const childEdge of children) {
200
+ const child = childEdge.to;
201
+ if (!nodeLane.has(child)) {
202
+ const childLane = first ? lane : nextLane++;
203
+ nodeLane.set(child, childLane);
204
+ bfsQueue.push({
205
+ node: child,
206
+ lane: childLane
207
+ });
208
+ }
209
+ first = false;
210
+ }
211
+ }
212
+ for (const n of allNodes) if (!nodeLane.has(n)) nodeLane.set(n, nextLane++);
213
+ return {
214
+ nodeLane,
215
+ nodeRank,
216
+ numLanes: nextLane
217
+ };
218
+ }
219
+ function computeDisplayOrder(nodes, nodeLane, nodeRank) {
220
+ const seen = /* @__PURE__ */ new Set();
221
+ const result = [];
222
+ for (const n of nodes) {
223
+ if (n === null || seen.has(n)) continue;
224
+ seen.add(n);
225
+ result.push({
226
+ hash: n,
227
+ lane: nodeLane.get(n) ?? 0,
228
+ rank: nodeRank.get(n) ?? 0
229
+ });
230
+ }
231
+ result.sort((a, b) => b.rank - a.rank || a.lane - b.lane);
232
+ return result;
233
+ }
234
+ /** Create an empty cell. */
235
+ function emptyCell() {
236
+ return { lines: [] };
237
+ }
238
+ function buildGrid(rowModel, opts = {}, highlight = {
239
+ mode: "flat",
240
+ onPath: /* @__PURE__ */ new Set()
241
+ }) {
242
+ const colsPerLane = opts.colsPerLane ?? 2;
243
+ const isFocus = highlight.mode === "focus";
244
+ const { nodeLane, nodeRank, numLanes } = buildLaneAssignment(rowModel.nodes, rowModel.edges);
245
+ const displayOrder = computeDisplayOrder(rowModel.nodes, nodeLane, nodeRank);
246
+ const displayIndex = /* @__PURE__ */ new Map();
247
+ displayOrder.forEach((d, i) => {
248
+ displayIndex.set(d.hash, i);
249
+ });
250
+ const rollbackEdges = rowModel.edges.filter((e) => e.kind === "rollback" && e.from !== e.to);
251
+ const adjacentRollbacks = [];
252
+ const skippingRollbacks = [];
253
+ for (const e of rollbackEdges) {
254
+ const si = displayIndex.get(e.from);
255
+ const ti = displayIndex.get(e.to);
256
+ if (si === void 0 || ti === void 0) continue;
257
+ if (ti === si + 1) adjacentRollbacks.push(e);
258
+ else skippingRollbacks.push(e);
259
+ }
260
+ const colourLaneOf = /* @__PURE__ */ new Map();
261
+ [...skippingRollbacks].sort((a, b) => a.dirName.localeCompare(b.dirName)).forEach((e, i) => {
262
+ colourLaneOf.set(e.migrationHash, numLanes + i);
263
+ });
264
+ const geomOrder = [...skippingRollbacks].sort((a, b) => {
265
+ const ta = displayIndex.get(a.to) ?? 0;
266
+ const tb = displayIndex.get(b.to) ?? 0;
267
+ if (ta !== tb) return tb - ta;
268
+ return (displayIndex.get(a.from) ?? 0) - (displayIndex.get(b.from) ?? 0);
269
+ });
270
+ const geomLaneOf = /* @__PURE__ */ new Map();
271
+ const outermost = numLanes + skippingRollbacks.length - 1;
272
+ geomOrder.forEach((e, i) => {
273
+ geomLaneOf.set(e.migrationHash, outermost - i);
274
+ });
275
+ const routedBackArcs = skippingRollbacks.map((e) => ({
276
+ edge: e,
277
+ sourceIndex: displayIndex.get(e.from) ?? 0,
278
+ targetIndex: displayIndex.get(e.to) ?? 0,
279
+ geomLane: geomLaneOf.get(e.migrationHash) ?? numLanes,
280
+ colourLane: colourLaneOf.get(e.migrationHash) ?? numLanes
281
+ }));
282
+ const backArcsBySource = /* @__PURE__ */ new Map();
283
+ const backArcsByTarget = /* @__PURE__ */ new Map();
284
+ for (const arc of routedBackArcs) {
285
+ const sb = backArcsBySource.get(arc.edge.from);
286
+ if (sb) sb.push(arc);
287
+ else backArcsBySource.set(arc.edge.from, [arc]);
288
+ const tb = backArcsByTarget.get(arc.edge.to);
289
+ if (tb) tb.push(arc);
290
+ else backArcsByTarget.set(arc.edge.to, [arc]);
291
+ }
292
+ const adjacentBySource = /* @__PURE__ */ new Map();
293
+ const adjacentByTarget = /* @__PURE__ */ new Map();
294
+ for (const e of adjacentRollbacks) {
295
+ const b = adjacentBySource.get(e.from);
296
+ if (b) b.push(e);
297
+ else adjacentBySource.set(e.from, [e]);
298
+ const t = adjacentByTarget.get(e.to);
299
+ if (t) t.push(e);
300
+ else adjacentByTarget.set(e.to, [e]);
301
+ }
302
+ for (const list of adjacentBySource.values()) list.sort((a, b) => a.dirName.localeCompare(b.dirName));
303
+ const totalCols = (numLanes + skippingRollbacks.length) * colsPerLane;
304
+ const fwdEdges = rowModel.edges.filter((e) => e.kind === "forward" && e.from !== e.to);
305
+ const selfEdges = rowModel.edges.filter((e) => e.kind === "self");
306
+ const outboundFwd = /* @__PURE__ */ new Map();
307
+ const inboundFwd = /* @__PURE__ */ new Map();
308
+ for (const e of fwdEdges) {
309
+ const ob = outboundFwd.get(e.from);
310
+ if (ob) ob.push(e);
311
+ else outboundFwd.set(e.from, [e]);
312
+ const ib = inboundFwd.get(e.to);
313
+ if (ib) ib.push(e);
314
+ else inboundFwd.set(e.to, [e]);
315
+ }
316
+ for (const list of outboundFwd.values()) list.sort((a, b) => a.dirName.localeCompare(b.dirName));
317
+ for (const list of inboundFwd.values()) list.sort((a, b) => a.dirName.localeCompare(b.dirName));
318
+ const selfEdgesByNode = /* @__PURE__ */ new Map();
319
+ for (const e of selfEdges) {
320
+ const bucket = selfEdgesByNode.get(e.from);
321
+ if (bucket) bucket.push(e);
322
+ else selfEdgesByNode.set(e.from, [e]);
323
+ }
324
+ for (const list of selfEdgesByNode.values()) list.sort((a, b) => a.dirName.localeCompare(b.dirName));
325
+ function roleOf(migrationHash) {
326
+ if (!isFocus) return void 0;
327
+ return highlight.onPath.has(migrationHash) ? "on-path" : "off-path";
328
+ }
329
+ const onPathNodes = /* @__PURE__ */ new Set();
330
+ if (isFocus) {
331
+ for (const e of [
332
+ ...fwdEdges,
333
+ ...selfEdges,
334
+ ...rollbackEdges
335
+ ]) if (highlight.onPath.has(e.migrationHash)) {
336
+ onPathNodes.add(e.from);
337
+ onPathNodes.add(e.to);
338
+ }
339
+ }
340
+ function nodeRoleOf(hash) {
341
+ if (!isFocus) return void 0;
342
+ return onPathNodes.has(hash) ? "on-path" : "off-path";
343
+ }
344
+ function planeOf(lane, role) {
345
+ if (!isFocus) return lane;
346
+ return role === "on-path" ? 0 : lane + 1;
347
+ }
348
+ function lineRefFor(edge, lane) {
349
+ return {
350
+ migrationHash: edge.migrationHash,
351
+ dirName: edge.dirName,
352
+ lane,
353
+ role: roleOf(edge.migrationHash)
354
+ };
355
+ }
356
+ /** Synthetic LineRef for a lane carrying a representative edge's role (pass-through). */
357
+ function passLineRef(lane, dirName, migHash) {
358
+ return {
359
+ migrationHash: migHash,
360
+ dirName,
361
+ lane,
362
+ role: roleOf(migHash)
363
+ };
364
+ }
365
+ function vertCell(line) {
366
+ return { lines: [{
367
+ line,
368
+ directions: new Set(["up", "down"]),
369
+ plane: planeOf(line.lane, line.role)
370
+ }] };
371
+ }
372
+ function dirCell(line, dirs) {
373
+ return { lines: [{
374
+ line,
375
+ directions: dirs,
376
+ plane: planeOf(line.lane, line.role)
377
+ }] };
378
+ }
379
+ function nodeCell(nodeRef) {
380
+ return {
381
+ node: nodeRef,
382
+ lines: []
383
+ };
384
+ }
385
+ const laneCurrentEdge = /* @__PURE__ */ new Map();
386
+ function getRepLine(lane) {
387
+ const e = laneCurrentEdge.get(lane);
388
+ if (e) return lineRefFor(e, lane);
389
+ return passLineRef(lane, `lane${lane}`, `lane${lane}`);
390
+ }
391
+ const activeLanes = /* @__PURE__ */ new Set();
392
+ const grid = [];
393
+ function makeRow() {
394
+ return Array.from({ length: totalCols }, () => emptyCell());
395
+ }
396
+ function placeVerticals(row, skip) {
397
+ for (const lane of activeLanes) {
398
+ if (skip.has(lane)) continue;
399
+ const railCol = lane * colsPerLane;
400
+ const cell = row[railCol];
401
+ if (cell !== void 0 && cell.lines.length === 0 && !cell.node) row[railCol] = vertCell(getRepLine(lane));
402
+ }
403
+ }
404
+ const activeBackArcs = /* @__PURE__ */ new Set();
405
+ function backArcLine(arc) {
406
+ return {
407
+ migrationHash: arc.edge.migrationHash,
408
+ dirName: arc.edge.dirName,
409
+ lane: arc.colourLane,
410
+ role: roleOf(arc.edge.migrationHash)
411
+ };
412
+ }
413
+ function backArcPlane(arc) {
414
+ const role = roleOf(arc.edge.migrationHash);
415
+ if (!isFocus) return arc.colourLane;
416
+ return role === "on-path" ? 0 : arc.colourLane + 1;
417
+ }
418
+ function composeLine(row, col, line, dirs, plane, extra) {
419
+ const existing = row[col];
420
+ const cellLine = {
421
+ line,
422
+ directions: dirs,
423
+ plane,
424
+ ...extra?.landingArrow ? { landingArrow: true } : {}
425
+ };
426
+ if (existing && (existing.lines.length > 0 || existing.node)) row[col] = {
427
+ ...existing,
428
+ lines: [...existing.lines, cellLine]
429
+ };
430
+ else row[col] = { lines: [cellLine] };
431
+ }
432
+ function placeBackVerticals(row) {
433
+ for (const arc of activeBackArcs) composeLine(row, arc.geomLane * colsPerLane, backArcLine(arc), new Set(["up", "down"]), backArcPlane(arc));
434
+ placeAdjacentOverlays(row);
435
+ }
436
+ const activeAdjacent = /* @__PURE__ */ new Set();
437
+ function placeAdjacentOverlays(row) {
438
+ for (const adj of activeAdjacent) {
439
+ const railCol = adj.lane * colsPerLane;
440
+ if (row[railCol]?.node) continue;
441
+ const line = lineRefFor(adj.edge, adj.lane);
442
+ composeLine(row, railCol, line, new Set(["up", "down"]), planeOf(adj.lane, line.role));
443
+ }
444
+ }
445
+ function emitBackArcTee(row, nodeLaneNum, arc) {
446
+ const nodeRail = nodeLaneNum * colsPerLane;
447
+ const geomRail = arc.geomLane * colsPerLane;
448
+ const line = backArcLine(arc);
449
+ const plane = backArcPlane(arc);
450
+ for (let col = nodeRail + 1; col < geomRail; col++) composeLine(row, col, line, new Set(["left", "right"]), plane);
451
+ composeLine(row, geomRail, line, new Set(["down", "left"]), plane);
452
+ }
453
+ function emitBackArcLanding(row, nodeLaneNum, arc) {
454
+ const nodeRail = nodeLaneNum * colsPerLane;
455
+ const geomRail = arc.geomLane * colsPerLane;
456
+ const line = backArcLine(arc);
457
+ const plane = backArcPlane(arc);
458
+ composeLine(row, nodeRail + 1, line, new Set(["left", "right"]), plane, { landingArrow: true });
459
+ for (let col = nodeRail + 2; col < geomRail; col++) composeLine(row, col, line, new Set(["left", "right"]), plane);
460
+ composeLine(row, geomRail, line, new Set(["up", "left"]), plane);
461
+ }
462
+ function emitConnectorRow(trunkLane, branchEntries, connectorType, trunkEdge) {
463
+ const row = makeRow();
464
+ const sorted = [...branchEntries].sort((a, b) => a.lane - b.lane);
465
+ if (sorted.length === 0) return row;
466
+ const branchByLane = /* @__PURE__ */ new Map();
467
+ for (const b of sorted) branchByLane.set(b.lane, b.edge);
468
+ let continuousLane = trunkLane;
469
+ if (isFocus) if (trunkEdge && highlight.onPath.has(trunkEdge.migrationHash)) continuousLane = trunkLane;
470
+ else {
471
+ const onPathBranch = sorted.find((b) => highlight.onPath.has(b.edge.migrationHash));
472
+ if (onPathBranch) continuousLane = onPathBranch.lane;
473
+ }
474
+ const trunkRailCol = trunkLane * colsPerLane;
475
+ const continuousRailCol = continuousLane * colsPerLane;
476
+ function addLine(col, line, dirs) {
477
+ const existing = row[col];
478
+ const cellLine = {
479
+ line,
480
+ directions: dirs,
481
+ plane: planeOf(line.lane, line.role)
482
+ };
483
+ row[col] = existing && existing.lines.length > 0 ? {
484
+ ...existing,
485
+ lines: [...existing.lines, cellLine]
486
+ } : { lines: [cellLine] };
487
+ }
488
+ const cornerLeftDown = connectorType === "merge" ? new Set(["left", "down"]) : new Set(["left", "up"]);
489
+ for (let i = 0; i < sorted.length; i++) {
490
+ const b = sorted[i];
491
+ if (b.lane === continuousLane) continue;
492
+ const branchLine = lineRefFor(b.edge, b.lane);
493
+ const railCol = b.lane * colsPerLane;
494
+ addLine(railCol, branchLine, cornerLeftDown);
495
+ const leftBound = i === 0 ? trunkRailCol + 1 : sorted[i - 1].lane * colsPerLane + 1;
496
+ for (let col = leftBound; col < railCol; col++) addLine(col, branchLine, new Set(["left", "right"]));
497
+ }
498
+ const continuousLine = continuousLane === trunkLane ? trunkEdge ? lineRefFor(trunkEdge, trunkLane) : getRepLine(trunkLane) : lineRefFor(branchByLane.get(continuousLane), continuousLane);
499
+ if (continuousLane === trunkLane) addLine(trunkRailCol, continuousLine, new Set(["up", "down"]));
500
+ else {
501
+ addLine(trunkRailCol, continuousLine, connectorType === "merge" ? new Set(["up", "right"]) : new Set(["down", "right"]));
502
+ for (let col = trunkRailCol + 1; col < continuousRailCol; col++) addLine(col, continuousLine, new Set(["left", "right"]));
503
+ addLine(continuousRailCol, continuousLine, cornerLeftDown);
504
+ }
505
+ placeVerticals(row, new Set([trunkLane, ...sorted.map((b) => b.lane)]));
506
+ placeBackVerticals(row);
507
+ return row;
508
+ }
509
+ for (const nodeDisplay of displayOrder) {
510
+ const { hash: nodeHash } = nodeDisplay;
511
+ const nodeLaneNum = nodeLane.get(nodeHash) ?? 0;
512
+ activeLanes.add(nodeLaneNum);
513
+ const outEdges = outboundFwd.get(nodeHash) ?? [];
514
+ if (outEdges.length > 1) {
515
+ const trunkChildLane = nodeLane.get(outEdges[0].to) ?? nodeLaneNum;
516
+ const branchEntries = outEdges.slice(1).map((e) => ({
517
+ lane: nodeLane.get(e.to) ?? 0,
518
+ edge: e
519
+ })).filter((b) => b.lane !== trunkChildLane && activeLanes.has(b.lane));
520
+ if (branchEntries.length > 0) {
521
+ const trunkEdge = outEdges[0];
522
+ const connRow = emitConnectorRow(nodeLaneNum, branchEntries, "fork", trunkEdge);
523
+ grid.push(connRow);
524
+ assertSingleOwner(connRow, isFocus);
525
+ for (const b of branchEntries) activeLanes.delete(b.lane);
526
+ }
527
+ }
528
+ const selfMigrations = selfEdgesByNode.get(nodeHash) ?? [];
529
+ for (const selfEdge of selfMigrations) {
530
+ const row = makeRow();
531
+ const railCol = nodeLaneNum * colsPerLane;
532
+ const connCol = nodeLaneNum * colsPerLane + 1;
533
+ const line = lineRefFor(selfEdge, nodeLaneNum);
534
+ row[railCol] = vertCell(line);
535
+ row[connCol] = { lines: [{
536
+ line,
537
+ directions: /* @__PURE__ */ new Set(),
538
+ plane: planeOf(nodeLaneNum, line.role),
539
+ selfLoop: true
540
+ }] };
541
+ placeVerticals(row, new Set([nodeLaneNum]));
542
+ placeBackVerticals(row);
543
+ grid.push(row);
544
+ }
545
+ {
546
+ const row = makeRow();
547
+ const railCol = nodeLaneNum * colsPerLane;
548
+ row[railCol] = nodeCell({
549
+ contractHash: nodeHash,
550
+ isEmpty: nodeHash === EMPTY_CONTRACT_HASH,
551
+ lane: nodeLaneNum,
552
+ role: nodeRoleOf(nodeHash)
553
+ });
554
+ placeVerticals(row, new Set([nodeLaneNum]));
555
+ const landingArcs = backArcsByTarget.get(nodeHash) ?? [];
556
+ for (const arc of landingArcs) activeBackArcs.delete(arc);
557
+ for (const adj of [...activeAdjacent]) if (adj.edge.to === nodeHash) activeAdjacent.delete(adj);
558
+ placeBackVerticals(row);
559
+ for (const arc of landingArcs) emitBackArcLanding(row, nodeLaneNum, arc);
560
+ const teeArcs = backArcsBySource.get(nodeHash) ?? [];
561
+ for (const arc of teeArcs) emitBackArcTee(row, nodeLaneNum, arc);
562
+ grid.push(row);
563
+ for (const arc of teeArcs) activeBackArcs.add(arc);
564
+ for (const adj of adjacentBySource.get(nodeHash) ?? []) activeAdjacent.add({
565
+ lane: nodeLaneNum,
566
+ edge: adj
567
+ });
568
+ }
569
+ const inEdges = inboundFwd.get(nodeHash) ?? [];
570
+ inEdges.sort((a, b) => a.dirName.localeCompare(b.dirName));
571
+ for (const edge of inEdges) {
572
+ const edgeLane = Math.max(nodeLane.get(edge.from) ?? 0, nodeLane.get(edge.to) ?? 0);
573
+ laneCurrentEdge.set(edgeLane, edge);
574
+ }
575
+ {
576
+ const teeArcs = backArcsBySource.get(nodeHash) ?? [];
577
+ for (const arc of teeArcs) {
578
+ const row = makeRow();
579
+ const railCol = arc.geomLane * colsPerLane;
580
+ const connCol = railCol + 1;
581
+ const line = backArcLine(arc);
582
+ const plane = backArcPlane(arc);
583
+ composeLine(row, railCol, line, new Set(["up", "down"]), plane);
584
+ composeLine(row, connCol, line, new Set(["down"]), plane);
585
+ placeVerticals(row, /* @__PURE__ */ new Set());
586
+ placeBackVerticals(row);
587
+ grid.push(row);
588
+ }
589
+ }
590
+ if (inEdges.length > 1) {
591
+ const branchEntries = inEdges.slice(1).map((e) => ({
592
+ lane: nodeLane.get(e.from) ?? 0,
593
+ edge: e
594
+ }));
595
+ const trunkEdge = inEdges[0];
596
+ const connRow = emitConnectorRow(nodeLaneNum, branchEntries, "merge", trunkEdge);
597
+ grid.push(connRow);
598
+ assertSingleOwner(connRow, isFocus);
599
+ for (const b of branchEntries) activeLanes.add(b.lane);
600
+ }
601
+ for (const edge of inEdges) {
602
+ const fromLane = nodeLane.get(edge.from) ?? 0;
603
+ const toLane = nodeLane.get(edge.to) ?? 0;
604
+ const edgeLane = Math.max(fromLane, toLane);
605
+ const row = makeRow();
606
+ const railCol = edgeLane * colsPerLane;
607
+ const connCol = edgeLane * colsPerLane + 1;
608
+ const line = lineRefFor(edge, edgeLane);
609
+ row[railCol] = vertCell(line);
610
+ row[connCol] = dirCell(line, new Set(["up"]));
611
+ placeVerticals(row, new Set([edgeLane]));
612
+ placeBackVerticals(row);
613
+ grid.push(row);
614
+ }
615
+ {
616
+ const adjacents = adjacentBySource.get(nodeHash) ?? [];
617
+ for (const adj of adjacents) {
618
+ const row = makeRow();
619
+ const connCol = nodeLaneNum * colsPerLane + 1;
620
+ const line = lineRefFor(adj, nodeLaneNum);
621
+ const plane = planeOf(nodeLaneNum, line.role);
622
+ composeLine(row, connCol, line, new Set(["down"]), plane);
623
+ placeVerticals(row, /* @__PURE__ */ new Set());
624
+ placeBackVerticals(row);
625
+ grid.push(row);
626
+ }
627
+ }
628
+ if (inEdges.length === 0) activeLanes.delete(nodeLaneNum);
629
+ }
630
+ return grid;
631
+ }
632
+ function assertSingleOwner(row, isFocus) {
633
+ for (const cell of row) {
634
+ if (cell.lines.length <= 1) continue;
635
+ let topPlane = Number.POSITIVE_INFINITY;
636
+ for (const cl of cell.lines) if (cl.plane < topPlane) topPlane = cl.plane;
637
+ const top = cell.lines.filter((cl) => cl.plane === topPlane);
638
+ if (top.length > 1) {
639
+ if (isFocus) {
640
+ if (new Set(top.map((cl) => cl.line.role)).size > 1) throw new Error("migration-graph layout: single-owner invariant violated — two differently-roled lines share the top plane in one cell");
641
+ }
642
+ }
643
+ }
644
+ }
645
+ //#endregion
646
+ //#region src/utils/formatters/migration-list-graph-topology.ts
647
+ function compareDirNameDesc(a, b) {
648
+ return b.dirName.localeCompare(a.dirName);
649
+ }
650
+ function bumpDegree(map, key) {
651
+ map.set(key, (map.get(key) ?? 0) + 1);
652
+ }
653
+ function compareNodesRootFirst(a, b) {
654
+ if (a === EMPTY_CONTRACT_HASH) return -1;
655
+ if (b === EMPTY_CONTRACT_HASH) return 1;
656
+ return a.localeCompare(b);
657
+ }
658
+ /**
659
+ * Shortest-path distance of each node from the forward roots, over the given
660
+ * candidate edges. Roots are the in-degree-0 nodes (baseline first, then lex);
661
+ * a rooted component therefore distances every node by how many forward steps
662
+ * it sits from a root. A component with no root (a pure cycle) is seeded from
663
+ * its single lexically-smallest node so the cycle still gets a stable layering.
664
+ *
665
+ * Crucially this is *shortest* path, not longest: a backward (rollback) edge
666
+ * `deep → shallow` never offers a shorter route to the already-shallower
667
+ * target, so it is inert here. Distances are thus stable whether or not the
668
+ * rollbacks are still in the candidate set — which is what lets the peel below
669
+ * tell a genuine back-edge (target strictly shallower than source) apart from a
670
+ * forward edge that merely happens to share the back-edge's cycle.
671
+ */
672
+ function forwardDistances(nodes, candidates) {
673
+ const inDegree = /* @__PURE__ */ new Map();
674
+ for (const node of nodes) inDegree.set(node, 0);
675
+ for (const edge of candidates) bumpDegree(inDegree, edge.to);
676
+ const roots = [...nodes].filter((node) => (inDegree.get(node) ?? 0) === 0);
677
+ roots.sort(compareNodesRootFirst);
678
+ const seeds = roots.length > 0 ? roots : [...nodes].sort(compareNodesRootFirst).slice(0, 1);
679
+ const dist = /* @__PURE__ */ new Map();
680
+ for (const seed of seeds) dist.set(seed, 0);
681
+ const maxPasses = nodes.size;
682
+ for (let pass = 0; pass < maxPasses; pass++) {
683
+ let changed = false;
684
+ for (const edge of candidates) {
685
+ const base = dist.get(edge.from);
686
+ if (base === void 0) continue;
687
+ const next = base + 1;
688
+ if (next < (dist.get(edge.to) ?? Number.POSITIVE_INFINITY)) {
689
+ dist.set(edge.to, next);
690
+ changed = true;
691
+ }
692
+ }
693
+ if (!changed) break;
694
+ }
695
+ for (const node of nodes) if (!dist.has(node)) dist.set(node, 0);
696
+ return dist;
697
+ }
698
+ function canReachForward(start, goal, candidates) {
699
+ if (start === goal) return true;
700
+ const outgoing = /* @__PURE__ */ new Map();
701
+ for (const edge of candidates) {
702
+ const bucket = outgoing.get(edge.from);
703
+ if (bucket) bucket.push(edge.to);
704
+ else outgoing.set(edge.from, [edge.to]);
705
+ }
706
+ const visited = new Set([start]);
707
+ const queue = [start];
708
+ while (queue.length > 0) {
709
+ const node = queue.shift();
710
+ if (node === void 0) continue;
711
+ for (const next of outgoing.get(node) ?? []) {
712
+ if (next === goal) return true;
713
+ if (!visited.has(next)) {
714
+ visited.add(next);
715
+ queue.push(next);
716
+ }
717
+ }
718
+ }
719
+ return false;
720
+ }
721
+ /**
722
+ * Demote node-skipping rollbacks left forward by the DFS. An edge `from → to`
723
+ * is a rollback exactly when both hold:
724
+ * 1. `to` is a forward-ancestor of `from` — `to` can still reach `from` over
725
+ * the other forward edges, so the edge closes a cycle; and
726
+ * 2. `to` is strictly shallower than `from` (smaller forward distance) — the
727
+ * edge points back toward the root rather than advancing history.
728
+ *
729
+ * Condition 2 is the discriminator: in a cycle created by a rollback every edge
730
+ * satisfies condition 1, but only the rollback itself runs deep → shallow. The
731
+ * forward chain edges run shallow → deep and are never peeled, however many
732
+ * rollbacks converge on the same target. Tight back-edges whose source and
733
+ * target sit at the same distance (mutual two-node cycles) are already resolved
734
+ * by the DFS immediate-parent rule, so they never reach this pass. One edge is
735
+ * peeled per iteration (dirName-descending tie-break) and distances/reachability
736
+ * are recomputed, making the outcome independent of edge input order.
737
+ */
738
+ function peelNodeSkippingRollbacks(nodes, kindByMigrationHash, nonSelf) {
739
+ let candidates = nonSelf.filter((edge) => kindByMigrationHash.get(edge.hash) === "forward");
740
+ while (candidates.length > 0) {
741
+ const dist = forwardDistances(nodes, candidates);
742
+ const backEdges = candidates.filter((edge) => {
743
+ if ((dist.get(edge.to) ?? 0) >= (dist.get(edge.from) ?? 0)) return false;
744
+ const without = candidates.filter((candidate) => candidate !== edge);
745
+ return canReachForward(edge.to, edge.from, without);
746
+ });
747
+ if (backEdges.length === 0) break;
748
+ backEdges.sort(compareDirNameDesc);
749
+ const rollback = backEdges[0];
750
+ if (rollback === void 0) break;
751
+ kindByMigrationHash.set(rollback.hash, "rollback");
752
+ candidates = candidates.filter((edge) => edge !== rollback);
753
+ }
754
+ }
755
+ /**
756
+ * DFS with dirName-descending traversal. A GRAY target is a rollback only when it
757
+ * is the immediate DFS parent of the source — cross-links to other GRAY nodes
758
+ * stay forward. A follow-up peel pass demotes node-skipping rollbacks (target is
759
+ * a forward-ancestor of the source and sits strictly shallower than it).
760
+ */
761
+ function classifyNormalizedEdges(edges) {
762
+ const nodes = /* @__PURE__ */ new Set();
763
+ const kindByMigrationHash = /* @__PURE__ */ new Map();
764
+ const outgoingByFrom = /* @__PURE__ */ new Map();
765
+ const nonSelf = [];
766
+ for (const edge of edges) {
767
+ nodes.add(edge.from);
768
+ nodes.add(edge.to);
769
+ if (edge.from === edge.to) {
770
+ kindByMigrationHash.set(edge.hash, "self");
771
+ continue;
772
+ }
773
+ nonSelf.push(edge);
774
+ const bucket = outgoingByFrom.get(edge.from);
775
+ if (bucket) bucket.push(edge);
776
+ else outgoingByFrom.set(edge.from, [edge]);
777
+ }
778
+ for (const bucket of outgoingByFrom.values()) bucket.sort(compareDirNameDesc);
779
+ const nonSelfInDegree = /* @__PURE__ */ new Map();
780
+ for (const node of nodes) nonSelfInDegree.set(node, 0);
781
+ for (const bucket of outgoingByFrom.values()) for (const edge of bucket) bumpDegree(nonSelfInDegree, edge.to);
782
+ const dfsRoots = [];
783
+ for (const node of nodes) if ((nonSelfInDegree.get(node) ?? 0) === 0) dfsRoots.push(node);
784
+ dfsRoots.sort((a, b) => {
785
+ if (a === EMPTY_CONTRACT_HASH) return -1;
786
+ if (b === EMPTY_CONTRACT_HASH) return 1;
787
+ return a.localeCompare(b);
788
+ });
789
+ if (dfsRoots.length === 0) dfsRoots.push(...[...nodes].sort((a, b) => a.localeCompare(b)));
790
+ const WHITE = 0;
791
+ const GRAY = 1;
792
+ const BLACK = 2;
793
+ const color = /* @__PURE__ */ new Map();
794
+ const dfsParent = /* @__PURE__ */ new Map();
795
+ for (const node of nodes) color.set(node, WHITE);
796
+ const stack = [];
797
+ function isImmediateDfsParent(ancestor, node) {
798
+ return dfsParent.get(node) === ancestor;
799
+ }
800
+ function pushFrame(node, parent) {
801
+ color.set(node, GRAY);
802
+ dfsParent.set(node, parent);
803
+ stack.push({
804
+ node,
805
+ outgoing: outgoingByFrom.get(node) ?? [],
806
+ index: 0
807
+ });
808
+ }
809
+ function runDfsFrom(root) {
810
+ if (color.get(root) !== WHITE) return;
811
+ pushFrame(root, void 0);
812
+ while (stack.length > 0) {
813
+ const frame = stack[stack.length - 1];
814
+ if (frame === void 0) break;
815
+ if (frame.index >= frame.outgoing.length) {
816
+ color.set(frame.node, BLACK);
817
+ stack.pop();
818
+ continue;
819
+ }
820
+ const edge = frame.outgoing[frame.index];
821
+ frame.index += 1;
822
+ if (edge === void 0) continue;
823
+ const v = edge.to;
824
+ const vColor = color.get(v);
825
+ if (vColor === GRAY && isImmediateDfsParent(v, frame.node)) kindByMigrationHash.set(edge.hash, "rollback");
826
+ else {
827
+ kindByMigrationHash.set(edge.hash, "forward");
828
+ if (vColor === WHITE) pushFrame(v, frame.node);
829
+ }
830
+ }
831
+ }
832
+ for (const root of dfsRoots) runDfsFrom(root);
833
+ const remainingWhite = [...nodes].filter((node) => color.get(node) === WHITE);
834
+ remainingWhite.sort((a, b) => a.localeCompare(b));
835
+ for (const root of remainingWhite) runDfsFrom(root);
836
+ peelNodeSkippingRollbacks(nodes, kindByMigrationHash, nonSelf);
837
+ const forwardInDegree = /* @__PURE__ */ new Map();
838
+ const forwardOutDegree = /* @__PURE__ */ new Map();
839
+ for (const edge of edges) {
840
+ if (kindByMigrationHash.get(edge.hash) !== "forward") continue;
841
+ bumpDegree(forwardOutDegree, edge.from);
842
+ bumpDegree(forwardInDegree, edge.to);
843
+ }
844
+ return {
845
+ kindByMigrationHash,
846
+ forwardInDegree,
847
+ forwardOutDegree
848
+ };
849
+ }
850
+ /**
851
+ * Classify forward/rollback/self for a `MigrationGraph` edge set (Tier-3).
852
+ */
853
+ function classifyMigrationGraphTopology(graph) {
854
+ const normalized = [];
855
+ for (const edges of graph.forwardChain.values()) for (const edge of edges) normalized.push({
856
+ hash: edge.migrationHash,
857
+ from: edge.from,
858
+ to: edge.to,
859
+ dirName: edge.dirName
860
+ });
861
+ return classifyNormalizedEdges(normalized);
862
+ }
863
+ //#endregion
864
+ //#region src/utils/formatters/migration-graph-rows.ts
865
+ /**
866
+ * Return the weakly-connected components of `graph` as an array of node sets,
867
+ * ordered so the component containing EMPTY_CONTRACT_HASH comes first (if
868
+ * present), with remaining components sorted by their lex-smallest node hash.
869
+ */
870
+ function weaklyConnectedComponents(graph) {
871
+ const visited = /* @__PURE__ */ new Set();
872
+ const adjacency = /* @__PURE__ */ new Map();
873
+ function addAdjacent(a, b) {
874
+ const aList = adjacency.get(a);
875
+ if (aList) aList.push(b);
876
+ else adjacency.set(a, [b]);
877
+ const bList = adjacency.get(b);
878
+ if (bList) bList.push(a);
879
+ else adjacency.set(b, [a]);
880
+ }
881
+ for (const edges of graph.forwardChain.values()) for (const edge of edges) if (edge.from !== edge.to) addAdjacent(edge.from, edge.to);
882
+ for (const node of graph.nodes) if (!adjacency.has(node)) adjacency.set(node, []);
883
+ const components = [];
884
+ function bfsComponent(start) {
885
+ const component = /* @__PURE__ */ new Set();
886
+ const queue = [start];
887
+ while (queue.length > 0) {
888
+ const node = queue.shift();
889
+ if (node === void 0 || visited.has(node)) continue;
890
+ visited.add(node);
891
+ component.add(node);
892
+ for (const neighbor of adjacency.get(node) ?? []) if (!visited.has(neighbor)) queue.push(neighbor);
893
+ }
894
+ return component;
895
+ }
896
+ const allNodes = [...graph.nodes].sort((a, b) => {
897
+ if (a === EMPTY_CONTRACT_HASH) return -1;
898
+ if (b === EMPTY_CONTRACT_HASH) return 1;
899
+ return a.localeCompare(b);
900
+ });
901
+ for (const node of allNodes) if (!visited.has(node)) components.push(bfsComponent(node));
902
+ components.sort((a, b) => {
903
+ const aHasEmpty = a.has(EMPTY_CONTRACT_HASH);
904
+ const bHasEmpty = b.has(EMPTY_CONTRACT_HASH);
905
+ if (aHasEmpty && !bHasEmpty) return -1;
906
+ if (!aHasEmpty && bHasEmpty) return 1;
907
+ const aMin = [...a].sort((x, y) => x.localeCompare(y))[0] ?? "";
908
+ const bMin = [...b].sort((x, y) => x.localeCompare(y))[0] ?? "";
909
+ return aMin.localeCompare(bMin);
910
+ });
911
+ return components;
912
+ }
913
+ function forwardRootsInComponent(componentNodes, topology) {
914
+ const roots = [];
915
+ for (const node of componentNodes) if ((topology.forwardInDegree.get(node) ?? 0) === 0) roots.push(node);
916
+ roots.sort((a, b) => {
917
+ if (a === EMPTY_CONTRACT_HASH) return -1;
918
+ if (b === EMPTY_CONTRACT_HASH) return 1;
919
+ return a.localeCompare(b);
920
+ });
921
+ if (roots.length > 0) return roots;
922
+ return [...componentNodes].sort((a, b) => {
923
+ if (a === EMPTY_CONTRACT_HASH) return -1;
924
+ if (b === EMPTY_CONTRACT_HASH) return 1;
925
+ return a.localeCompare(b);
926
+ });
927
+ }
928
+ function compareNodesTipsFirst(a, b, rank) {
929
+ const rankA = rank.get(a) ?? 0;
930
+ const rankB = rank.get(b) ?? 0;
931
+ if (rankA !== rankB) return rankB - rankA;
932
+ if (a === EMPTY_CONTRACT_HASH) return 1;
933
+ if (b === EMPTY_CONTRACT_HASH) return -1;
934
+ return a.localeCompare(b);
935
+ }
936
+ /**
937
+ * Layer nodes by longest forward-path rank from forward roots within the
938
+ * component. Rank 0 is the root (bottom row); the maximum rank is the tip
939
+ * (top row). Emits rank-descending with lex-ascending tie-break among siblings
940
+ * at the same rank — stable across edge-insertion order and correct under
941
+ * diamonds, cross-links, and rollbacks.
942
+ */
943
+ function maxRank(rank) {
944
+ let max = 0;
945
+ for (const value of rank.values()) if (value > max) max = value;
946
+ return max;
947
+ }
948
+ function layerNodesByLongestForwardPath(componentNodes, topology, graph, contractHash) {
949
+ const forwardOut = /* @__PURE__ */ new Map();
950
+ for (const node of componentNodes) forwardOut.set(node, []);
951
+ for (const edges of graph.forwardChain.values()) for (const edge of edges) {
952
+ if (!componentNodes.has(edge.from) || !componentNodes.has(edge.to)) continue;
953
+ if (edge.from === edge.to) continue;
954
+ if (topology.kindByMigrationHash.get(edge.migrationHash) !== "forward") continue;
955
+ const bucket = forwardOut.get(edge.from);
956
+ if (bucket) bucket.push(edge.to);
957
+ }
958
+ const roots = forwardRootsInComponent(componentNodes, topology);
959
+ const rank = /* @__PURE__ */ new Map();
960
+ for (const root of roots) rank.set(root, 0);
961
+ const maxPasses = componentNodes.size;
962
+ for (let pass = 0; pass < maxPasses; pass++) {
963
+ let changed = false;
964
+ for (const node of componentNodes) {
965
+ const base = rank.get(node);
966
+ if (base === void 0) continue;
967
+ for (const to of forwardOut.get(node) ?? []) {
968
+ const next = base + 1;
969
+ if (next > (rank.get(to) ?? -1)) {
970
+ rank.set(to, next);
971
+ changed = true;
972
+ }
973
+ }
974
+ }
975
+ if (!changed) break;
976
+ }
977
+ for (const node of componentNodes) if (!rank.has(node)) rank.set(node, 0);
978
+ if (contractHash !== void 0 && contractHash !== EMPTY_CONTRACT_HASH && componentNodes.has(contractHash) && (forwardOut.get(contractHash) ?? []).length === 0) rank.set(contractHash, maxRank(rank) + 1);
979
+ return [...componentNodes].sort((a, b) => compareNodesTipsFirst(a, b, rank));
980
+ }
981
+ /**
982
+ * Build the row model from a tolerant `MigrationGraph`.
983
+ *
984
+ * The row model is the first pure-data stage of the `migration graph` render
985
+ * pipeline. It:
986
+ * - classifies every edge as `forward`, `rollback`, or `self`;
987
+ * - produces a deterministic vertical node ordering (tips at index 0, roots
988
+ * at the end) within each weakly-connected component;
989
+ * - separates disjoint components with `null` sentinels;
990
+ * - optionally prepends a detached current contract as its own single-node
991
+ * component when `contractHash` is not already in the graph.
992
+ *
993
+ * No columns, no lane allocation, no glyphs, no rendering.
994
+ */
995
+ /**
996
+ * Resolve the detached current contract, if any: a real contract (not the
997
+ * empty baseline) that no migration on disk produces, so it is absent from
998
+ * the graph. Such a contract renders as a floating node rather than
999
+ * decorating an existing one. Returns the hash when detached, else undefined.
1000
+ */
1001
+ function detachedContractHash(graph, contractHash) {
1002
+ return contractHash !== void 0 && contractHash !== EMPTY_CONTRACT_HASH && !graph.nodes.has(contractHash) ? contractHash : void 0;
1003
+ }
1004
+ function isForwardLeaf(node, edges) {
1005
+ return !edges.some((e) => e.kind === "forward" && e.from === node && e.from !== e.to);
1006
+ }
1007
+ function forwardReachableFrom(start, forwardTo) {
1008
+ const reachable = new Set([start]);
1009
+ const queue = [start];
1010
+ while (queue.length > 0) {
1011
+ const node = queue.shift();
1012
+ if (node === void 0) continue;
1013
+ for (const next of forwardTo.get(node) ?? []) if (!reachable.has(next)) {
1014
+ reachable.add(next);
1015
+ queue.push(next);
1016
+ }
1017
+ }
1018
+ return reachable;
1019
+ }
1020
+ function buildForwardToMap(edges) {
1021
+ const forwardTo = /* @__PURE__ */ new Map();
1022
+ for (const edge of edges) {
1023
+ if (edge.kind !== "forward" || edge.from === edge.to) continue;
1024
+ const bucket = forwardTo.get(edge.from);
1025
+ if (bucket) bucket.push(edge.to);
1026
+ else forwardTo.set(edge.from, [edge.to]);
1027
+ }
1028
+ return forwardTo;
1029
+ }
1030
+ function sortEdgesForContractHashTrunk(edges, contractHash) {
1031
+ if (contractHash === void 0 || contractHash === EMPTY_CONTRACT_HASH || !isForwardLeaf(contractHash, edges)) return edges;
1032
+ const preferredLeaf = contractHash;
1033
+ const forwardTo = buildForwardToMap(edges);
1034
+ const reachability = /* @__PURE__ */ new Map();
1035
+ function canReachContractHash(from) {
1036
+ let cached = reachability.get(from);
1037
+ if (cached === void 0) {
1038
+ cached = forwardReachableFrom(from, forwardTo);
1039
+ reachability.set(from, cached);
1040
+ }
1041
+ return cached.has(preferredLeaf);
1042
+ }
1043
+ function trunkBias(edge) {
1044
+ if (edge.kind !== "forward" || edge.from === edge.to) return 0;
1045
+ if (edge.to === preferredLeaf) return 2;
1046
+ if (canReachContractHash(edge.to)) return 1;
1047
+ return 0;
1048
+ }
1049
+ return edges.map((edge, index) => ({
1050
+ edge,
1051
+ index,
1052
+ bias: trunkBias(edge)
1053
+ })).sort((a, b) => {
1054
+ if (a.edge.from !== b.edge.from) return a.index - b.index;
1055
+ if (a.bias !== b.bias) return b.bias - a.bias;
1056
+ return a.index - b.index;
1057
+ }).map(({ edge }) => edge);
1058
+ }
1059
+ function rebuildEdgeLookupMaps(edges) {
1060
+ const edgesByFrom = /* @__PURE__ */ new Map();
1061
+ const edgesByTo = /* @__PURE__ */ new Map();
1062
+ for (const classified of edges) {
1063
+ const fromBucket = edgesByFrom.get(classified.from);
1064
+ if (fromBucket) fromBucket.push(classified);
1065
+ else edgesByFrom.set(classified.from, [classified]);
1066
+ const toBucket = edgesByTo.get(classified.to);
1067
+ if (toBucket) toBucket.push(classified);
1068
+ else edgesByTo.set(classified.to, [classified]);
1069
+ }
1070
+ return {
1071
+ edgesByFrom,
1072
+ edgesByTo
1073
+ };
1074
+ }
1075
+ function buildMigrationGraphRows(graph, options = {}) {
1076
+ const emptyModel = {
1077
+ nodes: [],
1078
+ edges: [],
1079
+ edgesByFrom: /* @__PURE__ */ new Map(),
1080
+ edgesByTo: /* @__PURE__ */ new Map()
1081
+ };
1082
+ if (graph.nodes.size === 0) {
1083
+ const detached = detachedContractHash(graph, options.contractHash);
1084
+ return detached !== void 0 ? {
1085
+ ...emptyModel,
1086
+ nodes: [detached]
1087
+ } : emptyModel;
1088
+ }
1089
+ const topology = classifyMigrationGraphTopology(graph);
1090
+ const edges = [];
1091
+ for (const edgeList of graph.forwardChain.values()) for (const edge of edgeList) {
1092
+ const kind = topology.kindByMigrationHash.get(edge.migrationHash) ?? "forward";
1093
+ edges.push({
1094
+ migrationHash: edge.migrationHash,
1095
+ from: edge.from,
1096
+ to: edge.to,
1097
+ dirName: edge.dirName,
1098
+ kind
1099
+ });
1100
+ }
1101
+ const sortedEdges = sortEdgesForContractHashTrunk(edges, options.contractHash);
1102
+ const { edgesByFrom, edgesByTo } = rebuildEdgeLookupMaps(sortedEdges);
1103
+ const components = weaklyConnectedComponents(graph);
1104
+ const nodes = [];
1105
+ for (let i = 0; i < components.length; i++) {
1106
+ if (i > 0) nodes.push(null);
1107
+ const component = components[i];
1108
+ if (component === void 0) continue;
1109
+ const ordered = layerNodesByLongestForwardPath(component, topology, graph, options.contractHash);
1110
+ for (const node of ordered) nodes.push(node);
1111
+ }
1112
+ const detached = detachedContractHash(graph, options.contractHash);
1113
+ if (detached !== void 0) {
1114
+ if (nodes.length > 0) nodes.unshift(null);
1115
+ nodes.unshift(detached);
1116
+ }
1117
+ return {
1118
+ nodes,
1119
+ edges: sortedEdges,
1120
+ edgesByFrom,
1121
+ edgesByTo
1122
+ };
1123
+ }
1124
+ //#endregion
1125
+ //#region src/utils/formatters/migration-graph-space-render.ts
1126
+ function mergeMigrationEdgeAnnotations(listOverlay, statusOverlay) {
1127
+ const merged = /* @__PURE__ */ new Map();
1128
+ for (const [migrationHash, listAnnotation] of listOverlay) {
1129
+ const statusAnnotation = statusOverlay.get(migrationHash);
1130
+ merged.set(migrationHash, {
1131
+ ...listAnnotation,
1132
+ ...statusAnnotation?.status !== void 0 ? { status: statusAnnotation.status } : {}
1133
+ });
1134
+ }
1135
+ return merged;
1136
+ }
1137
+ /**
1138
+ * Translate `migrate --show` per-edge path-highlight annotations into a
1139
+ * {@link Highlight}. With any `pathHighlight` present the result is focus mode
1140
+ * (on-path lifted green, off-path dim); otherwise flat (lane-rotation colour).
1141
+ */
1142
+ function highlightFromEdgeAnnotations(edgeAnnotationsByHash) {
1143
+ const onPath = /* @__PURE__ */ new Set();
1144
+ let anyPathHighlight = false;
1145
+ for (const [migrationHash, annotation] of edgeAnnotationsByHash) {
1146
+ if (annotation.pathHighlight === void 0) continue;
1147
+ anyPathHighlight = true;
1148
+ if (annotation.pathHighlight === "on-path") onPath.add(migrationHash);
1149
+ }
1150
+ return anyPathHighlight ? {
1151
+ mode: "focus",
1152
+ onPath
1153
+ } : {
1154
+ mode: "flat",
1155
+ onPath: /* @__PURE__ */ new Set()
1156
+ };
1157
+ }
1158
+ function buildGridForInput(input) {
1159
+ const rowModel = buildMigrationGraphRows(input.graph, { contractHash: input.liveContractHash });
1160
+ return {
1161
+ grid: buildGrid(rowModel, {}, {
1162
+ mode: "flat",
1163
+ onPath: /* @__PURE__ */ new Set()
1164
+ }),
1165
+ rowModel
1166
+ };
1167
+ }
1168
+ /**
1169
+ * The widest gutter→label column across the given space layouts. Cross-space
1170
+ * callers pass this back in so every section's labels share one column.
1171
+ */
1172
+ function computeGlobalMaxEdgeTreePrefixWidth(inputs, glyphMode = "unicode") {
1173
+ let globalMax = 0;
1174
+ for (const input of inputs) {
1175
+ const { grid } = buildGridForInput(input);
1176
+ globalMax = Math.max(globalMax, computeLabelColumn(grid, glyphMode));
1177
+ }
1178
+ return globalMax;
1179
+ }
1180
+ function computeGlobalMaxDirNameWidth(inputs) {
1181
+ let globalMax = 0;
1182
+ for (const input of inputs) {
1183
+ const { rowModel } = buildGridForInput(input);
1184
+ globalMax = Math.max(globalMax, computeMaxDirNameWidth(rowModel));
1185
+ }
1186
+ return globalMax;
1187
+ }
1188
+ function renderMigrationGraphSpaceTreeInternal(input) {
1189
+ const appSpace = input.isAppSpace !== false;
1190
+ const rowModel = buildMigrationGraphRows(input.graph, { ...appSpace ? { contractHash: input.liveContractHash } : {} });
1191
+ const listOverlay = buildEdgeAnnotationsByHashFromListEntries(input.migrations);
1192
+ const edgeAnnotationsByHash = input.statusOverlayByHash === void 0 ? listOverlay : mergeMigrationEdgeAnnotations(listOverlay, input.statusOverlayByHash);
1193
+ return renderMigrationGraphCommand({
1194
+ grid: buildGrid(rowModel, {}, highlightFromEdgeAnnotations(edgeAnnotationsByHash)),
1195
+ rowModel,
1196
+ colorize: input.colorize,
1197
+ glyphMode: input.glyphMode,
1198
+ contractHash: input.liveContractHash,
1199
+ isAppSpace: appSpace,
1200
+ edgeAnnotationsByHash,
1201
+ refsByHash: input.refsByHash ?? buildRefsByHashFromListEntries(input.migrations),
1202
+ ...input.dbHash !== void 0 ? { dbHash: input.dbHash } : {},
1203
+ ...input.styler !== void 0 ? { styler: input.styler } : {},
1204
+ ...input.globalMaxEdgeTreePrefixWidth !== void 0 ? { globalLabelColumn: input.globalMaxEdgeTreePrefixWidth } : {},
1205
+ ...input.globalMaxDirNameWidth !== void 0 ? { globalMaxDirNameWidth: input.globalMaxDirNameWidth } : {}
1206
+ });
1207
+ }
1208
+ function renderMigrationGraphSpaceTree(input) {
1209
+ return renderMigrationGraphSpaceTreeInternal(input);
1210
+ }
1211
+ function indentMigrationGraphTreeBlock(treeOutput, indent) {
1212
+ if (treeOutput.length === 0) return treeOutput;
1213
+ return treeOutput.split("\n").map((line) => line.length === 0 ? line : `${indent}${line}`).join("\n");
1214
+ }
1215
+ //#endregion
1216
+ //#region src/utils/formatters/migration-list-render.ts
1217
+ const IDENTITY_MIGRATION_LIST_STYLER = {
1218
+ kind: (text) => text,
1219
+ dirName: (text) => text,
1220
+ sourceHash: (text) => text,
1221
+ destHash: (text) => text,
1222
+ glyph: (text) => text,
1223
+ lane: (text) => text,
1224
+ invariants: (ids) => `{${ids.join(", ")}}`,
1225
+ refs: (names) => `(${names.join(", ")})`,
1226
+ spaceHeading: (text) => text,
1227
+ summary: (text) => text,
1228
+ emptyState: (text) => text
1229
+ };
1230
+ function canonicalFrom(from) {
1231
+ return from ?? EMPTY_CONTRACT_HASH;
1232
+ }
1233
+ function migrationGraphFromListEntries(entries) {
1234
+ const nodes = /* @__PURE__ */ new Set();
1235
+ const forwardChain = /* @__PURE__ */ new Map();
1236
+ const reverseChain = /* @__PURE__ */ new Map();
1237
+ const migrationByHash = /* @__PURE__ */ new Map();
1238
+ for (const entry of entries) {
1239
+ const from = canonicalFrom(entry.fromContract);
1240
+ const edge = {
1241
+ from,
1242
+ to: entry.toContract,
1243
+ migrationHash: entry.hash,
1244
+ dirName: entry.name,
1245
+ createdAt: entry.createdAt,
1246
+ invariants: entry.providedInvariants
1247
+ };
1248
+ nodes.add(from);
1249
+ nodes.add(entry.toContract);
1250
+ const forward = forwardChain.get(from);
1251
+ if (forward) forward.push(edge);
1252
+ else forwardChain.set(from, [edge]);
1253
+ const reverse = reverseChain.get(entry.toContract);
1254
+ if (reverse) reverse.push(edge);
1255
+ else reverseChain.set(entry.toContract, [edge]);
1256
+ migrationByHash.set(entry.hash, edge);
1257
+ }
1258
+ return {
1259
+ nodes,
1260
+ forwardChain,
1261
+ reverseChain,
1262
+ migrationByHash
1263
+ };
1264
+ }
1265
+ function buildEdgeAnnotationsByHashFromListEntries(entries) {
1266
+ const annotations = /* @__PURE__ */ new Map();
1267
+ for (const entry of entries) annotations.set(entry.hash, {
1268
+ operationCount: entry.operationCount,
1269
+ invariants: entry.providedInvariants
1270
+ });
1271
+ return annotations;
1272
+ }
1273
+ function buildRefsByHashFromListEntries(entries) {
1274
+ const refsByHash = /* @__PURE__ */ new Map();
1275
+ for (const entry of entries) if (entry.refs.length > 0) refsByHash.set(entry.toContract, entry.refs);
1276
+ return refsByHash;
1277
+ }
1278
+ function formatEmptyStateLine(spaceId, style) {
1279
+ return style.emptyState(`There are no migrations in migrations/${spaceId}/ yet`);
1280
+ }
1281
+ function renderSpaceTreeBlock(spaceId, migrations, multiSpace, glyphMode, style, colorize, liveContractHash, graphForSpace, appSpaceId, globalMaxEdgeTreePrefixWidth, globalMaxDirNameWidth) {
1282
+ if (migrations.length === 0) {
1283
+ const emptyLine = formatEmptyStateLine(spaceId, style);
1284
+ if (!multiSpace) return [emptyLine];
1285
+ return [style.spaceHeading(`${spaceId}:`), ` ${emptyLine}`];
1286
+ }
1287
+ const graph = graphForSpace(spaceId) ?? migrationGraphFromListEntries(migrations);
1288
+ const isAppSpace = appSpaceId === void 0 ? void 0 : spaceId === appSpaceId;
1289
+ const treeOutput = renderMigrationGraphSpaceTree({
1290
+ graph,
1291
+ migrations,
1292
+ liveContractHash,
1293
+ glyphMode,
1294
+ colorize,
1295
+ refsByHash: buildRefsByHashFromListEntries(migrations),
1296
+ styler: style,
1297
+ ...isAppSpace !== void 0 ? { isAppSpace } : {},
1298
+ ...globalMaxEdgeTreePrefixWidth !== void 0 ? { globalMaxEdgeTreePrefixWidth } : {},
1299
+ ...globalMaxDirNameWidth !== void 0 ? { globalMaxDirNameWidth } : {}
1300
+ });
1301
+ if (!multiSpace) return treeOutput.length === 0 ? [] : [treeOutput];
1302
+ const indented = indentMigrationGraphTreeBlock(treeOutput, " ");
1303
+ return [style.spaceHeading(`${spaceId}:`), indented];
1304
+ }
1305
+ /**
1306
+ * Compose the styled `migration list` human output via the shared tree
1307
+ * renderer. Each on-disk migration is one edge row with package-fact
1308
+ * annotations; refs decorate destination contract nodes.
1309
+ *
1310
+ * `options.colorize` must match whether `style` emits ANSI (e.g. both true for
1311
+ * `createAnsiMigrationListStyler({ useColor: true })`).
1312
+ */
1313
+ function renderMigrationListWithStyle(result, style, glyphMode = "unicode", options = {}) {
1314
+ const multiSpace = result.spaces.length > 1;
1315
+ const colorize = options.colorize ?? false;
1316
+ const liveContractHash = options.liveContractHash ?? EMPTY_CONTRACT_HASH;
1317
+ const graphForSpace = options.graphForSpace ?? (() => void 0);
1318
+ const appSpaceId = options.appSpaceId;
1319
+ const globalLayoutInputs = multiSpace ? result.spaces.filter((space) => space.migrations.length > 0).map((space) => ({
1320
+ graph: graphForSpace(space.space) ?? migrationGraphFromListEntries(space.migrations),
1321
+ liveContractHash
1322
+ })) : [];
1323
+ const globalMaxEdgeTreePrefixWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxEdgeTreePrefixWidth(globalLayoutInputs) : void 0;
1324
+ const globalMaxDirNameWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxDirNameWidth(globalLayoutInputs) : void 0;
1325
+ const lines = [];
1326
+ for (let index = 0; index < result.spaces.length; index++) {
1327
+ const space = result.spaces[index];
1328
+ if (index > 0) lines.push("");
1329
+ lines.push(...renderSpaceTreeBlock(space.space, space.migrations, multiSpace, glyphMode, style, colorize, liveContractHash, graphForSpace, appSpaceId, globalMaxEdgeTreePrefixWidth, globalMaxDirNameWidth));
1330
+ }
1331
+ if (result.spaces.reduce((count, space) => count + space.migrations.length, 0) > 0) {
1332
+ lines.push("");
1333
+ lines.push(style.summary(result.summary));
1334
+ }
1335
+ return lines.join("\n");
1336
+ }
1337
+ //#endregion
1338
+ //#region src/utils/formatters/migration-list-styler.ts
1339
+ function hasMarkersFormatter(styler) {
1340
+ return "markers" in styler && typeof styler.markers === "function";
1341
+ }
1342
+ function styleMarkerName(name) {
1343
+ return name === "contract" ? bold(green(name)) : green(name);
1344
+ }
1345
+ function plainMarkers(names) {
1346
+ return names.map((name) => `@${name}`).join(" ");
1347
+ }
1348
+ function formatContractNodeOverlays(styler, markers, refs) {
1349
+ const parts = [];
1350
+ if (markers.length > 0) parts.push(hasMarkersFormatter(styler) ? styler.markers(markers) : plainMarkers(markers));
1351
+ if (refs.length > 0) parts.push(styler.refs(refs));
1352
+ return parts.join(" ");
1353
+ }
1354
+ /**
1355
+ * The current contract overlay marker. Unlike user refs, this names the user's
1356
+ * declared desired state — the implicit base/target for `plan` / `migrate` —
1357
+ * not a stored label. It is emphasized (bold) so it stands out from plain refs
1358
+ * (including the live-database `db` marker, which is just another ref).
1359
+ */
1360
+ const CONTRACT_MARKER_NAME = "contract";
1361
+ function styleRefName(name) {
1362
+ return green(name);
1363
+ }
1364
+ /**
1365
+ * Build a {@link MigrationListStyler} that decorates `migration list`
1366
+ * tokens with ANSI SGR codes. When `useColor` is `false` (non-TTY,
1367
+ * `--no-color`, `NO_COLOR=1`, piped output) the function returns the
1368
+ * shared identity styler so callers get plain text with zero ANSI
1369
+ * bytes — pipe-friendly by construction.
1370
+ *
1371
+ * Palette:
1372
+ *
1373
+ * - `dirName`: bold
1374
+ * - `sourceHash`: dim cyan
1375
+ * - `destHash`: bright cyan
1376
+ * - `kind` (`*` / `↩` / `⟲`): bright — the signal; lanes and arrows dim
1377
+ * - `glyph` (`→` / `⟲` / `∅`): dim
1378
+ * - `lane` (graph gutter lines `│` and fan/join connectors `├─┐` / `├─┘`): dim
1379
+ * - `invariants` (`{...}`): yellow
1380
+ * - `markers` (`@contract @db`): green; the `contract` desired-state marker is
1381
+ * green-bold (`db` is plain green); the `@` sigil is applied to each name
1382
+ * - `refs` (`(...)`): green (the active ref is bolded separately by the tree styler)
1383
+ * - `spaceHeading` (`<spaceId>:`): bold
1384
+ * - `summary`: dim
1385
+ * - `emptyState`: dim
1386
+ */
1387
+ function createAnsiMigrationListStyler(opts) {
1388
+ if (!opts.useColor) return {
1389
+ ...IDENTITY_MIGRATION_LIST_STYLER,
1390
+ markers: plainMarkers
1391
+ };
1392
+ return {
1393
+ kind: (text) => text,
1394
+ dirName: (text) => bold(text),
1395
+ sourceHash: (text) => dim(cyan(text)),
1396
+ destHash: (text) => cyanBright(text),
1397
+ glyph: (text) => dim(text),
1398
+ lane: (text) => dim(text),
1399
+ invariants: (ids) => yellow(`{${ids.join(", ")}}`),
1400
+ markers: (names) => {
1401
+ const sigil = green("@");
1402
+ return names.map((name) => sigil + styleMarkerName(name)).join(" ");
1403
+ },
1404
+ refs: (names) => {
1405
+ const open = green("(");
1406
+ const close = green(")");
1407
+ const separator = green(", ");
1408
+ return open + names.map(styleRefName).join(separator) + close;
1409
+ },
1410
+ spaceHeading: (text) => bold(text),
1411
+ summary: (text) => dim(text),
1412
+ emptyState: (text) => dim(text)
1413
+ };
1414
+ }
1415
+ //#endregion
1416
+ //#region src/utils/formatters/migration-graph-labels.ts
1417
+ /**
1418
+ * Per-row label formatting for the command graph renderer.
1419
+ *
1420
+ * The command graph renderer ({@link renderMigrationGraphCommand}) derives the
1421
+ * graph structure — rows, gutter, lane colours — from the grid pipeline. The
1422
+ * per-row LABEL (contract hash + markers + refs for node rows;
1423
+ * migration name + `from → to` + ops/status/will-run for migration rows) is
1424
+ * formatted here. This module owns ONLY label text + styling; it knows nothing
1425
+ * about lanes, gutters, or grid geometry.
1426
+ *
1427
+ * The label format (hash abbreviation, `from → to` arrow column, `@contract`/
1428
+ * `@db` markers, `(refs)`, ops/status/will-run suffix, the legend) is the same
1429
+ * as the previous renderer — that part was never the bug.
1430
+ */
1431
+ /**
1432
+ * The live-database overlay marker. Just another ref as far as styling goes —
1433
+ * the only emphasized markers are the active ref and the `contract`
1434
+ * desired-state marker (see {@link CONTRACT_MARKER_NAME}).
1435
+ */
1436
+ const DB_MARKER_NAME = "db";
1437
+ /**
1438
+ * Forced-color functions that always emit ANSI regardless of the ambient TTY
1439
+ * environment (NO_COLOR, piped output). Used so on-path green / off-path dim are
1440
+ * deterministically emitted in tests that request colour while NO_COLOR is set.
1441
+ */
1442
+ const { dim: forcedDim, bold: forcedBold } = createColors({ useColor: true });
1443
+ const { greenBright: forcedGreen } = createColors({ useColor: true });
1444
+ /**
1445
+ * The two label styles used in `migrate --show` path-highlight mode.
1446
+ *
1447
+ * - `onPath`: bold name, neutral hashes (the on-path lane glyphs are coloured
1448
+ * green by the grid renderer, not here).
1449
+ * - `offPath`: uniform dim grey on the name and the whole hash column.
1450
+ *
1451
+ * To change the on-path / off-path label colour in future, edit this object.
1452
+ */
1453
+ const PATH_HIGHLIGHT_STYLES = {
1454
+ onPath: (_style, colorize) => ({
1455
+ lane: colorize ? forcedGreen : (text) => text,
1456
+ arrow: (text) => text,
1457
+ dirName: (text) => bold(text),
1458
+ hashOverride: void 0
1459
+ }),
1460
+ offPath: (colorize) => ({
1461
+ lane: colorize ? forcedDim : (text) => text,
1462
+ arrow: colorize ? forcedDim : (text) => text,
1463
+ dirName: colorize ? forcedDim : (text) => text,
1464
+ hashOverride: colorize ? forcedDim : void 0
1465
+ })
1466
+ };
1467
+ function abbreviateHash(hash, hashLength, emptySource) {
1468
+ if (hash === EMPTY_CONTRACT_HASH) return emptySource;
1469
+ return (hash.startsWith("sha256:") ? hash.slice(7) : hash).slice(0, hashLength);
1470
+ }
1471
+ function overlayNamesForContract(contractHash, opts) {
1472
+ const markers = [];
1473
+ const refs = [];
1474
+ const userRefs = opts.refsByHash?.get(contractHash);
1475
+ if (userRefs) refs.push(...[...userRefs].sort((a, b) => a.localeCompare(b)));
1476
+ if (opts.isAppSpace !== false && opts.contractHash === contractHash && contractHash !== EMPTY_CONTRACT_HASH) markers.push(CONTRACT_MARKER_NAME);
1477
+ if (opts.dbHash === contractHash) markers.push(DB_MARKER_NAME);
1478
+ markers.sort((a, b) => {
1479
+ if (a === "contract") return -1;
1480
+ if (b === "contract") return 1;
1481
+ return a.localeCompare(b);
1482
+ });
1483
+ return {
1484
+ markers,
1485
+ refs
1486
+ };
1487
+ }
1488
+ function createLabelStyler(opts) {
1489
+ const base = opts.styler ?? createAnsiMigrationListStyler({ useColor: opts.colorize });
1490
+ const activeRefName = opts.activeRefName;
1491
+ if (!opts.colorize || activeRefName === void 0) return base;
1492
+ return {
1493
+ ...base,
1494
+ refs: (names) => {
1495
+ const styledNames = names.map((name) => name === activeRefName ? bold(name) : name);
1496
+ return base.refs(styledNames);
1497
+ }
1498
+ };
1499
+ }
1500
+ function overlayStatusGlyphs(mode) {
1501
+ return mode === "ascii" ? {
1502
+ applied: "+",
1503
+ pending: ">"
1504
+ } : {
1505
+ applied: "✓",
1506
+ pending: "⧗"
1507
+ };
1508
+ }
1509
+ function formatEdgeAnnotationSuffix(migrationHash, opts, style) {
1510
+ const annotation = opts.edgeAnnotationsByHash?.get(migrationHash);
1511
+ if (annotation === void 0) return "";
1512
+ const isOffPath = annotation.pathHighlight === "off-path";
1513
+ const segments = [];
1514
+ if (annotation.operationCount !== void 0) segments.push(`${annotation.operationCount} ops`);
1515
+ if (annotation.invariants !== void 0 && annotation.invariants.length > 0) segments.push(style.invariants(annotation.invariants));
1516
+ const status = annotation.status;
1517
+ if (status !== void 0) {
1518
+ const glyphs = overlayStatusGlyphs(opts.glyphMode ?? "unicode");
1519
+ const glyph = status === "applied" ? glyphs.applied : glyphs.pending;
1520
+ const label = status === "applied" ? "applied" : "pending";
1521
+ if (!opts.colorize) segments.push(`${glyph} ${label}`);
1522
+ else {
1523
+ const styler = status === "applied" ? green : yellow;
1524
+ segments.push(styler(`${glyph} ${label}`));
1525
+ }
1526
+ }
1527
+ if (annotation.pathHighlight === "on-path") {
1528
+ const glyph = opts.glyphMode === "ascii" ? ">" : "↑";
1529
+ segments.push(`${glyph} will run`);
1530
+ }
1531
+ if (segments.length === 0) return "";
1532
+ const suffix = ` ${segments.join(" ")}`;
1533
+ return opts.colorize && isOffPath ? forcedDim(suffix) : suffix;
1534
+ }
1535
+ /**
1536
+ * Format the `from → to` hash data column for an edge row.
1537
+ *
1538
+ * When `hashOverride` is provided (off-path → `dim`), it replaces ALL sub-stylers
1539
+ * so dim reaches every character without inner ANSI codes overriding it.
1540
+ */
1541
+ function formatEdgeHashColumn(edge, style, hashLength, glyphMode, hashOverride) {
1542
+ const emptySource = migrationListEmptySource(glyphMode);
1543
+ const forwardArrow = migrationListForwardArrow(glyphMode);
1544
+ const src = hashOverride ?? style.sourceHash;
1545
+ const dst = hashOverride ?? style.destHash;
1546
+ const glyph = hashOverride ?? style.glyph;
1547
+ if (edge.kind === "self") {
1548
+ const hash = abbreviateHash(edge.from, hashLength, emptySource);
1549
+ return `${padFromHashColumn(src(hash), hashLength)} ${glyph(forwardArrow)} ${dst(hash)}`;
1550
+ }
1551
+ return `${edge.from === EMPTY_CONTRACT_HASH ? padFromHashColumn(glyph(emptySource), hashLength) : padFromHashColumn(src(abbreviateHash(edge.from, hashLength, emptySource)), hashLength)} ${glyph(forwardArrow)} ${dst(abbreviateHash(edge.to, hashLength, emptySource))}`;
1552
+ }
1553
+ /**
1554
+ * The label text for a contract node row: the abbreviated hash (or the `∅`
1555
+ * empty-source token for the baseline) followed by its `@contract`/`@db` markers
1556
+ * and `(refs)`, with two spaces between the hash and the overlay block.
1557
+ */
1558
+ function formatNodeLabel(contractHash, opts, nodeHighlight) {
1559
+ const style = createLabelStyler(opts);
1560
+ const hashLength = opts.hashLength ?? 7;
1561
+ const emptySource = migrationListEmptySource(opts.glyphMode ?? "unicode");
1562
+ const overlays = overlayNamesForContract(contractHash, opts);
1563
+ const hasOverlays = overlays.markers.length > 0 || overlays.refs.length > 0;
1564
+ const offPath = nodeHighlight === "off-path" && opts.colorize;
1565
+ const hashText = contractHash === EMPTY_CONTRACT_HASH ? (offPath ? forcedDim : style.glyph)(emptySource) : (offPath ? forcedDim : style.sourceHash)(abbreviateHash(contractHash, hashLength, emptySource));
1566
+ if (!hasOverlays) return hashText;
1567
+ return `${hashText} ${formatContractNodeOverlays(style, overlays.markers, overlays.refs)}`;
1568
+ }
1569
+ /**
1570
+ * The label text for a migration row: the migration name (padded to
1571
+ * `dirNameWidth`) followed by the `from → to` hash column and the annotation
1572
+ * suffix (ops / status / will-run).
1573
+ *
1574
+ * In flat mode the name is tinted with its lane's hue (`lane` ≥ 0), so the node
1575
+ * `○`, the edges/arrows in the gutter, and the name all read in one colour. In
1576
+ * focus mode the on-path/off-path role overrides the lane hue (bold / dim).
1577
+ */
1578
+ function formatMigrationLabel(edge, dirNameWidth, opts, lane) {
1579
+ const style = createLabelStyler(opts);
1580
+ const hashLength = opts.hashLength ?? 7;
1581
+ const glyphMode = opts.glyphMode ?? "unicode";
1582
+ const highlight = opts.edgeAnnotationsByHash?.get(edge.migrationHash)?.pathHighlight;
1583
+ let dirNameStyler;
1584
+ let hashOverride;
1585
+ if (highlight === "on-path") {
1586
+ dirNameStyler = (text) => bold(text);
1587
+ hashOverride = void 0;
1588
+ } else if (highlight === "off-path") {
1589
+ dirNameStyler = opts.colorize ? forcedDim : style.dirName;
1590
+ hashOverride = opts.colorize ? forcedDim : void 0;
1591
+ } else if (opts.colorize && lane !== void 0) {
1592
+ dirNameStyler = (text) => forcedBold(laneColorizer(lane)(text));
1593
+ hashOverride = void 0;
1594
+ } else {
1595
+ dirNameStyler = style.dirName;
1596
+ hashOverride = void 0;
1597
+ }
1598
+ const dirNamePadding = " ".repeat(Math.max(0, dirNameWidth - edge.dirName.length));
1599
+ return `${`${dirNameStyler(edge.dirName)}${dirNamePadding}`}${formatEdgeHashColumn(edge, style, hashLength, glyphMode, hashOverride)}${formatEdgeAnnotationSuffix(edge.migrationHash, opts, style)}`;
1600
+ }
1601
+ /**
1602
+ * Format a single on-path migration row for the `migrate --show` run-list.
1603
+ * Shares PATH_HIGHLIGHT_STYLES.onPath with the graph tree so the run-list and
1604
+ * the graph are byte-for-byte identical in their name/hash columns.
1605
+ */
1606
+ function formatOnPathMigrationRow(dirName, from, to, dirNameWidth, colorize, glyphMode) {
1607
+ const style = createAnsiMigrationListStyler({ useColor: colorize });
1608
+ const styledDirName = `${PATH_HIGHLIGHT_STYLES.onPath(style, colorize).dirName(dirName)}${" ".repeat(Math.max(0, dirNameWidth - dirName.length))}`;
1609
+ const hashLength = 7;
1610
+ const emptySource = migrationListEmptySource(glyphMode);
1611
+ const forwardArrow = migrationListForwardArrow(glyphMode);
1612
+ const fromAbbr = from === EMPTY_CONTRACT_HASH ? padFromHashColumn(style.glyph(emptySource), hashLength) : padFromHashColumn(style.sourceHash(abbreviateHash(from, hashLength, emptySource)), hashLength);
1613
+ const toAbbr = to === EMPTY_CONTRACT_HASH ? style.glyph(emptySource) : style.destHash(abbreviateHash(to, hashLength, emptySource));
1614
+ return `${styledDirName} ${fromAbbr} ${style.glyph(forwardArrow)} ${toAbbr}`;
1615
+ }
1616
+ function legendGlyphs(mode) {
1617
+ return mode === "ascii" ? {
1618
+ node: "*",
1619
+ forward: "^",
1620
+ rollback: "v",
1621
+ self: "@"
1622
+ } : {
1623
+ node: "○",
1624
+ forward: "↑",
1625
+ rollback: "↓",
1626
+ self: "⟲"
1627
+ };
1628
+ }
1629
+ function formatLegendExampleMarkers(colorize) {
1630
+ if (!colorize) return "@contract @db";
1631
+ const sigil = green("@");
1632
+ return `${sigil + bold(green("contract"))} ${sigil}${green("db")}`;
1633
+ }
1634
+ /**
1635
+ * A compact key for the tree visual language: the contract node glyph, the
1636
+ * in-lane direction arrows, the empty baseline, the system-marker `@…` and
1637
+ * user-ref `(…)` conventions, and a worked sample of the data-column hash arrow.
1638
+ */
1639
+ function renderMigrationGraphLegend(opts) {
1640
+ const glyphMode = opts.glyphMode ?? "unicode";
1641
+ const style = createAnsiMigrationListStyler({ useColor: opts.colorize });
1642
+ const glyphs = legendGlyphs(glyphMode);
1643
+ const emptySource = migrationListEmptySource(glyphMode);
1644
+ const forwardArrow = migrationListForwardArrow(glyphMode);
1645
+ const sampleArrow = `${style.sourceHash("aaaaaa")} ${style.glyph(forwardArrow)} ${style.destHash("bbbbbb")}`;
1646
+ const statusGlyphs = overlayStatusGlyphs(glyphMode);
1647
+ const appliedPending = opts.colorize ? ` ${green(statusGlyphs.applied)} ${style.summary("applied")} ${yellow(statusGlyphs.pending)} ${style.summary("pending")}` : ` ${statusGlyphs.applied} ${style.summary("applied")} ${statusGlyphs.pending} ${style.summary("pending")}`;
1648
+ const exampleMarkers = formatLegendExampleMarkers(opts.colorize);
1649
+ const exampleRefs = opts.colorize ? style.refs(["prod", "staging"]) : "(prod, staging)";
1650
+ return [
1651
+ "Legend:",
1652
+ ` ${style.kind(glyphs.node)} ${style.summary("contract")} ${style.kind(glyphs.forward)} ${style.summary("forward")} ${style.kind(glyphs.rollback)} ${style.summary("rollback")}`,
1653
+ ` ${style.kind(glyphs.self)} ${style.summary("migration without schema change")}`,
1654
+ appliedPending,
1655
+ ` ${style.kind(emptySource)} ${style.summary("empty database (baseline)")}`,
1656
+ ` ${exampleMarkers} ${style.summary("reserved markers — also typeable as --from/--to tokens")}`,
1657
+ ` ${exampleRefs} ${style.summary("user-defined refs")}`,
1658
+ ` ${sampleArrow} ${style.summary("migration from contract aaaaaa to bbbbbb")}`
1659
+ ].join("\n");
1660
+ }
1661
+ //#endregion
1662
+ //#region src/utils/formatters/migration-graph-command-render.ts
1663
+ /**
1664
+ * Command graph renderer: composes the gutter (from the grid) with per-row labels.
1665
+ *
1666
+ * Pipeline: buildMigrationGraphRows → buildGrid → renderMigrationGraphCommand
1667
+ *
1668
+ * Each grid row is classified by its cells: a node row gets a contract label;
1669
+ * a migration arrow row gets a migration label; connector rows get no label.
1670
+ * Label format and styling live in `./migration-graph-labels`.
1671
+ */
1672
+ const LABEL_GAP = 2;
1673
+ const MIN_HASH_DATA_COLUMN = 25;
1674
+ /**
1675
+ * Classify a grid row by its own cells:
1676
+ * - a cell carrying a NodeRef → node row (contract label);
1677
+ * - a cell whose top line is an arrow ({up}/{down}/self-loop) → migration row;
1678
+ * - otherwise → no label.
1679
+ *
1680
+ * A migration's arrow appears in exactly one grid row (the forward `↑` row, the
1681
+ * adjacent-rollback `↓` row, or the self-loop `⟲` row), so each migration gets
1682
+ * exactly one label, on the row that draws its arrow.
1683
+ *
1684
+ * Two distinct migrations with identical content (same from/to/ops) hash to the
1685
+ * SAME migration hash, so the arrow line is matched on BOTH its hash and its
1686
+ * `dirName` (which the LineRef carries per-row) — otherwise both rows would
1687
+ * resolve to one edge and the other migration's name would be lost.
1688
+ */
1689
+ function classifyRow(row, edgesByHash) {
1690
+ for (const cell of row) if (cell.node !== void 0) return {
1691
+ kind: "node",
1692
+ contractHash: cell.node.contractHash
1693
+ };
1694
+ for (const cell of row) {
1695
+ const arrow = arrowLine(cell);
1696
+ if (arrow === void 0) continue;
1697
+ const candidates = edgesByHash.get(arrow.line.migrationHash) ?? [];
1698
+ const edge = candidates.find((e) => e.dirName === arrow.line.dirName) ?? candidates[0];
1699
+ if (edge !== void 0) return {
1700
+ kind: "migration",
1701
+ edge,
1702
+ lane: arrow.line.lane
1703
+ };
1704
+ }
1705
+ return { kind: "none" };
1706
+ }
1707
+ /**
1708
+ * Return the cell's arrow line if it carries one — a self-loop, or a line whose
1709
+ * directions are exactly `{up}` or `{down}` (the migration-direction arrows).
1710
+ * Connector/corner/vertical lines are not arrows and yield `undefined`.
1711
+ */
1712
+ function arrowLine(cell) {
1713
+ for (const line of cell.lines) {
1714
+ if (line.selfLoop === true) return line;
1715
+ if (line.landingArrow === true) continue;
1716
+ const dirs = line.directions;
1717
+ if (dirs.size !== 1) continue;
1718
+ if (dirs.has("up") || dirs.has("down")) return line;
1719
+ }
1720
+ }
1721
+ /**
1722
+ * Resolve each contract's path-highlight role from the edges incident on it.
1723
+ * On-path wins: a contract touched by any on-path edge is on-path. Empty unless
1724
+ * focus-mode annotations are present.
1725
+ */
1726
+ function resolveNodeHighlights(rowModel, edgeAnnotationsByHash) {
1727
+ const result = /* @__PURE__ */ new Map();
1728
+ if (edgeAnnotationsByHash === void 0) return result;
1729
+ for (const edge of rowModel.edges) {
1730
+ const highlight = edgeAnnotationsByHash.get(edge.migrationHash)?.pathHighlight;
1731
+ if (highlight === void 0) continue;
1732
+ for (const hash of [edge.from, edge.to]) {
1733
+ if (hash === EMPTY_CONTRACT_HASH) continue;
1734
+ if (result.get(hash) !== "on-path") result.set(hash, highlight);
1735
+ }
1736
+ }
1737
+ return result;
1738
+ }
1739
+ function maxDirNameLength(edges) {
1740
+ let max = 0;
1741
+ for (const edge of edges) max = Math.max(max, edge.dirName.length);
1742
+ return max;
1743
+ }
1744
+ /**
1745
+ * The label column for a render: the widest gutter (visible width) across every
1746
+ * row, plus the label gap. Labels begin here so they line up regardless of how
1747
+ * deep the lane structure runs on any one row. A cross-space override widens it
1748
+ * so sibling space sections share one column.
1749
+ */
1750
+ function computeLabelColumn(grid, glyphMode) {
1751
+ let maxGutter = 0;
1752
+ for (const row of grid) {
1753
+ const gutter = renderGridRow(row, {
1754
+ colorize: false,
1755
+ glyphMode
1756
+ });
1757
+ maxGutter = Math.max(maxGutter, stringWidth(gutter));
1758
+ }
1759
+ return maxGutter + LABEL_GAP;
1760
+ }
1761
+ function computeMaxDirNameWidth(rowModel) {
1762
+ return maxDirNameLength(rowModel.edges);
1763
+ }
1764
+ function padVisible(text, targetWidth) {
1765
+ const padding = Math.max(0, targetWidth - stringWidth(text));
1766
+ return text + " ".repeat(padding);
1767
+ }
1768
+ const ANSI_ESCAPE = "\x1B";
1769
+ function trimTrailingWhitespace(line) {
1770
+ const trailingSpaceBeforeReset = new RegExp(`[\\t ]+((?:${ANSI_ESCAPE}\\[[0-9;]*m)+)$`);
1771
+ return line.replace(trailingSpaceBeforeReset, "$1").replace(/\s+$/, "");
1772
+ }
1773
+ function renderMigrationGraphCommand(input) {
1774
+ const { grid, rowModel } = input;
1775
+ const glyphMode = input.glyphMode;
1776
+ const edgesByHash = /* @__PURE__ */ new Map();
1777
+ for (const edge of rowModel.edges) {
1778
+ const bucket = edgesByHash.get(edge.migrationHash);
1779
+ if (bucket) bucket.push(edge);
1780
+ else edgesByHash.set(edge.migrationHash, [edge]);
1781
+ }
1782
+ const labelOpts = {
1783
+ colorize: input.colorize,
1784
+ glyphMode,
1785
+ ...ifDefined("refsByHash", input.refsByHash),
1786
+ ...ifDefined("edgeAnnotationsByHash", input.edgeAnnotationsByHash),
1787
+ ...ifDefined("dbHash", input.dbHash),
1788
+ ...ifDefined("contractHash", input.contractHash),
1789
+ ...ifDefined("isAppSpace", input.isAppSpace),
1790
+ ...ifDefined("activeRefName", input.activeRefName),
1791
+ ...ifDefined("styler", input.styler)
1792
+ };
1793
+ const nodeHighlights = resolveNodeHighlights(rowModel, input.edgeAnnotationsByHash);
1794
+ const labelColumn = input.globalLabelColumn ?? computeLabelColumn(grid, glyphMode);
1795
+ const maxDirNameLen = input.globalMaxDirNameWidth ?? maxDirNameLength(rowModel.edges);
1796
+ const dirNameWidth = Math.max(maxDirNameLen + LABEL_GAP, MIN_HASH_DATA_COLUMN - labelColumn);
1797
+ const lines = [];
1798
+ for (const row of grid) {
1799
+ const gutter = renderGridRow(row, {
1800
+ colorize: input.colorize,
1801
+ glyphMode
1802
+ });
1803
+ const identity = classifyRow(row, edgesByHash);
1804
+ if (identity.kind === "none") {
1805
+ lines.push(trimTrailingWhitespace(gutter));
1806
+ continue;
1807
+ }
1808
+ const gutterPad = padVisible(gutter, labelColumn);
1809
+ if (identity.kind === "node") {
1810
+ const label = formatNodeLabel(identity.contractHash, labelOpts, nodeHighlights.get(identity.contractHash));
1811
+ lines.push(trimTrailingWhitespace(label.length === 0 ? gutter : `${gutterPad}${label}`));
1812
+ continue;
1813
+ }
1814
+ const label = formatMigrationLabel(identity.edge, dirNameWidth, labelOpts, identity.lane);
1815
+ lines.push(trimTrailingWhitespace(`${gutterPad}${label}`));
1816
+ }
1817
+ return lines.join("\n");
1818
+ }
1819
+ //#endregion
1820
+ export { migrationListEmptySource as _, renderMigrationGraphLegend as a, renderMigrationListWithStyle as c, highlightFromEdgeAnnotations as d, indentMigrationGraphTreeBlock as f, abbreviateContractHash as g, buildGrid as h, formatOnPathMigrationRow as i, computeGlobalMaxDirNameWidth as l, buildMigrationGraphRows as m, computeMaxDirNameWidth as n, createAnsiMigrationListStyler as o, renderMigrationGraphSpaceTree as p, renderMigrationGraphCommand as r, IDENTITY_MIGRATION_LIST_STYLER as s, computeLabelColumn as t, computeGlobalMaxEdgeTreePrefixWidth as u, migrationListForwardArrow as v };
1821
+
1822
+ //# sourceMappingURL=migration-graph-command-render-BAOzyYF6.mjs.map