@seikika/astro-report 0.0.0-stage → 0.1.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.
@@ -0,0 +1,947 @@
1
+ import type { ReportViews } from "../report-view";
2
+ import type { Summary } from "../lib/summary";
3
+ import { noFacts } from "../lib/summary";
4
+ import type { ReportData } from "../types";
5
+ import { badge, barEl, grow, legendEl, levelLegend, levelOrder, levelPill, medal, splitUnassessed, tallyLevels, unrunIn } from "../lib/bars";
6
+ import { BASIS, basisBadge, basisCounts, basisIcon, basisInline, basisKey, basisOf, lockIcon, refs, whyEl } from "../lib/basis";
7
+ import { levelName, moverBits, nextLevel, scCaption, verifiedMover } from "../lib/campaigns";
8
+ import { cardName, judgedMark, keepWithLast } from "../lib/compare";
9
+ import { el, enc, KNOWN, link } from "../lib/dom";
10
+ import { kindCount, kindTitle } from "../lib/kinds";
11
+ import { ONLY_LEVEL, fill } from "../lib/levels";
12
+ import { capsRepo, isTop, shortId, title } from "../lib/rings";
13
+ import { trackPath } from "../lib/routes";
14
+ import { LADDER, floorOf, floorPill, isComparative, memberLinks, ruleLink, ruleTitle } from "../lib/rules";
15
+ import { blockers, isFailing, isPassing } from "../lib/status";
16
+ import { rich, richCards } from "../lib/text";
17
+ import { trackStats, trackTitle, tracksSorted, unassessedIn, unassessedNote } from "../lib/tracks";
18
+ import { fmt, plural, scPurpose, whyFirst } from "../lib/words";
19
+
20
+ export const scorecardsViews = {
21
+ scorecardIndex(D: ReportData, S: Summary, query) {
22
+ var self = this;
23
+ var standards = S.rows.filter(function (r) {
24
+ return !r.compare;
25
+ });
26
+ var factors = S.rows.length - standards.length;
27
+ var groups = tracksSorted(D, S)
28
+ .filter(function (t) {
29
+ return !t.compare && t.cards.length;
30
+ })
31
+ .map(function (t) {
32
+ return { name: t.name, title: t.def.title || t.name, rows: t.cards.map(function (c) { return c.row; }) };
33
+ });
34
+ var placed = {};
35
+ groups.forEach(function (g) {
36
+ g.rows.forEach(function (r) {
37
+ placed[r.name] = true;
38
+ });
39
+ });
40
+ var loose = standards.filter(function (r) {
41
+ return !placed[r.name];
42
+ });
43
+ if (loose.length) groups.push({ name: null, title: "Not in a track", rows: loose });
44
+ var search = el("input", { type: "search", placeholder: "Find a scorecard…", title: "Matches a scorecard's name, id, kind, or how it's decided", ariaLabel: "Find a scorecard by name, id, kind, or how it's decided", value: (query || {}).q || "" });
45
+ var only = function (b) {
46
+ return el(
47
+ "button",
48
+ {
49
+ className: "link",
50
+ onclick: function () {
51
+ search.value = BASIS[b].label.toLowerCase();
52
+ search.dispatchEvent(new Event("input"));
53
+ },
54
+ },
55
+ basisIcon(b),
56
+ " " + BASIS[b].label,
57
+ );
58
+ };
59
+ var mixedBases = standards.some(function (r) {
60
+ return basisCounts(r.sc.rules).judged;
61
+ }) && standards.some(function (r) {
62
+ return basisCounts(r.sc.rules).measured;
63
+ });
64
+ var anyScored = standards.some(function (r) {
65
+ return r.scored > 0;
66
+ });
67
+ var basisPick = el("p", { className: "sub", style: "margin:6px 0 0" }, "Show only: ", only("judged"), " · ", only("measured"));
68
+ var list = el("div");
69
+ var row = function (r) {
70
+ var floor = floorOf(D, r.name);
71
+ var purpose = scPurpose(r.sc);
72
+ return link("scorecard/" + enc(r.name), "sc-row", [
73
+ medal(floor || "not scored", 26),
74
+ el("div", { className: "sc-name" }, ...cardName(D, r.name)),
75
+ el("div", { className: "sc-dist" }, barEl(splitUnassessed(D, r.name, r.parts)), el("small", {}, ...scCaption(D, r))),
76
+ el("div", { className: "sc-weak" }, floor ? floorPill(D, r.name) : el("span", { className: "sub", textContent: "not scored" }), r.none ? el("small", { className: "bad", textContent: fmt(r.none) + " at none" }) : floor && capsRepo(D, r.name, floor) ? el("small", { className: "capnote" }, lockIcon(), " at its top level, so it caps the repository") : floor && isTop(D, r.name, floor) && !ONLY_LEVEL.has(floor) ? el("small", { className: "topmark", textContent: "✓ top level" }) : null),
77
+ purpose ? el("span", { className: "sc-why", textContent: purpose }) : null,
78
+ ]);
79
+ };
80
+ var draw = function () {
81
+ var q = search.value.toLowerCase();
82
+ var hit = function (r) {
83
+ var basis: keyof typeof BASIS = basisCounts(r.sc.rules).judged ? "judged" : "measured";
84
+ var basisWords = BASIS[basis].label.toLowerCase() + (basis === "judged" ? " judged by an agent assessed" : " measured deterministic mechanical");
85
+ return !q || r.name.toLowerCase().indexOf(q) >= 0 || title(D, r.name).toLowerCase().indexOf(q) >= 0 || kindTitle(D, r.sc.kind || "").toLowerCase().indexOf(q) >= 0 || basisWords.indexOf(q) >= 0;
86
+ };
87
+ var shown = groups
88
+ .map(function (g) {
89
+ return { g: g, rows: g.rows.filter(hit) };
90
+ })
91
+ .filter(function (x) {
92
+ return x.rows.length;
93
+ });
94
+ var want = "#scorecards" + (search.value ? "?q=" + encodeURIComponent(search.value) : "");
95
+ if (location.hash !== want && history.replaceState) history.replaceState(history.state, "", want);
96
+ if (!shown.length) {
97
+ list.replaceChildren(
98
+ el("div", { className: "empty" }, "No scorecards match “" + search.value + "”. ", el("button", {
99
+ className: "link",
100
+ textContent: "Clear search",
101
+ onclick: function () {
102
+ search.value = "";
103
+ draw();
104
+ search.focus();
105
+ },
106
+ })),
107
+ );
108
+ return;
109
+ }
110
+ // Without a search, scorecards whose every entity is at the top level fold under one row, so the
111
+ // work left leads each group. One that caps the repository stays out: its top level is the blocker.
112
+ var doneOf = function (r) {
113
+ return !q && r.scored > 0 && r.topShare === 100 && !capsRepo(D, r.name, floorOf(D, r.name));
114
+ };
115
+ list.replaceChildren(
116
+ ...shown.map(function (x) {
117
+ var done = x.rows.filter(doneOf);
118
+ if (done.length < 2) done = [];
119
+ var open = x.rows.filter(function (r) {
120
+ return done.indexOf(r) < 0;
121
+ });
122
+ // A long group shows its weakest few; the rest open in place, so each track's debt scans first.
123
+ var SHOWN = 4;
124
+ var rest = !q && open.length > SHOWN + 1 ? open.slice(SHOWN) : [];
125
+ if (rest.length) open = open.slice(0, SHOWN);
126
+ var restRows = el("div", { className: "sc-rest", hidden: true });
127
+ var restBtn = rest.length
128
+ ? el("button", {
129
+ className: "link sc-more",
130
+ ariaExpanded: "false",
131
+ textContent: "Show the other " + plural(rest.length, "scorecard") + " in " + x.g.title,
132
+ onclick: function (this: HTMLElement) {
133
+ var opening = this.getAttribute("aria-expanded") !== "true";
134
+ if (opening && !restRows.childElementCount) restRows.append(...rest.map(row));
135
+ restRows.hidden = !opening;
136
+ this.setAttribute("aria-expanded", String(opening));
137
+ this.textContent = opening ? "Show only the weakest " + SHOWN : "Show the other " + plural(rest.length, "scorecard") + " in " + x.g.title;
138
+ var first = opening && restRows.querySelector("a");
139
+ if (first) first.focus();
140
+ },
141
+ })
142
+ : null;
143
+ var byLevel = {};
144
+ var topAt = {};
145
+ var levelOrderSeen: any[] = [];
146
+ x.rows.forEach(function (r) {
147
+ var f = floorOf(D, r.name);
148
+ if (!f) return;
149
+ if (!byLevel[f]) levelOrderSeen.push(f);
150
+ byLevel[f] = (byLevel[f] || 0) + 1;
151
+ if (isTop(D, r.name, f) && !ONLY_LEVEL.has(f) && LADDER.indexOf(f) < LADDER.length - 1) topAt[f] = (topAt[f] || 0) + 1;
152
+ });
153
+ var mix = q
154
+ ? ""
155
+ : levelOrderSeen
156
+ .sort(function (a, b) {
157
+ var ra = LADDER.indexOf(a);
158
+ var rb = LADDER.indexOf(b);
159
+ return (ra < 0 ? 9 : ra) - (rb < 0 ? 9 : rb);
160
+ })
161
+ .map(function (l) {
162
+ return byLevel[l] + " at " + levelName(l) + (topAt[l] ? " (" + topAt[l] + " at its top level)" : "");
163
+ })
164
+ .join(" · ");
165
+ var fold: HTMLDetailsElement | null = null;
166
+ if (done.length) {
167
+ var body = el("div", { className: "sc-done-rows" });
168
+ fold = el(
169
+ "details",
170
+ {
171
+ className: "sc-done",
172
+ ontoggle: function (this: HTMLDetailsElement) {
173
+ if (this.open && !body.childElementCount) body.append(...done.map(row));
174
+ },
175
+ },
176
+ el("summary", {}, el("span", { className: "topmark", textContent: "✓ " + plural(done.length, "scorecard") + " with every entity at the top level" }), el("small", { textContent: done.map(function (r) { return title(D, r.name); }).join(", ") })),
177
+ body,
178
+ );
179
+ }
180
+ var lead = x.g.name ? verifiedMover(D, trackStats(D, S, x.g.name).cards) : null;
181
+ return el(
182
+ "div",
183
+ { className: "sc-group" },
184
+ groups.length === 1 && !x.g.name ? null : el("h3", {}, x.g.name ? link(trackPath(D, x.g.name), "", x.g.title) : x.g.title, el("span", { className: "sub", textContent: " · " + plural(x.rows.length, "scorecard") + (x.g.name ? ", weakest first" : "") + (mix ? "; by lowest level, " + mix : "") })),
185
+ lead ? el("div", { className: "tnext", style: "margin:0 0 8px" }, el("b", { textContent: "Next: " }), ...moverBits(D, lead)) : null,
186
+ el("div", { className: "sc-rows" }, el("div", { className: "sc-head", ariaHidden: "true" }, el("span"), el("span", { textContent: "Scorecard" }), el("span", { textContent: "Entities by level" }), el("span", { textContent: "Lowest level" })), ...open.map(row), restRows, restBtn ? el("div", { className: "more" }, restBtn) : null, fold),
187
+ );
188
+ }),
189
+ );
190
+ };
191
+ search.oninput = draw;
192
+ draw();
193
+ const highestDebt = groups
194
+ .map(group => ({ group, atNone: group.rows.filter(row => row.none > 0).length }))
195
+ .sort((a, b) => b.atNone - a.atNone)[0];
196
+ const debtSummary = groups.length > 1 && highestDebt?.atNone
197
+ ? el("p", { className: "sc-debt" },
198
+ el("button", {
199
+ type: "button",
200
+ className: "link",
201
+ textContent: highestDebt.group.title,
202
+ onclick: () => {
203
+ search.value = "";
204
+ draw();
205
+ const group = list.querySelectorAll(".sc-group")[groups.indexOf(highestDebt.group)];
206
+ const heading = group?.querySelector("h3");
207
+ group?.scrollIntoView({ block: "start" });
208
+ if (heading) {
209
+ heading.tabIndex = -1;
210
+ heading.focus({ preventScroll: true });
211
+ }
212
+ },
213
+ }),
214
+ " has the most scorecards with an entity at none (" +
215
+ highestDebt.atNone + " of " + highestDebt.group.rows.length + ").")
216
+ : null;
217
+ return el(
218
+ "section",
219
+ { className: "sc-index" },
220
+ el("div", { className: "head" }, el("h2", { textContent: "Scorecards" }), el("span", { className: "sub", textContent: plural(standards.length, "scorecard") + (groups.length > 1 ? " in " + plural(groups.length, "group") : "") })),
221
+ debtSummary,
222
+ el("p", { className: "lede" }, "Each scorecard rates every entity of one kind against levels of rules; the medal is its weakest entity's level, and the bar shows where the rest stand. " + (Object.keys(D.tracks || {}).length ? "They are grouped by track, the line of work each one serves. " : "") + "Open one for its failures, entities and what each level needs.", factors ? el("span", {}, " The " + plural(factors, "comparison factor") + " against a rival are on ", link("compare", "", "the Compare tab"), ".") : null),
223
+ noFacts(S) ? el("div", { className: "next", style: "margin:8px 0" }, el("b", { textContent: "Nothing is scored yet. Next: " }), "run ", el("code", { textContent: "seikika doctor" }), " to see which connector or tool is missing, then ", el("code", { textContent: "seikika report" }), " again.") : null,
224
+ anyScored ? el("details", { className: "keyd", open: !matchMedia("(max-width:640px)").matches }, el("summary", { textContent: "How to read the bars" }), levelLegend(D, standards)) : null,
225
+ el("label", { className: "sc-search" }, el("span", { className: "sub" }, "Filter scorecards"), search),
226
+ mixedBases ? basisPick : null,
227
+ list,
228
+ );
229
+ },
230
+
231
+ scorecard(D: ReportData, S: Summary, name, query) {
232
+ query = query || {};
233
+ var ranked = S.rows;
234
+ var active = name && D.scorecards[name] ? name : ranked[0] && ranked[0].name;
235
+ if (!active) return el("section", {}, el("div", { className: "empty", textContent: "No scorecards in this report." }));
236
+ var self = this;
237
+ var sc = D.scorecards[active];
238
+ var rows = Object.entries(D.scores[active] || {});
239
+ var order = levelOrder(sc.levels);
240
+ // How far off an entity is: the measures of the rules it fails (lines over a limit, findings).
241
+ var offBy = function (r) {
242
+ return Object.keys(r.rules || {}).reduce(function (n, rule) {
243
+ var v = (r.measures || {})[rule];
244
+ return n + (isFailing(r.rules[rule]) && typeof v === "number" ? v : 0);
245
+ }, 0);
246
+ };
247
+ var parts = tallyLevels(rows, order);
248
+
249
+ var cardSearch = el("input", { type: "search", placeholder: "Find a scorecard by name or id…", ariaLabel: "Find a scorecard" });
250
+ var cardNav = el("nav", { className: "rank", ariaLabel: "Scorecards, most debt first" });
251
+ var drawCards = function () {
252
+ var q = cardSearch.value.toLowerCase();
253
+ var shown = ranked.filter(function (r) {
254
+ return !q || r.name.toLowerCase().indexOf(q) >= 0 || title(D, r.name).toLowerCase().indexOf(q) >= 0 || (r.sc.kind || "").toLowerCase().indexOf(q) >= 0;
255
+ });
256
+ if (!shown.length) {
257
+ cardNav.replaceChildren(
258
+ el("div", { className: "empty", textContent: "No scorecards match." }),
259
+ el("button", {
260
+ className: "link",
261
+ textContent: "Clear search",
262
+ onclick: function () {
263
+ cardSearch.value = "";
264
+ drawCards();
265
+ },
266
+ }),
267
+ );
268
+ return;
269
+ }
270
+ var nStd = shown.filter(function (r) {
271
+ return !r.compare;
272
+ }).length;
273
+ var items: Node[] = [];
274
+ shown.forEach(function (r, i) {
275
+ if (i === 0 && !r.compare) items.push(el("div", { className: "rank-head", textContent: plural(nStd, "scorecard") }));
276
+ if (r.compare && (i === 0 || !shown[i - 1].compare)) items.push(el("div", { className: "rank-head" }, plural(shown.length - nStd, "comparison factor") + ", on ", link("compare", "", "the Compare tab →")));
277
+ var c = r.compare ? (D.comparisons || {})[r.name] || {} : null;
278
+ var verdict = c ? (c.verdict || {})[(c.peers || [])[0]] || "unknown" : null;
279
+ var debt = c ? (verdict === "unknown" ? "not measured" : verdict) : r.none > 0 ? r.none + " at none" : r.bronze > 0 ? r.bronze + " at bronze" : r.scored && r.topShare === 100 ? "✓ top level" : r.scored ? "✓ clear" : "not scored";
280
+ var capped = !c && !r.none && !r.bronze && r.scored && r.topShare === 100 && capsRepo(D, r.name, floorOf(D, r.name));
281
+ var a = link("scorecard/" + enc(r.name), "", [el("span", {}, ...keepWithLast(title(D, r.name), judgedMark(D, r.name, true))), el("span", { className: "debt " + (c ? (verdict === "behind" ? "bad" : verdict === "ahead" ? "ok" : "") : r.none > 0 ? "bad" : r.bronze > 0 || !r.scored ? "" : capped ? "capnote" : "ok") }, ...(capped ? [lockIcon(), " caps the repository"] : [debt]))]);
282
+ a.title = r.name + " · " + r.sc.kind;
283
+ if (r.name === active) a.setAttribute("aria-current", "true");
284
+ items.push(a);
285
+ });
286
+ cardNav.replaceChildren.apply(cardNav, items);
287
+ };
288
+ cardSearch.oninput = function () {
289
+ drawCards();
290
+ edges();
291
+ };
292
+ drawCards();
293
+ var toTop = el("button", {
294
+ className: "link rank-top",
295
+ hidden: true,
296
+ textContent: "↑ Back to the top of the list",
297
+ onclick: function () {
298
+ cardNav.scrollTop = 0;
299
+ var first = cardNav.querySelector("a");
300
+ if (first) first.focus({ preventScroll: true });
301
+ },
302
+ });
303
+ var edges = function () {
304
+ cardNav.classList.toggle("more", cardNav.scrollTop + cardNav.clientHeight < cardNav.scrollHeight - 4);
305
+ cardNav.classList.toggle("less", cardNav.scrollTop > 4);
306
+ toTop.hidden = cardNav.scrollTop <= 4;
307
+ };
308
+ cardNav.onscroll = edges;
309
+ requestAnimationFrame(function () {
310
+ var cur = cardNav.querySelector<HTMLElement>("[aria-current]");
311
+ if (cur) {
312
+ var at = cur.getBoundingClientRect().top - cardNav.getBoundingClientRect().top + cardNav.scrollTop;
313
+ if (at + cur.offsetHeight > cardNav.clientHeight) {
314
+ var want = at - cardNav.clientHeight / 3;
315
+ var base = cardNav.getBoundingClientRect().top - cardNav.scrollTop;
316
+ var row = Array.from(cardNav.querySelectorAll("a")).find(function (a) {
317
+ return a.getBoundingClientRect().top - base >= want;
318
+ });
319
+ cardNav.scrollTop = row ? row.getBoundingClientRect().top - base - 4 : want;
320
+ }
321
+ }
322
+ edges();
323
+ });
324
+
325
+ var levelFilter = query.level === "not-in-scope" || query.level === "skipped" ? "skipped" : query.level && order.indexOf(query.level) >= 0 ? query.level : "all";
326
+ var outcomeFilter = query.outcome === "failing" || query.outcome === "passing" ? query.outcome : "all";
327
+ var ruleFilter = query.rule && (sc.rules || {})[query.rule] ? query.rule : null;
328
+ var search = el("input", { type: "search", placeholder: "Filter by entity or rule…", ariaLabel: "Filter entities", value: query.q || "" });
329
+ var keepInUrl = function () {
330
+ var qs = new URLSearchParams();
331
+ if (levelFilter !== "all") qs.set("level", levelFilter === "skipped" ? "not-in-scope" : levelFilter);
332
+ if (outcomeFilter !== "all") qs.set("outcome", outcomeFilter);
333
+ if (ruleFilter) qs.set("rule", ruleFilter);
334
+ if (search.value) qs.set("q", search.value);
335
+ var tail = qs.toString();
336
+ if (!tail && location.hash.indexOf("?") < 0) return;
337
+ var want = "#scorecard/" + enc(active) + (tail ? "?" + tail : "");
338
+ if (location.hash !== want && history.replaceState) history.replaceState(history.state, "", want);
339
+ };
340
+ var filters = el("div", { className: "filters" });
341
+ var list = el("div");
342
+ var limit = 12;
343
+ var seg = function (label, options, current, set) {
344
+ var g = el(
345
+ "div",
346
+ { className: "seg" },
347
+ ...options.map(function (o) {
348
+ return el("button", {
349
+ textContent: o.label,
350
+ ariaPressed: String(current === o.value),
351
+ onclick: function () {
352
+ set(o.value);
353
+ redrawFilters();
354
+ draw();
355
+ },
356
+ });
357
+ }),
358
+ );
359
+ g.setAttribute("role", "group");
360
+ g.setAttribute("aria-label", label);
361
+ return g;
362
+ };
363
+ var clearFilters = function () {
364
+ levelFilter = "all";
365
+ outcomeFilter = "all";
366
+ ruleFilter = null;
367
+ search.value = "";
368
+ redrawFilters();
369
+ draw();
370
+ };
371
+ var redrawFilters = function () {
372
+ var present = order.filter(function (l) {
373
+ return parts.some(function (p) {
374
+ return p.level === l;
375
+ });
376
+ });
377
+ filters.replaceChildren(
378
+ seg(
379
+ "Level",
380
+ [{ label: "All levels", value: "all" }].concat(
381
+ present.map(function (l) {
382
+ return { label: l === "skipped" ? "not in scope" : l, value: l };
383
+ }),
384
+ ),
385
+ levelFilter,
386
+ function (v) {
387
+ levelFilter = v;
388
+ },
389
+ ),
390
+ seg(
391
+ "Outcome",
392
+ [
393
+ { label: "All outcomes", value: "all" },
394
+ { label: "Failing", value: "failing" },
395
+ { label: "Passing", value: "passing" },
396
+ ],
397
+ outcomeFilter,
398
+ function (v) {
399
+ outcomeFilter = v;
400
+ },
401
+ ),
402
+ ruleFilter
403
+ ? el(
404
+ "button",
405
+ {
406
+ className: "chip-filter",
407
+ ariaLabel: "Remove filter: not passing " + ruleFilter,
408
+ onclick: function () {
409
+ ruleFilter = null;
410
+ redrawFilters();
411
+ draw();
412
+ },
413
+ },
414
+ "Not passing ",
415
+ el("b", { textContent: ruleFilter }),
416
+ el("span", { ariaHidden: "true", textContent: " ×" }),
417
+ )
418
+ : "",
419
+ );
420
+ };
421
+ var draw = function () {
422
+ keepInUrl();
423
+ var q = search.value.toLowerCase();
424
+ var shown = rows
425
+ .filter(function (pair) {
426
+ return pair[1].level !== "skipped" || levelFilter === "skipped";
427
+ })
428
+ .filter(function (pair) {
429
+ return levelFilter === "all" || pair[1].level === levelFilter;
430
+ })
431
+ .filter(function (pair) {
432
+ if (!q) return true;
433
+ if (pair[0].toLowerCase().indexOf(q) >= 0) return true;
434
+ return Object.keys(pair[1].rules || {}).some(function (rn) {
435
+ return rn.toLowerCase().indexOf(q) >= 0;
436
+ });
437
+ })
438
+ .filter(function (pair) {
439
+ if (!ruleFilter) return true;
440
+ var o = (pair[1].rules || {})[ruleFilter];
441
+ return isFailing(o) || o === "unknown";
442
+ })
443
+ .filter(function (pair) {
444
+ if (outcomeFilter === "all") return true;
445
+ var outs = Object.values(pair[1].rules || {});
446
+ return outcomeFilter === "failing"
447
+ ? outs.some(isFailing)
448
+ : outs.every(function (o) {
449
+ return isPassing(o) || o === "skipped";
450
+ });
451
+ })
452
+ .sort(function (a, b) {
453
+ return order.indexOf(a[1].level) - order.indexOf(b[1].level) || offBy(b[1]) - offBy(a[1]) || a[0].localeCompare(b[0]);
454
+ });
455
+ var sized = shown.some(function (pair) {
456
+ return offBy(pair[1]) > 0;
457
+ });
458
+ if (!rows.length) {
459
+ list.replaceChildren(el("div", { className: "empty" }, "No " + kindTitle(D, sc.kind).toLowerCase() + " has been collected yet. Run ", el("code", { textContent: "seikika doctor" }), " to see whether a connector for it is listed under ", el("code", { textContent: "connectors:" }), " in the portal's ", el("code", { textContent: "seikika.yaml" }), " and installed, then ", el("code", { textContent: "seikika report" }), " again."));
460
+ return;
461
+ }
462
+ if (!shown.length) {
463
+ list.replaceChildren(
464
+ el("div", { className: "empty", textContent: "No entities match these filters." }),
465
+ el("button", { className: "link", textContent: "Clear filters", onclick: clearFilters }),
466
+ );
467
+ return;
468
+ }
469
+ var outOfScope = rows.filter(function (pair) {
470
+ return pair[1].level === "skipped";
471
+ }).length;
472
+ list.replaceChildren(el("div", { className: "sub", style: "margin:6px 0", textContent: plural(shown.length, "entity", "entities") + (outcomeFilter === "failing" ? " failing a rule" : outcomeFilter === "passing" ? " passing every rule" : "") + (outOfScope && levelFilter === "all" && outcomeFilter === "all" && !ruleFilter && !q ? " in scope, of " + kindCount(D, sc.kind, rows.length) : "") + ", lowest level first" + (sized ? ", then furthest off" : "") }));
473
+ var facts = function (pair) {
474
+ var r = pair[1];
475
+ var outs = Object.entries(r.rules || {});
476
+ var next = nextLevel(sc, r.level);
477
+ var need = next ? blockers(sc, r, next) : [];
478
+ return [r.level, unassessedIn(D, active, pair[0]) ? 1 : 0, unrunIn(sc, r).length, need.join(","), outs.filter(function (ro) {
479
+ return isFailing(ro[1]);
480
+ }).length, outs.filter(function (ro) {
481
+ return isPassing(ro[1]);
482
+ }).length, outs.length].join("|");
483
+ };
484
+ // The furthest-off member of a group (members are sorted that way), with the evidence that sizes it.
485
+ var worstOf = function (g) {
486
+ var r = g[0][1];
487
+ if (!(offBy(r) > 0)) return "";
488
+ var rule = Object.keys(r.rules || {}).find(function (n) {
489
+ return isFailing(r.rules[n]) && typeof (r.measures || {})[n] === "number";
490
+ });
491
+ var ev = rule && (r.evidence || {})[rule];
492
+ return shortId(g[0][0]) + (ev ? ", " + String(Array.isArray(ev) ? ev[0] : ev).split("\n")[0] : "");
493
+ };
494
+ var groups: any[] = [];
495
+ var byFacts = new Map();
496
+ shown.forEach(function (pair) {
497
+ var key = facts(pair);
498
+ var g = byFacts.get(key);
499
+ if (!g) {
500
+ g = [];
501
+ byFacts.set(key, g);
502
+ groups.push(g);
503
+ }
504
+ g.push(pair);
505
+ });
506
+ var entRow = function (pair) {
507
+ var id = pair[0];
508
+ var r = pair[1];
509
+ var outs = Object.entries(r.rules || {});
510
+ var failing = outs.filter(function (ro) {
511
+ return isFailing(ro[1]);
512
+ });
513
+ var passing = outs.filter(function (ro) {
514
+ return isPassing(ro[1]);
515
+ });
516
+ var unrun = outs.filter(function (ro) {
517
+ return ro[1] === "unknown";
518
+ }).length;
519
+ var short = shortId(id);
520
+ var next = nextLevel(sc, r.level);
521
+ var need = next ? blockers(sc, r, next) : [];
522
+ var later = failing.length - need.length;
523
+ var d = el(
524
+ "details",
525
+ { className: "ent" },
526
+ el(
527
+ "summary",
528
+ {},
529
+ r.level === "skipped" ? badge(r.level) : levelPill(r.level, unassessedIn(D, active, id), unrunIn(sc, r), !unassessedIn(D, active, id)),
530
+ el("span", { className: "name" }, short.replace(/[^\s\-/]+$/, ""), el("span", { className: (/[^\s\-/]{25,}$/.test(short) ? "tail long" : "tail") }, (/[^\s\-/]+$/.exec(short) || [""])[0], el("span", { className: "chev", textContent: "›" })), short !== id ? el("small", { textContent: id, title: id }) : null),
531
+ r.level === "skipped"
532
+ ? el("span", { className: "tally sub", textContent: "not rated: outside this scorecard's scope" })
533
+ : el(
534
+ "span",
535
+ { className: "tally" },
536
+ need.length
537
+ ? el(
538
+ "b",
539
+ { className: r.level === "none" ? "bad" : "" },
540
+ (KNOWN.indexOf(next) >= 0 ? next.charAt(0).toUpperCase() + next.slice(1) : levelName(next)) + " needs: ",
541
+ ...need.slice(0, 2).map(function (n, i) {
542
+ return el("span", { className: "nr" }, ...keepWithLast(ruleTitle(active, n), basisBadge(basisOf((sc.rules || {})[n]), true)), i < Math.min(need.length, 2) - 1 ? ", " : "");
543
+ }),
544
+ need.length > 2 ? " +" + (need.length - 2) : "",
545
+ )
546
+ : failing.length
547
+ ? ""
548
+ : "✓ all pass",
549
+ later > 0 ? (need.length ? " · " : "") + later + " more for higher levels" : "",
550
+ " · " + passing.length + " of " + outs.length + " pass",
551
+ unrun ? el("span", { className: "provisional" }, " · " + unrun + " not run") : "",
552
+ ),
553
+ ),
554
+ );
555
+ var bodyBuilt = false;
556
+ d.addEventListener("toggle", function () {
557
+ if (!d.open || bodyBuilt) return;
558
+ bodyBuilt = true;
559
+ d.append(
560
+ el(
561
+ "div",
562
+ { className: "ent-body" },
563
+ self.nextStep(sc, r),
564
+ self.rulesFor(sc, r, active, unassessedIn(D, active, id), id),
565
+ el("p", { style: "margin:12px 0 0" }, link("entity/" + enc(id), "", "Open " + short + " across every scorecard →")),
566
+ ),
567
+ );
568
+ });
569
+ return d;
570
+ };
571
+ var rowsShown = 0;
572
+ var entsShown = 0;
573
+ groups.forEach(function (g) {
574
+ if (rowsShown >= limit) return;
575
+ if (g.length < 3) {
576
+ g.forEach(function (pair) {
577
+ if (rowsShown >= limit) return;
578
+ list.append(entRow(pair));
579
+ rowsShown++;
580
+ entsShown++;
581
+ });
582
+ return;
583
+ }
584
+ rowsShown++;
585
+ entsShown += g.length;
586
+ var first = entRow(g[0]).querySelector("summary") as HTMLElement;
587
+ var grp = el(
588
+ "details",
589
+ { className: "ent ent-group" },
590
+ el(
591
+ "summary",
592
+ {},
593
+ first.children[0],
594
+ el("span", { className: "name" }, kindCount(D, sc.kind, g.length) + " at " + (g[0][1].level === "none" ? "none" : g[0][1].level), el("span", { className: "tail" }, el("span", { className: "chev", textContent: "›" })), worstOf(g) ? el("small", { textContent: "one of them: " + worstOf(g) }) : null),
595
+ first.children[2],
596
+ ),
597
+ );
598
+ var built = false;
599
+ grp.addEventListener("toggle", function () {
600
+ if (!grp.open || built) return;
601
+ built = true;
602
+ grp.append(el("div", { className: "ent-members" }, ...g.map(entRow)));
603
+ });
604
+ list.append(
605
+ grp,
606
+ memberLinks(g.map(function (pair) {
607
+ return pair[0];
608
+ })),
609
+ );
610
+ });
611
+ if (entsShown < shown.length) {
612
+ list.append(
613
+ el(
614
+ "div",
615
+ { className: "more" },
616
+ el("button", {
617
+ className: "link",
618
+ textContent: "Show all " + fmt(shown.length) + " (" + fmt(shown.length - entsShown) + " more)",
619
+ onclick: function () {
620
+ limit = Infinity;
621
+ draw();
622
+ },
623
+ }),
624
+ ),
625
+ );
626
+ }
627
+ };
628
+ search.oninput = draw;
629
+ redrawFilters();
630
+ draw();
631
+
632
+ var scored = rows.filter(function (pair) {
633
+ return pair[1].level !== "skipped";
634
+ });
635
+ var failCounts: Record<string, number> = {};
636
+ var unrunCounts = {};
637
+ var provisionalN = 0;
638
+ scored.forEach(function (pair) {
639
+ Object.entries(pair[1].rules || {}).forEach(function (ro) {
640
+ if (isFailing(ro[1])) failCounts[ro[0]] = (failCounts[ro[0]] || 0) + 1;
641
+ else if (ro[1] === "unknown") unrunCounts[ro[0]] = (unrunCounts[ro[0]] || 0) + 1;
642
+ });
643
+ if (unrunIn(sc, pair[1]).length) provisionalN++;
644
+ });
645
+ var unrunNames = Object.keys(unrunCounts).sort();
646
+ var unrunNote = unrunNames.length
647
+ ? el(
648
+ "p",
649
+ { className: "sub unrun-note" },
650
+ el("b", { className: "provisional", textContent: "Not run in this build: " }),
651
+ ...unrunNames.map(function (n, i) {
652
+ return el("span", { className: "nr" }, i ? ", " : "", ruleLink(active, n), " ", basisBadge(basisOf((sc.rules || {})[n]), "tip"), " (" + unrunCounts[n] + " of " + scored.length + ")");
653
+ }),
654
+ ". A check that was not run is neither a pass nor a failure, so it is left out of the bars above and of which rule to fix first. Levels that need one are provisional: they hold only if it passes.",
655
+ )
656
+ : null;
657
+ var provisionalNote = provisionalN
658
+ ? el("p", { className: "sub", style: "margin:6px 0 0" }, el("b", { className: "provisional", textContent: "Provisional: " }), plural(provisionalN, "entity's level rests", "entities' levels rest") + " on checks not run in this build (drawn dotted in the bar above and the list below). ", el("span", { textContent: "They hold only if those checks pass." }))
659
+ : null;
660
+ // The rule that holds the most entities at the lowest occupied level below the top.
661
+ var lever: HTMLElement | null = null;
662
+ var leverRule: string | null = null;
663
+ var low = order.find(function (l) {
664
+ return l !== "skipped" && nextLevel(sc, l) && parts.some(function (p) {
665
+ return p.level === l;
666
+ });
667
+ });
668
+ if (low) {
669
+ var held: Record<string, number> = {};
670
+ var up = nextLevel(sc, low);
671
+ scored.forEach(function (pair) {
672
+ if (pair[1].level !== low) return;
673
+ blockers(sc, pair[1], up).forEach(function (n) {
674
+ held[n] = (held[n] || 0) + 1;
675
+ });
676
+ });
677
+ var best = Object.entries(held).sort(function (a, b) {
678
+ return b[1] - a[1] || a[0].localeCompare(b[0]);
679
+ })[0];
680
+ if (best) leverRule = best[0];
681
+ var close = scored.filter(function (pair) {
682
+ var nx = pair[1].level !== "skipped" && nextLevel(sc, pair[1].level);
683
+ return nx && blockers(sc, pair[1], nx).length === 1;
684
+ }).length;
685
+ if (best)
686
+ lever = el(
687
+ "div",
688
+ { className: "next", style: "margin:0 0 10px" },
689
+ el("b", { textContent: "Biggest lever" }),
690
+ el("span", { className: "sub", textContent: " (the rule that lifts the most entities a level)" }),
691
+ el("br"),
692
+ ruleLink(active, best[0]),
693
+ " ",
694
+ basisBadge(basisOf((sc.rules || {})[best[0]])),
695
+ " keeps " + plural(best[1], "entity", "entities") + " at " + low + "; they need it for " + up + ". ",
696
+ ...rich(((sc.rules || {})[best[0]] || {}).fix),
697
+ close ? el("span", { className: "close-note" }, el("br"), el("b", { textContent: "Within reach: " }), plural(close, "entity is", "entities are") + " one rule from " + (close === 1 ? "its" : "their") + " next level.") : null,
698
+ );
699
+ }
700
+ var topFails = Object.entries(failCounts)
701
+ .sort(function (a, b) {
702
+ return b[1] - a[1] || a[0].localeCompare(b[0]);
703
+ })
704
+ .slice(0, 5);
705
+ var failChart = topFails.length
706
+ ? el(
707
+ "div",
708
+ { className: "fails" },
709
+ ...topFails.map(function (f) {
710
+ var rl = ((sc.rules || {})[f[0]] || {}).level;
711
+ var share = Math.round((f[1] / scored.length) * 100);
712
+ var fillSpan = el("span", { style: "flex-grow:0;background:var(--fail)" });
713
+ grow([fillSpan], [share]);
714
+ var b = el(
715
+ "button",
716
+ {
717
+ className: "fail-row",
718
+ title: ((sc.rules || {})[f[0]] || {}).fix || "",
719
+ onclick: function () {
720
+ search.value = "";
721
+ levelFilter = "all";
722
+ if (outcomeFilter === "passing") outcomeFilter = "all";
723
+ ruleFilter = f[0];
724
+ limit = 25;
725
+ redrawFilters();
726
+ draw();
727
+ filters.scrollIntoView({ block: "start", behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth" });
728
+ var chip = filters.querySelector<HTMLElement>(".chip-filter");
729
+ if (chip) chip.focus({ preventScroll: true });
730
+ },
731
+ },
732
+ el("span", { className: "rn" }, el("span", { textContent: ruleTitle(active, f[0]) }), basisBadge(basisOf((sc.rules || {})[f[0]]), false, true), rl ? badge(rl) : null, lever && f[0] === leverRule ? el("span", { className: "pill", title: "Fixing it lifts the most entities a level", textContent: "fix first" }) : null),
733
+ el("span", { className: "bar xs" }, fillSpan, el("span", { style: "flex-grow:" + (100 - share) + ";background:transparent" })),
734
+ el("span", { className: "fc" }, f[1] + " of " + scored.length, el("span", { className: "sr", textContent: " fail it. Show them." })),
735
+ );
736
+ return b;
737
+ }),
738
+ )
739
+ : !scored.length
740
+ ? el("p", { className: "empty", textContent: "No entity is scored yet, so no rule has failed or passed." })
741
+ : el("p", { className: "empty good", textContent: unrunNames.length ? "✓ No rule fails on any entity; some checks were not run." : "✓ No rule fails on any entity." });
742
+
743
+ var needs = el("div", { className: "levels-need" });
744
+ (sc.levels || []).forEach(function (l) {
745
+ var names = Object.keys(sc.rules || {})
746
+ .filter(function (n) {
747
+ return sc.rules[n].level === l;
748
+ })
749
+ .sort();
750
+ var bases = names.map(function (n) {
751
+ return basisOf(sc.rules[n]);
752
+ });
753
+ var shared = bases.length && bases.every(function (b) {
754
+ return b === bases[0];
755
+ })
756
+ ? bases[0]
757
+ : null;
758
+ needs.append(
759
+ el(
760
+ "div",
761
+ { className: "need" },
762
+ el("div", { className: "need-head" }, badge(l), shared ? el("span", { className: "need-basis" }, names.length > 1 ? "All " + names.length + " rules" : "1 rule", basisBadge(shared, "tip")) : null),
763
+ names.length
764
+ ? el(
765
+ "ul",
766
+ {},
767
+ ...names.map(function (n) {
768
+ var rd = sc.rules[n];
769
+ return el("li", {}, el("span", { style: "display:inline-flex;flex-wrap:wrap;gap:4px 6px;align-items:center" }, el("b", {}, ruleLink(active, n, null, true)), shared ? null : basisBadge(basisOf(rd), "tip")), rd.rationale || rd.fix ? whyFirst(rd.rationale || rd.fix) : null, refs(rd.links));
770
+ }),
771
+ )
772
+ : el("div", { className: "sub", textContent: "No rules at this level." }),
773
+ ),
774
+ );
775
+ });
776
+ // Reasons are clamped to three lines so the levels read side by side; the full text stays in the
777
+ // accessibility tree and one toggle opens them all.
778
+ needs.classList.add("clamped");
779
+ var needsToggle = el("button", {
780
+ className: "link need-toggle",
781
+ textContent: "Show full reasons, with thresholds and sources",
782
+ ariaExpanded: "false",
783
+ onclick: function () {
784
+ var open = needs.classList.toggle("clamped") === false;
785
+ needsToggle.textContent = open ? "Show shorter reasons" : "Show full reasons, with thresholds and sources";
786
+ needsToggle.setAttribute("aria-expanded", String(open));
787
+ },
788
+ });
789
+ var picker = el(
790
+ "select",
791
+ {
792
+ ariaLabel: "Scorecard",
793
+ onchange: function () {
794
+ location.hash = "scorecard/" + enc(picker.value);
795
+ },
796
+ },
797
+ ...[false, true]
798
+ .map(function (cmp) {
799
+ var group = ranked.filter(function (r) {
800
+ return !!r.compare === cmp;
801
+ });
802
+ if (!group.length) return null;
803
+ return el(
804
+ "optgroup",
805
+ { label: cmp ? plural(group.length, "comparison factor") : plural(group.length, "scorecard") },
806
+ ...group.map(function (r) {
807
+ var c = cmp ? (D.comparisons || {})[r.name] || {} : null;
808
+ var debt = c ? (c.verdict || {})[(c.peers || [])[0]] || "not measured" : r.none > 0 ? r.none + " at none" : r.bronze > 0 ? r.bronze + " at bronze" : r.scored && r.topShare === 100 ? "top level" : r.scored ? "clear" : "not scored";
809
+ return el("option", { value: r.name, selected: r.name === active, textContent: title(D, r.name) + " (" + debt + ")" });
810
+ }),
811
+ );
812
+ })
813
+ .filter(Boolean),
814
+ );
815
+ var owner = sc.owner ? sc.owner.replace(/^group:/, "") : "";
816
+ var hStand = el("h3", { textContent: "What holds it where it is", tabIndex: -1 });
817
+ var hFail = el("h3", { textContent: scored.length ? "Most common failures, at any level" : "Nothing has failed or passed", tabIndex: -1 });
818
+ var hNeeds = el("h3", { textContent: "What each level needs (each level also needs the ones below)", tabIndex: -1 });
819
+ var hList = el("h3", { textContent: "Entities", tabIndex: -1 });
820
+ var jump = function (label, target) {
821
+ return el("button", {
822
+ className: "link",
823
+ textContent: label,
824
+ onclick: function () {
825
+ target.scrollIntoView({ block: "start", behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth" });
826
+ target.focus({ preventScroll: true });
827
+ },
828
+ });
829
+ };
830
+ var standNotes = [unassessedNote(D, active, scored.length), provisionalNote, lever ? el("div", { style: "margin-top:12px" }, lever) : null].filter(Boolean);
831
+ var jumpBar = el("nav", { className: "jumpbar", ariaLabel: "On this page" }, el("span", { className: "sub", textContent: "On this page:" }), standNotes.length ? jump("What holds it", hStand) : null, jump(scored.length ? "Failures" : "Results", hFail), jump("Filter entities (" + fmt(scored.length) + ")", hList), jump("What each level needs", hNeeds));
832
+ var floorHere = floorOf(D, active);
833
+ var topHere = order.filter(function (l) {
834
+ return l !== "skipped" && l !== "none";
835
+ }).pop();
836
+ var atTop = scored.filter(function (pair) {
837
+ return pair[1].level === topHere;
838
+ }).length;
839
+ var split = splitUnassessed(D, active, parts);
840
+ var statusLegend = legendEl(parts);
841
+ if (split.some(function (p) { return p.hollow; })) statusLegend.append(el("span", {}, el("span", { className: "dot hatch", style: "--seg:" + fill("bronze") }), "hatched: not assessed"));
842
+ if (split.some(function (p) { return p.unrun; })) statusLegend.append(el("span", {}, el("span", { className: "dot dots", style: "--seg:" + fill("silver") }), "◌ dotted: provisional, checks not run"));
843
+ var status = el(
844
+ "div",
845
+ { className: "sc-status" },
846
+ medal(floorHere || (scored.length ? "none" : "not scored"), 44),
847
+ el(
848
+ "div",
849
+ { className: "sc-status-b" },
850
+ el(
851
+ "div",
852
+ { className: "sc-status-t" },
853
+ el("span", { className: "sub", textContent: scored.length ? "Lowest level " : "" }),
854
+ floorHere ? floorPill(D, active) : el("b", { textContent: scored.length ? "not scored" : "No entities collected yet" }),
855
+ floorHere && isTop(D, active, floorHere) && !ONLY_LEVEL.has(floorHere) ? el("span", { className: "topmark", textContent: " ✓ top level" }) : null,
856
+ topHere && scored.length ? el("span", { className: "sep", ariaHidden: "true", textContent: "·" }) : null,
857
+ topHere && scored.length ? el("span", { className: "fact", textContent: fmt(atTop) + " of " + fmt(scored.length) + " at the top level (" + levelName(topHere) + ")" }) : null,
858
+ leverRule ? el("span", { className: "sep", ariaHidden: "true", textContent: "·" }) : null,
859
+ leverRule ? el("span", { className: "fact" }, "fix first: ", el("button", { className: "link", textContent: ruleTitle(active, leverRule), onclick: function () {
860
+ hStand.scrollIntoView({ block: "start", behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth" });
861
+ hStand.focus({ preventScroll: true });
862
+ } })) : null,
863
+ ),
864
+ barEl(split, "lg"),
865
+ statusLegend,
866
+ ),
867
+ );
868
+ var whyEl: HTMLElement | null = null;
869
+ if (sc.rationale || (sc.links || []).length) {
870
+ var whyText = sc.rationale ? el("div", { className: "why-text" }, ...richCards(D, sc.rationale, active)) : null;
871
+ var long = String(sc.rationale || "").length > 260;
872
+ if (long && whyText) whyText.classList.add("clamped");
873
+ whyEl = el(
874
+ "div",
875
+ { className: "rationale" },
876
+ el("b", { textContent: "Why this scorecard" }),
877
+ whyText,
878
+ long
879
+ ? el("button", {
880
+ className: "link why-more",
881
+ textContent: "Read the full why",
882
+ ariaExpanded: "false",
883
+ onclick: function (e) {
884
+ var open = (whyText as HTMLElement).classList.toggle("clamped") === false;
885
+ e.currentTarget.textContent = open ? "Show less" : "Read the full why";
886
+ e.currentTarget.setAttribute("aria-expanded", String(open));
887
+ },
888
+ })
889
+ : null,
890
+ refs(sc.links),
891
+ );
892
+ }
893
+ var anyJudged = ranked.some(function (r) {
894
+ return basisCounts(((D.scorecards || {})[r.name] || {}).rules).judged;
895
+ });
896
+ return el(
897
+ "div",
898
+ { className: "split" },
899
+ el(
900
+ "section",
901
+ {},
902
+ el("div", { className: "head" }, el("h2", { textContent: "Scorecards" })),
903
+ el("p", { className: "sub", style: "margin:0" }, ranked.some(function (r) {
904
+ return r.scored;
905
+ }) ? "Most entities at none first" : "Nothing is scored yet", anyJudged ? el("span", {}, " · ", el("span", { className: "bicon judged" }, basisIcon("judged")), " has agent-judged rules · ", el("span", { className: "bicon" }, basisIcon("measured")), " tool checks only") : null),
906
+ cardSearch,
907
+ toTop,
908
+ cardNav,
909
+ ),
910
+ el(
911
+ "section",
912
+ { className: basisCounts(sc.rules).judged || !basisCounts(sc.rules).measured ? "" : "allmeasured" },
913
+ el("nav", { className: "crumb", ariaLabel: "Breadcrumb" }, link("scorecards", "", "Scorecards"), " / " + title(D, active)),
914
+ el("label", { className: "picker" }, el("span", { className: "sub", textContent: "Scorecard" }), picker),
915
+ el("div", { className: "head" }, el("h2", { textContent: title(D, active) }), el("code", { className: "sub", textContent: active })),
916
+ status,
917
+ jumpBar,
918
+ el("p", { className: "lede" }, ...richCards(D, sc.description, active)),
919
+ whyEl,
920
+ el(
921
+ "div",
922
+ { className: "sub" },
923
+ "Rates every " + kindTitle(D, sc.kind).replace(/^[A-Z](?=[a-z]|$)/, function (c) {
924
+ return c.toLowerCase();
925
+ }) + (owner ? " · owned by " + owner : ""),
926
+ sc.track ? el("span", {}, " · track ", link(trackPath(D, sc.track), "", trackTitle(D, sc.track))) : null,
927
+ basisInline(basisCounts(sc.rules)),
928
+ ),
929
+ isComparative(D, active) ? el("div", { className: "callout" }, el("span", {}, "This scorecard compares products rather than levelling them. ", link("compare/" + enc(active), "", "See how they stand →"))) : null,
930
+ basisInline(basisCounts(sc.rules)) ? null : basisKey(basisCounts(sc.rules)),
931
+ standNotes.length ? hStand : null,
932
+ ...standNotes,
933
+ hFail,
934
+ failChart && rows.length ? el("p", { className: "sub", style: "margin:0 0 6px", textContent: "Each bar is the share of entities failing the rule; the pill beside it names the level the rule is needed for." }) : null,
935
+ failChart,
936
+ unrunNote,
937
+ hList,
938
+ rows.length ? filters : null,
939
+ rows.length ? search : null,
940
+ list,
941
+ hNeeds,
942
+ needsToggle,
943
+ needs,
944
+ ),
945
+ );
946
+ },
947
+ } satisfies ThisType<ReportViews>;