"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertItemToContentHubIndex = void 0;
const getDefaultEntitySettings_1 = require("../../discussions/api/settings/getDefaultEntitySettings");
const settings_1 = require("../../discussions/api/settings/settings");
const fetchModelFromItem_1 = require("../../models/fetchModelFromItem");
const modelToHubEditableContent_1 = require("../modelToHubEditableContent");
/**
 * Convert an Item to an editable Hub Content object,
 * fetch any additional information that may be required
 */
const convertItemToContentHubIndex = async (item, requestOptions, enrichments) => {
    const [model, entitySettings] = await Promise.all([
        (0, fetchModelFromItem_1.fetchModelFromItem)(item, requestOptions),
        !requestOptions.isPortal
            ? (0, settings_1.fetchSettingV2)(Object.assign({ id: item.id }, requestOptions)).catch(() => (Object.assign({ id: null }, (0, getDefaultEntitySettings_1.getDefaultEntitySettings)("content"))))
            : null, // non-hub-indexer path
    ]);
    model.entitySettings = entitySettings;
    const content = (0, modelToHubEditableContent_1.modelToHubEditableContent)(model, requestOptions, enrichments);
    return content;
};
exports.convertItemToContentHubIndex = convertItemToContentHubIndex;
//# sourceMappingURL=convertItemToContentHubIndex.js.map