'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _tslib = require('../../chunks/bundle-CxoFSSXv.js');
var React = require('react');
var uikitTools = require('@sendbird/uikit-tools');
var index = require('../../chunks/bundle-D7YiKR6i.js');
var utils = require('../../chunks/bundle-CzJX13Yl.js');
var MessageView = require('../../chunks/bundle-BX4VESNC.js');
var GroupChannel_components_FileViewer = require('./FileViewer.js');
var GroupChannel_components_RemoveMessageModal = require('./RemoveMessageModal.js');
var _const = require('../../chunks/bundle-kPv1Olqr.js');
var GroupChannelProvider = require('../../chunks/bundle-DJOukqkN.js');
var useSendbird = require('../../chunks/bundle-LI9JjqG2.js');
require('@sendbird/chat/groupChannel');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-dfqZUdij.js');
require('../../chunks/bundle-Dn0hi6OJ.js');
require('../../chunks/bundle-C1G0SKDq.js');
require('../../chunks/bundle-yU9Mr2pS.js');
require('../../chunks/bundle-FJtjwZwh.js');
require('../../chunks/bundle-BV7y6VDn.js');
require('../../chunks/bundle-DDNdw3A9.js');
require('../../chunks/bundle-EhtiN7UV.js');
require('../../Message/hooks/useDirtyGetMentions.js');
require('../../ui/DateSeparator.js');
require('../../chunks/bundle-BIrmQghI.js');
require('../../chunks/bundle-B0UICprZ.js');
require('../../ui/MessageInput.js');
require('../../chunks/bundle-Cwboa2Wr.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('../../chunks/bundle-Bx1_cAVo.js');
require('dompurify');
require('../../chunks/bundle-za5uPkdP.js');
require('../../chunks/bundle-CgCnWqE5.js');
require('../../chunks/bundle-BXvzT2m9.js');
require('../../ui/Icon.js');
require('../../chunks/bundle-DQNu-S6D.js');
require('../../chunks/bundle-CXHWkhsI.js');
require('../../ui/MessageContent.js');
require('../../chunks/bundle-BFKxvlzn.js');
require('../../ui/Loader.js');
require('../../chunks/bundle-CBLzrxjV.js');
require('../../chunks/bundle-B9BY1g5d.js');
require('../../chunks/bundle-D2TXT2xX.js');
require('../../chunks/bundle-Bqahh-7Q.js');
require('react-dom');
require('@sendbird/chat');
require('@sendbird/chat/openChannel');
require('../../ui/SortByRow.js');
require('../../chunks/bundle-BUGwK1WK.js');
require('../../chunks/bundle-AAO7jUU2.js');
require('../../ui/MessageItemReactionMenu.js');
require('../../ui/ImageRenderer.js');
require('../../ui/ReactionButton.js');
require('../../chunks/bundle-Bd-cNaJc.js');
require('../../chunks/bundle-CyQD5TkW.js');
require('../../ui/EmojiReactions.js');
require('../../ui/ReactionBadge.js');
require('../../ui/BottomSheet.js');
require('../../hooks/useModal.js');
require('../../chunks/bundle-YeW89zsR.js');
require('../../ui/UserListItem.js');
require('../../chunks/bundle-DeyX1dvY.js');
require('../../chunks/bundle-CLL-nCFU.js');
require('../../chunks/bundle-C8MACRPO.js');
require('../../ui/MutedAvatarOverlay.js');
require('../../ui/Checkbox.js');
require('../../ui/UserProfile.js');
require('../../sendbirdSelectors.js');
require('../../chunks/bundle-BPWJgESF.js');
require('../../ui/Tooltip.js');
require('../../ui/TooltipWrapper.js');
require('../../Message/context.js');
require('../../chunks/bundle-DsZL8mH-.js');
require('../../ui/AdminMessage.js');
require('../../ui/QuoteMessage.js');
require('../../chunks/bundle-BPGU6BH2.js');
require('@sendbird/chat/message');
require('../../ui/MobileMenu.js');
require('../../ui/ThreadReplies.js');
require('../../chunks/bundle-G4J-OWth.js');
require('../../ui/OGMessageItemBody.js');
require('../../chunks/bundle-vEi_Cfco.js');
require('../../ui/MentionLabel.js');
require('../../ui/LinkLabel.js');
require('../../ui/TextMessageItemBody.js');
require('../../ui/FileMessageItemBody.js');
require('../../ui/TextButton.js');
require('../../chunks/bundle-Cq2Y8hPN.js');
require('../../ui/FileViewer.js');
require('../../chunks/bundle-DNjcGEfJ.js');
require('../../ui/VoiceMessageItemBody.js');
require('../../ui/ProgressBar.js');
require('../../VoicePlayer/useVoicePlayer.js');
require('../../chunks/bundle-DK39NcVd.js');
require('../../VoiceRecorder/context.js');
require('../../ui/PlaybackTime.js');
require('../../ui/ThumbnailMessageItemBody.js');
require('../../ui/UnknownMessageItemBody.js');
require('../../ui/TemplateMessageItemBody.js');
require('../../chunks/bundle-aMt_60_o.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-CPeZ4wPf.js');
require('./SuggestedReplies.js');
require('../../chunks/bundle-DptJHWLW.js');
require('../../chunks/bundle-CaNXlSAv.js');
require('../../chunks/bundle-L8U6SolV.js');
require('../../chunks/bundle-C4t_1F0C.js');
require('../../chunks/bundle-B2KoWBOt.js');
require('../../chunks/bundle-CG2rv5Ij.js');
require('../../chunks/bundle-ChpcAmBg.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 state = useSendbird.useSendbird().state;
    var config = state.config, emojiManager = state.emojiManager;
    var _a = GroupChannelProvider.useGroupChannel(), _b = _a.state, loading = _b.loading, currentChannel = _b.currentChannel, animatedMessageId = _b.animatedMessageId, replyType = _b.replyType, threadReplySelectType = _b.threadReplySelectType, isReactionEnabled = _b.isReactionEnabled, nicknamesMap = _b.nicknamesMap, renderUserMentionItem = _b.renderUserMentionItem, filterEmojiCategoryIds = _b.filterEmojiCategoryIds, onQuoteMessageClick = _b.onQuoteMessageClick, onReplyInThreadClick = _b.onReplyInThreadClick, onMessageAnimated = _b.onMessageAnimated, onBeforeDownloadFileMessage = _b.onBeforeDownloadFileMessage, messages = _b.messages, _c = _a.actions, toggleReaction = _c.toggleReaction, setQuoteMessage = _c.setQuoteMessage, setAnimatedMessageId = _c.setAnimatedMessageId, scrollToMessage = _c.scrollToMessage, updateUserMessage = _c.updateUserMessage, sendUserMessage = _c.sendUserMessage, resendMessage = _c.resendMessage, deleteMessage = _c.deleteMessage;
    var message = props.message;
    var initialized = !loading && Boolean(currentChannel);
    var shouldRenderSuggestedReplies = uikitTools.useIIFE(function () {
        var _a = config.groupChannel, enableSuggestedReplies = _a.enableSuggestedReplies, showSuggestedRepliesFor = _a.showSuggestedRepliesFor;
        // Use `allMessages[allMessages.length - 1]` instead of `currentGroupChannel.lastMessage`
        // because lastMessage is not updated when **Bot** sends messages
        var lastMessageInView = messages[messages.length - 1];
        var hasUnsentMessage = index.isSendableMessage(lastMessageInView) && lastMessageInView.sendingStatus !== 'succeeded';
        var showSuggestedReplies = showSuggestedRepliesFor === 'all_messages'
            ? true
            : message.messageId === lastMessageInView.messageId;
        return enableSuggestedReplies && index.getSuggestedReplies(message).length > 0 && !hasUnsentMessage && showSuggestedReplies;
    });
    return (React__default.default.createElement(MessageView.MessageView, _tslib.__assign({}, props, { channel: currentChannel, emojiContainer: emojiManager.emojiContainer, editInputDisabled: !initialized
            || utils.isDisabledBecauseFrozen(currentChannel !== null && currentChannel !== void 0 ? currentChannel : undefined)
            || utils.isDisabledBecauseMuted(currentChannel !== null && currentChannel !== void 0 ? currentChannel : undefined)
            || !config.isOnline, shouldRenderSuggestedReplies: shouldRenderSuggestedReplies, isReactionEnabled: isReactionEnabled !== null && isReactionEnabled !== void 0 ? isReactionEnabled : false, replyType: replyType !== null && replyType !== void 0 ? replyType : 'NONE', threadReplySelectType: threadReplySelectType !== null && threadReplySelectType !== void 0 ? threadReplySelectType : _const.ThreadReplySelectType.PARENT, nicknamesMap: nicknamesMap, renderUserMentionItem: renderUserMentionItem, filterEmojiCategoryIds: filterEmojiCategoryIds, scrollToMessage: scrollToMessage, toggleReaction: toggleReaction, setQuoteMessage: setQuoteMessage, onQuoteMessageClick: onQuoteMessageClick, onReplyInThreadClick: onReplyInThreadClick, sendUserMessage: sendUserMessage, updateUserMessage: updateUserMessage, resendMessage: resendMessage, deleteMessage: deleteMessage, animatedMessageId: animatedMessageId, setAnimatedMessageId: setAnimatedMessageId, onMessageAnimated: onMessageAnimated, renderFileViewer: function (props) { return React__default.default.createElement(GroupChannel_components_FileViewer.FileViewer, _tslib.__assign({}, props)); }, renderRemoveMessageModal: function (props) { return React__default.default.createElement(GroupChannel_components_RemoveMessageModal.RemoveMessageModal, _tslib.__assign({}, props)); }, usedInLegacy: false, onBeforeDownloadFileMessage: onBeforeDownloadFileMessage })));
};

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