"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "AvatarGroup", {
    enumerable: true,
    get: function() {
        return AvatarGroup;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
var _components = require("@tarojs/components");
var _context = require("./context");
var _typings = require("../../utils/typings");
var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
    maxContent: '',
    max: '',
    maxBackground: '#eee',
    maxColor: '#666',
    gap: '-8',
    level: 'left'
});
var classPrefix = "nut-avatar-group";
var AvatarGroup = function AvatarGroup(props) {
    var propAvatarGroup = (0, _object_spread._)({}, defaultProps, props);
    var className = propAvatarGroup.className, style = propAvatarGroup.style, children = propAvatarGroup.children;
    var avatarGroupRef = (0, _react.useRef)(null);
    var cls = (0, _classnames.default)(classPrefix, className);
    var parentAvatar = {
        propAvatarGroup: (0, _object_spread._)({
            avatarCount: _react.default.Children.count(children) || 0
        }, propAvatarGroup),
        avatarGroupRef: avatarGroupRef
    };
    return /*#__PURE__*/ _react.default.createElement(_context.AvatarContext.Provider, {
        value: parentAvatar
    }, /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: cls,
        style: style,
        ref: avatarGroupRef
    }, _react.default.Children.map(children, function(child, index) {
        var _child_type;
        // @ts-ignore
        return (child === null || child === void 0 ? void 0 : (_child_type = child.type) === null || _child_type === void 0 ? void 0 : _child_type.displayName) === 'NutAvatar' ? /*#__PURE__*/ _react.default.cloneElement(child, {
            avatarIndex: index + 1,
            className: 'nut-avatar-group-avatar'
        }) : child;
    })));
};
AvatarGroup.displayName = 'NutAvatarGroup';
