import * as os from 'node:os';
import constants from './constants.js';
const { ANSI_CODES } = constants;
export default class OutputManager {
    static _EOL_STR = os.EOL;
    static commandText;
    static lastSentBlankLine = false;
    static taskText;
    static bold(text) {
        return `${ANSI_CODES.BOLD}${text}${ANSI_CODES.RESET}`;
    }
    static detail(message, newline = true) {
        return this.info(ANSI_CODES.DIM + message + ANSI_CODES.RESET, newline);
    }
    static error(message, err) {
        console.error(`${ANSI_CODES.RED}${message}${ANSI_CODES.RESET}`);
        if (err && process.env.DEBUG) {
            console.error("Details:", err);
        }
        this.lastSentBlankLine = false;
    }
    static info(message, newline = true) {
        // newline=false lets progress be represented as series of dots on same line
        process.stdout.write(message + (newline ? this._EOL_STR : ""));
        this.lastSentBlankLine = false;
    }
    static newline(stream = process.stdout) {
        if (this.lastSentBlankLine) {
            return;
        }
        stream.write(this._EOL_STR);
        this.lastSentBlankLine = true;
    }
    static outputDivider(text) {
        const width = process.stdout.columns || 80;
        const padding = Math.max(0, Math.floor((width - text.length - 2) / 2));
        const paddingStr = "=".repeat(padding);
        const line = `${paddingStr} ${text} ${paddingStr}`;
        this.info(ANSI_CODES.GREEN + line + ANSI_CODES.RESET);
    }
    static warn(message) {
        console.warn(message);
        this.lastSentBlankLine = false;
    }
}
