import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2020-2026 GoodData Corporation
import cx from "classnames";
import { injectIntl } from "react-intl";
import { v4 as uuid } from "uuid";
import { Bubble } from "../Bubble/Bubble.js";
import { BubbleHoverTrigger } from "../Bubble/BubbleHoverTrigger.js";
import { Button } from "../Button/Button.js";
function CoreHeaderDataMenu({ intl, onMenuItemClick, dataMenuItems, className }) {
    const renderSection = (items) => {
        return items.map((item) => {
            const { isDisable, tooltipText, isActive, className, key, onClick } = item;
            const classNames = cx(`gd-button-primary ${className}`, {
                "is-active": !isDisable && isActive,
                "is-normal": !isDisable && !isActive,
            });
            const clickHandler = onClick || (() => onMenuItemClick(item));
            return (_jsx("li", { children: _jsxs(BubbleHoverTrigger, { tagName: "div", hideDelay: 100, showDelay: 100, className: "gd-bubble-trigger-data-menu", children: [
                        _jsx(Button, { onClick: clickHandler, className: classNames, value: intl.formatMessage({ id: `${key}` }), disabled: isDisable, iconLeft: item.iconName }), tooltipText && isDisable ? (_jsx(Bubble, { alignPoints: [{ align: "bc tc" }, { align: "bc tl" }, { align: "bc tr" }], children: tooltipText })) : null] }) }, key));
        });
    };
    const dataMenuClassName = cx("gd-data-header-menu-section", className);
    return (_jsx("div", { className: "gd-data-header-menu-wrapper", children: _jsx("ul", { className: dataMenuClassName, children: renderSection(dataMenuItems) }, `section-${uuid()}`) }));
}
/**
 * @internal
 */
export const HeaderDataMenu = injectIntl(CoreHeaderDataMenu);
