"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _vue = require("vue");

var _antDesignVue = require("ant-design-vue");

var _proLayout = require("@antd-vue/pro-layout");

var _utils = require("../utils");

var _iconsVue = require("@ant-design/icons-vue");

function _isSlot(s) {
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !(0, _vue.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 = (0, _utils.getRenderComponent)('default', props, slots, (0, _vue.createVNode)(_proLayout.AppMenu, {
    "class": 'avatar-menu',
    "menus": menus,
    "theme": 'light',
    "onClick": function onClick(menu) {
      emit('menuClick', menu);
    }
  }, null), {
    propsArgs: [menus],
    slotArg: menus
  });
  return (0, _vue.createVNode)(_antDesignVue.Dropdown, {
    "overlay": overlay,
    "trigger": trigger
  }, _isSlot(_slot = (0, _vue.createVNode)("span", null, [(0, _vue.createVNode)(_antDesignVue.Avatar, {
    "size": "small",
    "class": 'avatar',
    "src": (user === null || user === void 0 ? void 0 : user.avatar) || defaultAvatar,
    "alt": "avatar"
  }, null), (0, _vue.createVNode)("span", {
    "class": 'name'
  }, [(user === null || user === void 0 ? void 0 : user.name) || (user === null || user === void 0 ? void 0 : user.realName)]), (0, _vue.createVNode)(_iconsVue.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: _utils.PropTypes.string.def('https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png'),
  trigger: {
    type: [Array],
    default: function _default() {
      return ['hover'];
    }
  }
};
AvatarDropdown.emits = ['menuClick'];

var _default2 = (0, _utils.withInstall)(AvatarDropdown);

exports.default = _default2;