"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackType = void 0;
const BehaviorManifestDefinition_1 = require("./BehaviorManifestDefinition");
const ResourceManifestDefinition_1 = require("./ResourceManifestDefinition");
const SkinManifestDefinition_1 = require("./SkinManifestDefinition");
var PackType;
(function (PackType) {
    PackType[PackType["resource"] = 0] = "resource";
    PackType[PackType["behavior"] = 1] = "behavior";
    PackType[PackType["skin"] = 2] = "skin";
})(PackType = exports.PackType || (exports.PackType = {}));
class Pack {
    constructor(folderIn, packTypeIn) {
        this.folder = folderIn;
        this.type = packTypeIn;
    }
    ensureManifestFile() {
        if (this.manifestFile === undefined) {
            this.manifestFile = this.folder.ensureFile("manifest.json");
        }
        return this.manifestFile;
    }
    async ensureManifest() {
        if (this.manifest) {
            return this.manifest;
        }
        this.manifestFile = this.ensureManifestFile();
        if (this.type === PackType.behavior) {
            this.manifest = await BehaviorManifestDefinition_1.default.ensureOnFile(this.manifestFile);
        }
        else if (this.type === PackType.skin) {
            this.manifest = await SkinManifestDefinition_1.default.ensureOnFile(this.manifestFile);
        }
        else {
            this.manifest = await ResourceManifestDefinition_1.default.ensureOnFile(this.manifestFile);
        }
        return this.manifest;
    }
    static ensureOnFolder(folder, packType, project) {
        if (folder.manager === undefined) {
            const pack = new Pack(folder, packType);
            pack.project = project;
            pack.type = packType;
            return pack;
        }
        else {
            return folder.manager;
        }
    }
}
exports.default = Pack;

//# sourceMappingURL=../maps/minecraft/Pack.js.map
