"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CaseUserAvatar = void 0;
var _react = _interopRequireDefault(require("react"));
var _userProfileComponents = require("@kbn/user-profile-components");
var _unknown_user = require("./unknown_user");
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */

const CaseUserAvatarComponent = ({
  size,
  userInfo
}) => {
  var _userInfo$user, _userInfo$data;
  const dataTestSubjName = userInfo === null || userInfo === void 0 ? void 0 : (_userInfo$user = userInfo.user) === null || _userInfo$user === void 0 ? void 0 : _userInfo$user.username;
  return (userInfo === null || userInfo === void 0 ? void 0 : userInfo.user) !== undefined ? /*#__PURE__*/_react.default.createElement(_userProfileComponents.UserAvatar, {
    user: userInfo === null || userInfo === void 0 ? void 0 : userInfo.user,
    avatar: userInfo === null || userInfo === void 0 ? void 0 : (_userInfo$data = userInfo.data) === null || _userInfo$data === void 0 ? void 0 : _userInfo$data.avatar,
    "data-test-subj": `case-user-profile-avatar-${dataTestSubjName}`,
    size: size
  }) : /*#__PURE__*/_react.default.createElement(_unknown_user.CaseUnknownUserAvatar, {
    size: size
  });
};
CaseUserAvatarComponent.displayName = 'CaseUserAvatar';
const CaseUserAvatar = /*#__PURE__*/_react.default.memo(CaseUserAvatarComponent);
exports.CaseUserAvatar = CaseUserAvatar;