import React__default from 'react';
import useSendbirdStateContext from '../../useSendbirdStateContext.js';
import { u as useChannelContext } from '../../ChannelProvider-b41fde4c.js';
import { P as PlaceHolder, a as PlaceHolderTypes } from '../../index-0f22e96e.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-0bc76382.js';
import '../../UserProfileContext-29074346.js';
import 'prop-types';
import '../../index-f1701c11.js';
import '../../index-865112db.js';
import '../../topics-5ff88d6f.js';
import '../../index-e2601165.js';
import '../../utils/message/getOutgoingMessageState.js';
import '../../compareIds-bc881fe7.js';
import '../../const-e51dda0c.js';
import '@sendbird/chat/groupChannel';
import '../../uuid-1f1bbd9c.js';
import '@sendbird/chat/message';
import '../../consts-3c0ff1ed.js';
import '../../LocalizationContext-57b46f6c.js';
import '../../stringSet-7a8ce1ce.js';
import '../../ui/Icon.js';
import '../../index-4023d1b2.js';
import '../../ui/Loader.js';
import '../../utils-af761f03.js';
import '../../ui/IconButton.js';
import '../../ui/ChannelAvatar.js';
import '../../ui/Avatar.js';
import '../../ui/ImageRenderer.js';
import '../../utils-6f2bb331.js';
import '../../MediaQueryContext-fbe7af77.js';
import '../../utils-388a790e.js';
import './Message.js';
import './SuggestedMentionList.js';
import '../../const-8daee9fc.js';
import '../../ThreadProvider-a3d3b241.js';
import '../../Thread/context/types.js';
import '@sendbird/chat';
import '../../ui/DateSeparator.js';
import '../../color-2ed716e6.js';
import '../../ui/MessageInput.js';
import '../../ui/Button.js';
import 'dompurify';
import '../../consts-d0b365df.js';
import '../../consts-d0cfee49.js';
import '../../consts-7aab5aff.js';
import '../../tokenize-003bf3f7.js';
import '../../ui/MessageContent.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';
import '../../index-fa140763.js';
import '../../index-1ec11afb.js';
import '../../index-37531f98.js';
import '../../ui/MessageItemMenu.js';
import '../../ui/ContextMenu.js';
import 'react-dom';
import '../../ui/SortByRow.js';
import '../../types-bffbc5f5.js';
import '../../ui/MessageItemReactionMenu.js';
import '../../ui/ReactionButton.js';
import '../../useLongPress-fbab35a9.js';
import '../../ui/EmojiReactions.js';
import '../../ui/ReactionBadge.js';
import '../../ui/BottomSheet.js';
import '../../index-7bff4ce0.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-5141f766.js';
import '../../index.module-9202ebbd.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-ac642e0b.js';
import '../../ui/ThreadReplies.js';
import '../../ui/VoiceMessageItemBody.js';
import '../../ui/ProgressBar.js';
import '../../VoicePlayer/useVoicePlayer.js';
import '../../index-d847a382.js';
import '../../VoiceRecorder/context.js';
import '../../ui/PlaybackTime.js';
import './FileViewer.js';
import './RemoveMessageModal.js';
import '../../ui/Modal.js';
import '../../index-3f1fa3f9.js';
import '../../useDirtyGetMentions-aac697f4.js';
import './UnreadCount.js';
import './FrozenNotification.js';
import '../../ui/QuoteMessageInput.js';
import '../../VoiceMessageInputWrapper-bdc53de4.js';
import '../../VoiceRecorder/useVoiceRecorder.js';
import '../../index-1e5cf284.js';

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
  } = 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()) || /*#__PURE__*/React__default.createElement(TypingIndicator, null), !isOnline && /*#__PURE__*/React__default.createElement(ConnectionStatus, null))));
};

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