import React__default, { useRef, useContext } from 'react';
import { a as LocalizationContext } from '../../LocalizationContext-1701e5c8.js';
import { a as UserProfileContext } from '../../UserProfileContext-74e9a128.js';
import Avatar from '../../ui/Avatar.js';
import MutedAvatarOverlay from '../../ui/MutedAvatarOverlay.js';
import { L as Label, a as LabelTypography, b as LabelColors } from '../../index-f50d7ab0.js';
import UserProfile from '../../ui/UserProfile.js';
import ContextMenu, { MenuItems } from '../../ui/ContextMenu.js';
import '../../stringSet-e9bb0333.js';
import '../../index-ff8f2f61.js';
import 'prop-types';
import '../../ui/ImageRenderer.js';
import '../../ui/Icon.js';
import '../../uuid-8b344dd2.js';
import '../../sendbirdSelectors.js';
import '../../_rollupPluginBabelHelpers-cc035350.js';
import '../../topics-0b30f52b.js';
import '../../utils-05aa9060.js';
import '../../ui/Button.js';
import '../../useSendbirdStateContext.js';
import '../../withSendbird.js';
import 'react-dom';
import '../../ui/SortByRow.js';
import '../../index-99ab01f6.js';
import '../../utils/message/getOutgoingMessageState.js';

const UserListItem = _ref => {
  let {
    user,
    className,
    currentUser,
    action
  } = _ref;
  const actionRef = useRef(null);
  const parentRef = useRef(null);
  const avatarRef = useRef(null);
  const {
    stringSet
  } = useContext(LocalizationContext);
  const {
    disableUserProfile,
    renderUserProfile
  } = useContext(UserProfileContext);
  const injectingClassNames = Array.isArray(className) ? className : [className];
  return /*#__PURE__*/React__default.createElement("div", {
    ref: parentRef,
    className: ['sendbird-user-list-item--small', ...injectingClassNames].join(' ')
  }, /*#__PURE__*/React__default.createElement(ContextMenu, {
    menuTrigger: toggleDropdown => /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Avatar, {
      onClick: () => {
        if (!disableUserProfile) {
          toggleDropdown();
        }
      },
      ref: avatarRef,
      className: "sendbird-user-list-item--small__avatar",
      src: user.profileUrl,
      width: 24,
      height: 24
    }), user.isMuted && /*#__PURE__*/React__default.createElement(MutedAvatarOverlay, null)),
    menuItems: closeDropdown => /*#__PURE__*/React__default.createElement(MenuItems, {
      openLeft: true,
      parentRef: avatarRef
      // for catching location(x, y) of MenuItems
      ,
      parentContainRef: avatarRef
      // for toggling more options(menus & reactions)
      ,
      closeDropdown: closeDropdown,
      style: {
        paddingTop: '0px',
        paddingBottom: '0px'
      }
    }, renderUserProfile ? renderUserProfile({
      user,
      currentUserId: currentUser,
      close: closeDropdown
    }) : /*#__PURE__*/React__default.createElement(UserProfile, {
      user: user,
      currentUserId: currentUser,
      onSuccess: closeDropdown
    }))
  }), /*#__PURE__*/React__default.createElement(Label, {
    className: "sendbird-user-list-item--small__title",
    type: LabelTypography.SUBTITLE_1,
    color: LabelColors.ONBACKGROUND_1
  }, user.nickname || stringSet.NO_NAME, currentUser === user.userId && stringSet.CHANNEL_SETTING__MEMBERS__YOU),
  // if there is now nickname, display userId
  !user.nickname && /*#__PURE__*/React__default.createElement(Label, {
    className: "sendbird-user-list-item--small__subtitle",
    type: LabelTypography.CAPTION_3,
    color: LabelColors.ONBACKGROUND_2
  }, user.userId), user.role === 'operator' && /*#__PURE__*/React__default.createElement(Label, {
    className: "sendbird-user-list-item--small__operator",
    type: LabelTypography.SUBTITLE_2,
    color: LabelColors.ONBACKGROUND_2
  }, stringSet.CHANNEL_SETTING__MEMBERS__OPERATOR), action && /*#__PURE__*/React__default.createElement("div", {
    ref: actionRef,
    className: "sendbird-user-list-item--small__action"
  }, action({
    actionRef,
    parentRef
  })));
};

export { UserListItem as default };
//# sourceMappingURL=UserListItem.js.map
