import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2021-2026 GoodData Corporation
import cx from "classnames";
import { useIntl } from "react-intl";
import { Bubble, BubbleHoverTrigger } from "@gooddata/sdk-ui-kit";
import { simplifyText } from "@gooddata/util";
const tooltipAlignPoints = [
    { align: "cl cr", offset: { x: 0, y: -2 } },
    { align: "cr cl", offset: { x: 0, y: 10 } },
];
export const getTooltip = (intl, accessibilityLimitation) => {
    switch (accessibilityLimitation) {
        case "forbidden":
            return intl.formatMessage({ id: "configurationPanel.drillConfig.forbiddenDashboard.tooltip" });
        case "notShared":
            return intl.formatMessage({ id: "configurationPanel.drillConfig.notSharedDashboard.tooltip" });
        default:
            return undefined;
    }
};
function DropdownItem({ onClick, accessibilityLimitation, title, isSelected = false, }) {
    const icon = accessibilityLimitation === undefined ? undefined : "gd-icon-circle-exclamation";
    const generatedTestClass = `s-dashboard-item s-${simplifyText(title)}`;
    const classNames = cx("gd-list-item gd-drill-dashboard-item", generatedTestClass, {
        "is-selected": isSelected,
    });
    return (_jsxs("div", { className: classNames, onClick: onClick, title: title, children: [icon ? _jsx("span", { className: cx("gd-list-icon", icon) }) : null, _jsx("span", { children: title })
        ] }));
}
export function DashboardListItem(props) {
    const { accessibilityLimitation } = props;
    const intl = useIntl();
    const tooltip = getTooltip(intl, accessibilityLimitation);
    if (!tooltip) {
        return _jsx(DropdownItem, { ...props });
    }
    return (_jsxs(BubbleHoverTrigger, { tagName: "div", showDelay: 200, hideDelay: 0, children: [
            _jsx(DropdownItem, { ...props }), _jsx(Bubble, { className: "bubble-primary", alignPoints: tooltipAlignPoints, children: tooltip })
        ] }));
}
//# sourceMappingURL=DashboardListItem.js.map