"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var MockProvider_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MockProvider = void 0;
const common_1 = require("@nestjs/common");
let MockProvider = MockProvider_1 = class MockProvider {
    constructor() {
        this.logger = new common_1.Logger(MockProvider_1.name);
        this.sessions = new Map();
        this.mockSessionCounter = 0;
        this.mockStartTime = Date.now();
    }
    async connect(_router) {
        this.logger.log(`Mock: Connected to router ${_router.name}`);
        return true;
    }
    async disconnect(_router) {
        this.logger.log(`Mock: Disconnected from router ${_router.name}`);
    }
    async testConnection(router) {
        this.logger.log(`Mock: Testing connection to ${router.name}`);
        return {
            success: true,
            message: 'Mock connection successful',
            details: {
                platform: 'MockRouter',
                version: '1.0.0',
                uptime: Math.floor((Date.now() - this.mockStartTime) / 1000),
            },
        };
    }
    async createHotspotUser(_router, params) {
        this.mockSessionCounter++;
        const sessionId = `mock-session-${this.mockSessionCounter}-${Date.now()}`;
        const username = params.username || `user-${this.mockSessionCounter}`;
        const password = params.password || `pass-${Math.random().toString(36).slice(2, 10)}`;
        const entry = {
            sessionId,
            username,
            macAddress: params.macAddress || '00:00:00:00:00:00',
            ipAddress: params.ipAddress || `10.0.${Math.floor(Math.random() * 255)}.${Math.floor(Math.random() * 255)}`,
            startTime: new Date(),
            bytesIn: 0,
            bytesOut: 0,
        };
        this.sessions.set(sessionId, entry);
        this.logger.log(`Mock: Created hotspot user "${username}" with session ${sessionId}`);
        return { username, password, sessionId };
    }
    async removeHotspotUser(_router, username) {
        for (const [sessionId, entry] of this.sessions.entries()) {
            if (entry.username === username) {
                this.sessions.delete(sessionId);
                this.logger.log(`Mock: Removed hotspot user "${username}"`);
                return;
            }
        }
        this.logger.warn(`Mock: Hotspot user "${username}" not found`);
    }
    async disconnectUser(_router, sessionId) {
        if (this.sessions.has(sessionId)) {
            this.sessions.delete(sessionId);
            this.logger.log(`Mock: Disconnected session "${sessionId}"`);
        }
        else {
            this.logger.warn(`Mock: Session "${sessionId}" not found`);
        }
    }
    async getActiveSessions(_router) {
        const now = Date.now();
        const sessions = [];
        for (const entry of this.sessions.values()) {
            const uptime = Math.floor((now - entry.startTime.getTime()) / 1000);
            sessions.push({
                sessionId: entry.sessionId,
                username: entry.username,
                macAddress: entry.macAddress,
                ipAddress: entry.ipAddress,
                uptime,
                bytesIn: entry.bytesIn + Math.floor(Math.random() * 50000),
                bytesOut: entry.bytesOut + Math.floor(Math.random() * 200000),
                startTime: entry.startTime,
                idleTime: Math.floor(Math.random() * 120),
            });
        }
        return sessions;
    }
    async getRouterStatus(_router) {
        const uptime = Math.floor((Date.now() - this.mockStartTime) / 1000);
        const cpuUsage = 15 + Math.random() * 35;
        const memoryUsage = 30 + Math.random() * 40;
        return {
            isOnline: true,
            cpuUsage: parseFloat(cpuUsage.toFixed(1)),
            memoryUsage: parseFloat(memoryUsage.toFixed(1)),
            uptime,
            activeSessions: this.sessions.size,
            version: 'MockOS v1.0.0',
            model: 'MockRouter-X1000',
        };
    }
    async setBandwidthLimit(_router, username, uploadKbps, downloadKbps) {
        this.logger.log(`Mock: Set bandwidth for "${username}": ${uploadKbps}kbps up / ${downloadKbps}kbps down`);
    }
    async bindMacAddress(_router, macAddress, ipAddress) {
        this.logger.log(`Mock: Bound MAC ${macAddress} to IP ${ipAddress}`);
    }
    async removeMacBinding(_router, macAddress) {
        this.logger.log(`Mock: Removed MAC binding for ${macAddress}`);
    }
    async refreshSession(_router, sessionId, newExpiry) {
        if (newExpiry) {
            this.logger.log(`Mock: Refreshed session "${sessionId}" until ${newExpiry.toISOString()}`);
        }
        else {
            this.logger.log(`Mock: Refreshed session "${sessionId}"`);
        }
    }
};
exports.MockProvider = MockProvider;
exports.MockProvider = MockProvider = MockProvider_1 = __decorate([
    (0, common_1.Injectable)()
], MockProvider);
