veoflow 0.4.3 → 0.4.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.
- package/bin/veoflow.mjs +1 -1
- package/dist/veo.mjs +186 -44
- package/native/veo-extract.darwin-arm64.node +0 -0
- package/native/veo-extract.darwin-x64.node +0 -0
- package/native/veo-extract.linux-arm64-gnu.node +0 -0
- package/native/veo-extract.linux-x64-gnu.node +0 -0
- package/native/veo-extract.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
- package/web/assets/{index-DcI5_Yly.js → index-Bx_159jR.js} +1 -1
- package/web/index.html +1 -1
package/bin/veoflow.mjs
CHANGED
|
@@ -6,7 +6,7 @@ const here = dirname(fileURLToPath(import.meta.url));
|
|
|
6
6
|
process.env.VEO_CHECKERS_MODULE ??= pathToFileURL(join(here, "../dist/checkers.mjs")).href;
|
|
7
7
|
process.env.VEO_NATIVE_DIR ??= join(here, "../native");
|
|
8
8
|
process.env.VEO_WEB_ROOT ??= join(here, "../web");
|
|
9
|
-
process.env.VEO_VERSION = "0.4.
|
|
9
|
+
process.env.VEO_VERSION = "0.4.4";
|
|
10
10
|
const { main } = await import("../dist/veo.mjs");
|
|
11
11
|
const code = await main(process.argv.slice(2), {
|
|
12
12
|
out: (line) => process.stdout.write(line + "\n"),
|
package/dist/veo.mjs
CHANGED
|
@@ -3796,7 +3796,7 @@ var PROTOCOL_VERSION;
|
|
|
3796
3796
|
var init_protocol = __esm({
|
|
3797
3797
|
"protocol/index.ts"() {
|
|
3798
3798
|
"use strict";
|
|
3799
|
-
PROTOCOL_VERSION = "1.
|
|
3799
|
+
PROTOCOL_VERSION = "1.7.0";
|
|
3800
3800
|
}
|
|
3801
3801
|
});
|
|
3802
3802
|
|
|
@@ -3908,6 +3908,8 @@ function factsForFile(sourceId, file2, result2) {
|
|
|
3908
3908
|
status: u.status,
|
|
3909
3909
|
importSpecifier: u.importSpecifier,
|
|
3910
3910
|
importedName: u.importedName,
|
|
3911
|
+
// A method of what an imported class makes (#281): only with its receiver.
|
|
3912
|
+
...u.receiver && u.member ? { member: u.member, receiver: u.receiver } : {},
|
|
3911
3913
|
evidence: evidence(u.site)
|
|
3912
3914
|
};
|
|
3913
3915
|
facts.push(site);
|
|
@@ -4556,6 +4558,20 @@ var init_engine = __esm({
|
|
|
4556
4558
|
}
|
|
4557
4559
|
// -------------------------------------------------------------------------
|
|
4558
4560
|
// projects and sources
|
|
4561
|
+
/** A folder's git repository top, or null for a plain folder; kept, since it rarely changes. */
|
|
4562
|
+
repoTops = /* @__PURE__ */ new Map();
|
|
4563
|
+
repoTop(root) {
|
|
4564
|
+
let top = this.repoTops.get(root);
|
|
4565
|
+
if (top === void 0) {
|
|
4566
|
+
try {
|
|
4567
|
+
top = repoInfo(root)?.top ?? null;
|
|
4568
|
+
} catch {
|
|
4569
|
+
top = null;
|
|
4570
|
+
}
|
|
4571
|
+
this.repoTops.set(root, top);
|
|
4572
|
+
}
|
|
4573
|
+
return top;
|
|
4574
|
+
}
|
|
4559
4575
|
listProjects() {
|
|
4560
4576
|
return {
|
|
4561
4577
|
projects: this.catalog.listProjects().map((p) => {
|
|
@@ -4567,6 +4583,9 @@ var init_engine = __esm({
|
|
|
4567
4583
|
try {
|
|
4568
4584
|
const store = this.handle(p).store;
|
|
4569
4585
|
summary2.committedRun = store.currentRun();
|
|
4586
|
+
const tops = this.catalog.listSources(p.id).map((s) => this.repoTop(s.root));
|
|
4587
|
+
summary2.repositories = new Set(tops.filter((t) => t !== null)).size;
|
|
4588
|
+
summary2.folders = tops.filter((t) => t === null).length;
|
|
4570
4589
|
const latest = store.runs().filter((r) => r.base === void 0).at(-1);
|
|
4571
4590
|
if (latest)
|
|
4572
4591
|
summary2.latest = {
|
|
@@ -10236,6 +10255,43 @@ function resolveImports2(plans, files) {
|
|
|
10236
10255
|
return true;
|
|
10237
10256
|
});
|
|
10238
10257
|
};
|
|
10258
|
+
const exportedSources = (dir, pkg, sub) => {
|
|
10259
|
+
const exports = pkg.exports;
|
|
10260
|
+
if (!exports || typeof exports !== "object" || Array.isArray(exports)) return [];
|
|
10261
|
+
const code = [];
|
|
10262
|
+
const types = [];
|
|
10263
|
+
const collect = (v, typesOnly) => {
|
|
10264
|
+
if (typeof v === "string") (typesOnly || /\.d\.[cm]?ts$/.test(v) ? types : code).push(v);
|
|
10265
|
+
else if (Array.isArray(v)) v.forEach((x) => collect(x, typesOnly));
|
|
10266
|
+
else if (v && typeof v === "object")
|
|
10267
|
+
for (const [k, x] of Object.entries(v)) collect(x, typesOnly || k === "types" || k === "typings");
|
|
10268
|
+
};
|
|
10269
|
+
const key = `./${sub}`;
|
|
10270
|
+
const map2 = exports;
|
|
10271
|
+
let middle = null;
|
|
10272
|
+
if (key in map2) collect(map2[key], false);
|
|
10273
|
+
else {
|
|
10274
|
+
const best = Object.keys(map2).filter((k) => {
|
|
10275
|
+
const star2 = k.indexOf("*");
|
|
10276
|
+
return star2 >= 0 && key.startsWith(k.slice(0, star2)) && key.endsWith(k.slice(star2 + 1)) && key.length >= k.length - 1;
|
|
10277
|
+
}).sort((a, b) => b.indexOf("*") - a.indexOf("*") || b.length - a.length)[0];
|
|
10278
|
+
if (!best) return [];
|
|
10279
|
+
const star = best.indexOf("*");
|
|
10280
|
+
middle = key.slice(star, key.length - (best.length - star - 1));
|
|
10281
|
+
collect(map2[best], false);
|
|
10282
|
+
}
|
|
10283
|
+
const out2 = [];
|
|
10284
|
+
for (const t of [...code, ...types]) {
|
|
10285
|
+
const rel = (middle === null ? t : t.replace("*", middle)).replace(/^\.\//, "").replace(/(\.d)?\.[cm]?[jt]sx?$/, "");
|
|
10286
|
+
const parts = rel.split("/");
|
|
10287
|
+
if (!parts[0] || !BUILD_DIRS.has(parts[0]) || parts.length < 2) continue;
|
|
10288
|
+
let inner = 1;
|
|
10289
|
+
while (inner < parts.length - 1 && BUILD_DIRS.has(parts[inner])) inner++;
|
|
10290
|
+
for (const rest of [parts.slice(inner), parts.slice(1)])
|
|
10291
|
+
out2.push(join14(dir, "src", ...rest), join14(dir, ...rest));
|
|
10292
|
+
}
|
|
10293
|
+
return [...new Set(out2)];
|
|
10294
|
+
};
|
|
10239
10295
|
const frameworkFallback = (t, from, specifier) => {
|
|
10240
10296
|
specifier = specifier.replace(/\?[^/]*$/, "");
|
|
10241
10297
|
const name = packageName(specifier);
|
|
@@ -10243,7 +10299,7 @@ function resolveImports2(plans, files) {
|
|
|
10243
10299
|
const pkg = link2 ? link2.tree.manifests.get(join14(link2.dir, "package.json")) : void 0;
|
|
10244
10300
|
if (link2 && pkg && entriesInMissingBuild(link2.tree, link2.dir, pkg)) {
|
|
10245
10301
|
const sub = specifier.slice(name.length).replace(/^\//, "");
|
|
10246
|
-
const bases = sub ? [join14(link2.dir, "src", sub), join14(link2.dir, sub)] : [
|
|
10302
|
+
const bases = sub ? [...exportedSources(link2.dir, pkg, sub), join14(link2.dir, "src", sub), join14(link2.dir, sub)] : [
|
|
10247
10303
|
...typeof pkg.source === "string" ? [join14(link2.dir, pkg.source)] : [],
|
|
10248
10304
|
join14(link2.dir, "src/index"),
|
|
10249
10305
|
join14(link2.dir, "index")
|
|
@@ -11350,7 +11406,8 @@ function typeGraph(input2) {
|
|
|
11350
11406
|
const found = declaredAt(file2, b.name);
|
|
11351
11407
|
const base2 = declared2(found) ? found : null;
|
|
11352
11408
|
const clause = evidence(file2, b.span);
|
|
11353
|
-
if (t.kind === "class" && b.relation === "extends")
|
|
11409
|
+
if (t.kind === "class" && b.relation === "extends")
|
|
11410
|
+
parentOf2.set(declKey(decl), { base: base2, name: b.name, clause });
|
|
11354
11411
|
if (!base2) continue;
|
|
11355
11412
|
const list = subtypes.get(declKey(base2)) ?? [];
|
|
11356
11413
|
list.push({ decl, kind: t.kind, clause });
|
|
@@ -11405,7 +11462,35 @@ function typeGraph(input2) {
|
|
|
11405
11462
|
}
|
|
11406
11463
|
return "unknown";
|
|
11407
11464
|
};
|
|
11465
|
+
const inherited = (d, member, isStatic) => {
|
|
11466
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11467
|
+
for (let at = d; at; ) {
|
|
11468
|
+
if (seen.has(declKey(at))) return "unknown";
|
|
11469
|
+
seen.add(declKey(at));
|
|
11470
|
+
const info = typesByKey.get(declKey(at));
|
|
11471
|
+
if (!info || info.kind !== "class") return "unknown";
|
|
11472
|
+
const table = isStatic ? info.statics ?? [] : info.members;
|
|
11473
|
+
if (table.some((x) => x.name === "[written]")) return "other";
|
|
11474
|
+
if (table.some((x) => x.name.startsWith("[") && !x.name.startsWith("[Symbol."))) return "unknown";
|
|
11475
|
+
const m = table.find((x) => x.name === member);
|
|
11476
|
+
if (m) {
|
|
11477
|
+
const fn = m.kind === "method" && m.function ? fnByName.get(`${at.file}\0${m.function}`) : void 0;
|
|
11478
|
+
return fn ? { fn, definer: at } : "other";
|
|
11479
|
+
}
|
|
11480
|
+
const parent = parentOf2.get(declKey(at));
|
|
11481
|
+
if (!parent) return "none";
|
|
11482
|
+
if (parent.base) {
|
|
11483
|
+
at = parent.base;
|
|
11484
|
+
continue;
|
|
11485
|
+
}
|
|
11486
|
+
const imp = importOf(at.file, parent.name);
|
|
11487
|
+
if (imp?.target.kind === "package") return { pkg: imp.target.pkg.id, name: imp.target.pkg.name };
|
|
11488
|
+
return "unknown";
|
|
11489
|
+
}
|
|
11490
|
+
return "unknown";
|
|
11491
|
+
};
|
|
11408
11492
|
return {
|
|
11493
|
+
inherited,
|
|
11409
11494
|
resultOf,
|
|
11410
11495
|
pathOf: pathOf4,
|
|
11411
11496
|
sourceOf: sourceOf4,
|
|
@@ -12604,6 +12689,47 @@ function link(input2, graph = typeGraph(input2)) {
|
|
|
12604
12689
|
};
|
|
12605
12690
|
return missing(f, "member", `Stage 2 can't tell what instances of ${at(cls)} run for ${m}`);
|
|
12606
12691
|
};
|
|
12692
|
+
const classMember = (statement, name, member, receiver) => {
|
|
12693
|
+
const f = follow(statement, name, [], 0);
|
|
12694
|
+
const what = receiver === "class" ? `the static ${member}` : member;
|
|
12695
|
+
if (f.kind === "external")
|
|
12696
|
+
return {
|
|
12697
|
+
...f,
|
|
12698
|
+
steps: [...f.steps, { kind: "instance", detail: `${name} is a class of a package: it runs ${what}` }]
|
|
12699
|
+
};
|
|
12700
|
+
if (f.kind !== "function") return f.kind === "value" ? missing(f, "member", `${name} isn't a class`) : f;
|
|
12701
|
+
if (!f.cls) return missing(f, "member", `${name} is a function, not a class Stage 2 follows members of`);
|
|
12702
|
+
const cls = f.cls;
|
|
12703
|
+
const r = graph.inherited(cls, member, receiver === "class");
|
|
12704
|
+
const kind = receiver === "class" ? "static" : "instance";
|
|
12705
|
+
if (r === "none") return missing(f, "member", `no class up ${at(cls)}'s chain declares ${what}`);
|
|
12706
|
+
if (r === "other")
|
|
12707
|
+
return missing(
|
|
12708
|
+
f,
|
|
12709
|
+
"not-a-function",
|
|
12710
|
+
`${at(cls)}'s ${what} isn't a method (a field, an accessor, or abstract)`
|
|
12711
|
+
);
|
|
12712
|
+
if (r === "unknown")
|
|
12713
|
+
return missing(f, "member", `${at(cls)}'s classes can't all be followed for ${what}`);
|
|
12714
|
+
if ("pkg" in r)
|
|
12715
|
+
return {
|
|
12716
|
+
kind: "external",
|
|
12717
|
+
pkg: r.pkg,
|
|
12718
|
+
steps: [...f.steps, { kind, detail: `${at(cls)} inherits ${what} from a class of ${r.name}` }]
|
|
12719
|
+
};
|
|
12720
|
+
return {
|
|
12721
|
+
kind: "function",
|
|
12722
|
+
fn: r.fn.id,
|
|
12723
|
+
hops: f.hops,
|
|
12724
|
+
steps: [
|
|
12725
|
+
...f.steps,
|
|
12726
|
+
{
|
|
12727
|
+
kind,
|
|
12728
|
+
detail: r.definer.file === cls.file && r.definer.name === cls.name ? `${at(cls)} declares ${what}` : `${at(cls)} inherits ${what} from ${at(r.definer)}`
|
|
12729
|
+
}
|
|
12730
|
+
]
|
|
12731
|
+
};
|
|
12732
|
+
};
|
|
12607
12733
|
const valueCall = (f, name, depth) => {
|
|
12608
12734
|
const v = f.value;
|
|
12609
12735
|
if (v.kind === "instance" || v.kind === "object")
|
|
@@ -12663,49 +12789,65 @@ function link(input2, graph = typeGraph(input2)) {
|
|
|
12663
12789
|
});
|
|
12664
12790
|
continue;
|
|
12665
12791
|
}
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12792
|
+
let found;
|
|
12793
|
+
let steps;
|
|
12794
|
+
let via = "import";
|
|
12795
|
+
if (site.receiver && site.member) {
|
|
12796
|
+
const cls = site.importedName ?? "default";
|
|
12797
|
+
found = classMember(statement, cls, site.member, site.receiver);
|
|
12798
|
+
via = /^(this|super)\./.test(site.expression) ? "inherited" : "import";
|
|
12799
|
+
steps = [
|
|
12800
|
+
{
|
|
12801
|
+
kind: "import",
|
|
12802
|
+
detail: `${site.expression} calls ${site.member} on ${site.receiver === "class" ? "the class" : "an instance of"} ${cls}, imported from ${site.importSpecifier}`
|
|
12803
|
+
},
|
|
12804
|
+
...found.steps
|
|
12805
|
+
];
|
|
12675
12806
|
} else {
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
{ kind: "import", detail: `${site.expression} goes through ${site.importSpecifier}` },
|
|
12689
|
-
...t.kind === "file" ? [{ kind: "computed", detail: `${site.expression} has no static name to follow` }] : t.steps
|
|
12690
|
-
]
|
|
12691
|
-
});
|
|
12692
|
-
continue;
|
|
12693
|
-
}
|
|
12694
|
-
let followed = follow(statement, name, [], 0);
|
|
12695
|
-
let path = member ? rest : "";
|
|
12696
|
-
if (binding2?.[0] === null && name !== "default" && followed.kind === "missing" && followed.steps.at(-1)?.kind === "not-exported") {
|
|
12697
|
-
const whole = follow(statement, "default", [], 0);
|
|
12698
|
-
if (whole.kind === "value" || whole.kind === "function" && whole.cls) {
|
|
12699
|
-
followed = whole;
|
|
12700
|
-
name = "default";
|
|
12701
|
-
path = rest;
|
|
12807
|
+
const local = /^[\w$]+/.exec(site.expression)?.[0] ?? null;
|
|
12808
|
+
const binding2 = statement.statement.bindings.find(([, l]) => l === local);
|
|
12809
|
+
const rest = local ? site.expression.slice(local.length) : site.expression;
|
|
12810
|
+
let name;
|
|
12811
|
+
let member = false;
|
|
12812
|
+
if (binding2 && binding2[0] === "*") {
|
|
12813
|
+
name = site.importedName && rest === `.${site.importedName}` ? site.importedName : null;
|
|
12814
|
+
} else if (binding2 && binding2[0] === null) {
|
|
12815
|
+
name = rest === "" ? "default" : site.importedName && rest === `.${site.importedName}` ? site.importedName : null;
|
|
12816
|
+
} else {
|
|
12817
|
+
name = site.importedName ?? binding2?.[0] ?? null;
|
|
12818
|
+
member = rest !== "" && !/^\.(call|apply|bind)$/.test(rest);
|
|
12702
12819
|
}
|
|
12820
|
+
if (name === null) {
|
|
12821
|
+
const t = statement.target;
|
|
12822
|
+
resolutions.push({
|
|
12823
|
+
...base2,
|
|
12824
|
+
status: t.kind === "package" ? "external" : "unresolved",
|
|
12825
|
+
target: null,
|
|
12826
|
+
externalPackage: t.kind === "package" ? t.pkg.id : null,
|
|
12827
|
+
importOutcome: t.kind === "unresolved" ? t.outcome : null,
|
|
12828
|
+
steps: [
|
|
12829
|
+
{ kind: "import", detail: `${site.expression} goes through ${site.importSpecifier}` },
|
|
12830
|
+
...t.kind === "file" ? [{ kind: "computed", detail: `${site.expression} has no static name to follow` }] : t.steps
|
|
12831
|
+
]
|
|
12832
|
+
});
|
|
12833
|
+
continue;
|
|
12834
|
+
}
|
|
12835
|
+
let followed = follow(statement, name, [], 0);
|
|
12836
|
+
let path = member ? rest : "";
|
|
12837
|
+
if (binding2?.[0] === null && name !== "default" && followed.kind === "missing" && followed.steps.at(-1)?.kind === "not-exported") {
|
|
12838
|
+
const whole = follow(statement, "default", [], 0);
|
|
12839
|
+
if (whole.kind === "value" || whole.kind === "function" && whole.cls) {
|
|
12840
|
+
followed = whole;
|
|
12841
|
+
name = "default";
|
|
12842
|
+
path = rest;
|
|
12843
|
+
}
|
|
12844
|
+
}
|
|
12845
|
+
found = settle2(followed, site.expression, name, path);
|
|
12846
|
+
steps = [
|
|
12847
|
+
{ kind: "import", detail: `${site.expression} is ${name} imported from ${site.importSpecifier}` },
|
|
12848
|
+
...found.steps
|
|
12849
|
+
];
|
|
12703
12850
|
}
|
|
12704
|
-
const found = settle2(followed, site.expression, name, path);
|
|
12705
|
-
const steps = [
|
|
12706
|
-
{ kind: "import", detail: `${site.expression} is ${name} imported from ${site.importSpecifier}` },
|
|
12707
|
-
...found.steps
|
|
12708
|
-
];
|
|
12709
12851
|
switch (found.kind) {
|
|
12710
12852
|
case "function":
|
|
12711
12853
|
resolutions.push({
|
|
@@ -12713,7 +12855,7 @@ function link(input2, graph = typeGraph(input2)) {
|
|
|
12713
12855
|
status: "linked",
|
|
12714
12856
|
target: found.fn,
|
|
12715
12857
|
externalPackage: null,
|
|
12716
|
-
via
|
|
12858
|
+
via,
|
|
12717
12859
|
importOutcome: null,
|
|
12718
12860
|
steps,
|
|
12719
12861
|
hops: found.hops
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -333,7 +333,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
333
333
|
`,` · `)},e.id))]}),(0,K.jsx)(`button`,{className:`fit`,onClick:()=>u.current&&Dx(u.current),children:`Fit`})]})}function Dx(e){e.fit(void 0,30);let t=e.zoom();if(t>1.2)e.zoom(1.2),e.center();else if(t<.75){let t=e.elements().boundingBox();e.zoom(.75),e.pan({x:30-t.x1*.75,y:30-t.y1*.75})}}var Ox=new Map;function kx(e,t,n){let r=Ox.get(e);return r||(r=n(),Ox.set(e,r),r.then(n=>n.committedRun!==t&&Ox.delete(e),()=>Ox.delete(e)),Ox.size>40&&Ox.delete(Ox.keys().next().value)),r}function Ax(e,t,n,r,i){let[a,o]=(0,d.useState)({key:null,data:null,error:null});return(0,d.useEffect)(()=>{if(e===null)return;let r=!1;return kx(e,t,n).then(t=>!r&&o({key:e,scope:i,data:t,error:null}),t=>!r&&o({key:e,scope:i,data:null,error:t.message})),()=>{r=!0}},[e,r]),a.key===e?a:i!==void 0&&a.scope===i&&a.data?{data:a.data,error:null}:{data:null,error:null}}function jx(e,t,n=0,r=null){let{data:i,error:a}=Ax(e?JSON.stringify([`groups`,e,t,r]):null,t,()=>L.groups(e,r),n);return{groups:i,error:a}}function Mx(e,t,n,r,i,a=0){let o=[...r].sort(),{data:s,error:c}=Ax(e&&n?JSON.stringify([`group`,e,t,n,o,i]):null,t,()=>L.group(e,n,o,i),a,JSON.stringify([e,t,n]));return{group:s,error:c}}function Nx(e,t,n){let{data:r,error:i}=Ax(e&&n?JSON.stringify([`imports`,e,t,n]):null,t,()=>L.imports(e,n),0);return{imports:r,error:i}}function Px(e,t,n){let{data:r,error:i}=Ax(e&&n?JSON.stringify([`calls`,e,t,n]):null,t,()=>Promise.all([L.crossFileCalls(e,n,`out`),L.crossFileCalls(e,n,`in`)]).then(([e,t])=>({committedRun:e.committedRun,out:e,in:t})),0);return{calls:r,error:i}}var Fx={"dynamic-dispatch":`type unknown`,reflection:`reflection`,"computed-member":`computed name`,metaprogramming:`built at run time`,candidates:`narrowed to candidates`,ambiguous:`could be several functions`,"not-exported":`not exported`,"not-found":`not found`,"template-binding":`awaiting its component`,"template-reference":`registered elsewhere`},Ix=100;function Lx(e,t,n,r,i){let a=JSON.stringify([e,n,r]),o=JSON.stringify([a,t,i]),[s,c]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!e)return;let t=!1;return L.findings(e,r.length?r:[`broken`],n?.kind===`file`?{file:n.file}:n?.kind===`group`?{group:n.group}:n?.kind===`source`?{source:n.source}:{},r.length?1e3:1).then(e=>!t&&c({key:o,same:a,data:e,error:null}),e=>!t&&c({key:o,same:a,data:null,error:e.message})),()=>{t=!0}},[o]),!s||s.same!==a?{data:null,error:null}:{data:s.data,error:s.key===o?s.error:null}}function Rx({project:e,run:t,scope:n,wholeProject:r,canScope:i,showPending:a,refresh:o,filter:s,onFilter:c,onWholeProject:l,onTogglePending:u,onSelectSite:f,onOpenImport:p,onManageLicense:m}){let h=r?null:n,{data:g}=Lx(e,t,h,[],o),_=g?.counts,v=s??(_&&_.broken>0?`broken`:`open-call`),y=[v,...a&&v!==`open-call`?[`pending`]:[]],{data:b,error:x}=Lx(e,t,h,y,o),[S,C]=(0,d.useState)(null),w=b&&S?.after===b?S.rows:[],T=[...b?.findings??[],...w],[E,D]=(0,d.useState)(!1),[O,k]=(0,d.useState)(``),A=()=>{b&&(D(!0),k(``),L.findings(e,y,h?.kind===`file`?{file:h.file}:h?.kind===`group`?{group:h.group}:h?.kind===`source`?{source:h.source}:{},1e3,T.length).then(e=>C({after:b,rows:[...w,...e.findings]}),e=>k(e.message)).finally(()=>D(!1)))},{groups:j}=jx(e,t),M=(0,d.useMemo)(()=>new Map((j?.groups??[]).map(e=>[e.id,e])),[j]),N=e=>{let t=e.group?M.get(e.group):void 0,n=t&&t.kind!==`cluster`&&t.root&&e.path.startsWith(`${t.root}/`)?e.path.slice(t.root.length+1):e.path;return`${t?`${t.name} › `:``}${n}:${e.line}`},P=n?.kind===`group`?M.get(n.group)?.name??`this group`:``,F=i&&n&&(0,K.jsxs)(`div`,{className:`scope`,role:`group`,"aria-label":`Findings scope`,children:[(0,K.jsx)(`button`,{"aria-pressed":!r,onClick:()=>l(!1),"data-testid":`questions-scope-file`,children:n.kind===`file`?`This file`:n.kind===`group`?`This group (${P})`:`This repository (${n.name??n.source})`}),(0,K.jsx)(`button`,{"aria-pressed":r,onClick:()=>l(!0),"data-testid":`questions-scope-project`,children:`Whole project`})]}),I=(e,t,n)=>(0,K.jsxs)(`button`,{className:`chip`,"aria-pressed":v===e,"data-testid":`findings-filter-${e}`,"data-count":n??``,onClick:()=>c(e),children:[t,` `,(0,K.jsx)(`small`,{children:n??`…`})]},e),R=T.filter(e=>e.kind===v),z=T.filter(e=>e.kind===`pending`);return(0,K.jsxs)(`div`,{className:`findings-panel`,"data-testid":`findings-panel`,children:[(0,K.jsx)(ge,{project:e,run:t,refresh:o,onManage:m}),F,(0,K.jsxs)(`div`,{className:`chips`,role:`group`,"aria-label":`Kinds of findings`,children:[I(`broken`,`Broken imports`,_?.broken),I(`not-analyzed`,`Imports not analyzed`,_?.notAnalyzed),I(`open-call`,`Open calls`,_?.openCalls)]}),(0,K.jsxs)(`label`,{className:`toggle small muted`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-command":`toggle-pending`,checked:a,onChange:u}),`Show pending (waiting for another source)`,_?` · ${_.pending}`:``]}),x?(0,K.jsx)(`p`,{className:`hint error`,children:x}):b?v===`open-call`?(0,K.jsx)(Vx,{rows:R,where:N,project:e,onSelect:f}):(0,K.jsxs)(K.Fragment,{children:[v===`not-analyzed`&&(!h||h.kind===`source`)&&(0,K.jsx)(Ux,{project:e,run:t,source:h?.source??null,refresh:o}),(0,K.jsx)(Bx,{rows:R,empty:v===`broken`?`No broken imports.`:`No imports of files left out of analysis.`,where:N,project:e,onOpen:p})]}):(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`}),b&&a&&v!==`open-call`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Pending (`,z.length,`)`]}),(0,K.jsx)(Bx,{rows:z,empty:`Nothing waits for another source.`,where:N,project:e,onOpen:p})]}),b&&b.total>T.length&&(0,K.jsxs)(`p`,{className:`hint small`,"data-testid":`findings-truncated`,children:[`Showing `,T.length.toLocaleString(`en-US`),` of `,b.total.toLocaleString(`en-US`),`.`,` `,(0,K.jsx)(`button`,{className:`link`,"data-testid":`findings-more`,disabled:E,onClick:A,children:E?`Loading…`:`Show more`}),O&&(0,K.jsxs)(`span`,{className:`error`,children:[` `,O]})]})]})}function zx({project:e,id:t}){let[n,r]=(0,d.useState)(!1);return n?(0,K.jsx)(ue,{project:e,id:t,start:!0}):(0,K.jsx)(`button`,{className:`link small`,"data-command":`explain-finding`,onClick:()=>r(!0),children:`Explain`})}function Bx({rows:e,empty:t,where:n,project:r,onOpen:i}){let[a,o]=(0,d.useState)(Ix);return e.length===0?(0,K.jsx)(`p`,{className:`hint`,children:t}):(0,K.jsxs)(`ul`,{className:`questions finding-rows`,"data-testid":`finding-rows`,children:[e.slice(0,a).map(e=>(0,K.jsxs)(`li`,{"data-kind":e.kind,children:[(0,K.jsx)(`div`,{className:`qrow`,children:(0,K.jsxs)(`button`,{"data-command":`open-finding`,"data-id":e.id,onClick:()=>i(e.file,e.id,e.group),children:[(0,K.jsx)(`code`,{children:e.text}),(0,K.jsxs)(`small`,{children:[n(e),` · `,bx[e.reason]??e.reason]})]})}),(0,K.jsx)(zx,{project:r,id:e.id})]},e.id)),e.length>a&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link`,onClick:()=>o(a+Ix),children:[e.length-a,` more…`]})})]})}function Vx({rows:e,where:t,project:n,onSelect:r}){let[i,a]=(0,d.useState)(Ix),[o,s]=(0,d.useState)(null),c=(0,d.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.text);e?e.push(n):t.set(n.text,[n])}return[...t].sort(([e,t],[n,r])=>r.length-t.length||(e<n?-1:+(e>n)))},[e]),l=e=>e.id.startsWith(`resolution|`)?e.id.slice(11):e.id;return e.length===0?(0,K.jsx)(`p`,{className:`hint`,children:`No open calls.`}):(0,K.jsxs)(`ul`,{className:`questions`,"data-testid":`questions`,children:[c.slice(0,i).map(([e,i])=>{let a=i[0],c=new Set(i.map(e=>e.file)).size,u=i.length===1?t(a):`×${i.length}${c>1?` in ${c} files`:``}`;return(0,K.jsxs)(`li`,{children:[(0,K.jsxs)(`div`,{className:`qrow`,children:[(0,K.jsxs)(`button`,{"data-command":`select`,"data-kind":`site`,"data-count":i.length,title:e,onClick:()=>r(l(a),a.file),children:[(0,K.jsx)(`code`,{children:e}),(0,K.jsxs)(`small`,{children:[u,` ·`,` `,a.candidates?a.exhaustive===!1?`${a.candidates} known function${a.candidates===1?``:`s`}, may not be all`:a.candidates===1?`one possible function`:`one of ${a.candidates} functions`:Fx[a.reason]??a.reason]})]}),i.length>1&&(0,K.jsx)(`button`,{className:`icon expand`,"aria-expanded":o===e,"aria-label":`Show all ${i.length}`,onClick:()=>s(o===e?null:e),children:o===e?`▾`:`▸`})]}),i.length===1&&(0,K.jsx)(zx,{project:n,id:a.id}),o===e&&(0,K.jsx)(`ul`,{className:`occurrences`,children:i.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`button`,{"data-command":`select`,"data-kind":`site`,onClick:()=>r(l(e),e.file),children:t(e)}),(0,K.jsx)(zx,{project:n,id:e.id})]},e.id))})]},e)}),c.length>i&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link`,onClick:()=>a(i+Ix),children:[c.length-i,` more…`]})})]})}var Hx={"language-not-analyzed":`language not analyzed yet`,"declaration-file":`type declarations`,"too-large":`over the size limit`,minified:`minified`,binary:`not text`,"invalid-utf8":`not UTF-8`,unreadable:`unreadable`,entitlement:`beyond the license`,frozen:`kept from an earlier analysis`,"parse-failure":`could not be parsed`,"internal-error":`the extractor failed`};function Ux({project:e,run:t,source:n,refresh:r}){let i=`${e}|${t??``}|${n??``}`,[a,o]=(0,d.useState)(null);(0,d.useEffect)(()=>{let t=!1;return L.totals(e,0,n??void 0).then(e=>!t&&o({key:i,files:e.files}),()=>!t&&o(null)),()=>{t=!0}},[i,r]);let s=a?.key===i?a.files:null,c=s?.notAnalyzed.reduce((e,t)=>e+t.files,0)??0;if(!s||c===0)return null;let l=e=>e.toLocaleString(`en-US`);return(0,K.jsxs)(`p`,{className:`small muted`,"data-testid":`unanalyzed-files`,children:[l(c),` of `,l(s.listed),` files aren't analyzed:`,` `,s.notAnalyzed.map(e=>`${l(e.files)} ${Hx[e.reason]??e.reason}`).join(`, `),`. They're marked ⚠ in the file tree; below are imports that lead to such files.`]})}function Wx(e,t,n=0){let r=e&&t?`${e}|${t.a}|${t.b}`:null,[i,a]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!r||!e||!t)return;let n=!1;return L.diff(e,t.a,t.b).then(e=>!n&&a({key:r,data:e,error:null}),e=>!n&&a({key:r,data:null,error:e.message})),()=>{n=!0}},[r,n]),i&&i.key===r?{data:i.data,error:i.error}:{data:null,error:null}}var Gx={added:`+`,removed:`−`,changed:`~`},Kx={added:`added`,removed:`removed`,changed:`changed`};function qx(e){let t=e.fact,n=e=>String(e??``).slice(String(e??``).lastIndexOf(`:`)+1);switch(e.type){case`Function`:return`function ${String(t.qualifiedName??t.name??n(e.id))}`;case`File`:return`file ${String(t.path??e.id)}`;case`CALLS`:case`CALLS_CROSS_FILE`:return`call ${n(t.from)} → ${n(t.to)}`;case`IMPORTS`:return`import ${String(t.specifier??``)}`;case`UnresolvedImport`:return`import ${String(t.specifier??``)} (${String(t.outcome??``)}${t.reason?`: ${String(t.reason)}`:``})`;case`UnresolvedCallSite`:return`open call ${String(t.expression??``)}`;case`SiteResolution`:return`call ${String(t.site??``).split(`|`)[3]??``} (${String(t.status??``)})`;case`Group`:return`group ${String(t.name??e.id)}`;case`DEPENDS_ON`:return`dependency ${String(t.from??``)} → ${String(t.to??``)}`;case`ExternalPackage`:return`package ${String(t.name??e.id)}`;case`Finding`:return`finding: ${String(t.message??t.kind??``)}`;default:return`${e.type} ${e.id}`}}function Jx(e){let t=[];for(let[n,r]of Object.entries({Function:`functions`,File:`files`,IMPORTS:`imports`,CALLS:`calls`,CALLS_CROSS_FILE:`cross-file calls`,UnresolvedImport:`unresolved imports`})){let i=e.byType[n];if(!i||i.added+i.removed+i.changed===0)continue;let a=[i.added?`+${i.added}`:``,i.removed?`−${i.removed}`:``,i.changed?`${i.changed} changed`:``].filter(Boolean);t.push(`${a.join(`, `)} ${r}`)}let{added:n,removed:r,changed:i}=e.total;return t.length?t.join(` · `):n+r+i===0?`No changes`:`${n+r+i} changes`}function Yx(e,t){return e.type===`ExternalPackage`?!1:e.change===`removed`?e.file!==null&&e.type!==`File`&&!t.has(e.file):e.file!==null||e.type===`Group`||e.type===`DEPENDS_ON`}var Xx=e=>e.startsWith(`sha256:`)?`folder`:e.slice(0,7),Zx=e=>e?new Date(e).toLocaleString():``;function Qx({run:e,picked:t,viewing:n,onPick:r,onView:i}){let a=e.sources.filter(e=>!e.pinned);return(0,K.jsxs)(`li`,{className:`run-row${n?` viewing`:``}`,"data-run":e.runId,children:[(0,K.jsx)(`label`,{className:`pick`,children:(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`compare-pick`,checked:t,onChange:e=>r(e.target.checked),"aria-label":`Compare run ${e.runId}`})}),(0,K.jsxs)(`span`,{className:`what`,children:[(0,K.jsxs)(`span`,{className:`title`,children:[(0,K.jsxs)(`strong`,{children:[`Run `,e.runId]}),e.current?(0,K.jsx)(`span`,{className:`badge`,children:`latest`}):null,e.kind===`branch`?(0,K.jsx)(`span`,{className:`badge`,children:`branch`}):null,e.kind===`draft`?(0,K.jsx)(`span`,{className:`badge`,children:`draft`}):null,e.kind===`debug`?(0,K.jsxs)(`span`,{className:`badge`,"data-testid":`debug-badge`,children:[`debug · until `,e.until]}):null]}),(0,K.jsx)(`span`,{className:`commits`,children:[...(a.length?a:e.sources).reduce((e,t)=>{let n=`${Xx(t.revision)}${t.branch?` (${t.branch})`:``}`;return e.set(n,[...e.get(n)??[],t.sourceId]),e},new Map).entries()].map(([e,t])=>`${t.join(`, `)} @ ${e}`).join(` · `)||`no sources`}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.trigger===`commit`?`commit hook`:e.trigger,` · +`,e.written.toLocaleString(`en-US`),` / −`,e.closed.toLocaleString(`en-US`),` facts · `,Zx(e.finishedAt)]})]}),(0,K.jsx)(`button`,{className:`link`,"data-command":`open-run`,onClick:i,disabled:n,children:n?`Viewing`:`View`})]})}function $x({project:e,refresh:t,run:n,compare:r,diff:i,diffError:a,onView:o,onCompare:s,onClose:c,onLocate:l,stages:u=[],onDebug:f}){let[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(r?[r.a,r.b]:[]);(0,d.useEffect)(()=>{r&&b([r.a,r.b])},[r?.a,r?.b]);let[x,S]=(0,d.useState)(``);(0,d.useEffect)(()=>{let t=!1;return L.history(e).then(e=>!t&&(g(e),v(null)),e=>!t&&v(e.message)),()=>{t=!0}},[e,t]);let C=(e,t)=>b(n=>t?[...n.filter(t=>t!==e),e].slice(-2):n.filter(t=>t!==e)),w=y.length===2?{a:Math.min(...y),b:Math.max(...y)}:null,T=(0,d.useMemo)(()=>new Set((i?.items??[]).filter(e=>e.type===`File`&&e.change===`removed`).map(e=>e.id)),[i]),E=(0,d.useMemo)(()=>{if(!i)return[];let e=x.trim().toLowerCase(),t=new Map(i.files.map(e=>[e.file??`\0${e.source}`,e.group?.name??e.source])),n=new Map;for(let r of i.items){let i=qx(r);if(e&&!`${i} ${r.file??``} ${r.type}`.toLowerCase().includes(e))continue;let a=r.file??`\0${r.source}`,o=t.get(a)??r.source,s=n.get(o);s||n.set(o,s=new Map);let c=s.get(a);c||s.set(a,c=[]),c.push({item:r,words:i})}return[...n].sort(([e],[t])=>e<t?-1:1)},[i,x]);return(0,K.jsxs)(`div`,{className:`history-panel`,"data-testid":`history-panel`,children:[(0,K.jsxs)(`div`,{className:`history-head`,children:[(0,K.jsx)(`strong`,{children:`History`}),(0,K.jsx)(`button`,{className:`icon`,"data-command":`toggle-history`,"aria-label":`Close History`,onClick:c,children:`×`})]}),r?(0,K.jsxs)(`section`,{className:`changes`,"aria-label":`Changes`,"data-testid":`change-list`,children:[(0,K.jsxs)(`div`,{className:`compare-head`,children:[(0,K.jsxs)(`span`,{children:[`Changes from run `,r.a,` to run `,r.b]}),(0,K.jsx)(`button`,{className:`link`,"data-command":`compare-runs`,onClick:()=>s(null),children:`Stop comparing`})]}),a?(0,K.jsx)(`p`,{className:`error`,children:a}):i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`summary`,"data-testid":`change-summary`,children:Jx(i)}),(0,K.jsxs)(`p`,{className:`legend muted small`,children:[`On the canvas:`,` `,(0,K.jsxs)(`span`,{className:`change added`,children:[(0,K.jsx)(`span`,{className:`sign`,children:`+`}),`added`]}),` `,`(solid blue border),`,` `,(0,K.jsxs)(`span`,{className:`change removed`,children:[(0,K.jsx)(`span`,{className:`sign`,children:`−`}),`removed`]}),` `,`(dashed orange),`,` `,(0,K.jsxs)(`span`,{className:`change changed`,children:[(0,K.jsx)(`span`,{className:`sign`,children:`~`}),`changed`]}),` `,`(double purple).`]}),i.latestOnly.length>0&&(0,K.jsxs)(`p`,{className:`muted small`,children:[`Not compared (plain folders have no history): `,i.latestOnly.join(`, `)]}),(0,K.jsx)(`input`,{type:`search`,className:`filter`,placeholder:`Filter changes`,"aria-label":`Filter changes`,"data-testid":`change-filter`,value:x,onChange:e=>S(e.target.value)}),E.map(([e,t])=>(0,K.jsxs)(`div`,{className:`change-group`,children:[(0,K.jsx)(`h4`,{children:e}),[...t].map(([e,t])=>(0,K.jsxs)(`div`,{className:`change-file`,children:[(0,K.jsx)(`div`,{className:`file-name`,children:e.startsWith(`\0`)?`(the repository)`:e.slice(e.indexOf(`:`)+1)}),(0,K.jsx)(`ul`,{children:t.map(({item:e,words:t})=>{let n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`sign`,"aria-hidden":`true`,children:Gx[e.change]}),(0,K.jsxs)(`span`,{className:`visually-hidden`,children:[Kx[e.change],`: `]}),t]});return(0,K.jsx)(`li`,{className:`change ${e.change}`,children:Yx(e,T)?(0,K.jsx)(`button`,{className:`link`,"data-testid":`change-item`,"data-id":e.id,"data-change":e.change,onClick:()=>l(e),children:n}):(0,K.jsx)(`span`,{"data-testid":`change-item`,"data-id":e.id,"data-change":e.change,children:n})},`${e.change}:${e.id}`)})})]},e))]},e)),i.truncated&&(0,K.jsxs)(`p`,{className:`muted small`,children:[`The first `,i.items.length,` of`,` `,i.total.added+i.total.removed+i.total.changed,` changes are listed.`]})]}):(0,K.jsx)(`p`,{className:`muted`,children:`Comparing…`})]}):null,_?(0,K.jsx)(`p`,{className:`error`,children:_}):null,h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`compare-bar`,children:[(0,K.jsx)(`button`,{"data-command":`compare-runs`,disabled:!w,onClick:()=>w&&s(w),title:`Pick two runs to compare`,children:w?`Compare run ${w.a} with run ${w.b}`:`Pick two runs to compare`}),n!==null&&(0,K.jsx)(`button`,{className:`link`,"data-command":`open-run`,onClick:()=>o(null),children:`Back to latest`})]}),(0,K.jsxs)(`ol`,{className:`runs`,"aria-label":`Runs`,children:[h.draft&&(0,K.jsx)(Qx,{run:h.draft,picked:y.includes(h.draft.runId),viewing:n===h.draft.runId,onPick:e=>C(h.draft.runId,e),onView:()=>o(h.draft.runId)}),h.debug&&(0,K.jsx)(Qx,{run:h.debug,picked:y.includes(h.debug.runId),viewing:n===h.debug.runId,onPick:e=>C(h.debug.runId,e),onView:()=>o(h.debug.runId)}),h.runs.map(e=>(0,K.jsx)(Qx,{run:e,picked:y.includes(e.runId),viewing:n===null?e.current:n===e.runId,onPick:t=>C(e.runId,t),onView:()=>o(e.current?null:e.runId)},e.runId))]}),h.hidden>0&&(0,K.jsxs)(`p`,{className:`muted small`,children:[h.hidden,` older runs aren't shown: this license shows 30 days of history.`]}),h.latestOnly.length>0&&(0,K.jsxs)(`p`,{className:`muted small`,children:[`Not under version control, so latest only: `,h.latestOnly.join(`, `),`. History and diffs need git.`]}),f&&u.length>0&&h.runs.length>0&&(0,K.jsxs)(`form`,{className:`debug-run`,onSubmit:e=>{e.preventDefault(),f(p||u[0])},children:[(0,K.jsxs)(`label`,{className:`muted small`,children:[`Debug run: stop after`,` `,(0,K.jsx)(`select`,{"data-testid":`debug-until`,value:p||u[0],onChange:e=>m(e.target.value),children:u.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsx)(`button`,{type:`submit`,"data-command":`analyze-debug`,"data-testid":`analyze-debug`,title:`Never committed: open it and compare it with the latest`,children:`Run`})]}),(0,K.jsxs)(`p`,{className:`muted small hook-note`,children:[`A run for each commit: `,(0,K.jsx)(`code`,{children:`veoflow hook install`}),` in a repository.`]})]}):!_&&(0,K.jsx)(`p`,{className:`muted`,children:`Loading…`})]})}var eS=e=>e.startsWith(`sha256:`)?``:e.slice(0,7),tS=e=>e.split(`
|
|
334
334
|
`).map(e=>e.trim()).filter(Boolean);function nS({source:e,onSave:t,onCancel:n}){let[r,i]=(0,d.useState)(e.include.join(`
|
|
335
335
|
`)),[a,o]=(0,d.useState)(e.exclude.join(`
|
|
336
|
-
`));return(0,K.jsxs)(`form`,{className:`rules-editor`,"data-testid":`rules-editor`,onSubmit:e=>{e.preventDefault(),t({include:tS(r),exclude:tS(a)})},children:[(0,K.jsxs)(`p`,{className:`muted small`,children:[`Glob patterns, one per line, relative to the repository (`,(0,K.jsx)(`code`,{children:`src/legacy/`}),`,`,` `,(0,K.jsx)(`code`,{children:`**/*.test.ts`}),`). Applied at the next analysis; files left out are closed in the graph and kept in history.`]}),(0,K.jsxs)(`label`,{children:[`Include only`,(0,K.jsx)(`textarea`,{"data-testid":`rules-include`,value:r,onChange:e=>i(e.target.value)})]}),(0,K.jsxs)(`label`,{children:[`Leave out`,(0,K.jsx)(`textarea`,{"data-testid":`rules-exclude`,value:a,onChange:e=>o(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`rules-save`,children:`Save and re-analyze`})]})]})}function rS({project:e,refresh:t,onAdd:n,onChooseFiles:r,onAnalyzeAll:i,onChanged:a,escape:o}){let[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(``),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(null),[w,T]=(0,d.useState)({top:0,right:0}),[E,D]=(0,d.useState)(!1),[O,k]=(0,d.useState)(0);(0,d.useEffect)(()=>{let t=!1;return L.sources(e).then(e=>!t&&c(e.sources.map(e=>({...e,optIn:e.optIn??[]}))),e=>!t&&u(e.message)),()=>{t=!0}},[e,t,O]);let A=async(e,t,n)=>{D(!0),u(``),n&&p(n);try{await e(),p(t),a()}catch(e){p(``),u(e.message??String(e))}finally{D(!1),k(e=>e+1)}},j=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!S)return;j.current?.querySelector(`button`)?.focus();let e=e=>{e.type===`mousedown`&&j.current?.contains(e.target)||C(null)};return document.addEventListener(`mousedown`,e),window.addEventListener(`resize`,e),document.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`resize`,e),document.removeEventListener(`scroll`,e,!0)}},[S]),o.current=()=>{if(S){let e=S;return C(null),document.querySelector(`tr[data-source="${CSS.escape(e)}"] [data-testid="repo-more"]`)?.focus(),!0}return m?(h(null),!0):b?(x(null),!0):v?(y(null),!0):!1};let M=(0,d.useRef)(null);if((0,d.useEffect)(()=>{(v||b)&&(M.current?.scrollIntoView({block:`nearest`}),M.current?.querySelector(`textarea, button`)?.focus())},[v,b]),(0,d.useEffect)(()=>{s&&(v&&!s.some(e=>e.id===v)&&y(null),b&&!s.some(e=>e.id===b)&&x(null))},[s,v,b]),!s)return(0,K.jsx)(`p`,{className:l?`error`:`muted`,children:l||`Loading…`});let N=v?s.find(e=>e.id===v):void 0;return(0,K.jsxs)(`div`,{className:`repositories`,"data-testid":`repositories`,children:[(0,K.jsxs)(`div`,{className:`repo-actions`,children:[(0,K.jsx)(`button`,{"data-testid":`repo-add`,onClick:n,children:`+ Add folder`}),(0,K.jsx)(`button`,{"data-testid":`repo-analyze-all`,disabled:E,onClick:i,children:`Re-analyze all`})]}),l&&(0,K.jsx)(`p`,{className:`error`,role:`alert`,children:l}),f&&(0,K.jsx)(`p`,{className:`muted small`,role:`status`,"data-testid":`repo-status`,children:f}),(0,K.jsxs)(`table`,{className:`repo-table`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{children:`Repository`}),(0,K.jsx)(`th`,{children:`Branch and commit`}),(0,K.jsx)(`th`,{children:`Analyzed`}),(0,K.jsx)(`th`,{children:`Files`}),(0,K.jsx)(`th`,{children:`Left out`}),(0,K.jsx)(`th`,{children:(0,K.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,K.jsx)(`tbody`,{children:s.map(t=>{let n=t.analysis,i=t.include.length+t.exclude.length;return(0,K.jsxs)(`tr`,{"data-source":t.id,children:[(0,K.jsxs)(`td`,{children:[m===t.id?(0,K.jsx)(`form`,{onSubmit:n=>{n.preventDefault(),h(null),A(()=>L.updateSource(e,t.id,{name:g}),`Renamed ${t.id} to ${g||t.id}.`)},onBlur:e=>!e.currentTarget.contains(e.relatedTarget)&&h(null),children:(0,K.jsx)(`input`,{autoFocus:!0,"aria-label":`New name for ${t.id}`,"data-testid":`repo-name`,value:g,onChange:e=>_(e.target.value)})}):(0,K.jsx)(`strong`,{className:`repo-name`,children:t.name??t.id}),(0,K.jsx)(`div`,{className:`muted small path`,children:t.root}),n?.notices.map(e=>(0,K.jsx)(`div`,{className:`notice-line small`,children:e},e))]}),(0,K.jsx)(`td`,{className:`mono small`,children:n?n.kind===`plain`?`plain folder (latest only)`:`${n.branch??`detached`} · ${eS(n.revision)}${n.pinned?` (kept)`:``}`:`not analyzed yet`}),(0,K.jsx)(`td`,{className:`small`,children:n?W(n.analyzedAt):``}),(0,K.jsx)(`td`,{className:`small`,children:n?n.files:``}),(0,K.jsx)(`td`,{className:`small`,children:i?`${i} rule${i===1?``:`s`}`:`defaults`}),(0,K.jsxs)(`td`,{className:`row-actions`,children:[(0,K.jsx)(`button`,{className:`link`,"data-testid":`repo-analyze`,"aria-label":`Re-analyze ${t.name??t.id}`,disabled:E,onClick:()=>void A(()=>L.analyzeSource(e,t.id),`Analyzing ${t.name??t.id} again (the others stay at their commits)…`,`Starting an analysis of ${t.name??t.id}…`),children:`Re-analyze`}),(0,K.jsx)(`button`,{className:`link`,"data-testid":`repo-choose`,"aria-label":`Choose files in ${t.name??t.id}`,onClick:()=>r(t.id),children:`Choose files…`}),(0,K.jsxs)(`span`,{className:`menu-wrap`,children:[(0,K.jsx)(`button`,{className:`icon`,"aria-label":`More for ${t.name??t.id}`,"aria-expanded":S===t.id,"data-testid":`repo-more`,disabled:E,onClick:e=>{let n=e.currentTarget.getBoundingClientRect();T({top:n.bottom+2,right:window.innerWidth-n.right}),C(S===t.id?null:t.id)},children:`⋯`}),S===t.id&&(0,K.jsxs)(`span`,{className:`menu`,role:`menu`,ref:j,style:{top:w.top,right:w.right},children:[(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rename`,onClick:()=>{C(null),_(t.name??t.id),h(t.id)},children:`Rename`}),(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rules`,onClick:()=>{C(null),y(t.id)},children:`Edit rules`}),(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-remove`,onClick:()=>{C(null),x(t.id)},children:`Remove…`})]})]})]})]},t.id)})})]}),s.length===0&&(0,K.jsx)(`p`,{className:`muted`,children:`No repositories yet: + Add folder adds one.`}),N&&(0,K.jsx)(`div`,{ref:M,children:(0,K.jsx)(nS,{source:N,onCancel:()=>y(null),onSave:t=>{let n=N.id;y(null),A(async()=>{await L.updateSource(e,n,t),await L.analyzeSource(e,n)},`Rules saved; analyzing ${n} again…`)}},N.id)}),b&&(0,K.jsxs)(`div`,{className:`confirm`,role:`alertdialog`,"aria-labelledby":`remove-title`,"data-testid":`repo-remove-confirm`,children:[(0,K.jsx)(`p`,{id:`remove-title`,children:(0,K.jsxs)(`strong`,{children:[`Remove `,s.find(e=>e.id===b)?.name??b,` from this project?`]})}),(0,K.jsx)(`p`,{className:`muted small`,children:`Its files and links leave the current graph. History keeps the analysis: earlier runs still show it, and adding the folder again analyzes it afresh. The folder itself is not touched.`}),(0,K.jsxs)(`div`,{className:`actions`,children:[(0,K.jsx)(`button`,{onClick:()=>x(null),"data-testid":`repo-remove-cancel`,children:`Cancel`}),(0,K.jsx)(`button`,{className:`danger`,"data-testid":`repo-remove-yes`,disabled:E,onClick:()=>{let t=b;x(null),A(()=>L.removeSource(e,t),`Removed ${t}; history keeps its analysis.`,`Removing ${t} (a run closes its facts)…`)},children:`Remove`})]})]})]})}function iS({project:e}){let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(null);return(0,d.useEffect)(()=>{L.projectSettings(e).then(e=>n(String(e.settings.maxFileMB)),e=>i({ok:!1,text:e.message}))},[e]),(0,K.jsxs)(`form`,{className:`analysis-settings`,onSubmit:n=>{n.preventDefault();let r=Number(t);if(!(r>0&&r<=64))return i({ok:!1,text:`The size limit is more than 0 and at most 64 MB.`});L.saveProjectSettings(e,{maxFileMB:r}).then(e=>i({ok:!0,text:`Saved: files over ${e.settings.maxFileMB} MB are left out at the next analysis.`}),e=>i({ok:!1,text:e.message}))},children:[(0,K.jsxs)(`label`,{children:[`Size limit per file (MB)`,(0,K.jsx)(`input`,{type:`number`,min:.1,max:64,step:.1,required:!0,"data-testid":`analysis-max-mb`,value:t,onChange:e=>n(e.target.value)})]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`Larger files are listed but not analyzed, unless you choose them in Choose files. Folders of installed libraries, generated output and tools' workspaces (`,(0,K.jsx)(`code`,{children:`node_modules`}),`, `,(0,K.jsx)(`code`,{children:`dist`}),`,`,` `,(0,K.jsx)(`code`,{children:`build`}),`, …) are left out by default; Choose files shows them and can add them.`]}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`analysis-save`,children:`Save`}),r&&(0,K.jsx)(`p`,{className:r.ok?`muted small`:`error`,role:r.ok?`status`:`alert`,children:r.text})]})}function aS({project:e,projectName:t,refresh:n,onClose:r,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,covered:c=!1,initialTab:l=`repositories`}){let[u,f]=(0,d.useState)(l),p=(0,d.useRef)(null),m=(0,d.useRef)(null),h=(0,d.useRef)(null);return(0,d.useEffect)(()=>{let e=document.activeElement;return m.current?.focus(),()=>e?.focus?.()},[]),(0,d.useEffect)(()=>{if(c)return;let e=e=>{if(e.key===`Escape`)e.stopPropagation(),h.current?.()||r();else if(e.key===`Tab`&&p.current){let t=[...p.current.querySelectorAll(`button:not([disabled]), input, textarea, select`)],n=t[0],r=t[t.length-1];p.current.contains(document.activeElement)?e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus()):(e.preventDefault(),n?.focus())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[c,r]),(0,K.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&r(),children:(0,K.jsxs)(`div`,{className:`modal wide`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`project-settings-title`,"data-testid":`project-settings-dialog`,ref:p,children:[(0,K.jsxs)(`div`,{className:`modal-head`,children:[(0,K.jsxs)(`h2`,{id:`project-settings-title`,children:[t,`: settings`]}),(0,K.jsx)(`button`,{className:`icon`,"aria-label":`Close`,onClick:r,ref:m,children:`×`})]}),(0,K.jsx)(`div`,{className:`segmented`,role:`tablist`,"aria-label":`Project settings`,children:[`repositories`,`analysis`,`license`].map(e=>(0,K.jsx)(`button`,{role:`tab`,"aria-selected":u===e,"data-testid":`project-tab-${e}`,onClick:()=>f(e),children:e===`repositories`?`Repositories`:e===`analysis`?`Analysis`:`License`},e))}),u===`repositories`?(0,K.jsx)(rS,{project:e,refresh:n,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,escape:h}):u===`analysis`?(0,K.jsx)(iS,{project:e}):(0,K.jsx)(he,{onChanged:s})]})})}var oS={library:`installed library code`,generated:`generated or built output`,tool:`a tool's or coding agent's workspace (settings, history, worktrees)`};function sS(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var cS=(e,t)=>`${e}\0${t}`,lS=(e,t)=>JSON.stringify([e.include,e.exclude,e.optIn??[]])===JSON.stringify([t?.include??[],t?.exclude??[],t?.optIn??[]]);function uS({project:e,files:t,run:n,onAnalyze:r,onClose:i,only:a,at:o}){let[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)(new Map),[f,p]=(0,d.useState)(new Set),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(new Map),[S,C]=(0,d.useState)(new Map),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)(``),O=(0,d.useRef)(new Set),k=s.length>1,A=(0,d.useCallback)(e=>n?.sources.find(t=>t.sourceId===e),[n]),j=(0,d.useCallback)(async(t,n)=>{let{entries:r}=await L.browse(e,t,n);O.current.add(cS(t,n)),u(e=>new Map(e).set(cS(t,n),r))},[e]),M=(0,d.useCallback)(async()=>{await Promise.all([...O.current].map(e=>{let[t,n]=e.split(`\0`);return j(t,n).catch(()=>O.current.delete(e))}))},[j]);(0,d.useEffect)(()=>{let t=!1;return(async()=>{try{let[{sources:n},{settings:r}]=await Promise.all([L.sources(e),L.projectSettings(e)]);if(t)return;let i=n.map(e=>({...e,optIn:e.optIn??[]})).filter(e=>a===void 0||e.id===a);c(i),T(r.maxFileMB),D(String(r.maxFileMB)),await Promise.all(i.map(e=>j(e.id,``)))}catch(e){t||h(e.message??String(e))}})(),()=>{t=!0}},[e,j,a]),(0,d.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(g?_(null):i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,i]),(0,d.useEffect)(()=>{if(!o||!a||s.length===0)return;let e=o.split(`/`).filter(Boolean),t=e.slice(0,-1).map((t,n)=>e.slice(0,n+1).join(`/`));p(e=>new Set([...e,...t.map(e=>cS(a,e))])),Promise.all(t.filter(e=>!O.current.has(cS(a,e))).map(e=>j(a,e))).then(()=>requestAnimationFrame(()=>document.querySelector(`.picker-row[data-path="${CSS.escape(o)}"]`)?.scrollIntoView({block:`center`})),e=>h(e.message))},[o,a,s.length,j]);let N=(e,t)=>{let n=cS(e,t);p(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),O.current.has(n)||j(e,t).catch(e=>h(e.message))},P=(0,d.useMemo)(()=>{let e=[],t=(n,r,i)=>{for(let a of l.get(cS(n,r))??[]){if(a.kind===`file`&&!a.language&&!a.path.toLowerCase().endsWith(`.html`))continue;let r=a.kind===`dir`&&f.has(cS(n,a.path));e.push({source:n,entry:a,depth:i,open:r}),r&&t(n,a.path,i+1)}};for(let e of s)t(e.id,``,+!!k);return e},[l,f,s,k]),F=(e,t)=>{if(t.kind!==`dir`)return!1;let n=e=>e.replace(/^\/+/,``).startsWith(`${t.path}/`),r=l.get(cS(e.id,t.path));if(t.excludedBy)return e.optIn.some(n)?!0:!!r?.some(e=>!e.excludedBy);if(r?.some(e=>e.excludedBy&&(e.kind===`dir`||e.language))||e.exclude.some(e=>e.startsWith(`/`)&&n(e)))return!0;let i=A(e.id),a=t=>e.optIn.some(e=>t===e||t.startsWith(`${e}/`));return i?.defaultExcluded?.some(e=>n(e.path)&&!a(e.path))?!0:lS(e,i?.filter)&&!!i?.ruleExcluded?.some(e=>n(e.path)&&!a(e.path))},I=(e,n,r)=>{if(!r)return-t.filter(t=>t.source===e&&(t.path===n.path||t.path.startsWith(`${n.path}/`))).length;if(n.kind===`file`)return 1;let i=A(e);return i?.defaultExcluded?.find(e=>e.path===n.path)?.files??i?.ruleExcluded?.find(e=>e.path===n.path)?.files??null},R=async(t,n,r)=>{y(!0),h(``),x(e=>new Map(e).set(cS(t,n.path),r));try{let{source:i}=await L.select(e,t,[n.path],r);c(e=>e.map(e=>e.id===t?{...i,optIn:i.optIn??[]}:e)),C(e=>{let i=new Map(e),a=cS(t,n.path);return i.has(a)?i.delete(a):i.set(a,I(t,n,r)),i}),await M()}catch(e){h(e.message??String(e))}finally{x(e=>{let r=new Map(e);return r.delete(cS(t,n.path)),r}),y(!1)}},z=(e,t,n)=>{if(!v){if(n&&t.excludedBy&&t.excludedBy!==`rule`){let n=t.path.slice(t.path.lastIndexOf(`/`)+1),r=A(e)?.defaultExcluded?.find(e=>e.path===t.path),i=t.kind===`dir`&&r?.files?` It has ${r.files.toLocaleString(`en-US`)} file${r.files===1?``:`s`}.`:``;if(t.excludedBy===`too-large`)_({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${sS(t.size??0)}, over the ${w??10} MB size limit. Files this large are usually generated or bundled code (minified builds, vendored bundles, source maps), and they slow analysis down. Files over 64 MB are never analyzed.`});else if(t.excludedBy===`minified`)_({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} looks minified: most of it is on very long lines, as in a library build. A build adds thousands of functions that aren't your project's own code. Analyze it if it is your code.`});else{let r=oS[t.excludedBy]??oS.generated;_({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${r}, not your project's own code.${i} Analyzing it makes analysis slower and the graph larger. Its files will be marked as ${t.excludedBy} code and left out of "largest files" and "most called".`})}return}R(e,t,n)}},B=async()=>{let t=Number(E);if(!Number.isFinite(t)||t<=0||t>64){h(`The size limit must be a number of megabytes between 0 and 64.`);return}try{let{settings:n}=await L.saveProjectSettings(e,{maxFileMB:t});T(n.maxFileMB),C(e=>new Map(e).set(`\0limit`,null)),await M()}catch(e){h(e.message??String(e))}},V=S.size>0||s.some(e=>!lS(e,A(e.id)?.filter))||w!==null&&n?.sources[0]?.maxFileBytes!==void 0&&n.sources[0].maxFileBytes!==w*1048576,H=0,U=0,W=!1;for(let[e,t]of S)e!==`\0limit`&&(t===null?W=!0:t>0?H+=t:U-=t);let G=e=>`${e} file${e===1?``:`s`}`,ee=[W?H?`${H}+ files added`:`files added`:H?`${G(H)} added`:``,U?`${G(U)} removed`:``].filter(Boolean).join(`, `);return(0,K.jsxs)(`div`,{className:`picker`,"data-testid":`file-picker`,children:[(0,K.jsxs)(`div`,{className:`picker-head`,children:[(0,K.jsx)(`strong`,{children:`Choose files`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{onClick:i,"data-testid":`picker-done`,children:`Done`})]}),(0,K.jsx)(`p`,{className:`muted small picker-help`,children:`Unchecked files are left out of the graph. Greyed folders are left out by default: libraries and generated output.`}),(0,K.jsxs)(`label`,{className:`picker-limit`,children:[`Skip files over`,(0,K.jsx)(`input`,{type:`number`,min:1,max:64,step:1,value:E,"data-testid":`size-limit`,"aria-label":`Size limit in MB`,onChange:e=>D(e.target.value),onBlur:()=>E!==String(w)&&void B(),onKeyDown:e=>e.key===`Enter`&&void B()}),`MB`]}),m&&(0,K.jsx)(`p`,{className:`error small`,role:`alert`,children:m}),V&&(0,K.jsxs)(`div`,{className:`picker-pending`,"data-testid":`picker-pending`,children:[(0,K.jsxs)(`span`,{children:[ee?(0,K.jsx)(`strong`,{children:ee[0].toUpperCase()+ee.slice(1)}):`Changes`,` at the next analysis`]}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`picker-apply`,disabled:v,onClick:()=>{C(new Map),r()},children:`Apply & re-analyze`})]}),(0,K.jsxs)(`div`,{className:`picker-list`,role:`tree`,"aria-label":`Choose files`,children:[s.map(e=>k?(0,K.jsx)(`div`,{className:`picker-row source`,title:e.root,children:(0,K.jsx)(`strong`,{children:e.id})},`s:${e.id}`):null),P.map(({source:e,entry:t,depth:n,open:r})=>{let i=s.find(t=>t.id===e),a=b.get(cS(e,t.path))??!t.excludedBy,c=F(i,t),l=t.path.slice(t.path.lastIndexOf(`/`)+1),u=t.notAnalyzable?t.notAnalyzable===`declaration-file`?`type declarations`:t.notAnalyzable===`symlink`?`link`:`${sS(t.size??0)} · over 64 MB`:t.excludedBy===`library`?`library`:t.excludedBy===`generated`||t.excludedBy===`tool`?t.excludedBy:t.excludedBy===`too-large`?`${sS(t.size??0)} · too large`:t.excludedBy===`minified`?`minified`:t.excludedBy===`rule`?`excluded`:null,d=t.optedIn?t.origin??null:null;return(0,K.jsxs)(`div`,{className:`picker-row ${t.kind} ${a?``:`excluded`}${t.path===o?` target`:``}`,style:{paddingLeft:8+n*14},role:`treeitem`,"aria-expanded":t.kind===`dir`?r:void 0,"aria-level":n+1,"data-path":t.path,children:[t.kind===`dir`?(0,K.jsx)(`button`,{className:`caret`,"aria-label":`${r?`Close`:`Open`} ${l}`,onClick:()=>N(e,t.path),children:r?`▾`:`▸`}):(0,K.jsx)(`span`,{className:`caret`}),t.kind===`dir`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:a,"data-testid":`pick`,"aria-label":`Analyze ${l}`,ref:e=>{e&&(e.indeterminate=c)},"aria-checked":c?`mixed`:a,onChange:n=>z(e,t,n.target.checked)}),(0,K.jsx)(`button`,{className:`name button-link`,"data-command":`open-folder`,onClick:()=>N(e,t.path),children:l})]}):(0,K.jsxs)(`label`,{children:[t.notAnalyzable?(0,K.jsx)(`span`,{className:`caret`}):(0,K.jsx)(`input`,{type:`checkbox`,checked:a,"data-testid":`pick`,ref:e=>{e&&(e.indeterminate=c)},"aria-checked":c?`mixed`:a,onChange:n=>z(e,t,n.target.checked)}),(0,K.jsx)(`span`,{className:`name`,children:l})]}),u&&(0,K.jsx)(`small`,{className:`reason`,children:u}),d&&(0,K.jsx)(`small`,{className:`origin ${d}`,children:d})]},cS(e,t.path))}),s.length>0&&P.length===0&&!m&&(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`})]}),g&&(0,K.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&_(null),children:(0,K.jsxs)(`div`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pick-warning-title`,"data-testid":`pick-warning`,children:[(0,K.jsx)(`h2`,{id:`pick-warning-title`,children:g.title}),(0,K.jsx)(`p`,{children:g.text}),(0,K.jsxs)(`div`,{className:`buttons`,children:[(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{autoFocus:!0,onClick:()=>_(null),children:`Cancel`}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`pick-warning-confirm`,onClick:()=>{let e=g;_(null),R(e.source,e.entry,!0)},children:`Analyze anyway`})]})]})})]})}function dS({projects:e,loading:t=!1,onOpen:n,onCreated:r,onAddFolder:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(``),[f,p]=(0,d.useState)(!1),m=()=>{o(!1),c(``),u(``)},h=async()=>{if(!f){p(!0),u(``);try{let{project:e}=await L.createProject(s.trim());m(),r(e.id)}catch(e){u(e.message??String(e))}finally{p(!1)}}};return(0,K.jsxs)(`section`,{className:`home`,"data-testid":`home`,"aria-labelledby":`home-title`,children:[(0,K.jsxs)(`div`,{className:`home-head`,children:[(0,K.jsx)(`h1`,{id:`home-title`,children:`Projects`}),(0,K.jsxs)(`div`,{className:`home-actions`,children:[(0,K.jsx)(`button`,{"data-testid":`new-project`,onClick:()=>o(!0),children:`+ New project`}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`home-add-folder`,onClick:i,children:`Add folder`})]})]}),a&&(0,K.jsxs)(`form`,{className:`new-project`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,K.jsxs)(`label`,{children:[`Name`,(0,K.jsx)(`input`,{autoFocus:!0,"data-testid":`new-project-name`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Escape`&&m()})]}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!s.trim()||f,"data-testid":`new-project-create`,children:`Create`}),(0,K.jsx)(`button`,{type:`button`,onClick:m,children:`Cancel`}),l&&(0,K.jsx)(`p`,{className:`error`,role:`alert`,children:l})]}),t?(0,K.jsx)(`p`,{className:`muted`,children:`Loading…`}):e.length===0?(0,K.jsx)(`p`,{className:`muted`,children:`No projects yet. Add a folder to analyze its code.`}):(0,K.jsx)(`ul`,{className:`project-cards`,children:e.map(e=>{let t=e.findings,r=t?t.broken+t.notAnalyzed+t.openCalls:0;return(0,K.jsx)(`li`,{"data-project":e.id,children:(0,K.jsxs)(`button`,{className:`project-card`,"data-testid":`open-project`,onClick:()=>n(e.id),children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.sources,` repositor`,e.sources===1?`y`:`ies`]}),e.error?(0,K.jsxs)(`span`,{className:`error small`,"data-testid":`project-error`,children:[`Can't be read: `,e.error]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`small`,children:e.latest?e.latest.status===`running`?`Analyzing…`:e.latest.status===`failed`?e.latest.errorCode===`cancelled`?`Last analysis cancelled`:`Last analysis failed`:`Analyzed${e.latest.finishedAt?` ${W(e.latest.finishedAt)}`:``}`:`Not analyzed yet`}),!t&&e.findingsPending&&(0,K.jsx)(`span`,{className:`muted small`,"data-testid":`findings-pending`,children:`Counting findings…`}),e.files&&e.files.analyzed<e.files.listed&&(0,K.jsx)(`span`,{className:`small`,"data-testid":`files-not-analyzed`,children:e.files.analyzed===0?`None of ${e.files.listed.toLocaleString(`en-US`)} files analyzed`:`${(e.files.listed-e.files.analyzed).toLocaleString(`en-US`)} of ${e.files.listed.toLocaleString(`en-US`)} files not analyzed`}),e.files?.listed===0&&(0,K.jsx)(`span`,{className:`small`,"data-testid":`files-not-analyzed`,children:`No files veoflow analyzes`}),t&&!(e.files&&e.files.analyzed===0)&&(0,K.jsx)(`span`,{className:`muted small`,children:r===0?`No findings`:[t.broken?`${t.broken} broken import${t.broken===1?``:`s`}`:``,t.notAnalyzed?`${t.notAnalyzed} import${t.notAnalyzed===1?``:`s`} not analyzed`:``,t.openCalls?`${t.openCalls} open calls`:``].filter(Boolean).join(` · `)})]})]})},e.id)})})]})}function fS({title:e,entries:t,x:n,y:r,onClose:i}){let a=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=document.activeElement;a.current?.querySelector(`button`)?.focus();let t=e=>{e.type===`mousedown`&&a.current?.contains(e.target)||i()},n=e=>{if(e.key===`Escape`){e.stopPropagation(),i();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;e.preventDefault();let t=[...a.current?.querySelectorAll(`button`)??[]],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()},r=e=>{a.current?.contains(e.relatedTarget)||i()},o=a.current;return document.addEventListener(`mousedown`,t),window.addEventListener(`resize`,t),document.addEventListener(`scroll`,t,!0),window.addEventListener(`keydown`,n,!0),o?.addEventListener(`focusout`,r),()=>{document.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,t),document.removeEventListener(`scroll`,t,!0),window.removeEventListener(`keydown`,n,!0),o?.removeEventListener(`focusout`,r),e&&e!==document.body&&document.contains(e)&&e.focus()}},[i]);let o=Math.max(4,Math.min(n,window.innerWidth-260)),s=Math.max(4,Math.min(r,window.innerHeight-40-t.length*30));return(0,K.jsxs)(`div`,{ref:a,className:`context-menu`,role:`menu`,"aria-label":e,"data-testid":`context-menu`,style:{left:o,top:s},children:[(0,K.jsx)(`div`,{className:`context-title`,"aria-hidden":`true`,children:e}),t.map(e=>(0,K.jsx)(`button`,{role:`menuitem`,tabIndex:-1,"data-command-name":e.command,onClick:()=>{i(),e.run()},children:e.label},e.label))]})}function pS(e,t){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);if(i>=0)return i;let a=0,o=0;for(let e of r)if(e===n[a]?a++:a>0&&o++,a===n.length)return 100+o;return null}function mS(e,t,n){return n===0?[]:t.map((t,n)=>({item:t,i:n,score:pS(e,t.label)})).filter(e=>e.score!==null).sort((e,t)=>e.score-t.score||e.i-t.i).slice(0,n).map(e=>e.item)}function hS(e,t){let{view:n,command:r}=t,i=e.trim(),a=[];if(n.project){let e=mS(i,t.files.map(e=>({...e,label:e.path})),i?5:0);for(let i of e)a.push({key:`file:${i.id}`,group:`Files`,label:i.path,run:()=>n.tab===`imports`?r(`openImportsFile`,{file:i.id}):r(`openFile`,{file:i.id})}),e.length<=2&&(n.tab===`imports`&&n.group!==null&&!n.fileLevel&&a.push({key:`only:${i.id}`,group:`Files`,label:`Show only links of ${i.path}`,run:()=>r(`showOnlyLinks`,{id:i.id})}),a.push({key:`leave:${i.id}`,group:`Files`,label:`Leave ${i.path} out of analysis…`,run:()=>t.action(`chooseFiles`,{source:i.id.slice(0,i.id.indexOf(`:`)),path:i.path})}));for(let e of mS(i,t.groups.map(e=>({...e,label:e.name})),i?4:0))a.push({key:`group:${e.id}`,group:`Groups`,label:e.name,detail:`open the group`,run:()=>r(`openGroup`,{group:e.id})}),a.push({key:`only:${e.id}`,group:`Groups`,label:`Show only links of ${e.name}`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`showOnlyLinks`,{id:e.id})}}),a.push({key:`pick:${e.id}`,group:`Groups`,label:`Details of ${e.name}`,detail:`on the project map`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`pickNode`,{id:e.id})}})}let o=[],s=(e,t,n,r)=>o.push({label:e,run:t,...n?{detail:n}:{},...r?{key:r}:{}});if(n.project){s(n.history?`Close History`:`History: runs by commit`,()=>r(`toggleHistory`)),n.compare&&s(`Stop comparing`,()=>r(`compareRuns`,{}));let e=/^(?:compare\s+)?(?:run\s*)?(\d+)\s*(?:\.\.|with|vs|and|,|\s)\s*(?:run\s*)?(\d+)$/i.exec(i);if(e){let[t,n]=[Number(e[1]),Number(e[2])];s(`Compare run ${Math.min(t,n)} with run ${Math.max(t,n)}`,()=>r(`compareRuns`,{a:t,b:n}))}n.run!==null&&s(`Back to latest`,()=>r(`openRun`,{}));let a=/^(?:view\s+)?run\s*(\d+)$/i.exec(i);a&&s(`View run ${a[1]}`,()=>r(`openRun`,{run:Number(a[1])})),s(`File tab`,()=>r(`showTab`,{tab:`file`}),`functions and calls inside a file`),s(`Imports tab`,()=>r(`showTab`,{tab:`imports`}),`how files depend on each other`),s(`Show the code`,()=>r(`showPanel`,{panel:`evidence`})),s(`Show Findings`,()=>r(`showPanel`,{panel:`questions`})),s(n.showPending?`Hide pending imports`:`Show pending imports`,()=>r(`togglePending`)),s(n.showUnresolved?`Hide unresolved call sites`:`Show unresolved call sites`,()=>r(`toggleUnresolved`)),n.selection&&s(`Clear the selection`,()=>r(`clearSelection`)),n.only&&s(`Show everything again`,()=>r(`showOnlyLinks`,{}),`not only one item's links`);for(let e of t.sources)s(`Re-analyze ${e.name??e.id}`,()=>t.action(`analyzeSource`,{source:e.id}),`this repository only`,`analyze:${e.id}`);if(t.sources.length>1){n.source&&s(`Scope: all repositories`,()=>r(`scopeSource`,{}));for(let e of t.sources)e.id!==n.source&&s(`Scope: ${e.name??e.id}`,()=>r(`scopeSource`,{source:e.id}),`one repository only`,`scope:${e.id}`)}n.group&&i.includes(`/`)&&s(`Open or close folder ${i}`,()=>r(`toggleFolder`,{path:i.replace(/^\.?\//,``).replace(/\/$/,``)})),s(`Re-analyze the project`,()=>t.action(`analyze`)),t.canDraft&&s(`Analyze uncommitted edits`,()=>t.action(`analyzeDraft`),`a draft beside the graph`);for(let e of t.stages??[])s(`Debug run: stop after ${e}`,()=>t.action(`analyzeDebug`,{until:e}),`never committed; compare it with the latest`,`debug:${e}`);s(`Repositories…`,()=>t.action(`openProjectSettings`),`re-analyze, choose files, rename, remove`),s(`License…`,()=>t.action(`openProjectSettings`,{tab:`license`}),`what the license includes; add or replace a key`)}n.project&&s(`All projects (home)`,()=>r(`goHome`),`every project and its last run`),s(`Add a folder…`,()=>t.action(`addFolder`)),s(`Settings…`,()=>t.action(`openSettings`),`the model for questions`);for(let e of t.projects)e.id!==n.project&&s(`Switch to project ${e.name}`,()=>r(`selectProject`,{project:e.id}),void 0,`project:${e.id}`);let c=o.filter(e=>/^(Compare run|View run|Open or close folder)/.test(e.label)),l=mS(i,o.filter(e=>!c.includes(e)),i?6:0);for(let e of[...c,...l])a.push({key:`cmd:${e.key??e.label}`,group:`Commands`,label:e.label,run:e.run,...e.detail?{detail:e.detail}:{}});return a}var gS=20;function _S({project:e,file:t,run:n,onOpen:r}){let{calls:i,error:a}=Px(e,n,t);if(a)return(0,K.jsx)(`p`,{className:`small muted`,children:`Calls to and from other files couldn't be loaded.`});if(!i||i.out.total===0&&i.in.total===0)return null;let o=(e,t)=>e.total===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`h4`,{className:`muted small`,children:[t===`out`?`Calls into other files`:`Called from other files`,` (`,e.total,`)`]}),(0,K.jsx)(`ul`,{className:`cross-calls`,"data-testid":`file-cross-calls-${t}`,children:e.calls.slice(0,gS).map(e=>{let n=t===`out`?e.from:e.to,i=t===`out`?e.to:e.from;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link-row`,"data-command":`open-cross-file`,title:`Open ${i.name} in ${i.path}`,onClick:()=>r({id:i.id,file:i.file}),children:[(0,K.jsx)(`span`,{className:`name`,children:t===`out`?`${n.name} → ${i.name}`:`${i.name} → ${n.name}`}),(0,K.jsxs)(`small`,{children:[i.path,` · line `,e.evidence.span.start.line]})]})},e.id)})}),e.total>gS&&(0,K.jsxs)(`p`,{className:`small muted`,children:[(e.total-gS).toLocaleString(`en-US`),` more: select a function to see its own.`]})]});return(0,K.jsxs)(`div`,{className:`file-cross-calls`,"data-testid":`file-cross-calls`,children:[o(i.out,`out`),o(i.in,`in`)]})}var vS=e=>e.reason===`imported-symbol`||e.reason===`template-reference`;function yS(e){let t=e.group;if(!t)return e.path;let n=t.root&&e.path.startsWith(`${t.root}/`)?e.path.slice(t.root.length+1):e.path;return`${t.name} › ${n}`}var bS={broken:`its import is broken`,pending:`its import waits for another source`,"not-analyzed":`its import leads to a file not analyzed`};function xS({project:e,graph:t,fn:n,onOpen:r,onShowImports:i}){let[a,o]=(0,d.useState)(null),s=t.file.id,c=t.unresolved.some(vS);(0,d.useEffect)(()=>{if(!c)return;let t=!1;return L.siteLinks(e,s).then(e=>!t&&o({file:s,byId:new Map(e.links.map(e=>[e.site,e]))}),()=>!t&&o({file:s,byId:`error`})),()=>{t=!0}},[e,s,t.committedRun,c]);let l=t.unresolved.filter(e=>e.enclosingFn===n&&vS(e)&&!e.component).sort((e,t)=>e.evidence.span.start.offset-t.evidence.span.start.offset);if(l.length===0)return null;let u=a?.file===s?a.byId:null,f=u===`error`?null:u;return(0,K.jsxs)(`div`,{className:`imported-calls`,"data-testid":`imported-calls`,children:[(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Calls into other files (`,l.length,`)`]}),u===`error`&&(0,K.jsx)(`p`,{className:`small muted`,children:`Where these calls lead couldn't be loaded.`}),l.map(e=>{let t=f?.get(e.id),n=e.importSpecifier?`imported from ${e.importSpecifier}`:`defined in another file`;return(0,K.jsxs)(`div`,{className:`imported-call`,"data-testid":`imported-call`,"data-site":e.id,children:[(0,K.jsxs)(`span`,{className:`mono small`,children:[e.expression,` · line `,e.evidence.span.start.line]}),u===`error`?(0,K.jsx)(`span`,{className:`small muted`,children:n}):f===null?(0,K.jsxs)(`span`,{className:`small muted`,children:[n,`…`]}):t?.status===`linked`&&t.target?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`small`,children:[`calls `,(0,K.jsx)(`strong`,{children:t.target.name}),` in`,` `,(0,K.jsx)(`span`,{className:`mono`,children:yS(t.target)}),`, found by`,` `,t.via===`import`?`import analysis`:`component linking`]}),(0,K.jsxs)(`span`,{className:`small links`,children:[(0,K.jsx)(`button`,{className:`button-link`,"data-command":`open-imported`,onClick:()=>r({id:t.target.id,file:t.target.file}),children:`Open that file`}),(0,K.jsx)(`button`,{className:`button-link`,"data-command":`show-in-imports`,onClick:i,children:`Show in Imports`})]})]}):t?.status===`external`?(0,K.jsxs)(`span`,{className:`small`,children:[`calls into the external package `,(0,K.jsx)(`strong`,{children:t.package?.name})]}):t?(0,K.jsxs)(`span`,{className:`small`,children:[n,`, not linked`,t.importOutcome?`: ${bS[t.importOutcome]}`:t.candidates?.length?t.exhaustive===!1?`: ${t.candidates.length} known function${t.candidates.length===1?``:`s`} could run (may not be all)`:`: it could be any of ${t.candidates.length} functions`:t.reason?`: ${t.reason}`:``]}):(0,K.jsxs)(`span`,{className:`small muted`,children:[n,`, not linked yet`]})]},e.id)})]})}var SS=(e,t)=>{let n=V(e).name;return n.length>t?`${n.slice(0,t-1)}…`:n};function CS(e,t,n,r){let i=e=>e.slice(e.indexOf(`:`)+1),a=e=>e.split(`/`).slice(-2).join(`/`),o=r.calls?t.out.calls:[],s=r.calls?t.in.calls:[],c=new Map;for(let e of o)c.set(e.from.id,e.from.name);for(let e of s)c.set(e.to.id,e.to.name);let l=[...c].sort((e,t)=>e[1]<t[1]?-1:+(e[1]>t[1])).map(([e])=>e),u=(e,t)=>({id:`${e}|${t.id}`,file:t.file,label:`${a(t.path)} ›\n${SS(t.name,28)}`}),d=new Map(s.map(e=>[e.from.id,u(`caller`,e.from)])),f=new Map(o.map(e=>[e.to.id,u(`callee`,e.to)])),p=new Map,m=new Map;if(r.imports&&n){for(let t of n.imports)t.outcome===`file`&&t.file&&t.file.id!==e&&!m.has(t.file.id)&&m.set(t.file.id,{id:`imported|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimported`,edge:t.id});for(let t of n.importedBy.files)t.file.id!==e&&!p.has(t.file.id)&&p.set(t.file.id,{id:`importer|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimports this file`,edge:t.id})}let h=e=>[...e.values()].sort((e,t)=>e.label<t.label?-1:+(e.label>t.label)),g=[...h(d),...h(p)],_=[...h(f),...h(m)],v=Math.max(l.length,1),y=e=>-((e-1)*58)/2,b=[{data:{id:`box`,kind:`box`,label:i(e),w:210,h:v*58+50},position:{x:0,y:0},classes:`box`},...l.map((e,t)=>({data:{id:e,kind:`function`,label:`ƒ ${SS(c.get(e),22)}`},position:{x:0,y:y(l.length)+t*58+12},classes:`function`})),...g.map((e,t)=>({data:{id:e.id,kind:`port`,side:`left`,file:e.file,label:e.label},position:{x:-330,y:y(g.length)+t*58},classes:e.id.startsWith(`importer|`)?`port file`:`port`})),..._.map((e,t)=>({data:{id:e.id,kind:`port`,side:`right`,file:e.file,label:e.label},position:{x:330,y:y(_.length)+t*58},classes:e.id.startsWith(`imported|`)?`port file`:`port`}))],x=new Map,S=(e,t,n)=>{let r=`${e}->${t}`,i=x.get(r);i?i.calls.push(n):x.set(r,{id:n,source:e,target:t,calls:[n]})};for(let e of o)S(e.from.id,`callee|${e.to.id}`,e.id);for(let e of s)S(`caller|${e.from.id}`,e.to.id,e.id);for(let e of x.values())b.push({data:{id:e.id,kind:`call`,source:e.source,target:e.target,calls:e.calls,label:e.calls.length>1?`×${e.calls.length}`:``},classes:`call`});for(let e of m.values())b.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:`box`,target:e.id,label:``},classes:`import`});for(let e of p.values())b.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:e.id,target:`box`,label:``},classes:`import`});return b}function wS({file:e,calls:t,imports:n,show:r,pick:i,onPick:a,onOpenFile:o,onClear:s,marks:c=null,onContext:l}){let u=(0,d.useRef)(null),f=(0,d.useRef)(null),p=(0,d.useRef)(c);p.current=c;let m=(0,d.useRef)(l);m.current=l,(0,d.useEffect)(()=>{f.current&&Se(f.current,c)},[c]);let h=(0,d.useRef)({onPick:a,onOpenFile:o,onClear:s});h.current={onPick:a,onOpenFile:o,onClear:s};let g=(0,d.useMemo)(()=>CS(e,t,n,r),[e,t,n,r.calls,r.imports]);(0,d.useEffect)(()=>{if(!u.current)return;let e=m_({container:u.current,elements:g,layout:{name:`preset`},autounselectify:!0,minZoom:.15,maxZoom:2.5,style:[{selector:`node`,style:{shape:`round-rectangle`,width:170,height:36,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`194px`,"text-valign":`center`,"text-halign":`center`,"font-size":12,color:`#1d2330`,"background-color":`#fff`,"border-width":1,"border-color":`#c9d1de`}},{selector:`node.box`,style:{"background-color":`#f7faff`,"border-color":`#c6d6f3`,"border-width":2,"text-valign":`top`,"text-margin-y":18,color:`#2a56ad`,"font-weight":`bold`,width:`data(w)`,height:`data(h)`,events:`no`,"z-index":0}},{selector:`node.port`,style:{width:210,height:42,"border-style":`dashed`,"border-color":`#6b87b8`}},{selector:`node.port.file`,style:{"border-color":`#b7c0cf`,color:`#4a5262`}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"line-color":`#6b87b8`,"line-style":`dashed`,"target-arrow-shape":`triangle`,"target-arrow-color":`#6b87b8`,"arrow-scale":.8,label:`data(label)`,"font-size":10,color:`#5d6675`,"text-background-color":`#fff`,"text-background-opacity":1}},{selector:`edge.import`,style:{"line-color":`#b7c0cf`,"target-arrow-color":`#b7c0cf`}},...xe,{selector:`.picked`,style:{"line-color":`#3b6fd4`,"target-arrow-color":`#3b6fd4`,width:3}}]});return e.on(`tap`,`node`,e=>{e.target.data(`kind`)===`port`&&h.current.onOpenFile(e.target.data(`file`))}),e.on(`tap`,`edge`,e=>h.current.onPick(e.target.data(`edge`)??e.target.id())),e.on(`tap`,t=>{t.target===e&&h.current.onClear()}),e.fit(void 0,30),e.zoom()>1.2&&(e.zoom(1.2),e.center()),f.current=e,Se(e,p.current),e.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`function`?`function`:t.kind===`port`&&t.file?`file`:t.kind===`call`||t.kind===`import`?`edge`:null;if(!n||!u.current)return;let r=u.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};m.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),()=>{f.current=null,e.destroy()}},[g]),(0,d.useEffect)(()=>{let e=f.current;e&&(e.elements().removeClass(`picked`),i&&e.edges().filter(e=>(e.data(`calls`)??[]).includes(i)||e.data(`edge`)===i).addClass(`picked`))},[i,g]);let _=e=>g.filter(t=>t.data.kind===`port`&&t.data.side===e).map(e=>e.data.id).join(` `),v=[t.in,t.out].filter(e=>e.truncated),y=(r.calls?t.out.calls.length+t.in.calls.length:0)===0,b=[...new Map([...t.in.calls.map(e=>e.from),...t.out.calls.map(e=>e.to)].map(e=>[e.file,e])).values()];return(0,K.jsxs)(`div`,{className:`graph-wrap`,children:[y&&r.calls&&(0,K.jsx)(`p`,{className:`hint overlay`,"data-testid":`no-cross-file-calls`,children:`No calls cross into or out of this file.`}),(0,K.jsx)(`div`,{ref:u,className:`graph map`,"data-testid":`file-canvas`,"data-calls":g.filter(e=>e.data.kind===`call`).length,"data-imports":g.filter(e=>e.data.kind===`import`).length,"data-ports-left":_(`left`),"data-ports-right":_(`right`)}),v.length>0&&(0,K.jsxs)(`p`,{className:`hint small overlay bottom`,"data-testid":`calls-truncated`,children:[v.map(e=>`Showing ${e.calls.length} of ${e.total} calls ${e.direction===`in`?`into`:`out of`} this file`).join(`; `),`.`]}),(0,K.jsxs)(`ul`,{className:`visually-hidden`,"aria-label":`Cross-file calls`,children:[t.in.calls.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`in`,tabIndex:-1,onClick:()=>a(e.id),children:[e.from.path,` › `,e.from.name,` calls `,e.to.name]})},e.id)),t.out.calls.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`out`,tabIndex:-1,onClick:()=>a(e.id),children:[e.from.name,` calls `,e.to.path,` › `,e.to.name]})},e.id)),b.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`open-imports-file`,"data-id":e.file,tabIndex:-1,onClick:()=>o(e.file),children:[`Open `,e.path]})},e.file))]}),(0,K.jsx)(`button`,{className:`fit`,onClick:()=>f.current?.fit(void 0,30),children:`Fit`})]})}var TS={repository:`repository`,"workspace-package":`workspace package`,cluster:`cluster`},ES=(e,t)=>`${e.toLocaleString()} ${t}${e===1?``:`s`}`,DS=.55;function OS(e){return e.resize(),e.elements().empty()?1:(e.fit(void 0,40),e.zoom()>1.2&&(e.zoom(1.2),e.center()),e.zoom())}var kS=(e,t=30)=>e.length>t?`${e.slice(0,t-1)}…`:e;function AS(e,t){if(!e||!t)return 0;let n=Math.abs(t.x-e.x)/290;return n>1.2||t.x<e.x?-(84*.9+12*Math.min(4,n)):0}var jS=(e,t)=>1+6*Math.sqrt(e/Math.max(1,t));function MS({map:e,layoutKey:t,pick:n,showPackages:r,onPick:i,onOpen:a,onClear:o,marks:s=null,only:c=null,onContext:l}){let u=(0,d.useRef)(null),f=(0,d.useRef)(null),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(!1),_=(0,d.useRef)(!1),v=(0,d.useRef)(c);v.current=c;let y=(0,d.useRef)(l);y.current=l,(0,d.useEffect)(()=>{f.current&&ve(f.current,c)},[c]);let b=(0,d.useRef)(s);b.current=s,(0,d.useEffect)(()=>{f.current&&Se(f.current,s)},[s]);let x=(0,d.useRef)({x:0,y:0}),S=(0,d.useRef)({onPick:i,onOpen:a,onClear:o});return S.current={onPick:i,onOpen:a,onClear:o},(0,d.useEffect)(()=>{if(!u.current)return;let n=e=>e.imports+e.calls,r=Math.max(1,...e.dependsOn.map(n)),i=_x(t,e.groups,e.dependsOn.map(e=>({from:e.from,to:e.to,weight:n(e)})));x.current=i.packages;let a=[...e.groups.map(e=>{let t=e.findings.broken;return{data:{id:e.id,kind:`group`,label:[kS(e.name),kS(`${e.source} · ${TS[e.kind]??e.kind}`),t>0?`${ES(e.files,`file`)} · ${ES(t,`broken import`)}`:`${ES(e.files,`file`)} · ${ES(e.functions,`function`)}`].join(`
|
|
336
|
+
`));return(0,K.jsxs)(`form`,{className:`rules-editor`,"data-testid":`rules-editor`,onSubmit:e=>{e.preventDefault(),t({include:tS(r),exclude:tS(a)})},children:[(0,K.jsxs)(`p`,{className:`muted small`,children:[`Glob patterns, one per line, relative to the repository (`,(0,K.jsx)(`code`,{children:`src/legacy/`}),`,`,` `,(0,K.jsx)(`code`,{children:`**/*.test.ts`}),`). Applied at the next analysis; files left out are closed in the graph and kept in history.`]}),(0,K.jsxs)(`label`,{children:[`Include only`,(0,K.jsx)(`textarea`,{"data-testid":`rules-include`,value:r,onChange:e=>i(e.target.value)})]}),(0,K.jsxs)(`label`,{children:[`Leave out`,(0,K.jsx)(`textarea`,{"data-testid":`rules-exclude`,value:a,onChange:e=>o(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`rules-save`,children:`Save and re-analyze`})]})]})}function rS({project:e,refresh:t,onAdd:n,onChooseFiles:r,onAnalyzeAll:i,onChanged:a,escape:o}){let[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(``),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(null),[w,T]=(0,d.useState)({top:0,right:0}),[E,D]=(0,d.useState)(!1),[O,k]=(0,d.useState)(0);(0,d.useEffect)(()=>{let t=!1;return L.sources(e).then(e=>!t&&c(e.sources.map(e=>({...e,optIn:e.optIn??[]}))),e=>!t&&u(e.message)),()=>{t=!0}},[e,t,O]);let A=async(e,t,n)=>{D(!0),u(``),n&&p(n);try{await e(),p(t),a()}catch(e){p(``),u(e.message??String(e))}finally{D(!1),k(e=>e+1)}},j=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!S)return;j.current?.querySelector(`button`)?.focus();let e=e=>{e.type===`mousedown`&&j.current?.contains(e.target)||C(null)};return document.addEventListener(`mousedown`,e),window.addEventListener(`resize`,e),document.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`resize`,e),document.removeEventListener(`scroll`,e,!0)}},[S]),o.current=()=>{if(S){let e=S;return C(null),document.querySelector(`tr[data-source="${CSS.escape(e)}"] [data-testid="repo-more"]`)?.focus(),!0}return m?(h(null),!0):b?(x(null),!0):v?(y(null),!0):!1};let M=(0,d.useRef)(null);if((0,d.useEffect)(()=>{(v||b)&&(M.current?.scrollIntoView({block:`nearest`}),M.current?.querySelector(`textarea, button`)?.focus())},[v,b]),(0,d.useEffect)(()=>{s&&(v&&!s.some(e=>e.id===v)&&y(null),b&&!s.some(e=>e.id===b)&&x(null))},[s,v,b]),!s)return(0,K.jsx)(`p`,{className:l?`error`:`muted`,children:l||`Loading…`});let N=v?s.find(e=>e.id===v):void 0;return(0,K.jsxs)(`div`,{className:`repositories`,"data-testid":`repositories`,children:[(0,K.jsxs)(`div`,{className:`repo-actions`,children:[(0,K.jsx)(`button`,{"data-testid":`repo-add`,onClick:n,children:`+ Add folder`}),(0,K.jsx)(`button`,{"data-testid":`repo-analyze-all`,disabled:E,onClick:i,children:`Re-analyze all`})]}),l&&(0,K.jsx)(`p`,{className:`error`,role:`alert`,children:l}),f&&(0,K.jsx)(`p`,{className:`muted small`,role:`status`,"data-testid":`repo-status`,children:f}),(0,K.jsxs)(`table`,{className:`repo-table`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{children:`Repository`}),(0,K.jsx)(`th`,{children:`Branch and commit`}),(0,K.jsx)(`th`,{children:`Analyzed`}),(0,K.jsx)(`th`,{children:`Files`}),(0,K.jsx)(`th`,{children:`Left out`}),(0,K.jsx)(`th`,{children:(0,K.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,K.jsx)(`tbody`,{children:s.map(t=>{let n=t.analysis,i=t.include.length+t.exclude.length;return(0,K.jsxs)(`tr`,{"data-source":t.id,children:[(0,K.jsxs)(`td`,{children:[m===t.id?(0,K.jsx)(`form`,{onSubmit:n=>{n.preventDefault(),h(null),A(()=>L.updateSource(e,t.id,{name:g}),`Renamed ${t.id} to ${g||t.id}.`)},onBlur:e=>!e.currentTarget.contains(e.relatedTarget)&&h(null),children:(0,K.jsx)(`input`,{autoFocus:!0,"aria-label":`New name for ${t.id}`,"data-testid":`repo-name`,value:g,onChange:e=>_(e.target.value)})}):(0,K.jsx)(`strong`,{className:`repo-name`,children:t.name??t.id}),(0,K.jsx)(`div`,{className:`muted small path`,children:t.root}),n?.notices.map(e=>(0,K.jsx)(`div`,{className:`notice-line small`,children:e},e))]}),(0,K.jsx)(`td`,{className:`mono small`,children:n?n.kind===`plain`?`plain folder (latest only)`:`${n.branch??`detached`} · ${eS(n.revision)}${n.pinned?` (kept)`:``}`:`not analyzed yet`}),(0,K.jsx)(`td`,{className:`small`,children:n?W(n.analyzedAt):``}),(0,K.jsx)(`td`,{className:`small`,children:n?n.files:``}),(0,K.jsx)(`td`,{className:`small`,children:i?`${i} rule${i===1?``:`s`}`:`defaults`}),(0,K.jsxs)(`td`,{className:`row-actions`,children:[(0,K.jsx)(`button`,{className:`link`,"data-testid":`repo-analyze`,"aria-label":`Re-analyze ${t.name??t.id}`,disabled:E,onClick:()=>void A(()=>L.analyzeSource(e,t.id),`Analyzing ${t.name??t.id} again (the others stay at their commits)…`,`Starting an analysis of ${t.name??t.id}…`),children:`Re-analyze`}),(0,K.jsx)(`button`,{className:`link`,"data-testid":`repo-choose`,"aria-label":`Choose files in ${t.name??t.id}`,onClick:()=>r(t.id),children:`Choose files…`}),(0,K.jsxs)(`span`,{className:`menu-wrap`,children:[(0,K.jsx)(`button`,{className:`icon`,"aria-label":`More for ${t.name??t.id}`,"aria-expanded":S===t.id,"data-testid":`repo-more`,disabled:E,onClick:e=>{let n=e.currentTarget.getBoundingClientRect();T({top:n.bottom+2,right:window.innerWidth-n.right}),C(S===t.id?null:t.id)},children:`⋯`}),S===t.id&&(0,K.jsxs)(`span`,{className:`menu`,role:`menu`,ref:j,style:{top:w.top,right:w.right},children:[(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rename`,onClick:()=>{C(null),_(t.name??t.id),h(t.id)},children:`Rename`}),(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rules`,onClick:()=>{C(null),y(t.id)},children:`Edit rules`}),(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-remove`,onClick:()=>{C(null),x(t.id)},children:`Remove…`})]})]})]})]},t.id)})})]}),s.length===0&&(0,K.jsx)(`p`,{className:`muted`,children:`No repositories yet: + Add folder adds one.`}),N&&(0,K.jsx)(`div`,{ref:M,children:(0,K.jsx)(nS,{source:N,onCancel:()=>y(null),onSave:t=>{let n=N.id;y(null),A(async()=>{await L.updateSource(e,n,t),await L.analyzeSource(e,n)},`Rules saved; analyzing ${n} again…`)}},N.id)}),b&&(0,K.jsxs)(`div`,{className:`confirm`,role:`alertdialog`,"aria-labelledby":`remove-title`,"data-testid":`repo-remove-confirm`,children:[(0,K.jsx)(`p`,{id:`remove-title`,children:(0,K.jsxs)(`strong`,{children:[`Remove `,s.find(e=>e.id===b)?.name??b,` from this project?`]})}),(0,K.jsx)(`p`,{className:`muted small`,children:`Its files and links leave the current graph. History keeps the analysis: earlier runs still show it, and adding the folder again analyzes it afresh. The folder itself is not touched.`}),(0,K.jsxs)(`div`,{className:`actions`,children:[(0,K.jsx)(`button`,{onClick:()=>x(null),"data-testid":`repo-remove-cancel`,children:`Cancel`}),(0,K.jsx)(`button`,{className:`danger`,"data-testid":`repo-remove-yes`,disabled:E,onClick:()=>{let t=b;x(null),A(()=>L.removeSource(e,t),`Removed ${t}; history keeps its analysis.`,`Removing ${t} (a run closes its facts)…`)},children:`Remove`})]})]})]})}function iS({project:e}){let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(null);return(0,d.useEffect)(()=>{L.projectSettings(e).then(e=>n(String(e.settings.maxFileMB)),e=>i({ok:!1,text:e.message}))},[e]),(0,K.jsxs)(`form`,{className:`analysis-settings`,onSubmit:n=>{n.preventDefault();let r=Number(t);if(!(r>0&&r<=64))return i({ok:!1,text:`The size limit is more than 0 and at most 64 MB.`});L.saveProjectSettings(e,{maxFileMB:r}).then(e=>i({ok:!0,text:`Saved: files over ${e.settings.maxFileMB} MB are left out at the next analysis.`}),e=>i({ok:!1,text:e.message}))},children:[(0,K.jsxs)(`label`,{children:[`Size limit per file (MB)`,(0,K.jsx)(`input`,{type:`number`,min:.1,max:64,step:.1,required:!0,"data-testid":`analysis-max-mb`,value:t,onChange:e=>n(e.target.value)})]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`Larger files are listed but not analyzed, unless you choose them in Choose files. Folders of installed libraries, generated output and tools' workspaces (`,(0,K.jsx)(`code`,{children:`node_modules`}),`, `,(0,K.jsx)(`code`,{children:`dist`}),`,`,` `,(0,K.jsx)(`code`,{children:`build`}),`, …) are left out by default; Choose files shows them and can add them.`]}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`analysis-save`,children:`Save`}),r&&(0,K.jsx)(`p`,{className:r.ok?`muted small`:`error`,role:r.ok?`status`:`alert`,children:r.text})]})}function aS({project:e,projectName:t,refresh:n,onClose:r,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,covered:c=!1,initialTab:l=`repositories`}){let[u,f]=(0,d.useState)(l),p=(0,d.useRef)(null),m=(0,d.useRef)(null),h=(0,d.useRef)(null);return(0,d.useEffect)(()=>{let e=document.activeElement;return m.current?.focus(),()=>e?.focus?.()},[]),(0,d.useEffect)(()=>{if(c)return;let e=e=>{if(e.key===`Escape`)e.stopPropagation(),h.current?.()||r();else if(e.key===`Tab`&&p.current){let t=[...p.current.querySelectorAll(`button:not([disabled]), input, textarea, select`)],n=t[0],r=t[t.length-1];p.current.contains(document.activeElement)?e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus()):(e.preventDefault(),n?.focus())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[c,r]),(0,K.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&r(),children:(0,K.jsxs)(`div`,{className:`modal wide`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`project-settings-title`,"data-testid":`project-settings-dialog`,ref:p,children:[(0,K.jsxs)(`div`,{className:`modal-head`,children:[(0,K.jsxs)(`h2`,{id:`project-settings-title`,children:[t,`: settings`]}),(0,K.jsx)(`button`,{className:`icon`,"aria-label":`Close`,onClick:r,ref:m,children:`×`})]}),(0,K.jsx)(`div`,{className:`segmented`,role:`tablist`,"aria-label":`Project settings`,children:[`repositories`,`analysis`,`license`].map(e=>(0,K.jsx)(`button`,{role:`tab`,"aria-selected":u===e,"data-testid":`project-tab-${e}`,onClick:()=>f(e),children:e===`repositories`?`Repositories`:e===`analysis`?`Analysis`:`License`},e))}),u===`repositories`?(0,K.jsx)(rS,{project:e,refresh:n,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,escape:h}):u===`analysis`?(0,K.jsx)(iS,{project:e}):(0,K.jsx)(he,{onChanged:s})]})})}var oS={library:`installed library code`,generated:`generated or built output`,tool:`a tool's or coding agent's workspace (settings, history, worktrees)`};function sS(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var cS=(e,t)=>`${e}\0${t}`,lS=(e,t)=>JSON.stringify([e.include,e.exclude,e.optIn??[]])===JSON.stringify([t?.include??[],t?.exclude??[],t?.optIn??[]]);function uS({project:e,files:t,run:n,onAnalyze:r,onClose:i,only:a,at:o}){let[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)(new Map),[f,p]=(0,d.useState)(new Set),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(new Map),[S,C]=(0,d.useState)(new Map),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)(``),O=(0,d.useRef)(new Set),k=s.length>1,A=(0,d.useCallback)(e=>n?.sources.find(t=>t.sourceId===e),[n]),j=(0,d.useCallback)(async(t,n)=>{let{entries:r}=await L.browse(e,t,n);O.current.add(cS(t,n)),u(e=>new Map(e).set(cS(t,n),r))},[e]),M=(0,d.useCallback)(async()=>{await Promise.all([...O.current].map(e=>{let[t,n]=e.split(`\0`);return j(t,n).catch(()=>O.current.delete(e))}))},[j]);(0,d.useEffect)(()=>{let t=!1;return(async()=>{try{let[{sources:n},{settings:r}]=await Promise.all([L.sources(e),L.projectSettings(e)]);if(t)return;let i=n.map(e=>({...e,optIn:e.optIn??[]})).filter(e=>a===void 0||e.id===a);c(i),T(r.maxFileMB),D(String(r.maxFileMB)),await Promise.all(i.map(e=>j(e.id,``)))}catch(e){t||h(e.message??String(e))}})(),()=>{t=!0}},[e,j,a]),(0,d.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(g?_(null):i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,i]),(0,d.useEffect)(()=>{if(!o||!a||s.length===0)return;let e=o.split(`/`).filter(Boolean),t=e.slice(0,-1).map((t,n)=>e.slice(0,n+1).join(`/`));p(e=>new Set([...e,...t.map(e=>cS(a,e))])),Promise.all(t.filter(e=>!O.current.has(cS(a,e))).map(e=>j(a,e))).then(()=>requestAnimationFrame(()=>document.querySelector(`.picker-row[data-path="${CSS.escape(o)}"]`)?.scrollIntoView({block:`center`})),e=>h(e.message))},[o,a,s.length,j]);let N=(e,t)=>{let n=cS(e,t);p(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),O.current.has(n)||j(e,t).catch(e=>h(e.message))},P=(0,d.useMemo)(()=>{let e=[],t=(n,r,i)=>{for(let a of l.get(cS(n,r))??[]){if(a.kind===`file`&&!a.language&&!a.path.toLowerCase().endsWith(`.html`))continue;let r=a.kind===`dir`&&f.has(cS(n,a.path));e.push({source:n,entry:a,depth:i,open:r}),r&&t(n,a.path,i+1)}};for(let e of s)t(e.id,``,+!!k);return e},[l,f,s,k]),F=(e,t)=>{if(t.kind!==`dir`)return!1;let n=e=>e.replace(/^\/+/,``).startsWith(`${t.path}/`),r=l.get(cS(e.id,t.path));if(t.excludedBy)return e.optIn.some(n)?!0:!!r?.some(e=>!e.excludedBy);if(r?.some(e=>e.excludedBy&&(e.kind===`dir`||e.language))||e.exclude.some(e=>e.startsWith(`/`)&&n(e)))return!0;let i=A(e.id),a=t=>e.optIn.some(e=>t===e||t.startsWith(`${e}/`));return i?.defaultExcluded?.some(e=>n(e.path)&&!a(e.path))?!0:lS(e,i?.filter)&&!!i?.ruleExcluded?.some(e=>n(e.path)&&!a(e.path))},I=(e,n,r)=>{if(!r)return-t.filter(t=>t.source===e&&(t.path===n.path||t.path.startsWith(`${n.path}/`))).length;if(n.kind===`file`)return 1;let i=A(e);return i?.defaultExcluded?.find(e=>e.path===n.path)?.files??i?.ruleExcluded?.find(e=>e.path===n.path)?.files??null},R=async(t,n,r)=>{y(!0),h(``),x(e=>new Map(e).set(cS(t,n.path),r));try{let{source:i}=await L.select(e,t,[n.path],r);c(e=>e.map(e=>e.id===t?{...i,optIn:i.optIn??[]}:e)),C(e=>{let i=new Map(e),a=cS(t,n.path);return i.has(a)?i.delete(a):i.set(a,I(t,n,r)),i}),await M()}catch(e){h(e.message??String(e))}finally{x(e=>{let r=new Map(e);return r.delete(cS(t,n.path)),r}),y(!1)}},z=(e,t,n)=>{if(!v){if(n&&t.excludedBy&&t.excludedBy!==`rule`){let n=t.path.slice(t.path.lastIndexOf(`/`)+1),r=A(e)?.defaultExcluded?.find(e=>e.path===t.path),i=t.kind===`dir`&&r?.files?` It has ${r.files.toLocaleString(`en-US`)} file${r.files===1?``:`s`}.`:``;if(t.excludedBy===`too-large`)_({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${sS(t.size??0)}, over the ${w??10} MB size limit. Files this large are usually generated or bundled code (minified builds, vendored bundles, source maps), and they slow analysis down. Files over 64 MB are never analyzed.`});else if(t.excludedBy===`minified`)_({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} looks minified: most of it is on very long lines, as in a library build. A build adds thousands of functions that aren't your project's own code. Analyze it if it is your code.`});else{let r=oS[t.excludedBy]??oS.generated;_({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${r}, not your project's own code.${i} Analyzing it makes analysis slower and the graph larger. Its files will be marked as ${t.excludedBy} code and left out of "largest files" and "most called".`})}return}R(e,t,n)}},B=async()=>{let t=Number(E);if(!Number.isFinite(t)||t<=0||t>64){h(`The size limit must be a number of megabytes between 0 and 64.`);return}try{let{settings:n}=await L.saveProjectSettings(e,{maxFileMB:t});T(n.maxFileMB),C(e=>new Map(e).set(`\0limit`,null)),await M()}catch(e){h(e.message??String(e))}},V=S.size>0||s.some(e=>!lS(e,A(e.id)?.filter))||w!==null&&n?.sources[0]?.maxFileBytes!==void 0&&n.sources[0].maxFileBytes!==w*1048576,H=0,U=0,W=!1;for(let[e,t]of S)e!==`\0limit`&&(t===null?W=!0:t>0?H+=t:U-=t);let G=e=>`${e} file${e===1?``:`s`}`,ee=[W?H?`${H}+ files added`:`files added`:H?`${G(H)} added`:``,U?`${G(U)} removed`:``].filter(Boolean).join(`, `);return(0,K.jsxs)(`div`,{className:`picker`,"data-testid":`file-picker`,children:[(0,K.jsxs)(`div`,{className:`picker-head`,children:[(0,K.jsx)(`strong`,{children:`Choose files`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{onClick:i,"data-testid":`picker-done`,children:`Done`})]}),(0,K.jsx)(`p`,{className:`muted small picker-help`,children:`Unchecked files are left out of the graph. Greyed folders are left out by default: libraries and generated output.`}),(0,K.jsxs)(`label`,{className:`picker-limit`,children:[`Skip files over`,(0,K.jsx)(`input`,{type:`number`,min:1,max:64,step:1,value:E,"data-testid":`size-limit`,"aria-label":`Size limit in MB`,onChange:e=>D(e.target.value),onBlur:()=>E!==String(w)&&void B(),onKeyDown:e=>e.key===`Enter`&&void B()}),`MB`]}),m&&(0,K.jsx)(`p`,{className:`error small`,role:`alert`,children:m}),V&&(0,K.jsxs)(`div`,{className:`picker-pending`,"data-testid":`picker-pending`,children:[(0,K.jsxs)(`span`,{children:[ee?(0,K.jsx)(`strong`,{children:ee[0].toUpperCase()+ee.slice(1)}):`Changes`,` at the next analysis`]}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`picker-apply`,disabled:v,onClick:()=>{C(new Map),r()},children:`Apply & re-analyze`})]}),(0,K.jsxs)(`div`,{className:`picker-list`,role:`tree`,"aria-label":`Choose files`,children:[s.map(e=>k?(0,K.jsx)(`div`,{className:`picker-row source`,title:e.root,children:(0,K.jsx)(`strong`,{children:e.id})},`s:${e.id}`):null),P.map(({source:e,entry:t,depth:n,open:r})=>{let i=s.find(t=>t.id===e),a=b.get(cS(e,t.path))??!t.excludedBy,c=F(i,t),l=t.path.slice(t.path.lastIndexOf(`/`)+1),u=t.notAnalyzable?t.notAnalyzable===`declaration-file`?`type declarations`:t.notAnalyzable===`symlink`?`link`:`${sS(t.size??0)} · over 64 MB`:t.excludedBy===`library`?`library`:t.excludedBy===`generated`||t.excludedBy===`tool`?t.excludedBy:t.excludedBy===`too-large`?`${sS(t.size??0)} · too large`:t.excludedBy===`minified`?`minified`:t.excludedBy===`rule`?`excluded`:null,d=t.optedIn?t.origin??null:null;return(0,K.jsxs)(`div`,{className:`picker-row ${t.kind} ${a?``:`excluded`}${t.path===o?` target`:``}`,style:{paddingLeft:8+n*14},role:`treeitem`,"aria-expanded":t.kind===`dir`?r:void 0,"aria-level":n+1,"data-path":t.path,children:[t.kind===`dir`?(0,K.jsx)(`button`,{className:`caret`,"aria-label":`${r?`Close`:`Open`} ${l}`,onClick:()=>N(e,t.path),children:r?`▾`:`▸`}):(0,K.jsx)(`span`,{className:`caret`}),t.kind===`dir`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:a,"data-testid":`pick`,"aria-label":`Analyze ${l}`,ref:e=>{e&&(e.indeterminate=c)},"aria-checked":c?`mixed`:a,onChange:n=>z(e,t,n.target.checked)}),(0,K.jsx)(`button`,{className:`name button-link`,"data-command":`open-folder`,onClick:()=>N(e,t.path),children:l})]}):(0,K.jsxs)(`label`,{children:[t.notAnalyzable?(0,K.jsx)(`span`,{className:`caret`}):(0,K.jsx)(`input`,{type:`checkbox`,checked:a,"data-testid":`pick`,ref:e=>{e&&(e.indeterminate=c)},"aria-checked":c?`mixed`:a,onChange:n=>z(e,t,n.target.checked)}),(0,K.jsx)(`span`,{className:`name`,children:l})]}),u&&(0,K.jsx)(`small`,{className:`reason`,children:u}),d&&(0,K.jsx)(`small`,{className:`origin ${d}`,children:d})]},cS(e,t.path))}),s.length>0&&P.length===0&&!m&&(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`})]}),g&&(0,K.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&_(null),children:(0,K.jsxs)(`div`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pick-warning-title`,"data-testid":`pick-warning`,children:[(0,K.jsx)(`h2`,{id:`pick-warning-title`,children:g.title}),(0,K.jsx)(`p`,{children:g.text}),(0,K.jsxs)(`div`,{className:`buttons`,children:[(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{autoFocus:!0,onClick:()=>_(null),children:`Cancel`}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`pick-warning-confirm`,onClick:()=>{let e=g;_(null),R(e.source,e.entry,!0)},children:`Analyze anyway`})]})]})})]})}function dS({projects:e,loading:t=!1,onOpen:n,onCreated:r,onAddFolder:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(``),[f,p]=(0,d.useState)(!1),m=()=>{o(!1),c(``),u(``)},h=async()=>{if(!f){p(!0),u(``);try{let{project:e}=await L.createProject(s.trim());m(),r(e.id)}catch(e){u(e.message??String(e))}finally{p(!1)}}};return(0,K.jsxs)(`section`,{className:`home`,"data-testid":`home`,"aria-labelledby":`home-title`,children:[(0,K.jsxs)(`div`,{className:`home-head`,children:[(0,K.jsx)(`h1`,{id:`home-title`,children:`Projects`}),(0,K.jsxs)(`div`,{className:`home-actions`,children:[(0,K.jsx)(`button`,{"data-testid":`new-project`,onClick:()=>o(!0),children:`+ New project`}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`home-add-folder`,onClick:i,children:`Add folder`})]})]}),a&&(0,K.jsxs)(`form`,{className:`new-project`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,K.jsxs)(`label`,{children:[`Name`,(0,K.jsx)(`input`,{autoFocus:!0,"data-testid":`new-project-name`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Escape`&&m()})]}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!s.trim()||f,"data-testid":`new-project-create`,children:`Create`}),(0,K.jsx)(`button`,{type:`button`,onClick:m,children:`Cancel`}),l&&(0,K.jsx)(`p`,{className:`error`,role:`alert`,children:l})]}),t?(0,K.jsx)(`p`,{className:`muted`,children:`Loading…`}):e.length===0?(0,K.jsx)(`p`,{className:`muted`,children:`No projects yet. Add a folder to analyze its code.`}):(0,K.jsx)(`ul`,{className:`project-cards`,children:e.map(e=>{let t=e.findings,r=t?t.broken+t.notAnalyzed+t.openCalls:0;return(0,K.jsx)(`li`,{"data-project":e.id,children:(0,K.jsxs)(`button`,{className:`project-card`,"data-testid":`open-project`,onClick:()=>n(e.id),children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsx)(`span`,{className:`muted small`,"data-testid":`project-sources`,children:e.repositories===void 0?`${e.sources} source${e.sources===1?``:`s`}`:[e.repositories?`${e.repositories} repositor${e.repositories===1?`y`:`ies`}`:``,e.folders?`${e.folders} folder${e.folders===1?``:`s`}`:``].filter(Boolean).join(` · `)||`no sources`}),e.error?(0,K.jsxs)(`span`,{className:`error small`,"data-testid":`project-error`,children:[`Can't be read: `,e.error]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`small`,children:e.latest?e.latest.status===`running`?`Analyzing…`:e.latest.status===`failed`?e.latest.errorCode===`cancelled`?`Last analysis cancelled`:`Last analysis failed`:`Analyzed${e.latest.finishedAt?` ${W(e.latest.finishedAt)}`:``}`:`Not analyzed yet`}),!t&&e.findingsPending&&(0,K.jsx)(`span`,{className:`muted small`,"data-testid":`findings-pending`,children:`Counting findings…`}),e.files&&e.files.analyzed<e.files.listed&&(0,K.jsx)(`span`,{className:`small`,"data-testid":`files-not-analyzed`,children:e.files.analyzed===0?`None of ${e.files.listed.toLocaleString(`en-US`)} files analyzed`:`${(e.files.listed-e.files.analyzed).toLocaleString(`en-US`)} of ${e.files.listed.toLocaleString(`en-US`)} files not analyzed`}),e.files?.listed===0&&(0,K.jsx)(`span`,{className:`small`,"data-testid":`files-not-analyzed`,children:`No files veoflow analyzes`}),t&&!(e.files&&e.files.analyzed===0)&&(0,K.jsx)(`span`,{className:`muted small`,children:r===0?`No findings`:[t.broken?`${t.broken} broken import${t.broken===1?``:`s`}`:``,t.notAnalyzed?`${t.notAnalyzed} import${t.notAnalyzed===1?``:`s`} not analyzed`:``,t.openCalls?`${t.openCalls} open calls`:``].filter(Boolean).join(` · `)})]})]})},e.id)})})]})}function fS({title:e,entries:t,x:n,y:r,onClose:i}){let a=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=document.activeElement;a.current?.querySelector(`button`)?.focus();let t=e=>{e.type===`mousedown`&&a.current?.contains(e.target)||i()},n=e=>{if(e.key===`Escape`){e.stopPropagation(),i();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;e.preventDefault();let t=[...a.current?.querySelectorAll(`button`)??[]],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()},r=e=>{a.current?.contains(e.relatedTarget)||i()},o=a.current;return document.addEventListener(`mousedown`,t),window.addEventListener(`resize`,t),document.addEventListener(`scroll`,t,!0),window.addEventListener(`keydown`,n,!0),o?.addEventListener(`focusout`,r),()=>{document.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,t),document.removeEventListener(`scroll`,t,!0),window.removeEventListener(`keydown`,n,!0),o?.removeEventListener(`focusout`,r),e&&e!==document.body&&document.contains(e)&&e.focus()}},[i]);let o=Math.max(4,Math.min(n,window.innerWidth-260)),s=Math.max(4,Math.min(r,window.innerHeight-40-t.length*30));return(0,K.jsxs)(`div`,{ref:a,className:`context-menu`,role:`menu`,"aria-label":e,"data-testid":`context-menu`,style:{left:o,top:s},children:[(0,K.jsx)(`div`,{className:`context-title`,"aria-hidden":`true`,children:e}),t.map(e=>(0,K.jsx)(`button`,{role:`menuitem`,tabIndex:-1,"data-command-name":e.command,onClick:()=>{i(),e.run()},children:e.label},e.label))]})}function pS(e,t){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);if(i>=0)return i;let a=0,o=0;for(let e of r)if(e===n[a]?a++:a>0&&o++,a===n.length)return 100+o;return null}function mS(e,t,n){return n===0?[]:t.map((t,n)=>({item:t,i:n,score:pS(e,t.label)})).filter(e=>e.score!==null).sort((e,t)=>e.score-t.score||e.i-t.i).slice(0,n).map(e=>e.item)}function hS(e,t){let{view:n,command:r}=t,i=e.trim(),a=[];if(n.project){let e=mS(i,t.files.map(e=>({...e,label:e.path})),i?5:0);for(let i of e)a.push({key:`file:${i.id}`,group:`Files`,label:i.path,run:()=>n.tab===`imports`?r(`openImportsFile`,{file:i.id}):r(`openFile`,{file:i.id})}),e.length<=2&&(n.tab===`imports`&&n.group!==null&&!n.fileLevel&&a.push({key:`only:${i.id}`,group:`Files`,label:`Show only links of ${i.path}`,run:()=>r(`showOnlyLinks`,{id:i.id})}),a.push({key:`leave:${i.id}`,group:`Files`,label:`Leave ${i.path} out of analysis…`,run:()=>t.action(`chooseFiles`,{source:i.id.slice(0,i.id.indexOf(`:`)),path:i.path})}));for(let e of mS(i,t.groups.map(e=>({...e,label:e.name})),i?4:0))a.push({key:`group:${e.id}`,group:`Groups`,label:e.name,detail:`open the group`,run:()=>r(`openGroup`,{group:e.id})}),a.push({key:`only:${e.id}`,group:`Groups`,label:`Show only links of ${e.name}`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`showOnlyLinks`,{id:e.id})}}),a.push({key:`pick:${e.id}`,group:`Groups`,label:`Details of ${e.name}`,detail:`on the project map`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`pickNode`,{id:e.id})}})}let o=[],s=(e,t,n,r)=>o.push({label:e,run:t,...n?{detail:n}:{},...r?{key:r}:{}});if(n.project){s(n.history?`Close History`:`History: runs by commit`,()=>r(`toggleHistory`)),n.compare&&s(`Stop comparing`,()=>r(`compareRuns`,{}));let e=/^(?:compare\s+)?(?:run\s*)?(\d+)\s*(?:\.\.|with|vs|and|,|\s)\s*(?:run\s*)?(\d+)$/i.exec(i);if(e){let[t,n]=[Number(e[1]),Number(e[2])];s(`Compare run ${Math.min(t,n)} with run ${Math.max(t,n)}`,()=>r(`compareRuns`,{a:t,b:n}))}n.run!==null&&s(`Back to latest`,()=>r(`openRun`,{}));let a=/^(?:view\s+)?run\s*(\d+)$/i.exec(i);a&&s(`View run ${a[1]}`,()=>r(`openRun`,{run:Number(a[1])})),s(`File tab`,()=>r(`showTab`,{tab:`file`}),`functions and calls inside a file`),s(`Imports tab`,()=>r(`showTab`,{tab:`imports`}),`how files depend on each other`),s(`Show the code`,()=>r(`showPanel`,{panel:`evidence`})),s(`Show Findings`,()=>r(`showPanel`,{panel:`questions`})),s(n.showPending?`Hide pending imports`:`Show pending imports`,()=>r(`togglePending`)),s(n.showUnresolved?`Hide unresolved call sites`:`Show unresolved call sites`,()=>r(`toggleUnresolved`)),n.selection&&s(`Clear the selection`,()=>r(`clearSelection`)),n.only&&s(`Show everything again`,()=>r(`showOnlyLinks`,{}),`not only one item's links`);for(let e of t.sources)s(`Re-analyze ${e.name??e.id}`,()=>t.action(`analyzeSource`,{source:e.id}),`this repository only`,`analyze:${e.id}`);if(t.sources.length>1){n.source&&s(`Scope: all repositories`,()=>r(`scopeSource`,{}));for(let e of t.sources)e.id!==n.source&&s(`Scope: ${e.name??e.id}`,()=>r(`scopeSource`,{source:e.id}),`one repository only`,`scope:${e.id}`)}n.group&&i.includes(`/`)&&s(`Open or close folder ${i}`,()=>r(`toggleFolder`,{path:i.replace(/^\.?\//,``).replace(/\/$/,``)})),s(`Re-analyze the project`,()=>t.action(`analyze`)),t.canDraft&&s(`Analyze uncommitted edits`,()=>t.action(`analyzeDraft`),`a draft beside the graph`);for(let e of t.stages??[])s(`Debug run: stop after ${e}`,()=>t.action(`analyzeDebug`,{until:e}),`never committed; compare it with the latest`,`debug:${e}`);s(`Repositories…`,()=>t.action(`openProjectSettings`),`re-analyze, choose files, rename, remove`),s(`License…`,()=>t.action(`openProjectSettings`,{tab:`license`}),`what the license includes; add or replace a key`)}n.project&&s(`All projects (home)`,()=>r(`goHome`),`every project and its last run`),s(`Add a folder…`,()=>t.action(`addFolder`)),s(`Settings…`,()=>t.action(`openSettings`),`the model for questions`);for(let e of t.projects)e.id!==n.project&&s(`Switch to project ${e.name}`,()=>r(`selectProject`,{project:e.id}),void 0,`project:${e.id}`);let c=o.filter(e=>/^(Compare run|View run|Open or close folder)/.test(e.label)),l=mS(i,o.filter(e=>!c.includes(e)),i?6:0);for(let e of[...c,...l])a.push({key:`cmd:${e.key??e.label}`,group:`Commands`,label:e.label,run:e.run,...e.detail?{detail:e.detail}:{}});return a}var gS=20;function _S({project:e,file:t,run:n,onOpen:r}){let{calls:i,error:a}=Px(e,n,t);if(a)return(0,K.jsx)(`p`,{className:`small muted`,children:`Calls to and from other files couldn't be loaded.`});if(!i||i.out.total===0&&i.in.total===0)return null;let o=(e,t)=>e.total===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`h4`,{className:`muted small`,children:[t===`out`?`Calls into other files`:`Called from other files`,` (`,e.total,`)`]}),(0,K.jsx)(`ul`,{className:`cross-calls`,"data-testid":`file-cross-calls-${t}`,children:e.calls.slice(0,gS).map(e=>{let n=t===`out`?e.from:e.to,i=t===`out`?e.to:e.from;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link-row`,"data-command":`open-cross-file`,title:`Open ${i.name} in ${i.path}`,onClick:()=>r({id:i.id,file:i.file}),children:[(0,K.jsx)(`span`,{className:`name`,children:t===`out`?`${n.name} → ${i.name}`:`${i.name} → ${n.name}`}),(0,K.jsxs)(`small`,{children:[i.path,` · line `,e.evidence.span.start.line]})]})},e.id)})}),e.total>gS&&(0,K.jsxs)(`p`,{className:`small muted`,children:[(e.total-gS).toLocaleString(`en-US`),` more: select a function to see its own.`]})]});return(0,K.jsxs)(`div`,{className:`file-cross-calls`,"data-testid":`file-cross-calls`,children:[o(i.out,`out`),o(i.in,`in`)]})}var vS=e=>e.reason===`imported-symbol`||e.reason===`template-reference`;function yS(e){let t=e.group;if(!t)return e.path;let n=t.root&&e.path.startsWith(`${t.root}/`)?e.path.slice(t.root.length+1):e.path;return`${t.name} › ${n}`}var bS={broken:`its import is broken`,pending:`its import waits for another source`,"not-analyzed":`its import leads to a file not analyzed`};function xS({project:e,graph:t,fn:n,onOpen:r,onShowImports:i}){let[a,o]=(0,d.useState)(null),s=t.file.id,c=t.unresolved.some(vS);(0,d.useEffect)(()=>{if(!c)return;let t=!1;return L.siteLinks(e,s).then(e=>!t&&o({file:s,byId:new Map(e.links.map(e=>[e.site,e]))}),()=>!t&&o({file:s,byId:`error`})),()=>{t=!0}},[e,s,t.committedRun,c]);let l=t.unresolved.filter(e=>e.enclosingFn===n&&vS(e)&&!e.component).sort((e,t)=>e.evidence.span.start.offset-t.evidence.span.start.offset);if(l.length===0)return null;let u=a?.file===s?a.byId:null,f=u===`error`?null:u;return(0,K.jsxs)(`div`,{className:`imported-calls`,"data-testid":`imported-calls`,children:[(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Calls into other files (`,l.length,`)`]}),u===`error`&&(0,K.jsx)(`p`,{className:`small muted`,children:`Where these calls lead couldn't be loaded.`}),l.map(e=>{let t=f?.get(e.id),n=e.importSpecifier?`imported from ${e.importSpecifier}`:`defined in another file`;return(0,K.jsxs)(`div`,{className:`imported-call`,"data-testid":`imported-call`,"data-site":e.id,children:[(0,K.jsxs)(`span`,{className:`mono small`,children:[e.expression,` · line `,e.evidence.span.start.line]}),u===`error`?(0,K.jsx)(`span`,{className:`small muted`,children:n}):f===null?(0,K.jsxs)(`span`,{className:`small muted`,children:[n,`…`]}):t?.status===`linked`&&t.target?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`small`,children:[`calls `,(0,K.jsx)(`strong`,{children:t.target.name}),` in`,` `,(0,K.jsx)(`span`,{className:`mono`,children:yS(t.target)}),`, found by`,` `,t.via===`import`||e.reason===`imported-symbol`?`import analysis`:`component linking`]}),(0,K.jsxs)(`span`,{className:`small links`,children:[(0,K.jsx)(`button`,{className:`button-link`,"data-command":`open-imported`,onClick:()=>r({id:t.target.id,file:t.target.file}),children:`Open that file`}),(0,K.jsx)(`button`,{className:`button-link`,"data-command":`show-in-imports`,onClick:i,children:`Show in Imports`})]})]}):t?.status===`external`?(0,K.jsxs)(`span`,{className:`small`,children:[`calls into the external package `,(0,K.jsx)(`strong`,{children:t.package?.name})]}):t?(0,K.jsxs)(`span`,{className:`small`,children:[n,`, not linked`,t.importOutcome?`: ${bS[t.importOutcome]}`:t.candidates?.length?t.exhaustive===!1?`: ${t.candidates.length} known function${t.candidates.length===1?``:`s`} could run (may not be all)`:`: it could be any of ${t.candidates.length} functions`:t.reason?`: ${t.reason}`:``]}):(0,K.jsxs)(`span`,{className:`small muted`,children:[n,`, not linked yet`]})]},e.id)})]})}var SS=(e,t)=>{let n=V(e).name;return n.length>t?`${n.slice(0,t-1)}…`:n};function CS(e,t,n,r){let i=e=>e.slice(e.indexOf(`:`)+1),a=e=>e.split(`/`).slice(-2).join(`/`),o=r.calls?t.out.calls:[],s=r.calls?t.in.calls:[],c=new Map;for(let e of o)c.set(e.from.id,e.from.name);for(let e of s)c.set(e.to.id,e.to.name);let l=[...c].sort((e,t)=>e[1]<t[1]?-1:+(e[1]>t[1])).map(([e])=>e),u=(e,t)=>({id:`${e}|${t.id}`,file:t.file,label:`${a(t.path)} ›\n${SS(t.name,28)}`}),d=new Map(s.map(e=>[e.from.id,u(`caller`,e.from)])),f=new Map(o.map(e=>[e.to.id,u(`callee`,e.to)])),p=new Map,m=new Map;if(r.imports&&n){for(let t of n.imports)t.outcome===`file`&&t.file&&t.file.id!==e&&!m.has(t.file.id)&&m.set(t.file.id,{id:`imported|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimported`,edge:t.id});for(let t of n.importedBy.files)t.file.id!==e&&!p.has(t.file.id)&&p.set(t.file.id,{id:`importer|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimports this file`,edge:t.id})}let h=e=>[...e.values()].sort((e,t)=>e.label<t.label?-1:+(e.label>t.label)),g=[...h(d),...h(p)],_=[...h(f),...h(m)],v=Math.max(l.length,1),y=e=>-((e-1)*58)/2,b=[{data:{id:`box`,kind:`box`,label:i(e),w:210,h:v*58+50},position:{x:0,y:0},classes:`box`},...l.map((e,t)=>({data:{id:e,kind:`function`,label:`ƒ ${SS(c.get(e),22)}`},position:{x:0,y:y(l.length)+t*58+12},classes:`function`})),...g.map((e,t)=>({data:{id:e.id,kind:`port`,side:`left`,file:e.file,label:e.label},position:{x:-330,y:y(g.length)+t*58},classes:e.id.startsWith(`importer|`)?`port file`:`port`})),..._.map((e,t)=>({data:{id:e.id,kind:`port`,side:`right`,file:e.file,label:e.label},position:{x:330,y:y(_.length)+t*58},classes:e.id.startsWith(`imported|`)?`port file`:`port`}))],x=new Map,S=(e,t,n)=>{let r=`${e}->${t}`,i=x.get(r);i?i.calls.push(n):x.set(r,{id:n,source:e,target:t,calls:[n]})};for(let e of o)S(e.from.id,`callee|${e.to.id}`,e.id);for(let e of s)S(`caller|${e.from.id}`,e.to.id,e.id);for(let e of x.values())b.push({data:{id:e.id,kind:`call`,source:e.source,target:e.target,calls:e.calls,label:e.calls.length>1?`×${e.calls.length}`:``},classes:`call`});for(let e of m.values())b.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:`box`,target:e.id,label:``},classes:`import`});for(let e of p.values())b.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:e.id,target:`box`,label:``},classes:`import`});return b}function wS({file:e,calls:t,imports:n,show:r,pick:i,onPick:a,onOpenFile:o,onClear:s,marks:c=null,onContext:l}){let u=(0,d.useRef)(null),f=(0,d.useRef)(null),p=(0,d.useRef)(c);p.current=c;let m=(0,d.useRef)(l);m.current=l,(0,d.useEffect)(()=>{f.current&&Se(f.current,c)},[c]);let h=(0,d.useRef)({onPick:a,onOpenFile:o,onClear:s});h.current={onPick:a,onOpenFile:o,onClear:s};let g=(0,d.useMemo)(()=>CS(e,t,n,r),[e,t,n,r.calls,r.imports]);(0,d.useEffect)(()=>{if(!u.current)return;let e=m_({container:u.current,elements:g,layout:{name:`preset`},autounselectify:!0,minZoom:.15,maxZoom:2.5,style:[{selector:`node`,style:{shape:`round-rectangle`,width:170,height:36,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`194px`,"text-valign":`center`,"text-halign":`center`,"font-size":12,color:`#1d2330`,"background-color":`#fff`,"border-width":1,"border-color":`#c9d1de`}},{selector:`node.box`,style:{"background-color":`#f7faff`,"border-color":`#c6d6f3`,"border-width":2,"text-valign":`top`,"text-margin-y":18,color:`#2a56ad`,"font-weight":`bold`,width:`data(w)`,height:`data(h)`,events:`no`,"z-index":0}},{selector:`node.port`,style:{width:210,height:42,"border-style":`dashed`,"border-color":`#6b87b8`}},{selector:`node.port.file`,style:{"border-color":`#b7c0cf`,color:`#4a5262`}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"line-color":`#6b87b8`,"line-style":`dashed`,"target-arrow-shape":`triangle`,"target-arrow-color":`#6b87b8`,"arrow-scale":.8,label:`data(label)`,"font-size":10,color:`#5d6675`,"text-background-color":`#fff`,"text-background-opacity":1}},{selector:`edge.import`,style:{"line-color":`#b7c0cf`,"target-arrow-color":`#b7c0cf`}},...xe,{selector:`.picked`,style:{"line-color":`#3b6fd4`,"target-arrow-color":`#3b6fd4`,width:3}}]});return e.on(`tap`,`node`,e=>{e.target.data(`kind`)===`port`&&h.current.onOpenFile(e.target.data(`file`))}),e.on(`tap`,`edge`,e=>h.current.onPick(e.target.data(`edge`)??e.target.id())),e.on(`tap`,t=>{t.target===e&&h.current.onClear()}),e.fit(void 0,30),e.zoom()>1.2&&(e.zoom(1.2),e.center()),f.current=e,Se(e,p.current),e.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`function`?`function`:t.kind===`port`&&t.file?`file`:t.kind===`call`||t.kind===`import`?`edge`:null;if(!n||!u.current)return;let r=u.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};m.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),()=>{f.current=null,e.destroy()}},[g]),(0,d.useEffect)(()=>{let e=f.current;e&&(e.elements().removeClass(`picked`),i&&e.edges().filter(e=>(e.data(`calls`)??[]).includes(i)||e.data(`edge`)===i).addClass(`picked`))},[i,g]);let _=e=>g.filter(t=>t.data.kind===`port`&&t.data.side===e).map(e=>e.data.id).join(` `),v=[t.in,t.out].filter(e=>e.truncated),y=(r.calls?t.out.calls.length+t.in.calls.length:0)===0,b=[...new Map([...t.in.calls.map(e=>e.from),...t.out.calls.map(e=>e.to)].map(e=>[e.file,e])).values()];return(0,K.jsxs)(`div`,{className:`graph-wrap`,children:[y&&r.calls&&(0,K.jsx)(`p`,{className:`hint overlay`,"data-testid":`no-cross-file-calls`,children:`No calls cross into or out of this file.`}),(0,K.jsx)(`div`,{ref:u,className:`graph map`,"data-testid":`file-canvas`,"data-calls":g.filter(e=>e.data.kind===`call`).length,"data-imports":g.filter(e=>e.data.kind===`import`).length,"data-ports-left":_(`left`),"data-ports-right":_(`right`)}),v.length>0&&(0,K.jsxs)(`p`,{className:`hint small overlay bottom`,"data-testid":`calls-truncated`,children:[v.map(e=>`Showing ${e.calls.length} of ${e.total} calls ${e.direction===`in`?`into`:`out of`} this file`).join(`; `),`.`]}),(0,K.jsxs)(`ul`,{className:`visually-hidden`,"aria-label":`Cross-file calls`,children:[t.in.calls.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`in`,tabIndex:-1,onClick:()=>a(e.id),children:[e.from.path,` › `,e.from.name,` calls `,e.to.name]})},e.id)),t.out.calls.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`out`,tabIndex:-1,onClick:()=>a(e.id),children:[e.from.name,` calls `,e.to.path,` › `,e.to.name]})},e.id)),b.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`open-imports-file`,"data-id":e.file,tabIndex:-1,onClick:()=>o(e.file),children:[`Open `,e.path]})},e.file))]}),(0,K.jsx)(`button`,{className:`fit`,onClick:()=>f.current?.fit(void 0,30),children:`Fit`})]})}var TS={repository:`repository`,"workspace-package":`workspace package`,cluster:`cluster`},ES=(e,t)=>`${e.toLocaleString()} ${t}${e===1?``:`s`}`,DS=.55;function OS(e){return e.resize(),e.elements().empty()?1:(e.fit(void 0,40),e.zoom()>1.2&&(e.zoom(1.2),e.center()),e.zoom())}var kS=(e,t=30)=>e.length>t?`${e.slice(0,t-1)}…`:e;function AS(e,t){if(!e||!t)return 0;let n=Math.abs(t.x-e.x)/290;return n>1.2||t.x<e.x?-(84*.9+12*Math.min(4,n)):0}var jS=(e,t)=>1+6*Math.sqrt(e/Math.max(1,t));function MS({map:e,layoutKey:t,pick:n,showPackages:r,onPick:i,onOpen:a,onClear:o,marks:s=null,only:c=null,onContext:l}){let u=(0,d.useRef)(null),f=(0,d.useRef)(null),[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(!1),_=(0,d.useRef)(!1),v=(0,d.useRef)(c);v.current=c;let y=(0,d.useRef)(l);y.current=l,(0,d.useEffect)(()=>{f.current&&ve(f.current,c)},[c]);let b=(0,d.useRef)(s);b.current=s,(0,d.useEffect)(()=>{f.current&&Se(f.current,s)},[s]);let x=(0,d.useRef)({x:0,y:0}),S=(0,d.useRef)({onPick:i,onOpen:a,onClear:o});return S.current={onPick:i,onOpen:a,onClear:o},(0,d.useEffect)(()=>{if(!u.current)return;let n=e=>e.imports+e.calls,r=Math.max(1,...e.dependsOn.map(n)),i=_x(t,e.groups,e.dependsOn.map(e=>({from:e.from,to:e.to,weight:n(e)})));x.current=i.packages;let a=[...e.groups.map(e=>{let t=e.findings.broken;return{data:{id:e.id,kind:`group`,label:[kS(e.name),kS(`${e.source} · ${TS[e.kind]??e.kind}`),t>0?`${ES(e.files,`file`)} · ${ES(t,`broken import`)}`:`${ES(e.files,`file`)} · ${ES(e.functions,`function`)}`].join(`
|
|
337
337
|
`)},position:i.groups[e.id]??{x:0,y:0},classes:t>0?`group broken`:`group`}}),...e.dependsOn.map(e=>({data:{bend:AS(i.groups[e.from],i.groups[e.to]),id:e.id,kind:`depends`,source:e.from,target:e.to,width:jS(n(e),r),label:n(e)*3>=r&&n(e)>1?String(n(e)):``},classes:`depends`}))],o=m_({container:u.current,elements:a,layout:{name:`preset`},autounselectify:!0,minZoom:.1,maxZoom:2.5,style:[{selector:`node`,style:{shape:`round-rectangle`,width:210,height:84,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`190px`,"text-valign":`center`,"text-halign":`center`,"font-size":13,"line-height":1.45,color:`#1d2330`,"background-color":`#f7f9fc`,"border-width":1,"border-color":`#c9d1de`}},{selector:`node.broken`,style:{"border-color":`#c9a45c`}},{selector:`node.packages`,style:{"background-color":`#fff`,"border-style":`dashed`,"border-color":`#b7c0cf`,color:`#4a5262`}},{selector:`edge`,style:{width:`data(width)`,"curve-style":`unbundled-bezier`,"control-point-distances":`data(bend)`,"control-point-weights":.5,"line-color":`#9aa6b8`,"target-arrow-shape":`triangle`,"target-arrow-color":`#9aa6b8`,"arrow-scale":.8,label:`data(label)`,"font-size":11,color:`#5d6675`,"text-background-color":`#fff`,"text-background-opacity":1,"text-background-padding":`2px`}},{selector:`edge.uses`,style:{"line-style":`dashed`,"line-color":`#c9d1de`,"target-arrow-shape":`none`}},...xe,_e,{selector:`node.picked`,style:{"border-width":2,"border-color":`#3b6fd4`,"background-color":`#eef4ff`}},{selector:`edge.picked`,style:{"line-color":`#3b6fd4`,"target-arrow-color":`#3b6fd4`}},{selector:`.faded`,style:{opacity:.25}}]});o.on(`tap`,`node`,e=>{e.target.data(`kind`)===`group`&&S.current.onPick(e.target.id())}),o.on(`dbltap`,`node`,e=>{e.target.data(`kind`)===`group`&&S.current.onOpen(e.target.id())}),o.on(`tap`,e=>{e.target===o&&S.current.onClear()}),_.current=!1,m(OS(o)<DS),o.on(`scrollzoom pinchzoom dragpan`,()=>{_.current=!0});let s=new ResizeObserver(()=>{_.current?o.resize():m(OS(o)<DS)});return u.current&&s.observe(u.current),f.current=o,u.current&&(u.current.veoCy=o),ve(o,v.current),o.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`group`?`group`:t.kind===`depends`?`edge`:null;if(!n||!u.current)return;let r=u.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};y.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),Se(o,b.current),()=>{s.disconnect(),f.current=null,o.destroy()}},[e,t]),(0,d.useEffect)(()=>{let t=f.current;if(!t||(t.remove(`#packages, .uses`),!r||e.externalPackages.total===0))return;let n=[],i=e.externalPackages.top.slice(0,4).map(e=>e.name),a=e.externalPackages.total-i.length;n.push({data:{id:`packages`,kind:`packages`,label:[`External packages`,i.join(`, `),a>0?`+ ${a} more`:``].filter(Boolean).join(`
|
|
338
338
|
`)},position:x.current,classes:`packages`});for(let t of e.groups)t.externalPackages>0&&n.push({data:{id:`packages|${t.id}`,kind:`uses`,source:t.id,target:`packages`,width:1,label:``,bend:0},classes:`uses`});t.add(n),_.current||m(OS(t)<DS)},[e,t,r]),(0,d.useEffect)(()=>{let e=f.current;e&&e.batch(()=>{e.elements().removeClass(`picked faded`);let t=n?e.getElementById(n):null;if(t&&t.nonempty()){let n=t.union(t.connectedEdges(`[kind = "depends"]`));n.addClass(`picked`),e.elements().not(n).not(n.connectedNodes()).addClass(`faded`)}})},[n,e,t,r]),(0,K.jsxs)(`div`,{className:`graph-wrap`,children:[(0,K.jsx)(`div`,{ref:u,className:`graph map`,"data-testid":`project-map`,tabIndex:0,role:`application`,"aria-label":`Project map: arrow keys move between groups, Enter opens one`,onKeyDown:t=>{let r=e.groups.map(e=>e.id);if(r.length===0)return;let s=n?r.indexOf(n):-1;if(t.key===`ArrowRight`||t.key===`ArrowDown`)i(r[(s+1)%r.length]);else if(t.key===`ArrowLeft`||t.key===`ArrowUp`)i(r[(s-1+r.length)%r.length]);else if(t.key===`Enter`&&n)a(n);else if(t.key===`Escape`)o();else return;t.preventDefault()}}),(0,K.jsx)(`ul`,{className:`visually-hidden`,"aria-label":`Groups`,children:e.groups.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`button`,{"data-command":`pick-node`,"data-id":e.id,tabIndex:-1,onClick:()=>i(e.id),children:e.name}),(0,K.jsxs)(`button`,{"data-command":`open-group`,"data-id":e.id,tabIndex:-1,onClick:()=>a(e.id),children:[`Open `,e.name]})]},e.id))}),h&&(0,K.jsx)(`ul`,{className:`map-list`,"data-testid":`map-list`,"aria-label":`Groups`,children:e.groups.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link-row${e.id===n?` picked`:``}`,"data-command":`list-group`,"data-id":e.id,onClick:()=>i(e.id),onDoubleClick:()=>a(e.id),title:`${e.name}: ${e.source} · ${TS[e.kind]??e.kind} (double-click or Enter opens it)`,onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),a(e.id))},children:[(0,K.jsx)(`span`,{className:`name`,children:e.name}),(0,K.jsxs)(`small`,{children:[e.source,` · `,TS[e.kind]??e.kind,` · `,ES(e.files,`file`),e.findings.broken>0?` · ${ES(e.findings.broken,`broken import`)}`:``]})]})},e.id))}),!h&&p&&(0,K.jsxs)(`p`,{className:`overlay bottom small muted map-note`,"data-testid":`map-too-small`,children:[`All `,e.groups.length,` groups are shown, zoomed out: scroll to zoom in, or`,` `,(0,K.jsx)(`button`,{className:`button-link`,onClick:()=>g(!0),children:`see them as a list`}),`.`]}),(0,K.jsxs)(`div`,{className:`map-controls`,children:[(0,K.jsx)(`button`,{"data-command":`map-as-list`,"aria-pressed":h,onClick:()=>g(!h),title:`The groups as a list`,children:h?`Map`:`List`}),!h&&(0,K.jsx)(`button`,{className:`fit`,"data-command":`fit-map`,onClick:()=>{f.current&&(_.current=!1,m(OS(f.current)<DS))},children:`Fit`})]})]})}function NS({project:e,projectName:t,run:n,group:r,source:i=null,pick:a,file:o,fileLevel:s,expand:c,showPending:l,tabs:u,onPick:f,onOpenGroup:p,onOpenFile:m,onToggleFolder:h,onTogglePending:g,onClear:_,marks:v=null,only:y=null,onContext:b}){let[x,S]=(0,d.useState)(0),{groups:C,error:w}=jx(e,n,x,i),[T,E]=(0,d.useState)(!1),D=s&&o!==null,{imports:O}=Nx(e,n,D?o:null),{calls:k,error:A}=Px(e,n,D?o:null),[j,M]=(0,d.useState)({calls:!0,imports:!0}),N=D?O?O.file.group:null:r??(C&&C.total===1?C.groups[0].id:null),P=N?C?.groups.find(e=>e.id===N):void 0,[F,I]=(0,d.useState)(0),{group:L,error:R}=Mx(e,n,D?null:N,c,l,F),z=(0,K.jsxs)(`div`,{className:`toolbar`,children:[u,(0,K.jsx)(`nav`,{className:`breadcrumb`,"aria-label":`Zoom`,"data-testid":`breadcrumb`,children:N?(0,K.jsxs)(K.Fragment,{children:[C?.total===1?(0,K.jsx)(`span`,{children:t}):(0,K.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>p(),children:t}),(0,K.jsx)(`span`,{className:`muted`,children:`›`}),D?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>p(N),children:P?.name??N}),(0,K.jsx)(`span`,{className:`muted`,children:`›`}),(0,K.jsx)(`strong`,{className:`mono`,children:Tx(FS(o),IS(P))})]}):(0,K.jsx)(`strong`,{children:P?.name??N})]}):D?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>p(),children:t}),(0,K.jsx)(`span`,{className:`muted`,children:`›`}),(0,K.jsx)(`strong`,{className:`mono`,children:FS(o)})]}):(0,K.jsx)(`strong`,{children:t})}),C&&!N&&C.stage2&&(0,K.jsxs)(`span`,{className:`small muted`,children:[`project map · `,C.total,` group`,C.total===1?``:`s`]}),L&&!D&&(0,K.jsxs)(`span`,{className:`small muted`,children:[`group · `,L.group.files,` file`,L.group.files===1?``:`s`,` · `,L.group.source]}),N&&!D&&c.length>0&&(0,K.jsx)(`span`,{className:`open-folders small`,children:c.map(e=>(0,K.jsxs)(`span`,{className:`chip`,children:[Tx(e,IS(P)),`/`,(0,K.jsx)(`button`,{className:`icon`,"data-command":`toggle-folder`,"data-testid":`close-folder`,"data-path":e,"aria-label":`Close the folder ${e}`,onClick:()=>h(e),children:`×`})]},e))}),D&&(0,K.jsx)(`span`,{className:`small muted`,children:`its imports and cross-file calls`}),(0,K.jsx)(`span`,{className:`spacer`}),D&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-calls`,checked:j.calls,onChange:e=>M({...j,calls:e.target.checked})}),`Cross-file calls`]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-imports`,checked:j.imports,onChange:e=>M({...j,imports:e.target.checked})}),`Imports`]})]}),N&&!D&&(0,K.jsxs)(`label`,{className:`toggle`,title:`Imports waiting for another source to be added`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-command":`toggle-pending`,checked:l,onChange:g}),`Pending imports`]}),C&&!N&&C.externalPackages.total>0&&(0,K.jsxs)(`label`,{className:`toggle`,title:`External packages are hidden by default: nearly every group imports the same few`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-packages`,checked:T,onChange:e=>E(e.target.checked)}),`External packages`]})]});if(w)return(0,K.jsxs)(K.Fragment,{children:[z,(0,K.jsxs)(`p`,{className:`hint error`,children:[w,` `,(0,K.jsx)(`button`,{className:`link`,onClick:()=>S(e=>e+1),children:`Try again`})]})]});if(!C)return(0,K.jsxs)(K.Fragment,{children:[z,(0,K.jsx)(`p`,{className:`hint`,children:`Loading the imports…`})]});if(!C.stage2)return(0,K.jsxs)(K.Fragment,{children:[z,(0,K.jsx)(`p`,{className:`hint`,"data-testid":`imports-no-stage2`,children:`Imports haven't been analyzed in this project yet: Stage 2, which follows imports across files, hasn't run. Analyze the project again to see them.`})]});let B=C.stats;return(0,K.jsxs)(K.Fragment,{children:[z,D?A?(0,K.jsx)(`p`,{className:`hint error`,children:A}):k?(0,K.jsx)(`div`,{className:`group-level`,"data-testid":`file-level`,children:(0,K.jsx)(wS,{marks:v,onContext:b,file:o,calls:k,imports:O,show:j,pick:a,onPick:f,onOpenFile:e=>m(e),onClear:_})}):(0,K.jsx)(`p`,{className:`hint`,children:`Loading the file…`}):N?R?(0,K.jsxs)(`p`,{className:`hint error`,children:[R,` `,(0,K.jsx)(`button`,{className:`link`,onClick:()=>I(e=>e+1),children:`Try again`})]}):L?(0,K.jsxs)(`div`,{className:`group-level`,"data-testid":`group-level`,children:[L.truncated&&(0,K.jsxs)(`p`,{className:`hint small`,children:[`Showing `,L.nodes.length,` of `,L.total,` files and folders.`]}),(0,K.jsx)(Ex,{marks:v,onContext:b,only:y,reply:L,pick:a,onPick:f,onOpenFile:e=>m(e,N),onToggleFolder:h,onClear:_})]}):(0,K.jsx)(`p`,{className:`hint`,children:`Loading the group…`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`dl`,{className:`map-stats`,"data-testid":`map-stats`,children:[(0,K.jsx)(PS,{n:B.files,label:`files`}),(0,K.jsx)(PS,{n:B.functions,label:`functions`}),(0,K.jsx)(PS,{n:B.crossFileCalls,label:`cross-file calls`}),(0,K.jsx)(PS,{n:B.brokenImports,label:`broken imports`,tone:B.brokenImports>0?`warn`:void 0}),(0,K.jsx)(PS,{n:B.openCalls,label:`open calls`}),(0,K.jsx)(PS,{n:C.externalPackages.total,label:T?`external packages`:`external packages (hidden)`})]}),C.total===0?(0,K.jsx)(`p`,{className:`hint`,children:`No groups: nothing was analyzed.`}):(0,K.jsx)(MS,{marks:v,onContext:b,only:y,map:C,layoutKey:`${e}|${C.committedRun}|${i??``}`,pick:a,showPackages:T,onPick:f,onOpen:e=>p(e),onClear:_}),C.truncated&&(0,K.jsxs)(`p`,{className:`hint small`,children:[`Showing `,C.groups.length,` of `,C.total,` groups.`]})]})]})}function PS({n:e,label:t,tone:n}){return(0,K.jsxs)(`div`,{className:n,children:[(0,K.jsx)(`dd`,{children:e.toLocaleString()}),(0,K.jsx)(`dt`,{children:t})]})}var FS=e=>e.slice(e.indexOf(`:`)+1);function IS(e){return!e||e.kind===`cluster`?``:e.root}var LS={focus:3,site:2,call:1},RS=e=>e.end.column<=1&&e.end.line>e.start.line?e.end.line-1:e.end.line;function zS(e,t){if(e.kind!==`call`||RS(e)===e.start.line)return e;let n=Array.from(t(e.start.line)??``),r=n.indexOf(`(`,e.start.column-1),i=r>=0?r+2:n.length+1;return{...e,end:{line:e.start.line,column:i}}}function BS(e,t){let n=t=>e.lines[t-e.startLine],r=t.map(e=>zS(e,n)),i=r.map(e=>(e.end.line-e.start.line)*1e4+(e.end.column-e.start.column)),a=new Map;r.forEach((t,n)=>{let r=Math.max(t.start.line,e.startLine),i=Math.min(RS(t),e.startLine+e.lines.length-1);for(let e=r;e<=i;e++){let t=a.get(e);t?t.push(n):a.set(e,[n])}});let o=new Set;return e.lines.map((t,n)=>{let s=e.startLine+n,c=Array.from(t),l=c.map(()=>null);for(let e of a.get(s)??[]){let t=r[e],n=s===t.start.line?t.start.column-1:0,a=s===t.end.line?t.end.column-1:c.length;for(let o=Math.max(0,n);o<Math.min(c.length,a);o++){let n=l[o];(n==null||LS[t.kind]>LS[r[n].kind]||LS[t.kind]===LS[r[n].kind]&&i[e]<i[n])&&(l[o]=e)}}let u=[];return c.forEach((e,t)=>{let n=u[u.length-1],r=l[t]??null;if(n&&n.mark===r)n.text+=e;else{let t=r!==null&&!o.has(r);r!==null&&o.add(r),u.push({text:e,mark:r,first:t})}}),{n:s,runs:u,focus:r.some(e=>e.kind===`focus`&&s>=e.start.line&&s<=RS(e))}})}function VS({snippet:e,marks:t,focusLine:n,testId:r,className:i}){let a=(0,d.useRef)(null),o=(0,d.useMemo)(()=>BS(e,t),[e,t]);(0,d.useEffect)(()=>{let e=a.current,t=e?.querySelector(`[data-line="${n}"]`);e&&t&&(e.scrollTop=Math.max(0,t.offsetTop-e.clientHeight/3))},[e,n]);let s=e=>{let n=e?.closest(`[data-mark]`);if(!n)return!1;let r=t[Number(n.dataset.mark)];return r?.onClick?(r.onClick(),!0):!1};return(0,K.jsx)(`pre`,{className:`code ${i??``}`,"data-testid":r,ref:a,onClick:e=>s(e.target),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&s(e.target)&&e.preventDefault()},children:o.map(({n:e,runs:n,focus:r})=>(0,K.jsxs)(`div`,{"data-line":e,className:r?`focus-line`:``,children:[(0,K.jsx)(`span`,{className:`ln`,"aria-hidden":`true`,children:e}),` `,n.map((e,n)=>{if(e.mark===null)return e.text;let r=t[e.mark],i=r.kind===`focus`?`hit`:r.kind===`site`?`site-mark`:`call-mark`,a=!!r.onClick;return(0,K.jsx)(`span`,{className:`mark ${i}${a?` clickable`:``}`,"data-mark":e.mark,title:r.title,...a&&e.first?{role:`button`,tabIndex:0}:{},children:e.text},n)})]},e))})}var HS={repository:`repository`,"workspace-package":`workspace package`,cluster:`cluster`};function US(e){let{project:t,run:n,pick:r,file:i,fileLevel:a}=e;return a&&i&&r?.startsWith(`CALLS_CROSS_FILE|`)?(0,K.jsx)(XS,{project:t,run:n,file:i,call:r}):a&&i&&(r?.startsWith(`IMPORTS|`)||r?.startsWith(`unresolved-import|`))?(0,K.jsx)(ZS,{project:t,run:n,file:i,edge:r}):a&&i?(0,K.jsx)(KS,{project:t,run:n,file:i,onOpenFile:e.onOpenFile}):r&&r.startsWith(`folder|`)?(0,K.jsx)(qS,{...e,folder:r}):r&&!r.startsWith(`group|`)?(0,K.jsx)(KS,{project:t,run:n,file:r,onOpenFile:e.onOpenFile,canOpen:!0}):(0,K.jsx)(WS,{project:t,run:n,group:e.group,pick:r,onOpenGroup:e.onOpenGroup,onPick:e.onPick})}function WS({project:e,run:t,group:n,pick:r,onOpenGroup:i,onPick:a}){let{groups:o}=jx(e,t),s=n??(o?.total===1?o.groups[0].id:r),c=s&&o?o.groups.find(e=>e.id===s):void 0;if(!o)return(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`});if(!o.stage2)return(0,K.jsx)(`p`,{className:`hint`,children:`Stage 2 hasn't run on this project, so there are no groups yet.`});if(!c)return(0,K.jsx)(`p`,{className:`hint`,children:`Pick a group on the map to see what it holds and what it depends on; double-click or press Enter to open it.`});let l=e=>o.groups.find(t=>t.id===e)?.name??e,u=o.dependsOn.filter(e=>e.from===c.id),d=o.dependsOn.filter(e=>e.to===c.id),f=c.findings,p=(e,t)=>e.length===0?(0,K.jsx)(`p`,{className:`small muted`,children:`None`}):(0,K.jsx)(`ul`,{className:`plain`,children:e.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`button`,{className:`link`,onClick:()=>n?i(e[t]):a(e[t]),children:l(e[t])}),` `,(0,K.jsxs)(`span`,{className:`small muted`,children:[e.imports,` import`,e.imports===1?``:`s`,` · `,e.calls,` call`,e.calls===1?``:`s`]})]},e.id))});return(0,K.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`group-details`,children:[(0,K.jsx)(`h3`,{children:c.name}),(0,K.jsxs)(`p`,{className:`muted small`,children:[c.source,` · `,HS[c.kind]??c.kind,c.root?` · ${c.root}`:``]}),(0,K.jsxs)(`p`,{children:[c.files.toLocaleString(),` files · `,c.functions.toLocaleString(),` functions · `,c.externalPackages,` `,`external package`,c.externalPackages===1?``:`s`]}),f.broken+f.notAnalyzed+f.openCalls+f.pending>0&&(0,K.jsx)(`p`,{className:`small`,"data-testid":`group-findings`,children:[f.broken?`${f.broken} broken import${f.broken===1?``:`s`}`:``,f.notAnalyzed?`${f.notAnalyzed} import${f.notAnalyzed===1?``:`s`} of files not analyzed`:``,f.openCalls?`${f.openCalls} open question${f.openCalls===1?``:`s`}`:``,f.pending?`${f.pending} pending`:``].filter(Boolean).join(` · `)}),(0,K.jsx)(`h4`,{className:`muted small`,children:`Depends on`}),p(u,`to`),(0,K.jsx)(`h4`,{className:`muted small`,children:`Used by`}),p(d,`from`),!n&&o.total>1&&(0,K.jsxs)(`button`,{"data-command":`open-group`,"data-testid":`open-picked`,onClick:()=>i(c.id),children:[`Open `,c.name]})]})}var GS=e=>e.slice(e.indexOf(`:`)+1);function KS({project:e,run:t,file:n,onOpenFile:r,canOpen:i=!1}){let{imports:a,error:o}=Nx(e,t,n),{groups:s}=jx(e,t);if(o)return(0,K.jsx)(`p`,{className:`hint error`,children:o});if(!a)return(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`});let c=a.file.group?s?.groups.find(e=>e.id===a.file.group):void 0,l=c&&c.kind!==`cluster`?c.root:``;return(0,K.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`file-details`,children:[(0,K.jsx)(`h3`,{className:`mono`,children:Tx(a.file.path,l)}),(0,K.jsx)(`p`,{className:`muted small`,children:c?`${c.name} · ${c.source}`:GS(n)}),(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Imports (`,a.total,`)`]}),a.imports.length===0?(0,K.jsx)(`p`,{className:`small muted`,children:`None`}):(0,K.jsx)(`ul`,{className:`plain`,"data-testid":`file-imports`,children:a.imports.map(e=>(0,K.jsxs)(`li`,{className:e.outcome===`broken`?`broken`:void 0,"data-outcome":e.outcome,children:[(0,K.jsx)(`span`,{className:`mono small`,children:e.specifier}),` `,e.outcome===`file`&&e.file?(0,K.jsx)(`button`,{className:`link small`,onClick:()=>r(e.file.id),children:e.file.path}):e.outcome===`package`&&e.package?(0,K.jsxs)(`span`,{className:`small muted`,children:[`package `,e.package.name,e.package.version?` ${e.package.version}`:``]}):(0,K.jsxs)(`span`,{className:`small outcome`,children:[`(`,e.outcome===`not-analyzed`?`not analyzed`:e.outcome,`:`,` `,bx[e.reason??``]??e.reason,`)`]})]},e.id))}),a.truncated&&(0,K.jsxs)(`p`,{className:`small muted`,children:[`Showing `,a.imports.length,` of `,a.total,`.`]}),(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Imported by (`,a.importedBy.total,`)`]}),a.importedBy.files.length===0?(0,K.jsx)(`p`,{className:`small muted`,children:`None`}):(0,K.jsx)(`ul`,{className:`plain`,"data-testid":`file-importers`,children:a.importedBy.files.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`button`,{className:`link small`,onClick:()=>r(e.file.id),children:e.file.path})},e.id))}),i&&(0,K.jsx)(`button`,{"data-command":`open-imports-file`,"data-testid":`open-picked-file`,onClick:()=>r(n),children:`Open file`})]})}function qS({project:e,run:t,group:n,folder:r,expand:i,showPending:a,onToggleFolder:o}){let{groups:s}=jx(e,t),{group:c}=Mx(e,t,n??(s?.total===1?s.groups[0].id:null),i,a),l=c?.nodes.find(e=>e.id===r);return!l||l.kind!==`folder`?(0,K.jsx)(`p`,{className:`hint`,children:`Pick a file or a folder in the group.`}):(0,K.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`folder-details`,children:[(0,K.jsxs)(`h3`,{className:`mono`,children:[l.path,`/`]}),(0,K.jsxs)(`p`,{children:[l.files.toLocaleString(),` files`]}),l.findings.broken>0&&(0,K.jsxs)(`p`,{className:`small`,children:[l.findings.broken,` broken import`,l.findings.broken===1?``:`s`]}),(0,K.jsx)(`button`,{"data-command":`toggle-folder`,onClick:()=>o(l.path),children:`Open the folder`})]})}function JS({project:e,run:t,file:n,span:r}){let[i,a]=(0,d.useState)(null),o=`${t}|${n}|${r.start.offset}|${r.end.offset}`;return(0,d.useEffect)(()=>{let t=!1;return a(null),L.snippet(e,n,r).then(e=>!t&&a(e),()=>!t&&a(`error`)),()=>{t=!0}},[e,o]),i?i===`error`?(0,K.jsx)(`p`,{className:`small muted`,children:`The code couldn't be loaded.`}):(0,K.jsx)(VS,{snippet:i,marks:[{start:r.start,end:r.end,kind:`focus`}],focusLine:r.start.line,testId:`snippet`}):null}function YS({file:e,span:t}){return(0,K.jsx)(`p`,{className:`location small`,"data-testid":`evidence-location`,children:(0,K.jsxs)(`code`,{children:[GS(e),`:`,t.start.line,`:`,t.start.column]})})}function XS({project:e,run:t,file:n,call:r}){let{calls:i}=Px(e,t,n),a=i?[...i.out.calls,...i.in.calls].find(e=>e.id===r):void 0;if(!i)return(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`});if(!a)return(0,K.jsx)(`p`,{className:`hint`,children:`Pick a call or an import on the canvas.`});let o=a.via===`import`?`found by import analysis${a.hops?.length?`, through ${a.hops.length} re-export${a.hops.length===1?``:`s`}`:``}`:a.via===`component`?`found by component linking`:`found by the template link`,s=a.steps?.find(e=>e.kind===`import`);return(0,K.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`call-details`,children:[(0,K.jsxs)(`h3`,{"data-testid":`evidence-title`,children:[a.from.name,` calls `,a.to.name]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`across files · `,o]}),s&&(0,K.jsx)(`p`,{className:`small`,"data-testid":`call-import`,children:s.detail}),a.hops&&a.hops.length>0&&(0,K.jsxs)(`p`,{className:`small muted`,children:[`through `,a.hops.join(` › `)]}),a.provenance&&(0,K.jsxs)(`p`,{className:`muted small`,"data-testid":`evidence-provenance`,children:[`Found by `,U(a.provenance.stage),` · run `,a.provenance.run]}),(0,K.jsx)(YS,{file:a.evidence.file,span:a.evidence.span}),(0,K.jsx)(JS,{project:e,run:t,file:a.evidence.file,span:a.evidence.span}),(0,K.jsx)(ue,{project:e,id:a.id},a.id)]})}function ZS({project:e,run:t,file:n,edge:r}){let{imports:i}=Nx(e,t,n);if(!i)return(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`});let a=i.imports.find(e=>e.id===r),o=i.importedBy.files.find(e=>e.id===r);if(!a&&!o)return(0,K.jsx)(`p`,{className:`hint`,children:`Pick a call or an import on the canvas.`});let s=a?.evidence??o.evidence;return(0,K.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`import-details`,children:[(0,K.jsx)(`h3`,{"data-testid":`evidence-title`,children:a?`imports ${a.specifier}`:`${o.file.path} imports this file`}),a?.file&&(0,K.jsxs)(`p`,{className:`small`,children:[`resolves to `,a.file.path]}),a&&!a.file&&!a.package&&(0,K.jsxs)(`p`,{className:`small`,"data-testid":`import-outcome`,children:[a.outcome===`not-analyzed`?`not analyzed`:a.outcome,`:`,` `,bx[a.reason??``]??a.reason]}),a?.steps.map((e,t)=>(0,K.jsx)(`p`,{className:`small muted`,children:e.detail},t)),(a?.provenance??o?.provenance)&&(0,K.jsxs)(`p`,{className:`muted small`,"data-testid":`evidence-provenance`,children:[`Found by `,U((a?.provenance??o.provenance).stage),` · run`,` `,(a?.provenance??o.provenance).run]}),(0,K.jsx)(YS,{file:s.file,span:s.span}),(0,K.jsx)(JS,{project:e,run:t,file:s.file,span:s.span}),(0,K.jsx)(ue,{project:e,id:r},r)]})}var QS=o(),$S=24,eC=12,tC=300,nC=new Set([`apps`,`packages`,`services`,`libs`,`modules`,`crates`,`projects`]),rC=/(^|\/)(__tests__|__mocks__|tests?|e2e|specs?|fixtures?)\/|\.(test|spec|e2e|stories)\.[a-z0-9]+$/i,iC=/(^|\/)([\w-]+\.config\.[cm]?[jt]sx?|\.?[\w-]*rc\.[cm]?[jt]s|(vite|vitest|jest|webpack|rollup|babel|eslint|prettier|tailwind|postcss|playwright|next|nuxt|svelte|astro|tsup|knip|commitlint|stylelint)\.[\w.-]*[cm]?[jt]s)$/i;function aC(e){return rC.test(e)?`tests`:iC.test(e)?`config`:`source`}var oC=e=>e.status!==`analyzed`,sC={"parse-failure":`could not be parsed`,"declaration-file":`type declarations`,"language-not-analyzed":`language not analyzed yet`,"too-large":`too large`,binary:`not text`,minified:`minified`,"invalid-utf8":`not UTF-8 text`,unreadable:`could not be read`,entitlement:`beyond the license`,frozen:`kept from an earlier analysis (beyond the license)`},cC={degraded:`partly analyzed`,not_analyzed:`not analyzed`,parse_error:`could not be parsed`},lC=(e,t)=>e<t?-1:+(e>t);function uC(e,t,n){let r={key:``,name:``,dirs:new Map,files:[],total:0,functions:0};for(let i of e){let e=(n?`${i.source}/${i.path}`:i.path).split(`/`);e.pop();let a=r,o=t[i.id]?.functions??0;a.total++,a.functions+=o;let s=``;for(let t of e){s=s?`${s}/${t}`:t;let e=a.dirs.get(t);e||(e={key:s,name:t,dirs:new Map,files:[],total:0,functions:0},a.dirs.set(t,e)),a=e,a.total++,a.functions+=o}a.files.push(i)}return r}function dC(e,t=!1,n=0){for(let[r,i]of e.dirs)e.dirs.set(r,dC(i,t,n+1));if(e.key!==``&&!(t&&n===1)&&e.files.length===0&&e.dirs.size===1){let t=[...e.dirs.values()][0];return{...t,name:`${e.name}/${t.name}`}}return e}function fC(e,t,n){let r=[],i=(e,a)=>{let o=[...e.dirs.values()].sort((e,t)=>{if(a===0){let n=+!nC.has(e.name.split(`/`)[0]),r=+!nC.has(t.name.split(`/`)[0]);if(n!==r)return n-r}return lC(e.name,t.name)});for(let e of o){let n=t.has(e.key);r.push({type:`dir`,key:e.key,name:e.name,depth:a,open:n,total:e.total,functions:e.functions}),n&&i(e,a+1)}for(let t of[...e.files].sort((e,t)=>lC(e.path,t.path))){let e=n[t.id];r.push({type:`file`,file:t,depth:a,label:t.path.slice(t.path.lastIndexOf(`/`)+1),...e?{hint:`${e.functions}ƒ`}:{}})}};return i(e,0),r}var pC=60;function mC(e,t){let n=new Set,r=e=>{for(let t of e.dirs.values())n.add(t.key),r(t)};if(t<=pC)return r(e),n;for(let t of e.dirs.values())if(n.add(t.key),nC.has(t.name.split(`/`).pop())||nC.has(t.name.split(`/`)[0]))for(let e of t.dirs.values())n.add(e.key);return n}var hC=e=>`veoflow.tree.${e}`;function gC(e){try{let t=localStorage.getItem(hC(e)),n=t?JSON.parse(t):[];return n.length>0?new Set(n):null}catch{return null}}function _C(e,t){try{localStorage.setItem(hC(e),JSON.stringify([...t]))}catch{}}function vC({project:e,files:t,counts:n,current:r,onOpen:i,run:a=null,onAnalyze:o,sources:s=[],scope:c=null,onScope:l}){let[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)({source:!0,tests:!1,config:!0}),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(new Set),[x,S]=(0,d.useState)(0),[C,w]=(0,d.useState)(600),[T,E]=(0,d.useState)(0),D=(0,d.useRef)(null),O=(0,d.useRef)(null),k=t;t=(0,d.useMemo)(()=>c?k.filter(e=>e.source===c):k,[k,c]);let A=(0,d.useMemo)(()=>s.length>1||new Set(k.map(e=>e.source)).size>1,[k,s.length]),j=(0,d.useMemo)(()=>new Map(s.map(e=>[e.id,e])),[s]),M=e=>{let t=j.get(e)?.analysis;return t?t.kind===`git`?`${t.branch??`detached`} · ${t.revision.slice(0,7)} · ${W(t.analyzedAt)}`:`plain folder · latest only`:``},N=(0,d.useMemo)(()=>{let e={source:0,tests:0,config:0,attention:0};for(let n of t)e[aC(n.path)]++,oC(n)&&e.attention++;return e},[t]),P=(0,d.useMemo)(()=>t.filter(e=>_?oC(e):e.id===r||h[aC(e.path)]||oC(e)),[t,h,_,r]),F=(0,d.useMemo)(()=>{let e=dC(uC(P,n,A),A);return c&&A?e.dirs.get(c)??{...e,dirs:new Map,files:[]}:e},[P,n,A,c]),I=(0,d.useRef)(!1);(0,d.useEffect)(()=>{!I.current&&e&&t.length!==0&&(I.current=!0,b(gC(e)??mC(F,t.length)))},[e,t,F]);let L=t.find(e=>e.id===r);(0,d.useEffect)(()=>{if(!L)return;let e=(A?`${L.source}/${L.path}`:L.path).split(`/`);e.pop(),b(t=>{let n=new Set(t),r=``,i=!1;for(let t of e)r=r?`${r}/${t}`:t,n.has(r)||(n.add(r),i=!0);return i?n:t})},[L?.id]);let R=(0,d.useMemo)(()=>{let e=p.trim().toLowerCase();return e?t.map(t=>{let n=t.path.toLowerCase(),r=n.slice(n.lastIndexOf(`/`)+1);return{f:t,rank:r.replace(/\.[^.]+$/,``)===e||r===e?0:r.startsWith(e)?1:r.includes(e)?2:n.includes(e)?3:-1,kind:aC(t.path)===`source`?0:1}}).filter(e=>e.rank>=0).sort((e,t)=>e.rank-t.rank||e.kind-t.kind||e.f.path.length-t.f.path.length||lC(e.f.path,t.f.path)).slice(0,tC).map(({f:e})=>{let t=e.path.includes(`/`)?e.path.slice(0,e.path.lastIndexOf(`/`)):``,n=A?j.get(e.source)?.name??e.source:``;return{type:`file`,file:e,depth:0,label:e.path.slice(e.path.lastIndexOf(`/`)+1),hint:[n,t].filter(Boolean).join(` · `)}}):fC(F,y,n)},[p,F,y,n,t,A,j]);(0,d.useEffect)(()=>{I.current&&e&&_C(e,y)},[y,e]),(0,d.useEffect)(()=>{T>=R.length&&E(Math.max(0,R.length-1))},[R.length,T]),(0,d.useEffect)(()=>{let e=D.current;if(!e)return;let t=new ResizeObserver(()=>w(e.clientHeight));return t.observe(e),()=>t.disconnect()},[]);let z=(0,d.useRef)(null),B=p.trim()!==``;(0,d.useEffect)(()=>{let e=r?`${r}\0${B}`:null;if(!r||z.current===e)return;let t=R.findIndex(e=>e.type===`file`&&e.file.id===r);if(t<0||!D.current)return;z.current=e;let n=t*$S,i=D.current;(n<i.scrollTop||n+$S>i.scrollTop+i.clientHeight)&&(i.scrollTop=Math.max(0,n-i.clientHeight/3),S(i.scrollTop)),E(t)},[r,R,B]),(0,d.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`p`&&(e.preventDefault(),O.current?.focus(),O.current?.select())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let V=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),H=e=>{let t=Math.max(0,Math.min(R.length-1,e)),n=D.current;if(n){let e=t*$S,r=n.scrollTop;e<r?r=e:e+$S>r+n.clientHeight&&(r=e+$S-n.clientHeight),n.scrollTop=r,(0,QS.flushSync)(()=>{S(r),E(t)})}else E(t);D.current?.querySelector(`[data-row="${t}"]`)?.focus({preventScroll:!0})},U=e=>{let t=R[e]?.depth??0;for(let n=e-1;n>=0;n--)if(R[n].type===`dir`&&R[n].depth<t)return n;return-1},G=e=>{let t=R[T];if(e.key===`ArrowDown`)H(T+1);else if(e.key===`ArrowUp`)H(T-1);else if(e.key===`Home`)H(0);else if(e.key===`End`)H(R.length-1);else if(e.key===`ArrowRight`&&t?.type===`dir`)t.open?H(T+1):V(t.key);else if(e.key===`ArrowLeft`){if(t?.type===`dir`&&t.open)V(t.key);else{let e=U(T);e>=0&&H(e)}}else return;e.preventDefault()},ee=Math.max(0,Math.floor(x/$S)-eC),te=Math.min(R.length,Math.ceil((x+C)/$S)+eC),ne=(e,t)=>N[e]===0?null:(0,K.jsxs)(`button`,{className:`chip`,"aria-pressed":!_&&h[e],"data-testid":`chip-${e}`,disabled:N[e]===0,onClick:()=>{v(!1),g(t=>({...t,[e]:!t[e]}))},children:[t,` `,(0,K.jsx)(`small`,{children:N[e]})]}),re=(0,d.useMemo)(()=>{let e=0,t=0;for(let n of a?.sources??[])e+=n.defaultExcluded?.length??0,t+=(n.ruleExcluded?.length??0)+(n.ruleExcludedMore??0);return{folders:e,paths:t}},[a]);return u&&e?(0,K.jsx)(`nav`,{className:`nav`,"aria-label":`Files`,children:(0,K.jsx)(uS,{project:e,files:t,run:a,onAnalyze:()=>{o?.(),f(!1)},onClose:()=>f(!1)})}):(0,K.jsxs)(`nav`,{className:`nav`,"aria-label":`Files`,children:[(0,K.jsxs)(`div`,{className:`nav-head`,children:[(s.length>1||c)&&(0,K.jsxs)(`label`,{className:`nav-scope`,children:[(0,K.jsx)(`span`,{className:`small muted`,children:`Scope`}),(0,K.jsxs)(`select`,{"data-command":`scope-source`,value:c??``,onChange:e=>l?.(e.target.value||null),children:[(0,K.jsx)(`option`,{value:``,children:`All repositories`}),s.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))]})]}),(0,K.jsx)(`input`,{ref:O,className:`nav-filter`,"data-testid":`file-filter`,type:`search`,placeholder:`Filter ${t.length} files… ⌘P`,"aria-label":`Filter files`,value:p,onChange:e=>{m(e.target.value),D.current&&(D.current.scrollTop=0),E(0)},onKeyDown:e=>{if(e.key===`Enter`&&p.trim()){let e=R.find(e=>e.type===`file`);e?.type===`file`&&i(e.file.id)}else e.key===`ArrowDown`?(e.preventDefault(),H(0)):e.key===`Escape`&&m(``)}}),(0,K.jsxs)(`div`,{className:`nav-chips`,role:`group`,"aria-label":`Show`,children:[ne(`source`,`Source`),ne(`tests`,`Tests`),ne(`config`,`Config`),N.attention>0&&(0,K.jsxs)(`button`,{className:`chip attention`,"aria-pressed":_,"data-testid":`chip-attention`,title:`Files that were not fully analyzed`,onClick:()=>v(e=>!e),children:[`⚠ `,(0,K.jsx)(`small`,{children:N.attention})]})]})]}),(0,K.jsxs)(`div`,{className:`nav-list`,ref:D,role:`tree`,"aria-label":`Files`,onScroll:e=>S(e.currentTarget.scrollTop),onKeyDown:G,children:[R.length===0&&t.length>0&&(0,K.jsx)(`p`,{className:`hint`,children:`No files match.`}),(0,K.jsx)(`div`,{style:{height:R.length*$S,position:`relative`},children:R.slice(ee,te).map((e,t)=>{let n=ee+t,a={top:n*$S,paddingLeft:8+e.depth*14};if(e.type===`dir`&&A&&!c&&e.depth===0&&j.has(e.key))return(0,K.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-expanded":e.open,"aria-level":1,"aria-setsize":R.length,"aria-posinset":n+1,tabIndex:n===T?0:-1,className:`row dir repo`,"data-testid":`repo-row`,"data-source":e.key,style:a,title:j.get(e.key)?.root??e.key,onClick:()=>{E(n),V(e.key)},children:[(0,K.jsx)(`span`,{className:`caret`,children:e.open?`▾`:`▸`}),(0,K.jsx)(`strong`,{className:`name`,children:j.get(e.key)?.name??e.key}),(0,K.jsx)(`small`,{className:`muted repo-hint`,children:M(e.key)}),(0,K.jsx)(`small`,{className:`count`,title:`${e.total} files, ${e.functions} functions`,children:e.total})]},`r:${e.key}`);if(e.type===`dir`)return(0,K.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-expanded":e.open,"aria-level":e.depth+1,"aria-setsize":R.length,"aria-posinset":n+1,tabIndex:n===T?0:-1,className:`row dir`,style:a,title:e.key,onClick:()=>{E(n),V(e.key)},children:[(0,K.jsx)(`span`,{className:`caret`,children:e.open?`▾`:`▸`}),(0,K.jsx)(`span`,{className:`name`,children:e.name}),(0,K.jsx)(`small`,{className:`count`,title:`${e.total} files, ${e.functions} functions`,children:e.total})]},`d:${e.key}`);let o=e.file;return(0,K.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-level":e.depth+1,"aria-setsize":R.length,"aria-posinset":n+1,"aria-selected":o.id===r,tabIndex:n===T?0:-1,"data-command":`open-file`,"data-file":o.path,className:`row file ${o.id===r?`current`:``} ${o.status}`,style:a,title:o.status===`analyzed`?o.path:`${o.path}: ${cC[o.status]??o.status}${o.reason?` (${sC[o.reason]??o.reason})`:``}`,onClick:()=>{E(n),i(o.id)},children:[(0,K.jsx)(`span`,{className:`caret`}),(0,K.jsxs)(`span`,{className:`name`,children:[e.label,p.trim()&&e.hint?(0,K.jsxs)(`small`,{className:`muted`,children:[` `,e.hint]}):null]}),o.origin&&(0,K.jsx)(`small`,{className:`origin ${o.origin}`,title:o.origin===`library`?`Installed library code, not the project's own`:o.origin===`tool`?`A tool's or coding agent's workspace, not the project's own code`:`Generated output, not the project's own code`,children:o.origin}),oC(o)?(0,K.jsxs)(`small`,{className:`warn`,"aria-label":`${cC[o.status]??o.status}${o.reason?`: ${sC[o.reason]??o.reason}`:``}`,children:[`⚠ `,sC[o.reason??``]??o.reason??o.status]}):!p.trim()&&e.hint&&(0,K.jsx)(`small`,{className:`count`,children:e.hint})]},`f:${o.id}`)})})]}),e&&o&&(0,K.jsxs)(`div`,{className:`nav-foot`,children:[(0,K.jsx)(`small`,{className:`muted`,"data-testid":`left-out`,children:re.folders+re.paths===0?``:`Left out: ${[re.folders?`${re.folders} by default (libraries, generated, tools)`:``,re.paths?`${re.paths} by your choice`:``].filter(Boolean).join(`, `)}`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{"data-testid":`choose-files`,onClick:()=>f(!0),title:`Choose which files are analyzed`,children:`Choose files…`})]})]})}m_.use(mx);function yC(e){try{return bC(e)}catch{return xC(e)}}function bC(e){let t=m_({headless:!0,styleEnabled:!0,elements:[...e.nodes.map(e=>({data:{id:e.id,w:e.w,h:e.h}})),...e.edges.map(e=>({data:{id:e.id,source:e.source,target:e.target}}))],style:[{selector:`node`,style:{width:`data(w)`,height:`data(h)`}}]}),n=e=>t.layout({name:`dagre`,rankDir:e,nodeSep:14,rankSep:e===`LR`?70:50,fit:!1,animate:!1}).run();try{n(`LR`);let r=t.elements().boundingBox(),{w:i,h:a}=e.canvas;r.w*e.fitZoom>i-2*e.pad&&r.w/Math.max(1,r.h)>i/a&&n(`TB`)}catch(e){throw t.destroy(),e}let r={};for(let e of t.nodes().toArray())r[e.id()]={...e.position()};return t.destroy(),r}function xC(e){let t=Math.max(1,Math.ceil(Math.sqrt(e.nodes.length))),n=Math.max(40,...e.nodes.map(e=>e.w))+24,r={};return e.nodes.forEach((e,i)=>{r[e.id]={x:i%t*n,y:Math.floor(i/t)*40}}),r}var SC=null,CC=typeof Worker>`u`,wC=0,TC=new Map,EC=e=>new Promise(t=>setTimeout(()=>t(yC(e)),0));function DC(){try{let e=new Worker(new URL(`/assets/callLayout.worker-BugXMtxI.js`,``+import.meta.url),{type:`module`});return e.addEventListener(`message`,e=>{let t=TC.get(e.data.id);t&&(TC.delete(e.data.id),e.data.error===void 0?t.resolve(e.data.positions):(console.error(`veoflow: laying out this graph failed; placed in a grid`,e.data.error),t.resolve(xC(t.input))))}),e.addEventListener(`error`,t=>{console.error(`veoflow: the layout worker failed; laying out on the page instead`,t),CC=!0,e.terminate(),SC=null;for(let[e,t]of TC)TC.delete(e),EC(t.input).then(t.resolve)}),e}catch{return CC=!0,null}}function OC(e){if(TC.size>0&&SC&&(SC.terminate(),SC=null,TC.clear()),!CC&&!SC&&(SC=DC()),!SC)return EC(e);let t=++wC;return new Promise(n=>{TC.set(t,{input:e,resolve:n}),SC.postMessage({id:t,input:e})})}var kC=2,AC=40,jC=25,MC=7;function NC(e,t,n=null){let r=new Map,i=(e,t)=>{e!==t&&(r.has(e)||r.set(e,new Set),r.get(e).add(t))};for(let t of e.calls)i(t.from,t.to),i(t.to,t.from);let a=e=>r.get(e)?.size??0,o=(e,t)=>[...e].sort((e,t)=>a(t)-a(e)||(e<t?-1:1)).slice(0,t),s=new Set(e.functions.map(e=>e.id));if(n&&s.has(n[0])&&s.has(n[1])){let e=new Set(n);for(let t of n)for(let n of o(r.get(t)??[],MC))e.add(n);return e}if(t&&s.has(t)){let e=new Set([t]),n=o(r.get(t)??[],jC);for(let t of n)e.add(t);for(let t=1;t<kC&&e.size<AC;t++)for(let t of n)for(let n of o(r.get(t)??[],5))e.size<AC&&e.add(n);return e}return new Set(o(s,AC))}var PC=e=>`site:${e}`,FC=(e,t)=>`pair:${e}->${t}`;m_.use(mx);var IC=.85,LC=1.25,RC=45,zC=.68,BC=4,VC=36,HC=e=>Math.max(36,String(e.data(`label`)).length*7+18);function UC(e){let t=e.nodes(`[kind = "function"], [kind = "port"], [kind = "ghost"]`).not(`.hidden`),n=e.edges(`[kind = "call"], [kind = "ghost-call"]`).not(`.hidden`),r=t.filter(e=>e.connectedEdges(`[kind = "call"], [kind = "ghost-call"]`).not(`.hidden`).empty());return{fns:t,isolated:r,connected:t.difference(r).union(n)}}var WC=300;function GC(e){let{connected:t}=UC(e);return{nodes:t.nodes().toArray().map(e=>({id:e.id(),w:e.outerWidth(),h:e.outerHeight()})),edges:t.edges().map(e=>({id:e.id(),source:e.source().id(),target:e.target().id()})),canvas:{w:Math.max(1,e.width()),h:Math.max(1,e.height())},fitZoom:zC,pad:VC}}function KC(e,t){let{fns:n,isolated:r,connected:i}=UC(e),a=e=>i.layout({name:`dagre`,rankDir:e,nodeSep:14,rankSep:e===`LR`?70:50,fit:!1}).run(),o={w:Math.max(1,e.width()),h:Math.max(1,e.height())};if(t)e.batch(()=>{for(let e of i.nodes().toArray()){let n=t[e.id()];n&&e.position(n)}});else if(i.nonempty()){a(`LR`);let e=i.boundingBox();e.w*zC>o.w-72&&e.w/Math.max(1,e.h)>o.w/o.h&&a(`TB`)}let s=r.toArray(),c=i.nonempty()?i.boundingBox():{x1:0,y1:0,x2:0,y2:0,w:0,h:0},l=i.nonempty()?c.y2+48:0,u=Math.max(0,...s.map(e=>HC(e)))+24,d=Math.max(BC,Math.floor(Math.max(c.w,o.w/IC-72)/u));s.forEach((e,t)=>{e.position({x:c.x1+t%d*u+u/2,y:l+Math.floor(t/d)*34})});for(let e of n.toArray()){let t=e.outgoers(`node[kind = "site"]`).not(`.hidden`).toArray();if(t.length===0)continue;let n=e.position(),r=n.x+HC(e)/2+48;t.forEach((e,i)=>e.position({x:r+HC(e)/2,y:n.y+(i-(t.length-1)/2)*26}))}}function qC(e,t){if(t.empty())return;e.fit(t,VC);let n=e.zoom(),r=t.nodes().length<=RC?zC:IC;if(n>LC)e.zoom(LC),e.center(t);else if(n<r){let n=t.boundingBox();e.zoom(r),e.pan({x:VC-n.x1*r,y:VC-n.y1*r})}}function JC(e,t){if(t.edges().nonempty()||t.nodes(`[kind = "site"]`).nonempty()){qC(e,t.union(t.edges().connectedNodes()).union(t.nodes().incomers(`node`)));return}let n=t,r=n.renderedBoundingBox(),i=e.width(),a=e.height();r.x1>=0&&r.y1>=0&&r.x2<=i&&r.y2<=a||e.animate({center:{eles:n}},{duration:250})}function YC({graph:e,showUnresolved:t,selection:n,onSelect:r,onClear:i,focus:a,sitesFor:o,answered:s,marks:c,only:l=null,onContext:f,extraSite:p=null}){let m=(0,d.useRef)(null),h=(0,d.useRef)(null),g=(0,d.useRef)(l);g.current=l;let _=(0,d.useRef)(f);_.current=f,(0,d.useEffect)(()=>{h.current&&ve(h.current,l)},[l]);let v=(0,d.useRef)(0),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(0);(0,d.useEffect)(()=>{let n=new Set(e.functions.map(e=>e.id)),a=new Map;for(let t of e.calls){if(!t.crossFile)continue;let e=n.has(t.from)?t.to:t.from;if(n.has(e)||a.has(e))continue;let r=t.function.path.split(`/`).pop()??t.function.path;a.set(e,`${r} › ${V(t.function.qualifiedName,void 0,t.function.title).name}`)}for(let e of a.keys())n.add(e);let o=new Set(e.calls.filter(e=>e.from===e.to).map(e=>e.from)),s=new Map;for(let t of e.calls){if(t.from===t.to||!n.has(t.from)||!n.has(t.to))continue;let e=FC(t.from,t.to),r=s.get(e);r?r.calls.push(t.id):s.set(e,{from:t.from,to:t.to,calls:[t.id]})}let c=e.functions.map(e=>V(e.qualifiedName,e.evidence.span.start.line,e.title).name),l=new Set(c.filter((e,t)=>c.indexOf(e)!==t)),d=[...e.functions.map((e,t)=>{let n=c[t],r=l.has(n)&&!n.includes(`· line`)?`${n} · line ${e.evidence.span.start.line}`:n;return{data:{id:e.id,label:o.has(e.id)?`${r} ↻`:r,kind:`function`},classes:e.qualifiedName===`<module>`?`module`:``}}),...[...a].map(([e,t])=>({data:{id:e,label:t,kind:`port`},classes:`port`})),...[...s].map(([e,t])=>({data:{id:e,source:t.from,target:t.to,kind:`call`,calls:t.calls,label:t.calls.length>1?`×${t.calls.length}`:``}}))];if(t||p){let r=new Map;for(let i of e.unresolved){if(!n.has(i.enclosingFn)||!(t&&u(i))&&i.id!==p)continue;let e=`${i.enclosingFn}\u0000${i.expression}\u0000${i.status}`,a=r.get(e);a?a.ids.push(i.id):r.set(e,{fn:i.enclosingFn,expression:i.expression,ids:[i.id],status:i.status})}for(let e of r.values()){let t=PC(e.ids[0]),n=e.expression.length>40?`${e.expression.slice(0,39)}…`:e.expression;d.push({data:{id:t,label:e.ids.length>1?`${n} ×${e.ids.length}`:n,kind:`site`,ids:e.ids},classes:`site ${e.status}`},{data:{id:`edge:${t}`,source:e.fn,target:t,kind:`site-edge`},classes:`site-edge`})}}let f=m_({container:m.current,elements:d,autounselectify:!0,layout:{name:`preset`},minZoom:.15,maxZoom:3,style:[{selector:`node`,style:{label:`data(label)`,"font-size":12,"text-valign":`center`,"text-halign":`center`,shape:`round-rectangle`,width:HC,height:22,"background-color":`#e8eef8`,"border-width":1,"border-color":`#6b87b8`,color:`#1d2330`}},{selector:`node.module`,style:{"background-color":`#f3f3f3`,"border-color":`#aaa`}},{selector:`node.port`,style:{"background-color":`#fff`,"border-style":`dashed`,"border-color":`#7a8aa0`,color:`#4a5568`}},{selector:`node.site`,style:{"background-color":`#fff`,"border-style":`dashed`,"border-color":`#c07a00`,color:`#8a5a00`}},{selector:`node.site.awaiting-link, node.site.external`,style:{"border-color":`#999`,color:`#777`}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"target-arrow-shape":`triangle`,"line-color":`#8fa6cc`,"target-arrow-color":`#8fa6cc`,label:`data(label)`,"font-size":10,color:`#5c6678`,"text-background-color":`#fafbfc`,"text-background-opacity":1,"text-background-padding":`2px`}},{selector:`edge.site-edge`,style:{"line-style":`dashed`,"line-color":`#c9a45c`,"target-arrow-color":`#c9a45c`}},...xe,_e,{selector:`.hidden`,style:{display:`none`}},{selector:`node.answered`,style:{"border-width":2,"border-color":`#d99a00`,"background-color":`#fff4cc`}},{selector:`.faded`,style:{opacity:.22}},{selector:`node.picked`,style:{"border-width":2,"border-color":`#2f5fbf`,"background-color":`#d6e3fa`}},{selector:`edge.picked`,style:{"line-color":`#2f5fbf`,"target-arrow-color":`#2f5fbf`,width:3}}]});return f.on(`tap`,`node, edge`,e=>{let t=e.target.data(`kind`),n=e.target.id();t===`function`?r({kind:`function`,id:n}):t===`call`?r({kind:`call`,id:e.target.data(`calls`)[0]}):t===`site`&&r({kind:`site`,id:e.target.data(`ids`)[0]})}),f.on(`tap`,e=>{e.target===f&&i()}),h.current=f,ve(f,g.current),f.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`function`?`function`:t.kind===`call`?`edge`:null;if(!n||!m.current)return;let r=m.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};_.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),m.current&&(m.current.veoCy=f),()=>{h.current=null,f.destroy()}},[e,t,r,i,p]);let C=(c?.removed??[]).filter(t=>t.file===e.file.id&&(t.type===`Function`||t.type===`CALLS`)).map(e=>e.id).join(`
|
|
339
339
|
`);(0,d.useEffect)(()=>{let t=h.current;t&&t.batch(()=>{if(t.elements(`.ghost`).remove(),t.elements().removeClass(`diff-added diff-removed diff-changed`),!c)return;t.nodes(`[kind = "function"]`).forEach(e=>{let t=c.byId.get(e.id());t&&e.addClass(be(t))}),t.edges(`[kind = "call"]`).forEach(e=>{let t=e.data(`calls`).map(e=>c.byId.get(e)).find(Boolean);t&&e.addClass(be(t))});let n=new Set(t.nodes().map(e=>e.id())),r=new Set,i=[];for(let t of c.removed){if(t.type!==`Function`||t.file!==e.file.id||n.has(t.id))continue;let a=t.fact;r.add(t.id),i.push({data:{id:t.id,label:`${a.qualifiedName??a.name??t.id} (removed)`,kind:`ghost`},classes:`diff-removed ghost`})}for(let e of c.removed){if(e.type!==`CALLS`)continue;let t=e.fact,a=e=>!!e&&(n.has(e)||r.has(e));a(t.from)&&a(t.to)&&t.from!==t.to&&i.push({data:{id:`gone:${e.id}`,source:t.from,target:t.to,kind:`ghost-call`,label:``},classes:`diff-removed ghost`})}i.length&&t.add(i)})},[c,e,t,p]);let w=a?o:null;return(0,d.useEffect)(()=>{let e=h.current;if(!e)return;e.batch(()=>{if(e.elements().removeClass(`hidden`),a){let t=e.nodes().filter(e=>e.data(`kind`)===`function`?!a.has(e.id()):e.incomers(`node`).first().id()!==w);t.addClass(`hidden`),t.connectedEdges().addClass(`hidden`)}});let t=++v.current;if(UC(e).connected.nodes().length<=WC){KC(e),qC(e,e.elements().not(`.hidden`)),g.current&&ve(e,g.current),b(!1);return}b(!0),OC(GC(e)).then(n=>{t===v.current&&h.current===e&&(KC(e,n),qC(e,e.elements().not(`.hidden`)),g.current&&ve(e,g.current),b(!1),S(e=>e+1))})},[a,e,t,w,C,p]),(0,d.useEffect)(()=>{let t=h.current;if(!t||(t.batch(()=>{t.elements().removeClass(`picked faded`)}),m.current?.setAttribute(`data-picked`,``),!n))return;let r=n.kind===`site`?t.nodes(`[kind = "site"]`).filter(e=>e.data(`ids`).includes(n.id)):t.getElementById(n.id);if(r.empty()&&n.kind===`call`&&(r=t.edges().filter(e=>(e.data(`calls`)??[]).includes(n.id)),r.empty())){let i=e.calls.find(e=>e.id===n.id);i&&(r=t.getElementById(i.from))}if(r.empty())return;m.current?.setAttribute(`data-picked`,`${n.kind}:${n.id}`);let i=r.union(r.nodes().closedNeighborhood()).union(r.edges().connectedNodes());t.batch(()=>{r.addClass(`picked`),a||t.elements().not(i).addClass(`faded`)}),JC(t,r)},[n,e,t,a,x,p]),(0,d.useEffect)(()=>{let e=h.current;e&&e.batch(()=>{e.nodes().removeClass(`answered`),s&&e.nodes().filter(e=>s.has(e.id())).addClass(`answered`)})},[s,e,t,a,p]),(0,K.jsxs)(`div`,{className:`graph-wrap`,children:[(0,K.jsx)(`div`,{className:`graph`,ref:m,"data-testid":`graph`,"data-laying-out":y||void 0}),y&&(0,K.jsx)(`div`,{className:`laying-out`,children:`Laying out…`}),(0,K.jsx)(`button`,{className:`fit`,title:`Fit the graph to the view`,"aria-label":`Fit the graph to the view`,onClick:()=>{let e=h.current;e&&qC(e,e.elements().not(`.hidden`))},children:`Fit`})]})}function XC({run:e,quiet:t=!1}){let n=e?.sources??[],r=n.flatMap(e=>(e.notices??[]).map(t=>n.length>1?`${e.sourceId}: ${t}`:t));return r.length?(0,K.jsx)(`ul`,{className:`run-notices${t?` quiet`:``}`,"data-testid":`run-notices`,"aria-label":`Notes from the analysis`,children:r.map(e=>(0,K.jsx)(`li`,{children:e},e))}):null}function ZC({project:e,files:t,run:n,counts:r,source:i,onOpen:a,onQuestions:o}){let[s,c]=(0,d.useState)(null);(0,d.useEffect)(()=>{let t=!1;return L.totals(e,30,i??void 0).then(e=>!t&&c(e),()=>!t&&c(`error`)),()=>{t=!0}},[e,t,i]);let l=s&&s!==`error`?s:null,u=(0,d.useMemo)(()=>(l?.mostCalled??[]).filter(e=>aC(e.path)===`source`).slice(0,5).map(e=>({key:e.id,name:e.name,count:e.calls})),[l]),f=(0,d.useMemo)(()=>i?t.filter(e=>e.id.startsWith(`${i}:`)):t,[t,i]),p=(0,d.useMemo)(()=>f.reduce((e,t)=>e+(r[t.id]?.functions??0),0),[f,r]),m=(0,d.useMemo)(()=>f.filter(e=>aC(e.path)===`source`&&!e.origin).map(e=>({f:e,n:r[e.id]?.functions??0})).filter(e=>e.n>0).sort((e,t)=>t.n-e.n||(e.f.path<t.f.path?-1:1)).slice(0,5),[f,r]),h=(0,d.useMemo)(()=>new Map(t.map(e=>[e.id,e.path])),[t]),g=(0,d.useMemo)(()=>new Set(f.map(e=>e.id.slice(0,e.id.indexOf(`:`)))).size>1,[f]),_=e=>e.toLocaleString(`en-US`);return(0,K.jsxs)(`div`,{className:`overview`,"data-testid":`overview`,children:[(0,K.jsx)(XC,{run:n,quiet:!0}),(0,K.jsxs)(`dl`,{className:`stats`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`files`}),(0,K.jsx)(`dd`,{children:_(f.length)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`functions`}),(0,K.jsx)(`dd`,{children:_(p)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`dt`,{children:[`calls`,l?.stage2&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`br`,{}),(0,K.jsxs)(`small`,{children:[_(l.calls.acrossFiles),` across files`]})]})]}),(0,K.jsx)(`dd`,{"data-testid":`overview-calls`,children:l?_(l.calls.withinFiles+l.calls.acrossFiles):s===`error`?`?`:`…`})]}),(0,K.jsxs)(`div`,{className:`muted-stat`,children:[(0,K.jsxs)(`dt`,{children:[`open calls`,(0,K.jsx)(`br`,{}),(0,K.jsx)(`small`,{children:`calls the analysis couldn't follow`})]}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`button`,{className:`stat-link`,"data-testid":`overview-open-calls`,onClick:o,title:`Show them in Findings (the same count as there)`,children:l?_(l.openCalls):s===`error`?`?`:`…`})})]})]}),(0,K.jsxs)(`div`,{className:`columns`,children:[(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h4`,{children:`Largest files`}),(0,K.jsx)(`ul`,{children:m.map(({f:e,n:t})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link-row`,onClick:()=>a(e.id),title:e.path,children:[(0,K.jsx)(`span`,{className:`name`,children:g?`${e.id.slice(0,e.id.indexOf(`:`))} › ${e.path}`:e.path}),(0,K.jsxs)(`small`,{children:[t,` function`,t===1?``:`s`]})]})},e.id))})]}),(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h4`,{children:`Most called`}),(0,K.jsx)(`ul`,{children:u.map(e=>{let t=e.key.slice(0,e.key.lastIndexOf(`:`));return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link-row`,onClick:()=>a(t),title:`${e.name??e.key} in ${h.get(t)??t}`,children:[(0,K.jsxs)(`span`,{className:`name`,children:[V(e.name??e.key).name,u.filter(t=>t.name===e.name).length>1&&(0,K.jsxs)(`small`,{className:`muted`,children:[` `,(h.get(t)??t).split(`/`).pop()]})]}),(0,K.jsxs)(`small`,{children:[e.count,` call`,e.count===1?``:`s`]})]})},e.key)})})]})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`Open a file on the left, or ask a question above (⌘K).`})]})}function QC({onClose:e,onSaved:t}){let[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(``),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(``),[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!1),h=(0,d.useRef)(null);(0,d.useEffect)(()=>{L.settings().then(({model:e})=>{r(e),a(e.baseUrl),s(e.model),setTimeout(()=>h.current?.focus(),0)},e=>f({ok:!1,text:`Could not load the settings: ${e.message??String(e)}`}))},[]),(0,d.useEffect)(()=>{let t=t=>t.key===`Escape`&&e();return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let g=async(e={})=>{m(!0),f(null);try{let{model:n}=await L.saveSettings({baseUrl:i,model:o,...c.trim()?{apiKey:c.trim()}:{},...e});return r(n),l(``),t(n),n}catch(e){return f({ok:!1,text:e.message??String(e)}),null}finally{m(!1)}},[_,v]=(0,d.useState)(!1),y=async(t=!1)=>{if(!t&&(c.trim()||n?.apiKeySet)){m(!0),f(null);let e=!1;try{let t=await L.testSettings({baseUrl:i,model:o,...c.trim()?{apiKey:c.trim()}:{}});e=t.ok,t.ok||f({ok:!1,text:t.message})}catch(e){f({ok:!1,text:e.message??String(e)})}finally{m(!1)}if(!e){v(!0);return}}await g()&&e()},b=async()=>{m(!0),f(null);try{let e=await L.testSettings({baseUrl:i,model:o,...c.trim()?{apiKey:c.trim()}:{}});f({ok:e.ok&&e.toolCalls,text:e.message})}catch(e){f({ok:!1,text:e.message??String(e)})}finally{m(!1)}};return(0,K.jsx)(`div`,{className:`backdrop`,onMouseDown:t=>t.target===t.currentTarget&&e(),children:(0,K.jsxs)(`form`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,"data-testid":`settings-dialog`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,K.jsx)(`h2`,{id:`settings-title`,children:`Settings`}),(0,K.jsxs)(`p`,{className:`muted`,children:[`Built-in questions work without a model. To ask anything, connect a model through`,` `,(0,K.jsx)(`a`,{href:`https://openrouter.ai/keys`,target:`_blank`,rel:`noreferrer`,children:`OpenRouter`}),` `,`(or any OpenAI-compatible endpoint) with your own key.`]}),(0,K.jsxs)(`fieldset`,{disabled:!n,className:`plain`,children:[(0,K.jsxs)(`label`,{children:[`Model`,(0,K.jsx)(`input`,{ref:h,"data-testid":`settings-model`,value:o,onChange:e=>s(e.target.value),placeholder:`anthropic/claude-sonnet-5.5`,spellCheck:!1}),(0,K.jsx)(`small`,{className:`muted`,children:`An OpenRouter model id that supports tool calls.`})]}),(0,K.jsxs)(`label`,{children:[`API key`,(0,K.jsx)(`input`,{"data-testid":`settings-key`,type:`password`,autoComplete:`off`,value:c,onChange:e=>l(e.target.value),placeholder:n?.apiKeySet?`Saved (…${n.apiKeyHint})${n.keySource===`env`?` from OPENROUTER_API_KEY`:``}`:`sk-or-…`,spellCheck:!1}),(0,K.jsx)(`small`,{className:`muted`,children:`Stored only on this computer, in the veoflow folder (readable by you only). It is never shown again.`})]}),(0,K.jsxs)(`details`,{children:[(0,K.jsx)(`summary`,{children:`Advanced`}),(0,K.jsxs)(`label`,{children:[`Base URL`,(0,K.jsx)(`input`,{"data-testid":`settings-base-url`,value:i,onChange:e=>a(e.target.value),placeholder:`https://openrouter.ai/api/v1`,spellCheck:!1})]})]})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`When a model answers, your question and the graph data it looks up (names, file paths, line numbers) are sent to the provider. Nothing is sent for built-in questions.`}),u&&(0,K.jsx)(`p`,{className:u.ok?`ok`:`error`,role:`status`,"data-testid":`settings-status`,children:u.text}),(0,K.jsxs)(`div`,{className:`buttons`,children:[n?.apiKeySet&&n.keySource===`config`&&(0,K.jsx)(`button`,{type:`button`,className:`danger`,disabled:p,onClick:()=>void g({apiKey:null}),"data-testid":`settings-remove-key`,children:`Remove key`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{type:`button`,disabled:p||!n,onClick:()=>void b(),"data-testid":`settings-test`,children:`Test connection`}),(0,K.jsx)(`button`,{type:`button`,onClick:e,children:`Cancel`}),_&&(0,K.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void y(!0),"data-testid":`settings-save-anyway`,children:`Save anyway`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:p||!n,"data-testid":`settings-save`,children:`Save`})]})]})})}function $C(e,t){if(t.type===`undo`)return C(e);if(t.type===`redo`)return w(e);if(t.type===`load`)return T(t.view)===T(e.present)?e:{past:[...e.past,e.present],present:t.view,future:[]};let n={name:t.name,...t.args?{args:t.args}:{}};try{return t.type===`reset`?{...e,present:S(x(e.present),n).present}:S(e,n)}catch(t){return console.warn(t),e}}var ew=[{id:`stage1`,name:`Functions & calls`,release:`R1`},{id:`stage2`,name:`Cross-file links`,release:`R2`},{id:`stage3`,name:`APIs & data`,release:`R4`},{id:`stage4`,name:`Runtime`,release:`R11`},{id:`stage5`,name:`Deployment`,release:`R10`}];function tw(){let[e,t]=(0,d.useReducer)($C,void 0,()=>x(D(location.hash.slice(1)))),n=e.present,r=(0,d.useCallback)((e,n)=>t({type:`command`,name:e,...n?{args:n}:{}}),[]),[i,a]=(0,d.useState)([]),o=(0,d.useRef)(!0),[s,c]=(0,d.useState)(!1),[l,f]=(0,d.useState)([]),[p,m]=(0,d.useState)({}),[h,g]=(0,d.useState)(null),[_,y]=(0,d.useState)(`file`),[b,S]=(0,d.useState)(``),[C,w]=(0,d.useState)(null),[E,j]=(0,d.useState)(!1),[P,F]=(0,d.useState)(!1),[I,z]=(0,d.useState)(null),[B,H]=(0,d.useState)(null),[U,W]=(0,d.useState)(null),[G,ee]=(0,d.useState)([]),[ne,re]=(0,d.useState)([]),q=(0,d.useMemo)(()=>new Set(ne.flatMap(e=>[...e.changed,...e.removed].map(t=>`${e.sourceId}:${t}`))),[ne]),[ie,ae]=(0,d.useState)(`pending`),oe=(0,d.useRef)(!1);oe.current=ie===`running`;let[se,le]=(0,d.useState)(``),[ue,de]=(0,d.useState)(``),[fe,pe]=(0,d.useState)(``),[me,he]=(0,d.useState)(!1),[ge,_e]=(0,d.useState)(null),[ve,be]=(0,d.useState)(null),[xe,Se]=(0,d.useState)(null),[Ce,we]=(0,d.useReducer)(e=>e+1,0);N(n.run);let Te=(0,d.useRef)(!0);(0,d.useEffect)(()=>{if(Te.current){Te.current=!1;return}we()},[n.run]);let Ee=(0,d.useRef)(n);Ee.current=n,(0,d.useEffect)(()=>{let e=e=>{let{run:n,reason:r}=e.detail??{};Ee.current.run&&n===Ee.current.run&&(t({type:`reset`,name:`openRun`,args:{}}),pe(r===`history`?`That run is older than the 30 days of history this license shows, so the latest analysis is shown.`:`That run is no longer available (a newer draft or analysis replaced it), so the latest analysis is shown.`))};return window.addEventListener(`veo-run-gone`,e),()=>window.removeEventListener(`veo-run-gone`,e)},[]);let De=n.run??I,Oe=Wx(n.project,n.compare,Ce),ke=(0,d.useMemo)(()=>ye(Oe.data),[Oe.data]),{groups:Ae}=jx(n.project,De,0,n.source),je=(0,d.useCallback)((e,t)=>r(`select`,{kind:`function`,id:e,file:t}),[r]),Me=(0,d.useCallback)(e=>{let t=e.file,i=e=>n.tab!==e&&r(`showTab`,{tab:e});if(e.change===`removed`){t&&e.type!==`File`&&ke?.fileFacts.get(t)!==`removed`&&(i(`file`),r(`openFile`,{file:t}));return}switch(e.type){case`Function`:if(t)return r(`select`,{kind:`function`,id:e.id,file:t});break;case`CALLS`:case`CALLS_CROSS_FILE`:if(t)return r(`select`,{kind:`call`,id:e.id,file:t});break;case`UnresolvedCallSite`:if(t)return r(`select`,{kind:`site`,id:e.id,file:t});break;case`IMPORTS`:case`UnresolvedImport`:if(t)return r(`openImportsFile`,{file:t,pick:e.id});break;case`Group`:return i(`imports`),r(`openGroup`,{group:e.id});case`DEPENDS_ON`:return i(`imports`),r(`openGroup`,{group:String(e.fact.from)})}t&&(i(`file`),r(`openFile`,{file:t}))},[r,n.tab,ke]),[Ne,Pe]=(0,d.useState)(null),[Fe,Ie]=(0,d.useState)(null),Le=(0,d.useRef)(n.project);Le.current=n.project;let Re=(0,d.useRef)(n.file);Re.current=n.file;let ze=(0,d.useRef)(n.source);ze.current=n.source;let[Be,Ve]=(0,d.useState)(!1),[He,Ue]=(0,d.useState)([]),[We,Ge]=(0,d.useState)([]),[Ke,qe]=(0,d.useState)(null),[J,Je]=(0,d.useState)(!1),[Ye,Xe]=(0,d.useState)(!1),[Ze,Y]=(0,d.useState)(0),Qe=(0,d.useRef)(null),$e=(0,d.useRef)(null),[et,tt]=(0,d.useState)(!1),[nt,rt]=(0,d.useState)(null);(0,d.useEffect)(()=>{if(Y(0),!Be)return;let e=Date.now(),t=setInterval(()=>Y(Math.round((Date.now()-e)/1e3)),1e3);return()=>clearInterval(t)},[Be,Fe]),(0,d.useEffect)(()=>{L.settings().then(e=>qe(e.model),()=>void 0)},[]);let it=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=`#${T(n)}`,t=JSON.stringify([n.project,n.file,n.selection,n.tab,n.group,n.fileLevel]);if(location.hash!==e){let r=T(D(location.hash.slice(1)))===T(n);it.current!==null&&it.current!==t&&!r?window.history.pushState(null,``,e):window.history.replaceState(null,``,e)}it.current=t},[n]),(0,d.useEffect)(()=>{let e=()=>t({type:`load`,view:D(location.hash.slice(1))});return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,d.useEffect)(()=>{if(n.project||!i.some(e=>e.findingsPending))return;let e=setTimeout(()=>{L.projects(!0).then(({projects:e})=>a(e),()=>void 0)},2e3);return()=>clearTimeout(e)},[i,n.project]),(0,d.useEffect)(()=>{let e=!1;return L.projects(!n.project).then(({projects:r})=>{if(e)return;a(r),c(!0);let i=r.some(e=>e.id===n.project);n.project&&!i&&de(`Project ${n.project} was not found.`),(o.current&&!n.project||n.project&&!i)&&t(r.length===1?{type:`reset`,name:`selectProject`,args:{project:r[0].id}}:{type:`reset`,name:`goHome`,args:{}}),o.current=!1},t=>!e&&de(t.message)),()=>{e=!0}},[Ce,n.project===null]),(0,d.useEffect)(()=>{if(!n.project)return Ge([]);let e=!1;return L.suggestions(n.project).then(t=>!e&&Ge(t.suggestions),()=>!e&&Ge([])),()=>{e=!0}},[n.project,Ce]),(0,d.useEffect)(()=>{f([]),m({}),Pe(null),Ve(!1),Ie(null),gt.current++,le(``),w(null),j(!1),F(!1),z(null),ae(`pending`),H(null),W(null),ee([]),re([])},[n.project]),(0,d.useEffect)(()=>{if(!n.project){f([]);return}let e=!1,t=n.project;return L.files(t).then(t=>{e||(f(t.files),F(!0))},()=>{e||(f([]),F(!0))}),L.fileCounts(t).then(t=>!e&&m(t.counts),()=>!e&&m({})),L.status(t).then(t=>{e||(w(t.latest),H(t.draft??null),W(t.debug??null),z(t.committedRun),j(!0),ae(t.runInProgress?`running`:t.latest?.status===`failed`?`failed`:t.latest?`done`:`pending`))},()=>void 0),()=>{e=!0}},[n.project,Ce]),(0,d.useEffect)(()=>{if(re([]),!n.project||I===null)return;let e=n.project,t=!1,r=()=>!oe.current&&void L.stale(e).then(e=>!t&&re(e.committedRun===I?e.sources:[]),()=>void 0);return r(),window.addEventListener(`focus`,r),()=>{t=!0,window.removeEventListener(`focus`,r)}},[n.project,I]);let[at,ot]=(0,d.useState)([]),st=(0,d.useMemo)(()=>n.file&&(n.tab===`file`||n.fileLevel)?{kind:`file`,file:n.file}:n.tab===`imports`&&n.group?{kind:`group`,group:n.group}:n.source?{kind:`source`,source:n.source,name:at.find(e=>e.id===n.source)?.name}:null,[n.file,n.tab,n.fileLevel,n.group,n.source,at]);(0,d.useEffect)(()=>{if(!n.project)return ot([]);let e=!1;return L.sources(n.project).then(t=>!e&&ot(t.sources.map(e=>({...e,optIn:e.optIn??[]}))),()=>void 0),()=>{e=!0}},[n.project,Ce]),(0,d.useEffect)(()=>{n.source&&at.length>0&&!at.some(e=>e.id===n.source)&&t({type:`reset`,name:`scopeSource`,args:{}})},[n.source,at]);let{data:ct}=Lx(n.project,De,_===`project`?null:st,[],Ce),lt=ct?ct.counts.broken+ct.counts.notAnalyzed+ct.counts.openCalls:null,[ut,dt]=(0,d.useState)(null),ft=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!n.project||!n.file){g(null);return}n.file!==ft.current&&pe(``),ft.current=n.file,g(e=>e&&e.file.id===n.file?e:null),tt(!1);let e=!1,r=n.file;return L.fileGraph(n.project,r).then(t=>!e&&g(t),r=>{e||M(r)||(g(null),pe(n.run===null?`That file wasn't in the latest analysis, so the project overview is shown instead.`:`That file isn't in run ${n.run}, so the project overview is shown instead.`),t({type:`reset`,name:`selectProject`,args:{project:n.project}}))}),()=>{e=!0}},[n.project,n.file,Ce]),(0,d.useEffect)(()=>R(we,e=>{if(!n.project){(e.type===`run.started`||e.type===`run.committed`||e.type===`run.failed`)&&we();return}e.projectId===n.project&&(e.type===`run.started`?(ae(`running`),le(`Analyzing…`)):e.type===`stage.completed`?le(`Analyzing…`):e.type===`run.committed`?(re([]),ae(`done`),le(`Analyzed just now`),we()):e.type===`run.failed`&&(ae(`failed`),le(`Analysis failed: ${String(e.error)}`),we()))}),[n.project]),(0,d.useEffect)(()=>{let e=e=>{let n=e.target;if(!document.querySelector(`[role="dialog"], [role="menu"]`)&&!n.closest(`input:not([type="checkbox"]):not([type="radio"]), textarea, select, [contenteditable], [role=dialog]`)){if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`z`){e.preventDefault(),t({type:e.shiftKey?`redo`:`undo`});return}e.metaKey||e.ctrlKey||e.altKey||(e.key===`Escape`?r(`clearSelection`):e.key===`u`&&r(`toggleUnresolved`))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let pt=(0,d.useCallback)(e=>r(`select`,e),[r]),mt=(0,d.useCallback)(()=>r(`clearSelection`),[r]),ht=async(e,t)=>{if(S(``),!_w(e)){S(`Enter an absolute path (for example /Users/you/app), not "${e}"`);return}let i=t?ge??n.project:null;try{k(`addFolder`,{root:e}),i||(i=(await L.createProject(e.split(/[\\/]/).filter(Boolean).pop()??`project`,e)).project.id,r(`selectProject`,{project:i})),await L.addSource(i,e)}catch(e){S(e.message??String(e));return}he(!1),_e(null),S(``),ae(`running`);try{await L.analyze(i)}catch(e){de(e.message??String(e))}we()},gt=(0,d.useRef)(0),_t=(0,d.useRef)(null),vt=async(e,i)=>{if(!n.project)return;k(`ask`,{question:e});let a=++gt.current,o=n.project;_t.current?.abort();let s=new AbortController;_t.current=s,t({type:`reset`,name:`showPanel`,args:{panel:`answer`}}),Ve(!0),Ie(e),Ue(t=>[e,...t.filter(t=>t!==e)].slice(0,5));let c;try{c=await L.ask(o,e,i,Re.current,s.signal,ze.current)}catch(t){let n=t;c={question:e,via:`help`,...i?{mode:i}:{},summary:`Could not answer: ${n.message??String(t)}`,results:[],toolCalls:[],error:{code:n.code??`error`,message:n.message??String(t)}}}if(a!==gt.current||Le.current!==o)return;let l=c.results[0];l?.kind===`function`&&l.file===Re.current&&(c.intent===`callers`||c.intent===`callees`||c.intent===`definition`)&&(r(`select`,{kind:`function`,id:l.id,file:l.file}),t({type:`reset`,name:`showPanel`,args:{panel:`answer`}})),Pe(c),Ve(!1),Ie(null)},yt=e=>{for(let t of A(e))r(t.name,t.args);t({type:`reset`,name:`showPanel`,args:{panel:`answer`}})},bt=()=>{_t.current?.abort(),gt.current++,Ve(!1),Ie(null)},xt=()=>{n.project&&(k(`analyzeDraft`),de(``),le(`Analyzing your uncommitted edits as a draft…`),L.analyzeDraft(n.project).catch(e=>{de(e.message),we()}))},St=e=>{n.project&&(k(`analyzeDebug`,{until:e}),de(``),le(`Debug run: analyzing up to ${e}…`),L.analyzeDebug(n.project,e).catch(e=>{de(e.message),we()}))};(0,d.useEffect)(()=>{if(!n.project)return;let e=!1;return L.stages(n.project).then(t=>!e&&ee(t.pipeline),()=>!e&&ee([])),()=>{e=!0}},[n.project]);let[Ct,wt]=(0,d.useState)(null),Tt=(0,d.useCallback)(()=>wt(null),[]),X=e=>{let t=e=>e.slice(0,e.indexOf(`:`)),i=e=>decodeURIComponent(e.slice(e.indexOf(`:`)+1)),a=e=>e.slice(0,e.indexOf(`:`,e.indexOf(`:`)+1)),o=(e,t)=>({label:`Leave it out of analysis…`,command:`chooseFiles`,run:()=>Se({source:e,...t?{path:t}:{}})}),s=e=>({label:`Re-analyze its repository`,command:`analyzeSource`,run:()=>void Et(e)}),c=e=>({label:`Broken imports in it`,command:`showPanel`,run:()=>{e(),dt(`broken`),r(`showPanel`,{panel:`questions`})}});if(e.kind===`group`){let[,t=``,i=``]=e.id.split(`|`);return{title:String(e.data.label??e.id).split(`
|
package/web/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
rel="icon"
|
|
9
9
|
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%233b6fd4'/%3E%3Ccircle cx='10' cy='11' r='3.5' fill='white'/%3E%3Ccircle cx='22' cy='11' r='3.5' fill='white'/%3E%3Ccircle cx='16' cy='22' r='3.5' fill='white'/%3E%3Cpath d='M10 11 16 22 22 11' stroke='white' stroke-width='2' fill='none'/%3E%3C/svg%3E"
|
|
10
10
|
/>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-Bx_159jR.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-C8y32Zs3.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|