import { jsx as _jsx } from "react/jsx-runtime";
import cx from "classnames";
import { Button } from "../Button/Button.js";
/**
 * @internal
 */
export function DropdownButton({ id, className, accessibilityConfig, value, title = value, disabled, isOpen, isSmall = true, iconLeft, isFullWidth = false, onClick, children, dropdownId, buttonRef, }) {
    const { ariaLabel, ariaLabelledBy, ariaDescribedBy, popupType, role, ariaExpanded, ariaControls } = accessibilityConfig ?? {};
    const effectiveAriaExpanded = ariaExpanded ?? isOpen ?? false;
    const buttonClasses = cx("gd-button-primary", "button-dropdown", "dropdown-button", {
        "gd-button-small": isSmall,
        "is-dropdown-open": isOpen,
        "is-active": isOpen,
        "is-full-width": isFullWidth,
    }, className);
    const buttonAccessibilityConfig = (dropdownId
        ? {
            isExpanded: isOpen,
            popupId: dropdownId,
            ariaLabel,
            ariaLabelledBy,
            ariaExpanded: effectiveAriaExpanded,
            ariaDescribedBy,
            ariaControls: ariaControls ?? dropdownId,
            role: role ?? "combobox",
            popupType,
        }
        : {
            ariaLabel,
            ariaLabelledBy,
            ariaDescribedBy,
            role: role ?? "combobox",
        });
    return (_jsx(Button, { id: id, accessibilityConfig: buttonAccessibilityConfig, title: title && typeof title === "string" ? title : undefined, className: buttonClasses, value: value, iconLeft: iconLeft, iconRight: isOpen ? "gd-icon-navigateup" : "gd-icon-navigatedown", disabled: disabled, onClick: onClick, ref: buttonRef, children: children }));
}
