/* ═══════════════════════════════════════════════════════ CONTRABAND // Resource Database Controller ═══════════════════════════════════════════════════════ */ (function () { 'use strict'; const API = '/api/contraband'; const root = document.getElementById('contrabandRoot'); if (!root) return; let state = { view: 'index', categories: [], searchTimeout: null }; // ─── Utilities ─────────────────────────────────────── function esc(s) { const d = document.createElement('div'); d.textContent = s || ''; return d.innerHTML; } 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.categories = data.categories || []; let html = ''; // Stats bar html += `
`; // Search html += `