/**
 * Log level management and formatted console output.
 *
 * LogManager is a singleton that encapsulates the current log level state.
 * Module-level functions are provided as convenient facades.
 */
import chalk from 'chalk';
/** Log level priorities */
const LOG_PRIORITIES = {
    debug: 0,
    info: 1,
    warn: 2,
    error: 3,
};
/**
 * Manages console log output level and provides formatted logging.
 * Singleton — use LogManager.getInstance().
 */
export class LogManager {
    static instance = null;
    currentLogLevel = 'info';
    constructor() { }
    static getInstance() {
        if (!LogManager.instance) {
            LogManager.instance = new LogManager();
        }
        return LogManager.instance;
    }
    /** Reset singleton for testing */
    static resetInstance() {
        LogManager.instance = null;
    }
    /** Set log level */
    setLogLevel(level) {
        this.currentLogLevel = level;
    }
    /** Check if a log level should be shown */
    shouldLog(level) {
        return LOG_PRIORITIES[level] >= LOG_PRIORITIES[this.currentLogLevel];
    }
    /** Log a debug message */
    debug(message) {
        if (this.shouldLog('debug')) {
            console.log(chalk.gray(`[DEBUG] ${message}`));
        }
    }
    /** Log an info message */
    info(message) {
        if (this.shouldLog('info')) {
            console.log(chalk.blue(`[INFO] ${message}`));
        }
    }
    /** Log a warning message */
    warn(message) {
        if (this.shouldLog('warn')) {
            console.log(chalk.yellow(`[WARN] ${message}`));
        }
    }
    /** Log an error message */
    error(message) {
        if (this.shouldLog('error')) {
            console.log(chalk.red(`[ERROR] ${message}`));
        }
    }
    /** Log a success message */
    success(message) {
        console.log(chalk.green(message));
    }
}
export function setLogLevel(level) {
    LogManager.getInstance().setLogLevel(level);
}
export function blankLine() {
    console.log();
}
export function debug(message) {
    LogManager.getInstance().debug(message);
}
export function info(message) {
    LogManager.getInstance().info(message);
}
export function warn(message) {
    LogManager.getInstance().warn(message);
}
export function error(message) {
    LogManager.getInstance().error(message);
}
export function success(message) {
    LogManager.getInstance().success(message);
}
export function header(title) {
    console.log();
    console.log(chalk.bold.cyan(`=== ${title} ===`));
    console.log();
}
export function section(title) {
    console.log(chalk.bold(`\n${title}`));
}
export function status(label, value, color) {
    const colorFn = color ? chalk[color] : chalk.white;
    console.log(`${chalk.gray(label)}: ${colorFn(value)}`);
}
export function progressBar(current, total, width = 30) {
    const percentage = Math.floor((current / total) * 100);
    const filled = Math.floor((current / total) * width);
    const empty = width - filled;
    const bar = chalk.green('█'.repeat(filled)) + chalk.gray('░'.repeat(empty));
    return `[${bar}] ${percentage}%`;
}
export function list(items, bullet = '•') {
    for (const item of items) {
        console.log(chalk.gray(bullet) + ' ' + item);
    }
}
export function divider(char = '─', length = 40) {
    console.log(chalk.gray(char.repeat(length)));
}
export function truncate(text, maxLength) {
    if (text.length <= maxLength) {
        return text;
    }
    return text.slice(0, maxLength - 3) + '...';
}
//# sourceMappingURL=LogManager.js.map