'use strict';

var _tslib = require('../../chunks/bundle-Dwj4MFbu.js');
var React = require('react');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
var Channel_context = require('../context.js');
var index = require('../../chunks/bundle-Dsga0STu.js');
var utils = require('../../chunks/bundle-ClrDxDE5.js');
var MessageView = require('../../chunks/bundle-DIHqg-nE.js');
var Channel_components_FileViewer = require('./FileViewer.js');
var Channel_components_RemoveMessageModal = require('./RemoveMessageModal.js');
require('../../withSendbird.js');
require('../../chunks/bundle-DBUexy6W.js');
require('@sendbird/uikit-tools');
require('../../chunks/bundle-28_kUN83.js');
require('../../chunks/bundle-7F-J6w2L.js');
require('react-dom');
require('../../chunks/bundle-DUlN8JG0.js');
require('../../chunks/bundle-CNo3XvY2.js');
require('../../chunks/bundle-D027Tr-j.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('../../chunks/bundle-q_NwnODB.js');
require('../../ui/Icon.js');
require('css-vars-ponyfill');
require('@sendbird/chat');
require('../../chunks/bundle-D_L8wtf_.js');
require('@sendbird/chat/openChannel');
require('@sendbird/chat/groupChannel');
require('../../chunks/bundle-V5e7Iz-M.js');
require('../../chunks/bundle-fHhNYi5k.js');
require('../../chunks/bundle-CNOy0SKq.js');
require('../../chunks/bundle-DsDVN_6R.js');
require('../../ui/SortByRow.js');
require('../../chunks/bundle-CfwVjrki.js');
require('../../chunks/bundle-D377oTBW.js');
require('../../chunks/bundle-BOCMTfPs.js');
require('../../chunks/bundle-CpC9YeBR.js');
require('@sendbird/chat/message');
require('../../chunks/bundle-dLmOq83s.js');
require('../../chunks/bundle-uYwxiwiJ.js');
require('../../chunks/bundle-C34VSCT5.js');
require('../../chunks/bundle-Wulpj6-2.js');
require('../../chunks/bundle-WAp-MTVO.js');
require('../../chunks/bundle-BNbtTuYT.js');
require('../../chunks/bundle-BpTO3vXw.js');
require('../../chunks/bundle-DfikOY-r.js');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-yToAKC5T.js');
require('../../Message/hooks/useDirtyGetMentions.js');
require('../../ui/DateSeparator.js');
require('../../chunks/bundle-IoTRqH9_.js');
require('../../ui/MessageInput.js');
require('../../chunks/bundle-CTDM43-k.js');
require('../../chunks/bundle-BdcIzrzX.js');
require('dompurify');
require('../../chunks/bundle-CGQPCPQH.js');
require('../../chunks/bundle-UNETZ57a.js');
require('../../chunks/bundle-Dy478tIp.js');
require('../../chunks/bundle-SpBht3pR.js');
require('../../ui/MessageContent.js');
require('../../chunks/bundle-CYQxg_eZ.js');
require('../../ui/Loader.js');
require('../../chunks/bundle-CwmDNzaS.js');
require('../../chunks/bundle-DfHbVMlf.js');
require('../../chunks/bundle-CcIJkgZG.js');
require('../../ui/MessageItemReactionMenu.js');
require('../../ui/ImageRenderer.js');
require('../../ui/ReactionButton.js');
require('../../chunks/bundle-5TSvGYIo.js');
require('../../ui/EmojiReactions.js');
require('../../ui/ReactionBadge.js');
require('../../ui/BottomSheet.js');
require('../../ui/UserListItem.js');
require('../../chunks/bundle-BLMOFXug.js');
require('../../chunks/bundle-DYd16-N-.js');
require('../../ui/MutedAvatarOverlay.js');
require('../../ui/Checkbox.js');
require('../../ui/UserProfile.js');
require('../../sendbirdSelectors.js');
require('../../ui/Tooltip.js');
require('../../ui/TooltipWrapper.js');
require('../../Message/context.js');
require('../../ui/AdminMessage.js');
require('../../ui/QuoteMessage.js');
require('../../chunks/bundle-D_527Yzl.js');
require('../../ui/MobileMenu.js');
require('../../ui/ThreadReplies.js');
require('../../chunks/bundle-28jK5HyI.js');
require('../../ui/OGMessageItemBody.js');
require('../../chunks/bundle-DraJ_wBk.js');
require('../../ui/MentionLabel.js');
require('../../ui/LinkLabel.js');
require('../../ui/TextMessageItemBody.js');
require('../../ui/FileMessageItemBody.js');
require('../../ui/TextButton.js');
require('../../chunks/bundle-BOfy7MGc.js');
require('../../ui/FileViewer.js');
require('../../chunks/bundle-DFxc2FDf.js');
require('../../ui/VoiceMessageItemBody.js');
require('../../ui/ProgressBar.js');
require('../../VoicePlayer/useVoicePlayer.js');
require('../../ui/PlaybackTime.js');
require('../../ui/ThumbnailMessageItemBody.js');
require('../../ui/UnknownMessageItemBody.js');
require('../../ui/TemplateMessageItemBody.js');
require('../../chunks/bundle-2FdfAfSg.js');
require('../../ui/FallbackTemplateMessageItemBody.tsx.js');
require('../../ui/LoadingTemplateMessageItemBody.tsx.js');
require('../../ui/MessageFeedbackFailedModal.js');
require('../../ui/FeedbackIconButton.js');
require('../../ui/MobileFeedbackMenu.js');
require('../../ui/MessageFeedbackModal.js');
require('../../ui/Input.js');
require('../../chunks/bundle-Cbhlvswp.js');
require('../../GroupChannel/components/SuggestedReplies.js');
require('../../chunks/bundle-CZlcUhal.js');
require('../../chunks/bundle-C5vMy3lQ.js');
require('../../chunks/bundle-DHUHtf9o.js');
require('../../chunks/bundle-DbLH7rSK.js');

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

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

var Message = function (props) {
    var _a, _b;
    var config = useSendbirdStateContext.useSendbirdStateContext().config;
    var _c = Channel_context.useChannelContext(), initialized = _c.initialized, currentGroupChannel = _c.currentGroupChannel, animatedMessageId = _c.animatedMessageId, setAnimatedMessageId = _c.setAnimatedMessageId, updateMessage = _c.updateMessage, scrollToMessage = _c.scrollToMessage, replyType = _c.replyType, threadReplySelectType = _c.threadReplySelectType, isReactionEnabled = _c.isReactionEnabled, toggleReaction = _c.toggleReaction, emojiContainer = _c.emojiContainer, nicknamesMap = _c.nicknamesMap, setQuoteMessage = _c.setQuoteMessage, resendMessage = _c.resendMessage, deleteMessage = _c.deleteMessage, renderUserMentionItem = _c.renderUserMentionItem, onReplyInThread = _c.onReplyInThread, onQuoteMessageClick = _c.onQuoteMessageClick, onMessageAnimated = _c.onMessageAnimated, sendMessage = _c.sendMessage, localMessages = _c.localMessages, allMessages = _c.allMessages;
    var message = props.message;
    if (!currentGroupChannel)
        return null;
    return (React__default.default.createElement(MessageView.MessageView, _tslib.__assign({}, props, { channel: currentGroupChannel, emojiContainer: emojiContainer, editInputDisabled: !initialized || utils.isDisabledBecauseFrozen(currentGroupChannel) || utils.isDisabledBecauseMuted(currentGroupChannel) || !config.isOnline, shouldRenderSuggestedReplies: ((_a = config === null || config === void 0 ? void 0 : config.groupChannel) === null || _a === void 0 ? void 0 : _a.enableSuggestedReplies)
            && (((_b = config === null || config === void 0 ? void 0 : config.groupChannel) === null || _b === void 0 ? void 0 : _b.showSuggestedRepliesFor) === 'all_messages'
                ? true
                : message.messageId === allMessages[allMessages.length - 1].messageId
            // Use `allMessages[allMessages.length - 1]` instead of `currentGroupChannel.lastMessage`
            // because lastMessage is not updated when **Bot** sends messages
            )
            // the options should appear only when there's no failed or pending messages
            && (localMessages === null || localMessages === void 0 ? void 0 : localMessages.length) === 0
            && index.getSuggestedReplies(message).length > 0, isReactionEnabled: isReactionEnabled, replyType: replyType, threadReplySelectType: threadReplySelectType, nicknamesMap: nicknamesMap, renderUserMentionItem: renderUserMentionItem, scrollToMessage: scrollToMessage, toggleReaction: toggleReaction, setQuoteMessage: setQuoteMessage, onQuoteMessageClick: onQuoteMessageClick, onReplyInThreadClick: onReplyInThread, sendUserMessage: function (params) {
            sendMessage({
                message: params.message,
                mentionedUsers: params.mentionedUsers,
                mentionTemplate: params.mentionedMessageTemplate,
            });
        }, updateUserMessage: function (messageId, params) {
            var _a;
            updateMessage({
                messageId: messageId,
                message: (_a = params.message) !== null && _a !== void 0 ? _a : '',
                mentionedUsers: params.mentionedUsers,
                mentionTemplate: params.mentionedMessageTemplate,
            });
        }, resendMessage: resendMessage, deleteMessage: deleteMessage, animatedMessageId: animatedMessageId, setAnimatedMessageId: setAnimatedMessageId, onMessageAnimated: onMessageAnimated, renderFileViewer: function (props) { return React__default.default.createElement(Channel_components_FileViewer.FileViewer, _tslib.__assign({}, props)); }, renderRemoveMessageModal: function (props) { return React__default.default.createElement(Channel_components_RemoveMessageModal, _tslib.__assign({}, props)); } })));
};

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