/** * Brain-5D Dashboard — Population Overview Visualization * * @version 1.0.0 * @license MIT */ "use strict"; const $ = (id) => document.getElementById(id); function formatNumber(value) { if (value === null || value === undefined) return '—'; return Number(value).toLocaleString(); } function formatFloat(value, decimals = 3) { if (value === null || value === undefined) return '—'; return Number(value).toFixed(decimals); } function escapeHtml(str) { if (!str) return ''; const div = document.createElement('div'); div.textContent = str; return div.innerHTML; } function setText(id, value) { const el = $(id); if (el) el.textContent = String(value); } export async function refreshPopulation() { try { const r = await fetch('/api/live/population', { cache: 'no-store' }); if (!r.ok) throw new Error(`HTTP ${r.status}`); const data = await r.json(); const badge = $('ei-ratio-badge'); if (badge) { const ratio = data.ei_ratio; if (typeof ratio === 'number') { badge.textContent = `E/I: ${ratio.toFixed(2)}`; badge.className = `gate-badge ${ratio > 0.5 && ratio < 3.0 ? 'passed' : 'stale'}`; } else { badge.textContent = 'E/I: unavailable'; badge.className = 'gate-badge pending'; } } const grid = $('population-grid'); if (!grid) return; if (!data.populations || data.populations.length === 0) { grid.innerHTML = '