"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const Structure_1 = require("../modules/Structure");
const system_settings_1 = require("@ewizardjs/system-settings");
const content_types_1 = require("@ewizardjs/content-types");
const Logger_1 = require("../modules/Logger");
const I18n_1 = require("../modules/I18n");
function updateStrucutreJson(presentationPath) {
    return __awaiter(this, void 0, void 0, function* () {
        const contentType = yield (0, system_settings_1.getByPath)(presentationPath, 'content.type');
        if (contentType === content_types_1.ContentTypes.EDETAILER) {
            try {
                const structure = new Structure_1.default(presentationPath);
                const v2Structure = yield structure.convertToStructureV2();
                return v2Structure;
            }
            catch (err) {
                Logger_1.default.error(I18n_1.default.error('STRUCTURE_JSON_UPDATE_FAILED'));
                return;
            }
        }
        Logger_1.default.error(I18n_1.default.error('NOT_SUPPORTED_CONTENT_TYPE'));
    });
}
exports.default = updateStrucutreJson;
//# sourceMappingURL=updateStructureJson.js.map