'use strict';

const applyFilterWithManager = require('./applyFilterWithManager-99cf7595.js');
require('./KlevuSearchSorting-3cce1bed.js');

/**
 * This modifier should be used in the case when user hits enter (or presses button) to see
 * all results from search.
 *
 * @category Modifier
 * @returns
 */
function sendSearchEvent(override) {
    return {
        klevuModifierId: "sendSearchEvent",
        onResult: (res, f) => {
            var _a;
            if (!f.params) {
                return res;
            }
            const { id, term } = f.params;
            if (!id || !term) {
                return res;
            }
            const meta = (_a = res.queriesById(id)) === null || _a === void 0 ? void 0 : _a.meta;
            if (!meta) {
                return res;
            }
            applyFilterWithManager.KlevuEvents.search({
                term,
                totalResults: meta.totalResultsFound,
                typeOfSearch: meta.typeOfSearch,
                override,
            });
            return res;
        },
    };
}

exports.sendSearchEvent = sendSearchEvent;

//# sourceMappingURL=sendSearchEvent-e3a2d35d.js.map