import React from 'react';
import PropTypes from 'prop-types';

var CompositeAvatar = function CompositeAvatar(props) {
  var children = props.children,
      size = props.size,
      className = props.className;

  var isAvatar = function isAvatar() {
    return children.reduce(function (prev, child) {
      return prev && child.type.displayName === 'Avatar';
    }, true);
  };

  var getChildren = function getChildren() {
    if (children.length === 2 && isAvatar()) {
      return children;
    }

    throw new Error('Children should have 2 Avatar component');
  };

  return React.createElement("div", {
    className: 'cui-composite-avatar' + ("" + (size && " cui-composite-avatar--" + size || '')) + ("" + (className && " " + className || ''))
  }, getChildren());
};

CompositeAvatar.displayName = 'CompositeAvatar';
CompositeAvatar.propTypes = {
  /** @prop Children nodes to render inside CompositeAvatar | null */
  children: PropTypes.node,

  /** @prop Optional css class string | '' */
  className: PropTypes.string,

  /** @prop Sets the size of the CompositeAvatar | 'medium' */
  size: PropTypes.oneOf(['small', 'medium', 'large', 28, 40, 84, 135])
};
CompositeAvatar.defaultProps = {
  className: '',
  size: 'medium',
  children: null
};
export default CompositeAvatar;