import React, { forwardRef } from "react";
import { cx } from "../../../../../../utils";
import { classes } from "../../../../Select.tokens";
import { getButtonLabel, getItemId, sizeToIconSize } from "../../../../utils";
import { StyledButton, StyledArrow, Label, ButtonWrapper, IconArrowWrapper } from "./Button.styles";
export const Button = /*#__PURE__*/ forwardRef(({ opened, value, valueToItemMap, onKeyDown, label, size, disabled, renderValue, treeId, activeDescendantItemValue, multiselect, isTargetAmount }, ref)=>{
    const withArrowInverse = opened ? classes.arrowInverse : undefined;
    return /*#__PURE__*/ React.createElement(ButtonWrapper, null, /*#__PURE__*/ React.createElement(StyledButton, {
        ref: ref,
        stretching: "filled",
        onKeyDown: onKeyDown,
        className: opened ? classes.selectWithoutBoxShadow : undefined,
        disabled: disabled,
        contentRight: /*#__PURE__*/ React.createElement(IconArrowWrapper, null, /*#__PURE__*/ React.createElement(StyledArrow, {
            size: sizeToIconSize(size),
            color: "inherit",
            className: cx(classes.selectTargetArrow, withArrowInverse)
        })),
        role: "combobox",
        "aria-autocomplete": "list",
        "aria-controls": `${treeId}_tree_level_1`,
        "aria-expanded": opened,
        "aria-activedescendant": activeDescendantItemValue ? getItemId(treeId, activeDescendantItemValue) : '',
        "aria-label": label
    }, /*#__PURE__*/ React.createElement(Label, null, getButtonLabel({
        value,
        valueToItemMap,
        label,
        renderValue,
        multiselect,
        isTargetAmount
    }))));
});
