"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SearchTextInput = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const components_1 = require("@gravity-ui/components");
const icons_1 = require("@gravity-ui/icons");
const uikit_1 = require("@gravity-ui/uikit");
const search_1 = require("../../../i18n/search/index.js");
const qa_1 = require("../qa.js");
const SearchCounter_1 = require("./SearchCounter.js");
const SearchTextInput = function SearchTextInput({ counter, onFindNext, onFindPrevious, ...inputProps }) {
    const handleKeyDown = (0, react_1.useCallback)((event) => {
        if (event.key === 'Enter') {
            if (event.shiftKey)
                onFindPrevious();
            else
                onFindNext();
        }
    }, [onFindNext, onFindPrevious]);
    return ((0, jsx_runtime_1.jsx)(components_1.DelayedTextInput, { size: "l", qa: qa_1.SearchQA.FindInput, onKeyDown: handleKeyDown, endContent: Boolean(inputProps.value) && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [counter && (0, jsx_runtime_1.jsx)(SearchCounter_1.SearchCounterText, { counter: counter, className: (0, uikit_1.sp)({ px: 1 }) }), (0, jsx_runtime_1.jsx)(uikit_1.Button, { size: "m", view: "flat-secondary", onClick: onFindPrevious, "aria-label": (0, search_1.i18n)('action_prev'), qa: qa_1.SearchQA.PrevBtn, children: (0, jsx_runtime_1.jsx)(uikit_1.ButtonIcon, { children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.ChevronUp }) }) }), (0, jsx_runtime_1.jsx)(uikit_1.Button, { size: "m", view: "flat-secondary", onClick: onFindNext, className: (0, uikit_1.sp)({ ml: 1 }), "aria-label": (0, search_1.i18n)('action_next'), qa: qa_1.SearchQA.NextBtn, children: (0, jsx_runtime_1.jsx)(uikit_1.ButtonIcon, { children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.ChevronDown }) }) })] })), ...inputProps }));
};
exports.SearchTextInput = SearchTextInput;
//# sourceMappingURL=SearchTextInput.js.map
