@peasant-labs/fairtrade 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/lib/ChartLine-Dlp6-CLL.js +264 -0
  2. package/dist/lib/InUseShell-DZvmRdj-.js +1532 -0
  3. package/dist/lib/analytics.css +1 -0
  4. package/dist/lib/analytics.js +1052 -0
  5. package/dist/lib/commons.css +1 -0
  6. package/dist/lib/commons.js +3275 -0
  7. package/dist/lib/components.css +1 -1
  8. package/dist/lib/graph.css +1 -0
  9. package/dist/lib/graph.js +823 -0
  10. package/dist/lib/types/Intensity.d.ts +3 -3
  11. package/dist/lib/types/MapCanvas.d.ts +37 -5
  12. package/dist/lib/types/RoleRoster.d.ts +12 -1
  13. package/dist/lib/types/analytics/ChartCard.d.ts +18 -0
  14. package/dist/lib/types/analytics/ContributorTable.d.ts +16 -0
  15. package/dist/lib/types/analytics/ProjectOverview.d.ts +40 -0
  16. package/dist/lib/types/analytics/format.d.ts +48 -0
  17. package/dist/lib/types/analytics/index.d.ts +24 -0
  18. package/dist/lib/types/analytics/metrics.d.ts +130 -0
  19. package/dist/lib/types/analytics/stats.d.ts +23 -0
  20. package/dist/lib/types/analytics/time.d.ts +32 -0
  21. package/dist/lib/types/analytics/types.d.ts +453 -0
  22. package/dist/lib/types/commons/Explore.d.ts +6 -0
  23. package/dist/lib/types/commons/Manage.d.ts +34 -0
  24. package/dist/lib/types/commons/index.d.ts +24 -0
  25. package/dist/lib/types/commons/providers.d.ts +8 -0
  26. package/dist/lib/types/commons/types.d.ts +356 -0
  27. package/dist/lib/types/graph/ChangeDetail.d.ts +28 -0
  28. package/dist/lib/types/graph/Changes.d.ts +21 -0
  29. package/dist/lib/types/graph/CodeMap.d.ts +49 -0
  30. package/dist/lib/types/graph/CodeMapComposition.d.ts +85 -0
  31. package/dist/lib/types/graph/changeGraph.d.ts +106 -0
  32. package/dist/lib/types/graph/index.d.ts +30 -0
  33. package/dist/lib/types/graph/types.d.ts +579 -0
  34. package/dist/lib/types/index.d.ts +1 -0
  35. package/dist/lib/types/inuse/InUseShell.d.ts +50 -0
  36. package/dist/lib/ui-oBFnHPFe.js +11146 -0
  37. package/dist/lib/ui.js +4 -12693
  38. package/package.json +37 -6
