import { getProp } from "../objects/get-prop";
import { checkPermission } from "../permissions/checkPermission";
import { convertItemToContentPortal } from "./convertItemToContentPortal";
import { convertItemToContentHubIndex } from "./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
 */
export const convertItemToContent = async (item, requestOptions, enrichments) => {
    const context = getProp(requestOptions, "context");
    let codePath = "hubIndexer";
    if (context) {
        const chk = checkPermission("hub:content:fetch:portal", context);
        if (chk.access) {
            codePath = "portal";
        }
    }
    let hubContent;
    if (codePath === "portal") {
        hubContent = await convertItemToContentPortal(item, requestOptions, enrichments);
    }
    else {
        hubContent = await convertItemToContentHubIndex(item, requestOptions, enrichments);
    }
    return hubContent;
};
//# sourceMappingURL=convertItemToContent.js.map