import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2023-2026 GoodData Corporation
import { useMemo } from "react";
import cx from "classnames";
import { isEmpty } from "lodash-es";
import { ShortenedText } from "@gooddata/sdk-ui-kit";
import { simplifyText } from "@gooddata/util";
import { AttributeListItemTooltip } from "./attributeListItemTooltip/AttributeListItemTooltip.js";
const TOOLTIP_ALIGN_POINT = [
    { align: "cr cl", offset: { x: 10, y: 0 } },
    { align: "cl cr", offset: { x: -10, y: 0 } },
];
export function AttributeListItem({ item, title, isLocationIconEnabled, onClick }) {
    const classNames = useMemo(() => {
        const isDisplayLocationIcon = isLocationIconEnabled && !isEmpty(item?.geoPinDisplayForms);
        return cx(`s-${simplifyText(item.attribute.title)}`, "gd-attribute-list-item", {
            "gd-list-item": true,
            "gd-list-item-shortened": true,
            "type-attribute": !isDisplayLocationIcon,
            "type-geo_attribute": isDisplayLocationIcon,
        });
    }, [item, isLocationIconEnabled]);
    return (_jsxs("div", { className: classNames, onClick: onClick, children: [
            _jsx(ShortenedText, { tooltipAlignPoints: TOOLTIP_ALIGN_POINT, children: getAttributeListItemTitle(item, title) }), _jsx(AttributeListItemTooltip, { item: item })
        ] }, item.attribute.id));
}
export const getAttributeListItemTitle = (item, title) => {
    return title ?? item.attribute.title;
};
//# sourceMappingURL=AttributeListItem.js.map