import React__default from 'react';
import useSendbirdStateContext from '../../useSendbirdStateContext.js';
import { u as useChannelContext } from '../../ChannelProvider-5dcbee7b.js';
import { P as PlaceHolder, a as PlaceHolderTypes } from '../../index-2cfab646.js';
import ConnectionStatus from '../../ui/ConnectionStatus.js';
import ChannelHeader from './ChannelHeader.js';
import MessageList from './MessageList.js';
import TypingIndicator from './TypingIndicator.js';
import MessageInputWrapper from './MessageInput.js';
import '../../withSendbird.js';
import '../../_rollupPluginBabelHelpers-05128ded.js';
import '../../UserProfileContext-f3f446d2.js';
import 'prop-types';
import '../../const-72f012b6.js';
import '../../index-ccef08fe.js';
import '../../index-6add7940.js';
import '../../topics-eb548880.js';
import '../../index-579ca9d7.js';
import '../../utils/message/getOutgoingMessageState.js';
import '../../compareIds-2e50e905.js';
import '@sendbird/chat/groupChannel';
import '../../uuid-717930b4.js';
import '@sendbird/chat/message';
import '../../consts-fa6ab3c0.js';
import '../../resolvedReplyType-9d00a3db.js';
import '../../LocalizationContext-a82461b5.js';
import '../../stringSet-b60e9529.js';
import '../../ui/Icon.js';
import '../../index-6420013c.js';
import '../../ui/Loader.js';
import '../../utils-b571dc44.js';
import '../../ui/IconButton.js';
import '../../ui/ChannelAvatar.js';
import '../../ui/Avatar.js';
import '../../ui/ImageRenderer.js';
import '../../utils-7f5e872b.js';
import '../../MediaQueryContext-d6110905.js';
import '../../utils-e0c7329c.js';
import './Message.js';
import './SuggestedMentionList.js';
import '../../const-3a34a127.js';
import '../../ThreadProvider-cf357120.js';
import '../../Thread/context/types.js';
import '@sendbird/chat';
import '../../ui/DateSeparator.js';
import '../../color-91e43dce.js';
import '../../ui/MessageInput.js';
import '../../ui/Button.js';
import 'dompurify';
import '../../consts-b4cb83cf.js';
import '../../consts-7693b8d3.js';
import '../../consts-9469111b.js';
import '../../tokenize-c718324d.js';
import '../../index.module-4f1cd64e.js';
import '../../ui/MessageContent.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';
import '../../index-ac0b2d20.js';
import '../../index-f879f6ef.js';
import '../../index-ad50e2c0.js';
import '../../ui/MessageItemMenu.js';
import '../../ui/ContextMenu.js';
import 'react-dom';
import '../../ui/SortByRow.js';
import '../../types-95cfd227.js';
import '../../ui/MessageItemReactionMenu.js';
import '../../ui/ReactionButton.js';
import '../../useLongPress-12280c78.js';
import '../../ui/EmojiReactions.js';
import '../../ui/ReactionBadge.js';
import '../../ui/BottomSheet.js';
import '../../index-a9101009.js';
import '../../ui/UserListItem.js';
import '../../ui/MutedAvatarOverlay.js';
import '../../ui/Checkbox.js';
import '../../ui/Tooltip.js';
import '../../ui/TooltipWrapper.js';
import '../../Message/context.js';
import '../../ui/AdminMessage.js';
import '../../ui/TextMessageItemBody.js';
import '../../index-a2bb2783.js';
import '../../ui/MentionLabel.js';
import '../../ui/LinkLabel.js';
import '../../ui/FileMessageItemBody.js';
import '../../ui/TextButton.js';
import '../../ui/ThumbnailMessageItemBody.js';
import '../../ui/OGMessageItemBody.js';
import '../../ui/UnknownMessageItemBody.js';
import '../../ui/QuoteMessage.js';
import '../../index-86294a68.js';
import '../../ui/ThreadReplies.js';
import '../../ui/VoiceMessageItemBody.js';
import '../../ui/ProgressBar.js';
import '../../VoicePlayer/useVoicePlayer.js';
import '../../index-fa5b2b8c.js';
import '../../VoiceRecorder/context.js';
import '../../ui/Modal.js';
import '../../ui/PlaybackTime.js';
import './FileViewer.js';
import './RemoveMessageModal.js';
import '../../index-dd5a8777.js';
import '../../useDirtyGetMentions-dffd4046.js';
import './UnreadCount.js';
import './FrozenNotification.js';
import '../../ui/QuoteMessageInput.js';
import '../../VoiceMessageInputWrapper-43163d7f.js';
import '../../VoiceRecorder/useVoiceRecorder.js';
import '../../index-090cbf21.js';

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

  return /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-conversation"
  }, (renderChannelHeader === null || renderChannelHeader === void 0 ? void 0 : renderChannelHeader()) || /*#__PURE__*/React__default.createElement(ChannelHeader, {
    className: "sendbird-conversation__channel-header"
  }), /*#__PURE__*/React__default.createElement(MessageList, {
    className: "sendbird-conversation__message-list",
    renderMessage: renderMessage,
    renderPlaceholderEmpty: renderPlaceholderEmpty,
    renderCustomSeparator: renderCustomSeparator,
    renderPlaceholderLoader: renderPlaceholderLoader
  }), /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-conversation__footer"
  }, (renderMessageInput === null || renderMessageInput === void 0 ? void 0 : renderMessageInput()) || /*#__PURE__*/React__default.createElement(MessageInputWrapper, {
    renderFileUploadIcon: renderFileUploadIcon,
    renderVoiceMessageIcon: renderVoiceMessageIcon,
    renderSendMessageIcon: renderSendMessageIcon
  }), /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-conversation__footer__typing-indicator"
  }, (renderTypingIndicator === null || renderTypingIndicator === void 0 ? void 0 : renderTypingIndicator()) || (globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$config3 = globalStore.config) === null || _globalStore$config3 === void 0 ? void 0 : (_globalStore$config3$ = _globalStore$config3.groupChannel) === null || _globalStore$config3$ === void 0 ? void 0 : _globalStore$config3$.enableTypingIndicator) && /*#__PURE__*/React__default.createElement(TypingIndicator, null), !isOnline && /*#__PURE__*/React__default.createElement(ConnectionStatus, null))));
};

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