import { color, hux } from '@heroku/heroku-cli-util';
import { ux } from '@oclif/core/ux';
import { getGeneration } from '../apps/generation.js';
export function displayNat(nat) {
    if (!nat)
        return;
    if (nat.state !== 'enabled')
        return nat.state;
    return nat.sources.join(', ');
}
export function displayShieldState(space) {
    return space.shield ? 'on' : 'off';
}
export function renderInfo(space, json) {
    if (json) {
        ux.stdout(JSON.stringify(space, null, 2));
    }
    else {
        hux.styledHeader(color.space(space.name || ''));
        /* eslint-disable perfectionist/sort-objects */
        hux.styledObject({
            ID: space.id,
            Team: space.team?.name,
            Region: space.region?.description,
            CIDR: space.cidr,
            'Data CIDR': space.data_cidr,
            State: space.state,
            Shield: displayShieldState(space),
            'Outbound IPs': displayNat(space.outbound_ips),
            Generation: getGeneration(space),
            'Created at': space.created_at,
        }, 
        /* eslint-enable perfectionist/sort-objects */
        ['ID', 'Team', 'Region', 'CIDR', 'Data CIDR', 'State', 'Shield', 'Outbound IPs', 'Generation', 'Created at']);
    }
}
