import React__default from 'react';
import useSendbirdStateContext from '../../useSendbirdStateContext.js';
import { u as useChannelContext } from '../../ChannelProvider-e2c86cba.js';
import { P as PlaceHolder, a as PlaceHolderTypes } from '../../index-e3412d57.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-dfc61977.js';
import '../../UserProfileContext-d2264917.js';
import 'prop-types';
import '../../index-c55389dc.js';
import '../../index-5b34a381.js';
import '../../topics-c4837013.js';
import '../../index-102fbe62.js';
import '../../tslib.es6-645dedf8.js';
import '../../utils/message/getOutgoingMessageState.js';
import '../../compareIds-86584ff3.js';
import '../../const-26fafb08.js';
import '@sendbird/chat/groupChannel';
import '../../uuid-e15650df.js';
import '@sendbird/chat/message';
import '../../ui/ContextMenu.js';
import 'react-dom';
import '../../ui/SortByRow.js';
import '../../index-46d8dde5.js';
import '../../stringSet-fd70cba0.js';
import '../../ui/ReactionButton.js';
import '../../ui/ImageRenderer.js';
import '../../ui/Icon.js';
import '../../consts-37ea645a.js';
import '../../LocalizationContext-187f787e.js';
import '../../ui/Loader.js';
import '../../utils-88f76aba.js';
import '../../ui/IconButton.js';
import '../../ui/ChannelAvatar.js';
import '../../ui/Avatar.js';
import '../../utils-d17bcc15.js';
import '../../MediaQueryContext-add671c4.js';
import '../../utils-780c1e12.js';
import './Message.js';
import './SuggestedMentionList.js';
import '../../const-693a408f.js';
import '../../ThreadProvider-8d535c1b.js';
import '../../Thread/context/types.js';
import '@sendbird/chat';
import '../../ui/DateSeparator.js';
import '../../color-b379fbc5.js';
import '../../ui/MessageInput.js';
import '../../ui/Button.js';
import 'dompurify';
import '../../consts-b2395440.js';
import '../../ui/MessageContent.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';
import '../../index-7b740ffc.js';
import '../../index-7afa5c8d.js';
import '../../index-30236e16.js';
import '../../ui/MessageItemMenu.js';
import '../../types-87c77099.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 '../../ui/Word.js';
import '../../ui/LinkLabel.js';
import '../../ui/MentionLabel.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-81323308.js';
import '../../ui/BottomSheet.js';
import '../../index-f338f866.js';
import '../../ui/ThreadReplies.js';
import '../../ui/VoiceMessageItemBody.js';
import '../../ui/ProgressBar.js';
import '../../VoicePlayer/useVoicePlayer.js';
import '../../index-c29a819f.js';
import '../../VoiceRecorder/context.js';
import '../../lame.all.js';
import '../../ui/PlaybackTime.js';
import './FileViewer.js';
import './RemoveMessageModal.js';
import '../../ui/Modal.js';
import './UnreadCount.js';
import './FrozenNotification.js';
import '../../ui/QuoteMessageInput.js';
import '../../VoiceMessageInputWrapper-2434abc5.js';
import '../../VoiceRecorder/useVoiceRecorder.js';
import '../../index-30721345.js';

var ChannelUI = function (_a) {
  var _b, _c, _d, _e;

  var isLoading = _a.isLoading,
      renderPlaceholderLoader = _a.renderPlaceholderLoader,
      renderPlaceholderInvalid = _a.renderPlaceholderInvalid,
      renderPlaceholderEmpty = _a.renderPlaceholderEmpty,
      renderChannelHeader = _a.renderChannelHeader,
      renderMessage = _a.renderMessage,
      renderMessageInput = _a.renderMessageInput,
      renderTypingIndicator = _a.renderTypingIndicator,
      renderCustomSeparator = _a.renderCustomSeparator,
      renderFileUploadIcon = _a.renderFileUploadIcon,
      renderVoiceMessageIcon = _a.renderVoiceMessageIcon,
      renderSendMessageIcon = _a.renderSendMessageIcon;

  var _f = useChannelContext(),
      channelUrl = _f.channelUrl,
      isInvalid = _f.isInvalid;

  var globalStore = useSendbirdStateContext();
  var sdkError = (_c = (_b = globalStore === null || globalStore === void 0 ? void 0 : globalStore.stores) === null || _b === void 0 ? void 0 : _b.sdkStore) === null || _c === void 0 ? void 0 : _c.error;
  var logger = (_d = globalStore === null || globalStore === void 0 ? void 0 : globalStore.config) === null || _d === void 0 ? void 0 : _d.logger;
  var isOnline = (_e = globalStore === null || globalStore === void 0 ? void 0 : globalStore.config) === null || _e === void 0 ? void 0 : _e.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: function () {
        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
