"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 EntityTypeDefinition_1 = require("../minecraft/EntityTypeDefinition");
const ItemTypeBehaviorDefinition_1 = require("../minecraft/ItemTypeBehaviorDefinition");
class StrictPlatformInfoGenerator {
    constructor() {
        this.id = "STRICT";
        this.title = "Strict Platform Info Generator";
    }
    getTopicData(topicId) {
        switch (topicId) {
            case 100:
                return {
                    title: "Uses a minecraft identifier",
                };
            case 101:
                return {
                    title: "Uses a minecraft runtime identifier",
                };
        }
        return {
            title: topicId.toString(),
        };
    }
    summarize(info, infoSet) { }
    async generate(project, contentIndex) {
        const infoItems = [];
        const itemsCopy = project.getItemsCopy();
        for (let i = 0; i < itemsCopy.length; i++) {
            const pi = itemsCopy[i];
            if (pi.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior) {
                await pi.ensureFileStorage();
                if (pi.file) {
                    const bpEntityType = await EntityTypeDefinition_1.default.ensureOnFile(pi.file);
                    if (bpEntityType) {
                        await bpEntityType.load();
                        if (bpEntityType && bpEntityType.data && bpEntityType.data.description) {
                            const desc = bpEntityType.data.description;
                            if (desc.identifier !== undefined && desc.identifier.toLowerCase().startsWith("minecraft:")) {
                                infoItems.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.testCompleteFail, this.id, 100, `Uses a minecraft: identifier override`, pi, desc.identifier));
                            }
                            if (desc.runtime_identifier !== undefined &&
                                desc.runtime_identifier.toLowerCase !== undefined &&
                                desc.runtime_identifier.toLowerCase().startsWith("minecraft:")) {
                                infoItems.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.testCompleteFail, this.id, 101, `Uses a runtime_identifier override`, pi, desc.runtime_identifier));
                            }
                        }
                    }
                }
            }
            else if (pi.itemType === IProjectItemData_1.ProjectItemType.itemTypeBehavior) {
                await pi.ensureFileStorage();
                if (pi.file) {
                    const bpItemType = await ItemTypeBehaviorDefinition_1.default.ensureOnFile(pi.file);
                    if (bpItemType) {
                        await bpItemType.load();
                        if (bpItemType && bpItemType.data && bpItemType.data.description) {
                            const desc = bpItemType.data.description;
                            if (desc.identifier !== undefined && desc.identifier.toLowerCase().startsWith("minecraft:")) {
                                infoItems.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.testCompleteFail, this.id, 104, `Uses a minecraft: identifier override`, pi, desc.identifier));
                            }
                        }
                    }
                }
            }
        }
        return infoItems;
    }
}
exports.default = StrictPlatformInfoGenerator;

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