/* ============================================================
STREAM WITH LIEN — Setup, Music Bingo, Playlists
============================================================ */
/* ---------------- SETUP ---------------- */
function SetupPage({ d, ui, social }) {
const ref = useReveal();
return (
<>
{d.groups.map((g, gi) => (
{String(gi + 1).padStart(2, "0")}
{g.name}
{g.items.map((it, ii) => (
{it.t}
{it.d}
))}
))}
>
);
}
/* ---------------- MUSIC BINGO ---------------- */
function BingoCard({ d }) {
const FREE = 12; // center index in 5x5
const build = useCallback(() => {
const pool = [...d.cells];
for (let i = pool.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [pool[i], pool[j]] = [pool[j], pool[i]]; }
const picks = pool.slice(0, 24);
const grid = [];
let p = 0;
for (let i = 0; i < 25; i++) grid.push(i === FREE ? null : picks[p++]);
return grid;
}, [d]);
const [grid, setGrid] = useState(build);
const [marked, setMarked] = useState(() => new Set([FREE]));
const [bingo, setBingo] = useState(false);
useEffect(() => { setGrid(build()); setMarked(new Set([FREE])); setBingo(false); }, [build]);
const checkBingo = (set) => {
const lines = [];
for (let r = 0; r < 5; r++) lines.push([0,1,2,3,4].map(c => r*5+c));
for (let c = 0; c < 5; c++) lines.push([0,1,2,3,4].map(r => r*5+c));
lines.push([0,6,12,18,24]); lines.push([4,8,12,16,20]);
return lines.some(l => l.every(i => set.has(i)));
};
useEffect(() => { setBingo(checkBingo(marked)); }, [marked]);
const toggle = (i) => {
if (i === FREE) return;
setMarked(prev => {
const next = new Set(prev);
next.has(i) ? next.delete(i) : next.add(i);
return next;
});
};
const reset = () => { setGrid(build()); setMarked(new Set([FREE])); setBingo(false); };
return (
BI
NG
O
{grid.map((c, i) => (
))}
{bingo ? d.bingoMsg : ""}
{d.resetLabel}
);
}
function BingoPage({ d, ui, social }) {
const ref = useReveal();
return (
<>
{d.steps.map((s, i) => (
))}
{d.tryKicker}
{d.tryH}
{d.tryP}
{ui.watchLive}
>
);
}
/* ---------------- PLAYLISTS ---------------- */
function PlaylistsPage({ d, ui, social }) {
const ref = useReveal();
return (
<>
>
);
}
Object.assign(window, { SetupPage, BingoPage, PlaylistsPage });