/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import Vue from 'vue';
import { renderContent, renderLNodeJSX } from '../../utils/render-node.js';
import { getClassPrefixMixins } from '../config-provider/config-receiver.js';
import mixins from '../../utils/mixins.js';
import _Avatar from './avatar.js';
import { AvatarGroupProps } from './props.js';
import 'lodash';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import '../../_chunks/dep-def4c2ce.js';

const classPrefixMixins = getClassPrefixMixins("avatar");
var _AvatarGroup = mixins(classPrefixMixins).extend({
  name: "LAvatarGroup",
  components: {
    LAvatar: _Avatar
  },
  props: {
    ...AvatarGroupProps
  },
  provide() {
    return {
      avatarGroup: this
    };
  },
  methods: {
    renderEllipsisAvatar(children) {
      const h = this.$createElement;
      if ((children === null || children === void 0 ? void 0 : children.length) > this.max) {
        const content = this.setEllipsisContent(children);
        const outAvatar = children.slice(0, this.max);
        outAvatar.push(h("l-avatar", {
          "attrs": {
            "size": this.size,
            "icon": this.isIcon() ? this.collapseAvatar : null
          }
        }, [content]));
        return [outAvatar];
      }
      return [children];
    },
    setEllipsisContent(children) {
      let content = "";
      if (this.collapseAvatar) {
        if (!this.isIcon()) content = renderContent(this, "collapseAvatar", "content");
      } else {
        content = `+${children.length - this.max}`;
      }
      return content;
    },
    isIcon() {
      const content = renderLNodeJSX(this, "collapseAvatar");
      return (content === null || content === void 0 ? void 0 : content.context) instanceof Vue;
    }
  },
  render() {
    const h = arguments[0];
    const {
      $scopedSlots
    } = this;
    const children = $scopedSlots.default && $scopedSlots.default(null);
    const {
      cascading,
      max
    } = this.$props;
    const groupClass = [`${this.componentName}-group`, {
      [`${this.componentName}--offset-right`]: cascading === "right-up",
      [`${this.componentName}--offset-left`]: cascading === "left-up"
    }];
    let content = [children];
    if (max && max >= 0) content = [this.renderEllipsisAvatar(children)];
    return h("div", {
      "class": groupClass
    }, [content]);
  }
});

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