function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/*
Copyright (c) 2018 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import { styled } from '../styles/index.js';

function getSize(props) {
  var $size = props.$size,
      $theme = props.$theme;
  var defaultSize = $theme.sizing.scale1000;
  var size = $size || defaultSize;
  return $theme.sizing[size] || size;
}

export var Avatar = styled('img', function (props) {
  var themedSize = getSize(props);
  return {
    borderRadius: '50%',
    boxSizing: 'border-box',
    display: 'block',
    height: themedSize,
    width: themedSize
  };
});
Avatar.displayName = "Avatar";
export var Initials = styled('div', function (props) {
  return _objectSpread({}, props.$theme.typography.font400, {
    color: props.$theme.colors.mono100,
    alignItems: 'center',
    display: 'flex',
    justifyContent: 'center',
    height: '100%'
  });
});
Initials.displayName = "Initials";
export var Root = styled('div', function (props) {
  var $didImageFailToLoad = props.$didImageFailToLoad;
  var themedSize = getSize(props);
  return {
    backgroundColor: $didImageFailToLoad ? props.$theme.colors.primary : null,
    borderRadius: '50%',
    boxSizing: 'border-box',
    display: 'inline-block',
    // image previously set the root height/width
    // since image is not rendered, set the height/width
    height: $didImageFailToLoad ? themedSize : null,
    width: $didImageFailToLoad ? themedSize : null
  };
});
Root.displayName = "Root";