---
import data from '../../data/research.json';
import { t, type Lang } from '../../i18n/ui';
import type { ChladniParams } from '../../scripts/chladni';
interface Props { lang: Lang }
const { lang } = Astro.props;
const ui = t(lang);
const r = ui.team.research;
/* Papers from both founders' Google Scholar profiles, deduplicated (src/data/research.json).
Rendered most cited first, so the page reads right without script; the script below re-sorts,
filters and folds the list. Entries marked display: false stay in the data only. */
const papers = data.papers.filter((p) => p.display && p.href);
const categories = data.categories.filter((c) => papers.some((p) => p.categories.includes(c)));
const countIn = (c: string) => papers.filter((p) => p.categories.includes(c)).length;
const INITIAL = 9;
const labels = { showAll: r.showAll(papers.length), showAllTpl: r.showAll(999).replace('999', '{n}'), showFewer: r.showFewer, count: r.count(111, 999).replace('111', '{shown}').replace('999', '{total}') };
/* Every paper carries its own figure (Chladni parameters for src/scripts/chladni.ts) and colour
field (three tokens and their positions) in research.json, generated per paper by
scripts/research-figures.py. They travel with the paper, so sorting and filtering never move them. */
const figure = (paper: (typeof papers)[number]) => ({ quality: 121, ...paper.figure }) as ChladniParams;
const fieldStyle = (paper: (typeof papers)[number]) =>
paper.field.colors.map((c, k) => `--c${k + 1}: var(--${c}); --ax${k + 1}: ${paper.field.positions[k][0]}%; --ay${k + 1}: ${paper.field.positions[k][1]}%;`).join(' ');
---