"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _faChevronDown = require("@fortawesome/free-solid-svg-icons/faChevronDown");
var _button = require("../button");
var _useDropdownTrigger = require("../dropdown-menu/use-dropdown-trigger");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/**
  @midnight-gray-supported
  @alpine-light-supported
 */
const DropdownButtonTrigger = /*#__PURE__*/(0, _react.forwardRef)(({
  onClick,
  isOpen,
  isDisabled,
  testId,
  accentType,
  buttonProps = {},
  children,
  onKeyboardClick
}, ref) => {
  const {
    onMouseEnter,
    onMouseLeave,
    onMouseClick,
    onKeyDown
  } = (0, _useDropdownTrigger.useDropdownTrigger)({
    onMouseEnter: buttonProps.onMouseEnter,
    onMouseLeave: buttonProps.onMouseLeave,
    onClick,
    triggerOnClickHandler: (_, isKeyboard) => {
      if (isKeyboard) {
        onKeyboardClick?.();
      }
    },
    isOpen
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
    ref: ref,
    testId: testId,
    id: testId,
    onMouseEnter: onMouseEnter,
    onMouseLeave: onMouseLeave,
    onClick: onMouseClick,
    onKeyDown: onKeyDown,
    isDisabled: isDisabled,
    rightIcon: _faChevronDown.faChevronDown,
    accentType: accentType,
    ...buttonProps,
    className: (0, _classnames.default)(buttonProps.className, 'dropdown-button-trigger', isOpen && 'expanded'),
    children: children
  });
});
DropdownButtonTrigger.displayName = 'DropdownButtonTrigger';
var _default = exports.default = DropdownButtonTrigger;