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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { isVNode, defineComponent, provide, createVNode } from 'vue';
import { useTNodeJSX } from '../hooks/tnode.js';
import { usePrefixClass } from '../hooks/useConfig.js';
import props from './avatar-group-props.js';
import _Avatar from './avatar.js';
import 'lodash/isFunction';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/isString';
import 'lodash/isObject';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-512eb181.js';
import 'dayjs';
import '../_chunks/dep-ac28b67c.js';
import '../config-provider/type.js';
import '../image/index.js';
import '../utils/withInstall.js';
import '../image/image.js';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/omit';
import '@ldesign/icons-vue-next';
import '../_common/js/utils/observe.js';
import '../space/index.js';
import '../space/space.js';
import 'lodash/isNumber';
import '../hooks/slot.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 _isSlot(s) {
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
}
var _AvatarGroup = defineComponent({
  name: "TAvatarGroup",
  props: props,
  setup: function setup(props2) {
    provide("avatarGroup", props2);
    var renderTNodeJSX = useTNodeJSX();
    var AVATAR_NAME = usePrefixClass("avatar");
    var COMPONENT_NAME = usePrefixClass("avatar-group");
    var renderEllipsisAvatar = function renderEllipsisAvatar(children) {
      if ((children === null || children === void 0 ? void 0 : children.length) > props2.max) {
        var content = getEllipsisContent(children);
        var outAvatar = children.slice(0, props2.max);
        outAvatar.push(createVNode(_Avatar, {
          "class": "".concat(AVATAR_NAME.value, "__collapse"),
          "size": props2.size
        }, _isSlot(content) ? content : {
          "default": function _default() {
            return [content];
          }
        }));
        return [outAvatar];
      }
      return [children];
    };
    var getEllipsisContent = function getEllipsisContent(children) {
      return renderTNodeJSX("collapseAvatar") || "+".concat(children.length - props2.max);
    };
    return function () {
      var _ref;
      var children = renderTNodeJSX("default");
      var cascading = props2.cascading,
        max = props2.max;
      var groupClass = ["".concat(COMPONENT_NAME.value), (_ref = {}, _defineProperty(_ref, "".concat(AVATAR_NAME.value, "--offset-right"), cascading === "right-up"), _defineProperty(_ref, "".concat(AVATAR_NAME.value, "--offset-left"), cascading === "left-up"), _ref)];
      var content = max && max >= 0 ? [renderEllipsisAvatar(children)] : [children];
      return createVNode("div", {
        "class": groupClass
      }, [content]);
    };
  }
});

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