"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Suggestions = Suggestions;
const jsx_runtime_1 = require("react/jsx-runtime");
const icons_1 = require("@gravity-ui/icons");
const uikit_1 = require("@gravity-ui/uikit");
const cn_1 = require("../../../utils/cn.js");
const ActionButton_1 = require("../../atoms/ActionButton/index.js");
require("./Suggestions.css");
const b = (0, cn_1.block)('suggestions');
/**
 * Suggestions component displays a group of clickable suggestion buttons
 * arranged in either horizontal (grid) or vertical (list) layout
 *
 * @param props - Component props
 * @returns React component
 */
function Suggestions(props) {
    const { items, onClick, title, layout = 'list', textAlign = 'left', wrapText = false, className, qa, } = props;
    const handleClick = (item) => {
        onClick(item.title, item.id);
    };
    const renderButton = (item, index) => {
        return ((0, jsx_runtime_1.jsx)(ActionButton_1.ActionButton, { tooltipTitle: wrapText ? undefined : item.title, size: "m", view: item.view || 'outlined', onClick: () => handleClick(item), className: b('button', { layout }), width: "auto", children: (0, jsx_runtime_1.jsxs)("div", { className: b('button-content', {
                    layout,
                    'text-align': item.icon ? undefined : textAlign,
                }), children: [item.icon === 'left' && ((0, jsx_runtime_1.jsx)("div", { className: b('button-icon'), children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.ChevronLeft, size: 16 }) })), (0, jsx_runtime_1.jsx)(uikit_1.Text, { as: "div", className: b(wrapText ? 'button-text-wrap' : 'button-text'), children: item.title }), item.icon === 'right' && ((0, jsx_runtime_1.jsx)("div", { className: b('button-icon'), children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.ChevronRight, size: 16 }) }))] }) }, item.id || index));
    };
    return ((0, jsx_runtime_1.jsxs)("div", { className: b('container', className), "data-qa": qa, children: [title && ((0, jsx_runtime_1.jsx)("div", { className: b('title'), children: typeof title === 'string' ? ((0, jsx_runtime_1.jsx)(uikit_1.Text, { variant: "body-1", color: "primary", children: title })) : (title) })), (0, jsx_runtime_1.jsx)("div", { className: b({ layout }), children: items.map((item, index) => renderButton(item, index)) })] }));
}
//# sourceMappingURL=Suggestions.js.map
