import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { useCallback } from 'react';
import { DelayedTextInput } from '@gravity-ui/components';
import { ChevronDown, ChevronUp } from '@gravity-ui/icons';
import { Button, ButtonIcon, Icon, sp } from '@gravity-ui/uikit';
import { i18n } from "../../../i18n/search/index.js";
import { SearchQA } from "../qa.js";
import { SearchCounterText } from "./SearchCounter.js";
export const SearchTextInput = function SearchTextInput({ counter, onFindNext, onFindPrevious, ...inputProps }) {
    const handleKeyDown = useCallback((event) => {
        if (event.key === 'Enter') {
            if (event.shiftKey)
                onFindPrevious();
            else
                onFindNext();
        }
    }, [onFindNext, onFindPrevious]);
    return (_jsx(DelayedTextInput, { size: "l", qa: SearchQA.FindInput, onKeyDown: handleKeyDown, endContent: Boolean(inputProps.value) && (_jsxs(_Fragment, { children: [counter && _jsx(SearchCounterText, { counter: counter, className: sp({ px: 1 }) }), _jsx(Button, { size: "m", view: "flat-secondary", onClick: onFindPrevious, "aria-label": i18n('action_prev'), qa: SearchQA.PrevBtn, children: _jsx(ButtonIcon, { children: _jsx(Icon, { data: ChevronUp }) }) }), _jsx(Button, { size: "m", view: "flat-secondary", onClick: onFindNext, className: sp({ ml: 1 }), "aria-label": i18n('action_next'), qa: SearchQA.NextBtn, children: _jsx(ButtonIcon, { children: _jsx(Icon, { data: ChevronDown }) }) })] })), ...inputProps }));
};
//# sourceMappingURL=SearchTextInput.js.map
