import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ActionTooltip, Button, DropdownMenu } from '@gravity-ui/uikit';
import { cn } from "../../../../classname.js";
import { i18n } from "../../../../i18n/gpt/dialog/index.js";
import { gptHotKeys } from "../constants.js";
import { useGptHotKeys } from "../hooks/useGptHotKeys.js";
import { usePresetList } from "../hooks/usePresetList.js";
import "./Presetlist.css";
export const cnGptDialogPresetList = cn('gpt-dialog-preset-list');
const PresetItem = ({ preset, onPresetClick, disablePromptPresets, hotKey, }) => {
    useGptHotKeys(hotKey, () => {
        onPresetClick(preset.data);
    }, { enableOnFormTags: true, enableOnContentEditable: true });
    return (_jsx(ActionTooltip, { title: preset.display, hotkey: hotKey, children: _jsx(Button, { className: cnGptDialogPresetList('preset'), view: "normal", size: "m", disabled: disablePromptPresets, onClick: () => onPresetClick(preset.data), children: preset.display }) }));
};
export const PresetList = ({ disablePromptPresets, promptPresets, onPresetClick, }) => {
    const { presetsContainerRef, visiblePresets, hiddenPresets, showMoreButton, measured } = usePresetList({
        promptPresets,
        onPresetClick,
    });
    return (_jsxs("div", { className: cnGptDialogPresetList({ measured }), ref: presetsContainerRef, children: [visiblePresets.map((preset, index) => (_jsx(PresetItem, { preset: preset, hotKey: preset.hotKey || gptHotKeys.presetsKey(String(index + 1)), disablePromptPresets: disablePromptPresets, onPresetClick: onPresetClick }, preset.display))), showMoreButton && (_jsx(DropdownMenu, { switcherWrapperClassName: cnGptDialogPresetList('more-button-wrapper'), switcher: _jsx(Button, { className: cnGptDialogPresetList('more-button'), view: "normal", size: "m", children: i18n('more') }), items: hiddenPresets }))] }));
};
//# sourceMappingURL=PresetList.js.map
