"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContentTypeInfo = void 0;
const system_settings_1 = require("@ewizardjs/system-settings");
const content_checker_1 = require("@ewizardjs/content-checker");
const content_types_1 = require("@ewizardjs/content-types");
function getContentType(cb) {
    return (path) => {
        return (0, system_settings_1.getByPath)(path, 'content.type')
            .then((contentType) => {
            if (isNoValidateContentType(contentType)) {
                return contentType;
            }
            return (0, content_checker_1.validateEwizardContent)(path).then(() => Promise.resolve(contentType));
        })
            .then(cb);
    };
}
exports.default = getContentType;
function getContentTypeInfo(cb) {
    return (path) => {
        return (0, system_settings_1.getByPath)(path, 'content')
            .then(({ type, subtype, brief }) => {
            const content = { type, subtype };
            if (brief) {
                content.subtype = content.type;
                content.type = content_types_1.ContentTypes.BRIEF;
            }
            if (isNoValidateContentType(content.type)) {
                return content;
            }
            return (0, content_checker_1.validateEwizardContent)(path).then(() => Promise.resolve(content));
        })
            .then(cb);
    };
}
exports.getContentTypeInfo = getContentTypeInfo;
function isNoValidateContentType(contentType) {
    return contentType === content_types_1.ContentTypes.COMPONENT || contentType === content_types_1.ContentTypes.BLOCK;
}
//# sourceMappingURL=getContentType.js.map