"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.SharingInfoGeneratorTest = 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 BehaviorManifestDefinition_1 = require("../minecraft/BehaviorManifestDefinition");
var SharingInfoGeneratorTest;
(function (SharingInfoGeneratorTest) {
    SharingInfoGeneratorTest[SharingInfoGeneratorTest["requiresCustomCapabilities"] = 100] = "requiresCustomCapabilities";
    SharingInfoGeneratorTest[SharingInfoGeneratorTest["hasStrongLanguageContent"] = 101] = "hasStrongLanguageContent";
})(SharingInfoGeneratorTest = exports.SharingInfoGeneratorTest || (exports.SharingInfoGeneratorTest = {}));
const TopicTestIdBase = 500;
const UnsupportedForSharingTypes = [
    IProjectItemData_1.ProjectItemType.jigsawProcessorList,
    IProjectItemData_1.ProjectItemType.jigsawStructure,
    IProjectItemData_1.ProjectItemType.jigsawStructureSet,
    IProjectItemData_1.ProjectItemType.jigsawTemplatePool,
    IProjectItemData_1.ProjectItemType.aimAssistPresetJson,
    IProjectItemData_1.ProjectItemType.aimAssistCategoryJson,
    IProjectItemData_1.ProjectItemType.behaviorTreeJson,
    IProjectItemData_1.ProjectItemType.spawnGroupJson,
];
const UnsupportedForSharingTypesSet = new Set(UnsupportedForSharingTypes);
class SharingInfoGenerator {
    id = "SHARING";
    title = "Sharing Best Practices Information";
    canAlwaysProcess = true;
    getTopicData(topicId) {
        if (topicId >= TopicTestIdBase) {
            return {
                title: ProjectItemUtilities_1.default.getDescriptionForType(topicId - TopicTestIdBase),
            };
        }
        return {
            title: topicId.toString(),
        };
    }
    summarize(info, infoSet) { }
    async generate(project, contentIndex) {
        const items = [];
        const itemsByType = {};
        const lineSizeCounts = [];
        for (let i = 0; i < IProjectItemData_2.MaxItemTypes; i++) {
            lineSizeCounts[i] = 0;
        }
        const itemsCopy = project.getItemsCopy();
        for (let i = 0; i < itemsCopy.length; i++) {
            const pi = itemsCopy[i];
            let projInfoItem = undefined;
            if (pi.storageType === IProjectItemData_1.ProjectItemStorageType.singleFile) {
                await pi.loadFileContent();
                if (pi.primaryFile) {
                    /*
                    let strongLanguageContent = await BasicValidators.hasStrongLanguageContent(pi.availableFile);
                    if (strongLanguageContent) {
                      projInfoItem = new ProjectInfoItem(
                        InfoItemType.error,
                        this.id,
                        SharingInfoGeneratorTest.hasStrongLanguageContent,
                        `Contains strong language content: ` + strongLanguageContent,
                        pi
                      );
                      itemsByType[pi.itemType] = projInfoItem;
                      items.push(projInfoItem);
                    }*/
                }
            }
            if (UnsupportedForSharingTypesSet.has(pi.itemType)) {
                projInfoItem = new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.error, this.id, TopicTestIdBase + pi.itemType, ProjectItemUtilities_1.default.getDescriptionForType(pi.itemType) +
                    " is not supported for sharing - probably because this item is still an experimental feature.", pi);
                itemsByType[pi.itemType] = projInfoItem;
                items.push(projInfoItem);
            }
            else if (pi.itemType === IProjectItemData_1.ProjectItemType.behaviorPackManifestJson) {
                await pi.loadFileContent();
                if (pi.primaryFile) {
                    const bpManifest = await BehaviorManifestDefinition_1.default.ensureOnFile(pi.primaryFile);
                    if (bpManifest) {
                        await bpManifest.load();
                        if (bpManifest && bpManifest.definition && bpManifest.definition.capabilities) {
                            projInfoItem = new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.error, this.id, SharingInfoGeneratorTest.requiresCustomCapabilities, `Declares a custom capabilities requirement, which is not recommended for sharing.`, pi, JSON.stringify(bpManifest.definition.capabilities, null, 2));
                            itemsByType[pi.itemType] = projInfoItem;
                            items.push(projInfoItem);
                        }
                    }
                }
            }
        }
        return items;
    }
}
exports.default = SharingInfoGenerator;

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