import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2026 GoodData Corporation
import { useMemo } from "react";
import cx from "classnames";
import { ShortenedText } from "@gooddata/sdk-ui-kit";
import { simplifyText } from "@gooddata/util";
const TOOLTIP_ALIGN_POINT = [
    { align: "cr cl", offset: { x: 10, y: 0 } },
    { align: "cl cr", offset: { x: -10, y: 0 } },
];
export function MetricListItem({ item, title, onClick }) {
    const classNames = useMemo(() => {
        return cx(`s-${simplifyText(item.measure.title)}`, "gd-attribute-list-item", {
            "gd-list-item": true,
            "gd-list-item-shortened": true,
            "type-metric": true,
            "is-disabled": !onClick,
        });
    }, [item, onClick]);
    return (_jsx("div", { className: classNames, onClick: onClick, children: _jsx(ShortenedText, { tooltipAlignPoints: TOOLTIP_ALIGN_POINT, children: getMetricListItemTitle(item, title) }) }));
}
export const getMetricListItemTitle = (item, title) => {
    return title ?? item.measure.title;
};
