import { expandPortalQuery } from "../utils";
import { getOgcCollectionUrl } from "./hubSearchItemsHelpers/getOgcCollectionUrl";
import { searchOgcAggregations } from "./hubSearchItemsHelpers/searchOgcAggregations";
import { searchOgcItems } from "./hubSearchItemsHelpers/searchOgcItems";
/**
 * @private
 * Execute item search against the Hub API
 * @param query
 * @param options
 * @returns
 */
export async function hubSearchItems(query, options) {
    var _a;
    const expanded = expandPortalQuery(query);
    if ((_a = options.aggFields) === null || _a === void 0 ? void 0 : _a.length) {
        return searchOgcAggregations(expanded, options);
    }
    const url = `${getOgcCollectionUrl(expanded, options)}/items`;
    return searchOgcItems(url, expanded, options);
}
//# sourceMappingURL=hubSearchItems.js.map