@@ -0,0 +1,1532 @@
1
+ import { useCallback as e, useEffect as t, useId as n, useMemo as r, useRef as i, useState as a } from "react";
2
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
3
+ import { Check as l, ChevronDown as u, ChevronLeft as d, ChevronRight as f, Eye as p, EyeOff as m, FileCode as h, Folder as g, GitMerge as ee, Maximize as te, Minus as ne, Plus as re, ScrollText as ie, Search as ae, Star as oe, TriangleAlert as se, Users as ce, Waypoints as _ } from "lucide-react";
4
+ //#region src/ui/CommitGraph.jsx
5
+ var v = 14, le = 9, ue = 7, de = 9, y = "3 3", b = (e) => le + e * v, x = (e) => b(Math.max(e - 1, 0)) + ue;
6
+ function fe({ commits: e = [], selectedId: t, onSelect: n, hasMore: i = !1, onShowOlder: a, label: o = "commit history", className: l = "", ...d }) {
7
+ let f = r(() => e.reduce((e, t) => Math.max(e, (t.lane ?? 0) + 1), 1), [e]), p = r(() => {
8
+ let t = new Map(e.map((e) => [e.id, e.lane ?? 0])), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
9
+ return e.forEach((e, t) => {
10
+ let i = e.lane ?? 0;
11
+ n.has(i) || n.set(i, t), r.set(i, t);
12
+ }), e.map((e, i) => {
13
+ let a = e.lane ?? 0, o = (e.parents ?? []).map((e) => t.get(e)).filter((e) => e !== void 0 && e !== a).map((e) => ({
14
+ from: a,
15
+ to: e
16
+ })), s = [];
17
+ for (let [e, t] of n) e !== a && i >= t && i <= r.get(e) && s.push(e);
18
+ let c = r.get(a);
19
+ return {
20
+ commit: e,
21
+ lane: a,
22
+ joins: o,
23
+ passLanes: s,
24
+ laneUp: i > n.get(a),
25
+ laneDown: i < c
26
+ };
27
+ });
28
+ }, [e]), m = x(f), h = ["cg", l].filter(Boolean).join(" ");
29
+ return e.length === 0 ? /* @__PURE__ */ s("div", {
30
+ className: h,
31
+ ...d,
32
+ children: /* @__PURE__ */ s("p", {
33
+ className: "cg-empty",
34
+ children: "no commits to show."
35
+ })
36
+ }) : /* @__PURE__ */ c("div", {
37
+ className: h,
38
+ role: "list",
39
+ "aria-label": o,
40
+ ...d,
41
+ children: [p.map((e) => /* @__PURE__ */ s(S, {
42
+ row: e,
43
+ width: m,
44
+ selected: e.commit.id === t,
45
+ onSelect: n
46
+ }, e.commit.id)), i && /* @__PURE__ */ c("div", {
47
+ className: "cg-older-band",
48
+ children: [/* @__PURE__ */ s("span", {
49
+ className: "cg-gutter cg-gutter-older",
50
+ style: { width: m },
51
+ "aria-hidden": "true",
52
+ children: /* @__PURE__ */ s("svg", {
53
+ className: "cg-svg",
54
+ width: m,
55
+ height: "100%",
56
+ preserveAspectRatio: "none",
57
+ children: /* @__PURE__ */ s("line", {
58
+ className: "cg-stroke-lane0",
59
+ x1: b(0),
60
+ y1: "0",
61
+ x2: b(0),
62
+ y2: "60%",
63
+ strokeDasharray: y
64
+ })
65
+ })
66
+ }), /* @__PURE__ */ c("button", {
67
+ type: "button",
68
+ className: "cg-older",
69
+ onClick: a,
70
+ children: [/* @__PURE__ */ s(u, {
71
+ className: "cg-older-ic",
72
+ "aria-hidden": "true"
73
+ }), "show older"]
74
+ })]
75
+ })]
76
+ });
77
+ }
78
+ function S({ row: e, width: t, selected: n, onSelect: r }) {
79
+ let { commit: i, lane: a, joins: o, passLanes: l, laneUp: u, laneDown: d } = e, f = !!i.session, p = [
80
+ "cg-dot",
81
+ f ? "cg-dot-filled" : "cg-dot-hollow",
82
+ n && "cg-dot-sel"
83
+ ].filter(Boolean).join(" "), m = ["cg-row", n && "cg-row-sel"].filter(Boolean).join(" ");
84
+ return /* @__PURE__ */ c("div", {
85
+ className: "cg-band",
86
+ role: "listitem",
87
+ children: [/* @__PURE__ */ c("span", {
88
+ className: "cg-gutter",
89
+ style: { width: t },
90
+ "aria-hidden": "true",
91
+ children: [
92
+ /* @__PURE__ */ c("svg", {
93
+ className: "cg-svg",
94
+ width: t,
95
+ height: "100%",
96
+ preserveAspectRatio: "none",
97
+ children: [
98
+ u && /* @__PURE__ */ s("line", {
99
+ className: "cg-stroke-self",
100
+ x1: b(a),
101
+ y1: "0",
102
+ x2: b(a),
103
+ y2: "50%"
104
+ }),
105
+ d && /* @__PURE__ */ s("line", {
106
+ className: "cg-stroke-self",
107
+ x1: b(a),
108
+ y1: "50%",
109
+ x2: b(a),
110
+ y2: "100%"
111
+ }),
112
+ l.map((e) => /* @__PURE__ */ s("line", {
113
+ className: e === 0 ? "cg-stroke-lane0" : "cg-stroke-branch",
114
+ x1: b(e),
115
+ y1: "0",
116
+ x2: b(e),
117
+ y2: "100%"
118
+ }, e)),
119
+ o.map((e, t) => /* @__PURE__ */ c("g", {
120
+ className: "cg-elbow",
121
+ children: [/* @__PURE__ */ s("line", {
122
+ className: "cg-stroke-branch",
123
+ x1: b(e.to),
124
+ y1: "50%",
125
+ x2: b(e.to),
126
+ y2: "100%"
127
+ }), /* @__PURE__ */ s("line", {
128
+ className: "cg-stroke-branch",
129
+ x1: b(e.to),
130
+ y1: "50%",
131
+ x2: b(e.from),
132
+ y2: "50%"
133
+ })]
134
+ }, t))
135
+ ]
136
+ }),
137
+ /* @__PURE__ */ s("span", {
138
+ className: p,
139
+ style: {
140
+ left: b(a),
141
+ width: de,
142
+ height: de
143
+ },
144
+ "data-has-session": f || void 0
145
+ }),
146
+ f && /* @__PURE__ */ s(oe, {
147
+ className: "cg-spark",
148
+ style: { left: b(a) },
149
+ "aria-hidden": "true"
150
+ })
151
+ ]
152
+ }), /* @__PURE__ */ c("button", {
153
+ type: "button",
154
+ className: m,
155
+ onClick: () => r?.(i),
156
+ children: [/* @__PURE__ */ s("span", {
157
+ className: "cg-msg",
158
+ title: i.message,
159
+ children: i.message
160
+ }), /* @__PURE__ */ c("span", {
161
+ className: "cg-meta",
162
+ children: [
163
+ i.merged && /* @__PURE__ */ c("span", {
164
+ className: "cg-merged",
165
+ children: [/* @__PURE__ */ s(ee, {
166
+ className: "cg-merged-ic",
167
+ "aria-hidden": "true"
168
+ }), "merged"]
169
+ }),
170
+ i.tip && /* @__PURE__ */ s("span", {
171
+ className: "cg-tip",
172
+ children: "tip"
173
+ }),
174
+ i.branch && /* @__PURE__ */ s("span", {
175
+ className: "cg-branch",
176
+ children: i.branch
177
+ }),
178
+ f && /* @__PURE__ */ s("span", {
179
+ className: "cg-sr",
180
+ children: "session"
181
+ }),
182
+ i.time && /* @__PURE__ */ s("span", {
183
+ className: "cg-time tnum",
184
+ children: i.time
185
+ })
186
+ ]
187
+ })]
188
+ })]
189
+ });
190
+ }
191
+ //#endregion
192
+ //#region src/ui/DiffView.jsx
193
+ function C(e) {
194
+ let t = 0, n = 0;
195
+ for (let r of e) for (let e of r.lines) e.type === "add" ? t++ : e.type === "del" && n++;
196
+ return {
197
+ adds: t,
198
+ dels: n
199
+ };
200
+ }
201
+ function pe({ line: e }) {
202
+ let { type: t, oldNo: n, newNo: r, text: i } = e, a = t === "add" ? re : t === "del" ? ne : null;
203
+ return /* @__PURE__ */ c("div", {
204
+ className: `dv-line dv-${t}`,
205
+ role: "row",
206
+ children: [
207
+ /* @__PURE__ */ s("span", {
208
+ className: "dv-rail",
209
+ "aria-hidden": "true"
210
+ }),
211
+ /* @__PURE__ */ s("span", {
212
+ className: "dv-num dv-num-old tnum",
213
+ role: "cell",
214
+ children: n ?? ""
215
+ }),
216
+ /* @__PURE__ */ s("span", {
217
+ className: "dv-num dv-num-new tnum",
218
+ role: "cell",
219
+ children: r ?? ""
220
+ }),
221
+ /* @__PURE__ */ s("span", {
222
+ className: "dv-sign",
223
+ role: "cell",
224
+ "aria-hidden": "true",
225
+ children: a ? /* @__PURE__ */ s(a, { "aria-hidden": "true" }) : null
226
+ }),
227
+ /* @__PURE__ */ c("span", {
228
+ className: "dv-text",
229
+ role: "cell",
230
+ children: [/* @__PURE__ */ s("span", {
231
+ className: "dv-sr",
232
+ children: t === "add" ? "added: " : t === "del" ? "removed: " : ""
233
+ }), i || "\xA0"]
234
+ })
235
+ ]
236
+ });
237
+ }
238
+ function w({ match: e }) {
239
+ let { category: t, confidence: n, original: r, replacement: i, oldNo: o, newNo: l } = e, [u, d] = a(!1), f = n < .7, h = n.toFixed(2);
240
+ return /* @__PURE__ */ c("div", {
241
+ className: `dv-match${u ? " dv-match-kept" : ""}`,
242
+ children: [/* @__PURE__ */ c("div", {
243
+ className: "dv-match-head",
244
+ children: [
245
+ /* @__PURE__ */ c("span", {
246
+ className: `dv-badge${f ? " dv-badge-low" : ""}`,
247
+ children: [
248
+ /* @__PURE__ */ s("span", {
249
+ className: "dv-badge-cat",
250
+ children: t
251
+ }),
252
+ /* @__PURE__ */ s("span", {
253
+ className: "dv-badge-dot",
254
+ "aria-hidden": "true",
255
+ children: "·"
256
+ }),
257
+ /* @__PURE__ */ s("span", {
258
+ className: "dv-badge-conf tnum",
259
+ children: h
260
+ })
261
+ ]
262
+ }),
263
+ u && /* @__PURE__ */ c("span", {
264
+ className: "dv-kept-flag",
265
+ children: [/* @__PURE__ */ s(m, { "aria-hidden": "true" }), "un-redacted"]
266
+ }),
267
+ /* @__PURE__ */ c("button", {
268
+ type: "button",
269
+ className: "dv-keep",
270
+ "aria-pressed": u,
271
+ onClick: () => d((e) => !e),
272
+ children: [s(u ? p : m, { "aria-hidden": "true" }), u ? "revert" : "keep"]
273
+ })
274
+ ]
275
+ }), /* @__PURE__ */ c("div", {
276
+ className: "dv-match-pair",
277
+ role: "rowgroup",
278
+ children: [/* @__PURE__ */ c("div", {
279
+ className: `dv-line dv-del${u ? " dv-line-muted" : ""}`,
280
+ role: "row",
281
+ children: [
282
+ /* @__PURE__ */ s("span", {
283
+ className: "dv-rail",
284
+ "aria-hidden": "true"
285
+ }),
286
+ /* @__PURE__ */ s("span", {
287
+ className: "dv-num dv-num-old tnum",
288
+ role: "cell",
289
+ children: o ?? ""
290
+ }),
291
+ /* @__PURE__ */ s("span", {
292
+ className: "dv-num dv-num-new tnum",
293
+ role: "cell"
294
+ }),
295
+ /* @__PURE__ */ s("span", {
296
+ className: "dv-sign",
297
+ role: "cell",
298
+ "aria-hidden": "true",
299
+ children: /* @__PURE__ */ s(ne, { "aria-hidden": "true" })
300
+ }),
301
+ /* @__PURE__ */ c("span", {
302
+ className: "dv-text",
303
+ role: "cell",
304
+ children: [/* @__PURE__ */ s("span", {
305
+ className: "dv-sr",
306
+ children: "original: "
307
+ }), /* @__PURE__ */ s("span", {
308
+ className: "dv-strike",
309
+ children: r
310
+ })]
311
+ })
312
+ ]
313
+ }), /* @__PURE__ */ c("div", {
314
+ className: `dv-line dv-add${u ? " dv-line-muted" : ""}`,
315
+ role: "row",
316
+ children: [
317
+ /* @__PURE__ */ s("span", {
318
+ className: "dv-rail",
319
+ "aria-hidden": "true"
320
+ }),
321
+ /* @__PURE__ */ s("span", {
322
+ className: "dv-num dv-num-old tnum",
323
+ role: "cell"
324
+ }),
325
+ /* @__PURE__ */ s("span", {
326
+ className: "dv-num dv-num-new tnum",
327
+ role: "cell",
328
+ children: l ?? ""
329
+ }),
330
+ /* @__PURE__ */ s("span", {
331
+ className: "dv-sign",
332
+ role: "cell",
333
+ "aria-hidden": "true",
334
+ children: /* @__PURE__ */ s(re, { "aria-hidden": "true" })
335
+ }),
336
+ /* @__PURE__ */ c("span", {
337
+ className: "dv-text",
338
+ role: "cell",
339
+ children: [/* @__PURE__ */ s("span", {
340
+ className: "dv-sr",
341
+ children: "redacted to: "
342
+ }), i]
343
+ })
344
+ ]
345
+ })]
346
+ })]
347
+ });
348
+ }
349
+ function T({ file: e, hunks: t = [], matches: n = [], variant: r = "default", className: i = "", ...a }) {
350
+ let o = r === "redaction", l = o ? null : C(t);
351
+ return /* @__PURE__ */ c("figure", {
352
+ className: [
353
+ "dv",
354
+ o && "dv-redaction",
355
+ i
356
+ ].filter(Boolean).join(" "),
357
+ ...a,
358
+ children: [/* @__PURE__ */ c("figcaption", {
359
+ className: "dv-head",
360
+ children: [/* @__PURE__ */ s("span", {
361
+ className: "dv-file",
362
+ children: e
363
+ }), o ? /* @__PURE__ */ c("span", {
364
+ className: "dv-churn",
365
+ children: [/* @__PURE__ */ s("span", {
366
+ className: "dv-churn-r tnum",
367
+ children: n.length
368
+ }), /* @__PURE__ */ s("span", {
369
+ className: "dv-churn-label",
370
+ children: "redacted"
371
+ })]
372
+ }) : /* @__PURE__ */ c("span", {
373
+ className: "dv-churn",
374
+ children: [/* @__PURE__ */ c("span", {
375
+ className: "dv-churn-add tnum",
376
+ children: ["+", l.adds]
377
+ }), /* @__PURE__ */ c("span", {
378
+ className: "dv-churn-del tnum",
379
+ children: ["−", l.dels]
380
+ })]
381
+ })]
382
+ }), o ? /* @__PURE__ */ s("div", {
383
+ className: "dv-body dv-matches",
384
+ role: "table",
385
+ "aria-label": `redactions in ${e}`,
386
+ children: n.length === 0 ? /* @__PURE__ */ s("p", {
387
+ className: "dv-empty",
388
+ children: "no sensitive content detected. safe to share as-is."
389
+ }) : n.map((e, t) => /* @__PURE__ */ s(w, { match: e }, e.id ?? t))
390
+ }) : /* @__PURE__ */ s("div", {
391
+ className: "dv-body",
392
+ role: "table",
393
+ "aria-label": `diff of ${e}`,
394
+ children: t.length === 0 ? /* @__PURE__ */ s("p", {
395
+ className: "dv-empty",
396
+ children: "no line changes."
397
+ }) : t.map((e, t) => /* @__PURE__ */ c("div", {
398
+ className: "dv-hunk",
399
+ children: [/* @__PURE__ */ c("div", {
400
+ className: "dv-hunk-head",
401
+ children: [
402
+ /* @__PURE__ */ s("span", {
403
+ className: "dv-hunk-at",
404
+ "aria-hidden": "true",
405
+ children: "@@"
406
+ }),
407
+ /* @__PURE__ */ s("span", {
408
+ className: "dv-hunk-range tnum",
409
+ children: e.header
410
+ }),
411
+ /* @__PURE__ */ s("span", {
412
+ className: "dv-hunk-at",
413
+ "aria-hidden": "true",
414
+ children: "@@"
415
+ })
416
+ ]
417
+ }), /* @__PURE__ */ s("div", {
418
+ className: "dv-hunk-pair",
419
+ role: "rowgroup",
420
+ children: e.lines.map((e, t) => /* @__PURE__ */ s(pe, { line: e }, t))
421
+ })]
422
+ }, t))
423
+ })]
424
+ });
425
+ }
426
+ //#endregion
427
+ //#region src/ui/MapCanvas.jsx
428
+ var E = 56, D = 104, O = 248, k = 132, A = 28, j = 48, me = .35, he = 2.4, ge = 1.25, _e = [
429
+ {
430
+ id: "overview",
431
+ label: "overview",
432
+ depth: 0
433
+ },
434
+ {
435
+ id: "folders",
436
+ label: "folders",
437
+ depth: 1
438
+ },
439
+ {
440
+ id: "files",
441
+ label: "files",
442
+ depth: Infinity
443
+ }
444
+ ], M = {
445
+ overview: 0,
446
+ folders: 1,
447
+ files: Infinity
448
+ }, N = 3;
449
+ function ve(e) {
450
+ let t = Math.round(Number(e) || 0);
451
+ return t < 0 ? 0 : t > 4 ? 4 : t;
452
+ }
453
+ function P(e) {
454
+ let t = String(e ?? ""), n = t.lastIndexOf("/");
455
+ return n >= 0 ? t.slice(n + 1) : t;
456
+ }
457
+ function F(e, t) {
458
+ return e._order === t._order ? e.id < t.id ? -1 : +(e.id > t.id) : e._order - t._order;
459
+ }
460
+ function ye(e) {
461
+ let t = /* @__PURE__ */ new Map();
462
+ e.forEach((e, n) => {
463
+ let r = Number.isFinite(e.order) ? e.order : n;
464
+ t.set(e.id, {
465
+ ...e,
466
+ _order: r
467
+ });
468
+ });
469
+ let n = /* @__PURE__ */ new Map(), r = [];
470
+ for (let e of t.values()) {
471
+ let i = e.parent && t.has(e.parent) ? e.parent : null;
472
+ if (i) {
473
+ let t = n.get(i);
474
+ t ? t.push(e) : n.set(i, [e]);
475
+ } else r.push(e);
476
+ }
477
+ for (let e of n.values()) e.sort(F);
478
+ return r.sort(F), {
479
+ byId: t,
480
+ children: n,
481
+ roots: r
482
+ };
483
+ }
484
+ function be(e, t) {
485
+ let n = 0, r = e;
486
+ for (; r && r.parent && t.has(r.parent);) r = t.get(r.parent), n += 1;
487
+ return n;
488
+ }
489
+ function xe(e, t) {
490
+ return Number.isFinite(e.layer) ? e.layer : be(e, t);
491
+ }
492
+ function Se(e, t, n) {
493
+ let { children: r, roots: i } = e, a = [], o = (e, i) => {
494
+ let s = r.get(e.id);
495
+ if (s && s.length > 0 && (i < t || n.has(e.id))) for (let e of s) o(e, i + 1);
496
+ else a.push(e);
497
+ };
498
+ for (let e of i) o(e, 0);
499
+ return a;
500
+ }
501
+ function Ce(e, t) {
502
+ if (e.length === 0) return {
503
+ positioned: [],
504
+ width: 0,
505
+ height: 0
506
+ };
507
+ let n = 0;
508
+ for (let t of e) n = Math.max(n, Math.max(0, Number(t.loc) || 0));
509
+ let r = (e) => {
510
+ if (n <= 0) return D;
511
+ let t = Math.max(0, Number(e.loc) || 0) / n;
512
+ return Math.round(D + t * (O - D));
513
+ }, i = /* @__PURE__ */ new Map();
514
+ for (let n of e) {
515
+ let e = xe(n, t), r = i.get(e);
516
+ r ? r.push(n) : i.set(e, [n]);
517
+ }
518
+ let a = Array.from(i.keys()).sort((e, t) => e - t);
519
+ for (let e of a) i.get(e).sort(F);
520
+ let o = (e) => e.reduce((e, t) => e + r(t), 0) + A * (e.length - 1), s = 0;
521
+ for (let e of a) s = Math.max(s, o(i.get(e)));
522
+ let c = [];
523
+ return a.forEach((e, t) => {
524
+ let n = i.get(e), a = j + (s - o(n)) / 2, l = j + t * k;
525
+ for (let e of n) {
526
+ let t = r(e);
527
+ c.push({
528
+ node: e,
529
+ x: a,
530
+ y: l,
531
+ w: t,
532
+ h: E
533
+ }), a += t + A;
534
+ }
535
+ }), {
536
+ positioned: c,
537
+ width: s + j * 2,
538
+ height: (a.length - 1) * k + E + j * 2
539
+ };
540
+ }
541
+ function we(e, t) {
542
+ let n = /* @__PURE__ */ new Map();
543
+ return (r) => {
544
+ if (n.has(r)) return n.get(r);
545
+ let i = r;
546
+ for (; i != null && !t.has(i);) {
547
+ let t = e.get(i);
548
+ i = t && t.parent || null;
549
+ }
550
+ return n.set(r, i ?? null), i ?? null;
551
+ };
552
+ }
553
+ function Te(e, t, n) {
554
+ let r = we(t, n), i = /* @__PURE__ */ new Map();
555
+ for (let t of e) {
556
+ let e = r(t.from), n = r(t.to);
557
+ if (!e || !n || e === n) continue;
558
+ let a = t.kind === "activity" ? "activity" : "structure", o = `${a}|${e}→${n}`, s = Math.max(0, Number(t.weight) || 1), c = i.get(o);
559
+ c ? c.weight += s : i.set(o, {
560
+ from: e,
561
+ to: n,
562
+ kind: a,
563
+ weight: s
564
+ });
565
+ }
566
+ return Array.from(i.values()).sort((e, t) => e.from === t.from ? e.to < t.to ? -1 : +(e.to > t.to) : e.from < t.from ? -1 : 1);
567
+ }
568
+ function Ee(e, t, n) {
569
+ let r = we(t, n), i = /* @__PURE__ */ new Map();
570
+ for (let t of e) {
571
+ let e = Math.max(0, Number(t.violations) || 0);
572
+ if (e <= 0) continue;
573
+ let n = r(t.id);
574
+ n && i.set(n, (i.get(n) || 0) + e);
575
+ }
576
+ return i;
577
+ }
578
+ function De(e) {
579
+ let t;
580
+ for (let n of e) (!t || n.y < t.y || n.y === t.y && n.x < t.x) && (t = n);
581
+ return t;
582
+ }
583
+ function Oe(e, t, n) {
584
+ let r = e.filter((e) => e.y === t.y).sort((e, t) => e.x - t.x), i = r.findIndex((e) => e.node.id === t.node.id);
585
+ if (i !== -1) return r[i + n];
586
+ }
587
+ function ke(e, t, n) {
588
+ let r;
589
+ for (let i of e) (i.y - t.y) * n <= 0 || (r === void 0 || (i.y - r) * n < 0) && (r = i.y);
590
+ if (r === void 0) return;
591
+ let i = t.x + t.w / 2, a;
592
+ for (let t of e) if (t.y === r) {
593
+ if (!a) {
594
+ a = t;
595
+ continue;
596
+ }
597
+ Math.abs(t.x + t.w / 2 - i) < Math.abs(a.x + a.w / 2 - i) && (a = t);
598
+ }
599
+ return a;
600
+ }
601
+ function I({ data: u = {
602
+ nodes: [],
603
+ edges: []
604
+ }, grain: d = "folders", expandedIds: f, selectedId: p, highlightedIds: m, nodeDeltas: ee = {}, edgeDeltas: ie = {}, onSelect: oe, onGrainChange: ce, onExpandedIdsChange: _, onExpand: v, height: le = 520, ariaLabel: ue = "code map", className: de = "" }) {
605
+ let y = u?.nodes ?? [], b = u?.edges ?? [], x = n().replace(/[:]/g, ""), fe = `${x}-live`, S = `${x}-list`, [C, pe] = a(M[d] === void 0 ? "folders" : d), [w, T] = a(() => je(f)), [E, D] = a(p ?? null), [O, k] = a(null), [A, j] = a(1), [N, P] = a({
606
+ x: 0,
607
+ y: 0
608
+ }), [F, be] = a(""), [xe, I] = a(!1), L = i(null), R = i(null), z = i(!1), ze = i(d), B = i(p), V = i(A), Be = i(N);
609
+ V.current = A, Be.current = N;
610
+ let Ve = Me(f), He = Me(m);
611
+ t(() => {
612
+ d !== ze.current && (ze.current = d, M[d] !== void 0 && pe(d));
613
+ }, [d]), t(() => {
614
+ f !== void 0 && T(je(f));
615
+ }, [Ve]), t(() => {
616
+ p !== B.current && (B.current = p, p !== void 0 && D(p));
617
+ }, [p]);
618
+ let H = r(() => ye(y), [y]), U = r(() => Se(H, M[C], w), [
619
+ H,
620
+ C,
621
+ w
622
+ ]), W = r(() => new Set(U.map((e) => e.id)), [U]), { positioned: G, width: K, height: q } = r(() => Ce(U, H.byId), [U, H.byId]), J = r(() => {
623
+ let e = /* @__PURE__ */ new Map();
624
+ for (let t of G) e.set(t.node.id, t);
625
+ return e;
626
+ }, [G]), Ue = r(() => {
627
+ let e = /* @__PURE__ */ new Map();
628
+ for (let [t, n] of H.children) e.set(t, n.length);
629
+ return e;
630
+ }, [H]), We = r(() => Te(b, H.byId, W), [
631
+ b,
632
+ H.byId,
633
+ W
634
+ ]), Ge = r(() => We.reduce((e, t) => Math.max(e, t.weight), 1), [We]), Ke = r(() => Ee(y, H.byId, W), [
635
+ y,
636
+ H.byId,
637
+ W
638
+ ]), qe = r(() => {
639
+ let e = je(m);
640
+ if (e.size === 0) return e;
641
+ let t = we(H.byId, W), n = /* @__PURE__ */ new Set();
642
+ for (let r of e) {
643
+ let e = t(r);
644
+ e && n.add(e);
645
+ }
646
+ return n;
647
+ }, [
648
+ He,
649
+ H.byId,
650
+ W
651
+ ]), Y = r(() => {
652
+ let e = F.trim().toLowerCase();
653
+ return e ? y.filter((t) => t.id.toLowerCase().includes(e) || (t.label || "").toLowerCase().includes(e)).slice(0, 8) : [];
654
+ }, [y, F]), X = e(() => {
655
+ let e = L.current;
656
+ if (!e || K <= 0 || q <= 0) return;
657
+ let t = e.clientWidth, n = e.clientHeight;
658
+ if (t <= 0 || n <= 0) return;
659
+ let r = Math.min(t / K, n / q), i = Math.max(me, Math.min(he, r));
660
+ j(i), P({
661
+ x: (t - K * i) / 2,
662
+ y: (n - q * i) / 2
663
+ });
664
+ }, [K, q]);
665
+ t(() => {
666
+ if (!z.current) {
667
+ z.current = !0, X();
668
+ return;
669
+ }
670
+ X();
671
+ }, [r(() => G.map((e) => e.node.id).join("|"), [G])]);
672
+ let Z = e((e) => {
673
+ let t = L.current, n = t ? t.clientWidth / 2 : 0, r = t ? t.clientHeight / 2 : 0, i = V.current, a = Math.max(me, Math.min(he, i * e));
674
+ if (a === i) return;
675
+ let o = Be.current;
676
+ j(a), P({
677
+ x: n - (n - o.x) / i * a,
678
+ y: r - (r - o.y) / i * a
679
+ });
680
+ }, []), Je = e((e) => {
681
+ let t = J.get(e), n = L.current;
682
+ if (!t || !n) return;
683
+ let r = Math.max(A, 1);
684
+ j(r), P({
685
+ x: n.clientWidth / 2 - (t.x + t.w / 2) * r,
686
+ y: n.clientHeight / 2 - (t.y + t.h / 2) * r
687
+ });
688
+ }, [J, A]), Q = e((e) => {
689
+ D(e);
690
+ let t = e ? H.byId.get(e) : null;
691
+ oe?.(e, t ? Ae(t) : null);
692
+ }, [oe, H.byId]), Ye = e((e) => {
693
+ pe(e), T(/* @__PURE__ */ new Set()), ce?.(e), _?.([]);
694
+ }, [_, ce]), Xe = e((e) => {
695
+ if ((Ue.get(e) || 0) === 0) return;
696
+ let t = new Set(w);
697
+ t.has(e) ? t.delete(e) : (t.add(e), v?.(e)), T(t), _?.(Array.from(t));
698
+ }, [
699
+ Ue,
700
+ w,
701
+ v,
702
+ _
703
+ ]), Ze = e((e) => {
704
+ let t = e.key;
705
+ if (t === "+" || t === "=") {
706
+ e.preventDefault(), Z(ge);
707
+ return;
708
+ }
709
+ if (t === "-" || t === "_") {
710
+ e.preventDefault(), Z(1 / ge);
711
+ return;
712
+ }
713
+ if (t === "0") {
714
+ e.preventDefault(), X();
715
+ return;
716
+ }
717
+ if (t === "ArrowLeft" || t === "ArrowRight" || t === "ArrowUp" || t === "ArrowDown") {
718
+ e.preventDefault();
719
+ let n = O ? J.get(O) : void 0;
720
+ if (!n) {
721
+ let e = De(G);
722
+ e && k(e.node.id);
723
+ return;
724
+ }
725
+ let r;
726
+ r = t === "ArrowLeft" ? Oe(G, n, -1) : t === "ArrowRight" ? Oe(G, n, 1) : t === "ArrowUp" ? ke(G, n, -1) : ke(G, n, 1), r && (k(r.node.id), Ie(r, L.current, A, N, P));
727
+ return;
728
+ }
729
+ if (t === "Enter") {
730
+ if (!O) return;
731
+ e.preventDefault(), e.shiftKey ? Xe(O) : Q(E === O ? null : O);
732
+ return;
733
+ }
734
+ if (t === "e" || t === "E") {
735
+ if (!O) return;
736
+ e.preventDefault(), Xe(O);
737
+ return;
738
+ }
739
+ t === "Escape" && E && (e.preventDefault(), Q(null));
740
+ }, [
741
+ O,
742
+ G,
743
+ J,
744
+ E,
745
+ A,
746
+ N,
747
+ Z,
748
+ X,
749
+ Xe,
750
+ Q
751
+ ]), Qe = e((e) => {
752
+ if (e.button !== 0) return;
753
+ let t = L.current;
754
+ t && t.setPointerCapture?.(e.pointerId), R.current = {
755
+ startX: e.clientX,
756
+ startY: e.clientY,
757
+ panX: N.x,
758
+ panY: N.y,
759
+ moved: !1
760
+ };
761
+ }, [N]), $e = e((e) => {
762
+ let t = R.current;
763
+ if (!t) return;
764
+ let n = e.clientX - t.startX, r = e.clientY - t.startY;
765
+ !t.moved && Math.abs(n) + Math.abs(r) > 3 && (t.moved = !0), t.moved && P({
766
+ x: t.panX + n,
767
+ y: t.panY + r
768
+ });
769
+ }, []), et = e((e) => {
770
+ let t = R.current;
771
+ R.current = null;
772
+ let n = L.current;
773
+ n && n.releasePointerCapture?.(e.pointerId), t && !t.moved && e.target === e.currentTarget && Q(null);
774
+ }, [Q]), tt = r(() => {
775
+ if (!O) return "";
776
+ let e = H.byId.get(O);
777
+ return e ? Fe(e, {
778
+ selected: E === O,
779
+ expanded: w.has(O),
780
+ violations: Ke.get(O) || 0
781
+ }) : "";
782
+ }, [
783
+ O,
784
+ H.byId,
785
+ E,
786
+ w,
787
+ Ke
788
+ ]), $ = r(() => {
789
+ let e = L.current;
790
+ if (!e || K <= 0 || q <= 0) return null;
791
+ let t = e.clientWidth, n = e.clientHeight;
792
+ return {
793
+ graphW: K,
794
+ graphH: q,
795
+ viewX: -N.x / A,
796
+ viewY: -N.y / A,
797
+ viewW: t / A,
798
+ viewH: n / A
799
+ };
800
+ }, [
801
+ N,
802
+ A,
803
+ K,
804
+ q
805
+ ]), nt = G.length === 0, rt = (e) => `${x}-grain-${e}`;
806
+ return /* @__PURE__ */ c("div", {
807
+ className: ["mc", de].filter(Boolean).join(" "),
808
+ style: { height: le },
809
+ role: "application",
810
+ "aria-label": ue,
811
+ "aria-roledescription": "code structure map",
812
+ children: [
813
+ /* @__PURE__ */ s("div", {
814
+ id: fe,
815
+ className: "mc-sr",
816
+ role: "status",
817
+ "aria-live": "polite",
818
+ children: tt
819
+ }),
820
+ /* @__PURE__ */ c("div", {
821
+ className: "mc-toolbar",
822
+ children: [/* @__PURE__ */ s("div", {
823
+ className: "mc-seg",
824
+ role: "radiogroup",
825
+ "aria-label": "detail grain",
826
+ children: _e.map((e) => /* @__PURE__ */ c("button", {
827
+ id: rt(e.id),
828
+ type: "button",
829
+ role: "radio",
830
+ "aria-checked": C === e.id,
831
+ className: "mc-seg-btn mono",
832
+ "data-active": C === e.id ? "true" : void 0,
833
+ onClick: () => Ye(e.id),
834
+ children: [C === e.id && /* @__PURE__ */ s(l, {
835
+ className: "lucide",
836
+ "aria-hidden": "true"
837
+ }), e.label]
838
+ }, e.id))
839
+ }), /* @__PURE__ */ c("div", {
840
+ className: "mc-search",
841
+ role: "combobox",
842
+ "aria-expanded": xe && Y.length > 0,
843
+ "aria-haspopup": "listbox",
844
+ "aria-owns": S,
845
+ children: [
846
+ /* @__PURE__ */ s(ae, {
847
+ className: "lucide mc-search-ico",
848
+ "aria-hidden": "true"
849
+ }),
850
+ /* @__PURE__ */ s("input", {
851
+ className: "mc-search-input mono",
852
+ type: "text",
853
+ placeholder: "find a node",
854
+ "aria-label": "find a node",
855
+ "aria-controls": S,
856
+ "aria-autocomplete": "list",
857
+ value: F,
858
+ onChange: (e) => {
859
+ be(e.target.value), I(!0);
860
+ },
861
+ onFocus: () => I(!0),
862
+ onBlur: () => {
863
+ window.setTimeout(() => I(!1), 120);
864
+ },
865
+ onKeyDown: (e) => {
866
+ e.key === "Enter" && Y[0] ? (e.preventDefault(), it(Y[0])) : e.key === "Escape" && I(!1);
867
+ }
868
+ }),
869
+ xe && Y.length > 0 && /* @__PURE__ */ s("ul", {
870
+ className: "mc-results",
871
+ id: S,
872
+ role: "listbox",
873
+ "aria-label": "search results",
874
+ children: Y.map((e) => /* @__PURE__ */ c("li", {
875
+ role: "option",
876
+ "aria-selected": e.id === E,
877
+ className: "mc-result mono",
878
+ onMouseDown: (t) => {
879
+ t.preventDefault(), it(e);
880
+ },
881
+ children: [e.kind === "folder" ? /* @__PURE__ */ s(g, {
882
+ className: "lucide",
883
+ "aria-hidden": "true"
884
+ }) : /* @__PURE__ */ s(h, {
885
+ className: "lucide",
886
+ "aria-hidden": "true"
887
+ }), /* @__PURE__ */ s("span", {
888
+ className: "mc-result-path",
889
+ children: e.id
890
+ })]
891
+ }, e.id))
892
+ })
893
+ ]
894
+ })]
895
+ }),
896
+ /* @__PURE__ */ s("div", {
897
+ className: "mc-viewport",
898
+ ref: L,
899
+ tabIndex: 0,
900
+ role: "group",
901
+ "aria-label": "map canvas: arrow keys move focus, enter selects, plus and minus zoom",
902
+ "aria-activedescendant": O && W.has(O) ? `${x}-node-${Pe(O)}` : void 0,
903
+ onKeyDown: Ze,
904
+ onPointerDown: Qe,
905
+ onPointerMove: $e,
906
+ onPointerUp: et,
907
+ onPointerCancel: et,
908
+ children: nt ? /* @__PURE__ */ s("p", {
909
+ className: "mc-empty mono",
910
+ children: "no nodes to map"
911
+ }) : /* @__PURE__ */ c(o, { children: [
912
+ /* @__PURE__ */ c("div", {
913
+ className: "mc-stage",
914
+ style: {
915
+ transform: `translate(${N.x}px, ${N.y}px) scale(${A})`,
916
+ width: K,
917
+ height: q
918
+ },
919
+ children: [/* @__PURE__ */ s("svg", {
920
+ className: "mc-edges",
921
+ width: K,
922
+ height: q,
923
+ viewBox: `0 0 ${K} ${q}`,
924
+ "aria-hidden": "true",
925
+ children: We.map((e) => {
926
+ let t = J.get(e.from), n = J.get(e.to);
927
+ if (!t || !n) return null;
928
+ let r = ie[Ne(e.from, e.to)] ?? ie[Ne(e.from, e.to, "arrow")];
929
+ return /* @__PURE__ */ s(Re, {
930
+ a: t,
931
+ b: n,
932
+ kind: e.kind,
933
+ weight: e.weight,
934
+ maxWeight: Ge,
935
+ delta: r
936
+ }, `${e.kind}:${e.from}->${e.to}`);
937
+ })
938
+ }), G.map((e) => /* @__PURE__ */ s(Le, {
939
+ domId: `${x}-node-${Pe(e.node.id)}`,
940
+ p: e,
941
+ selected: E === e.node.id,
942
+ focused: O === e.node.id,
943
+ highlighted: qe.has(e.node.id),
944
+ delta: ee[e.node.id],
945
+ expandable: (Ue.get(e.node.id) || 0) > 0,
946
+ expanded: w.has(e.node.id),
947
+ violations: Ke.get(e.node.id) || 0,
948
+ onClick: () => {
949
+ k(e.node.id), Q(E === e.node.id ? null : e.node.id);
950
+ },
951
+ onDoubleClick: () => Xe(e.node.id)
952
+ }, e.node.id))]
953
+ }),
954
+ /* @__PURE__ */ c("div", {
955
+ className: "mc-zoom",
956
+ role: "group",
957
+ "aria-label": "map zoom",
958
+ children: [
959
+ /* @__PURE__ */ s("button", {
960
+ type: "button",
961
+ className: "mc-zoom-btn",
962
+ "aria-label": "zoom in",
963
+ onClick: () => Z(ge),
964
+ children: /* @__PURE__ */ s(re, {
965
+ className: "lucide",
966
+ "aria-hidden": "true"
967
+ })
968
+ }),
969
+ /* @__PURE__ */ s("button", {
970
+ type: "button",
971
+ className: "mc-zoom-btn",
972
+ "aria-label": "zoom out",
973
+ onClick: () => Z(1 / ge),
974
+ children: /* @__PURE__ */ s(ne, {
975
+ className: "lucide",
976
+ "aria-hidden": "true"
977
+ })
978
+ }),
979
+ /* @__PURE__ */ s("button", {
980
+ type: "button",
981
+ className: "mc-zoom-btn",
982
+ "aria-label": "fit map to view",
983
+ onClick: X,
984
+ children: /* @__PURE__ */ s(te, {
985
+ className: "lucide",
986
+ "aria-hidden": "true"
987
+ })
988
+ })
989
+ ]
990
+ }),
991
+ $ && /* @__PURE__ */ s("div", {
992
+ className: "mc-minimap",
993
+ "aria-hidden": "true",
994
+ children: /* @__PURE__ */ c("svg", {
995
+ className: "mc-minimap-svg",
996
+ viewBox: `0 0 ${$.graphW} ${$.graphH}`,
997
+ preserveAspectRatio: "xMidYMid meet",
998
+ children: [G.map((e) => /* @__PURE__ */ s("rect", {
999
+ className: "mc-mini-node",
1000
+ "data-cov": ve(e.node.coverage),
1001
+ x: e.x,
1002
+ y: e.y,
1003
+ width: e.w,
1004
+ height: e.h
1005
+ }, e.node.id)), /* @__PURE__ */ s("rect", {
1006
+ className: "mc-mini-view",
1007
+ x: $.viewX,
1008
+ y: $.viewY,
1009
+ width: $.viewW,
1010
+ height: $.viewH
1011
+ })]
1012
+ })
1013
+ }),
1014
+ /* @__PURE__ */ c("div", {
1015
+ className: "mc-legend mono",
1016
+ "aria-hidden": "true",
1017
+ children: [
1018
+ /* @__PURE__ */ c("span", {
1019
+ className: "mc-legend-item",
1020
+ children: [/* @__PURE__ */ s(g, { className: "lucide" }), " folder"]
1021
+ }),
1022
+ /* @__PURE__ */ c("span", {
1023
+ className: "mc-legend-item",
1024
+ children: [/* @__PURE__ */ s(h, { className: "lucide" }), " file"]
1025
+ }),
1026
+ /* @__PURE__ */ c("span", {
1027
+ className: "mc-legend-item mc-legend-ramp",
1028
+ children: [
1029
+ /* @__PURE__ */ s("span", {
1030
+ className: "mc-ramp-sw",
1031
+ "data-cov": "0"
1032
+ }),
1033
+ /* @__PURE__ */ s("span", {
1034
+ className: "mc-ramp-sw",
1035
+ "data-cov": "1"
1036
+ }),
1037
+ /* @__PURE__ */ s("span", {
1038
+ className: "mc-ramp-sw",
1039
+ "data-cov": "2"
1040
+ }),
1041
+ /* @__PURE__ */ s("span", {
1042
+ className: "mc-ramp-sw",
1043
+ "data-cov": "3"
1044
+ }),
1045
+ /* @__PURE__ */ s("span", {
1046
+ className: "mc-ramp-sw",
1047
+ "data-cov": "4"
1048
+ }),
1049
+ "coverage"
1050
+ ]
1051
+ }),
1052
+ /* @__PURE__ */ c("span", {
1053
+ className: "mc-legend-item mc-legend-viol",
1054
+ children: [/* @__PURE__ */ s(se, { className: "lucide" }), " violation"]
1055
+ })
1056
+ ]
1057
+ })
1058
+ ] })
1059
+ })
1060
+ ]
1061
+ });
1062
+ function it(e) {
1063
+ e.kind === "file" && M[C] < Infinity && Ye("files");
1064
+ let t = new Set(e.kind === "file" && M[C] < Infinity ? [] : w), n = e.parent;
1065
+ for (; n && H.byId.has(n);) t.has(n) || (t.add(n), v?.(n)), n = H.byId.get(n).parent;
1066
+ T(t), _?.(Array.from(t)), be(""), I(!1), k(e.id), Q(e.id), window.requestAnimationFrame(() => {
1067
+ window.requestAnimationFrame(() => Je(e.id));
1068
+ });
1069
+ }
1070
+ }
1071
+ function Ae(e) {
1072
+ let { _order: t, ...n } = e;
1073
+ return n;
1074
+ }
1075
+ function je(e) {
1076
+ return e ? e instanceof Set ? new Set(e) : new Set(Array.from(e)) : /* @__PURE__ */ new Set();
1077
+ }
1078
+ function Me(e) {
1079
+ return e ? Array.from(e).map(String).sort().join("\0") : "";
1080
+ }
1081
+ function Ne(e, t, n = "plain") {
1082
+ return n === "arrow" ? `${e}->${t}` : `${e}→${t}`;
1083
+ }
1084
+ function Pe(e) {
1085
+ return String(e).replace(/[^a-zA-Z0-9_-]/g, "_");
1086
+ }
1087
+ function Fe(e, t = {}) {
1088
+ let { selected: n, expanded: r, violations: i = 0 } = t, a = ve(e.coverage), o = `${P(e.label || e.id)}: ${e.kind} · coverage ${a} of 4`;
1089
+ return e.loc && (o += ` · ${e.loc} loc`), i > 0 && (o += ` · ${i} violation${i === 1 ? "" : "s"}`), n && (o += " · selected"), r && (o += " · expanded"), o;
1090
+ }
1091
+ function Ie(e, t, n, r, i) {
1092
+ if (!t) return;
1093
+ let a = e.x * n + r.x, o = e.y * n + r.y, s = (e.x + e.w) * n + r.x, c = (e.y + e.h) * n + r.y, l = 0, u = 0;
1094
+ a < 24 ? l = 24 - a : s > t.clientWidth - 24 && (l = t.clientWidth - 24 - s), o < 24 ? u = 24 - o : c > t.clientHeight - 24 && (u = t.clientHeight - 24 - c), (l !== 0 || u !== 0) && i({
1095
+ x: r.x + l,
1096
+ y: r.y + u
1097
+ });
1098
+ }
1099
+ function Le({ domId: e, p: t, selected: n, focused: r, highlighted: i, delta: a, expandable: o, expanded: l, violations: u, onClick: d, onDoubleClick: f }) {
1100
+ let p = t.node, m = ve(p.coverage);
1101
+ return /* @__PURE__ */ c("button", {
1102
+ id: e,
1103
+ type: "button",
1104
+ className: "mc-node",
1105
+ "data-cov": m,
1106
+ "data-selected": n ? "true" : void 0,
1107
+ "data-focused": r ? "true" : void 0,
1108
+ "data-highlighted": i ? "true" : void 0,
1109
+ "data-delta": a || void 0,
1110
+ "data-ink-flip": m >= N ? "true" : void 0,
1111
+ "aria-label": Fe(p, {
1112
+ selected: n,
1113
+ expanded: l,
1114
+ violations: u
1115
+ }),
1116
+ "aria-pressed": n,
1117
+ "aria-expanded": o ? l : void 0,
1118
+ style: {
1119
+ left: t.x,
1120
+ top: t.y,
1121
+ width: t.w,
1122
+ height: t.h
1123
+ },
1124
+ onPointerDown: (e) => e.stopPropagation(),
1125
+ onClick: (e) => {
1126
+ e.stopPropagation(), d();
1127
+ },
1128
+ onDoubleClick: (e) => {
1129
+ e.stopPropagation(), f();
1130
+ },
1131
+ children: [
1132
+ n && /* @__PURE__ */ s("span", {
1133
+ className: "mc-node-marker",
1134
+ "aria-hidden": "true"
1135
+ }),
1136
+ /* @__PURE__ */ c("span", {
1137
+ className: "mc-node-head",
1138
+ children: [
1139
+ p.kind === "folder" ? /* @__PURE__ */ s(g, {
1140
+ className: "lucide mc-node-ico",
1141
+ "aria-hidden": "true"
1142
+ }) : /* @__PURE__ */ s(h, {
1143
+ className: "lucide mc-node-ico",
1144
+ "aria-hidden": "true"
1145
+ }),
1146
+ /* @__PURE__ */ s("span", {
1147
+ className: "mc-node-name mono",
1148
+ children: P(p.label || p.id)
1149
+ }),
1150
+ u > 0 && /* @__PURE__ */ c("span", {
1151
+ className: "mc-node-viol mono tnum",
1152
+ "aria-hidden": "true",
1153
+ children: [/* @__PURE__ */ s(se, {
1154
+ className: "lucide",
1155
+ "aria-hidden": "true"
1156
+ }), u]
1157
+ })
1158
+ ]
1159
+ }),
1160
+ /* @__PURE__ */ c("span", {
1161
+ className: "mc-node-meta mono tnum",
1162
+ children: [
1163
+ p.kind === "folder" && o ? l ? "open" : "folder" : "file",
1164
+ p.loc ? ` · ${p.loc} loc` : "",
1165
+ ` · cov ${m}/4`
1166
+ ]
1167
+ })
1168
+ ]
1169
+ });
1170
+ }
1171
+ function Re({ a: e, b: t, kind: n, weight: r, maxWeight: i, delta: a }) {
1172
+ let o = e.x + e.w / 2, l = e.y + e.h, u = t.x + t.w / 2, d = t.y, f = (l + d) / 2, p = `M ${o} ${l} L ${o} ${f} L ${u} ${f} L ${u} ${d}`, m = 1 + Math.min(r, i) / i * 2;
1173
+ return /* @__PURE__ */ c("g", {
1174
+ className: "mc-edge",
1175
+ "data-kind": n,
1176
+ "data-delta": a || void 0,
1177
+ children: [/* @__PURE__ */ s("path", {
1178
+ className: "mc-edge-path",
1179
+ d: p,
1180
+ style: { strokeWidth: m }
1181
+ }), n === "structure" && /* @__PURE__ */ s("path", {
1182
+ className: "mc-edge-head",
1183
+ d: `M ${u - 4} ${d - 6} L ${u + 4} ${d - 6} L ${u} ${d} Z`
1184
+ })]
1185
+ });
1186
+ }
1187
+ //#endregion
1188
+ //#region src/ui/RailShell.jsx
1189
+ function L({ toolbar: e, children: t, rail: r, railSide: i = "right", sheetTitle: o = "details", sheetMeta: l, className: d = "" }) {
1190
+ let [f, p] = a(!1), m = `rs-sheet-${n()}`;
1191
+ return /* @__PURE__ */ c("div", {
1192
+ className: `rs rs--${i}${d ? ` ${d}` : ""}`,
1193
+ "data-sheet-open": f ? "true" : "false",
1194
+ children: [/* @__PURE__ */ c("div", {
1195
+ className: "rs-frame",
1196
+ children: [/* @__PURE__ */ c("div", {
1197
+ className: "rs-main",
1198
+ children: [e && /* @__PURE__ */ s("div", {
1199
+ className: "rs-toolbar",
1200
+ children: e
1201
+ }), /* @__PURE__ */ s("div", {
1202
+ className: "rs-canvas",
1203
+ children: t
1204
+ })]
1205
+ }), /* @__PURE__ */ s("aside", {
1206
+ className: "rs-rail",
1207
+ "aria-label": o,
1208
+ children: /* @__PURE__ */ s("div", {
1209
+ className: "rs-rail-card",
1210
+ children: r
1211
+ })
1212
+ })]
1213
+ }), /* @__PURE__ */ c("div", {
1214
+ className: "rs-sheet",
1215
+ "aria-label": o,
1216
+ children: [/* @__PURE__ */ c("button", {
1217
+ type: "button",
1218
+ className: "rs-sheet-toggle",
1219
+ "aria-expanded": f,
1220
+ "aria-controls": m,
1221
+ onClick: () => p((e) => !e),
1222
+ children: [/* @__PURE__ */ s("span", {
1223
+ className: "rs-sheet-grip",
1224
+ "aria-hidden": "true"
1225
+ }), /* @__PURE__ */ c("span", {
1226
+ className: "rs-sheet-row",
1227
+ children: [/* @__PURE__ */ s("span", {
1228
+ className: "rs-sheet-title",
1229
+ children: o
1230
+ }), /* @__PURE__ */ c("span", {
1231
+ className: "rs-sheet-end",
1232
+ children: [l && /* @__PURE__ */ s("span", {
1233
+ className: "rs-sheet-meta",
1234
+ children: l
1235
+ }), /* @__PURE__ */ s(u, {
1236
+ className: "rs-sheet-chevron lucide",
1237
+ "aria-hidden": "true"
1238
+ })]
1239
+ })]
1240
+ })]
1241
+ }), /* @__PURE__ */ s("div", {
1242
+ id: m,
1243
+ role: "region",
1244
+ "aria-label": o,
1245
+ className: "rs-sheet-body",
1246
+ hidden: !f,
1247
+ children: r
1248
+ })]
1249
+ })]
1250
+ });
1251
+ }
1252
+ function R({ title: e, icon: t, meta: r, children: i, collapsible: l = !1, defaultOpen: u = !0, className: d = "" }) {
1253
+ let [p, m] = a(u), h = `rs-sec-${n()}`, g = /* @__PURE__ */ c(o, { children: [
1254
+ t && /* @__PURE__ */ s(t, {
1255
+ className: "rs-sec-icon lucide",
1256
+ "aria-hidden": "true"
1257
+ }),
1258
+ e && /* @__PURE__ */ s("span", {
1259
+ className: "rs-sec-title",
1260
+ children: e
1261
+ }),
1262
+ /* @__PURE__ */ c("span", {
1263
+ className: "rs-sec-end",
1264
+ children: [r && /* @__PURE__ */ s("span", {
1265
+ className: "rs-sec-meta",
1266
+ children: r
1267
+ }), l && /* @__PURE__ */ s(f, {
1268
+ className: "rs-sec-chevron lucide",
1269
+ "aria-hidden": "true"
1270
+ })]
1271
+ })
1272
+ ] });
1273
+ return /* @__PURE__ */ c("section", {
1274
+ className: `rs-sec${l ? " rs-sec--collapsible" : ""}${p ? " is-open" : ""}${d ? ` ${d}` : ""}`,
1275
+ children: [l ? /* @__PURE__ */ s("button", {
1276
+ type: "button",
1277
+ className: "rs-sec-head rs-sec-head--button",
1278
+ "aria-expanded": p,
1279
+ "aria-controls": h,
1280
+ onClick: () => m((e) => !e),
1281
+ children: g
1282
+ }) : /* @__PURE__ */ s("div", {
1283
+ className: "rs-sec-head",
1284
+ children: g
1285
+ }), /* @__PURE__ */ s("div", {
1286
+ id: l ? h : void 0,
1287
+ className: "rs-sec-body",
1288
+ hidden: l ? !p : void 0,
1289
+ children: i
1290
+ })]
1291
+ });
1292
+ }
1293
+ function z({ title: e, icon: t, meta: r, children: i, defaultOpen: o = !0 }) {
1294
+ let [l, u] = a(o), d = `rs-split-${n()}`;
1295
+ return /* @__PURE__ */ c("section", {
1296
+ className: `rs-split-panel${l ? " is-open" : ""}`,
1297
+ children: [/* @__PURE__ */ c("button", {
1298
+ type: "button",
1299
+ className: "rs-split-head",
1300
+ "aria-expanded": l,
1301
+ "aria-controls": d,
1302
+ onClick: () => u((e) => !e),
1303
+ children: [
1304
+ t && /* @__PURE__ */ s(t, {
1305
+ className: "rs-sec-icon lucide",
1306
+ "aria-hidden": "true"
1307
+ }),
1308
+ e && /* @__PURE__ */ s("span", {
1309
+ className: "rs-sec-title",
1310
+ children: e
1311
+ }),
1312
+ /* @__PURE__ */ c("span", {
1313
+ className: "rs-sec-end",
1314
+ children: [r && /* @__PURE__ */ s("span", {
1315
+ className: "rs-sec-meta",
1316
+ children: r
1317
+ }), /* @__PURE__ */ s(f, {
1318
+ className: "rs-sec-chevron lucide",
1319
+ "aria-hidden": "true"
1320
+ })]
1321
+ })
1322
+ ]
1323
+ }), /* @__PURE__ */ s("div", {
1324
+ id: d,
1325
+ className: "rs-split-body",
1326
+ hidden: !l,
1327
+ children: i
1328
+ })]
1329
+ });
1330
+ }
1331
+ function ze({ left: e, right: t, leftTitle: n = "outline", rightTitle: r = "filters", leftIcon: i, rightIcon: a, leftMeta: o, rightMeta: l, className: u = "" }) {
1332
+ return /* @__PURE__ */ c("div", {
1333
+ className: `rs-split${u ? ` ${u}` : ""}`,
1334
+ children: [/* @__PURE__ */ s(z, {
1335
+ title: n,
1336
+ icon: i,
1337
+ meta: o,
1338
+ children: e
1339
+ }), /* @__PURE__ */ s(z, {
1340
+ title: r,
1341
+ icon: a,
1342
+ meta: l,
1343
+ children: t
1344
+ })]
1345
+ });
1346
+ }
1347
+ //#endregion
1348
+ //#region src/ui/inuse/InUseShell.jsx
1349
+ var B = Object.freeze([
1350
+ {
1351
+ id: "transcript",
1352
+ mark: "transcript-browser",
1353
+ icon: ie
1354
+ },
1355
+ {
1356
+ id: "commons",
1357
+ mark: "village",
1358
+ icon: ce
1359
+ },
1360
+ {
1361
+ id: "graph",
1362
+ mark: "peasant",
1363
+ icon: _
1364
+ }
1365
+ ]), V = Object.freeze([
1366
+ {
1367
+ id: "analytics",
1368
+ label: "analytics"
1369
+ },
1370
+ {
1371
+ id: "changes",
1372
+ label: "changes"
1373
+ },
1374
+ {
1375
+ id: "map",
1376
+ label: "code map"
1377
+ }
1378
+ ]);
1379
+ function Be(e) {
1380
+ return e && (/(INPUT|TEXTAREA|SELECT)/.test(e.tagName) || e.isContentEditable);
1381
+ }
1382
+ function Ve({ apps: e = B, defaultApp: t, activeApp: n, onAppChange: r, renderApp: o, brand: l = "fairtrade", ariaLabel: u = "the design system in use" }) {
1383
+ let [d, f] = a(t ?? e[0]?.id), p = n ?? d, m = i({}), h = (e) => {
1384
+ n === void 0 && f(e), r?.(e);
1385
+ }, g = e.find((e) => e.id === p) ?? e[0];
1386
+ return /* @__PURE__ */ c("section", {
1387
+ className: "iu",
1388
+ id: "inuse",
1389
+ "aria-label": u,
1390
+ onKeyDown: (t) => {
1391
+ if (Be(t.target)) return;
1392
+ let n = {
1393
+ 1: 0,
1394
+ 2: 1,
1395
+ 3: 2
1396
+ }[t.key];
1397
+ n != null && e[n] && (t.preventDefault(), h(e[n].id));
1398
+ },
1399
+ children: [/* @__PURE__ */ c("div", {
1400
+ className: "iu-bar",
1401
+ children: [/* @__PURE__ */ c("div", {
1402
+ className: "iu-bar-brand",
1403
+ children: [/* @__PURE__ */ s("svg", {
1404
+ className: "logo",
1405
+ width: "18",
1406
+ height: "18",
1407
+ viewBox: "0 0 32 32",
1408
+ "aria-hidden": "true",
1409
+ children: /* @__PURE__ */ s("use", { href: "#logo" })
1410
+ }), /* @__PURE__ */ s("span", { children: l })]
1411
+ }), /* @__PURE__ */ s("div", {
1412
+ className: "iu-switch",
1413
+ role: "tablist",
1414
+ "aria-label": "apps",
1415
+ "aria-orientation": "horizontal",
1416
+ onKeyDown: (t) => {
1417
+ let n = e.map((e) => e.id), r = n.indexOf(g?.id);
1418
+ if (r < 0) return;
1419
+ let i = r;
1420
+ if (t.key === "ArrowRight" || t.key === "ArrowDown") i = (r + 1) % n.length;
1421
+ else if (t.key === "ArrowLeft" || t.key === "ArrowUp") i = (r - 1 + n.length) % n.length;
1422
+ else if (t.key === "Home") i = 0;
1423
+ else if (t.key === "End") i = n.length - 1;
1424
+ else return;
1425
+ t.preventDefault(), h(n[i]), m.current[n[i]]?.focus();
1426
+ },
1427
+ children: e.map((e, t) => {
1428
+ let n = e.icon, r = e.id === g?.id;
1429
+ return /* @__PURE__ */ c("button", {
1430
+ type: "button",
1431
+ role: "tab",
1432
+ id: "iu-tab-" + e.id,
1433
+ "aria-selected": r ? "true" : "false",
1434
+ "aria-controls": "inuse-stage",
1435
+ tabIndex: r ? 0 : -1,
1436
+ ref: (t) => {
1437
+ m.current[e.id] = t;
1438
+ },
1439
+ className: "iu-opt" + (r ? " iu-opt-on" : ""),
1440
+ onClick: () => h(e.id),
1441
+ children: [
1442
+ n ? /* @__PURE__ */ s("span", {
1443
+ className: "iu-opt-ico",
1444
+ children: /* @__PURE__ */ s(n, {
1445
+ size: 16,
1446
+ "aria-hidden": "true"
1447
+ })
1448
+ }) : null,
1449
+ /* @__PURE__ */ s("span", {
1450
+ className: "iu-opt-label",
1451
+ children: e.mark
1452
+ }),
1453
+ /* @__PURE__ */ s("span", {
1454
+ className: "iu-opt-key",
1455
+ "aria-hidden": "true",
1456
+ children: t + 1
1457
+ })
1458
+ ]
1459
+ }, e.id);
1460
+ })
1461
+ })]
1462
+ }), /* @__PURE__ */ s("div", {
1463
+ className: "iu-stage",
1464
+ id: "inuse-stage",
1465
+ role: "tabpanel",
1466
+ "aria-labelledby": "iu-tab-" + g?.id,
1467
+ tabIndex: -1,
1468
+ children: /* @__PURE__ */ s("div", {
1469
+ className: "iu-screen",
1470
+ children: g ? o?.(g.id) : null
1471
+ }, g?.id)
1472
+ })]
1473
+ });
1474
+ }
1475
+ function He({ sections: e = V, activeId: t, activePrimaryId: n, onSectionChange: r, backTo: i, onBack: a, children: o, ariaLabel: l = "peasant sections" }) {
1476
+ let u = n ?? t;
1477
+ return /* @__PURE__ */ c("div", {
1478
+ className: "iu-app-root",
1479
+ children: [/* @__PURE__ */ c("nav", {
1480
+ className: "iu-subnav",
1481
+ "aria-label": l,
1482
+ children: [i ? /* @__PURE__ */ c("button", {
1483
+ type: "button",
1484
+ className: "iu-subnav-back",
1485
+ onClick: () => a ? a(i) : r?.(i),
1486
+ children: [/* @__PURE__ */ s(d, {
1487
+ size: 14,
1488
+ "aria-hidden": "true"
1489
+ }), " back"]
1490
+ }) : null, e.map((e) => /* @__PURE__ */ s("button", {
1491
+ type: "button",
1492
+ className: "iu-subnav-item" + (u === e.id ? " active" : ""),
1493
+ "aria-current": t === e.id ? "page" : void 0,
1494
+ onClick: () => r?.(e.id),
1495
+ children: e.label
1496
+ }, e.id))]
1497
+ }), /* @__PURE__ */ s("div", {
1498
+ className: "iu-view",
1499
+ children: o
1500
+ })]
1501
+ });
1502
+ }
1503
+ function H({ sections: e = V, activeId: t = void 0, hrefFor: n = void 0, LinkComponent: r = void 0, onSectionChange: i = void 0, className: a = "iu-subnav", itemClassName: l = "iu-subnav-item", activeItemClassName: u = "active", activeMarker: d = null, ariaLabel: f = "peasant sections" }) {
1504
+ return /* @__PURE__ */ s("nav", {
1505
+ className: a,
1506
+ "aria-label": f,
1507
+ children: e.map((e) => {
1508
+ let a = t === e.id, f = l + (a && u ? " " + u : ""), p = /* @__PURE__ */ c(o, { children: [e.label, a ? d : null] }), m = n?.(e);
1509
+ return m && r ? /* @__PURE__ */ s(r, {
1510
+ href: m,
1511
+ className: f,
1512
+ "aria-current": a ? "page" : void 0,
1513
+ title: e.title,
1514
+ children: p
1515
+ }, e.id) : m ? /* @__PURE__ */ s("a", {
1516
+ href: m,
1517
+ className: f,
1518
+ "aria-current": a ? "page" : void 0,
1519
+ title: e.title,
1520
+ children: p
1521
+ }, e.id) : /* @__PURE__ */ s("button", {
1522
+ type: "button",
1523
+ className: f,
1524
+ "aria-current": a ? "page" : void 0,
1525
+ onClick: () => i?.(e.id),
1526
+ children: p
1527
+ }, e.id);
1528
+ })
1529
+ });
1530
+ }
1531
+ //#endregion
1532
+ export { Ve as a, ze as c, fe as d, B as i, I as l, He as n, R as o, H as r, L as s, V as t, T as u };