"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
const Utilities_1 = require("../core/Utilities");
const Pack_1 = require("../minecraft/Pack");
const StorageUtilities_1 = require("../storage/StorageUtilities");
const IProjectItemData_1 = require("./IProjectItemData");
const ProjectUtilities_1 = require("./ProjectUtilities");
class ProjectItemUtilities {
    static inferTypeFromContent(content, fileName) {
        const type = StorageUtilities_1.default.getTypeFromName(fileName);
        if (typeof content === "string") {
            switch (type) {
                case "json":
                    return ProjectItemUtilities.inferTypeFromJsonContent(content, fileName);
            }
        }
        else {
            switch (type) {
                case "png":
                    return { itemType: IProjectItemData_1.ProjectItemType.texture, packType: Pack_1.PackType.resource, path: "/textures/ " };
            }
        }
        return { itemType: IProjectItemData_1.ProjectItemType.unknown, packType: Pack_1.PackType.behavior, path: "/" };
    }
    static inferTypeFromJsonContent(jsonContent, fileName) {
        const fileBaseName = StorageUtilities_1.default.getBaseFromName(fileName);
        if (fileBaseName) {
            if (fileBaseName.endsWith(".mci")) {
                return { itemType: IProjectItemData_1.ProjectItemType.contentIndexJson };
            }
            else if (fileBaseName.endsWith(".mcr")) {
                return { itemType: IProjectItemData_1.ProjectItemType.contentReportJson };
            }
        }
        const firstHundred = jsonContent.substring(0, 100);
        if (firstHundred.indexOf('"minecraft:recipe_shaped"') >= 0 ||
            firstHundred.indexOf('"minecraft:recipe_shapeless"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.recipeBehaviorJson };
        }
        else if (firstHundred.indexOf('"minecraft:entity"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.entityTypeBehavior };
        }
        else if (firstHundred.indexOf('"minecraft:item"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.itemTypeBehaviorJson };
        }
        else if (firstHundred.indexOf('"pools"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.itemTypeBehaviorJson };
        }
        else if (firstHundred.indexOf('"minecraft:spawn_rules"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.spawnRuleBehavior };
        }
        else if (firstHundred.indexOf('"tiers"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.tradingBehaviorJson };
        }
        else if (firstHundred.indexOf('"animation_controllers"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.animationControllerResourceJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"animations"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.animationResourceJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"animations"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.animationResourceJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"minecraft:attachable"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.attachableResourceJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"minecraft:client_entity"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.entityTypeResource, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"minecraft:fog_settings"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.fogResourceJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"minecraft:geometry"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.modelGeometryJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"particle_effect"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.particleJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"render_controllers"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.renderControllerJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"namespace"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.uiJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"sound_definitions"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.soundDefinitionJson, packType: Pack_1.PackType.resource };
        }
        else if (fileBaseName === "manifest") {
            const jsonO = Utilities_1.default.getJsonObject(jsonContent);
            if (jsonO !== undefined && jsonO["modules"]) {
                for (const mod of jsonO["modules"]) {
                    if (mod && mod["type"]) {
                        switch (mod["type"]) {
                            case "script":
                            case "data":
                                return { itemType: IProjectItemData_1.ProjectItemType.behaviorPackManifestJson };
                            case "resources":
                                return { itemType: IProjectItemData_1.ProjectItemType.resourcePackManifestJson };
                        }
                    }
                }
            }
        }
        return { itemType: IProjectItemData_1.ProjectItemType.unknown };
    }
    static getSortOrder(itemType) {
        // default order is item type * 100;
        switch (itemType) {
            case IProjectItemData_1.ProjectItemType.resourcePackManifestJson: // sort next to .behaviorPackManifestJson
                return 510;
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
                return 1851;
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
                return 1852;
            case IProjectItemData_1.ProjectItemType.itemTypeBehaviorJson:
                return 1853;
            case IProjectItemData_1.ProjectItemType.recipeBehaviorJson:
                return 1860;
            case IProjectItemData_1.ProjectItemType.particleJson:
                return 1870;
            case IProjectItemData_1.ProjectItemType.tickJson:
                return 903;
            case IProjectItemData_1.ProjectItemType.soundsCatalogResourceJson:
                return 9901;
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
                return 5001;
            case IProjectItemData_1.ProjectItemType.renderControllerJson:
                return 5003;
            // sort all the world-y and container-y stuff next to each other
            case IProjectItemData_1.ProjectItemType.structure:
            case IProjectItemData_1.ProjectItemType.MCWorld:
            case IProjectItemData_1.ProjectItemType.MCTemplate:
            case IProjectItemData_1.ProjectItemType.MCPack:
            case IProjectItemData_1.ProjectItemType.MCProject:
            case IProjectItemData_1.ProjectItemType.zip:
                return 1600 + itemType;
        }
        return itemType * 100;
    }
    static getCategory(itemType) {
        switch (itemType) {
            case IProjectItemData_1.ProjectItemType.MCFunction:
            case IProjectItemData_1.ProjectItemType.testJs:
            case IProjectItemData_1.ProjectItemType.actionSet:
            case IProjectItemData_1.ProjectItemType.animationBehaviorJson:
            case IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson:
            case IProjectItemData_1.ProjectItemType.tickJson:
            case IProjectItemData_1.ProjectItemType.js:
            case IProjectItemData_1.ProjectItemType.ts:
            case IProjectItemData_1.ProjectItemType.buildProcessedJs:
            case IProjectItemData_1.ProjectItemType.catalogIndexJs:
                return IProjectItemData_1.ProjectItemCategory.logic;
            case IProjectItemData_1.ProjectItemType.image:
            case IProjectItemData_1.ProjectItemType.texture:
            case IProjectItemData_1.ProjectItemType.storeAssetImage:
            case IProjectItemData_1.ProjectItemType.marketingAssetImage:
            case IProjectItemData_1.ProjectItemType.uiTexture:
            case IProjectItemData_1.ProjectItemType.iconImage:
            case IProjectItemData_1.ProjectItemType.soundDefinitionJson:
            case IProjectItemData_1.ProjectItemType.soundsCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.resourcePackManifestJson:
            case IProjectItemData_1.ProjectItemType.resourcePackListJson:
            case IProjectItemData_1.ProjectItemType.renderControllerJson:
            case IProjectItemData_1.ProjectItemType.lightingJson:
            case IProjectItemData_1.ProjectItemType.textureSetJson:
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
            case IProjectItemData_1.ProjectItemType.material:
            case IProjectItemData_1.ProjectItemType.materialSetJson:
            case IProjectItemData_1.ProjectItemType.animationControllerResourceJson:
            case IProjectItemData_1.ProjectItemType.animationResourceJson:
            case IProjectItemData_1.ProjectItemType.itemTextureJson:
            case IProjectItemData_1.ProjectItemType.flipbookTexturesJson:
            case IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.globalVariablesJson:
            case IProjectItemData_1.ProjectItemType.uiJson:
            case IProjectItemData_1.ProjectItemType.lang:
            case IProjectItemData_1.ProjectItemType.languagesCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.ninesliceJson:
            case IProjectItemData_1.ProjectItemType.attachableResourceJson:
            case IProjectItemData_1.ProjectItemType.audio:
                return IProjectItemData_1.ProjectItemCategory.assets;
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
            case IProjectItemData_1.ProjectItemType.entityTypeBaseJs:
            case IProjectItemData_1.ProjectItemType.entityTypeBaseTs:
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
            case IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.blockTypeResourceJson:
            case IProjectItemData_1.ProjectItemType.itemTypeBehaviorJson:
            case IProjectItemData_1.ProjectItemType.fogResourceJson:
            case IProjectItemData_1.ProjectItemType.tradingBehaviorJson:
            case IProjectItemData_1.ProjectItemType.particleJson:
            case IProjectItemData_1.ProjectItemType.structure:
            case IProjectItemData_1.ProjectItemType.recipeBehaviorJson:
            case IProjectItemData_1.ProjectItemType.biomeBehaviorJson:
            case IProjectItemData_1.ProjectItemType.biomeResourceJson:
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
            case IProjectItemData_1.ProjectItemType.dialogueBehaviorJson:
            case IProjectItemData_1.ProjectItemType.MCWorld:
            case IProjectItemData_1.ProjectItemType.worldTemplateManifestJson:
            case IProjectItemData_1.ProjectItemType.itemTypeResourceJson:
            case IProjectItemData_1.ProjectItemType.featureBehavior:
            case IProjectItemData_1.ProjectItemType.featureRuleBehaviorJson:
                return IProjectItemData_1.ProjectItemCategory.types;
            case IProjectItemData_1.ProjectItemType.esLintConfigMjs:
            case IProjectItemData_1.ProjectItemType.env:
            case IProjectItemData_1.ProjectItemType.justConfigTs:
            case IProjectItemData_1.ProjectItemType.packageLockJson:
            case IProjectItemData_1.ProjectItemType.jsconfigJson:
            case IProjectItemData_1.ProjectItemType.prettierRcJson:
            case IProjectItemData_1.ProjectItemType.tsconfigJson:
            case IProjectItemData_1.ProjectItemType.docfxJson:
            case IProjectItemData_1.ProjectItemType.jsdocJson:
            case IProjectItemData_1.ProjectItemType.vsCodeExtensionsJson:
            case IProjectItemData_1.ProjectItemType.vsCodeLaunchJson:
            case IProjectItemData_1.ProjectItemType.vsCodeSettingsJson:
            case IProjectItemData_1.ProjectItemType.vsCodeTasksJson:
                return IProjectItemData_1.ProjectItemCategory.build;
            case IProjectItemData_1.ProjectItemType.zip:
            case IProjectItemData_1.ProjectItemType.MCAddon:
            case IProjectItemData_1.ProjectItemType.MCPack:
            case IProjectItemData_1.ProjectItemType.MCTemplate:
            case IProjectItemData_1.ProjectItemType.MCProject:
            case IProjectItemData_1.ProjectItemType.behaviorPackFolder:
            case IProjectItemData_1.ProjectItemType.resourcePackFolder:
            case IProjectItemData_1.ProjectItemType.skinPackFolder:
                return IProjectItemData_1.ProjectItemCategory.package;
        }
        return IProjectItemData_1.ProjectItemCategory.unknown;
    }
    static isImageType(itemType) {
        if (itemType === IProjectItemData_1.ProjectItemType.image ||
            itemType === IProjectItemData_1.ProjectItemType.texture ||
            itemType === IProjectItemData_1.ProjectItemType.storeAssetImage ||
            itemType === IProjectItemData_1.ProjectItemType.marketingAssetImage ||
            itemType === IProjectItemData_1.ProjectItemType.uiTexture ||
            itemType === IProjectItemData_1.ProjectItemType.iconImage) {
            return true;
        }
        return false;
    }
    static isAudioType(itemType) {
        if (itemType === IProjectItemData_1.ProjectItemType.audio) {
            return true;
        }
        return false;
    }
    static isPackageType(itemType) {
        if (itemType === IProjectItemData_1.ProjectItemType.zip ||
            itemType === IProjectItemData_1.ProjectItemType.MCAddon ||
            itemType === IProjectItemData_1.ProjectItemType.MCPack ||
            itemType === IProjectItemData_1.ProjectItemType.MCProject ||
            itemType === IProjectItemData_1.ProjectItemType.MCWorld ||
            itemType === IProjectItemData_1.ProjectItemType.MCTemplate) {
            return true;
        }
        return false;
    }
    static isBinaryType(itemType) {
        if (this.isImageType(itemType) || this.isPackageType(itemType) || this.isAudioType(itemType)) {
            return true;
        }
        return false;
    }
    static getMimeTypes(item) {
        switch (item.itemType) {
            case IProjectItemData_1.ProjectItemType.js:
            case IProjectItemData_1.ProjectItemType.testJs:
            case IProjectItemData_1.ProjectItemType.entityTypeBaseJs:
            case IProjectItemData_1.ProjectItemType.buildProcessedJs:
            case IProjectItemData_1.ProjectItemType.catalogIndexJs:
            case IProjectItemData_1.ProjectItemType.entityTypeBaseTs:
            case IProjectItemData_1.ProjectItemType.esLintConfigMjs:
            case IProjectItemData_1.ProjectItemType.blockTypeBaseJs:
                return ["application/javascript"];
            case IProjectItemData_1.ProjectItemType.justConfigTs:
            case IProjectItemData_1.ProjectItemType.ts:
            case IProjectItemData_1.ProjectItemType.blockTypeBaseTs:
                return ["application/typescript"];
            case IProjectItemData_1.ProjectItemType.json:
            case IProjectItemData_1.ProjectItemType.behaviorPackManifestJson:
            case IProjectItemData_1.ProjectItemType.resourcePackManifestJson:
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
            case IProjectItemData_1.ProjectItemType.tickJson:
            case IProjectItemData_1.ProjectItemType.cameraJson:
            case IProjectItemData_1.ProjectItemType.actionSet:
            case IProjectItemData_1.ProjectItemType.worldTest:
            case IProjectItemData_1.ProjectItemType.behaviorPackListJson:
            case IProjectItemData_1.ProjectItemType.resourcePackListJson:
            case IProjectItemData_1.ProjectItemType.animationBehaviorJson:
            case IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson:
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
            case IProjectItemData_1.ProjectItemType.blockMaterialsBehaviorJson:
            case IProjectItemData_1.ProjectItemType.itemTypeBehaviorJson:
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
            case IProjectItemData_1.ProjectItemType.biomeResourceJson:
            case IProjectItemData_1.ProjectItemType.fileListArrayJson:
            case IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.soundsCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.animationResourceJson:
            case IProjectItemData_1.ProjectItemType.animationControllerResourceJson:
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
            case IProjectItemData_1.ProjectItemType.fogResourceJson:
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
            case IProjectItemData_1.ProjectItemType.particleJson:
            case IProjectItemData_1.ProjectItemType.renderControllerJson:
            case IProjectItemData_1.ProjectItemType.ninesliceJson:
            case IProjectItemData_1.ProjectItemType.uiJson:
            case IProjectItemData_1.ProjectItemType.languagesCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.biomeBehaviorJson:
            case IProjectItemData_1.ProjectItemType.dialogueBehaviorJson:
            case IProjectItemData_1.ProjectItemType.featureRuleBehaviorJson:
            case IProjectItemData_1.ProjectItemType.featureBehavior:
            case IProjectItemData_1.ProjectItemType.functionEventJson:
            case IProjectItemData_1.ProjectItemType.recipeBehaviorJson:
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
            case IProjectItemData_1.ProjectItemType.tradingBehaviorJson:
            case IProjectItemData_1.ProjectItemType.volumeBehaviorJson:
            case IProjectItemData_1.ProjectItemType.attachableResourceJson:
            case IProjectItemData_1.ProjectItemType.itemTypeResourceJson:
            case IProjectItemData_1.ProjectItemType.materialsResourceJson:
            case IProjectItemData_1.ProjectItemType.musicDefinitionJson:
            case IProjectItemData_1.ProjectItemType.soundDefinitionJson:
            case IProjectItemData_1.ProjectItemType.contentIndexJson:
            case IProjectItemData_1.ProjectItemType.contentReportJson:
            case IProjectItemData_1.ProjectItemType.tsconfigJson:
            case IProjectItemData_1.ProjectItemType.prettierRcJson:
            case IProjectItemData_1.ProjectItemType.jsconfigJson:
            case IProjectItemData_1.ProjectItemType.docfxJson:
            case IProjectItemData_1.ProjectItemType.jsdocJson:
            case IProjectItemData_1.ProjectItemType.packageJson:
            case IProjectItemData_1.ProjectItemType.packageLockJson:
            case IProjectItemData_1.ProjectItemType.docInfoJson:
            case IProjectItemData_1.ProjectItemType.scriptTypesJson:
            case IProjectItemData_1.ProjectItemType.vanillaDataJson:
            case IProjectItemData_1.ProjectItemType.engineOrderingJson:
            case IProjectItemData_1.ProjectItemType.commandSetDefinitionJson:
            case IProjectItemData_1.ProjectItemType.skinPackManifestJson:
            case IProjectItemData_1.ProjectItemType.vsCodeLaunchJson:
            case IProjectItemData_1.ProjectItemType.vsCodeTasksJson:
            case IProjectItemData_1.ProjectItemType.vsCodeSettingsJson:
            case IProjectItemData_1.ProjectItemType.vsCodeExtensionsJson:
            case IProjectItemData_1.ProjectItemType.worldTemplateManifestJson:
            case IProjectItemData_1.ProjectItemType.textureSetJson:
            case IProjectItemData_1.ProjectItemType.textureListJson:
            case IProjectItemData_1.ProjectItemType.lightingJson:
            case IProjectItemData_1.ProjectItemType.flipbookTexturesJson:
            case IProjectItemData_1.ProjectItemType.itemTextureJson:
            case IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.globalVariablesJson:
            case IProjectItemData_1.ProjectItemType.dataForm:
            case IProjectItemData_1.ProjectItemType.dimensionJson:
            case IProjectItemData_1.ProjectItemType.behaviorPackHistoryListJson:
            case IProjectItemData_1.ProjectItemType.resourcePackHistoryListJson:
                return ["application/json"];
            case IProjectItemData_1.ProjectItemType.MCWorld:
            case IProjectItemData_1.ProjectItemType.MCTemplate:
            case IProjectItemData_1.ProjectItemType.MCProject:
            case IProjectItemData_1.ProjectItemType.MCAddon:
            case IProjectItemData_1.ProjectItemType.MCPack:
            case IProjectItemData_1.ProjectItemType.zip:
                return ["application/zip"];
            case IProjectItemData_1.ProjectItemType.structure:
                return ["application/octet-stream"];
            case IProjectItemData_1.ProjectItemType.MCFunction:
            case IProjectItemData_1.ProjectItemType.material:
            case IProjectItemData_1.ProjectItemType.materialGeometry:
            case IProjectItemData_1.ProjectItemType.materialFragment:
            case IProjectItemData_1.ProjectItemType.materialSetJson:
            case IProjectItemData_1.ProjectItemType.materialVertex:
            case IProjectItemData_1.ProjectItemType.env:
            case IProjectItemData_1.ProjectItemType.lang:
                return ["text/plain"];
            case IProjectItemData_1.ProjectItemType.audio:
                return ["audio/wav", "audio/mp3", "audio/ogg"];
            case IProjectItemData_1.ProjectItemType.image:
            case IProjectItemData_1.ProjectItemType.texture:
            case IProjectItemData_1.ProjectItemType.uiTexture:
            case IProjectItemData_1.ProjectItemType.iconImage:
            case IProjectItemData_1.ProjectItemType.marketingAssetImage:
            case IProjectItemData_1.ProjectItemType.storeAssetImage:
                return ["image/png", "image/tiff"];
            default:
                return ["application/octet-stream"];
        }
    }
    static getDescriptionForType(type) {
        switch (type) {
            case IProjectItemData_1.ProjectItemType.js:
                return "JavaScript";
            case IProjectItemData_1.ProjectItemType.buildProcessedJs:
                return "Built JavaScript";
            case IProjectItemData_1.ProjectItemType.ts:
                return "TypeScript";
            case IProjectItemData_1.ProjectItemType.json:
                return "General json file";
            case IProjectItemData_1.ProjectItemType.behaviorPackManifestJson:
                return "Behavior pack manifest";
            case IProjectItemData_1.ProjectItemType.resourcePackManifestJson:
                return "Resource pack manifest";
            case IProjectItemData_1.ProjectItemType.testJs:
                return "Test JavaScript file";
            case IProjectItemData_1.ProjectItemType.entityTypeBaseJs:
                return "Entity type JavaScript";
            case IProjectItemData_1.ProjectItemType.entityTypeBaseTs:
                return "Entity type TypeScript";
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
                return "Entity type";
            case IProjectItemData_1.ProjectItemType.MCTemplate:
                return "Minecraft template";
            case IProjectItemData_1.ProjectItemType.MCWorld:
                return "Minecraft world";
            case IProjectItemData_1.ProjectItemType.MCProject:
                return "Minecraft project";
            case IProjectItemData_1.ProjectItemType.MCAddon:
                return "Minecraft addon";
            case IProjectItemData_1.ProjectItemType.MCPack:
                return "Minecraft pack";
            case IProjectItemData_1.ProjectItemType.zip:
                return "Minecraft zip";
            case IProjectItemData_1.ProjectItemType.worldFolder:
                return "Minecraft world";
            case IProjectItemData_1.ProjectItemType.structure:
                return "Structure";
            case IProjectItemData_1.ProjectItemType.MCFunction:
                return "Function";
            case IProjectItemData_1.ProjectItemType.tickJson:
                return "Tick";
            case IProjectItemData_1.ProjectItemType.material:
                return "Material";
            case IProjectItemData_1.ProjectItemType.materialSetJson:
                return "Material Set";
            case IProjectItemData_1.ProjectItemType.materialGeometry:
                return "Geometry";
            case IProjectItemData_1.ProjectItemType.materialFragment:
                return "Fragment";
            case IProjectItemData_1.ProjectItemType.materialVertex:
                return "Vertex";
            case IProjectItemData_1.ProjectItemType.cameraJson:
                return "Camera";
            case IProjectItemData_1.ProjectItemType.catalogIndexJs:
                return "Catalog index";
            case IProjectItemData_1.ProjectItemType.behaviorPackFolder:
                return "Behavior pack";
            case IProjectItemData_1.ProjectItemType.resourcePackFolder:
                return "Resource pack";
            case IProjectItemData_1.ProjectItemType.skinPackFolder:
                return "Skin pack";
            case IProjectItemData_1.ProjectItemType.actionSet:
                return "Action Set";
            case IProjectItemData_1.ProjectItemType.worldTest:
                return "World test";
            case IProjectItemData_1.ProjectItemType.behaviorPackListJson:
                return "World behavior pack list";
            case IProjectItemData_1.ProjectItemType.resourcePackListJson:
                return "World resource pack list";
            case IProjectItemData_1.ProjectItemType.animationBehaviorJson:
                return "Behavior pack animation";
            case IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson:
                return "Behavior pack animation controller";
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
                return "Block type";
            case IProjectItemData_1.ProjectItemType.blockMaterialsBehaviorJson:
                return "Block type materials";
            case IProjectItemData_1.ProjectItemType.itemTypeBehaviorJson:
                return "Item type";
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
                return "Loot table";
            case IProjectItemData_1.ProjectItemType.biomeResourceJson:
                return "Biome resources";
            case IProjectItemData_1.ProjectItemType.fileListArrayJson:
                return "File list";
            case IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson:
                return "Block resource catalog";
            case IProjectItemData_1.ProjectItemType.soundsCatalogResourceJson:
                return "Sound catalog";
            case IProjectItemData_1.ProjectItemType.animationResourceJson:
                return "Animation";
            case IProjectItemData_1.ProjectItemType.animationControllerResourceJson:
                return "Animation controller";
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
                return "Entity type resources";
            case IProjectItemData_1.ProjectItemType.fogResourceJson:
                return "Fog";
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
                return "Model";
            case IProjectItemData_1.ProjectItemType.particleJson:
                return "Particle";
            case IProjectItemData_1.ProjectItemType.renderControllerJson:
                return "Render controller";
            case IProjectItemData_1.ProjectItemType.uiJson:
                return "User interface";
            case IProjectItemData_1.ProjectItemType.languagesCatalogResourceJson:
                return "Language catalog";
            case IProjectItemData_1.ProjectItemType.biomeBehaviorJson:
                return "Biome";
            case IProjectItemData_1.ProjectItemType.dialogueBehaviorJson:
                return "Entity dialogue";
            case IProjectItemData_1.ProjectItemType.featureRuleBehaviorJson:
                return "World feature rule";
            case IProjectItemData_1.ProjectItemType.featureBehavior:
                return "Feature";
            case IProjectItemData_1.ProjectItemType.functionEventJson:
                return "Function event";
            case IProjectItemData_1.ProjectItemType.recipeBehaviorJson:
                return "Recipe";
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
                return "Spawn rule";
            case IProjectItemData_1.ProjectItemType.tradingBehaviorJson:
                return "Trading";
            case IProjectItemData_1.ProjectItemType.volumeBehaviorJson:
                return "Volume";
            case IProjectItemData_1.ProjectItemType.attachableResourceJson:
                return "Attachable";
            case IProjectItemData_1.ProjectItemType.itemTypeResourceJson:
                return "Item type resources";
            case IProjectItemData_1.ProjectItemType.materialsResourceJson:
                return "Materials";
            case IProjectItemData_1.ProjectItemType.musicDefinitionJson:
                return "Music catalog";
            case IProjectItemData_1.ProjectItemType.soundDefinitionJson:
                return "Sound catalog";
            case IProjectItemData_1.ProjectItemType.audio:
                return "Audio";
            case IProjectItemData_1.ProjectItemType.contentIndexJson:
                return "Content Description";
            case IProjectItemData_1.ProjectItemType.contentReportJson:
                return "Content Report";
            case IProjectItemData_1.ProjectItemType.tsconfigJson:
                return "TypeScript config";
            case IProjectItemData_1.ProjectItemType.prettierRcJson:
                return "Prettier JavaScript/JSON style config";
            case IProjectItemData_1.ProjectItemType.jsconfigJson:
                return "JavaScript config";
            case IProjectItemData_1.ProjectItemType.docfxJson:
                return "DocFX definition";
            case IProjectItemData_1.ProjectItemType.jsdocJson:
                return "JSDoc definition";
            case IProjectItemData_1.ProjectItemType.packageJson:
                return "NPM package definition";
            case IProjectItemData_1.ProjectItemType.packageLockJson:
                return "NPM package lock definition";
            case IProjectItemData_1.ProjectItemType.env:
                return "Environment File";
            case IProjectItemData_1.ProjectItemType.esLintConfigMjs:
                return "ESLint config";
            case IProjectItemData_1.ProjectItemType.justConfigTs:
                return "Just config";
            case IProjectItemData_1.ProjectItemType.docInfoJson:
                return "Doc info json";
            case IProjectItemData_1.ProjectItemType.ninesliceJson:
                return "Nine-slice scaling config";
            case IProjectItemData_1.ProjectItemType.scriptTypesJson:
                return "Script types definition";
            case IProjectItemData_1.ProjectItemType.vanillaDataJson:
                return "Vanilla data definition";
            case IProjectItemData_1.ProjectItemType.engineOrderingJson:
                return "Engine ordering definition";
            case IProjectItemData_1.ProjectItemType.commandSetDefinitionJson:
                return "Command definition";
            case IProjectItemData_1.ProjectItemType.skinPackManifestJson:
                return "Skin pack manifest";
            case IProjectItemData_1.ProjectItemType.blockTypeBaseJs:
                return "Block type base JavaScript";
            case IProjectItemData_1.ProjectItemType.blockTypeBaseTs:
                return "Block type base TypeScript";
            case IProjectItemData_1.ProjectItemType.image:
                return "Image";
            case IProjectItemData_1.ProjectItemType.texture:
                return "Texture";
            case IProjectItemData_1.ProjectItemType.uiTexture:
                return "UI texture";
            case IProjectItemData_1.ProjectItemType.iconImage:
                return "Icon";
            case IProjectItemData_1.ProjectItemType.marketingAssetImage:
                return "Marketing image";
            case IProjectItemData_1.ProjectItemType.storeAssetImage:
                return "Store image";
            case IProjectItemData_1.ProjectItemType.vsCodeLaunchJson:
                return "VS Code launch file";
            case IProjectItemData_1.ProjectItemType.vsCodeTasksJson:
                return "VS Code tasks";
            case IProjectItemData_1.ProjectItemType.vsCodeSettingsJson:
                return "VS Code settings";
            case IProjectItemData_1.ProjectItemType.vsCodeExtensionsJson:
                return "VS Code extensions";
            case IProjectItemData_1.ProjectItemType.lang:
                return "Language translations";
            case IProjectItemData_1.ProjectItemType.worldTemplateManifestJson:
                return "World template manifest";
            case IProjectItemData_1.ProjectItemType.textureSetJson:
                return "Texture set";
            case IProjectItemData_1.ProjectItemType.textureListJson:
                return "Texture list";
            case IProjectItemData_1.ProjectItemType.lightingJson:
                return "Lighting";
            case IProjectItemData_1.ProjectItemType.flipbookTexturesJson:
                return "Flipbook texture set";
            case IProjectItemData_1.ProjectItemType.itemTextureJson:
                return "Item texture";
            case IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson:
                return "Terrain texture";
            case IProjectItemData_1.ProjectItemType.globalVariablesJson:
                return "UI global variables";
            case IProjectItemData_1.ProjectItemType.dataForm:
                return "Form";
            case IProjectItemData_1.ProjectItemType.dimensionJson:
                return "Dimension";
            case IProjectItemData_1.ProjectItemType.behaviorPackHistoryListJson:
                return "Behavior pack history";
            case IProjectItemData_1.ProjectItemType.resourcePackHistoryListJson:
                return "Resource pack history";
            default:
                return "Unknown";
        }
    }
    static getNewItemName(type) {
        return "New " + ProjectItemUtilities.getDescriptionForType(type).toLowerCase();
    }
    static getColorForType(type) {
        const cat = ProjectItemUtilities.getCategory(type);
        switch (cat) {
            case IProjectItemData_1.ProjectItemCategory.logic:
                return {
                    red: (type % 4) * 24 + 160,
                    green: (Math.floor(type / 4) % 4) * 12 + 104,
                    blue: (Math.floor(type / 16) % 4) * 12 + 104,
                };
            case IProjectItemData_1.ProjectItemCategory.assets:
                return {
                    red: (Math.floor(type / 4) % 4) * 12 + 104,
                    green: (type % 4) * 24 + 160,
                    blue: (Math.floor(type / 16) % 4) * 12 + 104,
                };
            case IProjectItemData_1.ProjectItemCategory.types:
                return {
                    red: (Math.floor(type / 16) % 4) * 12 + 104,
                    green: (Math.floor(type / 4) % 4) * 12 + 104,
                    blue: (type % 4) * 24 + 160,
                };
            default:
                return {
                    red: (Math.floor(type / 4) % 4) * 24 + 128,
                    green: (Math.floor(type / 4) % 4) * 24 + 128,
                    blue: (Math.floor(type / 4) % 4) * 24 + 128,
                };
        }
    }
    static getPluralDescriptionForType(type) {
        // override non-"plus s" plural-ifications here
        switch (type) {
            case IProjectItemData_1.ProjectItemType.ts:
                return "TypeScript files";
            case IProjectItemData_1.ProjectItemType.js:
                return "JavaScript files";
            case IProjectItemData_1.ProjectItemType.vsCodeTasksJson:
                return "VS Code task sets";
            case IProjectItemData_1.ProjectItemType.vsCodeSettingsJson:
                return "VS Code settings sets";
            case IProjectItemData_1.ProjectItemType.globalVariablesJson:
                return "UI global variable sets";
            case IProjectItemData_1.ProjectItemType.itemTypeResourceJson:
                return "Item type resource sets";
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
                return "Entity type resource sets";
            case IProjectItemData_1.ProjectItemType.materialGeometry:
                return "Geometries";
            case IProjectItemData_1.ProjectItemType.catalogIndexJs:
                return "Catalog indexes";
            case IProjectItemData_1.ProjectItemType.behaviorPackHistoryListJson:
                return "Behavior pack histories";
            case IProjectItemData_1.ProjectItemType.resourcePackHistoryListJson:
                return "Resource pack histories";
            default:
                return this.getDescriptionForType(type) + "s";
        }
    }
    static async getDefaultFolderForType(project, itemType) {
        const path = ProjectItemUtilities.getFolderRootsForType(itemType);
        if (path === undefined || path.length === 0) {
            return undefined;
        }
        await project.ensureLoadedProjectFolder();
        if (!project.projectFolder) {
            return undefined;
        }
        switch (itemType) {
            case IProjectItemData_1.ProjectItemType.js:
            case IProjectItemData_1.ProjectItemType.ts:
                const scriptsFolder = await project.getMainScriptsFolder();
                return scriptsFolder;
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
            case IProjectItemData_1.ProjectItemType.MCFunction:
                const defaultBpFolder = await project.getDefaultBehaviorPackFolder();
                if (!defaultBpFolder) {
                    return undefined;
                }
                return defaultBpFolder.ensureFolderFromRelativePath(path[0]);
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
                const defaultRpFolder = await project.getDefaultResourcePackFolder();
                if (!defaultRpFolder) {
                    return undefined;
                }
                return defaultRpFolder.ensureFolderFromRelativePath(path[0]);
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
                return await ProjectUtilities_1.default.getDefaultSpawnRulesFolder(project);
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
                return await ProjectUtilities_1.default.getDefaultLootTableFolder(project);
            case IProjectItemData_1.ProjectItemType.uiTexture:
                const defaultRpFolderA = await project.getDefaultResourcePackFolder();
                if (!defaultRpFolderA) {
                    return undefined;
                }
                return defaultRpFolderA.ensureFolderFromRelativePath(path.join("/"));
        }
        return undefined;
    }
    static getFolderRootsForType(itemType) {
        switch (itemType) {
            case IProjectItemData_1.ProjectItemType.MCFunction:
                return ["functions"];
            case IProjectItemData_1.ProjectItemType.js:
            case IProjectItemData_1.ProjectItemType.ts:
                return ["scripts"];
            case IProjectItemData_1.ProjectItemType.image:
                return ["subpacks"];
            case IProjectItemData_1.ProjectItemType.lightingJson:
                return ["lighting"];
            case IProjectItemData_1.ProjectItemType.tickJson:
                return ["functions"];
            case IProjectItemData_1.ProjectItemType.uiTexture:
                return ["textures", "ui"];
            case IProjectItemData_1.ProjectItemType.texture:
            case IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.itemTextureJson:
            case IProjectItemData_1.ProjectItemType.flipbookTexturesJson:
                return ["textures"];
            case IProjectItemData_1.ProjectItemType.iconImage:
                return [
                    "resource_packs",
                    "rps",
                    "development_resource_packs",
                    "behavior_packs",
                    "bps",
                    "development_behavior_packs",
                ];
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
                return ["models"];
            case IProjectItemData_1.ProjectItemType.soundsCatalogResourceJson:
                return ["resource_packs", "rps", "development_resource_packs"];
            case IProjectItemData_1.ProjectItemType.soundDefinitionJson:
                return ["sounds"];
            case IProjectItemData_1.ProjectItemType.renderControllerJson:
                return ["render_controllers"];
            case IProjectItemData_1.ProjectItemType.attachableResourceJson:
                return ["attachables"];
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
                return ["entities"];
            case IProjectItemData_1.ProjectItemType.itemTypeBehaviorJson:
            case IProjectItemData_1.ProjectItemType.itemTypeResourceJson:
                return ["items"];
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
                return ["blocks"];
            case IProjectItemData_1.ProjectItemType.documentedTypeFolder:
                return ["script_modules"];
            case IProjectItemData_1.ProjectItemType.commandSetDefinitionJson:
                return ["command_modules"];
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
                return ["loot_tables"];
            case IProjectItemData_1.ProjectItemType.recipeBehaviorJson:
                return ["recipes"];
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
                return ["spawn_rules"];
            case IProjectItemData_1.ProjectItemType.particleJson:
                return ["particles"];
            case IProjectItemData_1.ProjectItemType.structure:
                return ["structures"];
            case IProjectItemData_1.ProjectItemType.worldFolder:
            case IProjectItemData_1.ProjectItemType.MCWorld:
                return ["worlds"];
            case IProjectItemData_1.ProjectItemType.cameraJson:
                return ["cameras"];
            case IProjectItemData_1.ProjectItemType.dimensionJson:
                return ["dimensions"];
            case IProjectItemData_1.ProjectItemType.fogResourceJson:
                return ["fogs"];
            case IProjectItemData_1.ProjectItemType.dataForm:
                return ["forms"];
            case IProjectItemData_1.ProjectItemType.scriptTypesJson:
                return ["checkpoint_input", "script_modules"];
            case IProjectItemData_1.ProjectItemType.engineOrderingJson:
                return ["checkpoint_input", "engine_modules"];
            case IProjectItemData_1.ProjectItemType.vanillaDataJson:
                return ["checkpoint_input", "vanilladata_modules"];
            case IProjectItemData_1.ProjectItemType.marketingAssetImage:
                return ["marketing art"];
            case IProjectItemData_1.ProjectItemType.storeAssetImage:
                return ["store art"];
            case IProjectItemData_1.ProjectItemType.audio:
                return ["sounds"];
            case IProjectItemData_1.ProjectItemType.materialSetJson:
            case IProjectItemData_1.ProjectItemType.materialsResourceJson:
            case IProjectItemData_1.ProjectItemType.material:
                return ["materials"];
        }
        return [];
    }
}
exports.default = ProjectItemUtilities;

//# sourceMappingURL=../maps/app/ProjectItemUtilities.js.map
