'use strict';

var React = require('react');
var OpenChannel_context = require('../../OpenChannelProvider-b1e1151c.js');
var OpenChannel_components_OpenChannelInput = require('./OpenChannelInput.js');
var OpenChannel_components_FrozenChannelNotification = require('./FrozenChannelNotification.js');
var OpenChannel_components_OpenChannelHeader = require('./OpenChannelHeader.js');
var ui_PlaceHolder = require('../../index-89427d9d.js');
var OpenChannel_components_OpenChannelMessageList = require('./OpenChannelMessageList.js');
require('../../index-0ffaa79b.js');
require('../../index-3a0cfa58.js');
require('../../UserProfileContext-3a37e911.js');
require('prop-types');
require('../../_rollupPluginBabelHelpers-09eba4f3.js');
require('../../compareIds-c82fb274.js');
require('../../topics-b3f004b2.js');
require('@sendbird/chat');
require('@sendbird/chat/openChannel');
require('../../uuid-f2b80298.js');
require('../../useSendbirdStateContext.js');
require('../../withSendbird.js');
require('../../LocalizationContext-9eda9144.js');
require('../../stringSet-85aa5de9.js');
require('../../ui/MessageInput.js');
require('../../const-696b9e9c.js');
require('../../const-85f621b6.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('../../index-4efb56bf.js');
require('dompurify');
require('../../consts-049a4487.js');
require('../../ui/Icon.js');
require('../../index-cf37de8c.js');
require('../../utils/message/getOutgoingMessageState.js');
require('../../consts-a9db3fc2.js');
require('../../consts-47c8eee1.js');
require('../../tokenize-398af65e.js');
require('../../index.module-b62197d5.js');
require('../../ui/Avatar.js');
require('../../ui/ImageRenderer.js');
require('../../MediaQueryContext-d15578f3.js');
require('../../ui/Loader.js');
require('../../index-84bebbc3.js');
require('./OpenChannelMessage.js');
require('../../ui/OpenchannelUserMessage.js');
require('../../ui/ContextMenu.js');
require('react-dom');
require('../../ui/SortByRow.js');
require('../../ui/UserProfile.js');
require('../../sendbirdSelectors.js');
require('../../utils-6916bad3.js');
require('../../utils-13e73810.js');
require('../../index-ef1ced48.js');
require('../../useLongPress-e9001ef5.js');
require('../../ui/OpenChannelAdminMessage.js');
require('../../ui/OpenchannelOGMessage.js');
require('../../ui/LinkLabel.js');
require('../../index-1acd76e0.js');
require('../../Message/context.js');
require('../../ui/MentionLabel.js');
require('../../ui/OpenchannelThumbnailMessage.js');
require('../../ui/OpenchannelFileMessage.js');
require('../../ui/TextButton.js');
require('../../color-c2408258.js');
require('../../ui/DateSeparator.js');
require('../../ui/FileViewer.js');
require('../../index-61e3f022.js');
require('../../ui/Modal.js');
require('../../index-a023d0ae.js');
require('../../consts-eef8003b.js');

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

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

const COMPONENT_CLASS_NAME = 'sendbird-openchannel-conversation';
const OpenChannelUI = _ref => {
  let {
    renderMessage,
    renderHeader,
    renderInput,
    renderPlaceHolderEmptyList,
    renderPlaceHolderError,
    renderPlaceHolderLoading
  } = _ref;
  const {
    currentOpenChannel,
    amIBanned,
    loading,
    isInvalid,
    messageInputRef,
    conversationScrollRef
  } = OpenChannel_context.useOpenChannelContext();
  if (!currentOpenChannel || !(currentOpenChannel !== null && currentOpenChannel !== void 0 && currentOpenChannel.url) || amIBanned) {
    return (renderPlaceHolderError === null || renderPlaceHolderError === void 0 ? void 0 : renderPlaceHolderError()) || /*#__PURE__*/React__default["default"].createElement("div", {
      className: COMPONENT_CLASS_NAME
    }, /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.NO_CHANNELS
    }));
  }
  if (loading) {
    return (renderPlaceHolderLoading === null || renderPlaceHolderLoading === void 0 ? void 0 : renderPlaceHolderLoading()) || /*#__PURE__*/React__default["default"].createElement("div", {
      className: COMPONENT_CLASS_NAME
    }, /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.LOADING
    }));
  }
  if (isInvalid) {
    return (renderPlaceHolderError === null || renderPlaceHolderError === void 0 ? void 0 : renderPlaceHolderError()) || /*#__PURE__*/React__default["default"].createElement("div", {
      className: COMPONENT_CLASS_NAME
    }, /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.WRONG
    }));
  }
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: COMPONENT_CLASS_NAME
  }, (renderHeader === null || renderHeader === void 0 ? void 0 : renderHeader()) || /*#__PURE__*/React__default["default"].createElement(OpenChannel_components_OpenChannelHeader, null), (currentOpenChannel === null || currentOpenChannel === void 0 ? void 0 : currentOpenChannel.isFrozen) && /*#__PURE__*/React__default["default"].createElement(OpenChannel_components_FrozenChannelNotification, null), /*#__PURE__*/React__default["default"].createElement(OpenChannel_components_OpenChannelMessageList, {
    ref: conversationScrollRef,
    renderMessage: renderMessage,
    renderPlaceHolderEmptyList: renderPlaceHolderEmptyList
  }), (renderInput === null || renderInput === void 0 ? void 0 : renderInput()) || /*#__PURE__*/React__default["default"].createElement(OpenChannel_components_OpenChannelInput, {
    ref: messageInputRef
  }));
};

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