/* ═══════════════════════════════════════════════════════
RECON // Curated Lists Controller (flattened)
═══════════════════════════════════════════════════════ */
(function () {
'use strict';
const API = '/api/awesomelist';
const root = document.getElementById('awesomelistRoot');
if (!root) return;
let state = { view: 'index', sectors: [], searchTimeout: null };
// ─── Utilities ───────────────────────────────────────
function esc(s) {
const d = document.createElement('div');
d.textContent = s || '';
return d.innerHTML;
}
function md(s) {
if (!s) return '';
let h = esc(s);
h = h.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1');
h = h.replace(/\*\*([^*]+)\*\*/g, '$1');
h = h.replace(/\*([^*]+)\*/g, '$1');
h = h.replace(/`([^`]+)`/g, '$1');
return h;
}
function fmt(n) {
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
// ─── API Fetch ───────────────────────────────────────
async function api(endpoint) {
const res = await fetch(API + endpoint);
if (!res.ok) throw new Error(`API ${res.status}`);
return res.json();
}
// ─── Render: Index View ──────────────────────────────
function renderIndex(data) {
state.view = 'index';
state.sectors = data.sectors || [];
let html = '';
// Stats bar
html += `