"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDeployedTemplateType = void 0;
const dasherize_1 = require("../utils/dasherize");
const util_1 = require("../util");
/**
 * We do our best to glean what the solution template
 * is supposed to become when deployed. This util
 * extracts the expected item type from the
 * hubSolutionType typeKeyword on the solution item
 *
 * We use this in various UIs to show the expected
 * type rather than "Solution"
 *
 * @param template
 */
const getDeployedTemplateType = (template) => {
    let deployedType = "Solution";
    // 1. Extract the camelCase item type from the
    // hubSolutionType|<camel-case-item-type> typeKeyword
    const hubSolutionTypeKeyword = template.typeKeywords.find((keyword) => keyword.startsWith("hubSolutionType|"));
    // 2. Attempt to de-camelize the item type
    if (hubSolutionTypeKeyword) {
        const camelizedType = hubSolutionTypeKeyword.split("|")[1];
        deployedType = (0, dasherize_1.dasherize)(camelizedType)
            .split("-")
            .map((str) => (0, util_1.capitalize)(str))
            .join(" ");
        // some item types need to be handled separately
        // because they don't follow the standard pattern
        const exceptionMap = {
            storyMap: "StoryMap",
            // TODO: add other relevant exceptions
        };
        if (exceptionMap[camelizedType]) {
            deployedType = exceptionMap[camelizedType];
        }
    }
    return deployedType;
};
exports.getDeployedTemplateType = getDeployedTemplateType;
//# sourceMappingURL=utils.js.map