import React__default from 'react';
import useSendbirdStateContext from '../../useSendbirdStateContext.js';
import { u as useChannelContext } from '../../ChannelProvider-4ab3a851.js';
import { P as PlaceHolder, a as PlaceHolderTypes } from '../../index-77f3d9b0.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-b2d9bfc5.js';
import '../../UserProfileContext-a8aa4c0f.js';
import 'prop-types';
import '../../index-f48cfdf7.js';
import '../../index-a9ddd0f5.js';
import '../../topics-d8d10f83.js';
import '../../index-dbe0e004.js';
import '../../utils/message/getOutgoingMessageState.js';
import '../../compareIds-1e0e668f.js';
import '../../const-5f722b91.js';
import '@sendbird/chat/groupChannel';
import '../../uuid-48baadaf.js';
import '@sendbird/chat/message';
import '../../ui/ContextMenu.js';
import 'react-dom';
import '../../ui/SortByRow.js';
import '../../index-4111594a.js';
import '../../stringSet-1f18348a.js';
import '../../ui/ReactionButton.js';
import '../../ui/ImageRenderer.js';
import '../../ui/Icon.js';
import '../../consts-c9746f2b.js';
import '../../LocalizationContext-9c54e783.js';
import '../../ui/Loader.js';
import '../../utils-b57bff14.js';
import '../../ui/IconButton.js';
import '../../ui/ChannelAvatar.js';
import '../../ui/Avatar.js';
import '../../utils-447a922e.js';
import '../../MediaQueryContext-1988a4bc.js';
import '../../utils-0c09801e.js';
import './Message.js';
import './SuggestedMentionList.js';
import '../../const-6a07b718.js';
import '../../ThreadProvider-0a3c5f37.js';
import '../../Thread/context/types.js';
import '@sendbird/chat';
import '../../ui/DateSeparator.js';
import '../../color-3bac434a.js';
import '../../ui/MessageInput.js';
import '../../ui/Button.js';
import 'dompurify';
import '../../consts-d4c78cc0.js';
import '../../consts-aadaccca.js';
import '../../consts-790ae3a9.js';
import '../../tokenize-63d895d3.js';
import '../../ui/MessageContent.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';
import '../../index-51bd074f.js';
import '../../index-3062a861.js';
import '../../index-1a3c0d72.js';
import '../../ui/MessageItemMenu.js';
import '../../types-a85de720.js';
import '../../ui/MessageItemReactionMenu.js';
import '../../ui/EmojiReactions.js';
import '../../ui/Tooltip.js';
import '../../ui/TooltipWrapper.js';
import '../../ui/ReactionBadge.js';
import '../../ui/AdminMessage.js';
import '../../ui/TextMessageItemBody.js';
import '../../index-8df6bff0.js';
import '../../index.module-ab8289c1.js';
import '../../Message/context.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 '../../useLongPress-8acf717c.js';
import '../../ui/BottomSheet.js';
import '../../index-2a938266.js';
import '../../ui/ThreadReplies.js';
import '../../ui/VoiceMessageItemBody.js';
import '../../ui/ProgressBar.js';
import '../../VoicePlayer/useVoicePlayer.js';
import '../../index-38a78d99.js';
import '../../VoiceRecorder/context.js';
import '../../ui/PlaybackTime.js';
import './FileViewer.js';
import './RemoveMessageModal.js';
import '../../ui/Modal.js';
import '../../index-cfd0e4c4.js';
import './UnreadCount.js';
import './FrozenNotification.js';
import '../../ui/QuoteMessageInput.js';
import '../../VoiceMessageInputWrapper-ff160b51.js';
import '../../VoiceRecorder/useVoiceRecorder.js';
import '../../index-83600696.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
