"use strict";
/**
 * Health Check Types and Interfaces
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSpinner = exports.HealthCheck = void 0;
const ui_1 = require("../../utils/ui");
/**
 * Health check results container
 */
class HealthCheck {
    constructor() {
        this.checks = [];
        this.warnings = [];
        this.errors = [];
        this.details = {};
    }
    addCheck(name, status, message = '', fix = undefined, details = undefined) {
        this.checks.push({ name, status, message, fix });
        if (status === 'error')
            this.errors.push({ name, message, fix });
        if (status === 'warning')
            this.warnings.push({ name, message, fix });
        // Store details for summary table
        if (details) {
            this.details[name] = details;
        }
    }
    hasErrors() {
        return this.errors.length > 0;
    }
    hasWarnings() {
        return this.warnings.length > 0;
    }
    isHealthy() {
        return !this.hasErrors();
    }
}
exports.HealthCheck = HealthCheck;
/**
 * Create ora spinner with fallback for environments where ora is unavailable
 */
function createSpinner() {
    try {
        const oraModule = require('ora');
        return oraModule.default || oraModule;
    }
    catch (_e) {
        // ora not available, create fallback spinner that uses console.log with UI colors
        return function (text) {
            return {
                start: () => ({
                    succeed: (msg) => console.log(msg || (0, ui_1.ok)(text)),
                    fail: (msg) => console.log(msg || (0, ui_1.fail)(text)),
                    warn: (msg) => console.log(msg || (0, ui_1.warn)(text)),
                    info: (msg) => console.log(msg || (0, ui_1.info)(text)),
                    text: '',
                }),
            };
        };
    }
}
exports.createSpinner = createSpinner;
//# sourceMappingURL=types.js.map