---
import Base from '../../layouts/Base.astro';
import SectionBanner from '../../components/SectionBanner.astro';
import Icon from '../../components/Icon.astro';
import allTools from '../../data/tools.json';
import allTechniques from '../../data/techniques.json';
import { toolSlug, routeSourceOf, facetValues } from '../../lib/techniques';
import type { Tool, Technique, FacetKey } from '../../lib/techniques';
import { SOURCE_ROUTE, SOURCE_META, SOURCES, PLATFORM_META } from '../../lib/taxonomy';
import { totalFacetCounts } from '../../lib/render-row';
import { DECK_BREAKDOWN, buildBreakdown, renderBreakdown, facetLabel, ledger } from '../../lib/insights';
import { DECK_ALPHABET, deckLetter } from '../../lib/deck';
import { url } from '../../lib/url';
import type { SourceId } from '../../lib/taxonomy';
export async function getStaticPaths() {
const tools = allTools as unknown as Tool[];
const techs = allTechniques as unknown as Technique[];
return SOURCES.map((sourceId, i) => {
// Group by toolId namespace (deck), not per-technique source, so a
// daemon-authored WADComs addition lists under the WADComs deck.
const srcTools = tools.filter((t) => routeSourceOf(t.id) === sourceId).sort((a, b) => a.name.localeCompare(b.name, 'en', { sensitivity: 'base' }));
const srcTechs = techs.filter((t) => routeSourceOf(t.toolId) === sourceId);
return {
params: { source: SOURCE_ROUTE[sourceId] },
props: { sourceId, tools: srcTools, techs: srcTechs, n: String(i + 1).padStart(2, '0') },
};
});
}
interface Props { sourceId: SourceId; tools: Tool[]; techs: Technique[]; n: string }
const { sourceId, tools, techs, n } = Astro.props;
const src = SOURCE_META[sourceId];
const stats = [
{ label: 'Tools', value: tools.length, accent: true },
{ label: 'Techniques', value: techs.length },
{ label: 'License', value: src.license },
];
// What this deck is made of. The panel and the tag row are two views of the
// same facets, and both press the same filters.
const counts = totalFacetCounts(techs);
const breakdown = buildBreakdown(counts, DECK_BREAKDOWN);
const keys: FacetKey[] = [...breakdown.left.map((b) => b.key), 'capability'];
const tags = keys.flatMap((key) =>
Object.entries(counts[key] || {})
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
.map(([value, count]) => ({ key, value, count })),
);
// Each tool tile carries its techniques as short signatures: one character
// per facet value held, so the page can answer "does any one technique of
// this tool match every pressed filter" without shipping the dataset.
const vocab = tags.map((t) => `${t.key}\t${t.value}`);
if (vocab.length > DECK_ALPHABET.length) throw new Error(`${src.label}: ${vocab.length} facet values, the signature alphabet holds ${DECK_ALPHABET.length}`);
const code = new Map(vocab.map((v, i) => [v, DECK_ALPHABET[i]]));
const sigs = new Map<string, string[]>();
for (const t of techs) {
const sig = keys.flatMap((key) => facetValues(t, key).map((v) => code.get(`${key}\t${v}`) || '')).join('');
if (!sigs.has(t.toolId)) sigs.set(t.toolId, []);
sigs.get(t.toolId)!.push(sig || '-');
}
const letters = [...new Set(tools.map((t) => deckLetter(t.name)))];
const firstOf = new Map<string, string>();
for (const t of tools) if (!firstOf.has(deckLetter(t.name))) firstOf.set(deckLetter(t.name), t.id);
const AZ = ['#', ...'abcdefghijklmnopqrstuvwxyz'].filter((l) => l !== '#' || letters.includes('#'));
---
<Base title={`${src.label} — DÆMONBins`} description={`${src.label}: ${src.blurb}`}>
<SectionBanner n={n} label={src.tag} title={src.label} blurb={src.blurb} stats={stats} accent={src.accent} />
<div class="wrap src" data-deck data-vocab={JSON.stringify(vocab)} data-total={tools.length} style={`--acc: var(--${src.accent});`}>
<p class="src__lead">
<a href={url('catalog')} data-deck-catalog>← Full catalog</a>
<span aria-hidden="true"> · </span>
<a href={src.homepage} target="_blank" rel="noopener">{src.homepage.replace(/^https?:\/\//, '')}</a>
<span aria-hidden="true"> · </span>
<a href={src.repo} target="_blank" rel="noopener">source</a>
</p>
<div class="src__bar">
<div class="finder__row">
<label class="finder__box">
<Icon name="search" />
<span class="sr-only">Search {src.label} tools</span>
<input class="finder__input" data-deck-search type="search" placeholder="Search this collection" autocomplete="off" spellcheck="false" />
</label>
<button class="finder__clear" data-deck-clear type="button" hidden>Clear</button>
<span class="finder__shown" data-deck-shown role="status">{tools.length} shown</span>
</div>
<ul class="az" aria-label="Jump to a letter">
{AZ.map((l) => (
<li><a href={`#az-${l === '#' ? '0' : l}`} data-az={l} aria-disabled={letters.includes(l) ? undefined : 'true'} aria-label={l === '#' ? 'Tools starting with a digit or symbol' : `Tools starting with ${l.toUpperCase()}`}>{l}</a></li>
))}
</ul>
</div>
<ul class="tags src__tags" aria-label={`Filter ${src.label} by tag`}>
{tags.map((t) => (
<li><button class="tag" type="button" aria-pressed="false" data-facet={t.key} data-value={t.value}>{facetLabel(t.key, t.value)}<span class="tag__n">{ledger(t.count)}</span></button></li>
))}
</ul>
<section class="bd src__bd" aria-label={`What ${src.label} is made of`} set:html={renderBreakdown(breakdown, { mode: 'button', note: `Counted in techniques across ${tools.length} tools. Press a bar or a tag to keep only the tools that have one.` })} />
<div class="src__grid" data-deck-grid>
{tools.map((t) => (
<a
class="src__tool"
href={url(`${SOURCE_ROUTE[sourceId]}/${toolSlug(t.id)}`)}
id={firstOf.get(deckLetter(t.name)) === t.id ? `az-${deckLetter(t.name) === '#' ? '0' : deckLetter(t.name)}` : undefined}
data-letter={deckLetter(t.name)}
data-name={[t.name, ...(t.aliases || [])].join(' ').toLowerCase()}
data-sig={(sigs.get(t.id) || []).join(' ')}
>
<span class="src__tname">{t.name}</span>
<span class="src__tmeta">
<span class="src__tcount" title={`${t.count} technique${t.count === 1 ? '' : 's'}`}>{t.count}</span>
{t.platform?.map((p) => <span class="src__tplat">{PLATFORM_META[p]?.short || p}</span>)}
</span>
</a>
))}
</div>
<div class="src__empty" data-deck-empty hidden>
<p class="eyebrow"><span class="eyebrow__mark">^:</span><span>No matches</span></p>
<p>No {src.label} tool matches this search and these tags.</p>
<p><button class="finder__clear" data-deck-clear type="button">Clear search and tags</button> <a class="src__elsewhere" data-deck-elsewhere href={url('catalog')}>Try the full catalog →</a></p>
</div>
</div>
<script>import '../../scripts/deck';</script>
</Base>
<style>
.src { padding-block: 2.2rem 4rem; }
.src__lead { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; color: var(--fg-dim); margin: 0 0 1.2rem; }
.src__lead a, .src__elsewhere { color: var(--acc); text-decoration: none; }
.src__lead a:hover, .src__elsewhere:hover { text-decoration: underline; text-underline-offset: 3px; }
/* The search and the letter index ride under the masthead: in a deck of
hundreds of tools the two fastest ways to one of them stay in reach. */
.src__bar {
position: sticky; top: 63px; z-index: 20;
display: grid; gap: 0.6rem;
padding: 0.7rem 0; margin-bottom: 1rem;
background: var(--bg);
border-bottom: 1px solid var(--rule);
}
@media (max-width: 720px) {
.src__bar .az { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.src__bar .az a { min-width: 2.2rem; height: 2.2rem; }
}
.src__tags { margin-bottom: 1.4rem; }
.src__bd { margin-bottom: 1.6rem; }
.src__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.src__grid:not(:has(.src__tool:not([hidden]))) { display: none; }
.src__tool { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.7rem 0.9rem; background: var(--bg); text-decoration: none; color: var(--fg); scroll-margin-top: 11.5rem; }
.src__tool[hidden] { display: none; }
.src__tool:hover, .src__tool:focus-visible { background: var(--acc); color: var(--base); outline: none; }
.src__tool:hover .src__tcount, .src__tool:hover .src__tplat,
.src__tool:focus-visible .src__tcount, .src__tool:focus-visible .src__tplat { color: var(--base); border-color: color-mix(in srgb, var(--base) 40%, transparent); opacity: 0.85; }
.src__tname { font-family: var(--font-archivo); font-weight: 600; font-size: 14px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src__tmeta { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.src__tcount { font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); }
.src__tplat { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; color: var(--fg-faint); border: 1px solid var(--rule); padding: 0.05rem 0.25rem; }
.src__empty { border: 1px solid var(--rule); padding: 3rem 1.2rem; text-align: center; color: var(--fg-dim); }
.src__empty[hidden] { display: none; }
.src__empty .eyebrow { justify-content: center; }
.src__empty p { margin: 0.6rem 0; }
</style>