'use strict';

var React = require('react');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
var Channel_context = require('../../ChannelProvider-620bb354.js');
var ui_PlaceHolder = require('../../index-ff8ea47f.js');
var ui_ConnectionStatus = require('../../ui/ConnectionStatus.js');
var Channel_components_ChannelHeader = require('./ChannelHeader.js');
var Channel_components_MessageList = require('./MessageList.js');
var Channel_components_TypingIndicator = require('./TypingIndicator.js');
var Channel_components_MessageInput = require('./MessageInput.js');
require('../../withSendbird.js');
require('../../_rollupPluginBabelHelpers-c5955c81.js');
require('../../UserProfileContext-f068b0ba.js');
require('prop-types');
require('../../index-f65677b1.js');
require('../../index-83d1d15e.js');
require('../../topics-825e5d42.js');
require('../../index-f2146bae.js');
require('../../utils/message/getOutgoingMessageState.js');
require('../../compareIds-18b3b1d6.js');
require('../../const-6691e574.js');
require('@sendbird/chat/groupChannel');
require('../../uuid-0b4ed44c.js');
require('@sendbird/chat/message');
require('../../ui/ContextMenu.js');
require('react-dom');
require('../../ui/SortByRow.js');
require('../../index-73643285.js');
require('../../stringSet-68748705.js');
require('../../ui/ReactionButton.js');
require('../../ui/ImageRenderer.js');
require('../../ui/Icon.js');
require('../../consts-a5382bc1.js');
require('../../LocalizationContext-af96cf5f.js');
require('../../ui/Loader.js');
require('../../utils-4b74ea64.js');
require('../../ui/IconButton.js');
require('../../ui/ChannelAvatar.js');
require('../../ui/Avatar.js');
require('../../utils-7f75ad97.js');
require('../../MediaQueryContext-8ec3f647.js');
require('../../utils-d5176360.js');
require('./Message.js');
require('./SuggestedMentionList.js');
require('../../const-ab0f6056.js');
require('../../ThreadProvider-572574d7.js');
require('../../Thread/context/types.js');
require('@sendbird/chat');
require('../../ui/DateSeparator.js');
require('../../color-afeb8dc2.js');
require('../../ui/MessageInput.js');
require('../../ui/Button.js');
require('dompurify');
require('../../consts-6ec77e9a.js');
require('../../consts-bc27beff.js');
require('../../consts-a422c2f9.js');
require('../../tokenize-d86ab0c7.js');
require('../../ui/MessageContent.js');
require('../../ui/UserProfile.js');
require('../../sendbirdSelectors.js');
require('../../index-900dd19f.js');
require('../../index-6cb4a530.js');
require('../../index-4ee95667.js');
require('../../ui/MessageItemMenu.js');
require('../../types-24accb8d.js');
require('../../ui/MessageItemReactionMenu.js');
require('../../ui/EmojiReactions.js');
require('../../ui/Tooltip.js');
require('../../ui/TooltipWrapper.js');
require('../../ui/ReactionBadge.js');
require('../../ui/AdminMessage.js');
require('../../ui/TextMessageItemBody.js');
require('../../index-0b344bd7.js');
require('../../index.module-9f5edc7b.js');
require('../../Message/context.js');
require('../../ui/MentionLabel.js');
require('../../ui/LinkLabel.js');
require('../../ui/FileMessageItemBody.js');
require('../../ui/TextButton.js');
require('../../ui/ThumbnailMessageItemBody.js');
require('../../ui/OGMessageItemBody.js');
require('../../ui/UnknownMessageItemBody.js');
require('../../ui/QuoteMessage.js');
require('../../useLongPress-d9deb354.js');
require('../../ui/BottomSheet.js');
require('../../index-68c57136.js');
require('../../ui/ThreadReplies.js');
require('../../ui/VoiceMessageItemBody.js');
require('../../ui/ProgressBar.js');
require('../../VoicePlayer/useVoicePlayer.js');
require('../../index-9d518988.js');
require('../../VoiceRecorder/context.js');
require('../../ui/PlaybackTime.js');
require('./FileViewer.js');
require('./RemoveMessageModal.js');
require('../../ui/Modal.js');
require('../../index-8049c2a3.js');
require('./UnreadCount.js');
require('./FrozenNotification.js');
require('../../ui/QuoteMessageInput.js');
require('../../VoiceMessageInputWrapper-db7f2b72.js');
require('../../VoiceRecorder/useVoiceRecorder.js');
require('../../index-c1de8d8f.js');

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

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

