"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertItemToContent = void 0;
const get_prop_1 = require("../objects/get-prop");
const checkPermission_1 = require("../permissions/checkPermission");
const convertItemToContentPortal_1 = require("./convertItemToContentPortal");
const convertItemToContentHubIndex_1 = require("./fetchContentHubIndex/convertItemToContentHubIndex");
/**
 * Convert a content item to an IHubEditableContent
 * Currently a facade that routes to either
 * convertItemToContentPortal or convertItemToContentHubIndex
 * depending on gating
 * @param item
 * @param requestOptions
 * @param enrichments
 * @returns
 */
const convertItemToContent = async (item, requestOptions, enrichments) => {
    const context = (0, get_prop_1.getProp)(requestOptions, "context");
    let codePath = "hubIndexer";
    if (context) {
        const chk = (0, checkPermission_1.checkPermission)("hub:content:fetch:portal", context);
        if (chk.access) {
            codePath = "portal";
        }
    }
    let hubContent;
    if (codePath === "portal") {
        hubContent = await (0, convertItemToContentPortal_1.convertItemToContentPortal)(item, requestOptions, enrichments);
    }
    else {
        hubContent = await (0, convertItemToContentHubIndex_1.convertItemToContentHubIndex)(item, requestOptions, enrichments);
    }
    return hubContent;
};
exports.convertItemToContent = convertItemToContent;
//# sourceMappingURL=convertItemToContent.js.map