visualproof 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +10 -8
  2. package/dist/assets/tips/tour-library.webp +0 -0
  3. package/dist/assets/tips/tour-source.webp +0 -0
  4. package/dist/assets/tips/tour.json +90 -90
  5. package/dist/extractor/Extract.lean +34 -11
  6. package/dist/server/agent.js +19 -7
  7. package/dist/server/agentexport.js +2 -1
  8. package/dist/server/agentfollow.js +13 -3
  9. package/dist/server/agentlean.js +91 -1
  10. package/dist/server/agentnotes.js +6 -4
  11. package/dist/server/agentread.js +33 -1
  12. package/dist/server/app.js +1 -1
  13. package/dist/server/appgraph.js +24 -0
  14. package/dist/server/boardspots.js +1 -1
  15. package/dist/server/goals.js +224 -0
  16. package/dist/server/hover.js +281 -8
  17. package/dist/server/live.js +14 -0
  18. package/dist/server/main.js +3 -2
  19. package/dist/server/mcptools.js +11 -5
  20. package/dist/server/options.js +17 -2
  21. package/dist/server/readonlygate.js +2 -1
  22. package/dist/server/reviewapi.js +5 -2
  23. package/dist/server/status.js +43 -5
  24. package/dist/shared/build.js +9 -0
  25. package/dist/shared/collab.js +14 -2
  26. package/dist/shared/declfind.js +23 -3
  27. package/dist/shared/goals.js +309 -0
  28. package/dist/shared/hygiene.js +18 -0
  29. package/dist/shared/noteplace.js +45 -19
  30. package/dist/shared/scope.js +74 -45
  31. package/dist/shared/sharesnap.js +4 -2
  32. package/dist/web/bundle/app.js +2271 -581
  33. package/dist/web/index.html +1 -1
  34. package/dist/web/src/highlight.js +53 -3
  35. package/dist/web/style.css +148 -0
  36. package/docs/agent-api/README.md +1 -1
  37. package/docs/agent-api/mcp.md +1 -1
  38. package/docs/agent-api/notes.md +3 -2
  39. package/docs/agent-api/reading.md +38 -2
  40. package/docs/agent-api/words.md +3 -2
  41. package/package.json +1 -1