const ChannelUI = _ref => {
  var _globalStore$stores, _globalStore$stores$s, _globalStore$config, _globalStore$config2;
  let {
    isLoading,
    renderPlaceholderLoader,
    renderPlaceholderInvalid,
    renderPlaceholderEmpty,
    renderChannelHeader,
    renderMessage,
    renderMessageInput,
    renderTypingIndicator,
    renderCustomSeparator,
    renderFileUploadIcon,
    renderVoiceMessageIcon,
    renderSendMessageIcon
  } = _ref;
  const {
    channelUrl,
    isInvalid
  } = Channel_context.useChannelContext();
  const globalStore = useSendbirdStateContext();
  const sdkError = globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$stores = globalStore.stores) === null || _globalStore$stores === void 0 ? void 0 : (_globalStore$stores$s = _globalStore$stores.sdkStore) === null || _globalStore$stores$s === void 0 ? void 0 : _globalStore$stores$s.error;
  const logger = globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$config = globalStore.config) === null || _globalStore$config === void 0 ? void 0 : _globalStore$config.logger;
  const isOnline = globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$config2 = globalStore.config) === null || _globalStore$config2 === void 0 ? void 0 : _globalStore$config2.isOnline;
  if (isLoading) {
    return /*#__PURE__*/React__default["default"].createElement("div", {
      className: "sendbird-conversation"
    }, (renderPlaceholderLoader === null || renderPlaceholderLoader === void 0 ? void 0 : renderPlaceholderLoader()) || /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.LOADING
    }));
  }
  if (!channelUrl) {
    return /*#__PURE__*/React__default["default"].createElement("div", {
      className: "sendbird-conversation"
    }, (renderPlaceholderInvalid === null || renderPlaceholderInvalid === void 0 ? void 0 : renderPlaceholderInvalid()) || /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.NO_CHANNELS
    }));
  }
  if (isInvalid) {
    return /*#__PURE__*/React__default["default"].createElement("div", {
      className: "sendbird-conversation"
    }, (renderPlaceholderInvalid === null || renderPlaceholderInvalid === void 0 ? void 0 : renderPlaceholderInvalid()) || /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.WRONG
    }));
  }
  if (sdkError) {
    return /*#__PURE__*/React__default["default"].createElement("div", {
      className: "sendbird-conversation"
    }, (renderPlaceholderInvalid === null || renderPlaceholderInvalid === void 0 ? void 0 : renderPlaceholderInvalid()) || /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.WRONG,
      retryToConnect: () => {
        logger.info('Channel: reconnecting');
        // reconnect();
      }
    }));
  }

  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-conversation"
  }, (renderChannelHeader === null || renderChannelHeader === void 0 ? void 0 : renderChannelHeader()) || /*#__PURE__*/React__default["default"].createElement(Channel_components_ChannelHeader, {
    className: "sendbird-conversation__channel-header"
  }), /*#__PURE__*/React__default["default"].createElement(Channel_components_MessageList, {
    className: "sendbird-conversation__message-list",
    renderMessage: renderMessage,
    renderPlaceholderEmpty: renderPlaceholderEmpty,
    renderCustomSeparator: renderCustomSeparator,
    renderPlaceholderLoader: renderPlaceholderLoader
  }), /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-conversation__footer"
  }, (renderMessageInput === null || renderMessageInput === void 0 ? void 0 : renderMessageInput()) || /*#__PURE__*/React__default["default"].createElement(Channel_components_MessageInput, {
    renderFileUploadIcon: renderFileUploadIcon,
    renderVoiceMessageIcon: renderVoiceMessageIcon,
    renderSendMessageIcon: renderSendMessageIcon
  }), /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-conversation__footer__typing-indicator"
  }, (renderTypingIndicator === null || renderTypingIndicator === void 0 ? void 0 : renderTypingIndicator()) || /*#__PURE__*/React__default["default"].createElement(Channel_components_TypingIndicator["default"], null), !isOnline && /*#__PURE__*/React__default["default"].createElement(ui_ConnectionStatus, null))));
};

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