import { withoutDefaults } from '@wix/bex-core';
import { cairoFilterToggled, cairoSearchResults } from '@wix/bex-core/bi';
import { action } from 'mobx';
export class NestedTableFlatModeStateBIReporter {
    constructor(state) {
        this._createReportSearchResults = action(() => {
            const { state } = this;
            const { query } = state;
            this.reportBi(withoutDefaults(cairoFilterToggled)({
                filterName: 'search',
                origin: 'toolbar',
                actionType: 'add',
                filterValue: query.search.value,
                numFiltersActive: query.activeFiltersCount,
                filteredListSize: this.state.wrapper.nestedCollection._fetchAllTotal,
                currentFilters: JSON.stringify(query.filtersKey),
            }));
            const startTime = performance.now();
            const searchTerm = query.search.value;
            return action(() => {
                this.reportBi(withoutDefaults(cairoSearchResults)({
                    searchTerm,
                    searchResultsCnt: this.state.wrapper.nestedCollection._fetchAllTotal,
                    loadingTime: Math.round(performance.now() - startTime),
                }));
            });
        });
        this.state = state;
    }
    get reportBi() {
        return this.state.wrapper.reportBi;
    }
}
//# sourceMappingURL=NestedTableFlatModeStateBIReporter.js.map