"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuickSearchModule = void 0;
const tslib_1 = require("tslib");
const AdaptableModuleBase_1 = require("./AdaptableModuleBase");
const ModuleConstants = tslib_1.__importStar(require("../Utilities/Constants/ModuleConstants"));
const QuickSearchStatusBarContent_1 = require("../View/QuickSearch/QuickSearchStatusBarContent");
const QuickSearchRedux_1 = require("../Redux/ActionsReducers/QuickSearchRedux");
class QuickSearchModule extends AdaptableModuleBase_1.AdaptableModuleBase {
    constructor(api) {
        super(ModuleConstants.QuickSearchModuleId, ModuleConstants.QuickSearchFriendlyName, 'search-table', 'QuickSearchPopup', 'Quickly highlight all cells in the grid that contain matching query text', api);
    }
    getAgGridModuleDependencies() {
        return ['FindModule'];
    }
    getViewProperties() {
        return {
            getStatusBarPanelProps() {
                return {
                    content: QuickSearchStatusBarContent_1.QuickSearchStatusBarContent,
                };
            },
        };
    }
    onAdaptableReady() {
        const { api } = this;
        const { internalApi, agGridApi } = api;
        // Check for AG Grid QuickFilterModule if running Filter After Quick Search
        if (api.optionsApi.getQuickSearchOptions().filterGridAfterQuickSearch) {
            if (!api.internalApi.getAgGridModulesAdapter().isAgGridModuleRegistered('QuickFilterModule')) {
                api.consoleError('The AG Grid "GridFilter" Module is required if running Quick Search as Filter; Quick Search will run but no Filters will be applied');
            }
        }
        const isServerSideRowModel = agGridApi.getGridOption('rowModelType') === 'serverSide';
        if (isServerSideRowModel &&
            internalApi.getAdaptableState().QuickSearch.CellMatchStyle === undefined) {
            // for server side row model,
            // let's setup some defaults if there are no styles set
            // as there are no defaults in the AG Grid find functionality (as it only works for non ssrm)
            // so we need to set the defaults here
            this.api.internalApi.dispatchReduxAction((0, QuickSearchRedux_1.QuickSearchSetCellMatchingStyle)(QuickSearchRedux_1.QUICK_SEARCH_SET_CELL_MATCHING_STYLE_DEFAULT));
        }
    }
}
exports.QuickSearchModule = QuickSearchModule;
