'use strict';

var React = require('react');
var OpenChannel_context = require('../../OpenChannelProvider-8ef4ee2e.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-fd722a1e.js');
var OpenChannel_components_OpenChannelMessageList = require('./OpenChannelMessageList.js');
require('../../index-a9099968.js');
require('../../index-c08c7ef8.js');
require('../../UserProfileContext-268ad0d1.js');
require('prop-types');
require('../../_rollupPluginBabelHelpers-00480ba8.js');
require('../../compareIds-a65972c5.js');
require('../../topics-623a82c5.js');
require('@sendbird/chat');
require('@sendbird/chat/openChannel');
require('../../uuid-43555bb8.js');
require('../../useSendbirdStateContext.js');
require('../../withSendbird.js');
require('../../LocalizationContext-bc6af64a.js');
require('../../stringSet-812981b5.js');
require('../../ui/MessageInput.js');
require('../../const-eb6bfc42.js');
require('../../const-f1c7b0cf.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('../../index-902525e0.js');
require('dompurify');
require('../../consts-c63fe2cd.js');
require('../../ui/Icon.js');
require('../../index-609a0bf5.js');
require('../../utils/message/getOutgoingMessageState.js');
require('../../consts-db7e33d3.js');
require('../../consts-20c3e20f.js');
require('../../tokenize-846b6f86.js');
require('../../index.module-ceb5d636.js');
require('../../ui/Avatar.js');
require('../../ui/ImageRenderer.js');
require('../../MediaQueryContext-8be571f9.js');
require('../../ui/Loader.js');
require('../../index-c46b64e3.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-89c82b6d.js');
require('../../utils-496e7d26.js');
require('../../index-803fa23b.js');
require('../../useLongPress-d5e59a98.js');
require('../../ui/OpenChannelAdminMessage.js');
require('../../ui/OpenchannelOGMessage.js');
require('../../ui/LinkLabel.js');
require('../../index-060f95dc.js');
require('../../Message/context.js');
require('../../ui/MentionLabel.js');
require('../../ui/OpenchannelThumbnailMessage.js');
require('../../ui/OpenchannelFileMessage.js');
require('../../ui/TextButton.js');
require('../../color-41ee42a1.js');
require('../../ui/DateSeparator.js');
require('../../ui/FileViewer.js');
require('../../index-09573a50.js');
require('../../ui/Modal.js');
require('../../index-2fc373d9.js');
require('../../consts-d0461d4c.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
