import figlet from 'figlet';
export class Logger {
    _loggers;
    _callbacks;
    _logDir = 'chats';
    constructor(_loggers, _callbacks) {
        this._loggers = _loggers;
        this._callbacks = _callbacks;
    }
    async info(info) {
        await Promise.all(this._loggers.map(l => l.info(info)));
    }
    async notice(msg) {
        await Promise.all(this._loggers.map(l => l.notice(msg)));
    }
    async success(msg) {
        await Promise.all(this._loggers.map(l => l.success(msg)));
    }
    async warning(msg) {
        await Promise.all(this._loggers.map(l => l.warning(msg)));
    }
    async error(msg, error) {
        if (!error) {
            await Promise.all(this._loggers.map(l => {
                return l.error(msg);
            }));
            return;
        }
        let errorStr = '';
        const errorObj = error;
        if (typeof error === 'object' && errorObj.message) {
            if (errorObj.response) {
                const responseObj = errorObj.response;
                const status = responseObj.status || 'N/A';
                const data = responseObj.data || 'N/A';
                errorStr += `\nResponse Status: ${status}`;
                errorStr += `\nResponse Data: ${JSON.stringify(data, null, 2)}`;
            }
            errorStr += `\nMessage: ${errorObj.message}`;
        }
        await Promise.all(this._loggers.map(l => l.error(`${msg}${errorStr}`)));
    }
    async prompt(query) {
        return this._callbacks.promptUser(query);
    }
    async logHeader() {
        const logger = this;
        return new Promise((resolve, reject) => {
            figlet.text('Evo.Ninja', {
                font: 'Doom',
                horizontalLayout: 'default',
                verticalLayout: 'default',
                whitespaceBreak: true,
            }, async function (err, data) {
                if (err) {
                    await logger.error('Something went wrong...', err);
                    reject(err);
                    return;
                }
                resolve();
            });
        });
    }
}
