/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import Vue from 'vue';
import { renderContent, renderTNodeJSX } from '../utils/render-tnode.js';
import { getClassPrefixMixins } from '../config-provider/config-receiver.js';
import mixins from '../utils/mixins.js';
import _Avatar from './avatar.js';
import props from './avatar-group-props.js';
import '@babel/runtime/helpers/typeof';
import '@vue/composition-api';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../_chunks/dep-67ff4010.js';
import '../config-provider/type.js';
import '../_chunks/dep-c89aafbb.js';
import '../image/index.js';
import '../utils/map-props.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import '../image/image.js';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/omit';
import 'lodash/isFunction';
import '@ldesign/icons-vue';
import '../_common/js/utils/observe.js';
import '../config-provider/useConfig.js';
import '../space/index.js';
import '../space/space.js';
import '../hooks/useConfig.js';
import '../space/props.js';
import '../space/style';
import '../space/type.js';
import '../image/props.js';
import '../image/style';
import '../image/type.js';
import './props.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var classPrefixMixins = getClassPrefixMixins("avatar");
var _AvatarGroup = mixins(classPrefixMixins).extend({
  name: "TAvatarGroup",
  components: {
    Avatar: _Avatar
  },
  props: _objectSpread({}, props),
  provide: function provide() {
    return {
      avatarGroup: this
    };
  },
  methods: {
    renderEllipsisAvatar: function renderEllipsisAvatar(children) {
      var h = this.$createElement;
      if ((children === null || children === void 0 ? void 0 : children.length) > this.max) {
        var content = this.setEllipsisContent(children);
        var outAvatar = children.slice(0, this.max);
        outAvatar.push(h(_Avatar, {
          "class": "".concat(this.componentName, "__collapse"),
          "attrs": {
            "size": this.size,
            "icon": this.isIcon() ? this.collapseAvatar : null
          }
        }, [content]));
        return [outAvatar];
      }
      return [children];
    },
    setEllipsisContent: function setEllipsisContent(children) {
      var content = "";
      if (this.collapseAvatar) {
        if (!this.isIcon()) content = renderContent(this, "collapseAvatar", "content");
      } else {
        content = "+".concat(children.length - this.max);
      }
      return content;
    },
    isIcon: function isIcon() {
      var content = renderTNodeJSX(this, "collapseAvatar");
      return (content === null || content === void 0 ? void 0 : content.context) instanceof Vue;
    }
  },
  render: function render() {
    var _ref;
    var h = arguments[0];
    var $scopedSlots = this.$scopedSlots;
    var children = $scopedSlots["default"] && $scopedSlots["default"](null);
    var _this$$props = this.$props,
      cascading = _this$$props.cascading,
      max = _this$$props.max;
    var groupClass = ["".concat(this.componentName, "-group"), (_ref = {}, _defineProperty(_ref, "".concat(this.componentName, "--offset-right"), cascading === "right-up"), _defineProperty(_ref, "".concat(this.componentName, "--offset-left"), cascading === "left-up"), _ref)];
    var content = [children];
    if (max && max >= 0) content = [this.renderEllipsisAvatar(children)];
    return h("div", {
      "class": groupClass
    }, [content]);
  }
});

export { _AvatarGroup as default };
//# sourceMappingURL=group.js.map