@@ -221,9 +221,15 @@ function cleanView(v2) {
221
221
  const activity = av && typeof av.open === "boolean" && kind && who ? { open: av.open, kind, who, ...typeof av.mine === "string" && validName(av.mine) ? { mine: av.mine } : {} } : null;
222
222
  const lost = o2.lostFound && typeof o2.lostFound === "object" ? o2.lostFound.open : void 0;
223
223
  const scheme = one2(BOARD_SCHEMES, o2.scheme);
224
+ const cv = o2.caret && typeof o2.caret === "object" ? o2.caret : null;
225
+ const place2 = (n3, max) => Number.isInteger(n3) && n3 >= 0 && n3 <= max;
226
+ const caretDecl = cv ? str2(cv.decl) : null;
227
+ const caret = cv && caretDecl && place2(cv.line, 1e7) && place2(cv.character, 1e5) ? { decl: caretDecl, line: cv.line, character: cv.character, ...cv.after === true ? { after: true } : {}, ...cv.pinned === true ? { pinned: true } : {} } : null;
224
228
  const pinned = Array.isArray(o2.pinned) ? o2.pinned.slice(0, MAX_PINNED).map((w2) => {
225
- const decl = w2 && typeof w2 === "object" ? str2(w2.decl) : null;
226
- return decl ? { decl, collapsed: w2.collapsed === true } : null;
229
+ const x2 = w2 && typeof w2 === "object" ? w2 : null;
230
+ const decl = x2 ? str2(x2.decl) : null, file = x2 && !decl ? str2(x2.file, 300) : null;
231
+ if (decl) return { decl, collapsed: x2.collapsed === true, ...x2.mode === "file" ? { mode: "file" } : {} };
232
+ return file ? { file, collapsed: x2.collapsed === true } : null;
227
233
  }).filter((w2) => w2 !== null) : [];
228
234
  return {
229
235
  mode: str2(o2.mode, 16) ?? "tcb",
@@ -231,6 +237,7 @@ function cleanView(v2) {
231
237
  ...selection !== null ? { selection } : {},
232
238
  source,
233
239
  ...source && o2.sourceCollapsed === true ? { sourceCollapsed: true } : {},
240
+ ...source && o2.sourceMode === "file" ? { sourceMode: "file" } : {},
234
241
  ...pinned.length ? { pinned } : {},
235
242
  clusterMode: str2(o2.clusterMode, 16) ?? "namespace",
236
243
  cam: cx !== null && cy !== null && ck !== null ? { x: cx, y: cy, k: ck } : null,
@@ -242,6 +249,7 @@ function cleanView(v2) {
242
249
  ...o2.focus === null || str2(o2.focus) ? { focus: o2.focus } : {},
243
250
  ...visitors.length ? { visitors } : {},
244
251
  ...paper ? { paper } : {},
252
+ ...caret ? { caret } : {},
245
253
  ...activity ? { activity } : {},
246
254
  ...typeof lost === "boolean" ? { lostFound: { open: lost } } : {},
247
255
  ...scheme ? { scheme } : {},
@@ -2645,9 +2653,9 @@ function defaultLabel(place2, type) {
2645
2653
  function wordsText(words, lines) {
2646
2654
  let text2 = "";
2647
2655
  const starts = [];
2648
- const lineStart = new Set(lines);
2656
+ const lineStart2 = new Set(lines);
2649
2657
  words.forEach((w2, k2) => {
2650
- if (k2 > 0) text2 += lineStart.has(k2) ? "\n" : " ";
2658
+ if (k2 > 0) text2 += lineStart2.has(k2) ? "\n" : " ";
2651
2659
  starts.push(text2.length);
2652
2660
  text2 += w2[0];
2653
2661
  });
@@ -5351,6 +5359,8 @@ function snapshotSource(info2) {
5351
5359
  hover: async () => null,
5352
5360
  hoverOpen: () => {
5353
5361
  },
5362
+ goals: async () => null,
5363
+ subterm: async () => null,
5354
5364
  names: async () => null,
5355
5365
  describe: async () => null,
5356
5366
  print: async () => null,
@@ -5395,6 +5405,8 @@ function serverSource() {
5395
5405
  hover: (module, line, character, hash) => fetch(`/api/hover?module=${encodeURIComponent(module)}&line=${line}&character=${character}&hash=${hash}`).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
5396
5406
  hoverOpen: (module) => void fetch(`/api/hover/open?module=${encodeURIComponent(module)}`, { method: "POST" }).catch(() => {
5397
5407
  }),
5408
+ goals: (module, line, character, hash) => fetch(`/api/hover/goals?module=${encodeURIComponent(module)}&line=${line}&character=${character}&hash=${hash}`).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
5409
+ subterm: (module, line, character, hash, k2) => fetch(`/api/hover/goals/info?module=${encodeURIComponent(module)}&line=${line}&character=${character}&hash=${hash}&k=${k2}`).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
5398
5410
  describe: (module, name) => fetch(`/api/hover/describe?module=${encodeURIComponent(module)}&name=${encodeURIComponent(name)}`).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
5399
5411
  print: (module, name) => fetch(`/api/hover/print?module=${encodeURIComponent(module)}&name=${encodeURIComponent(name)}`).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
5400
5412
  names: (module, positions, hash) => fetch(`/api/hover/names?module=${encodeURIComponent(module)}&hash=${hash}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(positions) }).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
@@ -5822,15 +5834,52 @@ function tokenHtml(t2, isRef) {
5822
5834
  }
5823
5835
  }
5824
5836
  var HANG_MAX = 24;
5825
- function highlightLines(src, isRef, first) {
5837
+ function highlightLines(src, isRef, first, decor) {
5826
5838
  const lines = tokenLines(tokenizeLean(src));
5839
+ const folds = decor?.folds ?? [];
5840
+ let ls = 0;
5827
5841
  return src.split("\n").map((text2, k2) => {
5828
5842
  const indent = Math.min(/^ */.exec(text2)[0].length, HANG_MAX);
5829
- const html = (lines[k2] ?? []).map((t2) => tokenHtml(t2, isRef)).join("");
5843
+ const start = ls;
5844
+ ls += text2.length + 1;
5845
+ const own2 = decor?.line?.(k2);
5846
+ const tokens2 = lines[k2] ?? [];
5847
+ const html = folds.length ? foldedHtml(src, tokens2, start, start + text2.length, folds, isRef) : { html: tokens2.map((t2) => tokenHtml(t2, isRef)).join(""), hidden: null };
5830
5848
  const n3 = first !== void 0 ? ` data-n="${first + k2}"` : "";
5831
- return `<span class="ln"${n3} style="--in:${indent}">${html}${k2 < lines.length - 1 ? "\n" : ""}</span>`;
5849
+ const pf = html.hidden !== null ? ` data-pf="${html.hidden}"` : "";
5850
+ return `<span class="ln${own2?.cls ?? ""}${html.hidden !== null ? " pf-l" : ""}"${n3}${pf} style="--in:${indent}">${own2?.lead ?? ""}${html.html}${k2 < lines.length - 1 ? "\n" : ""}</span>`;
5832
5851
  }).join("");
5833
5852
  }
5853
+ function foldedHtml(src, tokens2, start, end, folds, isRef) {
5854
+ const over = folds.find((f2) => f2.from < start && f2.to > start);
5855
+ const hidden = over && (over.to >= end || !src.slice(over.to, end).trim()) ? over.id : null;
5856
+ const out = [];
5857
+ let open = null;
5858
+ const close = () => {
5859
+ if (open !== null) out.push("</span>");
5860
+ open = null;
5861
+ };
5862
+ for (const t2 of tokens2) {
5863
+ let p2 = t2.at;
5864
+ const e2 = t2.at + t2.text.length;
5865
+ while (p2 < e2) {
5866
+ const f2 = folds.find((x2) => x2.from <= p2 && p2 < x2.to);
5867
+ const next = f2 ? Math.min(e2, f2.to) : Math.min(e2, ...folds.filter((x2) => x2.from > p2).map((x2) => x2.from));
5868
+ if (f2 && open !== f2.id) {
5869
+ close();
5870
+ if (p2 === f2.from) out.push(`<button type="button" class="pf-mark" data-pf-open="${escapeHtml(f2.id)}" title="Show this proof" aria-label="Show this proof"></button>`);
5871
+ out.push(`<span class="pf-t" data-pf="${escapeHtml(f2.id)}">`);
5872
+ open = f2.id;
5873
+ } else if (!f2) close();
5874
+ out.push(tokenHtml(p2 === t2.at && next === e2 ? t2 : { ...t2, at: p2, text: src.slice(p2, next) }, isRef));
5875
+ p2 = next;
5876
+ }
5877
+ }
5878
+ close();
5879
+ const at = folds.find((f2) => f2.from === end && f2.to > end);
5880
+ if (at && !hidden) out.push(`<button type="button" class="pf-mark" data-pf-open="${escapeHtml(at.id)}" title="Show this proof" aria-label="Show this proof"></button>`);
5881
+ return { html: out.join(""), hidden };
5882
+ }
5834
5883
  function renderHover(md, isRef) {
5835
5884
  let html = "";
5836
5885
  let at = 0;
@@ -6289,7 +6338,7 @@ var FocusMenu = class {
6289
6338
  };
6290
6339
 
6291
6340
  // src/web/src/reload.ts
6292
- var PAGE_VERSION = true ? "0.8.1" : null;
6341
+ var PAGE_VERSION = true ? "0.9.0" : null;
6293
6342
  var KEY = "visualproof:reload";
6294
6343
  var FOR_KEY = "visualproof:reloaded-for";
6295
6344
  var FRESH_MS = 10 * 6e4;
@@ -6309,7 +6358,12 @@ function keep(k2, storage = session()) {
6309
6358
  var pairs = (x2, ok) => Array.isArray(x2) ? x2.filter((p2) => Array.isArray(p2) && p2.length === 2 && typeof p2[0] === "string" && ok(p2[1])) : [];
6310
6359
  var isString = (v2) => typeof v2 === "string";
6311
6360
  var isBool = (v2) => typeof v2 === "boolean";
6312
- var win = (v2) => v2 && typeof v2 === "object" && typeof v2.name === "string" ? { name: v2.name, collapsed: v2.collapsed === true } : null;
6361
+ var win = (v2) => {
6362
+ if (!v2 || typeof v2 !== "object") return null;
6363
+ const o2 = v2;
6364
+ if (typeof o2.name === "string") return { name: o2.name, collapsed: o2.collapsed === true, ...o2.mode === "file" ? { mode: "file" } : {} };
6365
+ return typeof o2.file === "string" ? { file: o2.file, collapsed: o2.collapsed === true } : null;
6366
+ };
6313
6367
  function takeKept(root, now = Date.now(), storage = session()) {
6314
6368
  let raw = null;
6315
6369
  try {
@@ -6323,7 +6377,8 @@ function takeKept(root, now = Date.now(), storage = session()) {
6323
6377
  const k2 = JSON.parse(raw);
6324
6378
  if (k2.root !== root || typeof k2.at !== "number" || now - k2.at > FRESH_MS || now < k2.at) return null;
6325
6379
  const pinned = Array.isArray(k2.sources?.pinned) ? k2.sources.pinned.map(win).filter((w2) => w2 !== null) : [];
6326
- return { root, at: k2.at, sources: { following: win(k2.sources?.following), pinned }, review: pairs(k2.review, isString), talk: pairs(k2.talk, isString), notes: pairs(k2.notes, isBool) };
6380
+ const f2 = win(k2.sources?.following);
6381
+ return { root, at: k2.at, sources: { following: f2 && "name" in f2 ? f2 : null, pinned }, review: pairs(k2.review, isString), talk: pairs(k2.talk, isString), notes: pairs(k2.notes, isBool) };
6327
6382
  } catch {
6328
6383
  return null;
6329
6384
  }
@@ -6414,6 +6469,608 @@ var Reloader = class {
6414
6469
  }
6415
6470
  };
6416
6471
 
6472
+ // src/shared/excerpt.ts
6473
+ var DECL = /^\s*(?:@\[[^\]]*\]\s*)*(?:(?:private|protected|noncomputable|partial|unsafe|nonrec|scoped|local)\s+)*(?:theorem|lemma|def|abbrev|instance|structure|class|inductive|axiom|opaque|example|irreducible_def)\s+(\S+)/;
6474
+ var NEXT = /^(?:@\[|\/--|\/-!|--|#|(?:(?:private|protected|noncomputable|partial|unsafe|nonrec|scoped|local)\s+)*(?:theorem|lemma|def|abbrev|instance|structure|class|inductive|axiom|opaque|example|irreducible_def|namespace|section|end|open|variable|universe|attribute|set_option|mutual|macro|syntax|notation|infix|infixl|infixr|prefix|postfix|elab|deriving)\b)/;
6475
+ function withPreamble(lines, line) {
6476
+ let start = line;
6477
+ while (start > 0 && line - start < 40) {
6478
+ const above = lines[start - 1];
6479
+ if (/^\s*@\[[^\]]*\]\s*$/.test(above) || /^\s*--/.test(above)) {
6480
+ start--;
6481
+ continue;
6482
+ }
6483
+ if (/-\/\s*$/.test(above)) {
6484
+ let k2 = start - 1;
6485
+ while (k2 > 0 && line - k2 < 60 && !/^\s*\/-/.test(lines[k2])) k2--;
6486
+ if (/^\s*\/--/.test(lines[k2])) {
6487
+ start = k2;
6488
+ continue;
6489
+ }
6490
+ }
6491
+ break;
6492
+ }
6493
+ return start;
6494
+ }
6495
+ function compiledExcerpt(lines, range) {
6496
+ const l0 = Math.max(0, range[0] - 1);
6497
+ const l1 = Math.min(lines.length - 1, Math.max(l0, range[2] - 1));
6498
+ return { start: withPreamble(lines, l0), end: l1 };
6499
+ }
6500
+ function excerptOf(lines, edited, name, range) {
6501
+ return edited ? findExcerpt(lines, name, range[0]) : compiledExcerpt(lines, range);
6502
+ }
6503
+ function findExcerpt(lines, name, near) {
6504
+ const parts = name.split(".");
6505
+ const short6 = parts[parts.length - 1].replace(/^«|»$/g, "");
6506
+ const tail2 = parts.slice(-2).join(".");
6507
+ let best = -1;
6508
+ let bestScore = Infinity;
6509
+ for (let i2 = 0; i2 < lines.length; i2++) {
6510
+ const m3 = DECL.exec(lines[i2]);
6511
+ if (!m3) continue;
6512
+ const declared = m3[1].replace(/[«»]/g, "");
6513
+ if (declared !== short6 && declared !== tail2.replace(/[«»]/g, "") && declared !== name && !name.endsWith("." + declared)) continue;
6514
+ const score2 = near ? Math.abs(i2 + 1 - near) : i2;
6515
+ if (score2 < bestScore) {
6516
+ bestScore = score2;
6517
+ best = i2;
6518
+ }
6519
+ }
6520
+ if (best < 0) return null;
6521
+ let end = best;
6522
+ for (let i2 = best + 1; i2 < lines.length && i2 < best + 400; i2++) {
6523
+ if (NEXT.test(lines[i2])) break;
6524
+ end = i2;
6525
+ }
6526
+ while (end > best && !lines[end].trim()) end--;
6527
+ return { start: withPreamble(lines, best), end };
6528
+ }
6529
+
6530
+ // src/shared/doc/proof.ts
6531
+ var OPEN = "([{\u2983\u27E8\u27E6\u27EA\u2985\u2987\u2045";
6532
+ var CLOSE = ")]}\u2984\u27E9\u27E7\u27EB\u2986\u2988\u2046";
6533
+ var BINDS = /* @__PURE__ */ new Set(["let", "have", "haveI", "letI"]);
6534
+ function valueStart(text2) {
6535
+ let depth = 0;
6536
+ let claimed = 0;
6537
+ for (const t2 of tokenizeLean(text2)) {
6538
+ if (t2.kind === "comment" || t2.kind === "doc" || t2.kind === "string" || t2.kind === "attr") continue;
6539
+ if (t2.kind === "keyword" || t2.kind === "ident") {
6540
+ if (depth === 0 && BINDS.has(t2.text)) claimed++;
6541
+ else if (depth === 0 && t2.text === "where") return t2.at;
6542
+ else if (depth === 0 && t2.text === "by") return null;
6543
+ continue;
6544
+ }
6545
+ if (t2.kind !== "text" && t2.kind !== "op") continue;
6546
+ for (let k2 = 0; k2 < t2.text.length; k2++) {
6547
+ const c3 = t2.text[k2];
6548
+ const at = t2.at + k2;
6549
+ if (OPEN.includes(c3)) depth++;
6550
+ else if (CLOSE.includes(c3)) depth = Math.max(0, depth - 1);
6551
+ else if (depth === 0 && c3 === ":" && t2.text[k2 + 1] === "=") {
6552
+ if (claimed > 0) {
6553
+ claimed--;
6554
+ k2++;
6555
+ continue;
6556
+ }
6557
+ return at;
6558
+ } else if (depth === 0 && c3 === "|" && lineStart(text2, at) && equation(text2, at)) return at;
6559
+ }
6560
+ }
6561
+ return null;
6562
+ }
6563
+ function lineStart(text2, at) {
6564
+ const nl = text2.lastIndexOf("\n", at - 1);
6565
+ return nl >= 0 && /^[ \t]*$/.test(text2.slice(nl + 1, at));
6566
+ }
6567
+ function equation(text2, at) {
6568
+ const end = text2.indexOf("\n", at);
6569
+ return text2.slice(at, end < 0 ? text2.length : end).includes("=>");
6570
+ }
6571
+
6572
+ // src/shared/reviewqueue.ts
6573
+ var TCB_SITES = SITE_STMT | SITE_BODY;
6574
+ function inTargets(g2, targets) {
6575
+ const out = new Uint16Array(g2.n);
6576
+ for (const t2 of targets) {
6577
+ const tcb = g2.reach([t2], TCB_SITES, "out");
6578
+ for (let i2 = 0; i2 < g2.n; i2++) out[i2] += tcb[i2];
6579
+ }
6580
+ return out;
6581
+ }
6582
+ function nonStandardAxiom(g2, i2) {
6583
+ return g2.nodes[i2].kind === "axiom" && !STANDARD_AXIOMS.includes(g2.nodes[i2].name);
6584
+ }
6585
+ function needsReview(g2, d2, i2) {
6586
+ return nonStandardAxiom(g2, i2) || !trusted(d2, g2.nodes[i2].name, g2.nodes[i2].module, g2.isExt(i2));
6587
+ }
6588
+ function trustSplit(g2, d2, s2, skip = -1) {
6589
+ let counted2 = 0, t2 = 0;
6590
+ for (let j2 = 0; j2 < s2.length; j2++) {
6591
+ if (!s2[j2] || j2 === skip) continue;
6592
+ if (needsReview(g2, d2, j2)) counted2++;
6593
+ else t2++;
6594
+ }
6595
+ return { counted: counted2, trusted: t2 };
6596
+ }
6597
+ function reviewSet(g2, d2, root) {
6598
+ return evaluate(reviewScope(g2.nodes[root].name), { g: g2, review: d2 });
6599
+ }
6600
+ var VIA = 8;
6601
+ function axiomsReached(g2, root, set) {
6602
+ const meta = g2.meta;
6603
+ const reach = g2.reach([root], ALL_SITES, "out");
6604
+ const names2 = /* @__PURE__ */ new Set();
6605
+ for (let i2 = 0; i2 < g2.n; i2++) {
6606
+ if (!reach[i2]) continue;
6607
+ if (nonStandardAxiom(g2, i2)) names2.add(g2.nodes[i2].name);
6608
+ for (const k2 of meta.axiomSets[g2.nodes[i2].ax] ?? []) if (!STANDARD_AXIOMS.includes(meta.axioms[k2])) names2.add(meta.axioms[k2]);
6609
+ }
6610
+ const out = [];
6611
+ for (const name of [...names2].sort()) {
6612
+ const j2 = g2.byName.get(name);
6613
+ const node = j2 !== void 0 && set[j2] ? j2 : null;
6614
+ const via = [];
6615
+ if (node !== null) {
6616
+ for (let e2 = g2.inStart[node]; e2 < g2.inStart[node + 1]; e2++) if (reach[g2.inSrc[e2]] && g2.inSrc[e2] !== node && !via.includes(g2.inSrc[e2])) via.push(g2.inSrc[e2]);
6617
+ } else {
6618
+ const k2 = meta.axioms.indexOf(name);
6619
+ const rests = (i2) => k2 >= 0 && (meta.axiomSets[g2.nodes[i2].ax] ?? []).includes(k2);
6620
+ for (let i2 = 0; i2 < g2.n; i2++) {
6621
+ if (!reach[i2] || !rests(i2)) continue;
6622
+ let deeper = false;
6623
+ for (let e2 = g2.outStart[i2]; e2 < g2.outStart[i2 + 1] && !deeper; e2++) deeper = g2.outDst[e2] !== i2 && rests(g2.outDst[e2]);
6624
+ if (!deeper) via.push(i2);
6625
+ }
6626
+ }
6627
+ via.sort((a3, b2) => Number(g2.isExt(a3)) - Number(g2.isExt(b2)) || (g2.nodes[a3].name < g2.nodes[b2].name ? -1 : 1));
6628
+ out.push({ name, node, via: via.slice(0, VIA) });
6629
+ }
6630
+ return out;
6631
+ }
6632
+ function reviewQueue(g2, d2, root, shared) {
6633
+ const set = reviewSet(g2, d2, root);
6634
+ const order = reviewOrder(g2, set, shared);
6635
+ const ax = order.filter((i2) => g2.nodes[i2].kind === "axiom");
6636
+ return { order: [...ax, ...order.filter((i2) => g2.nodes[i2].kind !== "axiom")], axioms: axiomsReached(g2, root, set) };
6637
+ }
6638
+ function offBoard(q2) {
6639
+ return q2.axioms.filter((a3) => a3.node === null);
6640
+ }
6641
+ function queueProgress(g2, d2, q2) {
6642
+ const p2 = { total: 0, approved: 0, commented: 0, stale: 0 };
6643
+ const count2 = (name, hash) => {
6644
+ p2.total++;
6645
+ const s2 = statusOf(d2, name, hash);
6646
+ if (s2 === "approved") p2.approved++;
6647
+ else if (s2 === "commented") p2.commented++;
6648
+ else if (s2 === "stale") p2.stale++;
6649
+ };
6650
+ for (const i2 of q2.order) count2(g2.nodes[i2].name, g2.nodes[i2].hash);
6651
+ for (const a3 of offBoard(q2)) count2(a3.name, void 0);
6652
+ return p2;
6653
+ }
6654
+ function reviewCount(g2, d2, root) {
6655
+ const set = reviewSet(g2, d2, root);
6656
+ let n3 = 0;
6657
+ for (let i2 = 0; i2 < g2.n; i2++) n3 += set[i2];
6658
+ return n3 + axiomsReached(g2, root, set).filter((a3) => a3.node === null).length;
6659
+ }
6660
+ function settled(d2, reader, name, hash, axiom) {
6661
+ return reviewedBy(d2, reader, name, hash) && (!axiom || statusOf(d2, name, hash) === "approved");
6662
+ }
6663
+ function reviewOrder(g2, set, shared) {
6664
+ const members = [];
6665
+ for (let i2 = 0; i2 < g2.n; i2++) if (set[i2]) members.push(i2);
6666
+ return dependencyOrder(g2, members, (x2, y2) => shared[x2] !== shared[y2] ? shared[x2] > shared[y2] : g2.nodes[x2].name < g2.nodes[y2].name);
6667
+ }
6668
+ function dependencyOrder(g2, members, before = (x2, y2) => g2.nodes[x2].name < g2.nodes[y2].name) {
6669
+ const local = /* @__PURE__ */ new Map();
6670
+ members.forEach((v2, k2) => local.set(v2, k2));
6671
+ const uses = members.map(() => []);
6672
+ members.forEach((u2, a3) => {
6673
+ for (let e2 = g2.outStart[u2]; e2 < g2.outStart[u2 + 1]; e2++) {
6674
+ const b2 = g2.outSite[e2] & TCB_SITES ? local.get(g2.outDst[e2]) : void 0;
6675
+ if (b2 !== void 0 && b2 !== a3) uses[a3].push(b2);
6676
+ }
6677
+ });
6678
+ return stepOrder(uses, (a3, b2) => before(members[a3], members[b2])).map((a3) => members[a3]);
6679
+ }
6680
+ function stepOrder(uses, before) {
6681
+ const m3 = uses.length;
6682
+ const comp = components(uses);
6683
+ const nc = comp.reduce((x2, c3) => Math.max(x2, c3 + 1), 0);
6684
+ const steps = Array.from({ length: nc }, () => []);
6685
+ for (let a3 = 0; a3 < m3; a3++) steps[comp[a3]].push(a3);
6686
+ for (const s2 of steps) s2.sort((a3, b2) => before(a3, b2) ? -1 : before(b2, a3) ? 1 : 0);
6687
+ const waiting = new Int32Array(nc);
6688
+ const usedBy = Array.from({ length: nc }, () => []);
6689
+ const seen = /* @__PURE__ */ new Set();
6690
+ for (let a3 = 0; a3 < m3; a3++) {
6691
+ for (const b2 of uses[a3]) {
6692
+ const c3 = comp[a3], d2 = comp[b2];
6693
+ if (c3 === d2 || seen.has(c3 * nc + d2)) continue;
6694
+ seen.add(c3 * nc + d2);
6695
+ waiting[c3]++;
6696
+ usedBy[d2].push(c3);
6697
+ }
6698
+ }
6699
+ const ready = new Heap((c3, d2) => before(steps[c3][0], steps[d2][0]));
6700
+ for (let c3 = 0; c3 < nc; c3++) if (!waiting[c3]) ready.push(c3);
6701
+ const out = [];
6702
+ while (ready.size) {
6703
+ const c3 = ready.pop();
6704
+ for (const a3 of steps[c3]) out.push(a3);
6705
+ for (const d2 of usedBy[c3]) if (--waiting[d2] === 0) ready.push(d2);
6706
+ }
6707
+ return out;
6708
+ }
6709
+ function components(succ) {
6710
+ const n3 = succ.length;
6711
+ const index = new Int32Array(n3).fill(-1);
6712
+ const low = new Int32Array(n3);
6713
+ const comp = new Int32Array(n3).fill(-1);
6714
+ const onStack = new Uint8Array(n3);
6715
+ const stack2 = [];
6716
+ let next = 0, nc = 0;
6717
+ const enter = (v2) => {
6718
+ index[v2] = low[v2] = next++;
6719
+ stack2.push(v2);
6720
+ onStack[v2] = 1;
6721
+ };
6722
+ for (let s2 = 0; s2 < n3; s2++) {
6723
+ if (index[s2] >= 0) continue;
6724
+ enter(s2);
6725
+ const path = [[s2, 0]];
6726
+ while (path.length) {
6727
+ const top = path[path.length - 1];
6728
+ const v2 = top[0];
6729
+ if (top[1] < succ[v2].length) {
6730
+ const w2 = succ[v2][top[1]++];
6731
+ if (index[w2] < 0) {
6732
+ enter(w2);
6733
+ path.push([w2, 0]);
6734
+ } else if (onStack[w2]) low[v2] = Math.min(low[v2], index[w2]);
6735
+ continue;
6736
+ }
6737
+ path.pop();
6738
+ if (path.length) {
6739
+ const u2 = path[path.length - 1][0];
6740
+ low[u2] = Math.min(low[u2], low[v2]);
6741
+ }
6742
+ if (low[v2] === index[v2]) {
6743
+ let w2;
6744
+ do {
6745
+ w2 = stack2.pop();
6746
+ onStack[w2] = 0;
6747
+ comp[w2] = nc;
6748
+ } while (w2 !== v2);
6749
+ nc++;
6750
+ }
6751
+ }
6752
+ }
6753
+ return comp;
6754
+ }
6755
+ var Heap = class {
6756
+ xs = [];
6757
+ before;
6758
+ constructor(before) {
6759
+ this.before = before;
6760
+ }
6761
+ get size() {
6762
+ return this.xs.length;
6763
+ }
6764
+ push(x2) {
6765
+ const xs = this.xs;
6766
+ xs.push(x2);
6767
+ for (let k2 = xs.length - 1; k2 > 0; ) {
6768
+ const p2 = k2 - 1 >> 1;
6769
+ if (!this.before(xs[k2], xs[p2])) break;
6770
+ [xs[k2], xs[p2]] = [xs[p2], xs[k2]];
6771
+ k2 = p2;
6772
+ }
6773
+ }
6774
+ pop() {
6775
+ const xs = this.xs;
6776
+ const top = xs[0];
6777
+ const last2 = xs.pop();
6778
+ if (xs.length) {
6779
+ xs[0] = last2;
6780
+ for (let k2 = 0; ; ) {
6781
+ const l2 = 2 * k2 + 1, r2 = l2 + 1;
6782
+ let best = k2;
6783
+ if (l2 < xs.length && this.before(xs[l2], xs[best])) best = l2;
6784
+ if (r2 < xs.length && this.before(xs[r2], xs[best])) best = r2;
6785
+ if (best === k2) break;
6786
+ [xs[k2], xs[best]] = [xs[best], xs[k2]];
6787
+ k2 = best;
6788
+ }
6789
+ }
6790
+ return top;
6791
+ }
6792
+ };
6793
+ function whyChain(g2, from, to) {
6794
+ const parent = new Int32Array(g2.n).fill(-1);
6795
+ parent[from] = from;
6796
+ const queue = [from];
6797
+ for (let k2 = 0; k2 < queue.length && parent[to] < 0; k2++) {
6798
+ const u2 = queue[k2];
6799
+ for (let e2 = g2.outStart[u2]; e2 < g2.outStart[u2 + 1]; e2++) {
6800
+ const v2 = g2.outDst[e2];
6801
+ if (!(g2.outSite[e2] & TCB_SITES) || parent[v2] >= 0) continue;
6802
+ parent[v2] = u2;
6803
+ queue.push(v2);
6804
+ }
6805
+ }
6806
+ if (parent[to] < 0) return null;
6807
+ const path = [to];
6808
+ while (path[path.length - 1] !== from) path.push(parent[path[path.length - 1]]);
6809
+ return path.reverse();
6810
+ }
6811
+ function reviewedBy(d2, reader, name, hash) {
6812
+ return !!reader && current(d2, name).some((o2) => o2.by === reader && fresh(o2, hash));
6813
+ }
6814
+
6815
+ // src/web/src/status.ts
6816
+ var SCHEMES_SHOWN = ["kind", "status", "mine"];
6817
+ var STATUSES2 = ["failed", "building", "sorry", "commented", "stale", "approved", "unreviewed", "trusted"];
6818
+ var ST_FAILED = 0;
6819
+ var ST_BUILDING = 1;
6820
+ var ST_SORRY = 2;
6821
+ var ST_COMMENTED = 3;
6822
+ var ST_STALE = 4;
6823
+ var ST_APPROVED = 5;
6824
+ var ST_UNREVIEWED = 6;
6825
+ var ST_TRUSTED = 7;
6826
+ var STATUS_LABEL = {
6827
+ failed: "failed or not built",
6828
+ building: "building",
6829
+ sorry: "contains sorry",
6830
+ commented: "commented",
6831
+ stale: "stale",
6832
+ approved: "approved",
6833
+ unreviewed: "not yet reviewed",
6834
+ trusted: "trusted"
6835
+ };
6836
+ var STATUS_HINT = {
6837
+ failed: "Its file failed to compile in the last build, or was never built: shown as it was last built",
6838
+ building: "Its file is being compiled right now",
6839
+ sorry: "It rests on sorry: its own, or through anything it uses",
6840
+ commented: "A reviewer's latest word on its present version is a comment",
6841
+ stale: "It has opinions, none on its present version",
6842
+ approved: "A reviewer approved its present version, and no reviewer's latest word on it is a comment",
6843
+ unreviewed: "Nobody has given an opinion on it yet, and nothing trusts it",
6844
+ trusted: "Trusted without review (Mathlib, Lean core, a trusted prefix, the standard axioms), with no opinion on it"
6845
+ };
6846
+ var MINE_STATES = [ST_COMMENTED, ST_STALE, ST_APPROVED, ST_UNREVIEWED, ST_TRUSTED];
6847
+ function mineLabel(code, whose) {
6848
+ const who = whose ?? "you";
6849
+ switch (code) {
6850
+ case ST_COMMENTED:
6851
+ return `${who} commented`;
6852
+ case ST_STALE:
6853
+ return `${whose ? `${whose}'s` : "your"} opinion is stale`;
6854
+ case ST_APPROVED:
6855
+ return `${who} approved`;
6856
+ case ST_TRUSTED:
6857
+ return "trusted";
6858
+ default:
6859
+ return `not reviewed by ${whose ?? "you"}`;
6860
+ }
6861
+ }
6862
+ function mineHint(code, whose) {
6863
+ const your = whose ? `${whose}'s` : "Your";
6864
+ switch (code) {
6865
+ case ST_COMMENTED:
6866
+ return `${your} current opinion on its present version is a comment`;
6867
+ case ST_STALE:
6868
+ return `${your} current opinion is on an earlier version: it changed since`;
6869
+ case ST_APPROVED:
6870
+ return `${your} current opinion approves its present version`;
6871
+ case ST_TRUSTED:
6872
+ return `Trusted without review, and no opinion of ${whose ? `${whose}'s` : "yours"} on it`;
6873
+ default:
6874
+ return `It needs review, and ${whose ? `${whose} has` : "you have"} no opinion on it (none given, or withdrawn)`;
6875
+ }
6876
+ }
6877
+ function mineState(d2, g2, i2, me) {
6878
+ const v2 = g2.nodes[i2];
6879
+ const s2 = me ? ownStatus(d2, v2.name, me, v2.hash) : "none";
6880
+ if (s2 === "stale") return ST_STALE;
6881
+ if (s2 === "commented") return ST_COMMENTED;
6882
+ if (s2 === "approved") return ST_APPROVED;
6883
+ return needsReview(g2, d2, i2) ? ST_UNREVIEWED : ST_TRUSTED;
6884
+ }
6885
+ function mineCodes(d2, g2, me) {
6886
+ const out = new Uint8Array(g2.n);
6887
+ for (let i2 = 0; i2 < g2.n; i2++) out[i2] = mineState(d2, g2, i2, me);
6888
+ return out;
6889
+ }
6890
+ function statusState(d2, g2, i2, file, sorryAx) {
6891
+ if (file?.state === "building") return ST_BUILDING;
6892
+ if (file?.state === "failed" || file?.state === "unbuilt") return ST_FAILED;
6893
+ if (sorryAx) return ST_SORRY;
6894
+ const v2 = g2.nodes[i2];
6895
+ const s2 = statusOf(d2, v2.name, v2.hash);
6896
+ if (s2 === "commented") return ST_COMMENTED;
6897
+ if (s2 === "stale") return ST_STALE;
6898
+ if (s2 === "approved") return ST_APPROVED;
6899
+ return needsReview(g2, d2, i2) ? ST_UNREVIEWED : ST_TRUSTED;
6900
+ }
6901
+ function statusCodes(d2, g2, files) {
6902
+ const out = new Uint8Array(g2.n);
6903
+ const sorrySets = /* @__PURE__ */ new Map();
6904
+ for (let i2 = 0; i2 < g2.n; i2++) {
6905
+ const ax = g2.nodes[i2].ax;
6906
+ let s2 = sorrySets.get(ax);
6907
+ if (s2 === void 0) sorrySets.set(ax, s2 = g2.axiomsOf(i2).includes("sorryAx"));
6908
+ out[i2] = statusState(d2, g2, i2, g2.isExt(i2) ? void 0 : files.get(g2.nodes[i2].module), s2);
6909
+ }
6910
+ return out;
6911
+ }
6912
+ function fileTrouble(f2) {
6913
+ switch (f2?.state) {
6914
+ case "failed":
6915
+ case "unbuilt":
6916
+ return ST_FAILED;
6917
+ case "building":
6918
+ return ST_BUILDING;
6919
+ case "sorry":
6920
+ return ST_SORRY;
6921
+ default:
6922
+ return -1;
6923
+ }
6924
+ }
6925
+ function clusterTroubles(clusters, clustering, files) {
6926
+ const out = new Int8Array(clusters.length).fill(-1);
6927
+ if (clustering === "module") clusters.forEach((c3, k2) => out[k2] = fileTrouble(files.get(c3.key)));
6928
+ return out;
6929
+ }
6930
+
6931
+ // src/web/src/filemode.ts
6932
+ var byModule = /* @__PURE__ */ new WeakMap();
6933
+ function moduleDecls(g2, module) {
6934
+ let m3 = byModule.get(g2);
6935
+ if (!m3) {
6936
+ m3 = /* @__PURE__ */ new Map();
6937
+ for (let i2 = 0; i2 < g2.n; i2++) {
6938
+ const k2 = g2.nodes[i2].module;
6939
+ const list2 = m3.get(k2);
6940
+ if (list2) list2.push(i2);
6941
+ else m3.set(k2, [i2]);
6942
+ }
6943
+ byModule.set(g2, m3);
6944
+ }
6945
+ return m3.get(module) ?? [];
6946
+ }
6947
+ var preamble = (l2) => /^\s*(?:$|--|@\[[^\]]*\]\s*$)/.test(l2);
6948
+ function headLine(lines, start, end) {
6949
+ let k2 = start;
6950
+ if (/^\s*\/--/.test(lines[k2] ?? "")) {
6951
+ const first = lines[k2].indexOf("/--");
6952
+ while (k2 <= end && lines[k2].indexOf("-/", k2 === start ? first + 3 : 0) < 0) k2++;
6953
+ if (k2 > end) return start;
6954
+ const rest = lines[k2].slice(lines[k2].indexOf("-/", k2 === start ? first + 3 : 0) + 2);
6955
+ if (rest.trim()) return k2;
6956
+ k2++;
6957
+ }
6958
+ while (k2 < end && preamble(lines[k2])) k2++;
6959
+ return k2 <= end ? k2 : start;
6960
+ }
6961
+ function fileDecls(g2, module, lines, edited) {
6962
+ const out = [];
6963
+ for (const i2 of moduleDecls(g2, module)) {
6964
+ const v2 = g2.nodes[i2];
6965
+ if (!v2.range || v2.gen !== void 0) continue;
6966
+ const at = edited ? excerptOf(lines, true, v2.name, v2.range) : compiledExcerpt(lines, v2.range);
6967
+ if (!at || at.start >= lines.length) continue;
6968
+ out.push({ i: i2, start: at.start, end: at.end, head: headLine(lines, at.start, at.end) });
6969
+ }
6970
+ return out.sort((a3, b2) => a3.start - b2.start || a3.end - b2.end || (g2.nodes[a3.i].name < g2.nodes[b2.i].name ? -1 : 1));
6971
+ }
6972
+ var CHUNK_LINES = 60;
6973
+ function chunksOf(decls, n3, max = CHUNK_LINES) {
6974
+ const out = [];
6975
+ const gap = (from, to) => {
6976
+ for (let s2 = from; s2 <= to; s2 += max) out.push({ start: s2, end: Math.min(to, s2 + max - 1) });
6977
+ };
6978
+ let at = 0;
6979
+ let k2 = 0;
6980
+ while (k2 < decls.length) {
6981
+ const start = Math.max(at, decls[k2].start);
6982
+ let end = Math.max(start, decls[k2].end);
6983
+ k2++;
6984
+ while (k2 < decls.length && decls[k2].start <= end) end = Math.max(end, decls[k2++].end);
6985
+ end = Math.min(end, n3 - 1);
6986
+ if (start > end) continue;
6987
+ if (start > at) gap(at, start - 1);
6988
+ out.push({ start, end });
6989
+ at = end + 1;
6990
+ }
6991
+ if (at < n3) gap(at, n3 - 1);
6992
+ return out;
6993
+ }
6994
+ function declAt(decls, line) {
6995
+ let best = null;
6996
+ for (const d2 of decls) {
6997
+ if (d2.start > line) break;
6998
+ if (d2.end >= line && (!best || d2.start >= best.start)) best = d2;
6999
+ }
7000
+ return best;
7001
+ }
7002
+ var VALUE_KINDS = /* @__PURE__ */ new Set(["def", "abbrev", "instance", "opaque"]);
7003
+ var FOLD_MARK = "\u22EF proof";
7004
+ function utf16At(line, col) {
7005
+ let i2 = 0;
7006
+ for (let cp = 0; cp < col && i2 < line.length; cp++) i2 += (line.codePointAt(i2) ?? 0) > 65535 ? 2 : 1;
7007
+ return i2;
7008
+ }
7009
+ function proofFolds(g2, decls, lines, passRead) {
7010
+ const out = [];
7011
+ const add = (d2, start, text2, a3, b2) => {
7012
+ while (b2 > a3 && /\s/.test(text2[b2 - 1])) b2--;
7013
+ if (b2 - a3 <= FOLD_MARK.length) return;
7014
+ const pos = (o2) => {
7015
+ let line = start, at = 0;
7016
+ for (let nl = text2.indexOf("\n"); nl >= 0 && nl < o2; nl = text2.indexOf("\n", at)) {
7017
+ line++;
7018
+ at = nl + 1;
7019
+ }
7020
+ return [line, o2 - at];
7021
+ };
7022
+ out.push({ from: pos(a3), to: pos(b2), decl: d2 });
7023
+ };
7024
+ decls.forEach((fd, d2) => {
7025
+ const v2 = g2.nodes[fd.i];
7026
+ const text2 = lines.slice(fd.start, fd.end + 1).join("\n");
7027
+ if (v2.kind === "theorem") {
7028
+ const at = valueStart(text2);
7029
+ if (at === null) return;
7030
+ let from = text2.startsWith(":=", at) ? at + 2 : at;
7031
+ while (from < text2.length && (text2[from] === " " || text2[from] === " ")) from++;
7032
+ add(d2, fd.start, text2, from, text2.length);
7033
+ return;
7034
+ }
7035
+ if (!VALUE_KINDS.has(v2.kind) || !v2.proofs?.length || !passRead(fd.i)) return;
7036
+ const starts = [];
7037
+ let o2 = 0;
7038
+ for (let l2 = fd.start; l2 <= fd.end; l2++) {
7039
+ starts.push(o2);
7040
+ o2 += lines[l2].length + 1;
7041
+ }
7042
+ const off = (line, col) => {
7043
+ const k2 = line - 1 - fd.start;
7044
+ return k2 < 0 || k2 >= starts.length ? null : starts[k2] + utf16At(lines[line - 1], col);
7045
+ };
7046
+ for (const [l0, c0, l1, c1] of v2.proofs) {
7047
+ const a3 = off(l0, c0), b2 = off(l1, c1);
7048
+ if (a3 !== null && b2 !== null && a3 < b2) add(d2, fd.start, text2, a3, b2);
7049
+ }
7050
+ });
7051
+ out.sort((x2, y2) => x2.from[0] - y2.from[0] || x2.from[1] - y2.from[1]);
7052
+ const apart2 = [];
7053
+ const before = (p2, q2) => p2[0] < q2[0] || p2[0] === q2[0] && p2[1] < q2[1];
7054
+ for (const f2 of out) {
7055
+ const last2 = apart2[apart2.length - 1];
7056
+ if (last2 && before(f2.from, last2.to)) {
7057
+ if (before(last2.to, f2.to)) last2.to = f2.to;
7058
+ } else apart2.push({ ...f2, from: [...f2.from], to: [...f2.to] });
7059
+ }
7060
+ return apart2;
7061
+ }
7062
+ var FILE_MARK_LABEL = { ...STATUS_LABEL, free: "in no target's review set" };
7063
+ function fileMark(d2, g2, i2, inReview, file) {
7064
+ const s2 = STATUSES2[statusState(d2, g2, i2, g2.isExt(i2) ? void 0 : file, g2.axiomsOf(i2).includes("sorryAx"))];
7065
+ return s2 === "unreviewed" && inReview && !inReview(i2) ? "free" : s2;
7066
+ }
7067
+ function sameText(compiled, range, lines, now) {
7068
+ const at = compiledExcerpt(compiled, range);
7069
+ if (at.end - at.start !== now.end - now.start) return false;
7070
+ for (let k2 = 0; k2 <= at.end - at.start; k2++) if (compiled[at.start + k2] !== lines[now.start + k2]) return false;
7071
+ return true;
7072
+ }
7073
+
6417
7074
  // src/shared/sharesnap.ts
6418
7075
  var SNAP_PARAM = "snap";
6419
7076
  var SNAPSHOT_MAX = 32e3;
@@ -6477,8 +7134,10 @@ var SNAPSHOT_FORMS = {
6477
7134
  read: (o2, clean) => "visitors" in o2 && clean.visitors ? { visitors: clean.visitors } : {}
6478
7135
  },
6479
7136
  panel: same("sel"),
6480
- sources: same("source", "sourceCollapsed", "pinned"),
7137
+ sources: same("source", "sourceCollapsed", "sourceMode", "pinned"),
6481
7138
  paper: same("paper"),
7139
+ // the InfoView's caret, in the window it is in (the owner's decision of 2026-11-01)
7140
+ caret: same("caret"),
6482
7141
  activity: same("activity"),
6483
7142
  lostFound: same("lostFound"),
6484
7143
  colouring: same("scheme"),
@@ -6547,7 +7206,7 @@ function sortOut(v2, has) {
6547
7206
  return { view, gone };
6548
7207
  }
6549
7208
  function goneNames(v2, picked, has) {
6550
- const named2 = [v2.sel, ...picked, ...(v2.visitors ?? []).map((w2) => w2.decl), ...(v2.pinned ?? []).map((w2) => w2.decl)];
7209
+ const named2 = [v2.sel, ...picked, ...(v2.visitors ?? []).map((w2) => w2.decl), ...(v2.pinned ?? []).flatMap((w2) => "decl" in w2 ? [w2.decl] : [])];
6551
7210
  const decls = [...new Set(named2.filter((n3) => !!n3 && !has.decl(n3)))];
6552
7211
  return { decls, ...typeof v2.focus === "string" && !has.target(v2.focus) ? { focus: v2.focus } : {} };
6553
7212
  }
@@ -7923,7 +8582,7 @@ var NAMESPACE = /^namespace\s+(\S+)/;
7923
8582
  var SECTION = /^(?:@\[[^\]]*\]\s*)?(?:(?:noncomputable|public|private)\s+)*section\b(?:\s+([^\s-]\S*))?/;
7924
8583
  var MUTUAL = /^mutual\b/;
7925
8584
  var END = /^end\b(?:\s+([^\s-]\S*))?/;
7926
- var OPEN = /^open\s+(.*)$/;
8585
+ var OPEN2 = /^open\s+(.*)$/;
7927
8586
  var VARIABLE = /^variable\b\s*(.*)$/;
7928
8587
  var UNIVERSE = /^universe\s+(.*)$/;
7929
8588
  var OPTION = /^set_option\s+(.*)$/;
@@ -7962,12 +8621,12 @@ function stripComments(line, depth) {
7962
8621
  }
7963
8622
  return { text: out, depth };
7964
8623
  }
7965
- function walk(lines, upto, hasNamespace) {
7966
- const stack2 = [frame("top", "", null, 0)];
7967
- let pending = null;
7968
- const current3 = () => stack2.map((f2) => f2.ns).filter(Boolean).join(".");
7969
- const resolveNs = (x2) => {
7970
- const cur = current3().split(".").filter(Boolean);
8624
+ var copyFrame = (f2) => ({ ...f2, opens: [...f2.opens], aliases: new Map(f2.aliases), open: [...f2.open], variables: [...f2.variables], universes: [...f2.universes], options: [...f2.options], local: [...f2.local] });
8625
+ function walker(lines, hasNamespace) {
8626
+ const live = { stack: [frame("top", "", null, 0)], pending: null };
8627
+ const current3 = (st2) => st2.stack.map((f2) => f2.ns).filter(Boolean).join(".");
8628
+ const resolveNs = (st2, x2) => {
8629
+ const cur = current3(st2).split(".").filter(Boolean);
7971
8630
  const out = [];
7972
8631
  for (let k2 = cur.length; k2 >= 0; k2--) {
7973
8632
  const n3 = [...cur.slice(0, k2), x2].join(".");
@@ -7975,7 +8634,7 @@ function walk(lines, upto, hasNamespace) {
7975
8634
  }
7976
8635
  return out;
7977
8636
  };
7978
- const open = (args, cmd, into) => {
8637
+ const open = (st2, args, cmd, into) => {
7979
8638
  const words = args.trim().split(/\s+/);
7980
8639
  const scoped = words[0] === "scoped";
7981
8640
  const spaces = [];
@@ -7983,14 +8642,14 @@ function walk(lines, upto, hasNamespace) {
7983
8642
  const paren = /^([^\s(]+)\s*\(([^)]*)\)/.exec(rest.trim());
7984
8643
  const renaming = /^([^\s]+)\s+renaming\s+(.*)$/.exec(rest.trim());
7985
8644
  if (paren) {
7986
- for (const ns of resolveNs(paren[1])) {
8645
+ for (const ns of resolveNs(st2, paren[1])) {
7987
8646
  spaces.push(ns);
7988
8647
  if (!scoped) {
7989
8648
  for (const x2 of paren[2].trim().split(/\s+/)) if (x2) into.aliases.set(x2, `${ns}.${x2}`);
7990
8649
  }
7991
8650
  }
7992
8651
  } else if (renaming) {
7993
- for (const ns of resolveNs(renaming[1])) {
8652
+ for (const ns of resolveNs(st2, renaming[1])) {
7994
8653
  spaces.push(ns);
7995
8654
  if (!scoped)
7996
8655
  for (const pair of renaming[2].split(",")) {
@@ -8002,50 +8661,51 @@ function walk(lines, upto, hasNamespace) {
8002
8661
  const hiding = rest.indexOf(" hiding ");
8003
8662
  for (const w2 of (hiding >= 0 ? rest.slice(0, hiding) : rest).trim().split(/\s+/)) {
8004
8663
  if (!w2) continue;
8005
- const ns = resolveNs(w2);
8664
+ const ns = resolveNs(st2, w2);
8006
8665
  spaces.push(...ns);
8007
8666
  if (!scoped) into.opens.push(...ns);
8008
8667
  }
8009
8668
  }
8010
8669
  into.open.push({ ...cmd, namespaces: [...new Set(spaces)], ...scoped ? { scoped: true } : {} });
8011
8670
  };
8012
- const finish = (text2, line) => {
8671
+ const finish = (st2, text2, line) => {
8672
+ const stack2 = st2.stack;
8013
8673
  let m3;
8014
8674
  if (m3 = NAMESPACE.exec(text2)) {
8015
8675
  stack2.push(frame("namespace", m3[1], m3[1], line));
8016
- pending = null;
8676
+ st2.pending = null;
8017
8677
  return;
8018
8678
  }
8019
8679
  if (m3 = SECTION.exec(text2)) {
8020
8680
  const f2 = frame("section", "", m3[1] ?? null, line);
8021
8681
  if (/\bnoncomputable\s+section\b/.test(text2)) f2.noncomputable = true;
8022
8682
  stack2.push(f2);
8023
- pending = null;
8683
+ st2.pending = null;
8024
8684
  return;
8025
8685
  }
8026
8686
  if (MUTUAL.test(text2)) {
8027
8687
  stack2.push(frame("mutual", "", null, line));
8028
- pending = null;
8688
+ st2.pending = null;
8029
8689
  return;
8030
8690
  }
8031
8691
  if (m3 = END.exec(text2)) {
8032
8692
  let parts = m3[1] ? m3[1].split(".").length : 1;
8033
8693
  while (parts > 0 && stack2.length > 1) parts -= (stack2.pop().name ?? "_").split(".").length;
8034
- pending = null;
8694
+ st2.pending = null;
8035
8695
  return;
8036
8696
  }
8037
8697
  if (ATTRIBUTES.test(text2)) return;
8038
8698
  const head = IN_HEAD.test(text2);
8039
8699
  if (head && !VARIABLE.test(text2) && /\sin\s/.test(text2)) {
8040
- pending = null;
8700
+ st2.pending = null;
8041
8701
  return;
8042
8702
  }
8043
8703
  const onlyNext = head && IN.test(text2);
8044
8704
  const body = onlyNext ? text2.replace(IN, "") : text2;
8045
- const into = onlyNext ? pending ??= frame("top", "", null, line) : stack2[stack2.length - 1];
8046
- if (!onlyNext) pending = null;
8705
+ const into = onlyNext ? st2.pending ??= frame("top", "", null, line) : stack2[stack2.length - 1];
8706
+ if (!onlyNext) st2.pending = null;
8047
8707
  const cmd = (t2) => ({ line: line + 1, text: t2, ...onlyNext ? { in: true } : {} });
8048
- if (m3 = OPEN.exec(body)) open(m3[1], cmd(body), into);
8708
+ if (m3 = OPEN2.exec(body)) open(st2, m3[1], cmd(body), into);
8049
8709
  else if (m3 = VARIABLE.exec(body)) into.variables.push(cmd(m3[1]));
8050
8710
  else if (m3 = UNIVERSE.exec(body)) into.universes.push(cmd(m3[1]));
8051
8711
  else if (m3 = OPTION.exec(body)) into.options.push(cmd(m3[1]));
@@ -8053,23 +8713,31 @@ function walk(lines, upto, hasNamespace) {
8053
8713
  };
8054
8714
  let depth = 0;
8055
8715
  let reading = null;
8056
- for (let l2 = 0; l2 < upto && l2 < lines.length; l2++) {
8057
- const line = lines[l2];
8058
- const inComment = depth > 0;
8059
- const s2 = stripComments(line, depth);
8060
- depth = s2.depth;
8061
- const text2 = s2.text.replace(/\s+/g, " ").trim();
8062
- if (!text2) continue;
8063
- if (!inComment && !/^\s/.test(line)) {
8064
- if (reading) finish(reading.text, reading.line);
8065
- reading = { line: l2, text: text2 };
8066
- } else if (reading) reading.text += " " + text2;
8067
- }
8068
- if (reading) finish(reading.text, reading.line);
8069
- return { stack: stack2, pending };
8716
+ let l2 = 0;
8717
+ return {
8718
+ to(upto) {
8719
+ for (; l2 < upto && l2 < lines.length; l2++) {
8720
+ const line = lines[l2];
8721
+ const inComment = depth > 0;
8722
+ const s2 = stripComments(line, depth);
8723
+ depth = s2.depth;
8724
+ const text2 = s2.text.replace(/\s+/g, " ").trim();
8725
+ if (!text2) continue;
8726
+ if (!inComment && !/^\s/.test(line)) {
8727
+ if (reading) finish(live, reading.text, reading.line);
8728
+ reading = { line: l2, text: text2 };
8729
+ } else if (reading) reading.text += " " + text2;
8730
+ }
8731
+ const st2 = { stack: live.stack.map(copyFrame), pending: live.pending && copyFrame(live.pending) };
8732
+ if (reading) finish(st2, reading.text, reading.line);
8733
+ return st2;
8734
+ }
8735
+ };
8070
8736
  }
8071
- function scopeAt(lines, upto, hasNamespace) {
8072
- const { stack: stack2, pending } = walk(lines, upto, hasNamespace);
8737
+ function walk(lines, upto, hasNamespace) {
8738
+ return walker(lines, hasNamespace).to(upto);
8739
+ }
8740
+ function scopeOf({ stack: stack2, pending }) {
8073
8741
  const frames = pending ? [...stack2, pending] : stack2;
8074
8742
  const cur = stack2.map((f2) => f2.ns).filter(Boolean).join(".").split(".").filter(Boolean);
8075
8743
  const namespaces = [];
@@ -8078,6 +8746,16 @@ function scopeAt(lines, upto, hasNamespace) {
8078
8746
  for (const f2 of frames) for (const [k2, v2] of f2.aliases) aliases.set(k2, v2);
8079
8747
  return { namespaces, opens: [...new Set(frames.flatMap((f2) => f2.opens))], aliases };
8080
8748
  }
8749
+ function scopesAt(lines, uptos, hasNamespace) {
8750
+ const w2 = walker(lines, hasNamespace);
8751
+ const out = new Array(uptos.length);
8752
+ const order = uptos.map((_2, k2) => k2).sort((a3, b2) => uptos[a3] - uptos[b2]);
8753
+ for (const k2 of order) out[k2] = scopeOf(w2.to(uptos[k2]));
8754
+ return out;
8755
+ }
8756
+ function scopeAt(lines, upto, hasNamespace) {
8757
+ return scopeOf(walk(lines, upto, hasNamespace));
8758
+ }
8081
8759
  function contextAt(lines, upto, hasNamespace) {
8082
8760
  const { stack: stack2, pending } = walk(lines, upto, hasNamespace);
8083
8761
  const frames = pending ? [...stack2, pending] : stack2;
@@ -8210,249 +8888,6 @@ function renderComment(text2, on, g2) {
8210
8888
  return render(text2, 0);
8211
8889
  }
8212
8890
 
8213
- // src/shared/reviewqueue.ts
8214
- var TCB_SITES = SITE_STMT | SITE_BODY;
8215
- function inTargets(g2, targets) {
8216
- const out = new Uint16Array(g2.n);
8217
- for (const t2 of targets) {
8218
- const tcb = g2.reach([t2], TCB_SITES, "out");
8219
- for (let i2 = 0; i2 < g2.n; i2++) out[i2] += tcb[i2];
8220
- }
8221
- return out;
8222
- }
8223
- function nonStandardAxiom(g2, i2) {
8224
- return g2.nodes[i2].kind === "axiom" && !STANDARD_AXIOMS.includes(g2.nodes[i2].name);
8225
- }
8226
- function needsReview(g2, d2, i2) {
8227
- return nonStandardAxiom(g2, i2) || !trusted(d2, g2.nodes[i2].name, g2.nodes[i2].module, g2.isExt(i2));
8228
- }
8229
- function trustSplit(g2, d2, s2, skip = -1) {
8230
- let counted2 = 0, t2 = 0;
8231
- for (let j2 = 0; j2 < s2.length; j2++) {
8232
- if (!s2[j2] || j2 === skip) continue;
8233
- if (needsReview(g2, d2, j2)) counted2++;
8234
- else t2++;
8235
- }
8236
- return { counted: counted2, trusted: t2 };
8237
- }
8238
- function reviewSet(g2, d2, root) {
8239
- return evaluate(reviewScope(g2.nodes[root].name), { g: g2, review: d2 });
8240
- }
8241
- var VIA = 8;
8242
- function axiomsReached(g2, root, set) {
8243
- const meta = g2.meta;
8244
- const reach = g2.reach([root], ALL_SITES, "out");
8245
- const names2 = /* @__PURE__ */ new Set();
8246
- for (let i2 = 0; i2 < g2.n; i2++) {
8247
- if (!reach[i2]) continue;
8248
- if (nonStandardAxiom(g2, i2)) names2.add(g2.nodes[i2].name);
8249
- for (const k2 of meta.axiomSets[g2.nodes[i2].ax] ?? []) if (!STANDARD_AXIOMS.includes(meta.axioms[k2])) names2.add(meta.axioms[k2]);
8250
- }
8251
- const out = [];
8252
- for (const name of [...names2].sort()) {
8253
- const j2 = g2.byName.get(name);
8254
- const node = j2 !== void 0 && set[j2] ? j2 : null;
8255
- const via = [];
8256
- if (node !== null) {
8257
- for (let e2 = g2.inStart[node]; e2 < g2.inStart[node + 1]; e2++) if (reach[g2.inSrc[e2]] && g2.inSrc[e2] !== node && !via.includes(g2.inSrc[e2])) via.push(g2.inSrc[e2]);
8258
- } else {
8259
- const k2 = meta.axioms.indexOf(name);
8260
- const rests = (i2) => k2 >= 0 && (meta.axiomSets[g2.nodes[i2].ax] ?? []).includes(k2);
8261
- for (let i2 = 0; i2 < g2.n; i2++) {
8262
- if (!reach[i2] || !rests(i2)) continue;
8263
- let deeper = false;
8264
- for (let e2 = g2.outStart[i2]; e2 < g2.outStart[i2 + 1] && !deeper; e2++) deeper = g2.outDst[e2] !== i2 && rests(g2.outDst[e2]);
8265
- if (!deeper) via.push(i2);
8266
- }
8267
- }
8268
- via.sort((a3, b2) => Number(g2.isExt(a3)) - Number(g2.isExt(b2)) || (g2.nodes[a3].name < g2.nodes[b2].name ? -1 : 1));
8269
- out.push({ name, node, via: via.slice(0, VIA) });
8270
- }
8271
- return out;
8272
- }
8273
- function reviewQueue(g2, d2, root, shared) {
8274
- const set = reviewSet(g2, d2, root);
8275
- const order = reviewOrder(g2, set, shared);
8276
- const ax = order.filter((i2) => g2.nodes[i2].kind === "axiom");
8277
- return { order: [...ax, ...order.filter((i2) => g2.nodes[i2].kind !== "axiom")], axioms: axiomsReached(g2, root, set) };
8278
- }
8279
- function offBoard(q2) {
8280
- return q2.axioms.filter((a3) => a3.node === null);
8281
- }
8282
- function queueProgress(g2, d2, q2) {
8283
- const p2 = { total: 0, approved: 0, commented: 0, stale: 0 };
8284
- const count2 = (name, hash) => {
8285
- p2.total++;
8286
- const s2 = statusOf(d2, name, hash);
8287
- if (s2 === "approved") p2.approved++;
8288
- else if (s2 === "commented") p2.commented++;
8289
- else if (s2 === "stale") p2.stale++;
8290
- };
8291
- for (const i2 of q2.order) count2(g2.nodes[i2].name, g2.nodes[i2].hash);
8292
- for (const a3 of offBoard(q2)) count2(a3.name, void 0);
8293
- return p2;
8294
- }
8295
- function reviewCount(g2, d2, root) {
8296
- const set = reviewSet(g2, d2, root);
8297
- let n3 = 0;
8298
- for (let i2 = 0; i2 < g2.n; i2++) n3 += set[i2];
8299
- return n3 + axiomsReached(g2, root, set).filter((a3) => a3.node === null).length;
8300
- }
8301
- function settled(d2, reader, name, hash, axiom) {
8302
- return reviewedBy(d2, reader, name, hash) && (!axiom || statusOf(d2, name, hash) === "approved");
8303
- }
8304
- function reviewOrder(g2, set, shared) {
8305
- const members = [];
8306
- for (let i2 = 0; i2 < g2.n; i2++) if (set[i2]) members.push(i2);
8307
- return dependencyOrder(g2, members, (x2, y2) => shared[x2] !== shared[y2] ? shared[x2] > shared[y2] : g2.nodes[x2].name < g2.nodes[y2].name);
8308
- }
8309
- function dependencyOrder(g2, members, before = (x2, y2) => g2.nodes[x2].name < g2.nodes[y2].name) {
8310
- const local = /* @__PURE__ */ new Map();
8311
- members.forEach((v2, k2) => local.set(v2, k2));
8312
- const uses = members.map(() => []);
8313
- members.forEach((u2, a3) => {
8314
- for (let e2 = g2.outStart[u2]; e2 < g2.outStart[u2 + 1]; e2++) {
8315
- const b2 = g2.outSite[e2] & TCB_SITES ? local.get(g2.outDst[e2]) : void 0;
8316
- if (b2 !== void 0 && b2 !== a3) uses[a3].push(b2);
8317
- }
8318
- });
8319
- return stepOrder(uses, (a3, b2) => before(members[a3], members[b2])).map((a3) => members[a3]);
8320
- }
8321
- function stepOrder(uses, before) {
8322
- const m3 = uses.length;
8323
- const comp = components(uses);
8324
- const nc = comp.reduce((x2, c3) => Math.max(x2, c3 + 1), 0);
8325
- const steps = Array.from({ length: nc }, () => []);
8326
- for (let a3 = 0; a3 < m3; a3++) steps[comp[a3]].push(a3);
8327
- for (const s2 of steps) s2.sort((a3, b2) => before(a3, b2) ? -1 : before(b2, a3) ? 1 : 0);
8328
- const waiting = new Int32Array(nc);
8329
- const usedBy = Array.from({ length: nc }, () => []);
8330
- const seen = /* @__PURE__ */ new Set();
8331
- for (let a3 = 0; a3 < m3; a3++) {
8332
- for (const b2 of uses[a3]) {
8333
- const c3 = comp[a3], d2 = comp[b2];
8334
- if (c3 === d2 || seen.has(c3 * nc + d2)) continue;
8335
- seen.add(c3 * nc + d2);
8336
- waiting[c3]++;
8337
- usedBy[d2].push(c3);
8338
- }
8339
- }
8340
- const ready = new Heap((c3, d2) => before(steps[c3][0], steps[d2][0]));
8341
- for (let c3 = 0; c3 < nc; c3++) if (!waiting[c3]) ready.push(c3);
8342
- const out = [];
8343
- while (ready.size) {
8344
- const c3 = ready.pop();
8345
- for (const a3 of steps[c3]) out.push(a3);
8346
- for (const d2 of usedBy[c3]) if (--waiting[d2] === 0) ready.push(d2);
8347
- }
8348
- return out;
8349
- }
8350
- function components(succ) {
8351
- const n3 = succ.length;
8352
- const index = new Int32Array(n3).fill(-1);
8353
- const low = new Int32Array(n3);
8354
- const comp = new Int32Array(n3).fill(-1);
8355
- const onStack = new Uint8Array(n3);
8356
- const stack2 = [];
8357
- let next = 0, nc = 0;
8358
- const enter = (v2) => {
8359
- index[v2] = low[v2] = next++;
8360
- stack2.push(v2);
8361
- onStack[v2] = 1;
8362
- };
8363
- for (let s2 = 0; s2 < n3; s2++) {
8364
- if (index[s2] >= 0) continue;
8365
- enter(s2);
8366
- const path = [[s2, 0]];
8367
- while (path.length) {
8368
- const top = path[path.length - 1];
8369
- const v2 = top[0];
8370
- if (top[1] < succ[v2].length) {
8371
- const w2 = succ[v2][top[1]++];
8372
- if (index[w2] < 0) {
8373
- enter(w2);
8374
- path.push([w2, 0]);
8375
- } else if (onStack[w2]) low[v2] = Math.min(low[v2], index[w2]);
8376
- continue;
8377
- }
8378
- path.pop();
8379
- if (path.length) {
8380
- const u2 = path[path.length - 1][0];
8381
- low[u2] = Math.min(low[u2], low[v2]);
8382
- }
8383
- if (low[v2] === index[v2]) {
8384
- let w2;
8385
- do {
8386
- w2 = stack2.pop();
8387
- onStack[w2] = 0;
8388
- comp[w2] = nc;
8389
- } while (w2 !== v2);
8390
- nc++;
8391
- }
8392
- }
8393
- }
8394
- return comp;
8395
- }
8396
- var Heap = class {
8397
- xs = [];
8398
- before;
8399
- constructor(before) {
8400
- this.before = before;
8401
- }
8402
- get size() {
8403
- return this.xs.length;
8404
- }
8405
- push(x2) {
8406
- const xs = this.xs;
8407
- xs.push(x2);
8408
- for (let k2 = xs.length - 1; k2 > 0; ) {
8409
- const p2 = k2 - 1 >> 1;
8410
- if (!this.before(xs[k2], xs[p2])) break;
8411
- [xs[k2], xs[p2]] = [xs[p2], xs[k2]];
8412
- k2 = p2;
8413
- }
8414
- }
8415
- pop() {
8416
- const xs = this.xs;
8417
- const top = xs[0];
8418
- const last2 = xs.pop();
8419
- if (xs.length) {
8420
- xs[0] = last2;
8421
- for (let k2 = 0; ; ) {
8422
- const l2 = 2 * k2 + 1, r2 = l2 + 1;
8423
- let best = k2;
8424
- if (l2 < xs.length && this.before(xs[l2], xs[best])) best = l2;
8425
- if (r2 < xs.length && this.before(xs[r2], xs[best])) best = r2;
8426
- if (best === k2) break;
8427
- [xs[k2], xs[best]] = [xs[best], xs[k2]];
8428
- k2 = best;
8429
- }
8430
- }
8431
- return top;
8432
- }
8433
- };
8434
- function whyChain(g2, from, to) {
8435
- const parent = new Int32Array(g2.n).fill(-1);
8436
- parent[from] = from;
8437
- const queue = [from];
8438
- for (let k2 = 0; k2 < queue.length && parent[to] < 0; k2++) {
8439
- const u2 = queue[k2];
8440
- for (let e2 = g2.outStart[u2]; e2 < g2.outStart[u2 + 1]; e2++) {
8441
- const v2 = g2.outDst[e2];
8442
- if (!(g2.outSite[e2] & TCB_SITES) || parent[v2] >= 0) continue;
8443
- parent[v2] = u2;
8444
- queue.push(v2);
8445
- }
8446
- }
8447
- if (parent[to] < 0) return null;
8448
- const path = [to];
8449
- while (path[path.length - 1] !== from) path.push(parent[path[path.length - 1]]);
8450
- return path.reverse();
8451
- }
8452
- function reviewedBy(d2, reader, name, hash) {
8453
- return !!reader && current(d2, name).some((o2) => o2.by === reader && fresh(o2, hash));
8454
- }
8455
-
8456
8891
  // src/web/src/linediff.ts
8457
8892
  var MAX_CELLS = 4e6;
8458
8893
  function lineDiff(before, after, context = 2) {
@@ -10986,8 +11421,12 @@ var FOLLOWED = [
10986
11421
  },
10987
11422
  {
10988
11423
  part: "sources",
10989
- what: "the source windows: the one following the selection and each pinned one \u2014 open, collapsed or not, on what",
10990
- fields: ["source", "sourceCollapsed", "pinned"],
11424
+ what: "the source windows: the one following the selection and each pinned one \u2014 open, collapsed or not, on what, showing the declaration or the whole file (File mode); a file window, opened on a file",
11425
+ fields: ["source", "sourceCollapsed", "sourceMode", "pinned"],
11426
+ // a file opened from the Files tree, where a press opens a file window (the owner's decision of
11427
+ // 2026-11-01); in a window, its switch between the declaration and the file is a control of it,
11428
+ // as its pin is
11429
+ changes: "#outline [data-o-file]",
10991
11430
  reads: ".sw-win",
10992
11431
  keys: [" "],
10993
11432
  dblclick: ".sw-win:not(.collapsed) .sw-head",
@@ -11002,6 +11441,17 @@ var FOLLOWED = [
11002
11441
  dblclick: ".pw-win:not(.collapsed) .pw-head",
11003
11442
  place: true
11004
11443
  },
11444
+ {
11445
+ part: "caret",
11446
+ // ReviewSpec, "The InfoView" (the owner's decision of 2026-11-01): one reader steps through a
11447
+ // proof, those following them watch. ↑ and ↓ step it, in a source window: no page's key, they end
11448
+ // following as any key does that is not the reader's own
11449
+ what: "the InfoView's caret: the source window it is in, where in the file, and the goals before or after the tactic there",
11450
+ fields: ["caret"],
11451
+ changes: ".sw-info [data-iv-when]",
11452
+ reads: ".sw-info",
11453
+ place: true
11454
+ },
11005
11455
  {
11006
11456
  part: "activity",
11007
11457
  what: "Activity: open or closed, and its filters",
@@ -11065,6 +11515,9 @@ var YOURS = [
11065
11515
  { id: "tcbOrder", what: "the TCB list's order, and what of it is kept to by the reader's own review", where: "[data-tcb-order], [data-q-own]" },
11066
11516
  // the review box's opinions all folded or all shown (ReviewSpec, "One review box", the owner's
11067
11517
  // decision of 2026-10-20), a reading preference, and What changed under a stale one opened
11518
+ // File mode's proofs folded (the owner's decision of 2026-11-01): the reader's own, kept in the
11519
+ // browser, as is a folded proof opened
11520
+ { id: "proofFolds", what: "File mode's proofs folded to a line each, and a folded proof opened", where: "[data-sw-folds], [data-pf-open]" },
11068
11521
  { id: "opinions", what: "the review box's opinions, all folded or all shown, and What changed under a stale one", where: "[data-rv-fold], [data-rv-changes] > summary" },
11069
11522
  { id: "outline", what: "the outline's levels opened", where: "#outline .tw" },
11070
11523
  { id: "whatChanged", what: `"What changed" opened: the Time Machine's counts and the lists they open`, where: "#tmbar .tm-sum, [data-tm-list], #tm-list" },
@@ -11101,8 +11554,10 @@ var YOURS = [
11101
11554
  // link followed from a message — the reader's own tool changing a followed part, which says so
11102
11555
  // itself (web/src/talk.ts) — and Esc; its button and a mention's notice open it
11103
11556
  { id: "conversation", what: "the conversation window \u2014 its channels, its thread, its box, a link to what you see \u2014, the conversation button and a mention's notice", where: "#convo, #talk-btn, #talk-notice", whole: true },
11104
- { id: "followingStrip", what: "the following strip: whom you follow, and its \u2715", where: "#following", whole: true },
11557
+ { id: "followingStrip", what: "the following strip: whom you follow, and its \u2715; once following has ended by a move, Follow again", where: "#following", whole: true },
11105
11558
  { id: "hoverCards", what: "hover cards", where: ".hcard" },
11559
+ // the InfoView hidden or shown (ReviewSpec, "The InfoView"): how the reader looks at the source
11560
+ { id: "infoView", what: "the InfoView hidden or shown, in every source window (kept in the browser)", where: "[data-iv-hide], [data-iv-show]" },
11106
11561
  // the downloads of a followed reader's Export window (the owner's decision of 2026-10-21): taking
11107
11562
  // the file is reading, as copying text is; every other control of the window ends following
11108
11563
  { id: "exportDownloads", what: "the downloads the Export window offers: the PDF, the LaTeX sources, the .tex and the .sty", where: "#export-modal .ex-dl a" },
@@ -11382,6 +11837,10 @@ var People = class {
11382
11837
  store;
11383
11838
  hooks;
11384
11839
  followed = null;
11840
+ /** whom following last ended with by the reader's own action (the owner's decision of
11841
+ * 2026-10-30): the strip offers to follow them again until the reader answers it, follows anyone,
11842
+ * or they leave */
11843
+ again = null;
11385
11844
  /** the followed reader's place as last gone to: their place again (a presence list that changed
11386
11845
  * elsewhere) is not gone to again */
11387
11846
  applied = "";
@@ -11654,7 +12113,7 @@ var People = class {
11654
12113
  return this.unfollow();
11655
12114
  }
11656
12115
  if (!acts(e2)) return;
11657
- this.unfollow();
12116
+ this.leave();
11658
12117
  };
11659
12118
  window.addEventListener(
11660
12119
  "keydown",
@@ -11667,14 +12126,20 @@ var People = class {
11667
12126
  { capture: true }
11668
12127
  );
11669
12128
  for (const ev of ["pointerdown", "wheel", "keydown", "dblclick"]) window.addEventListener(ev, stop, { capture: true });
11670
- window.addEventListener("popstate", () => this.unfollow());
12129
+ window.addEventListener("popstate", () => this.leave());
11671
12130
  $3("#peers").addEventListener("click", (e2) => {
11672
12131
  const b2 = e2.target.closest("[data-person]");
11673
12132
  if (!b2) return;
11674
12133
  if (!this.hooks.menu?.(b2.dataset.person, b2)) this.follow(b2.dataset.person);
11675
12134
  });
11676
12135
  $3("#following").addEventListener("click", (e2) => {
11677
- if (e2.target.closest("[data-unfollow]")) this.unfollow();
12136
+ const t2 = e2.target;
12137
+ if (t2.closest("[data-unfollow]")) this.unfollow();
12138
+ else if (t2.closest("[data-again]")) {
12139
+ const key = this.again?.key;
12140
+ this.dropAgain();
12141
+ if (key) this.follow(key);
12142
+ } else if (t2.closest("[data-dismiss]")) this.dropAgain();
11678
12143
  });
11679
12144
  void this.beat();
11680
12145
  }
@@ -11736,6 +12201,7 @@ var People = class {
11736
12201
  this.followersChanged();
11737
12202
  this.hooks.changed();
11738
12203
  this.hooks.roomChanged?.();
12204
+ if (this.again && !this.people().some((x2) => x2.key === this.again.key)) this.dropAgain();
11739
12205
  if (!this.followed) return;
11740
12206
  const p2 = this.people().find((x2) => x2.key === this.followed.key);
11741
12207
  if (!p2) {
@@ -11818,11 +12284,13 @@ var People = class {
11818
12284
  if (!p2) return;
11819
12285
  if (this.followed?.key === key) return this.unfollow();
11820
12286
  if (this.followed) this.hooks.unfollowed();
12287
+ this.again = null;
11821
12288
  this.followed = { key, name: this.nameOf(p2) };
11822
12289
  this.applied = "";
11823
12290
  this.toldFollowing();
11824
12291
  const box = $3("#following");
11825
12292
  box.style.setProperty("--c", this.colorOf(p2));
12293
+ box.classList.remove("again");
11826
12294
  this.renderStrip(p2.agent);
11827
12295
  box.hidden = false;
11828
12296
  document.body.classList.add("following");
@@ -11843,10 +12311,36 @@ var People = class {
11843
12311
  const strip = $3(".fl-strip");
11844
12312
  strip.textContent = why;
11845
12313
  setTimeout(() => {
11846
- if (!this.followed) box.hidden = true;
12314
+ if (!this.followed && !this.again) box.hidden = true;
11847
12315
  }, 2500);
11848
12316
  } else box.hidden = true;
11849
12317
  }
12318
+ /** Following ended by the reader's own action — a move, a control of what they were shown, Back or
12319
+ * Forward, a link followed from the conversation (CollabSpec decision 4): the strip stays, offering
12320
+ * to follow the same reader again (the owner's decision of 2026-10-30). Esc and the strip's ✕,
12321
+ * which mean to stop, end it without the offer, as the followed reader leaving does. */
12322
+ leave() {
12323
+ const was = this.followed;
12324
+ if (!was) return;
12325
+ this.unfollow();
12326
+ const p2 = this.people().find((x2) => x2.key === was.key);
12327
+ if (!p2) return;
12328
+ this.again = was;
12329
+ const box = $3("#following");
12330
+ box.style.setProperty("--c", this.colorOf(p2));
12331
+ box.classList.add("again");
12332
+ $3(".fl-strip").innerHTML = `<span class="dot"></span>${p2.agent ? BOT : ""}<span class="fl-who">Stopped following <b>${escapeHtml(was.name)}</b></span><button data-again type="button" class="fl-again">Follow again</button><button data-dismiss type="button" title="Close" aria-label="Close">\u2715</button>`;
12333
+ box.hidden = false;
12334
+ }
12335
+ /** Put the offer to follow again away. */
12336
+ dropAgain() {
12337
+ if (!this.again) return;
12338
+ this.again = null;
12339
+ const box = $3("#following");
12340
+ box.classList.remove("again");
12341
+ if (box.contains(document.activeElement)) document.activeElement.blur();
12342
+ if (!this.followed) box.hidden = true;
12343
+ }
11850
12344
  /** The strip: "Following X · Esc to stop", and its ✕. */
11851
12345
  renderStrip(agent) {
11852
12346
  $3(".fl-strip").innerHTML = `<span class="dot"></span>${agent ? BOT : ""}<span class="fl-who">Following <b>${escapeHtml(this.followed?.name ?? "")}</b> \xB7 Esc to stop</span><button data-unfollow type="button" title="Stop following" aria-label="Stop following">\u2715</button>`;
@@ -14232,64 +14726,6 @@ var WholeReview = class {
14232
14726
  }
14233
14727
  };
14234
14728
 
14235
- // src/shared/excerpt.ts
14236
- var DECL = /^\s*(?:@\[[^\]]*\]\s*)*(?:(?:private|protected|noncomputable|partial|unsafe|nonrec|scoped|local)\s+)*(?:theorem|lemma|def|abbrev|instance|structure|class|inductive|axiom|opaque|example|irreducible_def)\s+(\S+)/;
14237
- var NEXT = /^(?:@\[|\/--|\/-!|--|#|(?:(?:private|protected|noncomputable|partial|unsafe|nonrec|scoped|local)\s+)*(?:theorem|lemma|def|abbrev|instance|structure|class|inductive|axiom|opaque|example|irreducible_def|namespace|section|end|open|variable|universe|attribute|set_option|mutual|macro|syntax|notation|infix|infixl|infixr|prefix|postfix|elab|deriving)\b)/;
14238
- function withPreamble(lines, line) {
14239
- let start = line;
14240
- while (start > 0 && line - start < 40) {
14241
- const above = lines[start - 1];
14242
- if (/^\s*@\[[^\]]*\]\s*$/.test(above) || /^\s*--/.test(above)) {
14243
- start--;
14244
- continue;
14245
- }
14246
- if (/-\/\s*$/.test(above)) {
14247
- let k2 = start - 1;
14248
- while (k2 > 0 && line - k2 < 60 && !/^\s*\/-/.test(lines[k2])) k2--;
14249
- if (/^\s*\/--/.test(lines[k2])) {
14250
- start = k2;
14251
- continue;
14252
- }
14253
- }
14254
- break;
14255
- }
14256
- return start;
14257
- }
14258
- function compiledExcerpt(lines, range) {
14259
- const l0 = Math.max(0, range[0] - 1);
14260
- const l1 = Math.min(lines.length - 1, Math.max(l0, range[2] - 1));
14261
- return { start: withPreamble(lines, l0), end: l1 };
14262
- }
14263
- function excerptOf(lines, edited, name, range) {
14264
- return edited ? findExcerpt(lines, name, range[0]) : compiledExcerpt(lines, range);
14265
- }
14266
- function findExcerpt(lines, name, near) {
14267
- const parts = name.split(".");
14268
- const short6 = parts[parts.length - 1].replace(/^«|»$/g, "");
14269
- const tail2 = parts.slice(-2).join(".");
14270
- let best = -1;
14271
- let bestScore = Infinity;
14272
- for (let i2 = 0; i2 < lines.length; i2++) {
14273
- const m3 = DECL.exec(lines[i2]);
14274
- if (!m3) continue;
14275
- const declared = m3[1].replace(/[«»]/g, "");
14276
- if (declared !== short6 && declared !== tail2.replace(/[«»]/g, "") && declared !== name && !name.endsWith("." + declared)) continue;
14277
- const score2 = near ? Math.abs(i2 + 1 - near) : i2;
14278
- if (score2 < bestScore) {
14279
- bestScore = score2;
14280
- best = i2;
14281
- }
14282
- }
14283
- if (best < 0) return null;
14284
- let end = best;
14285
- for (let i2 = best + 1; i2 < lines.length && i2 < best + 400; i2++) {
14286
- if (NEXT.test(lines[i2])) break;
14287
- end = i2;
14288
- }
14289
- while (end > best && !lines[end].trim()) end--;
14290
- return { start: withPreamble(lines, best), end };
14291
- }
14292
-
14293
14729
  // src/shared/context.ts
14294
14730
  function exactContext(m3, name, hash) {
14295
14731
  if (!m3 || !hash || m3.hash !== hash) return null;
@@ -14726,6 +15162,25 @@ var ReviewFlow = class {
14726
15162
  }
14727
15163
  };
14728
15164
 
15165
+ // src/shared/build.ts
15166
+ function applyBuildDelta(held2, d2) {
15167
+ if (d2.epoch !== held2.epoch || d2.base !== held2.rev) return null;
15168
+ const changed2 = new Map(d2.files.map((f2) => [f2.module, f2]));
15169
+ const gone = new Set(d2.gone);
15170
+ const files = [];
15171
+ for (const f2 of held2.status?.files ?? []) {
15172
+ if (gone.has(f2.module)) continue;
15173
+ const c3 = changed2.get(f2.module);
15174
+ files.push(c3 ?? f2);
15175
+ if (c3) changed2.delete(f2.module);
15176
+ }
15177
+ files.push(...changed2.values());
15178
+ return { epoch: d2.epoch, rev: d2.rev, status: { active: d2.active, progress: d2.progress, files, counts: d2.counts } };
15179
+ }
15180
+ function isCompiledText(compiled, now) {
15181
+ return !!compiled && !!now && compiled === now;
15182
+ }
15183
+
14729
15184
  // src/web/src/pagereview.ts
14730
15185
  function reviewPart(page) {
14731
15186
  const { data, store: store2, S: S7, kept, reader } = page;
@@ -14748,7 +15203,7 @@ function reviewPart(page) {
14748
15203
  if (known2 !== void 0) return known2;
14749
15204
  const c3 = page.compiled.get(mod);
14750
15205
  const src = await data.source(mod);
14751
- const e2 = !!c3 && !!src?.hash && src.hash !== c3;
15206
+ const e2 = !!src && !isCompiledText(c3, src.hash);
14752
15207
  edits.set(mod, e2);
14753
15208
  served.set(mod, src ? src.text.split("\n") : null);
14754
15209
  servedContexts.set(mod, { contexts: src?.contexts ?? null, hash: src?.hash ?? null });
@@ -15012,6 +15467,15 @@ function reviewPart(page) {
15012
15467
  };
15013
15468
  }
15014
15469
 
15470
+ // src/shared/hygiene.ts
15471
+ function hygienic(name) {
15472
+ return name.includes("._@.");
15473
+ }
15474
+ function withoutMacroScopes(name) {
15475
+ const k2 = name.indexOf("._@.");
15476
+ return k2 < 0 ? name : name.slice(0, k2);
15477
+ }
15478
+
15015
15479
  // src/web/src/targetlist.ts
15016
15480
  function targetRows(targets, views) {
15017
15481
  const linked = new Map(views.flatMap((v2) => (v2.targets ?? []).map((t2) => [t2, v2])));
@@ -15337,10 +15801,15 @@ function interpretsHtml(g2, i2) {
15337
15801
  function genNote() {
15338
15802
  return "Generated by Lean from the command at this place: not written in the source.";
15339
15803
  }
15804
+ function generatedName(unit, a3) {
15805
+ const n3 = withoutMacroScopes(a3);
15806
+ return { short: n3.startsWith(unit + ".") ? n3.slice(unit.length + 1) : n3.split(".").pop(), hygienic: hygienic(a3) };
15807
+ }
15340
15808
  function alsoList(unit, also) {
15341
15809
  return also.map((a3) => {
15342
- const short6 = a3.startsWith(unit + ".") ? a3.slice(unit.length + 1) : a3.split(".").pop();
15343
- return `<span class="p-decl" title="${escapeHtml(a3)}: generated by Lean from the command that writes ${escapeHtml(unit)}, and part of it">${escapeHtml(short6)}</span>`;
15810
+ const { short: short6, hygienic: hygienic2 } = generatedName(unit, a3);
15811
+ const title = hygienic2 ? `${withoutMacroScopes(a3)}: written by the macro of the command that writes ${unit}, under a name of its hygiene (${a3}), and part of it` : `${a3}: generated by Lean from the command that writes ${unit}, and part of it`;
15812
+ return `<span class="p-decl" title="${escapeHtml(title)}">${escapeHtml(short6)}</span>`;
15344
15813
  }).join(", ");
15345
15814
  }
15346
15815
 
@@ -15711,6 +16180,11 @@ var FloatWindow = class {
15711
16180
  this.watch.observe(el);
15712
16181
  }
15713
16182
  }
16183
+ /** Whether it is fitted to its content now: it grows and shrinks with it (the InfoView beside the
16184
+ * code, web/src/infoview.ts). */
16185
+ get fitted() {
16186
+ return this.fitting;
16187
+ }
15714
16188
  /** Bring the window to the front of the others; one on top is there already. */
15715
16189
  front() {
15716
16190
  if (this.o.onTop || stack[stack.length - 1] === this.el) return;
@@ -15928,6 +16402,9 @@ function pastNote(when, commit, check, outside2) {
15928
16402
  }
15929
16403
 
15930
16404
  // src/web/src/hovercards.ts
16405
+ function afterClick(clicked, word) {
16406
+ return clicked && word === clicked ? { show: false, clicked } : { show: true, clicked: "" };
16407
+ }
15931
16408
  var GRACE_MS = 350;
15932
16409
  var OPEN_MS = 280;
15933
16410
  var HoverCards = class {
@@ -16087,6 +16564,411 @@ var HoverCards = class {
16087
16564
  }
16088
16565
  };
16089
16566
 
16567
+ // src/shared/goals.ts
16568
+ function codeLines(text2) {
16569
+ const lines = text2.split("\n");
16570
+ const out = lines.map(() => false);
16571
+ let inComment = 0;
16572
+ lines.forEach((l2, k2) => {
16573
+ let i2 = 0;
16574
+ while (i2 < l2.length) {
16575
+ if (inComment) {
16576
+ if (l2.startsWith("-/", i2)) {
16577
+ inComment--;
16578
+ i2 += 2;
16579
+ } else if (l2.startsWith("/-", i2)) {
16580
+ inComment++;
16581
+ i2 += 2;
16582
+ } else i2++;
16583
+ continue;
16584
+ }
16585
+ if (l2.startsWith("/-", i2)) {
16586
+ inComment++;
16587
+ i2 += 2;
16588
+ continue;
16589
+ }
16590
+ if (l2.startsWith("--", i2)) break;
16591
+ if (l2[i2] === '"') {
16592
+ out[k2] = true;
16593
+ let j2 = i2 + 1;
16594
+ while (j2 < l2.length && l2[j2] !== '"') j2 += l2[j2] === "\\" ? 2 : 1;
16595
+ i2 = j2 + 1;
16596
+ continue;
16597
+ }
16598
+ if (!/\s/.test(l2[i2])) out[k2] = true;
16599
+ i2++;
16600
+ }
16601
+ });
16602
+ return out;
16603
+ }
16604
+ function stepLine(text2, k2, dir) {
16605
+ const has = codeLines(text2);
16606
+ const lines = text2.split("\n");
16607
+ for (let j2 = k2 + dir; j2 >= 0 && j2 < lines.length; j2 += dir) if (has[j2]) return { line: j2, ch: /^\s*/.exec(lines[j2])[0].length };
16608
+ return null;
16609
+ }
16610
+
16611
+ // src/web/src/infoview.ts
16612
+ var SLOW_MS = 300;
16613
+ var AGAIN_MS = 900;
16614
+ var SIDE_MIN = 700;
16615
+ var FITTED_MIN = 540;
16616
+ var SCREEN_MIN = 1e3;
16617
+ function paneSide(winWidth, fitted, screenWidth) {
16618
+ if (screenWidth < SCREEN_MIN && winWidth < SIDE_MIN) return false;
16619
+ return winWidth >= (fitted && screenWidth >= SCREEN_MIN ? FITTED_MIN : SIDE_MIN);
16620
+ }
16621
+ function caretOf(text2, offset) {
16622
+ const before = text2.slice(0, Math.max(0, Math.min(offset, text2.length)));
16623
+ const nl = before.lastIndexOf("\n");
16624
+ return { line: before.split("\n").length - 1, ch: before.length - (nl + 1) };
16625
+ }
16626
+ function taggedHtml(t2, isRef) {
16627
+ if (typeof t2 === "string") return highlightLean(t2, (w2) => isRef(w2));
16628
+ if (Array.isArray(t2)) return t2.map((x2) => taggedHtml(x2, isRef)).join("");
16629
+ return `<span class="iv-t${t2.d ? ` iv-${t2.d}` : ""}" data-k="${t2.k}">${taggedHtml(t2.t, isRef)}</span>`;
16630
+ }
16631
+ function locals(hyps) {
16632
+ return new Set(hyps.flatMap((h2) => h2.names));
16633
+ }
16634
+ function hypHtml(h2, isRef) {
16635
+ const d2 = h2.d ? ` iv-${h2.d}` : "";
16636
+ return `<div class="iv-hyp${d2}"><span class="iv-names">${h2.names.map(escapeHtml).join(" ")}</span><span class="iv-colon"> : </span><span class="iv-type">${taggedHtml(h2.type, isRef)}${h2.val !== void 0 ? `<span class="iv-colon"> := </span>${taggedHtml(h2.val, isRef)}` : ""}</span></div>`;
16637
+ }
16638
+ function goalHtml(g2, resolve) {
16639
+ const own2 = locals(g2.hyps);
16640
+ const isRef = (w2) => own2.has(w2) || own2.has(w2.split(".")[0]) ? null : resolve(w2);
16641
+ const d2 = g2.d ? ` iv-${g2.d}` : "";
16642
+ return `<div class="iv-goal${d2}">` + (g2.case ? `<div class="iv-case">case <b>${escapeHtml(g2.case)}</b></div>` : "") + g2.hyps.map((h2) => hypHtml(h2, isRef)).join("") + `<div class="iv-target"><span class="iv-turn">${escapeHtml((g2.prefix ?? "\u22A2 ").trim())}</span> ${taggedHtml(g2.type, isRef)}</div></div>`;
16643
+ }
16644
+ function paneView(caret, off, answer, resolve) {
16645
+ const say = (cls, text2) => ({ show: true, sides: false, html: `<p class="${cls}">${escapeHtml(text2)}</p>` });
16646
+ if (!caret) return { show: false, sides: false, html: "" };
16647
+ if (off) return say("iv-off", off);
16648
+ if (!answer) return say("iv-wait", "Asking Lean\u2026");
16649
+ if (answer.off) return say("iv-off", answer.off);
16650
+ if (answer.pending) return say("iv-wait", `Lean has elaborated line ${answer.pending.line.toLocaleString("en")} of ${answer.pending.of.toLocaleString("en")}\u2026`);
16651
+ if (answer.error) return say("iv-err", `Lean could not be asked: ${answer.error}`);
16652
+ const goals = caret.after ? answer.after : answer.before;
16653
+ const any = answer.before != null || answer.after != null;
16654
+ if (!any && !answer.term && !answer.widgets) return { show: false, sides: false, html: "" };
16655
+ let html = "";
16656
+ if (answer.widgets) html += `<p class="iv-widget" title="Its JavaScript is the project's own code: VisualProof never runs it in a reader's browser.">A widget here: open it in your editor.</p>`;
16657
+ if (any) {
16658
+ const n3 = goals?.length ?? 0;
16659
+ html += `<div class="iv-h">${goals == null ? "No tactic state here" : n3 === 0 ? "No goals" : n3 === 1 ? "1 goal" : `${n3} goals`}</div>`;
16660
+ if (caret.after && answer.afterFrom !== void 0 && goals)
16661
+ html += `<p class="iv-note" title="The tactic holds a proof of its own, which ends inside it: these are the goals after the whole line, where the proof goes on">As line ${answer.afterFrom + 1} begins, after the whole line</p>`;
16662
+ html += (goals ?? []).map((g2) => goalHtml(g2, resolve)).join("");
16663
+ }
16664
+ if (answer.term) {
16665
+ html += `<div class="iv-h">Expected type</div>`;
16666
+ html += goalHtml({ hyps: goals?.length ? [] : answer.term.hyps, type: answer.term.type }, resolve);
16667
+ }
16668
+ return { show: true, sides: any, html };
16669
+ }
16670
+ function headHtml(caret, sides, interactive) {
16671
+ const seg = sides ? `<span class="iv-seg" role="group" aria-label="The goals before or after the tactic"><button type="button" data-iv-when="before" aria-pressed="${!caret.after}" title="The goals before the tactic at the caret">Before</button><button type="button" data-iv-when="after" aria-pressed="${caret.after}" title="The goals after it">After</button></span>` : "";
16672
+ return `<div class="iv-head"><span class="iv-title">InfoView</span><span class="iv-where" title="${interactive ? "Hover a subterm for its type" : ""}">line ${caret.line + 1}, column ${caret.ch + 1}</span>${seg}<button type="button" class="icon iv-hide" data-iv-hide aria-label="Hide the InfoView" title="Hide the InfoView in every source window (kept in this browser)">${HIDE}</button></div>`;
16673
+ }
16674
+ var HIDE = `<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M6 4l4 4-4 4"/></svg>`;
16675
+ var InfoView = class {
16676
+ hooks;
16677
+ code = null;
16678
+ caret = null;
16679
+ answer = null;
16680
+ /** bumped at each new question, so that a slow answer to an earlier one is dropped */
16681
+ turn = 0;
16682
+ pane = null;
16683
+ /** a line of the file in the code on show: the code's element, or the window's way of finding
16684
+ * one (File mode's pieces, drawn as they are reached) */
16685
+ lines = null;
16686
+ again = null;
16687
+ slow = null;
16688
+ /** the subterm the pointer rests on, and the wait before its card */
16689
+ hot = null;
16690
+ hoverWait = null;
16691
+ hoverTurn = 0;
16692
+ sizer = null;
16693
+ constructor(hooks) {
16694
+ this.hooks = hooks;
16695
+ }
16696
+ /** The window drew its frame: the pane's element in it, the code's element — or how the element of
16697
+ * a line of the file is found (File mode, the owner's decision of 2026-11-01: the whole file, in
16698
+ * pieces) —, and the code on show (null: none). A caret outside the code on show goes. */
16699
+ attach(pane, lines, code) {
16700
+ const was = this.code;
16701
+ this.code = code;
16702
+ this.lines = lines;
16703
+ if (this.pane !== pane) {
16704
+ this.pane = pane;
16705
+ if (pane) this.listen(pane);
16706
+ }
16707
+ const same2 = !!was && !!code && was.module === code.module && was.hash === code.hash;
16708
+ if (!same2) this.answer = null;
16709
+ if (this.caret && !this.holds(this.caret.line)) this.caret = null;
16710
+ this.watchSize();
16711
+ if (this.caret && !same2) this.ask();
16712
+ else this.draw();
16713
+ }
16714
+ /** The element of line `line` of the file in the code on show, or null. */
16715
+ lineEl(line) {
16716
+ const c3 = this.code, l2 = this.lines;
16717
+ if (!c3 || !l2) return null;
16718
+ return typeof l2 === "function" ? l2(line) : l2.querySelectorAll(".ln")[line - c3.start] ?? null;
16719
+ }
16720
+ /** Whether line `line` of the file is in the code on show. */
16721
+ holds(line) {
16722
+ const c3 = this.code;
16723
+ return !!c3 && line >= c3.start && line < c3.start + c3.text.split("\n").length;
16724
+ }
16725
+ /** The caret put at (line, ch) of the file by the reader: a click, the keyboard's caret. */
16726
+ place(line, ch) {
16727
+ if (!this.holds(line)) return;
16728
+ const after = this.caret?.after ?? false;
16729
+ if (this.caret && this.caret.line === line && this.caret.ch === ch) return;
16730
+ this.caret = { line, ch, after };
16731
+ this.ask();
16732
+ this.hooks.moved();
16733
+ }
16734
+ /** ↑ or ↓: the caret to the previous or next line of code, where its code starts, the line
16735
+ * scrolled into sight. False where there is nothing to step to. */
16736
+ step(dir) {
16737
+ const c3 = this.code, k2 = this.caret;
16738
+ if (!c3 || !k2) return false;
16739
+ const to = stepLine(c3.text, k2.line - c3.start, dir);
16740
+ if (!to) return false;
16741
+ this.caret = { line: c3.start + to.line, ch: to.ch, after: k2.after };
16742
+ this.ask();
16743
+ this.hooks.moved();
16744
+ this.lineEl(c3.start + to.line)?.scrollIntoView({ block: "nearest" });
16745
+ return true;
16746
+ }
16747
+ /** The caret as a followed reader's is (CollabSpec, "Surfaces"), or none: nobody is told. */
16748
+ follow(c3) {
16749
+ const k2 = this.caret;
16750
+ if (!c3) return void (k2 && this.clear());
16751
+ if (k2 && k2.line === c3.line && k2.ch === c3.ch && k2.after === c3.after) return;
16752
+ const moved = !k2 || k2.line !== c3.line || k2.ch !== c3.ch;
16753
+ this.caret = { ...c3 };
16754
+ if (!this.code) return;
16755
+ if (!this.holds(c3.line)) return;
16756
+ if (moved) {
16757
+ this.ask();
16758
+ this.lineEl(c3.line)?.scrollIntoView({ block: "nearest" });
16759
+ } else this.draw();
16760
+ }
16761
+ /** No caret here any more: another window holds the page's. */
16762
+ clear() {
16763
+ if (!this.caret) return;
16764
+ this.caret = null;
16765
+ this.turn++;
16766
+ this.stopWaits();
16767
+ this.draw();
16768
+ }
16769
+ /** The window goes. */
16770
+ dispose() {
16771
+ this.turn++;
16772
+ this.stopWaits();
16773
+ this.sizer?.disconnect();
16774
+ this.sizer = null;
16775
+ this.pane = null;
16776
+ this.lines = null;
16777
+ }
16778
+ stopWaits() {
16779
+ if (this.again) clearTimeout(this.again);
16780
+ if (this.slow) clearTimeout(this.slow);
16781
+ if (this.hoverWait) clearTimeout(this.hoverWait);
16782
+ this.again = this.slow = this.hoverWait = null;
16783
+ }
16784
+ /** Lean asked what is at the caret; until it answers, the pane shows what it showed, and after a
16785
+ * moment that it asks. A place Lean has not reached yet is asked again until it has, the pane
16786
+ * saying how far Lean is meanwhile. */
16787
+ ask(again = false) {
16788
+ const c3 = this.code, k2 = this.caret;
16789
+ this.stopWaits();
16790
+ const turn = ++this.turn;
16791
+ if (!c3 || !k2 || c3.off) {
16792
+ this.answer = null;
16793
+ return this.draw();
16794
+ }
16795
+ if (!again)
16796
+ this.slow = setTimeout(() => {
16797
+ if (turn !== this.turn) return;
16798
+ this.answer = null;
16799
+ this.draw();
16800
+ }, SLOW_MS);
16801
+ this.marks();
16802
+ void this.hooks.goals(c3.module, k2.line, k2.ch, c3.hash).then((a3) => {
16803
+ if (turn !== this.turn) return;
16804
+ if (this.slow) clearTimeout(this.slow);
16805
+ this.slow = null;
16806
+ if (a3?.stale) return this.hooks.stale();
16807
+ this.answer = a3 ?? { off: "There is no Lean to ask here." };
16808
+ this.draw();
16809
+ if (a3?.pending) this.again = setTimeout(() => turn === this.turn && this.ask(true), AGAIN_MS);
16810
+ });
16811
+ }
16812
+ /** The pane drawn again as it stands, and the caret's line and tactic marked in the code. */
16813
+ draw() {
16814
+ this.marks();
16815
+ const pane = this.pane;
16816
+ if (!pane) return;
16817
+ const k2 = this.caret;
16818
+ const split = pane.parentElement;
16819
+ const v2 = paneView(k2, this.code?.off ?? null, this.answer, (w2) => this.hooks.resolve(w2));
16820
+ const hidden = this.hooks.hidden();
16821
+ const focused = document.activeElement;
16822
+ pane.hidden = !v2.show || hidden;
16823
+ split?.classList.toggle("iv-on", v2.show && !hidden);
16824
+ let tab = split?.querySelector(":scope > .iv-show") ?? null;
16825
+ if (v2.show && hidden && split) {
16826
+ if (!tab) {
16827
+ tab = document.createElement("button");
16828
+ tab.type = "button";
16829
+ tab.className = "iv-show";
16830
+ tab.dataset.ivShow = "";
16831
+ tab.title = "Show the InfoView: what Lean says at the caret (kept in this browser)";
16832
+ tab.innerHTML = `<span aria-hidden="true">\u22A2</span> Lean`;
16833
+ split.prepend(tab);
16834
+ }
16835
+ } else tab?.remove();
16836
+ const had = focused instanceof HTMLElement && (pane.contains(focused) || focused.matches("[data-iv-show]")) ? focused : null;
16837
+ const when = had?.closest("[data-iv-when]")?.dataset.ivWhen;
16838
+ if (!v2.show || hidden || !k2) {
16839
+ if (had) this.hooks.win().focus({ preventScroll: true });
16840
+ return;
16841
+ }
16842
+ pane.innerHTML = headHtml(k2, v2.sides, !!this.answer?.interactive) + `<div class="iv-body">${v2.html}</div>`;
16843
+ pane.setAttribute("aria-label", "What Lean says at the caret");
16844
+ if (had && !had.isConnected) (pane.querySelector(`[data-iv-when="${when}"]`) ?? this.hooks.win()).focus({ preventScroll: true });
16845
+ }
16846
+ /** The caret's line marked in the code, and its tactic, where the browser can (the CSS Custom
16847
+ * Highlight API): marks the code keeps however often it is drawn again. */
16848
+ marks() {
16849
+ const c3 = this.code, k2 = this.caret;
16850
+ for (const l2 of this.hooks.win().querySelectorAll(".ln.ln-caret")) l2.classList.remove("ln-caret");
16851
+ const hl = globalThis.CSS?.highlights;
16852
+ const Hl = globalThis.Highlight;
16853
+ if (!c3 || !k2 || !this.holds(k2.line)) return;
16854
+ const ln = this.lineEl(k2.line);
16855
+ ln?.classList.add("ln-caret");
16856
+ const a3 = this.answer;
16857
+ const t2 = a3 && (a3.before || a3.after) ? a3.tactic : null;
16858
+ if (!hl || !Hl || !ln) return;
16859
+ if (!t2 || t2.line !== k2.line || t2.to <= t2.from) return void hl.delete("vp-tactic");
16860
+ const r2 = rangeIn(ln, t2.from, t2.to);
16861
+ if (r2) hl.set("vp-tactic", new Hl(r2));
16862
+ }
16863
+ /** The pane's own controls and hover: before or after, hide and show, a subterm's card. */
16864
+ listen(pane) {
16865
+ const split = pane.parentElement;
16866
+ split?.addEventListener("click", (e2) => {
16867
+ const t2 = e2.target;
16868
+ if (t2.closest("[data-iv-show]")) {
16869
+ this.hooks.hide(false);
16870
+ return;
16871
+ }
16872
+ if (!pane.contains(t2)) return;
16873
+ if (t2.closest("[data-iv-hide]")) return this.hooks.hide(true);
16874
+ const when = t2.closest("[data-iv-when]")?.dataset.ivWhen;
16875
+ if (when && this.caret && this.caret.after !== (when === "after")) {
16876
+ this.caret = { ...this.caret, after: when === "after" };
16877
+ this.draw();
16878
+ this.hooks.moved();
16879
+ }
16880
+ });
16881
+ pane.addEventListener("mousemove", (e2) => {
16882
+ if (e2.buttons) return;
16883
+ const t2 = e2.target;
16884
+ const sub = this.answer?.interactive ? t2.closest(".iv-t") : null;
16885
+ const ref = t2.closest("[data-ref]");
16886
+ const on = sub ?? ref;
16887
+ if (this.hoverWait) clearTimeout(this.hoverWait);
16888
+ if (!on || !pane.contains(on)) {
16889
+ this.heat(null);
16890
+ return this.hooks.cards.leave();
16891
+ }
16892
+ if (on === this.hot && this.hooks.cards.open) return;
16893
+ this.hoverWait = setTimeout(() => this.hover(on), 150);
16894
+ });
16895
+ pane.addEventListener("mouseleave", () => {
16896
+ if (this.hoverWait) clearTimeout(this.hoverWait);
16897
+ this.heat(null);
16898
+ this.hooks.cards.leave();
16899
+ });
16900
+ }
16901
+ /** The subterm the pointer rests on, outlined. */
16902
+ heat(el) {
16903
+ if (this.hot === el) return;
16904
+ this.hot?.classList.remove("iv-hot");
16905
+ this.hot = el;
16906
+ el?.classList.add("iv-hot");
16907
+ }
16908
+ /** A card for what the pointer rests on in the pane: a subterm's type and doc, as Lean says them;
16909
+ * a name's card, as in the code, where Lean's goals are plain. */
16910
+ async hover(on) {
16911
+ const turn = ++this.hoverTurn;
16912
+ this.heat(on.matches(".iv-t") ? on : null);
16913
+ const box = on.getBoundingClientRect();
16914
+ const k2 = on.dataset.k;
16915
+ const c3 = this.code, caret = this.caret;
16916
+ if (k2 === void 0 || !c3 || !caret) {
16917
+ const name = on.dataset.ref;
16918
+ if (!name) return;
16919
+ const card = this.hooks.card(name);
16920
+ this.hooks.cards.show(card.html ?? `<pre class="code">${escapeHtml(name)}</pre><div class="sw-tip-wait">Asking Lean\u2026</div>`, box, name);
16921
+ void card.more?.then((html) => {
16922
+ if (turn === this.hoverTurn && html) this.hooks.cards.show(html, on.getBoundingClientRect(), name);
16923
+ });
16924
+ return;
16925
+ }
16926
+ const r2 = await this.hooks.subterm(c3.module, caret.line, caret.ch, c3.hash, Number(k2));
16927
+ if (turn !== this.hoverTurn || !on.isConnected) return;
16928
+ if (!r2 || r2.error || r2.pending || r2.stale || !r2.type && !r2.expr) return;
16929
+ this.hooks.cards.show(subtermHtml(r2, (w2) => this.hooks.resolve(w2)), box);
16930
+ }
16931
+ /** Keep the pane beside the code where the window is wide enough, else below it; and tell the
16932
+ * pane how tall the window's scrolled view is, which it stays within. */
16933
+ watchSize() {
16934
+ if (this.sizer || typeof ResizeObserver === "undefined") return this.size();
16935
+ this.sizer = new ResizeObserver(() => this.size());
16936
+ this.sizer.observe(this.hooks.win());
16937
+ this.size();
16938
+ }
16939
+ size() {
16940
+ const split = this.pane?.parentElement;
16941
+ const scroll = split?.closest(".sw-scroll");
16942
+ if (!split || !scroll) return;
16943
+ const side2 = paneSide(this.hooks.win().offsetWidth, this.hooks.fitted(), document.documentElement.clientWidth || innerWidth);
16944
+ split.classList.toggle("iv-side", side2);
16945
+ scroll.style.setProperty("--sw-view", `${scroll.clientHeight}px`);
16946
+ }
16947
+ };
16948
+ function subtermHtml(r2, resolve) {
16949
+ const isRef = (w2) => resolve(w2);
16950
+ const head = r2.expr && r2.type ? `${r2.expr} : ${r2.type}` : r2.type ?? r2.expr ?? "";
16951
+ return `<pre class="code">${highlightLean(head, isRef)}</pre>${r2.doc ? `<hr>${renderDoc(r2.doc)}` : ""}`;
16952
+ }
16953
+ function rangeIn(el, from, to) {
16954
+ const r2 = document.createRange();
16955
+ let acc = 0, started = false;
16956
+ const walker2 = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
16957
+ for (let n3 = walker2.nextNode(); n3; n3 = walker2.nextNode()) {
16958
+ const len = n3.data.length;
16959
+ if (!started && from < acc + len) {
16960
+ r2.setStart(n3, from - acc);
16961
+ started = true;
16962
+ }
16963
+ if (started && to <= acc + len) {
16964
+ r2.setEnd(n3, to - acc);
16965
+ return r2;
16966
+ }
16967
+ acc += len;
16968
+ }
16969
+ return null;
16970
+ }
16971
+
16090
16972
  // src/web/src/sources.ts
16091
16973
  var MIN = { w: 360, h: 160 };
16092
16974
  var FIT_W = 560;
@@ -16136,7 +17018,7 @@ var Sources = class {
16136
17018
  reveal(p2) {
16137
17019
  if (p2.collapsed) p2.collapse(false);
16138
17020
  p2.front();
16139
- if (p2.decl >= 0) this.hooks.shown?.(p2, p2.decl);
17021
+ if (p2.decl >= 0 && p2.file === null) this.hooks.shown?.(p2, p2.decl);
16140
17022
  }
16141
17023
  /** Space: the following window closes; collapsed, it opens again; with none, one opens on the
16142
17024
  * selection `i`. */
@@ -16169,7 +17051,7 @@ var Sources = class {
16169
17051
  const states = [];
16170
17052
  const missing = [];
16171
17053
  for (const e2 of s2.pinned) {
16172
- const on = [...left].filter((p3) => p3.decl === e2.decl);
17054
+ const on = [...left].filter((p3) => "file" in e2 ? p3.file === e2.file : p3.file === null && p3.decl === e2.decl);
16173
17055
  const p2 = on.find((q2) => this.mirrored.has(q2)) ?? on[0];
16174
17056
  if (!p2) {
16175
17057
  missing.push(e2);
@@ -16177,32 +17059,48 @@ var Sources = class {
16177
17059
  }
16178
17060
  left.delete(p2);
16179
17061
  this.mirrored.add(p2);
16180
- states.push([p2, e2.collapsed]);
17062
+ states.push([p2, e2.collapsed, modeOf(e2)]);
16181
17063
  }
16182
17064
  for (const p2 of left) if (this.mirrored.has(p2)) this.close(p2);
16183
17065
  for (const e2 of missing) {
16184
17066
  if (this.pinned.length >= MAX_PINNED) break;
16185
17067
  const f3 = this.following;
16186
17068
  let p2;
16187
- if (f3 && f3.decl === e2.decl && s2.following?.decl !== e2.decl) {
17069
+ if (!("file" in e2) && f3 && f3.decl === e2.decl && s2.following?.decl !== e2.decl) {
16188
17070
  this.pinAt(f3);
16189
17071
  p2 = f3;
16190
17072
  } else {
16191
17073
  p2 = this.hooks.make();
16192
17074
  p2.pinAside(this.pinned.length + 1);
16193
- p2.show(e2.decl);
17075
+ if ("file" in e2) p2.showFile(e2.file);
17076
+ else {
17077
+ if (p2.mode !== modeOf(e2)) p2.setMode(modeOf(e2));
17078
+ p2.show(e2.decl);
17079
+ }
16194
17080
  this.pinned.push(p2);
16195
17081
  this.hooks.changed();
16196
17082
  }
16197
17083
  this.mirrored.add(p2);
16198
- states.push([p2, e2.collapsed]);
17084
+ states.push([p2, e2.collapsed, modeOf(e2)]);
17085
+ }
17086
+ for (const [p2, on, mode] of states) {
17087
+ if (p2.mode !== mode) p2.setMode(mode);
17088
+ if (p2.collapsed !== on) p2.collapse(on);
16199
17089
  }
16200
- for (const [p2, on] of states) if (p2.collapsed !== on) p2.collapse(on);
16201
17090
  const f2 = s2.following;
16202
17091
  if (f2 && f2.decl !== null) {
16203
17092
  let p2 = this.following;
16204
- if (!p2) p2 = this.show(f2.decl);
16205
- else if (p2.decl !== f2.decl) {
17093
+ const mode = f2.mode ?? "decl";
17094
+ if (!p2) {
17095
+ p2 = this.hooks.make();
17096
+ if (mode !== p2.mode) p2.setMode(mode);
17097
+ this.following = p2;
17098
+ p2.show(f2.decl);
17099
+ this.hooks.changed();
17100
+ p2.front();
17101
+ this.hooks.shown?.(p2, f2.decl);
17102
+ } else if (p2.mode !== mode) p2.setMode(mode);
17103
+ if (p2.decl !== f2.decl) {
16206
17104
  p2.show(f2.decl);
16207
17105
  this.hooks.shown?.(p2, f2.decl);
16208
17106
  }
@@ -16225,11 +17123,33 @@ var Sources = class {
16225
17123
  this.pinAt(p2);
16226
17124
  return true;
16227
17125
  }
17126
+ /** A file opened from the Files tree or the board's menu (the owner's decision of 2026-11-01): a
17127
+ * file window on module `module`, pinned as it opens a step aside from the middle of the screen,
17128
+ * in File mode at the file's top; one on it already comes in front instead. It is no
17129
+ * declaration's: nothing is paired. Refused, with why, when MAX_PINNED are pinned already. */
17130
+ openFile(module) {
17131
+ const have = this.pinned.find((p3) => p3.file === module);
17132
+ if (have) {
17133
+ this.reveal(have);
17134
+ return have;
17135
+ }
17136
+ if (this.pinned.length >= MAX_PINNED) {
17137
+ this.hooks.say(PIN_CAP);
17138
+ return null;
17139
+ }
17140
+ const p2 = this.hooks.make();
17141
+ p2.pinAside(this.pinned.length + 1);
17142
+ p2.showFile(module);
17143
+ this.pinned.push(p2);
17144
+ p2.front();
17145
+ this.hooks.changed();
17146
+ return p2;
17147
+ }
16228
17148
  /** "Open in a pinned window" (the canvas's menu): declaration `i` in a window of its own, pinned
16229
17149
  * as it opens a step aside from the middle of the screen; a pinned window on it already comes
16230
17150
  * in front instead. Either is paired. Refused, with why, when MAX_PINNED are pinned already. */
16231
17151
  openPinned(i2) {
16232
- const have = this.pinned.find((p3) => p3.decl === i2);
17152
+ const have = this.pinned.find((p3) => p3.file === null && p3.decl === i2);
16233
17153
  if (have) {
16234
17154
  this.reveal(have);
16235
17155
  return have;
@@ -16275,15 +17195,22 @@ var Sources = class {
16275
17195
  for (const p2 of this.pinned) p2.redrawReview();
16276
17196
  }
16277
17197
  /** A new graph, or files that changed: each pinned window shows its declaration again, found by
16278
- * name; one whose declaration the graph no longer holds closes. */
17198
+ * name, a file window its file; one whose declaration — or file — the graph no longer holds
17199
+ * closes. */
16279
17200
  redraw(find) {
16280
17201
  for (const p2 of [...this.pinned]) {
17202
+ if (p2.file !== null) {
17203
+ if (this.hooks.hasFile && !this.hooks.hasFile(p2.file)) this.close(p2);
17204
+ else p2.showFile(p2.file);
17205
+ continue;
17206
+ }
16281
17207
  const i2 = find(p2.name);
16282
17208
  if (i2 === void 0) this.close(p2);
16283
17209
  else p2.show(i2);
16284
17210
  }
16285
17211
  }
16286
17212
  };
17213
+ var modeOf = (e2) => "file" in e2 ? "file" : e2.mode ?? "decl";
16287
17214
  function openBounds(vp, top = EDGE) {
16288
17215
  const max = { w: Math.min(0.92 * vp.w, vp.w - 2 * EDGE), h: Math.min(0.88 * vp.h, vp.h - top - EDGE) };
16289
17216
  return { max, min: { w: Math.min(FIT_W, max.w), h: Math.min(MIN.h, max.h) } };
@@ -16316,6 +17243,28 @@ var FORWARD = `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true
16316
17243
  var PIN = `<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true"><path d="M6 2.5h4l-.6 4 2.1 2.2v.8H4.5v-.8L6.6 6.5 6 2.5zM8 9.5v4"/></svg>`;
16317
17244
  var COLLAPSE = `<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 8.5h8"/></svg>`;
16318
17245
  var READ_WAIT = 1e3;
17246
+ var FILE_ANCHOR = "\u27E8file\u27E9";
17247
+ var FILE_GLYPH = `<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 1.8h5.2L12.5 5v9.2H4zM9 1.8V5.2h3.4"/></svg>`;
17248
+ var FILE_W = 1040;
17249
+ var LINE_H = 19.4;
17250
+ var NAMES_MAX = 5e3;
17251
+ function notThere(v2, era) {
17252
+ return v2.range ? `<div class="banner bad">${escapeHtml(v2.name)} is not in this text${era === "then" ? " at this build" : " any more under this name"}.</div>` : `<div class="banner">No source position was recorded for ${escapeHtml(v2.name)}.</div>`;
17253
+ }
17254
+ function chunkAt(chunks, line) {
17255
+ let lo = 0, hi = chunks.length - 1;
17256
+ while (lo <= hi) {
17257
+ const mid = lo + hi >> 1;
17258
+ if (chunks[mid].end < line) lo = mid + 1;
17259
+ else if (chunks[mid].start > line) hi = mid - 1;
17260
+ else return mid;
17261
+ }
17262
+ return -1;
17263
+ }
17264
+ function modeSwitch(mode, fileOnly) {
17265
+ const b2 = (m3, label, title) => `<button type="button" data-sw-mode="${m3}" aria-pressed="${mode === m3}"${m3 === "decl" && fileOnly ? " disabled" : ""} title="${escapeHtml(title)}">${label}</button>`;
17266
+ return `<span class="sw-mode" role="group" aria-label="Show">` + b2("decl", "Declaration", fileOnly ? "This window is on the file, not on a declaration: a name in it, or the bar over the code, selects one" : "The declaration, with the context it is written in") + b2("file", "File", "The whole file it is in, the declaration highlighted") + `</span>`;
17267
+ }
16319
17268
  var SourceWindow = class {
16320
17269
  g;
16321
17270
  /** the window, in the windows' layer (#windows); what is drawn in it, and the pill it collapses to */
@@ -16345,6 +17294,9 @@ var SourceWindow = class {
16345
17294
  /** the hover cards, and the word of the code the first one is for */
16346
17295
  cards;
16347
17296
  tipAt = "";
17297
+ /** the word the reader last clicked into with the mouse: no card for it until the pointer is on
17298
+ * another word (hovercards.ts, afterClick); "" for none */
17299
+ clicked = "";
16348
17300
  hoverTurn = 0;
16349
17301
  hoverWait = null;
16350
17302
  /** where the pointer last was over the code, to ask again when scrolling stops under it */
@@ -16383,6 +17335,26 @@ var SourceWindow = class {
16383
17335
  reading = 0;
16384
17336
  readWait = null;
16385
17337
  waiting = [];
17338
+ /** the InfoView: what Lean says at the caret (web/src/infoview.ts) */
17339
+ info;
17340
+ /** when a key was last pressed in the window: the keyboard's caret moves the selection */
17341
+ keyAt = 0;
17342
+ /** what it shows (the owner's decision of 2026-11-01): the declaration, or the whole file it is in */
17343
+ mode = "decl";
17344
+ /** a file window, opened on a file by its module (the Files tree, the board's menu; the owner's
17345
+ * decision of 2026-11-01): File mode alone, with no declaration of its own; null on a declaration */
17346
+ file = null;
17347
+ /** File mode as drawn: kept while the window steps to another declaration of the same text, which
17348
+ * moves only what is the declaration's, the reader's place staying */
17349
+ whole = null;
17350
+ /** the proofs opened one by one while proofs are folded, by where they start */
17351
+ openFolds = /* @__PURE__ */ new Set();
17352
+ /** where File mode, once drawn, scrolls: to the window's declaration (opening, a switch of mode),
17353
+ * a file window's top */
17354
+ scrollWanted = false;
17355
+ stickyWait = 0;
17356
+ /** File mode's pieces coming into sight: Lean is asked about the names of each then */
17357
+ seen = null;
16386
17358
  /** A window in `layer`, following the selection until it is pinned. */
16387
17359
  constructor(layer, g2, data, box, hooks, memory) {
16388
17360
  this.g = g2;
@@ -16411,7 +17383,11 @@ var SourceWindow = class {
16411
17383
  // beside the reference window it is paired with, it leaves that window its room, and is as
16412
17384
  // tall as it, so that their tops and bottoms line up
16413
17385
  bounds: (vp) => {
16414
- const b2 = openBounds(vp, this.aside ? this.hooks.top() : EDGE);
17386
+ let b2 = openBounds(vp, this.aside ? this.hooks.top() : EDGE);
17387
+ if (this.mode === "file") {
17388
+ const w2 = Math.min(b2.max.w, Math.max(b2.min.w, FILE_W));
17389
+ b2 = { max: { w: w2, h: b2.max.h }, min: { w: w2, h: b2.max.h } };
17390
+ }
16415
17391
  const d2 = this.hooks.docked?.(this);
16416
17392
  if (!d2) return b2;
16417
17393
  const r2 = d2.room(vp);
@@ -16430,6 +17406,13 @@ var SourceWindow = class {
16430
17406
  const keep2 = (e2) => e2.target.closest?.("[data-sw-quote]") && e2.preventDefault();
16431
17407
  el.addEventListener("pointerdown", keep2);
16432
17408
  el.addEventListener("mousedown", keep2);
17409
+ el.addEventListener("pointerdown", (e2) => {
17410
+ if (e2.pointerType === "touch" || e2.button !== 0) return;
17411
+ const pre = e2.target.closest?.("pre.src");
17412
+ if (!pre || !this.shown) return;
17413
+ this.hideTip();
17414
+ this.clicked = this.positionAt(pre, e2.clientX, e2.clientY)?.word ?? "";
17415
+ });
16433
17416
  document.addEventListener("selectionchange", this.onSelection);
16434
17417
  el.addEventListener("click", (e2) => {
16435
17418
  const t2 = e2.target;
@@ -16439,11 +17422,23 @@ var SourceWindow = class {
16439
17422
  if (t2.closest("[data-sw-back]")) return this.hooks.back();
16440
17423
  if (t2.closest("[data-sw-fwd]")) return this.hooks.forward();
16441
17424
  if (t2.closest(".sw-pill, [data-sw-collapse]")) return;
17425
+ const mode = t2.closest("[data-sw-mode]");
17426
+ if (mode) return this.setMode(mode.dataset.swMode === "file" ? "file" : "decl");
17427
+ if (t2.closest("[data-sw-folds]")) return this.foldProofs(!this.hooks.foldProofs());
17428
+ const fold2 = t2.closest("[data-pf-open]");
17429
+ if (fold2) return this.openFold(fold2.dataset.pfOpen);
17430
+ const here = t2.closest("[data-sw-at]");
17431
+ if (here) {
17432
+ if (this.g.byName.has(here.dataset.swAt)) this.hooks.go(here.dataset.swAt);
17433
+ return;
17434
+ }
16442
17435
  const ref = t2.closest("[data-ref]");
16443
17436
  if (ref) {
16444
17437
  if (this.g.byName.has(ref.dataset.ref)) this.hooks.go(ref.dataset.ref);
16445
17438
  return;
16446
17439
  }
17440
+ const pre = t2.closest("pre.src");
17441
+ if (pre && document.getSelection()?.isCollapsed !== false) return this.caretAtPoint(pre, e2.clientX, e2.clientY);
16447
17442
  const ctx = t2.closest("[data-sw-ctx]");
16448
17443
  if (ctx) {
16449
17444
  const box2 = ctx.closest(".sw-ctx");
@@ -16477,17 +17472,46 @@ var SourceWindow = class {
16477
17472
  if (this.g.byName.has(name)) this.hooks.go(name);
16478
17473
  }
16479
17474
  });
17475
+ this.info = new InfoView({
17476
+ goals: (m3, line, ch, hash) => this.data.goals(m3, line, ch, hash),
17477
+ subterm: (m3, line, ch, hash, k2) => this.data.subterm(m3, line, ch, hash, k2),
17478
+ // as the names of the code at the caret resolve: the declaration's, or in File mode the piece's
17479
+ resolve: (w2) => {
17480
+ const r2 = this.namesAt(this.info?.caret?.line ?? 0).resolve;
17481
+ return r2 ? r2(w2) : this.g.byName.has(w2) ? w2 : null;
17482
+ },
17483
+ cards: this.cards,
17484
+ card: (name) => ({ html: this.fromGraph(name), more: this.describe(name) }),
17485
+ hidden: () => this.hooks.infoHidden?.() ?? false,
17486
+ hide: (on) => this.hooks.hideInfo?.(on),
17487
+ moved: () => this.hooks.caretMoved?.(this),
17488
+ win: () => this.el,
17489
+ fitted: () => this.win.fitted,
17490
+ stale: () => void this.render(false)
17491
+ });
17492
+ el.addEventListener("keydown", (e2) => {
17493
+ this.keyAt = Date.now();
17494
+ if (e2.key !== "ArrowUp" && e2.key !== "ArrowDown" || e2.altKey || e2.ctrlKey || e2.metaKey || e2.shiftKey) return;
17495
+ const t2 = e2.target;
17496
+ if (t2.closest?.("input, textarea, select, [contenteditable]")) return;
17497
+ if (this.info.step(e2.key === "ArrowDown" ? 1 : -1)) e2.preventDefault();
17498
+ });
16480
17499
  el.addEventListener("mousemove", (e2) => {
17500
+ if (e2.target.closest?.(".sw-info")) return;
16481
17501
  const pre = e2.target.closest?.("pre.src");
16482
17502
  this.pointer = pre ? { pre, x: e2.clientX, y: e2.clientY } : null;
16483
17503
  if (this.hoverWait) clearTimeout(this.hoverWait);
16484
17504
  if (e2.buttons || this.picked) return;
16485
- if (!pre || !this.shown) return this.cards.leave();
17505
+ if (!pre || !this.shown) {
17506
+ this.clicked = "";
17507
+ return this.cards.leave();
17508
+ }
16486
17509
  const { clientX: x2, clientY: y2 } = e2;
16487
17510
  this.hoverWait = setTimeout(() => this.pointAt(pre, x2, y2), 120);
16488
17511
  });
16489
17512
  el.addEventListener("mouseleave", () => {
16490
17513
  this.pointer = null;
17514
+ this.clicked = "";
16491
17515
  if (this.hoverWait) clearTimeout(this.hoverWait);
16492
17516
  this.cards.leave();
16493
17517
  });
@@ -16495,6 +17519,7 @@ var SourceWindow = class {
16495
17519
  "scroll",
16496
17520
  () => {
16497
17521
  this.hideTip();
17522
+ this.stickyLater();
16498
17523
  if (this.scrollEnd) clearTimeout(this.scrollEnd);
16499
17524
  this.scrollEnd = setTimeout(() => {
16500
17525
  const p2 = this.pointer;
@@ -16520,10 +17545,40 @@ var SourceWindow = class {
16520
17545
  void this.render(fresh3);
16521
17546
  if (first) this.win.layout();
16522
17547
  }
17548
+ /** A file window on module `module` (the owner's decision of 2026-11-01): the whole file in File
17549
+ * mode from its top, not tied to the selection, with no declaration of its own; drawn again where
17550
+ * it is on it already. */
17551
+ showFile(module) {
17552
+ const first = !this.drawnOnce && this.file === null && this.current < 0;
17553
+ const fresh3 = module !== this.file;
17554
+ this.file = module;
17555
+ this.mode = "file";
17556
+ this.current = -1;
17557
+ this.name = "";
17558
+ if (fresh3) this.scrollWanted = true;
17559
+ void this.render(fresh3);
17560
+ if (first) this.win.layout();
17561
+ }
17562
+ /** What a page finds it by in its windows, and others' pointers in it: its declaration's name, a
17563
+ * file window's module under a mark of its own (no declaration's name is written so). */
17564
+ get anchor() {
17565
+ return this.file !== null ? `${FILE_ANCHOR}${this.file}` : this.name;
17566
+ }
17567
+ /** Shown in mode `m` (the owner's decision of 2026-11-01): its declaration, or the whole file it
17568
+ * is in, scrolled to it; switched by the reader in the title bar, or as a followed reader's window
17569
+ * is. A file window has File mode alone. */
17570
+ setMode(m3) {
17571
+ if (m3 === this.mode || this.file !== null && m3 === "decl") return;
17572
+ this.mode = m3;
17573
+ this.scrollWanted = true;
17574
+ this.unpick();
17575
+ if (this.current >= 0) void this.render(true).then(() => this.win.layout());
17576
+ this.hooks.moded(this);
17577
+ }
16523
17578
  /** Laid out again where it is kept or fitted: a reference window paired beside it, or gone,
16524
17579
  * changes the room it has. */
16525
17580
  relayout() {
16526
- if (this.current >= 0) this.win.layout();
17581
+ if (this.current >= 0 || this.file !== null) this.win.layout();
16527
17582
  }
16528
17583
  /** Whether the reader moved or resized it since the page last placed it: paired, their choice is
16529
17584
  * kept where the reference window can stand beside it (AttachmentSpec decision 8). */
@@ -16559,6 +17614,7 @@ var SourceWindow = class {
16559
17614
  * code of another declaration is read, the frame is still the one before's: the new frame draws
16560
17615
  * the review. */
16561
17616
  redrawReview() {
17617
+ if (this.mode === "file" && !this.reading) this.refreshMarks();
16562
17618
  const r2 = this.el.querySelector(".sw-review");
16563
17619
  if (!r2 || this.current < 0 || this.reading) return;
16564
17620
  const a3 = document.activeElement;
@@ -16587,7 +17643,7 @@ var SourceWindow = class {
16587
17643
  this.pinned = true;
16588
17644
  this.aside = step2;
16589
17645
  this.el.classList.add("pinned");
16590
- if (this.current < 0) return;
17646
+ if (this.current < 0 && this.file === null) return;
16591
17647
  this.win.layout();
16592
17648
  void this.render(false);
16593
17649
  }
@@ -16656,9 +17712,12 @@ var SourceWindow = class {
16656
17712
  if (this.selWait) cancelAnimationFrame(this.selWait);
16657
17713
  this.unpick();
16658
17714
  if (this.scrollEnd) clearTimeout(this.scrollEnd);
17715
+ if (this.stickyWait) cancelAnimationFrame(this.stickyWait);
17716
+ this.seen?.disconnect();
16659
17717
  this.pointer = null;
16660
17718
  this.shown = null;
16661
17719
  this.cards.dispose();
17720
+ this.info.dispose();
16662
17721
  this.win.dispose();
16663
17722
  if (this.el.contains(document.activeElement)) document.activeElement.blur();
16664
17723
  this.el.remove();
@@ -16675,18 +17734,23 @@ var SourceWindow = class {
16675
17734
  * a comment box, the lines it touches are picked, with the button that quotes them under the
16676
17735
  * last; elsewhere, nothing is. Hover cards close as text is picked. */
16677
17736
  selectionChanged() {
16678
- const pre = this.el.querySelector("pre.src");
16679
17737
  const s2 = document.getSelection();
17738
+ this.caretChanged(s2);
16680
17739
  const range = s2 && !s2.isCollapsed && s2.rangeCount ? s2.getRangeAt(0) : null;
16681
17740
  const c3 = this.code;
16682
- if (!pre || !c3 || !range || this.collapsed || !this.el.querySelector("[data-rv-comment]") || !range.intersectsNode(pre)) return this.unpick();
17741
+ const pres = range ? [...this.el.querySelectorAll("pre.src")].filter((p2) => range.intersectsNode(p2)) : [];
17742
+ if (!pres.length || !c3 || !range || this.collapsed || !this.el.querySelector("[data-rv-comment]")) return this.unpick();
16683
17743
  const text2 = c3.lines.join("\n");
16684
- const from = pre.contains(range.startContainer) ? offsetIn(pre, range.startContainer, range.startOffset) : 0;
16685
- const to = pre.contains(range.endContainer) ? offsetIn(pre, range.endContainer, range.endOffset) : text2.length;
17744
+ const starts = [0];
17745
+ for (let k2 = 0; k2 < c3.lines.length; k2++) starts.push(starts[k2] + c3.lines[k2].length + 1);
17746
+ const base = (pre) => starts[Math.max(0, Math.min(c3.lines.length - 1, Number(pre.dataset.line ?? c3.start) - c3.start))];
17747
+ const first = pres[0], last2 = pres[pres.length - 1];
17748
+ const from = first.contains(range.startContainer) ? base(first) + offsetIn(first, range.startContainer, range.startOffset) : base(first);
17749
+ const to = last2.contains(range.endContainer) ? base(last2) + offsetIn(last2, range.endContainer, range.endOffset) : base(last2) + (last2.textContent ?? "").length;
16686
17750
  const picked = selectedLines(text2, from, to);
16687
- const body = pre.closest(".sw-body");
16688
- const last2 = picked && pre.querySelectorAll(".ln")[picked.last];
16689
- if (!picked || !body || !last2) return this.unpick();
17751
+ const body = first.closest(".sw-body");
17752
+ const end = picked && this.lineEl(c3.start + picked.last);
17753
+ if (!picked || !body || !end) return this.unpick();
16690
17754
  if (!this.picked) this.hideTip();
16691
17755
  this.picked = picked;
16692
17756
  let b2 = this.quoteBtn;
@@ -16702,7 +17766,57 @@ var SourceWindow = class {
16702
17766
  const n3 = picked.last - picked.first + 1;
16703
17767
  b2.textContent = "\u275D Quote in comment";
16704
17768
  b2.title = `Quote ${n3 === 1 ? "this line" : `these ${n3} lines`} in your comment on ${this.name}, with where they are`;
16705
- b2.style.top = `${last2.getBoundingClientRect().bottom - body.getBoundingClientRect().top + 3}px`;
17769
+ b2.style.top = `${end.getBoundingClientRect().bottom - body.getBoundingClientRect().top + 3}px`;
17770
+ }
17771
+ /** The element of line `line` of the file (from 0) in the code on show, or null: the code's
17772
+ * blocks each say the line they start at (`data-line`), one block in Declaration mode, File
17773
+ * mode's pieces. */
17774
+ lineEl(line) {
17775
+ for (const pre of this.el.querySelectorAll("pre.src")) {
17776
+ const from = Number(pre.dataset.line ?? 0);
17777
+ const to = pre.dataset.end !== void 0 ? Number(pre.dataset.end) : from + pre.children.length - 1;
17778
+ if (line < from || line > to) continue;
17779
+ if (pre.dataset.end !== void 0) this.fill(pre);
17780
+ return pre.children[line - from] ?? null;
17781
+ }
17782
+ return null;
17783
+ }
17784
+ /** The keyboard's caret moved in the code (caret browsing: the selection collapsed there, a key just
17785
+ * pressed) puts the InfoView's caret there, as a click does (caretAtPoint). */
17786
+ caretChanged(s2) {
17787
+ if (!s2 || !s2.isCollapsed || !s2.rangeCount || Date.now() - this.keyAt > 500) return;
17788
+ const r2 = s2.getRangeAt(0);
17789
+ const at = r2.startContainer.nodeType === Node.ELEMENT_NODE ? r2.startContainer : r2.startContainer.parentElement;
17790
+ const pre = at?.closest("pre.src");
17791
+ if (pre && this.el.contains(pre)) this.caretIn(pre, r2.startContainer, r2.startOffset);
17792
+ }
17793
+ /** A click or a tap in the code puts the InfoView's caret where it landed. */
17794
+ caretAtPoint(pre, x2, y2) {
17795
+ const d2 = document;
17796
+ const r2 = d2.caretRangeFromPoint?.(x2, y2);
17797
+ const c3 = r2 ? null : d2.caretPositionFromPoint?.(x2, y2);
17798
+ const node = r2 ? r2.startContainer : c3?.offsetNode;
17799
+ if (node && pre.contains(node)) this.caretIn(pre, node, r2 ? r2.startOffset : c3.offset);
17800
+ }
17801
+ /** The InfoView's caret at a place of the code (a node and an offset there), at its line and column
17802
+ * in the file; not while the reader follows someone, whose caret it is (a click is reading then). */
17803
+ caretIn(pre, node, off) {
17804
+ if (!this.shown || !this.code || this.collapsed || this.hooks.following?.()) return;
17805
+ const at = caretOf(pre.textContent ?? "", offsetIn(pre, node, off));
17806
+ this.info.place(Number(pre.dataset.line ?? this.shown.start) + at.line, at.ch);
17807
+ }
17808
+ /** The InfoView's caret: where it is in the file, and whether the goals after the tactic are on
17809
+ * show; null where there is none in this window. */
17810
+ get caret() {
17811
+ return this.info.caret ? { ...this.info.caret } : null;
17812
+ }
17813
+ /** The caret as a followed reader's is, or none here (the page's one caret is in another window). */
17814
+ followCaret(c3) {
17815
+ this.info.follow(c3);
17816
+ }
17817
+ /** The InfoView hidden or shown again by the reader, in every window. */
17818
+ infoChanged() {
17819
+ this.info.draw();
16706
17820
  }
16707
17821
  /** Nothing picked: the quote button goes. */
16708
17822
  unpick() {
@@ -16734,26 +17848,25 @@ var SourceWindow = class {
16734
17848
  flashLines() {
16735
17849
  const w2 = this.linesWanted;
16736
17850
  const c3 = this.code;
16737
- const pre = this.el.querySelector("pre.src");
16738
- if (!w2 || !c3 || !pre) return;
17851
+ if (!w2 || !c3 || !this.el.querySelector("pre.src")) return;
16739
17852
  const now = Date.now();
16740
17853
  if (now > (w2.since ? w2.since + FLASH_MS : w2.until)) {
16741
17854
  this.linesWanted = null;
16742
17855
  return;
16743
17856
  }
16744
17857
  const span = locateLines(c3.lines, c3.start, w2.from, w2.to, w2.quoted);
17858
+ if (!span && this.mode === "decl" && !this.still) return this.setMode("file");
16745
17859
  if (!span) {
16746
17860
  this.linesWanted = null;
16747
17861
  return this.hooks.say(`Line${w2.to > w2.from ? `s ${w2.from}\u2013${w2.to} are` : ` ${w2.from} is`} not in the text of ${this.name} ${this.era === "then" ? "at this build" : "now"}.`);
16748
17862
  }
16749
- const lns = pre.querySelectorAll(".ln");
16750
17863
  for (let k2 = span[0]; k2 <= span[1]; k2++) {
16751
- const l2 = lns[k2];
17864
+ const l2 = this.lineEl(c3.start + k2);
16752
17865
  if (!l2) continue;
16753
17866
  l2.style.animationDelay = w2.since ? `${w2.since - now}ms` : "";
16754
17867
  l2.classList.add("ln-flash");
16755
17868
  }
16756
- if (!w2.since) lns[span[0]]?.scrollIntoView({ block: "center", behavior: reducedMotion() ? "auto" : "smooth" });
17869
+ if (!w2.since) this.lineEl(c3.start + span[0])?.scrollIntoView({ block: "center", behavior: reducedMotion() ? "auto" : "smooth" });
16757
17870
  w2.since ||= now;
16758
17871
  }
16759
17872
  // ---------------------------------------------------------------- what Lean says
@@ -16780,11 +17893,12 @@ var SourceWindow = class {
16780
17893
  }
16781
17894
  return null;
16782
17895
  }
16783
- /** The character of `pre` under (x, y): its line and UTF-16 column in the code, and the box of
16784
- * the word it is in (one part of a dotted name: `o` and `elim` in `o.elim` are different
17896
+ /** The character of `pre` under (x, y): its line in the file (from 0) and UTF-16 column, and the
17897
+ * box of the word it is in (one part of a dotted name: `o` and `elim` in `o.elim` are different
16785
17898
  * things); null over nothing (past the end of a line, between lines, in the indentation a
16786
17899
  * wrapped line hangs from). Lines are counted by the line breaks in the text, which the code
16787
- * keeps as it wraps (highlightLines): a line wrapped on the screen is one line here. */
17900
+ * keeps as it wraps (highlightLines): a line wrapped on the screen is one line here; from the
17901
+ * line the block starts at in the file (`data-line`), so that both modes count in the file. */
16788
17902
  positionAt(pre, x2, y2) {
16789
17903
  const d2 = document;
16790
17904
  let node = null, off = 0;
@@ -16796,8 +17910,8 @@ var SourceWindow = class {
16796
17910
  }
16797
17911
  if (!node || node.nodeType !== Node.TEXT_NODE || !pre.contains(node)) return null;
16798
17912
  const texts2 = [];
16799
- const walker = document.createTreeWalker(pre, NodeFilter.SHOW_TEXT);
16800
- for (let t2 = walker.nextNode(); t2; t2 = walker.nextNode()) texts2.push(t2);
17913
+ const walker2 = document.createTreeWalker(pre, NodeFilter.SHOW_TEXT);
17914
+ for (let t2 = walker2.nextNode(); t2; t2 = walker2.nextNode()) texts2.push(t2);
16801
17915
  let abs = 0;
16802
17916
  for (const t2 of texts2) {
16803
17917
  if (t2 === node) break;
@@ -16835,7 +17949,8 @@ var SourceWindow = class {
16835
17949
  while (isWord(text2[to])) to++;
16836
17950
  }
16837
17951
  const range = this.rangeIn(texts2, from, to);
16838
- return { line, ch: abs - (before + 1), word: `${line}:${from - (before + 1)}`, box: range ? range.getBoundingClientRect() : hit.rect };
17952
+ const at = Number(pre.dataset.line ?? 0) + line;
17953
+ return { line: at, ch: abs - (before + 1), word: `${at}:${from - (before + 1)}`, box: range ? range.getBoundingClientRect() : hit.rect };
16839
17954
  }
16840
17955
  /** A range over characters `from`–`to` of the text nodes `texts`. */
16841
17956
  rangeIn(texts2, from, to) {
@@ -16858,6 +17973,9 @@ var SourceWindow = class {
16858
17973
  pointAt(pre, x2, y2) {
16859
17974
  const at = this.positionAt(pre, x2, y2);
16860
17975
  if (!at || document.elementFromPoint(x2, y2)?.closest(".tk-doc, .tk-comment")) return this.cards.leave();
17976
+ const quiet = afterClick(this.clicked, at.word);
17977
+ this.clicked = quiet.clicked;
17978
+ if (!quiet.show) return;
16861
17979
  if (at.word === this.tipAt && this.cards.open) return;
16862
17980
  this.tipAt = at.word;
16863
17981
  const node = document.elementFromPoint(x2, y2);
@@ -16875,6 +17993,32 @@ var SourceWindow = class {
16875
17993
  const isRef = (w2) => w2 === v2.name ? w2 : own2(w2);
16876
17994
  return `<div class="hc-where"><span class="dot ${kindDot(v2.kind, g2.isExt(i2))}"></span>${escapeHtml(v2.kind)} \xB7 ${escapeHtml(v2.module)}</div><pre class="code">${highlightLean(v2.type ? `${v2.name} : ${v2.type}` : v2.name, isRef)}</pre>` + (v2.doc ? `<hr>${renderDoc(v2.doc)}` : "");
16877
17995
  }
17996
+ /** Where a place in the code on show is in its file, as Lean counts it: the line from 0 and the
17997
+ * UTF-16 character, in the module and the text (its Lake hash) on show — in either mode, the
17998
+ * code's blocks each counting from the line they start at in the file (`data-line`), a folded
17999
+ * proof's text being there still, hidden. `node` and `offset` as a caret or a selection's end
18000
+ * gives them; null outside the code, or where no text Lean knows is on show (a past build's).
18001
+ * What the hovers ask Lean at; what a pane beside the code may ask it at too. */
18002
+ positionOf(node, offset) {
18003
+ const s2 = this.shown;
18004
+ const e2 = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
18005
+ const pre = e2?.closest("pre.src");
18006
+ if (!s2 || !s2.hash || !pre || !this.el.contains(pre)) return null;
18007
+ const o2 = offsetIn(pre, node, offset);
18008
+ const before = (pre.textContent ?? "").slice(0, o2);
18009
+ const nl = before.lastIndexOf("\n");
18010
+ let line = 0;
18011
+ for (let k2 = before.indexOf("\n"); k2 >= 0; k2 = before.indexOf("\n", k2 + 1)) line++;
18012
+ return { module: s2.module, hash: s2.hash, line: Number(pre.dataset.line ?? 0) + line, character: o2 - nl - 1 };
18013
+ }
18014
+ /** How a name written at line `line` of the file on show resolves, and whose own name links
18015
+ * nowhere there: the declaration on show's; in File mode, the piece's there. */
18016
+ namesAt(line) {
18017
+ const w2 = this.whole;
18018
+ if (this.mode !== "file" || !w2) return { self: this.current >= 0 ? this.g.nodes[this.current].name : "", resolve: this.resolve };
18019
+ const k2 = chunkAt(w2.chunks, line);
18020
+ return k2 < 0 ? { self: "", resolve: null } : { self: w2.selfs[k2], resolve: w2.resolvers[k2] };
18021
+ }
16878
18022
  async ask(line, ch, box, ref) {
16879
18023
  const s2 = this.shown;
16880
18024
  if (!s2) return;
@@ -16883,7 +18027,7 @@ var SourceWindow = class {
16883
18027
  return graph2 ? this.showTip(graph2, box) : this.cards.leave();
16884
18028
  }
16885
18029
  const turn = ++this.hoverTurn;
16886
- const res = await this.data.hover(s2.module, s2.start + line, ch, s2.hash);
18030
+ const res = await this.data.hover(s2.module, line, ch, s2.hash);
16887
18031
  if (turn !== this.hoverTurn) return;
16888
18032
  const graph = this.fromGraph(ref);
16889
18033
  if (res === null) return graph ? this.showTip(graph, box) : this.cards.leave();
@@ -16900,15 +18044,16 @@ var SourceWindow = class {
16900
18044
  }
16901
18045
  if (res.error) return this.showTip(`${graph ?? ""}<div class="sw-tip-err">Lean could not be asked: ${escapeHtml(res.error)}</div>`, box);
16902
18046
  if (!res.contents) return graph ? this.showTip(graph, box) : this.cards.leave();
16903
- const self2 = this.current >= 0 ? this.g.nodes[this.current].name : "";
16904
- const resolve = this.resolve;
18047
+ const { self: self2, resolve } = this.namesAt(line);
16905
18048
  const head = /^```[^\n]*\n(\S+)/.exec(res.contents)?.[1]?.replace(/\.\{.*$/, "") ?? null;
16906
18049
  const subject = head && this.g.byName.has(head) ? head : null;
16907
18050
  this.showTip(renderHover(res.contents, (w2) => w2 === self2 ? w2 : resolve ? resolve(w2) : this.g.byName.has(w2) ? w2 : null), box, subject);
16908
18051
  }
16909
18052
  async render(fresh3) {
18053
+ if (this.mode === "file") return this.renderFile(fresh3);
16910
18054
  const i2 = this.current;
16911
18055
  if (i2 < 0) return;
18056
+ this.leaveFile();
16912
18057
  const turn = ++this.turn;
16913
18058
  this.hideTip();
16914
18059
  this.shown = null;
@@ -16933,20 +18078,23 @@ var SourceWindow = class {
16933
18078
  const nav = () => `<span class="nav"><button data-sw-back title="Back (Alt \u2190)" aria-label="Back"${steps().back ? "" : " disabled"}>${BACK}</button><button data-sw-fwd title="Forward (Alt \u2192)" aria-label="Forward"${steps().forward ? "" : " disabled"}>${FORWARD}</button></span>`;
16934
18079
  const pin = pinned ? `<span class="sw-pinned" role="img" aria-label="Pinned" title="Pinned: it stays on ${escapeHtml(v2.name)}, whatever is selected">${PIN}</span>` : `<button class="icon sw-pin" data-sw-pin aria-label="Pin" title="Pin: keep this window on ${escapeHtml(v2.name)}; the next source you open (Space) opens in a new window beside it">${PIN}</button>`;
16935
18080
  let remote = null;
16936
- const head = (where, editor) => `<div class="sw-head">${pinned ? "" : nav()}<span class="dot ${kindDot(v2.kind, ext)}"></span><span class="sw-name" title="${escapeHtml(v2.name)}">${short6}</span><span class="sw-ns">${escapeHtml(parts.slice(0, -1).join("."))}</span><span class="sw-loc">${where}</span>` + (editor ? editorAnchor(editor) : "") + (remote ? githubAnchor(remote.href, remote.commit, remote.what) : "") + `<span class="sw-acts">${pin}<button class="icon" data-sw-collapse aria-label="Collapse" title="Collapse to one line (or double-click the title bar)">${COLLAPSE}</button><button class="icon sw-close" data-sw-close aria-label="Close" title="${pinned ? "Close (Esc)" : "Close (Esc, or Space)"}">\u2715</button></span></div>`;
18081
+ const head = (where, editor) => `<div class="sw-head">${pinned ? "" : nav()}<span class="dot ${kindDot(v2.kind, ext)}"></span><span class="sw-name" title="${escapeHtml(v2.name)}">${short6}</span><span class="sw-ns">${escapeHtml(parts.slice(0, -1).join("."))}</span><span class="sw-loc">${where}</span>` + (editor ? editorAnchor(editor) : "") + (remote ? githubAnchor(remote.href, remote.commit, remote.what) : "") + modeSwitch("decl", false) + `<span class="sw-acts">${pin}<button class="icon" data-sw-collapse aria-label="Collapse" title="Collapse to one line (or double-click the title bar)">${COLLAPSE}</button><button class="icon sw-close" data-sw-close aria-label="Close" title="${pinned ? "Close (Esc)" : "Close (Esc, or Space)"}">\u2715</button></span></div>`;
16937
18082
  const frame2 = (where, notes2, body, editor = this.still ? null : this.hooks.editorLink(g2, i2), final = true) => {
16938
18083
  this.el.setAttribute("aria-label", `Source of ${v2.name}${pinned ? ", pinned" : ""}`);
16939
- this.frameEl.innerHTML = `${head(where, editor)}${this.pairHtml()}${notes2}<div class="sw-scroll"><div class="sw-body">${body}</div><div class="sw-review">${this.box.html(i2)}</div></div>`;
18084
+ this.frameEl.innerHTML = `${head(where, editor)}${this.pairHtml()}${notes2}<div class="sw-scroll"><div class="sw-split"><div class="sw-body">${body}</div><aside class="sw-info" hidden></aside></div><div class="sw-review">${this.box.html(i2)}</div></div>`;
16940
18085
  this.pillEl.innerHTML = `<button class="sw-pill-open" type="button" title="Open the source of ${escapeHtml(v2.name)} again"><span class="dot ${kindDot(v2.kind, ext)}"></span><span class="sw-pill-name">${short6}</span>${pinned ? `<span class="sw-pinned" aria-label="Pinned">${PIN}</span>` : ""}</button><button class="icon sw-close" data-sw-close aria-label="Close" title="Close">\u2715</button>`;
16941
18086
  if (final) this.drew();
16942
18087
  };
16943
18088
  if (!v2.range) {
16944
18089
  frame2(escapeHtml(v2.module), "", `<div class="sw-none">No source position was recorded for it.</div>`);
18090
+ this.attachInfo(null);
16945
18091
  this.box.reveal(this.el);
16946
18092
  return;
16947
18093
  }
16948
18094
  if (fresh3) this.awaitCode(turn, () => frame2(escapeHtml(v2.module), "", `<div class="sw-none">Reading the source\u2026</div>`, void 0, false));
18095
+ let infoCode = null;
16949
18096
  const settle2 = () => {
18097
+ this.attachInfo(infoCode);
16950
18098
  const scrolled = this.el.querySelector(".sw-scroll");
16951
18099
  if (scrolled && keep2 !== null) scrolled.scrollTop = keep2;
16952
18100
  if (hadFocus) {
@@ -16981,6 +18129,7 @@ var SourceWindow = class {
16981
18129
  if (href) remote = { href, commit: pc.hash };
16982
18130
  }
16983
18131
  this.shown = { module: v2.module, start: shot.start, hash: "" };
18132
+ infoCode = { module: v2.module, start: shot.start, text: shot.text, hash: "", off: "A past build has no InfoView: Lean knows only the latest build. Its goals are there, in the window of the board of now." };
16984
18133
  const notes2 = [`<div class="banner sw-then">${escapeHtml(pastNote(then.when, commit, got.check, got.outside))}</div>`];
16985
18134
  if (v2.gen !== void 0) notes2.unshift(`<div class="banner">${genNote()}</div>`);
16986
18135
  frame2(
@@ -16994,13 +18143,14 @@ var SourceWindow = class {
16994
18143
  if (turn !== this.turn || this.current !== i2) return;
16995
18144
  if (!src) {
16996
18145
  frame2(escapeHtml(v2.module), "", `<div class="sw-none">${ext ? "A declaration from outside the project: its source is not found here." : "The file could not be read."}</div>`);
18146
+ this.attachInfo(null);
16997
18147
  this.box.reveal(this.el);
16998
18148
  return;
16999
18149
  }
17000
18150
  const lines = src.text.split("\n");
17001
18151
  const out = src.outside;
17002
18152
  const compiled = this.hooks.compiledOf(v2.module);
17003
- const edited = out ? !!out.changed : !!compiled && !!src.hash && compiled !== src.hash;
18153
+ const edited = out ? !!out.changed : !isCompiledText(compiled, src.hash);
17004
18154
  const at = excerptOf(lines, edited, v2.name, v2.range);
17005
18155
  const notes = [];
17006
18156
  if (v2.gen !== void 0) notes.push(`<div class="banner">${genNote()}${this.still ? "" : " What Lean made of it is below the command."}</div>`);
@@ -17017,6 +18167,7 @@ var SourceWindow = class {
17017
18167
  const place2 = (out ? `${packageWords(out)} \xB7 ` : "") + src.file;
17018
18168
  if (!at) {
17019
18169
  frame2(escapeHtml(place2), notes.join(""), `<div class="sw-none">Not found in the present text.</div>`);
18170
+ this.attachInfo(null);
17020
18171
  this.box.reveal(this.el);
17021
18172
  return;
17022
18173
  }
@@ -17031,7 +18182,7 @@ var SourceWindow = class {
17031
18182
  }
17032
18183
  const resolve = resolver(g2, v2.name, scopeAt(lines, at.start, (n3) => namespacesOf(g2).has(n3)));
17033
18184
  this.resolve = resolve;
17034
- const key = `${v2.module}:${src.hash ?? ""}:${at.start}`;
18185
+ const key = `${v2.module}:${src.hash ?? ""}:${at.start}-${at.end}`;
17035
18186
  const known2 = this.still ? void 0 : this.memory.learned.get(key);
17036
18187
  const words = [];
17037
18188
  const code = highlightLines(
@@ -17042,6 +18193,13 @@ var SourceWindow = class {
17042
18193
  },
17043
18194
  at.start + 1
17044
18195
  );
18196
+ infoCode = {
18197
+ module: v2.module,
18198
+ start: at.start,
18199
+ text: text2,
18200
+ hash: src.hash ?? "",
18201
+ off: this.data.snapshot ? "A snapshot of the page has no InfoView: there is no Lean in it. The server's page shows the goals." : edited && out ? `${out.core ? "The toolchain" : out.package} is at another revision than when the graph was read: its goals would be another text's than Lean checked.` : edited ? "This file has changed since it was compiled: its goals would be the present text's, not what Lean checked. They come back once it is compiled again." : !src.hash ? "Lean cannot be asked about this file here." : null
18202
+ };
17045
18203
  if (src.hash) {
17046
18204
  this.shown = { module: v2.module, start: at.start, hash: src.hash };
17047
18205
  if (fresh3 && !this.still) this.data.hoverOpen(v2.module);
@@ -17063,7 +18221,531 @@ var SourceWindow = class {
17063
18221
  if (name && !this.memory.printed.has(name)) void this.printInto(turn, i2, name, out2);
17064
18222
  }
17065
18223
  settle2();
17066
- if (src.hash && !known2 && !this.still) void this.learn(turn, v2.name, key, v2.module, src.hash, text2, at.start, words, resolve);
18224
+ if (src.hash && !known2 && !this.still)
18225
+ void this.learn(() => turn === this.turn, v2.name, key, v2.module, src.hash, text2, at.start, words, (learned) => {
18226
+ const pre = this.el.querySelector("pre.src");
18227
+ if (!pre) return;
18228
+ pre.innerHTML = highlightLines(text2, (w2, off) => learned.has(off) ? learned.get(off) : resolve(w2), at.start + 1);
18229
+ this.flashLines();
18230
+ this.info.marks();
18231
+ });
18232
+ }
18233
+ // ---------------------------------------------------------------- File mode
18234
+ /** Out of File mode: what it drew of the file goes. */
18235
+ leaveFile() {
18236
+ this.whole = null;
18237
+ this.seen?.disconnect();
18238
+ this.seen = null;
18239
+ this.el.classList.remove("sw-file-mode", "sw-folds");
18240
+ }
18241
+ /** File mode's title bar: the declaration's, as Declaration mode's (its name, its namespace, where
18242
+ * it is, the editor's and GitHub's links), or a file window's, the file's name and folder; the
18243
+ * switch, set on File; the pin, collapse and close. */
18244
+ fileHead(where, editor, remote) {
18245
+ const pinned = this.pinned;
18246
+ const nav = `<span class="nav"><button data-sw-back title="Back (Alt \u2190)" aria-label="Back"${this.hooks.steps().back ? "" : " disabled"}>${BACK}</button><button data-sw-fwd title="Forward (Alt \u2192)" aria-label="Forward"${this.hooks.steps().forward ? "" : " disabled"}>${FORWARD}</button></span>`;
18247
+ const what = this.file !== null ? `the file ${this.file}` : this.g.nodes[this.current].name;
18248
+ const pin = pinned ? `<span class="sw-pinned" role="img" aria-label="Pinned" title="Pinned: it stays on ${escapeHtml(what)}, whatever is selected">${PIN}</span>` : `<button class="icon sw-pin" data-sw-pin aria-label="Pin" title="Pin: keep this window on ${escapeHtml(what)}; the next source you open (Space) opens in a new window beside it">${PIN}</button>`;
18249
+ let title;
18250
+ if (this.file !== null) {
18251
+ const parts = this.file.split(".");
18252
+ title = `<span class="sw-glyph">${FILE_GLYPH}</span><span class="sw-name" title="${escapeHtml(this.file)}">${escapeHtml(parts[parts.length - 1])}</span><span class="sw-ns">${escapeHtml(parts.slice(0, -1).join("."))}</span>`;
18253
+ } else {
18254
+ const v2 = this.g.nodes[this.current];
18255
+ const parts = v2.name.split(".");
18256
+ title = `<span class="dot ${kindDot(v2.kind, this.g.isExt(this.current))}"></span><span class="sw-name" title="${escapeHtml(v2.name)}">${escapeHtml(v2.display ?? parts[parts.length - 1])}</span><span class="sw-ns">${escapeHtml(parts.slice(0, -1).join("."))}</span>`;
18257
+ }
18258
+ return `<div class="sw-head">${pinned ? "" : nav}${title}<span class="sw-loc">${where}</span>` + (editor ? editorAnchor(editor) : "") + (remote ? githubAnchor(remote.href, remote.commit, remote.what) : "") + modeSwitch("file", this.file !== null) + `<span class="sw-acts">${pin}<button class="icon" data-sw-collapse aria-label="Collapse" title="Collapse to one line (or double-click the title bar)">${COLLAPSE}</button><button class="icon sw-close" data-sw-close aria-label="Close" title="${pinned ? "Close (Esc)" : "Close (Esc, or Space)"}">\u2715</button></span></div>`;
18259
+ }
18260
+ /** File mode's frame: the title bar, the notes under it, and what scrolls — the sticky header and
18261
+ * the code, with the review box under the declaration's lines; `final`: the file's own, not
18262
+ * what stands for it while it is read. */
18263
+ paintFile(head, notes, inner, final = true) {
18264
+ const pinned = this.pinned;
18265
+ const v2 = this.current >= 0 ? this.g.nodes[this.current] : null;
18266
+ this.el.setAttribute("aria-label", v2 ? `Source of ${v2.name}, the whole file${pinned ? ", pinned" : ""}` : `The file ${this.file}${pinned ? ", pinned" : ""}`);
18267
+ this.frameEl.innerHTML = `${head}${this.pairHtml()}${notes}<div class="sw-scroll">${inner}</div>`;
18268
+ const name = v2 ? escapeHtml(v2.display ?? v2.name.split(".").pop()) : escapeHtml(this.file.split(".").pop());
18269
+ this.pillEl.innerHTML = `<button class="sw-pill-open" type="button" title="Open ${v2 ? `the source of ${escapeHtml(v2.name)}` : `the file ${escapeHtml(this.file)}`} again">` + (v2 ? `<span class="dot ${kindDot(v2.kind, this.g.isExt(this.current))}"></span>` : `<span class="sw-glyph">${FILE_GLYPH}</span>`) + `<span class="sw-pill-name">${name}</span>${pinned ? `<span class="sw-pinned" aria-label="Pinned">${PIN}</span>` : ""}</button><button class="icon sw-close" data-sw-close aria-label="Close" title="Close">\u2715</button>`;
18270
+ if (final) this.drew();
18271
+ }
18272
+ /** File mode (ReviewSpec, "The source window", the owner's decisions of 2026-11-01): the whole
18273
+ * file the window's declaration is in — a file window's, the file it was opened on — as the graph
18274
+ * was read from it, as it is now under the warning where it changed since, or as a past build
18275
+ * compiled it. The declaration is highlighted and scrolled to as the window opens or switches
18276
+ * mode; each declaration has its mark in the gutter; the review box is the declaration's, under
18277
+ * its lines; a sticky header names the declaration the reading position is in. A step to another
18278
+ * declaration of the same text moves only what is the declaration's, the reader's place staying. */
18279
+ async renderFile(fresh3) {
18280
+ const g2 = this.g;
18281
+ const i2 = this.current;
18282
+ const v2 = i2 >= 0 ? g2.nodes[i2] : null;
18283
+ const module = this.file ?? v2?.module;
18284
+ if (!module) return;
18285
+ const turn = ++this.turn;
18286
+ this.hideTip();
18287
+ this.unpick();
18288
+ const past = this.hooks.pastOf(g2);
18289
+ this.still = !!past;
18290
+ this.era = past ? "then" : "now";
18291
+ this.el.classList.add("sw-file-mode");
18292
+ this.el.classList.toggle("sw-folds", this.hooks.foldProofs());
18293
+ const before = this.whole;
18294
+ const scroll = this.el.querySelector(".sw-scroll");
18295
+ const keep2 = !this.scrollWanted && before?.module === module && scroll ? scroll.scrollTop : null;
18296
+ if (fresh3 && !(before && before.module === module && before.g === g2)) this.awaitCode(turn, () => this.paintFile(this.fileHead(escapeHtml(module), null, null), "", `<div class="sw-body"><div class="sw-none">Reading the file\u2026</div></div>`, false));
18297
+ let text2, file, hash = "", edited = false, out;
18298
+ let passRead = () => false;
18299
+ const notes = [];
18300
+ let remoteFor = () => null;
18301
+ const nowhere = (where, note, why) => {
18302
+ this.leaveFile();
18303
+ this.paintFile(this.fileHead(escapeHtml(where), null, null), note, `<div class="sw-body"><div class="sw-none">${why}</div></div>${v2 ? `<div class="sw-review">${this.box.html(i2)}</div>` : ""}`);
18304
+ this.attachInfo(null);
18305
+ this.box.reveal(this.el);
18306
+ };
18307
+ if (past) {
18308
+ const got = await this.data.pastSource(past.past.snapshot.id, module);
18309
+ if (turn !== this.turn) return;
18310
+ const commit = past.past.snapshot.commit?.hash ?? null;
18311
+ if ("missing" in got) {
18312
+ const why = got.why ? `: ${escapeHtml(got.why)}` : "";
18313
+ return nowhere(got.file || module, `<div class="banner sw-then">As built ${escapeHtml(past.when)}${commit ? ` \xB7 <code>${escapeHtml(commit.slice(0, 7))}</code>` : ""}</div>`, `This file at this build ${got.outside ? "was" : "is"} not kept${why}.`);
18314
+ }
18315
+ ({ text: text2, file, outside: out } = got);
18316
+ notes.push(`<div class="banner sw-then">${escapeHtml(pastNote(past.when, commit, got.check, got.outside))}</div>`);
18317
+ const pc = past.past.snapshot.commit;
18318
+ const o2 = out;
18319
+ remoteFor = (from, to) => {
18320
+ const href = o2?.github ? outsideLink(o2, from, to) : !o2 && pc && !pc.dirty && !pc.guessed && (got.from === "tree" || got.from === `git:${pc.hash}`) ? this.hooks.githubLink?.(file, pc.hash, from, to) : null;
18321
+ return href ? o2?.github ? { href, commit: o2.github.rev, what: packageWords(o2) } : { href, commit: pc.hash } : null;
18322
+ };
18323
+ } else {
18324
+ const src = await this.data.source(module);
18325
+ if (turn !== this.turn) return;
18326
+ if (!src) return nowhere(module, "", this.file === null && v2 && g2.isExt(i2) ? "A declaration from outside the project: its source is not found here." : "The file could not be read.");
18327
+ ({ text: text2, file, outside: out } = src);
18328
+ hash = src.hash ?? "";
18329
+ const compiled2 = this.hooks.compiledOf(module);
18330
+ edited = out ? !!out.changed : !isCompiledText(compiled2, src.hash);
18331
+ const o2 = out, e2 = edited, at = file;
18332
+ remoteFor = (from, to) => this.nowRemote(at, o2, e2, from, to);
18333
+ passRead = (j2) => !edited && !!src.hash && src.contexts?.hash === src.hash && Object.hasOwn(src.contexts.decls, g2.nodes[j2].name);
18334
+ const f2 = this.hooks.fileOf(module);
18335
+ if (f2 && (f2.state === "failed" || f2.state === "unbuilt")) notes.push(`<div class="banner bad">The last build of this file failed: the graph shows it as it was last compiled.</div>`);
18336
+ if (edited && out)
18337
+ notes.push(`<div class="banner warn">${escapeHtml(out.core ? "The toolchain" : out.package)} is at another revision than when the graph was read (${escapeHtml(packageWords(out))} now). Below is its present text; the graph refers to what was read then, and no declaration's mark is shown.</div>`);
18338
+ else if (edited)
18339
+ notes.push(`<div class="banner warn">This file has changed since it was compiled. Below is its present text; the statements, the TCBs and the review refer to the compiled version, and a declaration's mark shows only where its text is still the one compiled.</div>`);
18340
+ }
18341
+ const place2 = (out ? `${packageWords(out)} \xB7 ` : "") + file;
18342
+ if (before && before.g === g2 && before.module === module && before.text === text2 && before.era === this.era && this.el.querySelector(".sw-file")) {
18343
+ this.whole = before;
18344
+ this.placeOwn(fresh3, notes, place2, edited, remoteFor, out);
18345
+ return;
18346
+ }
18347
+ const lines = text2.split("\n");
18348
+ const decls = fileDecls(g2, module, lines, edited);
18349
+ const chunks = chunksOf(decls, lines.length);
18350
+ const spaces = namespacesOf(g2);
18351
+ const scopes = scopesAt(lines, chunks.map((c3) => c3.start), (n3) => spaces.has(n3));
18352
+ let d2 = 0;
18353
+ const selfs = chunks.map((c3) => {
18354
+ while (d2 < decls.length && decls[d2].start < c3.start) d2++;
18355
+ return d2 < decls.length && decls[d2].start <= c3.end ? g2.nodes[decls[d2].i].name : "";
18356
+ });
18357
+ const resolvers = chunks.map((_2, k2) => resolver(g2, selfs[k2], scopes[k2]));
18358
+ const folds = proofFolds(g2, decls, lines, passRead);
18359
+ const compiled = edited && !out && !past ? await this.hooks.compiledText(module) : null;
18360
+ if (turn !== this.turn) return;
18361
+ if (before?.module !== module) this.openFolds.clear();
18362
+ const w2 = { g: g2, module, text: text2, file, hash, lines, era: this.era, edited, decls, chunks, selfs, resolvers, folds, marks: [], compiled };
18363
+ this.whole = w2;
18364
+ this.marksOf(w2);
18365
+ const own2 = this.ownDecl();
18366
+ const ownAt = own2 ? chunkAt(chunks, own2.start) : -1;
18367
+ const review = v2 ? `<div class="sw-review">${this.box.html(i2)}</div>` : "";
18368
+ if (v2 && !own2) notes.push(notThere(v2, this.era));
18369
+ const body = chunks.map((_2, k2) => this.pieceHtml(k2) + (k2 === ownAt ? review : "")).join("");
18370
+ this.paintFile(
18371
+ this.fileHead(this.fileWhere(place2, edited), this.ownEditor(edited), remoteFor(...this.ownLines())),
18372
+ notes.join(""),
18373
+ `<div class="sw-sticky"><span class="sw-at-slot"></span>${this.foldsButton()}</div><div class="sw-split"><div class="sw-body sw-file">${own2 || !v2 ? "" : review}${body}</div><aside class="sw-info" hidden></aside></div>`
18374
+ );
18375
+ this.code = { file, start: 0, lines };
18376
+ this.resolve = null;
18377
+ this.shown = { module, start: 0, hash };
18378
+ this.attachInfo(this.fileInfo(w2, past !== null, out));
18379
+ if (fresh3 && !this.still && hash) this.data.hoverOpen(module);
18380
+ this.fillAround(own2 ? own2.start : 0);
18381
+ this.watchPieces(w2);
18382
+ const sc = this.el.querySelector(".sw-scroll");
18383
+ if (sc && keep2 !== null) sc.scrollTop = keep2;
18384
+ if (this.scrollWanted || fresh3) this.scrollToOwn();
18385
+ this.scrollWanted = false;
18386
+ this.updateSticky();
18387
+ this.box.reveal(this.el);
18388
+ this.flashLines();
18389
+ }
18390
+ /** The InfoView's code in File mode: the whole file from its first line; why Lean is not asked
18391
+ * about it, as in Declaration mode — a past build's, a snapshot's, a text changed since it was
18392
+ * compiled. */
18393
+ fileInfo(w2, past, out) {
18394
+ const off = past ? "A past build has no InfoView: Lean knows only the latest build. Its goals are there, in the window of the board of now." : this.data.snapshot ? "A snapshot of the page has no InfoView: there is no Lean in it. The server's page shows the goals." : w2.edited && out ? `${out.core ? "The toolchain" : out.package} is at another revision than when the graph was read: its goals would be another text's than Lean checked.` : w2.edited ? "This file has changed since it was compiled: its goals would be the present text's, not what Lean checked. They come back once it is compiled again." : !w2.hash ? "Lean cannot be asked about this file here." : null;
18395
+ return { module: w2.module, start: 0, text: w2.text, hash: w2.hash, off };
18396
+ }
18397
+ /** Where File mode's file is, as the title bar says it: the file, the declaration's lines in it. */
18398
+ fileWhere(place2, edited) {
18399
+ const own2 = this.ownDecl();
18400
+ return `${escapeHtml(place2)}${own2 ? `:${own2.start + 1}\u2013${own2.end + 1}` : ""}${edited ? " \xB7 present text" : ""}`;
18401
+ }
18402
+ /** The editor's link to the window's declaration in File mode, as in Declaration mode; none for a
18403
+ * file window or a past build. */
18404
+ ownEditor(edited) {
18405
+ const own2 = this.ownDecl();
18406
+ if (this.still || this.current < 0) return null;
18407
+ return this.hooks.editorLink(this.g, this.current, edited && own2 ? { line: own2.start + 1, col: 1 } : void 0);
18408
+ }
18409
+ /** GitHub's link to lines `from`–`to` of the file of now (DeploySpec decision 13): at the build's
18410
+ * commit, outside the project in its package at its revision; none for a text changed since. */
18411
+ nowRemote(file, out, edited, from, to) {
18412
+ if (edited) return null;
18413
+ if (out) {
18414
+ const href2 = outsideLink(out, from, to);
18415
+ return href2 && out.github ? { href: href2, commit: out.github.rev, what: packageWords(out) } : null;
18416
+ }
18417
+ const built = this.hooks.builtCommit?.();
18418
+ const href = built ? this.hooks.githubLink?.(file, built, from, to) : null;
18419
+ return href && built ? { href, commit: built } : null;
18420
+ }
18421
+ /** The window's declaration's lines (from 1), what GitHub's link shows; a file window's first. */
18422
+ ownLines() {
18423
+ const own2 = this.ownDecl();
18424
+ return own2 ? [own2.start + 1, own2.end + 1] : [1, 1];
18425
+ }
18426
+ /** The window's declaration among the file's, where it is in this text; null for a file window,
18427
+ * or one not found. */
18428
+ ownDecl() {
18429
+ const w2 = this.whole;
18430
+ if (!w2 || this.current < 0) return null;
18431
+ const d2 = w2.decls.find((x2) => x2.i === this.current);
18432
+ if (d2) return d2;
18433
+ const v2 = w2.g.nodes[this.current];
18434
+ if (v2.gen === void 0 || !v2.range || v2.module !== w2.module) return null;
18435
+ const at = excerptOf(w2.lines, w2.edited, v2.name, v2.range);
18436
+ return at ? { i: this.current, start: at.start, end: at.end, head: at.start } : null;
18437
+ }
18438
+ /** The window stepped to another declaration of the text on show (the selection followed, the
18439
+ * sticky header pressed), or drawn again: the title bar and the notes are the new declaration's,
18440
+ * its lines are highlighted, the review box goes under them; the reader's place stays, scrolled
18441
+ * to the declaration only where none of it is in sight. */
18442
+ placeOwn(fresh3, notes, place2, edited, remoteFor, out) {
18443
+ const w2 = this.whole;
18444
+ const v2 = this.current >= 0 ? this.g.nodes[this.current] : null;
18445
+ const own2 = this.ownDecl();
18446
+ if (v2 && !own2) notes.push(notThere(v2, this.era));
18447
+ const headEl = this.frameEl.querySelector(".sw-head");
18448
+ if (headEl) headEl.outerHTML = this.fileHead(this.fileWhere(place2, edited), this.ownEditor(edited), remoteFor(...this.ownLines()));
18449
+ for (const b2 of this.frameEl.querySelectorAll(":scope > .banner")) b2.remove();
18450
+ (this.frameEl.querySelector(".sw-pair") ?? this.frameEl.querySelector(".sw-head"))?.insertAdjacentHTML("afterend", notes.join(""));
18451
+ for (const l2 of this.frameEl.querySelectorAll(".ln.hl")) l2.classList.remove("hl");
18452
+ if (own2) for (let l2 = own2.start; l2 <= own2.end; l2++) this.lineEl(l2)?.classList.add("hl");
18453
+ const body = this.frameEl.querySelector(".sw-file");
18454
+ let r2 = this.frameEl.querySelector(".sw-review");
18455
+ if (!v2) r2?.remove();
18456
+ else if (!fresh3 && r2) this.redrawReview();
18457
+ else if (body) {
18458
+ if (!r2) {
18459
+ r2 = document.createElement("div");
18460
+ r2.className = "sw-review";
18461
+ }
18462
+ r2.innerHTML = this.box.html(this.current);
18463
+ const at = own2 ? body.querySelector(`pre.src[data-piece="${chunkAt(w2.chunks, own2.start)}"]`) : null;
18464
+ if (at) at.after(r2);
18465
+ else body.prepend(r2);
18466
+ }
18467
+ this.el.setAttribute("aria-label", v2 ? `Source of ${v2.name}, the whole file${this.pinned ? ", pinned" : ""}` : `The file ${this.file}${this.pinned ? ", pinned" : ""}`);
18468
+ this.refreshMarks();
18469
+ this.drew();
18470
+ this.code = { file: w2.file, start: 0, lines: w2.lines };
18471
+ this.shown = { module: w2.module, start: 0, hash: w2.hash };
18472
+ this.attachInfo(this.fileInfo(w2, w2.era === "then", out));
18473
+ if (this.scrollWanted || fresh3 && !this.ownInSight()) this.scrollToOwn();
18474
+ this.scrollWanted = false;
18475
+ this.updateSticky();
18476
+ this.box.reveal(this.el);
18477
+ this.flashLines();
18478
+ }
18479
+ /** Piece `k` of the file on show as a code block of its own, empty until it comes near the screen
18480
+ * (`fill`), standing meanwhile as tall as its lines would be unwrapped: a file of thousands of
18481
+ * lines is highlighted and laid out where it is read, not all at once. */
18482
+ pieceHtml(k2) {
18483
+ const w2 = this.whole;
18484
+ const c3 = w2.chunks[k2];
18485
+ const h2 = Math.round((c3.end - c3.start + 1) * LINE_H);
18486
+ return `<pre class="code src sw-piece" data-line="${c3.start}" data-end="${c3.end}" data-piece="${k2}" style="--gw:${gutterDigits(w2.lines.length)};height:${h2}px;contain-intrinsic-block-size:auto ${h2}px"></pre>`;
18487
+ }
18488
+ /** A piece drawn, where it is not yet: its lines highlighted, the names in them linked (as Lean
18489
+ * said, where it was asked), the window's declaration's lines highlighted, a declaration's mark
18490
+ * where its command starts, its proofs marked to fold, those opened one by one open. Laid out
18491
+ * only near the screen after that (web/style.css). */
18492
+ fill(pre) {
18493
+ if (pre.dataset.end === void 0 || !this.whole) return;
18494
+ delete pre.dataset.end;
18495
+ pre.innerHTML = this.pieceLines(Number(pre.dataset.piece));
18496
+ pre.style.height = "";
18497
+ this.applyOpen(pre);
18498
+ const k2 = this.info.caret;
18499
+ if (k2 && k2.line >= Number(pre.dataset.line) && k2.line < Number(pre.dataset.line) + pre.children.length) this.info.marks();
18500
+ }
18501
+ /** The pieces of the file around line `line` drawn at once, `n` lines either way: what is on the
18502
+ * screen as the window opens on it, before the pieces coming near are drawn as they come. */
18503
+ fillAround(line, n3 = 120) {
18504
+ for (const pre of this.el.querySelectorAll("pre.sw-piece[data-end]")) {
18505
+ const from = Number(pre.dataset.line), to = Number(pre.dataset.end);
18506
+ if (to >= line - n3 && from <= line + n3) this.fill(pre);
18507
+ }
18508
+ }
18509
+ pieceLines(k2) {
18510
+ const w2 = this.whole;
18511
+ const c3 = w2.chunks[k2];
18512
+ const lines = w2.lines.slice(c3.start, c3.end + 1);
18513
+ const text2 = lines.join("\n");
18514
+ const known2 = this.still ? void 0 : this.memory.learned.get(`${w2.module}:${w2.hash}:${c3.start}-${c3.end}`);
18515
+ const resolve = w2.resolvers[k2];
18516
+ const own2 = this.ownDecl();
18517
+ const heads = /* @__PURE__ */ new Map();
18518
+ w2.decls.forEach((fd, d2) => {
18519
+ if (fd.head >= c3.start && fd.head <= c3.end && !heads.has(fd.head)) heads.set(fd.head, d2);
18520
+ });
18521
+ const starts = [0];
18522
+ for (const l2 of lines) starts.push(starts[starts.length - 1] + l2.length + 1);
18523
+ const off = ([line, col]) => starts[Math.max(0, Math.min(lines.length, line - c3.start))] + col;
18524
+ const folds = w2.folds.filter((f2) => f2.from[0] >= c3.start && f2.from[0] <= c3.end).map((f2) => ({ from: off(f2.from), to: Math.min(text2.length, off(f2.to)), id: `${f2.from[0]}:${f2.from[1]}` }));
18525
+ const decor = {
18526
+ line: (j2) => {
18527
+ const l2 = c3.start + j2;
18528
+ const hl = !!own2 && l2 >= own2.start && l2 <= own2.end;
18529
+ const d2 = heads.get(l2);
18530
+ const lead = d2 === void 0 ? "" : this.markHtml(d2);
18531
+ return hl || lead ? { cls: hl ? " hl" : "", lead } : void 0;
18532
+ },
18533
+ folds
18534
+ };
18535
+ return highlightLines(text2, (word, at) => known2?.has(at) ? known2.get(at) : resolve(word), c3.start + 1, decor);
18536
+ }
18537
+ /** Declaration `d`'s mark in the gutter, where its command starts: its review state in the Status
18538
+ * scheme's colours, with its name and state as its tooltip; nothing where none is shown. No
18539
+ * text: the code's text stays the source's. */
18540
+ markHtml(d2) {
18541
+ const w2 = this.whole;
18542
+ const m3 = w2.marks[d2];
18543
+ if (!m3) return "";
18544
+ const v2 = w2.g.nodes[w2.decls[d2].i];
18545
+ return `<span class="dm s-${m3}" data-dm="${d2}" aria-hidden="true" title="${escapeHtml(`${v2.name}: ${FILE_MARK_LABEL[m3]}`)}"></span>`;
18546
+ }
18547
+ /** Each declaration's mark, as Status shows it — the build, `sorry`, the review as it is now —:
18548
+ * shown only where the text is the one compiled, which they are about (a file changed since:
18549
+ * where its text is still that). */
18550
+ marksOf(w2) {
18551
+ const d2 = this.hooks.review(w2.g);
18552
+ const inReview = this.hooks.inReview(w2.g);
18553
+ const file = w2.era === "now" ? this.hooks.fileOf(w2.module) : void 0;
18554
+ w2.marks = w2.decls.map((fd) => {
18555
+ const r2 = w2.g.nodes[fd.i].range;
18556
+ if (w2.edited && !(w2.compiled && r2 && sameText(w2.compiled, r2, w2.lines, fd))) return null;
18557
+ return fileMark(d2, w2.g, fd.i, inReview, file);
18558
+ });
18559
+ }
18560
+ /** The review changed: the marks again, where they are drawn, and the sticky header's. */
18561
+ refreshMarks() {
18562
+ const w2 = this.whole;
18563
+ if (!w2) return;
18564
+ this.marksOf(w2);
18565
+ for (const el of this.frameEl.querySelectorAll(".dm[data-dm]")) {
18566
+ const d2 = Number(el.dataset.dm);
18567
+ const m3 = w2.marks[d2];
18568
+ if (!m3) {
18569
+ el.remove();
18570
+ continue;
18571
+ }
18572
+ el.className = `dm s-${m3}`;
18573
+ el.title = `${w2.g.nodes[w2.decls[d2].i].name}: ${FILE_MARK_LABEL[m3]}`;
18574
+ }
18575
+ this.stickyAt = null;
18576
+ this.updateSticky();
18577
+ }
18578
+ /** "Fold proofs", in the sticky header: the reader's own, remembered in this browser. */
18579
+ foldsButton() {
18580
+ const on = this.hooks.foldProofs();
18581
+ return `<button type="button" class="sw-folds-btn" data-sw-folds aria-pressed="${on}" title="${on ? "Show every proof again" : "Fold every proof to one line, \u22EF proof: a click on one shows it"} (in every window, in this browser)">Fold proofs</button>`;
18582
+ }
18583
+ /** Proofs folded or shown, the reader's choice, in every window of the page (the page tells each,
18584
+ * `refold`). */
18585
+ foldProofs(on) {
18586
+ this.hooks.setFoldProofs(on);
18587
+ }
18588
+ /** Proofs folded or shown as the reader chose: the place in the file stays where it was read. */
18589
+ refold() {
18590
+ if (this.mode !== "file") return;
18591
+ const on = this.hooks.foldProofs();
18592
+ if (on) this.openFolds.clear();
18593
+ this.keepPlace(() => {
18594
+ this.el.classList.toggle("sw-folds", on);
18595
+ for (const el of this.el.querySelectorAll(".pf-open")) el.classList.remove("pf-open");
18596
+ this.applyOpen();
18597
+ });
18598
+ const b2 = this.el.querySelector("[data-sw-folds]");
18599
+ if (b2) b2.outerHTML = this.foldsButton();
18600
+ this.updateSticky();
18601
+ }
18602
+ /** A folded proof opened: that one alone, its place staying. */
18603
+ openFold(id) {
18604
+ this.openFolds.add(id);
18605
+ this.keepPlace(() => this.applyOpen());
18606
+ }
18607
+ /** The proofs opened one by one shown, in the code as drawn now. */
18608
+ applyOpen(root = this.frameEl) {
18609
+ for (const id of this.openFolds) for (const el of root.querySelectorAll(`[data-pf="${CSS.escape(id)}"], [data-pf-open="${CSS.escape(id)}"]`)) el.classList.add("pf-open");
18610
+ }
18611
+ /** Do `change` to what is drawn, the line read at the top of the code staying where it was. */
18612
+ keepPlace(change) {
18613
+ const sc = this.el.querySelector(".sw-scroll");
18614
+ const top = sc ? this.topLine() : null;
18615
+ const el = top ? this.lineEl(top.line) ?? null : null;
18616
+ const was = el?.getBoundingClientRect().top ?? null;
18617
+ change();
18618
+ if (!sc || !el || was === null) return;
18619
+ const now = (el.getClientRects().length ? el : el.parentElement).getBoundingClientRect().top;
18620
+ sc.scrollTop += now - was;
18621
+ }
18622
+ /** The line of the file at the top of the code, under the sticky header, and the element there;
18623
+ * null where nothing is. */
18624
+ topLine() {
18625
+ const sc = this.el.querySelector(".sw-scroll");
18626
+ const body = this.el.querySelector(".sw-file");
18627
+ if (!sc || !body) return null;
18628
+ const r2 = sc.getBoundingClientRect();
18629
+ const y2 = r2.top + (sc.querySelector(".sw-sticky")?.offsetHeight ?? 0) + LINE_H * 0.75;
18630
+ const x2 = body.getBoundingClientRect().left + 24;
18631
+ const hit = document.elementFromPoint(x2, y2);
18632
+ if (!hit || !this.el.contains(hit)) return null;
18633
+ if (hit.closest(".sw-review")) {
18634
+ const own2 = this.ownDecl();
18635
+ return own2 ? { line: own2.end, inReview: true } : null;
18636
+ }
18637
+ const ln = hit.closest(".ln");
18638
+ const pre = ln?.parentElement ?? hit.closest("pre.src");
18639
+ if (!pre?.matches("pre.src")) return null;
18640
+ return { line: Number(pre.dataset.line ?? 0) + (ln ? Array.prototype.indexOf.call(pre.children, ln) : 0), inReview: false };
18641
+ }
18642
+ /** what the sticky header names, as last drawn */
18643
+ stickyAt = null;
18644
+ stickyLater() {
18645
+ if (this.mode !== "file" || this.stickyWait) return;
18646
+ this.stickyWait = requestAnimationFrame(() => {
18647
+ this.stickyWait = 0;
18648
+ this.updateSticky();
18649
+ });
18650
+ }
18651
+ /** The sticky header: the declaration the reading position is in, with its state — pressed, it is
18652
+ * selected (the owner's decision of 2026-11-01: scrolling never selects) —, or the file between
18653
+ * declarations. */
18654
+ updateSticky() {
18655
+ const w2 = this.whole;
18656
+ const slot = this.el.querySelector(".sw-at-slot");
18657
+ if (!w2 || !slot) return;
18658
+ const top = this.topLine();
18659
+ const fd = top ? declAt(w2.decls, top.line) : null;
18660
+ const d2 = fd ? w2.decls.indexOf(fd) : -1;
18661
+ const key = fd ? `${fd.i}:${w2.marks[d2] ?? ""}:${fd.i === this.current}` : `-${w2.file}`;
18662
+ if (key === this.stickyAt) return;
18663
+ this.stickyAt = key;
18664
+ if (!fd) {
18665
+ slot.innerHTML = `<span class="sw-at-file">${escapeHtml(w2.file)}</span>`;
18666
+ return;
18667
+ }
18668
+ const v2 = w2.g.nodes[fd.i];
18669
+ const m3 = w2.marks[d2];
18670
+ const short6 = v2.display ?? v2.name.split(".").pop();
18671
+ slot.innerHTML = `<button type="button" class="sw-at" data-sw-at="${escapeHtml(v2.name)}" title="${escapeHtml(fd.i === this.current ? `${v2.name}: on show in this window` : `Select ${v2.name}`)}">${m3 ? `<span class="dm s-${m3}" aria-hidden="true"></span>` : ""}<span class="sw-at-name">${escapeHtml(short6)}</span><span class="sw-at-st">${m3 ? escapeHtml(FILE_MARK_LABEL[m3]) : ""}</span></button>`;
18672
+ }
18673
+ /** Scrolled to the window's declaration, under the sticky header; a file window, to its top. */
18674
+ scrollToOwn() {
18675
+ const sc = this.el.querySelector(".sw-scroll");
18676
+ if (!sc) return;
18677
+ const own2 = this.ownDecl();
18678
+ if (!own2) {
18679
+ if (this.file !== null) sc.scrollTop = 0;
18680
+ return;
18681
+ }
18682
+ const go = () => {
18683
+ const el = this.lineEl(own2.start);
18684
+ if (!el) return;
18685
+ const sticky = sc.querySelector(".sw-sticky")?.offsetHeight ?? 0;
18686
+ sc.scrollTop += el.getBoundingClientRect().top - sc.getBoundingClientRect().top - sticky - 10;
18687
+ };
18688
+ go();
18689
+ requestAnimationFrame(() => {
18690
+ go();
18691
+ this.updateSticky();
18692
+ });
18693
+ }
18694
+ /** Whether some of the window's declaration's lines are in sight. */
18695
+ ownInSight() {
18696
+ const sc = this.el.querySelector(".sw-scroll");
18697
+ const own2 = this.ownDecl();
18698
+ const a3 = own2 && this.lineEl(own2.start), b2 = own2 && this.lineEl(own2.end);
18699
+ if (!sc || !a3 || !b2) return false;
18700
+ const r2 = sc.getBoundingClientRect();
18701
+ return a3.getBoundingClientRect().top < r2.bottom && b2.getBoundingClientRect().bottom > r2.top + (sc.querySelector(".sw-sticky")?.offsetHeight ?? 0);
18702
+ }
18703
+ /** Lean asked what the names of each piece mean as it comes into sight (or near it), once per
18704
+ * text: a file's thousands of names are not asked at once. */
18705
+ watchPieces(w2) {
18706
+ this.seen?.disconnect();
18707
+ this.seen = null;
18708
+ const sc = this.el.querySelector(".sw-scroll");
18709
+ if (!sc) return;
18710
+ const learn = !this.still && !!w2.hash;
18711
+ if (typeof IntersectionObserver === "undefined") return void this.fillAround(0, Infinity);
18712
+ const seen = new IntersectionObserver(
18713
+ (es) => {
18714
+ for (const e2 of es) {
18715
+ if (!e2.isIntersecting) continue;
18716
+ seen.unobserve(e2.target);
18717
+ this.fill(e2.target);
18718
+ if (learn) void this.learnPiece(w2, Number(e2.target.dataset.piece));
18719
+ }
18720
+ },
18721
+ { root: sc, rootMargin: "600px 0px" }
18722
+ );
18723
+ for (const pre of sc.querySelectorAll("pre.sw-piece")) seen.observe(pre);
18724
+ this.seen = seen;
18725
+ }
18726
+ /** What Lean says each name of piece `k` means, the piece drawn again with it. */
18727
+ async learnPiece(w2, k2) {
18728
+ const c3 = w2.chunks[k2];
18729
+ if (!c3) return;
18730
+ const key = `${w2.module}:${w2.hash}:${c3.start}-${c3.end}`;
18731
+ if (this.memory.learned.has(key)) return;
18732
+ const text2 = w2.lines.slice(c3.start, c3.end + 1).join("\n");
18733
+ const words = [];
18734
+ highlightLines(text2, (word, at) => (words.push({ word, at }), null));
18735
+ if (!words.length) return;
18736
+ const live = () => this.whole === w2 && this.mode === "file";
18737
+ await this.learn(live, w2.selfs[k2], key, w2.module, w2.hash, text2, c3.start, words, () => {
18738
+ const pre = this.frameEl.querySelector(`pre.sw-piece[data-piece="${k2}"]`);
18739
+ if (!pre) return;
18740
+ pre.innerHTML = this.pieceLines(k2);
18741
+ this.applyOpen(pre);
18742
+ this.flashLines();
18743
+ this.info.marks();
18744
+ });
18745
+ }
18746
+ /** The InfoView told the code drawn now, its element and the code's (none: no code on show). */
18747
+ attachInfo(code) {
18748
+ this.info.attach(this.frameEl.querySelector(".sw-info"), (line) => this.lineEl(line), code);
17067
18749
  }
17068
18750
  /** The context the code on show is written in, as Lean, muted above it: folded when long to
17069
18751
  * its first lines and its namespaces and sections, with the `variable`s the declaration uses
@@ -17098,10 +18780,12 @@ var SourceWindow = class {
17098
18780
  * the latest build. */
17099
18781
  generatedHtml(unit, also) {
17100
18782
  if (!also.length) return "";
17101
- const shortOf = (a3) => a3.startsWith(unit + ".") ? a3.slice(unit.length + 1) : a3.split(".").pop();
18783
+ const shortOf = (a3) => generatedName(unit, a3).short;
17102
18784
  if (this.still) return `<div class="sw-print"><div class="sw-print-h">What Lean generated from this command</div>${also.map((a3) => `<div class="sw-gen-row"><code title="${escapeHtml(a3)}">${escapeHtml(shortOf(a3))}</code></div>`).join("")}</div>`;
17103
18785
  const rows = also.map((a3) => {
17104
18786
  const short6 = shortOf(a3);
18787
+ if (generatedName(unit, a3).hygienic)
18788
+ return `<div class="sw-gen-row"><code class="sw-gen-hyg" title="${escapeHtml(`${a3}: a name of the macro's hygiene, which Lean cannot be asked about`)}">${escapeHtml(short6)}</code> <span class="sw-gen-cmd">\xB7 the macro's own name</span></div>`;
17105
18789
  const open = this.printOpen.has(a3);
17106
18790
  return `<div class="sw-gen-row"><button class="link sw-gen-name" data-sw-gen="${escapeHtml(a3)}" title="What Lean made of ${escapeHtml(a3)} (#print)"><span class="sw-gen-cmd">#print</span> ${escapeHtml(short6)}</button><pre class="code" data-sw-print${open ? "" : " hidden"}>${this.memory.printed.get(a3) ?? "Asking Lean\u2026"}</pre></div>`;
17107
18791
  }).join("");
@@ -17132,7 +18816,7 @@ var SourceWindow = class {
17132
18816
  /** Ask Lean what each name in the code on show means (server/hover.ts, `names`), and link the
17133
18817
  * names by its answers: a declaration where it names one, nothing where it names a variable;
17134
18818
  * the page's own reading stays where Lean says nothing. */
17135
- async learn(turn, self2, key, module, hash, text2, start, words, resolve) {
18819
+ async learn(live, self2, key, module, hash, text2, start, words, apply) {
17136
18820
  const g2 = this.g;
17137
18821
  const lineStarts = [0];
17138
18822
  for (let k2 = 0; k2 < text2.length; k2++) if (text2[k2] === "\n") lineStarts.push(k2 + 1);
@@ -17156,18 +18840,22 @@ var SourceWindow = class {
17156
18840
  }
17157
18841
  });
17158
18842
  if (!positions.length) return;
18843
+ if (positions.length > NAMES_MAX) {
18844
+ positions.length = NAMES_MAX;
18845
+ parts.length = NAMES_MAX;
18846
+ }
17159
18847
  let heads;
17160
18848
  for (let tries = 0; tries < 120 && !heads; tries++) {
17161
18849
  const res = await this.data.names(module, positions, hash);
17162
- if (turn !== this.turn || !res || res.stale || res.error) return;
18850
+ if (!live() || !res || res.stale || res.error) return;
17163
18851
  if (res.pending) await new Promise((ok) => setTimeout(ok, 1e3));
17164
18852
  else heads = res.heads;
17165
18853
  }
17166
- if (!heads || turn !== this.turn) return;
18854
+ if (!heads || !live()) return;
17167
18855
  const byWord = /* @__PURE__ */ new Map();
17168
18856
  parts.forEach((p2, k2) => {
17169
18857
  const segs = byWord.get(p2.word) ?? [];
17170
- segs.push(heads[k2]);
18858
+ segs.push(heads[k2] ?? null);
17171
18859
  byWord.set(p2.word, segs);
17172
18860
  });
17173
18861
  const learned = /* @__PURE__ */ new Map();
@@ -17190,11 +18878,8 @@ var SourceWindow = class {
17190
18878
  } else if (segs.length === 1 && each[0] === null) learned.set(at, null);
17191
18879
  }
17192
18880
  this.memory.learned.set(key, learned);
17193
- if (this.memory.learned.size > 64) this.memory.learned.delete(this.memory.learned.keys().next().value);
17194
- const pre = this.el.querySelector("pre.src");
17195
- if (!pre || turn !== this.turn) return;
17196
- pre.innerHTML = highlightLines(text2, (w2, off) => learned.has(off) ? learned.get(off) : resolve(w2), start + 1);
17197
- this.flashLines();
18881
+ if (this.memory.learned.size > 256) this.memory.learned.delete(this.memory.learned.keys().next().value);
18882
+ if (live()) apply(learned);
17198
18883
  }
17199
18884
  };
17200
18885
  function offsetIn(root, node, off) {
@@ -17204,7 +18889,7 @@ function offsetIn(root, node, off) {
17204
18889
  return r2.toString().length;
17205
18890
  }
17206
18891
  function codeHtml(lines, start, text2) {
17207
- return `<pre class="code src" style="--gw:${gutterDigits(start + text2.split("\n").length)}">${lines}</pre>`;
18892
+ return `<pre class="code src" data-line="${start}" style="--gw:${gutterDigits(start + text2.split("\n").length)}">${lines}</pre>`;
17208
18893
  }
17209
18894
  function githubAnchor(href, commit, what) {
17210
18895
  const title = what ? `These lines of ${what}, on GitHub` : `These lines at ${commit.slice(0, 7)}, the commit of the build shown, on GitHub`;
@@ -40429,7 +42114,60 @@ function panelsPart(page) {
40429
42114
  return past && past.graph === G2 ? { past, when: buildWhen(past.snapshot.at) } : null;
40430
42115
  },
40431
42116
  // the reference window paired with a source window stands beside it, on the right of the two
40432
- docked: (w2) => papers.dockFor(w2)
42117
+ docked: (w2) => papers.dockFor(w2),
42118
+ // the InfoView (ReviewSpec, "The InfoView"): hidden by the reader in every window, kept in the
42119
+ // browser; the page's one caret, in the window the reader put it in last, which those following
42120
+ // see (CollabSpec, "Surfaces": caret)
42121
+ infoHidden: () => !!store2.data.infoHidden,
42122
+ hideInfo: (on) => {
42123
+ store2.data.infoHidden = on ? true : void 0;
42124
+ store2.save();
42125
+ for (const w2 of sources.all) w2.infoChanged();
42126
+ },
42127
+ caretMoved: (w2) => {
42128
+ for (const o2 of sources.all) if (o2 !== w2) o2.followCaret(null);
42129
+ page.people.report();
42130
+ },
42131
+ following: () => !!page.people.following,
42132
+ // File mode (the owner's decisions of 2026-11-01): the marks are the board's review, as its
42133
+ // Status colouring reads it
42134
+ review: () => page.boardReview(),
42135
+ inReview: (G2) => inReviewOf(G2),
42136
+ compiledText: async (m3) => {
42137
+ if (data.snapshot) return null;
42138
+ await page.tm.load().catch(() => {
42139
+ });
42140
+ const id = page.tm.latest;
42141
+ const got = id === null ? null : await data.pastSource(id, m3);
42142
+ return got && !("missing" in got) ? got.text.split("\n") : null;
42143
+ },
42144
+ foldProofs: () => store2.data.proofsFolded === true,
42145
+ setFoldProofs: (on) => {
42146
+ store2.data.proofsFolded = on ? true : void 0;
42147
+ store2.save();
42148
+ for (const w2 of sources.all) w2.refold();
42149
+ },
42150
+ moded: () => {
42151
+ page.people.report();
42152
+ papers.redock();
42153
+ }
42154
+ };
42155
+ let reviewed = null;
42156
+ const inReviewOf = (G2) => {
42157
+ if (G2 !== page.g) return null;
42158
+ const d2 = page.boardReview();
42159
+ const key = Object.keys(d2.targets).sort().join("\n") + "\n\n" + d2.trusted.join("\n");
42160
+ if (!reviewed || reviewed.g !== G2 || reviewed.key !== key) {
42161
+ const roots3 = Object.keys(d2.targets).map((n3) => G2.byName.get(n3)).filter((i2) => i2 !== void 0);
42162
+ let set2 = null;
42163
+ if (roots3.length) {
42164
+ set2 = new Uint8Array(G2.n);
42165
+ for (const r2 of roots3) for (const i2 of page.flow.order(r2)) set2[i2] = 1;
42166
+ }
42167
+ reviewed = { g: G2, key, set: set2 };
42168
+ }
42169
+ const set = reviewed.set;
42170
+ return set ? (i2) => set[i2] === 1 : null;
40433
42171
  };
40434
42172
  const memory = sourceMemory();
40435
42173
  const sources = new Sources({
@@ -40445,7 +42183,9 @@ function panelsPart(page) {
40445
42183
  top: () => pairTop(),
40446
42184
  // the reference window opens the declaration's first link beside the window opened or stepped,
40447
42185
  // pinned or not (AttachmentSpec decision 8)
40448
- shown: (w2, i2) => papers.paired(i2, w2)
42186
+ shown: (w2, i2) => papers.paired(i2, w2),
42187
+ // a file window stays while the graph has declarations in its file
42188
+ hasFile: (m3) => moduleDecls(page.g, m3).length > 0
40449
42189
  });
40450
42190
  const openSourceAt = (name, from, to, quoted, at) => {
40451
42191
  const j2 = page.g.byName.get(name) ?? page.g.foldedInto.get(name);
@@ -42791,122 +44531,6 @@ var Motion = class {
42791
44531
  }
42792
44532
  };
42793
44533
 
42794
- // src/web/src/status.ts
42795
- var SCHEMES_SHOWN = ["kind", "status", "mine"];
42796
- var STATUSES2 = ["failed", "building", "sorry", "commented", "stale", "approved", "unreviewed", "trusted"];
42797
- var ST_FAILED = 0;
42798
- var ST_BUILDING = 1;
42799
- var ST_SORRY = 2;
42800
- var ST_COMMENTED = 3;
42801
- var ST_STALE = 4;
42802
- var ST_APPROVED = 5;
42803
- var ST_UNREVIEWED = 6;
42804
- var ST_TRUSTED = 7;
42805
- var STATUS_LABEL = {
42806
- failed: "failed or not built",
42807
- building: "building",
42808
- sorry: "contains sorry",
42809
- commented: "commented",
42810
- stale: "stale",
42811
- approved: "approved",
42812
- unreviewed: "not yet reviewed",
42813
- trusted: "trusted"
42814
- };
42815
- var STATUS_HINT = {
42816
- failed: "Its file failed to compile in the last build, or was never built: shown as it was last built",
42817
- building: "Its file is being compiled right now",
42818
- sorry: "It rests on sorry: its own, or through anything it uses",
42819
- commented: "A reviewer's latest word on its present version is a comment",
42820
- stale: "It has opinions, none on its present version",
42821
- approved: "A reviewer approved its present version, and no reviewer's latest word on it is a comment",
42822
- unreviewed: "Nobody has given an opinion on it yet, and nothing trusts it",
42823
- trusted: "Trusted without review (Mathlib, Lean core, a trusted prefix, the standard axioms), with no opinion on it"
42824
- };
42825
- var MINE_STATES = [ST_COMMENTED, ST_STALE, ST_APPROVED, ST_UNREVIEWED, ST_TRUSTED];
42826
- function mineLabel(code, whose) {
42827
- const who = whose ?? "you";
42828
- switch (code) {
42829
- case ST_COMMENTED:
42830
- return `${who} commented`;
42831
- case ST_STALE:
42832
- return `${whose ? `${whose}'s` : "your"} opinion is stale`;
42833
- case ST_APPROVED:
42834
- return `${who} approved`;
42835
- case ST_TRUSTED:
42836
- return "trusted";
42837
- default:
42838
- return `not reviewed by ${whose ?? "you"}`;
42839
- }
42840
- }
42841
- function mineHint(code, whose) {
42842
- const your = whose ? `${whose}'s` : "Your";
42843
- switch (code) {
42844
- case ST_COMMENTED:
42845
- return `${your} current opinion on its present version is a comment`;
42846
- case ST_STALE:
42847
- return `${your} current opinion is on an earlier version: it changed since`;
42848
- case ST_APPROVED:
42849
- return `${your} current opinion approves its present version`;
42850
- case ST_TRUSTED:
42851
- return `Trusted without review, and no opinion of ${whose ? `${whose}'s` : "yours"} on it`;
42852
- default:
42853
- return `It needs review, and ${whose ? `${whose} has` : "you have"} no opinion on it (none given, or withdrawn)`;
42854
- }
42855
- }
42856
- function mineState(d2, g2, i2, me) {
42857
- const v2 = g2.nodes[i2];
42858
- const s2 = me ? ownStatus(d2, v2.name, me, v2.hash) : "none";
42859
- if (s2 === "stale") return ST_STALE;
42860
- if (s2 === "commented") return ST_COMMENTED;
42861
- if (s2 === "approved") return ST_APPROVED;
42862
- return needsReview(g2, d2, i2) ? ST_UNREVIEWED : ST_TRUSTED;
42863
- }
42864
- function mineCodes(d2, g2, me) {
42865
- const out = new Uint8Array(g2.n);
42866
- for (let i2 = 0; i2 < g2.n; i2++) out[i2] = mineState(d2, g2, i2, me);
42867
- return out;
42868
- }
42869
- function statusState(d2, g2, i2, file, sorryAx) {
42870
- if (file?.state === "building") return ST_BUILDING;
42871
- if (file?.state === "failed" || file?.state === "unbuilt") return ST_FAILED;
42872
- if (sorryAx) return ST_SORRY;
42873
- const v2 = g2.nodes[i2];
42874
- const s2 = statusOf(d2, v2.name, v2.hash);
42875
- if (s2 === "commented") return ST_COMMENTED;
42876
- if (s2 === "stale") return ST_STALE;
42877
- if (s2 === "approved") return ST_APPROVED;
42878
- return needsReview(g2, d2, i2) ? ST_UNREVIEWED : ST_TRUSTED;
42879
- }
42880
- function statusCodes(d2, g2, files) {
42881
- const out = new Uint8Array(g2.n);
42882
- const sorrySets = /* @__PURE__ */ new Map();
42883
- for (let i2 = 0; i2 < g2.n; i2++) {
42884
- const ax = g2.nodes[i2].ax;
42885
- let s2 = sorrySets.get(ax);
42886
- if (s2 === void 0) sorrySets.set(ax, s2 = g2.axiomsOf(i2).includes("sorryAx"));
42887
- out[i2] = statusState(d2, g2, i2, g2.isExt(i2) ? void 0 : files.get(g2.nodes[i2].module), s2);
42888
- }
42889
- return out;
42890
- }
42891
- function fileTrouble(f2) {
42892
- switch (f2?.state) {
42893
- case "failed":
42894
- case "unbuilt":
42895
- return ST_FAILED;
42896
- case "building":
42897
- return ST_BUILDING;
42898
- case "sorry":
42899
- return ST_SORRY;
42900
- default:
42901
- return -1;
42902
- }
42903
- }
42904
- function clusterTroubles(clusters, clustering, files) {
42905
- const out = new Int8Array(clusters.length).fill(-1);
42906
- if (clustering === "module") clusters.forEach((c3, k2) => out[k2] = fileTrouble(files.get(c3.key)));
42907
- return out;
42908
- }
42909
-
42910
44534
  // src/web/src/visitors.ts
42911
44535
  var TRAIL = 6;
42912
44536
  function visit(trail, v2) {
@@ -46986,6 +48610,7 @@ function itemSpot(n3, b2, exists, linked = []) {
46986
48610
  const at = declOf2(n3, b2, exists);
46987
48611
  if (at && typeof at === "object") return { at: "decl", j: at.j, name: at.name, d: [n3.decl.at[0], n3.decl.at[1]] };
46988
48612
  if (at === "off") return { at: "ring", angle: null, about: linked.length ? { links: [...linked] } : null };
48613
+ if (at === "gone") return { at: "ring", angle: null, about: placedAbout(n3.places, b2, exists) ?? (linked.length ? { links: [...linked] } : null), gone: n3.decl.name };
46989
48614
  const m3 = b2.mode;
46990
48615
  const place2 = n3.places[m3];
46991
48616
  const h2 = holderOf(place2, m3, exists);
@@ -47004,6 +48629,15 @@ function itemSpot(n3, b2, exists, linked = []) {
47004
48629
  const about = linked.length ? { links: [...linked] } : o2 && b2.on[otherMode(m3)].has(o2.key) ? { mode: otherMode(m3), key: o2.key } : null;
47005
48630
  return { at: "ring", angle: place2 && "ring" in place2 ? place2.ring : null, about };
47006
48631
  }
48632
+ function placedAbout(places, b2, exists) {
48633
+ for (const m3 of [b2.mode, otherMode(b2.mode)]) {
48634
+ const p2 = places[m3];
48635
+ if (!p2 || !("in" in p2)) continue;
48636
+ const key = p2.in.map((e2) => e2[0]).find((k2) => exists(m3, k2) && b2.on[m3].has(k2));
48637
+ if (key) return { mode: m3, key };
48638
+ }
48639
+ return null;
48640
+ }
47007
48641
  function aboutMembers(b2, about) {
47008
48642
  if (!about) return [];
47009
48643
  if ("key" in about) return membersOf2(b2, about.mode, about.key);
@@ -47017,13 +48651,15 @@ function aboutMembers(b2, about) {
47017
48651
  }
47018
48652
  return [...out].sort((x2, y2) => x2 - y2);
47019
48653
  }
47020
- function viewSpot(n3, b2, index) {
47021
- const at = declOf2(n3, b2, NO_GRAPH);
48654
+ function viewSpot(n3, b2, index, exists = NO_GRAPH) {
48655
+ const at = declOf2(n3, b2, exists);
47022
48656
  if (at && typeof at === "object") return { at: "decl", j: at.j, name: at.name, d: [n3.decl.at[0], n3.decl.at[1]] };
48657
+ const key = n3.place.in.map((e2) => e2[0]).find((k2) => b2.on[n3.place.mode].has(k2));
48658
+ const about = key ? { mode: n3.place.mode, key } : null;
48659
+ if (at === "gone") return { at: "ring", angle: null, about, gone: n3.decl.name };
47023
48660
  const r2 = resolvePlace(n3.place, b2.mode, index);
47024
48661
  if (r2) return r2.c >= 0 ? { at: "offset", c: r2.c, d: [r2.dx, r2.dy] } : { at: "world", x: r2.dx, y: r2.dy };
47025
- const key = n3.place.in.map((e2) => e2[0]).find((k2) => b2.on[n3.place.mode].has(k2));
47026
- return { at: "ring", angle: null, about: key ? { mode: n3.place.mode, key } : null };
48662
+ return { at: "ring", angle: null, about };
47027
48663
  }
47028
48664
  var NO_GRAPH = () => true;
47029
48665
  function declPlace(L2, i2, d2 = [0, 0]) {
@@ -47289,7 +48925,7 @@ var Stickies = class {
47289
48925
  };
47290
48926
  const all = [
47291
48927
  ...project.map((n3) => ({ kind: "project", note: n3, ...projectSpot(n3) })),
47292
- ...view.map((n3) => ({ kind: "view", note: n3, spot: viewSpot(n3, nb, (key) => index.get(key) ?? -1), why: null }))
48928
+ ...view.map((n3) => ({ kind: "view", note: n3, spot: viewSpot(n3, nb, (key) => index.get(key) ?? -1, exists), why: null }))
47293
48929
  ];
47294
48930
  for (const { kind, note: n3, spot, why } of all) {
47295
48931
  if (!spot || keep2.has(n3.id)) continue;
@@ -47365,27 +49001,31 @@ var Stickies = class {
47365
49001
  return ICONS2[iconKind(n3.carries, (sha) => this.hooks.file(sha))] + (count2 ? `<span class="sk-count">${count2}</span>` : "") + `<span class="sk-dot"></span>`;
47366
49002
  }
47367
49003
  /** What the pointer on an icon says: the note's first line, what it carries, whose it is, what it is
47368
- * about on the ring, and what a click does. */
49004
+ * about on the ring — or the declaration it is attached to, there because this build does not
49005
+ * have it —, and what a click does. */
47369
49006
  iconTitle(n3, own2, spot, why) {
47370
49007
  const cs = n3.carries ?? [];
47371
49008
  const carried = cs.length ? ` \u2014 carries ${cs.map((c3) => this.carryWords(c3)).join("; ")}` : "";
47372
49009
  const whose = own2 ? " \u2014 only in this view" : why === "added" ? " \u2014 added to this view" : "";
47373
- const about = spot.at === "ring" && spot.about ? ` \u2014 ${aboutWords(spot.about)}` : spot.at === "decl" ? ` \u2014 attached to ${spot.name}` : "";
49010
+ const about = spot.at === "ring" && spot.gone ? ` \u2014 attached to ${spot.gone}, not in this build` : spot.at === "ring" && spot.about ? ` \u2014 ${aboutWords(spot.about)}` : spot.at === "decl" ? ` \u2014 attached to ${spot.name}` : "";
47374
49011
  const first = noteExcerpt(n3.text.split("\n").find((l2) => l2.trim()) ?? n3.text, 120);
47375
49012
  return `${first}${carried}${whose}${about}`;
47376
49013
  }
47377
- /** A note's card: its text, what it carries, who wrote it, and, for a view's own (`own`), whose it is. */
49014
+ /** A note's card: its text, what it carries, who wrote it, for a view's own (`own`) whose it is, and,
49015
+ * on the ring because this build does not have the declaration it is attached to, which that is
49016
+ * (the owner's decision of 2026-10-30). */
47378
49017
  cardHtml(n3, own2, spot) {
47379
49018
  const by = n3.by ? n3.agent ? `${BOT}${escapeHtml(n3.by)}` : nameHtml(n3.by, n3.person) : "Someone";
47380
49019
  const ed = n3.edited;
47381
49020
  const other = ed?.by && !(ed.person ? ed.person === n3.person : !n3.person && ed.by === n3.by);
47382
49021
  const edited = ed ? ` \xB7 edited${other ? ` by ${nameHtml(ed.by, ed.person)}` : ""}` : "";
47383
49022
  const whose = own2 ? `<div class="sk-whose">${VIEW_MARK}only in this view</div>` : "";
49023
+ const gone = spot.at === "ring" && spot.gone ? `<div class="sk-whose sk-gone">attached to <code>${escapeHtml(spot.gone)}</code>, not in this build</div>` : "";
47384
49024
  const words = spot.at === "ring" && spot.about ? aboutWords(spot.about) : "";
47385
49025
  const about = words ? `${words.charAt(0).toUpperCase()}${words.slice(1)}` : "";
47386
49026
  const cs = n3.carries ?? [];
47387
49027
  const w2 = (cs.some((c3) => this.pictured(c3)) ? CARRY_W.picture : CARRY_W.paper) - INNER_PAD;
47388
- return `<div class="sk-text"${about ? ` title="${escapeHtml(about)}"` : ""}>${renderMarkdown(n3.text, (name) => this.hooks.resolve(name))}</div>` + (cs.length ? `<div class="sk-carries">${cs.map((c3, k2) => this.carryHtml(c3, k2, w2)).join("")}</div>` : "") + `<div class="sk-by">${by}${edited}</div>${whose}`;
49028
+ return `<div class="sk-text"${about ? ` title="${escapeHtml(about)}"` : ""}>${renderMarkdown(n3.text, (name) => this.hooks.resolve(name))}</div>` + (cs.length ? `<div class="sk-carries">${cs.map((c3, k2) => this.carryHtml(c3, k2, w2)).join("")}</div>` : "") + `<div class="sk-by">${by}${edited}</div>${whose}${gone}`;
47389
49029
  }
47390
49030
  // ---------------------------------------------------------------- what a note carries
47391
49031
  /** Whether a carry is something to look at, drawn at the note's width: an image, or a clip. */
@@ -51637,6 +53277,7 @@ var BoardSync = class {
51637
53277
  };
51638
53278
 
51639
53279
  // src/web/src/outline.ts
53280
+ var FILE_MARK = `<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 1.8h5.2L12.5 5v9.2H4zM9 1.8V5.2h3.4"/></svg>`;
51640
53281
  var HIDE_MARK = `<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8 12.1 12.5 8 12.5 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="2"/><path d="M2.5 13.5l11-11"/></svg>`;
51641
53282
  function rowsToWrite(before, after, held2) {
51642
53283
  if (before.length !== after.length || held2 !== after.length) return null;
@@ -51678,6 +53319,8 @@ var Outline2 = class {
51678
53319
  this.hooks.trustClicked(c3, row);
51679
53320
  } else if (t2.closest("[data-hide]")) {
51680
53321
  this.hooks.hide(c3);
53322
+ } else if (t2.closest("[data-o-file]")) {
53323
+ this.hooks.openFile?.(c3);
51681
53324
  } else this.hooks.select(c3, e2.shiftKey);
51682
53325
  });
51683
53326
  }
@@ -51711,7 +53354,7 @@ var Outline2 = class {
51711
53354
  rows.push(
51712
53355
  `<div class="o-row${inactive ? " folded" : ""}${this.hooks.picked(c3) ? " on" : ""}" data-c="${c3}" style="padding-left:${8 + depth * 12}px" title="${escapeHtml(cl.key)}">` + // the arrow opens or folds a level of the list, the name selects: each a button, for the
51713
53356
  // keyboard as for the pointer
51714
- (has ? `<button class="tw" type="button" aria-expanded="${this.open.has(c3)}" aria-label="What ${escapeHtml(cl.label)} holds">${this.open.has(c3) ? "\u25BE" : "\u25B8"}</button>` : `<span class="tw"></span>`) + `<button class="o-label" type="button">${escapeHtml(cl.label)}</button>` + (this.hooks.stateOf(c3) ? `<span class="o-st ${this.hooks.stateOf(c3)}"></span>` : "") + `<span class="o-count">${cl.count}</span>` + this.hooks.trustCell(c3) + `<button class="o-hide" data-hide title="Hide this level, for everyone on this board: what it holds moves up into its parent (\u2699 Board shows it again)" aria-label="Hide this level">${HIDE_MARK}</button><button class="fold" title="${folded ? "Unfold" : "Fold"} on the canvas" aria-label="${folded ? "Unfold" : "Fold"} ${escapeHtml(cl.label)} on the canvas">${folded ? "\u25CB" : "\u25CF"}</button></div>`
53357
+ (has ? `<button class="tw" type="button" aria-expanded="${this.open.has(c3)}" aria-label="What ${escapeHtml(cl.label)} holds">${this.open.has(c3) ? "\u25BE" : "\u25B8"}</button>` : `<span class="tw"></span>`) + `<button class="o-label" type="button">${escapeHtml(cl.label)}</button>` + (this.hooks.stateOf(c3) ? `<span class="o-st ${this.hooks.stateOf(c3)}"></span>` : "") + `<span class="o-count">${cl.count}</span>` + (this.hooks.file?.(c3) ? `<button class="o-file" type="button" data-o-file title="Open the file: the whole of ${escapeHtml(this.hooks.file(c3))} in a window of its own" aria-label="Open the file ${escapeHtml(cl.label)}">${FILE_MARK}</button>` : "") + this.hooks.trustCell(c3) + `<button class="o-hide" data-hide title="Hide this level, for everyone on this board: what it holds moves up into its parent (\u2699 Board shows it again)" aria-label="Hide this level">${HIDE_MARK}</button><button class="fold" title="${folded ? "Unfold" : "Fold"} on the canvas" aria-label="${folded ? "Unfold" : "Fold"} ${escapeHtml(cl.label)} on the canvas">${folded ? "\u25CB" : "\u25CF"}</button></div>`
51715
53358
  );
51716
53359
  if (has && this.open.has(c3)) for (const k2 of this.kids[c3]) walk2(k2, depth + 1);
51717
53360
  };
@@ -51733,6 +53376,11 @@ var Outline2 = class {
51733
53376
  };
51734
53377
 
51735
53378
  // src/web/src/pageside.ts
53379
+ function fileCluster(page, key) {
53380
+ if (page.cm() !== "module" || isPhone()) return null;
53381
+ const g2 = page.g;
53382
+ return moduleDecls(g2, key).some((i2) => !g2.isExt(i2)) ? key : null;
53383
+ }
51736
53384
  function sidePart(page) {
51737
53385
  const { data, store: store2, reader } = page;
51738
53386
  const shut = (section) => store2.isShut(section);
@@ -51782,7 +53430,14 @@ function sidePart(page) {
51782
53430
  },
51783
53431
  trustCell: (c3) => trust.cell(page.canvas.layout.clusters[c3], page.cm()),
51784
53432
  trustClicked: (c3, row) => trust.clicked(page.canvas.layout.clusters[c3], page.cm(), row),
51785
- hide: (c3) => hideLevel(page.canvas.layout.clusters[c3].key)
53433
+ hide: (c3) => hideLevel(page.canvas.layout.clusters[c3].key),
53434
+ // clustered by file, a file of the project opens whole (the owner's decision of 2026-11-01); a
53435
+ // phone pins no window (PhoneSpec decision 13), and opens it by a window's switch alone
53436
+ file: (c3) => fileCluster(page, page.canvas.layout.clusters[c3].key),
53437
+ openFile: (c3) => {
53438
+ const m3 = fileCluster(page, page.canvas.layout.clusters[c3].key);
53439
+ if (m3) page.sources.openFile(m3);
53440
+ }
51786
53441
  });
51787
53442
  page.fileIndex = files();
51788
53443
  const boardPanel = new BoardPanel($("#board"), $("#board-note"), {
@@ -52419,6 +54074,7 @@ function schemePart(page) {
52419
54074
  // src/web/src/pagefollow.ts
52420
54075
  function followPart(page) {
52421
54076
  const { S: S7 } = page;
54077
+ const pinnedOf = (p2) => p2.file !== null ? { file: p2.file, collapsed: p2.collapsed } : { decl: p2.name, collapsed: p2.collapsed, ...p2.mode === "file" ? { mode: "file" } : {} };
52422
54078
  const parts = {
52423
54079
  read: {
52424
54080
  view: () => ({ view: page.nav.board.id, scope: page.nav.query(), clusterMode: page.cm() }),
@@ -52432,14 +54088,23 @@ function followPart(page) {
52432
54088
  focus: () => page.mine !== void 0 ? { focus: page.mine } : {},
52433
54089
  visitors: () => page.visitors.length ? { visitors: shareVisitors(page.visitors, (k2) => page.canvas.visitorPos(k2)) } : {},
52434
54090
  panel: () => ({ sel: page.shown && "decl" in page.shown ? page.shown.decl : null }),
52435
- // the source windows, the following one and those pinned (decided 2026-10-09)
54091
+ // the source windows, the following one and those pinned (decided 2026-10-09), each in its
54092
+ // mode, and the file windows (the owner's decisions of 2026-11-01)
52436
54093
  sources: () => ({
52437
54094
  source: page.sources.open,
52438
54095
  ...page.sources.following?.collapsed ? { sourceCollapsed: true } : {},
52439
- ...page.sources.pinned.length ? { pinned: page.sources.pinned.map((p2) => ({ decl: p2.name, collapsed: p2.collapsed })) } : {}
54096
+ ...page.sources.following?.mode === "file" ? { sourceMode: "file" } : {},
54097
+ ...page.sources.pinned.length ? { pinned: page.sources.pinned.map(pinnedOf) } : {}
52440
54098
  }),
52441
54099
  // the reference window (AttachmentSpec decision 11)
52442
54100
  paper: () => page.papers.state() ? { paper: page.papers.state() } : {},
54101
+ // the InfoView's caret (ReviewSpec, "The InfoView"; the owner's decision of 2026-11-01): the
54102
+ // page's one, in the window the reader put it in
54103
+ caret: () => {
54104
+ const w2 = page.sources.all.find((p2) => p2.caret);
54105
+ const c3 = w2?.caret;
54106
+ return w2 && c3 ? { caret: { decl: w2.name, line: c3.line, character: c3.ch, ...c3.after ? { after: true } : {}, ...w2 !== page.sources.following ? { pinned: true } : {} } } : {};
54107
+ },
52443
54108
  activity: () => ({ activity: page.activity.state() }),
52444
54109
  lostFound: () => ({ lostFound: { open: page.lostDrawer.open } }),
52445
54110
  // the reader's own, under an artwork's, which the artwork's part carries
@@ -52494,14 +54159,20 @@ function followPart(page) {
52494
54159
  if (ended()) return reached;
52495
54160
  applyOwn(v2, parts.apply);
52496
54161
  if (!once) page.papers.mirror(v2.paper);
52497
- if (!page.pastShown())
54162
+ if (!page.pastShown()) {
52498
54163
  page.sources.mirror({
52499
- following: v2.source ? { decl: page.selected(), collapsed: v2.sourceCollapsed === true } : null,
54164
+ following: v2.source ? { decl: page.selected(), collapsed: v2.sourceCollapsed === true, mode: v2.sourceMode === "file" ? "file" : "decl" } : null,
52500
54165
  pinned: (v2.pinned ?? []).flatMap((w2) => {
54166
+ if ("file" in w2) return moduleDecls(page.g, w2.file).length ? [{ file: w2.file, collapsed: w2.collapsed }] : [];
52501
54167
  const i2 = page.g.byName.get(w2.decl);
52502
- return i2 === void 0 ? [] : [{ decl: i2, collapsed: w2.collapsed }];
54168
+ return i2 === void 0 ? [] : [{ decl: i2, collapsed: w2.collapsed, ...w2.mode === "file" ? { mode: "file" } : {} }];
52503
54169
  })
52504
54170
  });
54171
+ const c3 = v2.caret;
54172
+ const f2 = page.sources.following;
54173
+ const at = c3 ? c3.pinned ? page.sources.pinned.find((p2) => p2.name === c3.decl) : f2 && f2.name === c3.decl ? f2 : void 0 : void 0;
54174
+ for (const p2 of page.sources.all) p2.followCaret(p2 === at && c3 ? { line: c3.line, ch: c3.character, after: c3.after === true } : null);
54175
+ }
52505
54176
  if (once) {
52506
54177
  page.papers.mirror(v2.paper);
52507
54178
  page.sources.release();
@@ -52555,12 +54226,12 @@ function talkPart(page) {
52555
54226
  peers: () => page.people.peers,
52556
54227
  resolve: resolveName,
52557
54228
  go: (name) => {
52558
- page.people.unfollow();
54229
+ page.people.leave();
52559
54230
  const i2 = page.g.byName.get(name);
52560
54231
  if (i2 !== void 0) page.go(i2);
52561
54232
  },
52562
54233
  open: (hash) => {
52563
- page.people.unfollow();
54234
+ page.people.leave();
52564
54235
  page.openAddress(hash);
52565
54236
  },
52566
54237
  chip: (url) => chipFor(url),
@@ -52597,7 +54268,9 @@ function talkPart(page) {
52597
54268
  $("#talk-notice").hidden = true;
52598
54269
  talk.open(noticeOf);
52599
54270
  });
52600
- if (store2.data.chatOpen && !talkBtn.hidden) page.chatWin.show();
54271
+ const reopenTalk = () => {
54272
+ if (store2.data.chatOpen && !talkBtn.hidden) page.chatWin.show();
54273
+ };
52601
54274
  const chipFor = (url) => {
52602
54275
  const l2 = siteLink(url, site.origins);
52603
54276
  if (!l2) return null;
@@ -52610,7 +54283,7 @@ function talkPart(page) {
52610
54283
  tool: (t2) => restsOn(t2) ? "Rests on" : MODE_NAME[t2]
52611
54284
  });
52612
54285
  };
52613
- return { talk, chipFor };
54286
+ return { talk, chipFor, reopenTalk };
52614
54287
  }
52615
54288
 
52616
54289
  // src/shared/askfollow.ts
@@ -53157,6 +54830,8 @@ function inRoom(page, other) {
53157
54830
  // src/web/src/pointers.ts
53158
54831
  var NOT_TEXT = '[aria-hidden="true"]';
53159
54832
  var CODE = "pre.code.src";
54833
+ var baseOf = (code) => Number(code.dataset?.line ?? 0) || 0;
54834
+ var inFile = (code, [line, col]) => [baseOf(code) + line, col];
53160
54835
  var BOARD = "#canvas, #labels, #cards, #stickies";
53161
54836
  var clamp01 = (n3) => Math.min(1.5, Math.max(-0.5, n3));
53162
54837
  var round3 = (n3, d2 = 1e3) => Math.round(n3 * d2) / d2;
@@ -53295,7 +54970,7 @@ function anchorAt(x2, y2, t2, h2) {
53295
54970
  const decl = h2.windowDecl(sw);
53296
54971
  const c3 = caretAt(x2, y2);
53297
54972
  const o2 = decl && c3 ? offsetIn2(code, c3.node, c3.offset) : null;
53298
- if (decl && o2 !== null) return { sw: decl, lc: lineColOf(textOf2(code), o2) };
54973
+ if (decl && o2 !== null) return { sw: decl, lc: inFile(code, lineColOf(textOf2(code), o2)) };
53299
54974
  }
53300
54975
  const page = t2.closest(".pw-win .pw-page, .pw-win .pw-img");
53301
54976
  if (page) {
@@ -53317,7 +54992,7 @@ function textAt(node, offset, h2) {
53317
54992
  if (sw && code) {
53318
54993
  const decl = h2.windowDecl(sw);
53319
54994
  const o3 = decl ? offsetIn2(code, node, offset) : null;
53320
- return decl && o3 !== null ? { sw: decl, lc: lineColOf(textOf2(code), o3) } : null;
54995
+ return decl && o3 !== null ? { sw: decl, lc: inFile(code, lineColOf(textOf2(code), o3)) } : null;
53321
54996
  }
53322
54997
  const from = rootOf(e2, h2);
53323
54998
  const path = from ? stepsTo(from.el, e2) : null;
@@ -53381,9 +55056,9 @@ function caretRect(p2) {
53381
55056
  function textHere(t2, h2) {
53382
55057
  if ("lc" in t2) {
53383
55058
  const win2 = h2.windowOf(t2.sw);
53384
- const code = win2?.querySelector(CODE);
55059
+ const code = win2 ? [...win2.querySelectorAll(CODE)].find((c3) => t2.lc[0] >= baseOf(c3) && t2.lc[0] < baseOf(c3) + c3.children.length) : void 0;
53385
55060
  if (!win2 || !code) return null;
53386
- const o2 = offsetOf(textOf2(code), t2.lc);
55061
+ const o2 = offsetOf(textOf2(code), [t2.lc[0] - baseOf(code), t2.lc[1]]);
53387
55062
  const p3 = o2 === null ? null : pointIn(code, o2);
53388
55063
  return p3 ? { p: p3, holder: code, root: win2 } : null;
53389
55064
  }
@@ -53708,10 +55383,11 @@ function pointerPart(page) {
53708
55383
  return { left: r2.left + i2.left, top: r2.top + i2.top, right: r2.right - i2.right, bottom: r2.bottom - i2.bottom };
53709
55384
  },
53710
55385
  linear: () => page.linear.shown ? { at: (x2, y2) => page.linear.pointAt(x2, y2), screenOf: (p2) => page.linear.screenOf(p2), room: () => page.linear.room(), reveal: (k2) => page.linear.reveal(k2) } : null,
53711
- windowDecl: (el) => page.sources.all.find((w2) => w2.el === el)?.name ?? null,
55386
+ // a window by its declaration's name, a file window by its file (SourceWindow.anchor)
55387
+ windowDecl: (el) => page.sources.all.find((w2) => w2.el === el)?.anchor || null,
53712
55388
  // the window open on it, the following one first; a collapsed one is a pill, which holds no code
53713
55389
  windowOf: (decl) => {
53714
- const all = page.sources.all.filter((w2) => w2.name === decl);
55390
+ const all = page.sources.all.filter((w2) => w2.anchor === decl);
53715
55391
  return (all.find((w2) => !w2.collapsed) ?? all[0])?.el ?? null;
53716
55392
  },
53717
55393
  yours: (el) => inYours(el),
@@ -54823,10 +56499,10 @@ var Activity = class {
54823
56499
  }
54824
56500
  const label = linkRef(h2.id, h2.label);
54825
56501
  const file = fileOf(r2, h2.file);
54826
- const inFile = file ? fileRef(h2.file, file.title) : `<span class="act-gone" title="This server has no record of this file">a file</span>`;
56502
+ const inFile2 = file ? fileRef(h2.file, file.title) : `<span class="act-gone" title="This server has no record of this file">a file</span>`;
54827
56503
  const names2 = (...ss) => [...new Set([...ss, links.get(h2.id)?.subject].flatMap(declIn))];
54828
56504
  if (h2.op !== "link-edit") {
54829
- const html2 = h2.op === "link" ? `${by} linked ${subject(h2.subject)} to ${label} in ${inFile}` : `${by} removed the link ${label} from ${subject(h2.subject)}`;
56505
+ const html2 = h2.op === "link" ? `${by} linked ${subject(h2.subject)} to ${label} in ${inFile2}` : `${by} removed the link ${label} from ${subject(h2.subject)}`;
54830
56506
  out.push({ ...base, by: now(h2.by, h2.person), cat: "review", html: html2, names: names2(h2.subject) });
54831
56507
  return;
54832
56508
  }
@@ -55877,22 +57553,6 @@ function addressPart(page) {
55877
57553
  return { current: current3, seenHash, renderNav, writeAddress, commit, openAddress };
55878
57554
  }
55879
57555
 
55880
- // src/shared/build.ts
55881
- function applyBuildDelta(held2, d2) {
55882
- if (d2.epoch !== held2.epoch || d2.base !== held2.rev) return null;
55883
- const changed2 = new Map(d2.files.map((f2) => [f2.module, f2]));
55884
- const gone = new Set(d2.gone);
55885
- const files = [];
55886
- for (const f2 of held2.status?.files ?? []) {
55887
- if (gone.has(f2.module)) continue;
55888
- const c3 = changed2.get(f2.module);
55889
- files.push(c3 ?? f2);
55890
- if (c3) changed2.delete(f2.module);
55891
- }
55892
- files.push(...changed2.values());
55893
- return { epoch: d2.epoch, rev: d2.rev, status: { active: d2.active, progress: d2.progress, files, counts: d2.counts } };
55894
- }
55895
-
55896
57556
  // src/web/src/buildread.ts
55897
57557
  var MAX_WAITING = 64;
55898
57558
  function behindBuild(held2, told) {
@@ -56130,8 +57790,8 @@ function livePart(page) {
56130
57790
  root: page.meta.project.root,
56131
57791
  at: Date.now(),
56132
57792
  sources: {
56133
- following: page.sources.following ? { name: page.sources.following.name, collapsed: page.sources.following.collapsed } : null,
56134
- pinned: page.sources.pinned.map((p2) => ({ name: p2.name, collapsed: p2.collapsed }))
57793
+ following: page.sources.following ? { name: page.sources.following.name, collapsed: page.sources.following.collapsed, ...page.sources.following.mode === "file" ? { mode: "file" } : {} } : null,
57794
+ pinned: page.sources.pinned.map((p2) => p2.file !== null ? { file: p2.file, collapsed: p2.collapsed } : { name: p2.name, collapsed: p2.collapsed, ...p2.mode === "file" ? { mode: "file" } : {} })
56135
57795
  },
56136
57796
  review: page.reviewBox.keptDrafts,
56137
57797
  talk: page.talk.keptDrafts,
@@ -56510,7 +58170,8 @@ function menuItems(t2, ctx, title = "View") {
56510
58170
  if (review.length) review[0].sep = true;
56511
58171
  out.push(...review, ...note);
56512
58172
  } else if (t2.kind === "cluster") {
56513
- out.push({ act: "fold", label: t2.folded ? "Unfold" : "Fold", key: "double-click" });
58173
+ if (t2.file) out.push({ act: "file", label: "Open the file" });
58174
+ out.push({ act: "fold", label: t2.folded ? "Unfold" : "Fold", key: "double-click", ...t2.file ? { sep: true } : {} });
56514
58175
  if (ctx.arrange && !ctx.preview) out.push({ act: "hide", label: "Hide this level" });
56515
58176
  out.push(...link);
56516
58177
  if (ctx.arrange) out.push(removeFrom(ctx, title, short5(t2.key)), addTo(ctx, short5(t2.key)));
@@ -56801,6 +58462,7 @@ function menuPart(page) {
56801
58462
  key: cl.key,
56802
58463
  folded: folded ?? page.canvas.folded.has(t2.c),
56803
58464
  folder: page.cm() === "module",
58465
+ ...fileCluster(page, cl.key) ? { file: cl.key } : {},
56804
58466
  trust: st2.prefix && (st2.on || !st2.by) ? { prefix: st2.prefix, on: st2.on } : null,
56805
58467
  ...inArt !== void 0 ? { art: inArt } : {}
56806
58468
  };
@@ -56916,6 +58578,9 @@ function menuPart(page) {
56916
58578
  case "pin":
56917
58579
  if (i2 !== void 0) page.sources.openPinned(i2);
56918
58580
  return;
58581
+ case "file":
58582
+ if (t2.kind === "cluster" && t2.file) page.sources.openFile(t2.file);
58583
+ return;
56919
58584
  case "tcb":
56920
58585
  case "deps":
56921
58586
  case "apps":
@@ -57616,7 +59281,7 @@ var SearchBox = class {
57616
59281
  const dot = name.lastIndexOf(".");
57617
59282
  let html = `<div class="hit${k2 === this.cursor ? " on" : ""}" data-i="${h2.i}"><div class="h-line"><span class="dot ${kindDot(v2.kind, g2.isExt(h2.i))}"></span><span class="h-name">${piecesHtml(marked(name, lower, f2.words, dot + 1))}</span><span class="h-ns">${piecesHtml(marked(name, lower, f2.words, 0, Math.max(0, dot)))}</span></div>`;
57618
59283
  if (h2.via !== void 0) {
57619
- const via = h2.via;
59284
+ const via = withoutMacroScopes(h2.via);
57620
59285
  html += `<div class="h-snip h-also"><span class="h-where">also declares</span><span class="h-text">${piecesHtml(marked(via, lowerKeepingOffsets(via), f2.words))}</span></div>`;
57621
59286
  } else if (h2.where !== "name") {
57622
59287
  const p2 = h2.where === "statement" ? 1 : 2;
@@ -57702,6 +59367,7 @@ function keysPart(page) {
57702
59367
  if (win2 && route === "own") {
57703
59368
  if (e2.ctrlKey || e2.metaKey || e2.altKey || e2.repeat) return;
57704
59369
  e2.preventDefault();
59370
+ if (win2.decl < 0) return page.say("This window is on a file, not on a declaration: select one first, from a name in it or the bar over the code.");
57705
59371
  if (e2.key === "k") page.toggleKey(win2.decl);
57706
59372
  else page.reviewBox.give(e2.key === "a" ? "approve" : "comment", win2.decl, win2.el);
57707
59373
  return;
@@ -57991,6 +59657,28 @@ var TIPS = [
57991
59657
  showMe: "colour-status",
57992
59658
  manual: "what-you-see"
57993
59659
  },
59660
+ {
59661
+ id: "whole-file",
59662
+ group: "seeing",
59663
+ title: "The whole file",
59664
+ text: "<b>File</b>, in a source window's title bar, shows the whole file, each declaration marked by its review; <b>Fold proofs</b> folds each proof to a line. On a larger screen, a file's row in <b>Files</b> opens one.",
59665
+ who: "all",
59666
+ where: "both",
59667
+ since: "0.9.0",
59668
+ about: [".sw-win [data-sw-mode=file]", ".sw-win [data-sw-folds]", "#outline [data-o-file]"],
59669
+ manual: "review"
59670
+ },
59671
+ {
59672
+ id: "infoview",
59673
+ group: "seeing",
59674
+ title: "Lean's goals, step by step",
59675
+ text: "Click a tactic in a source window: the <b>InfoView</b> beside the code shows Lean's goals before it, <b>After</b> those after it, a subterm's type as you rest on it. <kbd>\u2191</kbd> <kbd>\u2193</kbd> step through the proof, those following you watching.",
59676
+ who: "all",
59677
+ where: "both",
59678
+ since: "0.9.0",
59679
+ about: [".sw-info", ".sw-info [data-iv-when=after]"],
59680
+ manual: "review"
59681
+ },
57994
59682
  // ─────────────────────────────────────────────────────────────── reviewing
57995
59683
  {
57996
59684
  id: "what-changed",
@@ -58050,7 +59738,7 @@ var TIPS = [
58050
59738
  id: "follow",
58051
59739
  group: "together",
58052
59740
  title: "Follow someone",
58053
- text: "Click someone's initials to see what they see: their view, camera, selection and windows. Anything you change ends it, and so does Esc.",
59741
+ text: "Click someone's initials to see what they see: their view, camera, selection and windows. Anything you change ends it, and <b>Follow again</b> in the strip takes you back; Esc stops it.",
58054
59742
  who: "all",
58055
59743
  where: "both",
58056
59744
  since: "0.1.0",
@@ -60109,6 +61797,7 @@ async function boot() {
60109
61797
  Object.assign(page, menuPart(page));
60110
61798
  Object.assign(page, notesPart(page));
60111
61799
  Object.assign(page, keysPart(page));
61800
+ page.reopenTalk();
60112
61801
  window.visualproof = { canvas: page.canvas, linear: page.linear, graph: () => page.g, present: () => page.present, board: () => page.nav.board, views: page.views, tm: page.tm, timeMachine: (at) => page.openTimeMachine(at) };
60113
61802
  window.addEventListener("resize", page.syncInsets);
60114
61803
  const firstPlace = linked ? { mode: linked.mode, picks: linked.picks, shown: linked.shown, cam: null, ...keptFocus(S7.seen[first]) } : null;
@@ -60136,11 +61825,12 @@ async function boot() {
60136
61825
  page.renderBuild();
60137
61826
  if (kept && (kept.sources.following || kept.sources.pinned.length)) {
60138
61827
  const on = (w2) => {
61828
+ if ("file" in w2) return moduleDecls(page.present, w2.file).length ? { file: w2.file, collapsed: w2.collapsed } : null;
60139
61829
  const decl = page.present.byName.get(w2.name);
60140
- return decl === void 0 ? null : { decl, collapsed: w2.collapsed };
61830
+ return decl === void 0 ? null : { decl, collapsed: w2.collapsed, mode: w2.mode ?? "decl" };
60141
61831
  };
60142
61832
  const f2 = kept.sources.following && on(kept.sources.following);
60143
- page.sources.mirror({ following: f2, pinned: kept.sources.pinned.map(on).filter((w2) => w2 !== null) });
61833
+ page.sources.mirror({ following: f2 && "decl" in f2 ? f2 : null, pinned: kept.sources.pinned.map(on).filter((w2) => w2 !== null) });
60144
61834
  page.sources.release();
60145
61835
  }
60146
61836
  $("#loader").classList.add("gone");