"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hubSearchItems = hubSearchItems;
const utils_1 = require("../utils");
const getOgcCollectionUrl_1 = require("./hubSearchItemsHelpers/getOgcCollectionUrl");
const searchOgcAggregations_1 = require("./hubSearchItemsHelpers/searchOgcAggregations");
const searchOgcItems_1 = require("./hubSearchItemsHelpers/searchOgcItems");
/**
 * @private
 * Execute item search against the Hub API
 * @param query
 * @param options
 * @returns
 */
async function hubSearchItems(query, options) {
    var _a;
    const expanded = (0, utils_1.expandPortalQuery)(query);
    if ((_a = options.aggFields) === null || _a === void 0 ? void 0 : _a.length) {
        return (0, searchOgcAggregations_1.searchOgcAggregations)(expanded, options);
    }
    const url = `${(0, getOgcCollectionUrl_1.getOgcCollectionUrl)(expanded, options)}/items`;
    return (0, searchOgcItems_1.searchOgcItems)(url, expanded, options);
}
//# sourceMappingURL=hubSearchItems.js.map