'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var iconsVue = require('@ant-design/icons-vue');
require('../../../utils/index.cjs');
var index = require('../../button/index.cjs');
var useConfigInject = require('../../config-provider/src/hooks/useConfigInject.cjs');
var index$1 = require('../style/index.cjs');
var props = require('./props.cjs');
var Dropdown = require('./Dropdown.cjs');
var initDefaultProps = require('../../../utils/vue/initDefaultProps.cjs');
var _class = require('../../../utils/dom/class.cjs');

const ButtonGroup = index.Button.Group;
var ADropdownButton = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ADropdownButton",
  inheritAttrs: false,
  __ANT_BUTTON: true,
  props: initDefaultProps.initDefaultProps(props.dropdownButtonProps(), {
    trigger: "hover",
    placement: "bottomRight",
    type: "default"
  }),
  // emits: ['click', 'visibleChange', 'update:visible'],s
  slots: Object,
  setup(props, {
    slots,
    attrs,
    emit
  }) {
    const handleVisibleChange = (val) => {
      emit("update:visible", val);
      emit("visibleChange", val);
      emit("update:open", val);
      emit("openChange", val);
    };
    const {
      prefixCls,
      direction,
      getPopupContainer
    } = useConfigInject.default("dropdown", props);
    const buttonPrefixCls = vue.computed(() => `${prefixCls.value}-button`);
    const [wrapSSR, hashId] = index$1.default(prefixCls);
    return () => {
      var _a, _b;
      const {
        type = "default",
        disabled,
        danger,
        loading,
        htmlType,
        class: className = "",
        overlay = (_a = slots.overlay) == null ? void 0 : _a.call(slots),
        trigger,
        align,
        open,
        visible,
        onVisibleChange: _onVisibleChange,
        placement = direction.value === "rtl" ? "bottomLeft" : "bottomRight",
        href,
        title,
        icon = ((_b = slots.icon) == null ? void 0 : _b.call(slots)) || vue.createVNode(iconsVue.EllipsisOutlined, null, null),
        mouseEnterDelay,
        mouseLeaveDelay,
        overlayClassName,
        overlayStyle,
        destroyPopupOnHide,
        onClick,
        "onUpdate:open": _updateVisible,
        ...restProps
      } = {
        ...props,
        ...attrs
      };
      const dropdownProps = {
        align,
        disabled,
        trigger: disabled ? [] : trigger,
        placement,
        getPopupContainer: getPopupContainer == null ? void 0 : getPopupContainer.value,
        onOpenChange: handleVisibleChange,
        mouseEnterDelay,
        mouseLeaveDelay,
        open: open != null ? open : visible,
        overlayClassName,
        overlayStyle,
        destroyPopupOnHide
      };
      const leftButton = vue.createVNode(index.Button, {
        "danger": danger,
        "type": type,
        "disabled": disabled,
        "loading": loading,
        "onClick": onClick,
        "htmlType": htmlType,
        "href": href,
        "title": title
      }, {
        default: slots.default
      });
      const rightButton = vue.createVNode(index.Button, {
        "danger": danger,
        "type": type,
        "icon": icon
      }, null);
      return wrapSSR(vue.createVNode(ButtonGroup, {
        ...restProps,
        "class": _class.classNames(buttonPrefixCls.value, className, hashId.value)
      }, {
        default: () => [slots.leftButton ? slots.leftButton({
          button: leftButton
        }) : leftButton, vue.createVNode(Dropdown.default, dropdownProps, {
          default: () => [slots.rightButton ? slots.rightButton({
            button: rightButton
          }) : rightButton],
          overlay: () => overlay
        })]
      }));
    };
  }
});

exports.default = ADropdownButton;
//# sourceMappingURL=DropdownButton.cjs.map
