import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2025-2026 GoodData Corporation
import { bem } from "../@utils/bem.js";
import { UiIcon } from "../UiIcon/UiIcon.js";
const { e } = bem("gd-ui-kit-chip");
export function ChipContent({ label, tag, iconBefore, iconAfter, iconColor = "primary", onClick, onKeyDown, isActive, isLocked, isExpandable, isDisabled, isDeletable, accessibilityConfig, dataTestId, buttonRef, styleObj, }) {
    const { isExpanded, popupId, popupType, ariaHaspopup, ariaLabel, ariaLabelledBy, ariaControls } = accessibilityConfig ?? {};
    const isDropdownTrigger = isExpandable || isExpanded !== undefined || popupId !== undefined;
    const ariaDropdownProps = isDropdownTrigger
        ? {
            ...(popupId && isExpanded ? { "aria-controls": popupId } : {}),
            ...(!popupId && isExpanded && ariaControls ? { "aria-controls": ariaControls } : {}),
            ...(popupId ? { "aria-haspopup": popupType ?? ariaHaspopup ?? !!popupId } : {}),
            ...(isExpanded === undefined ? { "aria-expanded": isActive } : { "aria-expanded": isExpanded }),
        }
        : {};
    return (_jsxs("button", { "data-testid": dataTestId, className: e("trigger", { isDeletable, isActive, isLocked: isLocked || isDisabled }), disabled: isDisabled, onClick: isLocked ? undefined : onClick, onKeyDown: onKeyDown, style: { ...styleObj }, ref: buttonRef, "aria-disabled": isLocked || isDisabled, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...ariaDropdownProps, children: [iconBefore ? (_jsx("span", { className: e("icon-before"), children: _jsx(UiIcon, { type: iconBefore, color: iconColor, size: 15 }) })) : null, _jsx("span", { className: e("label"), children: label }), tag ? _jsx("span", { className: e("tag"), children: tag }) : null, isDisabled ? null : (_jsx(_Fragment, { children: isLocked ? (_jsx("span", { className: e("icon-lock"), children: _jsx(UiIcon, { type: "lock", color: "complementary-6", size: 14 }) })) : isExpandable ? (_jsx("span", { className: e("icon-chevron", { isActive }), children: _jsx(UiIcon, { type: isActive ? "chevronUp" : "chevronDown", color: "complementary-7", size: 8 }) })) : iconAfter ? (_jsx("span", { className: e("icon-after"), children: _jsx(UiIcon, { type: iconAfter, color: iconColor, size: 15 }) })) : null }))] }));
}
