import { nowIso } from '../fsx.js';
export function isZellijSelfHealResult(value) {
    if (!value || typeof value !== 'object' || Array.isArray(value))
        return false;
    const row = value;
    return row.schema === 'sks.zellij-self-heal.v1'
        && typeof row.ok === 'boolean'
        && typeof row.requested_by === 'string'
        && typeof row.strategy === 'string'
        && row.before !== null
        && typeof row.before === 'object'
        && row.after !== null
        && typeof row.after === 'object'
        && Array.isArray(row.blockers)
        && Array.isArray(row.warnings);
}
export function normalizeZellijSelfHealResult(value) {
    if (isZellijSelfHealResult(value)) {
        return {
            ...value,
            dry_run: value.dry_run === true,
            planned_mutations: Array.isArray(value.planned_mutations) ? value.planned_mutations : []
        };
    }
    return {
        schema: 'sks.zellij-self-heal.v1',
        ok: false,
        requested_by: 'setup',
        fix_requested: false,
        auto_approved: false,
        install_homebrew_allowed: false,
        dry_run: false,
        planned_mutations: [],
        before: { status: 'unknown', version: null, bin: null },
        latest_version: null,
        strategy: 'failed',
        command: null,
        after: { status: 'unknown', version: null, bin: null },
        mutation_guard_artifact: null,
        homebrew: { present: false, bin: null, install_attempted: false, install_allowed: false },
        blockers: ['invalid_zellij_self_heal_result'],
        warnings: [`normalized_at:${nowIso()}`]
    };
}
//# sourceMappingURL=zellij-self-heal-types.js.map