/**
 * Web Control UI Dashboard
 *
 * Provides an HTTP-based admin dashboard for monitoring
 * agent status, sessions, channels, tools, and system health.
 */
import { logger } from '../utils/logger.js';
// ============================================================================
// Dashboard
// ============================================================================
export class Dashboard {
    static instance = null;
    config;
    running = false;
    startTime = 0;
    connectedClients = 0;
    constructor(config) {
        this.config = config || { port: 8080 };
    }
    static getInstance(config) {
        if (!Dashboard.instance) {
            Dashboard.instance = new Dashboard(config);
        }
        return Dashboard.instance;
    }
    static resetInstance() {
        Dashboard.instance = null;
    }
    start(port) {
        if (port !== undefined) {
            this.config.port = port;
        }
        logger.info(`Starting dashboard on port ${this.config.port || 8080}`);
        this.running = true;
        this.startTime = Date.now();
        this.connectedClients = 0;
    }
    stop() {
        logger.info('Stopping dashboard');
        this.running = false;
        this.startTime = 0;
        this.connectedClients = 0;
    }
    isRunning() {
        return this.running;
    }
    getPort() {
        return this.config.port || 8080;
    }
    getUrl() {
        return `http://localhost:${this.getPort()}`;
    }
    getStatus() {
        return {
            running: this.running,
            port: this.getPort(),
            uptime: this.running ? Math.floor((Date.now() - this.startTime) / 1000) : 0,
            connectedClients: this.connectedClients,
        };
    }
    generateDashboardHtml() {
        return `<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Code Buddy Dashboard</title>
</head>
<body>
  <h1>Code Buddy Admin Dashboard</h1>
  <section id="agent-status"><h2>Agent Status</h2></section>
  <section id="active-sessions"><h2>Active Sessions</h2></section>
  <section id="channel-status"><h2>Channel Status</h2></section>
  <section id="tool-usage"><h2>Tool Usage</h2></section>
  <section id="memory-stats"><h2>Memory Stats</h2></section>
  <section id="system-health"><h2>System Health</h2></section>
</body>
</html>`;
    }
    getMetrics() {
        return {
            agent: { status: 'idle', model: 'grok-3', mode: 'code' },
            sessions: 0,
            channels: ['telegram', 'discord', 'slack'],
            tools: 25,
            memory: { used: 0, total: 1024 },
            system: { cpuPercent: 0, memoryPercent: 0 },
        };
    }
    setConnectedClients(count) {
        this.connectedClients = count;
    }
}
//# sourceMappingURL=dashboard.js.map