import { isVNode as _isVNode } from "vue";
import { createVNode as _createVNode } from "vue";
import { Dropdown, Avatar } from 'ant-design-vue';
import { AppMenu } from '@antd-vue/pro-layout';
import { getRenderComponent, PropTypes, withInstall } from '../utils';
import { CaretDownOutlined } from '@ant-design/icons-vue';

function _isSlot(s) {
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
}

var AvatarDropdown = function AvatarDropdown(props, _ref) {
  var _slot;

  var emit = _ref.emit,
      slots = _ref.slots;
  var user = props.user,
      _props$menus = props.menus,
      menus = _props$menus === void 0 ? [] : _props$menus,
      defaultAvatar = props.defaultAvatar,
      trigger = props.trigger;
  var overlay = getRenderComponent('default', props, slots, _createVNode(AppMenu, {
    "class": 'avatar-menu',
    "menus": menus,
    "theme": 'light',
    "onClick": function onClick(menu) {
      emit('menuClick', menu);
    }
  }, null), {
    propsArgs: [menus],
    slotArg: menus
  });
  return _createVNode(Dropdown, {
    "overlay": overlay,
    "trigger": trigger
  }, _isSlot(_slot = _createVNode("span", null, [_createVNode(Avatar, {
    "size": "small",
    "class": 'avatar',
    "src": (user === null || user === void 0 ? void 0 : user.avatar) || defaultAvatar,
    "alt": "avatar"
  }, null), _createVNode("span", {
    "class": 'name'
  }, [(user === null || user === void 0 ? void 0 : user.name) || (user === null || user === void 0 ? void 0 : user.realName)]), _createVNode(CaretDownOutlined, {
    "class": 'down'
  }, null)])) ? _slot : {
    default: function _default() {
      return [_slot];
    }
  });
};

AvatarDropdown.displayName = 'AvatarDropdown';
AvatarDropdown.props = {
  user: {
    type: Object,
    default: function _default() {
      return {
        name: '演示用户'
      };
    }
  },
  menus: {
    type: Array
  },
  defaultAvatar: PropTypes.string.def('https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png'),
  trigger: {
    type: [Array],
    default: function _default() {
      return ['hover'];
    }
  }
};
AvatarDropdown.emits = ['menuClick'];
export default withInstall(AvatarDropdown);