"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ItemCountsInfoGeneratorTest = void 0;
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");
const TopicTestIdBase = 200;
var ItemCountsInfoGeneratorTest;
(function (ItemCountsInfoGeneratorTest) {
    ItemCountsInfoGeneratorTest[ItemCountsInfoGeneratorTest["behaviorPackManifest"] = 102] = "behaviorPackManifest";
    ItemCountsInfoGeneratorTest[ItemCountsInfoGeneratorTest["resourcePackManifest"] = 103] = "resourcePackManifest";
})(ItemCountsInfoGeneratorTest = exports.ItemCountsInfoGeneratorTest || (exports.ItemCountsInfoGeneratorTest = {}));
class ItemCountsInfoGenerator {
    id = "ITEMS";
    title = "Minimum Definition of a Pack";
    getTopicData(topicId) {
        if (topicId > TopicTestIdBase && topicId < TopicTestIdBase + IProjectItemData_2.MaxItemTypes) {
            return {
                title: ProjectItemUtilities_1.default.getDescriptionForType(topicId - TopicTestIdBase) + " count",
            };
        }
        return {
            title: topicId.toString(),
        };
    }
    summarize(info, infoSet) {
        info.behaviorPackManifestCount = infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + IProjectItemData_1.ProjectItemType.behaviorPackManifestJson);
        info.unknownJsonCount = infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + IProjectItemData_1.ProjectItemType.unknownJson);
        info.entityTypeManifestCount = infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        info.itemTypeManifestCount = infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + IProjectItemData_1.ProjectItemType.itemTypeBehavior);
        info.blockTypeManifestCount = infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + IProjectItemData_1.ProjectItemType.blockTypeBehavior);
        info.resourcePackManifestCount = infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + IProjectItemData_1.ProjectItemType.resourcePackManifestJson);
        info.worldCount =
            infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + IProjectItemData_1.ProjectItemType.MCWorld) +
                infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + IProjectItemData_1.ProjectItemType.worldFolder);
        info.entityTypeResourceCount = infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + IProjectItemData_1.ProjectItemType.entityTypeResource);
        info.behaviorPackAnimationCount = infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + IProjectItemData_1.ProjectItemType.animationBehaviorJson);
        info.behaviorPackAnimationControllerCount = infoSet.getFirstNumberDataValue(this.id, TopicTestIdBase + 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, ItemCountsInfoGeneratorTest.behaviorPackManifest, "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, ItemCountsInfoGeneratorTest.resourcePackManifest, "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, TopicTestIdBase + i, ProjectItemUtilities_1.default.getDescriptionForType(i) + " item count", undefined, typeCounts[i]));
            }
        }
        return items;
    }
}
exports.default = ItemCountsInfoGenerator;

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