"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnlinkedItemNotFoundByType = exports.UnlinkedItemInfoGeneratorTest = void 0;
const ProjectInfoItem_1 = require("./ProjectInfoItem");
const ProjectItemUtilities_1 = require("../app/ProjectItemUtilities");
const IInfoItemData_1 = require("./IInfoItemData");
const Database_1 = require("../minecraft/Database");
const IProjectItemData_1 = require("../app/IProjectItemData");
var UnlinkedItemInfoGeneratorTest;
(function (UnlinkedItemInfoGeneratorTest) {
    UnlinkedItemInfoGeneratorTest[UnlinkedItemInfoGeneratorTest["unlinkedItemIsNotUsed"] = 191] = "unlinkedItemIsNotUsed";
    UnlinkedItemInfoGeneratorTest[UnlinkedItemInfoGeneratorTest["avoidLinksToVanillaItems"] = 205] = "avoidLinksToVanillaItems";
})(UnlinkedItemInfoGeneratorTest = exports.UnlinkedItemInfoGeneratorTest || (exports.UnlinkedItemInfoGeneratorTest = {}));
exports.UnlinkedItemNotFoundByType = 300;
class UnlinkedItemInfoGenerator {
    id = "UNLINK";
    title = "Unlinked item info generator";
    canAlwaysProcess = true;
    getTopicData(topicId) {
        return {
            title: topicId.toString(),
        };
    }
    summarize(info, infoSet) { }
    async generate(projectItem, contentIndex) {
        const items = [];
        if (projectItem.unfulfilledRelationships) {
            for (const rel of projectItem.unfulfilledRelationships) {
                if (rel.isVanillaDependent) {
                    // UNLINK205
                    items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.recommendation, this.id, UnlinkedItemInfoGeneratorTest.avoidLinksToVanillaItems, `Link to vanilla ` +
                        ProjectItemUtilities_1.default.getDescriptionForType(rel.itemType).toLowerCase() +
                        ` item; avoid if possible`, projectItem, rel.path));
                }
                else {
                    const message = `Link to ` +
                        ProjectItemUtilities_1.default.getDescriptionForType(rel.itemType).toLowerCase() +
                        ` is not found in this pack`;
                    // UNLINK300+
                    items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.warning, this.id, exports.UnlinkedItemNotFoundByType + rel.itemType, message, projectItem, projectItem.projectPath + " to `" + rel.path + "`"));
                }
            }
        }
        if (projectItem.itemType === IProjectItemData_1.ProjectItemType.texture || projectItem.itemType === IProjectItemData_1.ProjectItemType.audio) {
            if (projectItem.parentItemCount <= 0 && projectItem.childItemCount <= 0) {
                const path = await projectItem.getPackRelativePath();
                if (path) {
                    const isVanilla = await Database_1.default.matchesVanillaPath(path);
                    if (!isVanilla) {
                        // UNLINK191
                        items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.warning, this.id, UnlinkedItemInfoGeneratorTest.unlinkedItemIsNotUsed, ProjectItemUtilities_1.default.getDescriptionForType(projectItem.itemType) +
                            ` does not have any items in this pack that are using this.`, projectItem));
                    }
                }
            }
        }
        return items;
    }
}
exports.default = UnlinkedItemInfoGenerator;

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