import { fetchEditableContentEnrichments } from "./_internal/fetchEditableContentEnrichments";
import { normalizeItemType } from "./compose";
import { setProp } from "../objects/set-prop";
import { fetchContent } from "./fetchContent";
import { convertItemToContent } from "./convertItemToContent";
/**
 * fetch a content entity by identifier
 * Currently used in arcgis-hub-add-content component, and the Ember content service
 * @param identifier
 * @param requestOptions
 * @returns content entity
 */
export const fetchHubContent = async (identifier, requestOptions, enrichments) => {
    // NOTE: b/c we have to support slugs, we use fetchContent() to get the item
    // by telling it to not fetch any enrichments. We then can fetch enrichments
    // as needed after we have the item
    const options = Object.assign(Object.assign({}, requestOptions), { enrichments: [] });
    const { item } = await fetchContent(identifier, options);
    const editableContentEnrichments = await fetchEditableContentEnrichments(item, requestOptions, enrichments);
    // we must normalize the underlying item type to account
    // for older items (e.g. sites that are type "Web Mapping
    // Application") before we map the model to a Hub Entity
    const type = normalizeItemType(item);
    setProp("type", type, item);
    return convertItemToContent(item, requestOptions, editableContentEnrichments);
};
//# sourceMappingURL=fetchHubContent.js.map