// Admin shell: sidebar + command palette + sparkline/bar chart primitives + shared styles const adminStyles = { mono: { fontFamily: "'JetBrains Mono', monospace" }, monoLabel: { fontFamily: "'JetBrains Mono', monospace", fontSize: 9, letterSpacing: '0.22em', color: '#565656' }, }; // Sparkline SVG const Sparkline = ({ data, width = 120, height = 32, color = '#10B981', fill = true }) => { const max = Math.max(...data); const min = Math.min(...data); const range = max - min || 1; const pts = data.map((v, i) => [ (i / (data.length - 1)) * width, height - ((v - min) / range) * (height - 2) - 1, ]); const line = pts.map(([x, y], i) => `${i === 0 ? 'M' : 'L'}${x.toFixed(1)},${y.toFixed(1)}`).join(' '); const area = `${line} L${width},${height} L0,${height} Z`; return ( {fill && } ); }; const Bars = ({ data, width = 260, height = 56, color = '#10B981', highlight = -1 }) => { const max = Math.max(...data); const gap = 1; const bw = (width - gap * (data.length - 1)) / data.length; return ( {data.map((v, i) => { const h = (v / max) * (height - 2); return ; })} ); }; // STATUS DOT const StatusDot = ({ status }) => { const color = status === 'ok' ? '#10B981' : status === 'warn' ? '#F59E0B' : status === 'err' ? '#DC2626' : '#565656'; return ; }; // SIDEBAR const AdminSidebar = ({ current, onNav, collapsed, onToggle, onOpenPalette }) => { const items = [ { id: 'dashboard', label: 'Dashboard', icon: }, { id: 'domains', label: 'Domains', icon: }, { id: 'keys', label: 'Keys', icon: }, { id: 'firehose', label: 'Firehose', icon: , live: true }, { id: 'abuse', label: 'Abuse', icon: }, { id: 'health', label: 'System', icon: }, { id: 'audit', label: 'Audit log', icon: }, { id: 'settings', label: 'Settings', icon: }, ]; const w = collapsed ? 52 : 208; return (
A
{!collapsed &&
ADMIN·CTL
}
{!collapsed && ( )}
{items.map((it) => ( ))}
); }; // COMMAND PALETTE const CommandPalette = ({ open, onClose, onRun }) => { const [q, setQ] = React.useState(''); const inputRef = React.useRef(null); React.useEffect(() => { if (open) { setQ(''); setTimeout(() => inputRef.current?.focus(), 20); } }, [open]); if (!open) return null; const cmds = [ { id: 'nav:dashboard', label: 'Go to Dashboard', kind: 'nav', hotkey: 'G D' }, { id: 'nav:domains', label: 'Go to Domains', kind: 'nav', hotkey: 'G O' }, { id: 'nav:keys', label: 'Go to Keys', kind: 'nav', hotkey: 'G K' }, { id: 'nav:firehose', label: 'Go to Firehose', kind: 'nav', hotkey: 'G F' }, { id: 'nav:abuse', label: 'Go to Abuse', kind: 'nav' }, { id: 'nav:health', label: 'Go to System health', kind: 'nav' }, { id: 'nav:audit', label: 'Go to Audit log', kind: 'nav' }, { id: 'nav:settings', label: 'Go to Settings', kind: 'nav' }, { id: 'act:newkey', label: 'Generate new access key', kind: 'action', hotkey: 'N K' }, { id: 'act:adddomain', label: 'Add shared domain', kind: 'action', hotkey: 'N D' }, { id: 'act:blocksender', label: 'Block sender pattern', kind: 'action' }, { id: 'act:pause', label: 'Pause / resume firehose', kind: 'action' }, { id: 'act:export', label: 'Export keys as CSV', kind: 'action' }, { id: 'act:signout', label: 'Sign out admin session', kind: 'action' }, ]; const filtered = q ? cmds.filter(c => c.label.toLowerCase().includes(q.toLowerCase())) : cmds; return ( <>
setQ(e.target.value)} placeholder="Type a command or search…" style={{ flex: 1, background: 'none', border: 'none', outline: 'none', color: '#EDEDED', fontFamily: "'Geist', system-ui, sans-serif", fontSize: 15 }} /> ESC
{filtered.length === 0 &&
No matches
} {filtered.map((c, i) => ( ))}
); }; // Shared page chrome const AdminPageHeader = ({ title, count, children }) => (

{title}

{count !== undefined && {count}}
{children}
); const AdminBtn = ({ children, onClick, variant = 'muted', danger, size = 'md' }) => { const pad = size === 'sm' ? '5px 10px' : '8px 12px'; const fs = size === 'sm' ? 11 : 12; const base = { padding: pad, borderRadius: 5, cursor: 'pointer', fontFamily: "'Geist', system-ui, sans-serif", fontSize: fs, display: 'inline-flex', alignItems: 'center', gap: 6, transition: 'background 100ms, border-color 100ms' }; const styles = { primary: { ...base, background: '#F59E0B', color: '#0A0A0A', border: 'none', fontWeight: 600 }, primaryGreen: { ...base, background: '#10B981', color: '#0A0A0A', border: 'none', fontWeight: 600 }, muted: { ...base, background: 'transparent', color: danger ? '#DC2626' : '#EDEDED', border: `1px solid ${danger ? '#3a1414' : '#262626'}` }, ghost: { ...base, background: 'transparent', color: '#8A8A8A', border: 'none' }, }; return ; }; // Admin icons (not in main set) const IconGrid = (p) => ; const IconGlobe = (p) => ; const IconKey = (p) => ; const IconActivity = (p) => ; const IconShield = (p) => ; const IconServer = (p) => ; const IconScroll = (p) => ; const IconPause = (p) => ; const IconPlay = (p) => ; const IconDownload = (p) => ; const IconEye = (p) => ; const IconFilter = (p) => ; Object.assign(window, { Sparkline, Bars, StatusDot, AdminSidebar, CommandPalette, AdminPageHeader, AdminBtn, adminStyles, IconGrid, IconGlobe, IconKey, IconActivity, IconShield, IconServer, IconScroll, IconPause, IconPlay, IconDownload, IconEye, IconFilter });