"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
const ProjectInfoItem_1 = require("./ProjectInfoItem");
const IInfoItemData_1 = require("./IInfoItemData");
class PathLengthFileGenerator {
    constructor() {
        this.id = "PATHLENGTH";
        this.title = "Path Length";
    }
    getTopicData(topicId) {
        return {
            title: topicId.toString(),
        };
    }
    summarize(info, infoSet) { }
    async generate(project, file, contentIndex) {
        const items = [];
        let path = file.storageRelativePath;
        const packContentFolderHints = [
            "bp",
            "rp",
            "resource pack",
            "resource packs",
            "content/resource_packs",
            "behavior pack",
            "behavior packs",
            "content/behavior_packs",
            "skin pack",
            "skin packs",
            "content/skin_packs",
            "world_template",
        ];
        for (const hint of packContentFolderHints) {
            const hintIndex = path.toLowerCase().indexOf("/" + hint + "/");
            if (hintIndex >= 0) {
                path = path.substring(hintIndex + hint.length + 2);
            }
        }
        const packStarterFolderHints = ["resource_packs", "behavior_packs", "world_templates", "skin_packs"];
        for (const hint of packStarterFolderHints) {
            if (path.toLowerCase().startsWith(hint + "/")) {
                path = path.substring(hint.length + 1);
            }
        }
        const fSlashSegments = path.split("/");
        const bSlashSegments = path.split("\\");
        if (fSlashSegments.length > 9 || bSlashSegments.length > 9) {
            items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.testCompleteFail, this.id, 2, `File path contains 8 or more directory segments, and may not run on all devices`, project.getItemByExtendedOrProjectPath(file.extendedPath), path));
        }
        if (path.length > 80) {
            items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.testCompleteFail, this.id, 3, `File path contains more than 80 characters, and may not run on all devices`, project.getItemByExtendedOrProjectPath(file.extendedPath), path));
        }
        return items;
    }
}
exports.default = PathLengthFileGenerator;

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