/**
 * Session & Misc Enhancements
 * Per-session settings, update channels, and elevated mode management.
 */
import { logger } from './logger.js';
export class SessionPersistentSettings {
    static instance = null;
    sessions = new Map();
    static getInstance() {
        if (!SessionPersistentSettings.instance) {
            SessionPersistentSettings.instance = new SessionPersistentSettings();
        }
        return SessionPersistentSettings.instance;
    }
    static resetInstance() {
        SessionPersistentSettings.instance = null;
    }
    set(sessionId, key, value) {
        if (!this.sessions.has(sessionId)) {
            this.sessions.set(sessionId, new Map());
        }
        this.sessions.get(sessionId).set(key, value);
        logger.debug(`Session ${sessionId}: set ${key}`);
    }
    get(sessionId, key) {
        return this.sessions.get(sessionId)?.get(key);
    }
    getAll(sessionId) {
        const map = this.sessions.get(sessionId);
        if (!map)
            return {};
        const result = {};
        for (const [k, v] of map) {
            result[k] = v;
        }
        return result;
    }
    clear(sessionId) {
        this.sessions.delete(sessionId);
        logger.debug(`Session ${sessionId}: cleared`);
    }
}
export class UpdateChannelManager {
    static instance = null;
    channels = ['stable', 'beta', 'dev'];
    currentChannel = 'stable';
    static getInstance() {
        if (!UpdateChannelManager.instance) {
            UpdateChannelManager.instance = new UpdateChannelManager();
        }
        return UpdateChannelManager.instance;
    }
    static resetInstance() {
        UpdateChannelManager.instance = null;
    }
    getCurrentChannel() {
        return this.currentChannel;
    }
    setChannel(channel) {
        if (!this.isValidChannel(channel)) {
            throw new Error(`Invalid channel: ${channel}. Must be one of: ${this.channels.join(', ')}`);
        }
        this.currentChannel = channel;
        logger.debug(`Update channel set to: ${channel}`);
    }
    getLatestVersion(channel) {
        if (!this.isValidChannel(channel)) {
            throw new Error(`Invalid channel: ${channel}`);
        }
        // Stub implementation
        const versions = {
            stable: '1.0.0',
            beta: '1.1.0-beta.1',
            dev: '1.2.0-dev.1',
        };
        return {
            version: versions[channel] || '0.0.0',
            channel,
            date: new Date().toISOString(),
        };
    }
    isValidChannel(channel) {
        return this.channels.includes(channel);
    }
}
export class ElevatedModeManager {
    static instance = null;
    elevated = false;
    static getInstance() {
        if (!ElevatedModeManager.instance) {
            ElevatedModeManager.instance = new ElevatedModeManager();
        }
        return ElevatedModeManager.instance;
    }
    static resetInstance() {
        ElevatedModeManager.instance = null;
    }
    isElevated() {
        return this.elevated;
    }
    enable() {
        this.elevated = true;
        logger.debug('Elevated mode enabled');
    }
    disable() {
        this.elevated = false;
        logger.debug('Elevated mode disabled');
    }
    toggle() {
        this.elevated = !this.elevated;
        logger.debug(`Elevated mode toggled to: ${this.elevated}`);
        return this.elevated;
    }
    getWarning() {
        return 'WARNING: Elevated mode bypasses safety confirmations. Use with caution.';
    }
}
//# sourceMappingURL=session-enhancements.js.map