'use strict';

var React = require('react');
var LocalizationContext = require('../../LocalizationContext-8cc9717d.js');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
var ui_Label = require('../../index-35633fb6.js');
var ui_Avatar = require('../../ui/Avatar.js');
require('../../stringSet-ce782136.js');
require('../../index-d749c4c2.js');
require('../../withSendbird.js');
require('../../_rollupPluginBabelHelpers-acf412a3.js');
require('prop-types');
require('../../ui/ImageRenderer.js');
require('../../ui/Icon.js');
require('../../uuid-1eceb0c8.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

const ChannelListHeader = _ref => {
  let {
    renderHeader,
    renderTitle,
    renderIconButton,
    onEdit,
    allowProfileEdit
  } = _ref;
  const {
    stores,
    config
  } = useSendbirdStateContext();
  const {
    user
  } = stores.userStore;
  const {
    logger
  } = config;
  const {
    stringSet
  } = React.useContext(LocalizationContext.LocalizationContext);
  if (renderHeader) {
    logger === null || logger === void 0 ? void 0 : logger.warning('Recomend to use "renderTitle" instead of "renderHeader". It will be deprecated.');
  }
  // renderTitle should have higher priority
  const titleRenderer = renderHeader || renderTitle;
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: ['sendbird-channel-header', allowProfileEdit ? 'sendbird-channel-header--allow-edit' : ''].join(' ')
  }, (titleRenderer === null || titleRenderer === void 0 ? void 0 : titleRenderer()) || /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-channel-header__title",
    role: "button",
    onClick: () => {
      onEdit === null || onEdit === void 0 ? void 0 : onEdit();
    },
    onKeyDown: () => {
      onEdit === null || onEdit === void 0 ? void 0 : onEdit();
    },
    tabIndex: 0
  }, /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-channel-header__title__left"
  }, /*#__PURE__*/React__default["default"].createElement(ui_Avatar["default"], {
    width: "32px",
    height: "32px",
    src: user.profileUrl,
    alt: user.nickname
  })), /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-channel-header__title__right"
  }, /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    className: "sendbird-channel-header__title__right__name",
    type: ui_Label.LabelTypography.SUBTITLE_2,
    color: ui_Label.LabelColors.ONBACKGROUND_1
  }, user.nickname || stringSet.NO_NAME), /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    className: "sendbird-channel-header__title__right__user-id",
    type: ui_Label.LabelTypography.BODY_2,
    color: ui_Label.LabelColors.ONBACKGROUND_2
  }, user.userId))), /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-channel-header__right-icon"
  }, renderIconButton === null || renderIconButton === void 0 ? void 0 : renderIconButton()));
};

module.exports = ChannelListHeader;
//# sourceMappingURL=ChannelListHeader.js.map
