"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mablApiClientFactory_1 = require("@mablhq-internal/runtime/api/mablApiClientFactory");
const describe_1 = require("../../commandUtil/describe");
const util_1 = require("../../commandUtil/util");
const cliUtil_1 = require("@mablhq-internal/runtime/core/cliUtil");
exports.command = 'describe <id>';
exports.describe = (0, util_1.getDescribeDescriptions)('plan');
exports.builder = (0, describe_1.getDescribeBuilderOptions)();
exports.handler = (0, cliUtil_1.failWrapper)(getPlan);
async function getPlan(parsed) {
    try {
        const planId = parsed.id;
        const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
        const plan = await apiClient.getPlan(planId);
        delete plan.journeys_ddt_migration_backup;
        (0, describe_1.outputEntity)(plan, parsed.output);
        return plan.id ?? '';
    }
    catch (error) {
        throw new Error(`Error getting plan: ${error}`);
    }
}
