"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
const ProjectInfoItem_1 = require("./ProjectInfoItem");
const IProjectItemData_1 = require("../app/IProjectItemData");
const IInfoItemData_1 = require("./IInfoItemData");
const IProjectItemData_2 = require("../app/IProjectItemData");
const ProjectItemUtilities_1 = require("../app/ProjectItemUtilities");
class ItemCountsInfoGenerator {
    constructor() {
        this.id = "ITEMS";
        this.title = "Minimum Definition of a Pack";
    }
    getTopicData(topicId) {
        if (topicId > 100 && topicId < 100 + IProjectItemData_2.MaxItemTypes) {
            return {
                title: ProjectItemUtilities_1.default.getDescriptionForType(topicId - 100) + " count",
            };
        }
        return {
            title: topicId.toString(),
        };
    }
    summarize(info, infoSet) {
        info.behaviorPackManifestCount = infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.behaviorPackManifestJson);
        info.unknownJsonCount = infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.json);
        info.entityTypeManifestCount = infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        info.itemTypeManifestCount = infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.itemTypeBehavior);
        info.blockTypeManifestCount = infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.blockTypeBehavior);
        info.resourcePackManifestCount = infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.resourcePackManifestJson);
        info.worldCount =
            infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.MCWorld) +
                infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.worldFolder);
        info.entityTypeResourceCount = infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.entityTypeResource);
        info.behaviorPackAnimationCount = infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.animationBehaviorJson);
        info.behaviorPackAnimationControllerCount = infoSet.getFirstNumberValue("ITEMS", 100 + IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson);
    }
    async generate(project, contentIndex) {
        const items = [];
        const typeCounts = [];
        for (let i = 0; i < IProjectItemData_2.MaxItemTypes; i++) {
            typeCounts[i] = 0;
        }
        const itemsCopy = project.getItemsCopy();
        for (let i = 0; i < itemsCopy.length; i++) {
            const pi = itemsCopy[i];
            typeCounts[pi.itemType]++;
            if (pi.itemType === IProjectItemData_1.ProjectItemType.behaviorPackManifestJson) {
                items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.info, this.id, 2, "Behavior pack manifest found", pi));
            }
            else if (pi.itemType === IProjectItemData_1.ProjectItemType.resourcePackManifestJson) {
                items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.info, this.id, 3, "Resource pack manifest found", pi));
            }
        }
        for (let i = 0; i < IProjectItemData_2.MaxItemTypes; i++) {
            if (typeCounts[i] > 0) {
                items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.info, this.id, 100 + i, ProjectItemUtilities_1.default.getDescriptionForType(i) + " item count", undefined, typeCounts[i]));
            }
        }
        return items;
    }
}
exports.default = ItemCountsInfoGenerator;

//# sourceMappingURL=../maps/info/ItemCountsInfoGenerator.js.map
