import React__default, { useContext, useEffect } from 'react';
import { a as LocalizationContext } from '../LocalizationContext-2a073ef0.js';
import { L as Label, a as LabelTypography, b as LabelColors } from '../index-ed39099a.js';
import Icon, { IconTypes, IconColors } from './Icon.js';
import IconButton from './IconButton.js';
import ChannelAvatar from './ChannelAvatar.js';
import '../stringSet-647493ce.js';
import '../index-5ec69689.js';
import '../_rollupPluginBabelHelpers-3043541a.js';
import 'prop-types';
import '../tslib.es6-710c6267.js';
import './Avatar.js';
import './ImageRenderer.js';
import '../uuid-60ae25c1.js';
import '../utils-2666bdfb.js';

var getChannelTitle = function getChannelTitle(channel, currentUserId, stringSet) {
  var _a;

  if (!(channel === null || channel === void 0 ? void 0 : channel.name) && !(channel === null || channel === void 0 ? void 0 : channel.members)) {
    return stringSet.NO_TITLE;
  }

  if ((channel === null || channel === void 0 ? void 0 : channel.name) && channel.name !== 'Group Channel') {
    return channel.name;
  }

  if (((_a = channel === null || channel === void 0 ? void 0 : channel.members) === null || _a === void 0 ? void 0 : _a.length) === 1) {
    return stringSet.NO_MEMBERS;
  }

  return ((channel === null || channel === void 0 ? void 0 : channel.members) || []).filter(function (_a) {
    var userId = _a.userId;
    return userId !== currentUserId;
  }).map(function (_a) {
    var nickname = _a.nickname;
    return nickname || stringSet.NO_NAME;
  }).join(', ');
};

// will be deprecated
function ChatHeader(_a) {
  var currentGroupChannel = _a.currentGroupChannel,
      currentUser = _a.currentUser,
      _b = _a.title,
      title = _b === void 0 ? '' : _b,
      _c = _a.subTitle,
      subTitle = _c === void 0 ? '' : _c,
      _d = _a.isMuted,
      isMuted = _d === void 0 ? false : _d,
      _e = _a.theme,
      theme = _e === void 0 ? 'light' : _e,
      _f = _a.showSearchIcon,
      showSearchIcon = _f === void 0 ? false : _f,
      _g = _a.onSearchClick,
      onSearchClick = _g === void 0 ? function () {} : _g,
      _h = _a.onActionClick,
      onActionClick = _h === void 0 ? function () {} : _h;
  var userId = currentUser === null || currentUser === void 0 ? void 0 : currentUser.userId;
  var stringSet = useContext(LocalizationContext).stringSet;
  useEffect(function () {
    // eslint-disable-next-line no-console
    console.warn('SendbirdUIKit: ChatHeader will be deprecated in the next minor version. Recommend to use "@sendbird/uikit-react/Channtl/components/ChannelHeader" instead.');
  }, []);
  return /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-chat-header"
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-chat-header__left"
  }, /*#__PURE__*/React__default.createElement(ChannelAvatar, {
    theme: theme,
    channel: currentGroupChannel,
    userId: userId,
    height: 32,
    width: 32
  }), /*#__PURE__*/React__default.createElement(Label, {
    className: "sendbird-chat-header__left__title",
    type: LabelTypography.H_2,
    color: LabelColors.ONBACKGROUND_1
  }, title || getChannelTitle(currentGroupChannel, userId, stringSet)), /*#__PURE__*/React__default.createElement(Label, {
    className: "sendbird-chat-header__left__subtitle",
    type: LabelTypography.BODY_1,
    color: LabelColors.ONBACKGROUND_2
  }, subTitle)), /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-chat-header__right"
  }, (typeof isMuted === 'string' && isMuted === 'true' || typeof isMuted === 'boolean' && isMuted) && /*#__PURE__*/React__default.createElement(Icon, {
    className: "sendbird-chat-header__right__mute",
    type: IconTypes.NOTIFICATIONS_OFF_FILLED,
    width: "24px",
    height: "24px"
  }), showSearchIcon && /*#__PURE__*/React__default.createElement(IconButton, {
    className: "sendbird-chat-header__right__search",
    width: "32px",
    height: "32px",
    onClick: onSearchClick
  }, /*#__PURE__*/React__default.createElement(Icon, {
    type: IconTypes.SEARCH,
    fillColor: IconColors.PRIMARY,
    width: "24px",
    height: "24px"
  })), /*#__PURE__*/React__default.createElement(IconButton, {
    className: "sendbird-chat-header__right__info",
    width: "32px",
    height: "32px",
    onClick: onActionClick
  }, /*#__PURE__*/React__default.createElement(Icon, {
    type: IconTypes.INFO,
    fillColor: IconColors.PRIMARY,
    width: "24px",
    height: "24px"
  }))));
}

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