'use strict';

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

var _tslib = require('../../chunks/bundle-Conb-pOy.js');
var React = require('react');
var uikitTools = require('@sendbird/uikit-tools');
var index = require('../../chunks/bundle-fYxs1lss.js');
var utils = require('../../chunks/bundle-PVDrKOjZ.js');
var MessageView = require('../../chunks/bundle-CPoi7VvJ.js');
var GroupChannel_components_FileViewer = require('./FileViewer.js');
var GroupChannel_components_RemoveMessageModal = require('./RemoveMessageModal.js');
var _const = require('../../chunks/bundle-BLz2EOZ5.js');
var GroupChannelProvider = require('../../chunks/bundle-C0RMVFg8.js');
var useSendbird = require('../../chunks/bundle-Bq15P9qk.js');
require('@sendbird/chat/groupChannel');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-DAdgL6r8.js');
require('../../chunks/bundle-Dobj18FB.js');
require('../../chunks/bundle-CVJwHwWn.js');
require('../../chunks/bundle-Cfh78Xnm.js');
require('../../chunks/bundle-CHAKEXIJ.js');
require('../../chunks/bundle-Cyl6_qLo.js');
require('../../chunks/bundle-DPDyqKIJ.js');
require('../../chunks/bundle-BbrBawlX.js');
require('../../Message/hooks/useDirtyGetMentions.js');
require('../../ui/DateSeparator.js');
require('../../chunks/bundle-DurllD3r.js');
require('../../chunks/bundle-zgmRG2KL.js');
require('../../ui/MessageInput.js');
require('../../chunks/bundle-Bomzwcdt.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('../../chunks/bundle-VKi81862.js');
require('dompurify');
require('../../chunks/bundle-DHuNGmIj.js');
require('../../chunks/bundle-2PCdBxVA.js');
require('../../chunks/bundle-BkgFGPs_.js');
require('../../ui/Icon.js');
require('../../chunks/bundle-CkQrhwR6.js');
require('../../chunks/bundle-CzkEKbFB.js');
require('../../ui/MessageContent.js');
require('../../chunks/bundle-DO5FgbkI.js');
require('../../ui/Loader.js');
require('../../chunks/bundle-ptQgj0WJ.js');
require('../../chunks/bundle-DQaXgp8o.js');
require('../../chunks/bundle-Y-wq3CF0.js');
require('../../chunks/bundle-DGV1BX0m.js');
require('react-dom');
require('@sendbird/chat');
require('@sendbird/chat/openChannel');
require('../../ui/SortByRow.js');
require('../../chunks/bundle-t8BQsgL5.js');
require('../../chunks/bundle-B19RHFpR.js');
require('../../ui/MessageItemReactionMenu.js');
require('../../ui/ImageRenderer.js');
require('../../ui/ReactionButton.js');
require('../../chunks/bundle-C5p82xwC.js');
require('../../chunks/bundle-Fv6PNPGZ.js');
require('../../ui/EmojiReactions.js');
require('../../ui/ReactionBadge.js');
require('../../ui/BottomSheet.js');
require('../../hooks/useModal.js');
require('../../chunks/bundle-DZlJeh0V.js');
require('../../ui/UserListItem.js');
require('../../chunks/bundle-Bnb8seJF.js');
require('../../chunks/bundle-B7KG10z2.js');
require('../../chunks/bundle-C99t7tzf.js');
require('../../ui/MutedAvatarOverlay.js');
require('../../ui/Checkbox.js');
require('../../ui/UserProfile.js');
require('../../sendbirdSelectors.js');
require('../../chunks/bundle-dUH189qO.js');
require('../../ui/Tooltip.js');
require('../../ui/TooltipWrapper.js');
require('../../Message/context.js');
require('../../chunks/bundle-CXbYckbN.js');
require('../../ui/AdminMessage.js');
require('../../ui/QuoteMessage.js');
require('../../chunks/bundle-D9d0Qum8.js');
require('@sendbird/chat/message');
require('../../ui/MobileMenu.js');
require('../../ui/ThreadReplies.js');
require('../../chunks/bundle-DYon6O60.js');
require('../../ui/OGMessageItemBody.js');
require('../../chunks/bundle-CX7K4z2J.js');
require('../../ui/MentionLabel.js');
require('../../ui/LinkLabel.js');
require('../../ui/TextMessageItemBody.js');
require('../../ui/FileMessageItemBody.js');
require('../../ui/TextButton.js');
require('../../chunks/bundle-KzwW_H6y.js');
require('../../ui/FileViewer.js');
require('../../chunks/bundle-Yq_R9TAN.js');
require('../../ui/VoiceMessageItemBody.js');
require('../../ui/ProgressBar.js');
require('../../VoicePlayer/useVoicePlayer.js');
require('../../chunks/bundle-BHp3N9Mz.js');
require('../../VoiceRecorder/context.js');
require('../../ui/PlaybackTime.js');
require('../../ui/ThumbnailMessageItemBody.js');
require('../../ui/UnknownMessageItemBody.js');
require('../../ui/TemplateMessageItemBody.js');
require('../../chunks/bundle-Bt1qvip8.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-BwwNS3QS.js');
require('./SuggestedReplies.js');
require('../../chunks/bundle-B7tlFbQZ.js');
require('../../chunks/bundle-8juyGk3c.js');
require('../../chunks/bundle-COgAaDxc.js');
require('../../chunks/bundle-B2b-r84m.js');
require('../../chunks/bundle-19BZVS4G.js');
require('../../chunks/bundle-BPUhuptz.js');
require('../../chunks/bundle-CxArG0ag.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, markAsUnread = _b.markAsUnread, _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 === null || lastMessageInView === void 0 ? void 0 : lastMessageInView.sendingStatus) !== 'succeeded';
        var showSuggestedReplies = showSuggestedRepliesFor === 'all_messages'
            ? true
            : message.messageId === (lastMessageInView === null || lastMessageInView === void 0 ? void 0 : 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 === null || emojiManager === void 0 ? void 0 : 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, markAsUnread: markAsUnread, 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
