import { catalogContains } from "./catalogContains";
import { deepCatalogContains } from "./deepCatalogContains";
/**
 * Check which of the given matches are contained in the specified catalog.
 * Decorates each match with inCatalog: true|false, which the disambiguation
 * UX can then use to determine how to present the matches.
 * @param type
 * @param matches
 * @param catalog
 * @param context
 * @param path
 */
export async function matchesInCatalog(type, matches, catalog, context, path) {
    // check each match for containment
    const results = await Promise.all(matches.map(async (match) => {
        // if we got a path, use deepCatalogContains otherwise use catalogContains
        let isContained = false;
        if (path) {
            const deepResult = await deepCatalogContains(match.id, type, path, context, catalog);
            isContained = deepResult.isContained;
        }
        else {
            const catalogResult = await catalogContains(match.id, catalog, context, { hubEntityType: type });
            isContained = catalogResult.isContained;
        }
        return Object.assign(Object.assign({}, match), { inCatalog: isContained });
    }));
    return results;
}
//# sourceMappingURL=matchesInCatalog.js.map