"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useQuickSearchDebounced = void 0;
const tslib_1 = require("tslib");
const react_1 = require("react");
const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
const useQuickSearchDebounced = (props) => {
    const [searchText, setSearchText] = (0, react_1.useState)(props.QuickSearchText ?? '');
    const debouncedRunQuickSearch = (0, react_1.useMemo)(() => (0, debounce_1.default)(props.onRunQuickSearch, GeneralConstants_1.QUICK_SEARCH_DEBOUNCE_TIME), [props.onRunQuickSearch]);
    (0, react_1.useEffect)(() => {
        setSearchText(props.QuickSearchText);
    }, [props.QuickSearchText]);
    const executeSearch = (searchText) => {
        setSearchText(searchText);
        debouncedRunQuickSearch(searchText);
    };
    return [searchText, executeSearch];
};
exports.useQuickSearchDebounced = useQuickSearchDebounced;
