"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vnode = require("../../../utils/vue/vnode.js");
const index = require("../../../hooks/use-namespace/index.js");
const index$1 = require("../../tooltip/index.js");
const constants = require("./constants.js");
const avatar2 = require("./avatar2.js");
const avatarGroupProps = require("./avatar-group-props.js");
const vue = require("vue");
var avatar_group_default = /* @__PURE__ */ vue.defineComponent({
  name: "ElAvatarGroup",
  props: avatarGroupProps.avatarGroupProps,
  setup(props, { slots }) {
    const ns = index.useNamespace("avatar-group");
    vue.provide(constants.avatarGroupContextKey, vue.reactive({
      size: vue.toRef(props, "size"),
      shape: vue.toRef(props, "shape")
    }));
    return () => {
      var _a;
      const avatars = vnode.flattedChildren(((_a = slots.default) == null ? void 0 : _a.call(slots)) ?? []);
      let visibleAvatars = avatars;
      if (props.collapseAvatars && avatars.length > props.maxCollapseAvatars) {
        visibleAvatars = avatars.slice(0, props.maxCollapseAvatars);
        const hiddenAvatars = avatars.slice(props.maxCollapseAvatars);
        visibleAvatars.push(vue.createVNode(index$1.ElTooltip, {
          "popperClass": props.popperClass,
          "popperStyle": props.popperStyle,
          "placement": props.placement,
          "effect": props.effect,
          "disabled": !props.collapseAvatarsTooltip
        }, {
          default: () => vue.createVNode(avatar2.default, {
            "size": props.size,
            "shape": props.shape,
            "class": props.collapseClass,
            "style": props.collapseStyle
          }, { default: () => [vue.createTextVNode("+ "), hiddenAvatars.length] }),
          content: () => vue.createVNode("div", { "class": ns.e("collapse-avatars") }, [hiddenAvatars.map((node, idx) => vue.isVNode(node) ? vue.cloneVNode(node, { key: node.key ?? idx }) : node)])
        }));
      }
      return vue.createVNode("div", { "class": ns.b() }, [visibleAvatars]);
    };
  }
});
exports.default = avatar_group_default;
