'use strict';

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

var _tslib = require('../../chunks/bundle-5ru_FO5x.js');
var React = require('react');
var uikitTools = require('@sendbird/uikit-tools');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
var index = require('../../chunks/bundle-Ce6jCnmC.js');
var utils = require('../../chunks/bundle-MOn9SqMU.js');
var GroupChannel_context = require('../context.js');
var MessageView = require('../../chunks/bundle-asVjYr1M.js');
var GroupChannel_components_FileViewer = require('./FileViewer.js');
var GroupChannel_components_RemoveMessageModal = require('./RemoveMessageModal.js');
require('../../withSendbird.js');
require('@sendbird/chat/groupChannel');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-BFtlkbFV.js');
require('@sendbird/chat/message');
require('../../chunks/bundle-Cgk-lpZZ.js');
require('../../chunks/bundle-Dv4YKtdL.js');
require('../../chunks/bundle-ghdvllVc.js');
require('../../chunks/bundle-3dML2VBI.js');
require('../../chunks/bundle-MDcnM2N1.js');
require('../../chunks/bundle-Bi2wvpu_.js');
require('../../chunks/bundle-Dpfab45s.js');
require('../../chunks/bundle-BMEm0fE7.js');
require('../../chunks/bundle-BedaAirg.js');
require('../../chunks/bundle-CGX-vhe9.js');
require('../../chunks/bundle-De62SpYH.js');
require('../../chunks/bundle-V-_XUHW5.js');
require('../../chunks/bundle-BLV9zZk1.js');
require('../../chunks/bundle-Ck_8lQa-.js');
require('../../chunks/bundle-DrCmmE89.js');
require('../../Message/hooks/useDirtyGetMentions.js');
require('../../ui/DateSeparator.js');
require('../../chunks/bundle-xUIqwbO0.js');
require('../../chunks/bundle-DCPc6-Im.js');
require('../../ui/MessageInput.js');
require('../../chunks/bundle-DrV1GooU.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('../../chunks/bundle-D0hE0g6d.js');
require('dompurify');
require('../../chunks/bundle-B20ESzEn.js');
require('../../chunks/bundle-9ogjIkrJ.js');
require('../../chunks/bundle-B3qxP7Hx.js');
require('../../ui/Icon.js');
require('../../chunks/bundle-Cd8aIDXf.js');
require('../../chunks/bundle-lBIlhpy4.js');
require('../../ui/MessageContent.js');
require('../../chunks/bundle-DDwAQ_Z-.js');
require('../../ui/Loader.js');
require('../../chunks/bundle-CMTxpe5r.js');
require('../../chunks/bundle-Cf4R8HbK.js');
require('../../ui/MessageItemMenu.js');
require('../../ui/ContextMenu.js');
require('react-dom');
require('@sendbird/chat');
require('@sendbird/chat/openChannel');
require('../../ui/SortByRow.js');
require('../../chunks/bundle-slS7A2f9.js');
require('../../chunks/bundle-Bm-ZyNnL.js');
require('../../ui/MessageItemReactionMenu.js');
require('../../ui/ImageRenderer.js');
require('../../ui/ReactionButton.js');
require('../../chunks/bundle-Bzoa2z57.js');
require('../../chunks/bundle-DqTUSoNi.js');
require('../../ui/EmojiReactions.js');
require('../../ui/ReactionBadge.js');
require('../../ui/BottomSheet.js');
require('../../hooks/useModal.js');
require('../../chunks/bundle-CHERnV8x.js');
require('../../ui/UserListItem.js');
require('../../chunks/bundle-BFWd_LLn.js');
require('../../chunks/bundle-Bvh9LUfE.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-DqRKg94l.js');
require('../../chunks/bundle-BOisWxx6.js');
require('../../ui/ThreadReplies.js');
require('../../ui/OGMessageItemBody.js');
require('../../chunks/bundle-B2jW5UwW.js');
require('../../ui/MentionLabel.js');
require('../../ui/LinkLabel.js');
require('../../ui/TextMessageItemBody.js');
require('../../ui/FileMessageItemBody.js');
require('../../ui/TextButton.js');
require('../../chunks/bundle-BrG6R1ys.js');
require('../../chunks/bundle-CGDy7a1C.js');
require('../../chunks/bundle-OAOzXmfa.js');
require('../../ui/VoiceMessageItemBody.js');
require('../../ui/ProgressBar.js');
require('../../VoicePlayer/useVoicePlayer.js');
require('../../chunks/bundle-BMU1Zuos.js');
require('../../VoiceRecorder/context.js');
require('../../ui/PlaybackTime.js');
require('../../ui/ThumbnailMessageItemBody.js');
require('../../ui/UnknownMessageItemBody.js');
require('../../ui/TemplateMessageItemBody.js');
require('../../chunks/bundle-CRIqKUCJ.js');
require('../../ui/FallbackTemplateMessageItemBody.tsx.js');
require('../../ui/LoadingTemplateMessageItemBody.tsx.js');
require('../../ui/FeedbackIconButton.js');
require('../../ui/MobileFeedbackMenu.js');
require('../../ui/MessageFeedbackModal.js');
require('../../ui/Input.js');
require('../../ui/MessageFeedbackFailedModal.js');
require('./SuggestedReplies.js');
require('../../chunks/bundle-DrPY0rWx.js');
require('../../chunks/bundle-iCZhCxHm.js');
require('../../chunks/bundle-BaxkaZ7Q.js');
require('../../chunks/bundle-DHHo4V-U.js');

var Message = function (props) {
    var _a = useSendbirdStateContext.useSendbirdStateContext(), config = _a.config, emojiManager = _a.emojiManager;
    var _b = GroupChannel_context.useGroupChannelContext(), loading = _b.loading, currentChannel = _b.currentChannel, animatedMessageId = _b.animatedMessageId, setAnimatedMessageId = _b.setAnimatedMessageId, scrollToMessage = _b.scrollToMessage, replyType = _b.replyType, threadReplySelectType = _b.threadReplySelectType, isReactionEnabled = _b.isReactionEnabled, toggleReaction = _b.toggleReaction, nicknamesMap = _b.nicknamesMap, setQuoteMessage = _b.setQuoteMessage, renderUserMentionItem = _b.renderUserMentionItem, onQuoteMessageClick = _b.onQuoteMessageClick, onReplyInThreadClick = _b.onReplyInThreadClick, onMessageAnimated = _b.onMessageAnimated, onBeforeDownloadFileMessage = _b.onBeforeDownloadFileMessage, messages = _b.messages, updateUserMessage = _b.updateUserMessage, sendUserMessage = _b.sendUserMessage, resendMessage = _b.resendMessage, deleteMessage = _b.deleteMessage;
    var message = props.message;
    var initialized = !loading && Boolean(currentChannel);
    var groupChannelConfig = config === null || config === void 0 ? void 0 : config.groupChannel;
    var shouldRenderSuggestedReplies = uikitTools.useIIFE(function () {
        var _a;
        if (!groupChannelConfig)
            return false;
        var enableSuggestedReplies = groupChannelConfig.enableSuggestedReplies, showSuggestedRepliesFor = groupChannelConfig.showSuggestedRepliesFor;
        if (!enableSuggestedReplies)
            return false;
        if ((!showSuggestedRepliesFor || showSuggestedRepliesFor === 'last_message_only')
            && message.messageId === ((_a = currentChannel === null || currentChannel === void 0 ? void 0 : currentChannel.lastMessage) === null || _a === void 0 ? void 0 : _a.messageId))
            return false;
        if (index.getSuggestedReplies(message).length === 0)
            return false;
        var lastMessage = messages[messages.length - 1];
        if (lastMessage && index.isSendableMessage(lastMessage) && lastMessage.sendingStatus !== 'succeeded')
            return false;
        return true;
    });
    return (React.createElement(MessageView.MessageView, _tslib.__assign({}, props, { channel: currentChannel, emojiContainer: emojiManager.emojiContainer, editInputDisabled: !initialized || utils.isDisabledBecauseFrozen(currentChannel) || utils.isDisabledBecauseMuted(currentChannel) || !config.isOnline, shouldRenderSuggestedReplies: shouldRenderSuggestedReplies, isReactionEnabled: isReactionEnabled, replyType: replyType, threadReplySelectType: threadReplySelectType, nicknamesMap: nicknamesMap, renderUserMentionItem: renderUserMentionItem, 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.createElement(GroupChannel_components_FileViewer.FileViewer, _tslib.__assign({}, props)); }, renderRemoveMessageModal: function (props) { return React.createElement(GroupChannel_components_RemoveMessageModal.RemoveMessageModal, _tslib.__assign({}, props)); }, usedInLegacy: false, onBeforeDownloadFileMessage: onBeforeDownloadFileMessage })));
};

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