import { _ as __assign } from '../../chunks/bundle-7oF7KbGv.js';
import React__default from 'react';
import { useIIFE } from '@sendbird/uikit-tools';
import { useSendbirdStateContext } from '../../useSendbirdStateContext.js';
import { e as isSendableMessage, g as getSuggestedReplies } from '../../chunks/bundle-BWCGFXhj.js';
import { i as isDisabledBecauseFrozen, a as isDisabledBecauseMuted } from '../../chunks/bundle-BvG71y_P.js';
import { useGroupChannelContext } from '../context.js';
import { M as MessageView } from '../../chunks/bundle-CDwtSJbC.js';
import { FileViewer } from './FileViewer.js';
import { RemoveMessageModal } from './RemoveMessageModal.js';
import '../../withSendbird.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '@sendbird/chat/message';
import '../../chunks/bundle-B7barEsR.js';
import '../../chunks/bundle-oCSRGy9i.js';
import '../../chunks/bundle-BtY8jyVv.js';
import '../../chunks/bundle-DaoHZIZy.js';
import '../../chunks/bundle-CD9AzC6s.js';
import '../../chunks/bundle-DDkUg3Os.js';
import '../../chunks/bundle-uBJzoaNT.js';
import '../../chunks/bundle-2uJIsyo2.js';
import '../../chunks/bundle-BWuyd0AD.js';
import '../../chunks/bundle-Jir4hfa9.js';
import '../../chunks/bundle-C040958G.js';
import '../../chunks/bundle-C1ds4cil.js';
import '../../chunks/bundle-Bx5vhTbU.js';
import '../../chunks/bundle-C8im5l9B.js';
import '../../chunks/bundle-BOSnopxk.js';
import '../../Message/hooks/useDirtyGetMentions.js';
import '../../ui/DateSeparator.js';
import '../../chunks/bundle-HoQqraNc.js';
import '../../chunks/bundle-LYAWKk4n.js';
import '../../ui/MessageInput.js';
import '../../chunks/bundle-QxUVt4Ms.js';
import '../../ui/IconButton.js';
import '../../ui/Button.js';
import '../../chunks/bundle-DO1vNias.js';
import 'dompurify';
import '../../chunks/bundle-B5N2u5f-.js';
import '../../chunks/bundle-DSOf9RKe.js';
import '../../chunks/bundle-DQ2q-zNM.js';
import '../../ui/Icon.js';
import '../../chunks/bundle-ByvmbZD0.js';
import '../../chunks/bundle-DpGWywZ5.js';
import '../../ui/MessageContent.js';
import '../../chunks/bundle-DJTSztr0.js';
import '../../ui/Loader.js';
import '../../chunks/bundle-yZ1rqvSQ.js';
import '../../chunks/bundle-CaaUNO3F.js';
import '../../ui/MessageItemMenu.js';
import '../../ui/ContextMenu.js';
import '../../chunks/bundle-BbWD2VuS.js';
import 'react-dom';
import '@sendbird/chat';
import '@sendbird/chat/openChannel';
import '../../ui/SortByRow.js';
import '../../chunks/bundle-BJ46V6XQ.js';
import '../../chunks/bundle-DmYqVYeD.js';
import '../../ui/MessageItemReactionMenu.js';
import '../../ui/ImageRenderer.js';
import '../../ui/ReactionButton.js';
import '../../chunks/bundle-Gx0ryc_f.js';
import '../../chunks/bundle-Diqj6For.js';
import '../../ui/EmojiReactions.js';
import '../../ui/ReactionBadge.js';
import '../../ui/BottomSheet.js';
import '../../chunks/bundle-C4Z-NWqF.js';
import 'css-vars-ponyfill';
import '../../chunks/bundle-CIwVkd-E.js';
import '../../ui/UserListItem.js';
import '../../chunks/bundle-CNJMLyGJ.js';
import '../../chunks/bundle-CT8ZXUi2.js';
import '../../ui/MutedAvatarOverlay.js';
import '../../ui/Checkbox.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';
import '../../ui/Tooltip.js';
import '../../ui/TooltipWrapper.js';
import '../../Message/context.js';
import '../../ui/AdminMessage.js';
import '../../ui/QuoteMessage.js';
import '../../chunks/bundle-DDhhxSv0.js';
import '../../chunks/bundle-DXCQovsu.js';
import '../../ui/ThreadReplies.js';
import '../../ui/OGMessageItemBody.js';
import '../../chunks/bundle-C1hw1sij.js';
import '../../ui/MentionLabel.js';
import '../../ui/LinkLabel.js';
import '../../ui/TextMessageItemBody.js';
import '../../ui/FileMessageItemBody.js';
import '../../ui/TextButton.js';
import '../../chunks/bundle--nVHk3fx.js';
import '../../chunks/bundle-B__zC9zD.js';
import '../../chunks/bundle-D_eJq5Xk.js';
import '../../ui/VoiceMessageItemBody.js';
import '../../ui/ProgressBar.js';
import '../../VoicePlayer/useVoicePlayer.js';
import '../../ui/PlaybackTime.js';
import '../../ui/ThumbnailMessageItemBody.js';
import '../../ui/UnknownMessageItemBody.js';
import '../../ui/TemplateMessageItemBody.js';
import '../../chunks/bundle-IGQYX_K1.js';
import '../../ui/FallbackTemplateMessageItemBody.tsx.js';
import '../../ui/LoadingTemplateMessageItemBody.tsx.js';
import '../../ui/FeedbackIconButton.js';
import '../../ui/MobileFeedbackMenu.js';
import '../../ui/MessageFeedbackModal.js';
import '../../ui/Input.js';
import '../../ui/MessageFeedbackFailedModal.js';
import './SuggestedReplies.js';
import '../../chunks/bundle-DlfN5GTa.js';
import '../../chunks/bundle-BAvMd_j0.js';
import '../../chunks/bundle-afCfXO2C.js';
import '../../chunks/bundle-DzxiMlgV.js';

var Message = function (props) {
    var _a = useSendbirdStateContext(), config = _a.config, emojiManager = _a.emojiManager;
    var _b = 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 shouldRenderSuggestedReplies = useIIFE(function () {
        var _a;
        var _b = config.groupChannel, enableSuggestedReplies = _b.enableSuggestedReplies, showSuggestedRepliesFor = _b.showSuggestedRepliesFor;
        var lastMessageInView = messages[messages.length - 1];
        var hasUnsentMessage = isSendableMessage(lastMessageInView) && lastMessageInView.sendingStatus !== 'succeeded';
        var showSuggestedReplies = showSuggestedRepliesFor === 'all_messages' ? true : message.messageId === ((_a = currentChannel === null || currentChannel === void 0 ? void 0 : currentChannel.lastMessage) === null || _a === void 0 ? void 0 : _a.messageId);
        return enableSuggestedReplies && getSuggestedReplies(message).length > 0 && !hasUnsentMessage && showSuggestedReplies;
    });
    return (React__default.createElement(MessageView, __assign({}, props, { channel: currentChannel, emojiContainer: emojiManager.emojiContainer, editInputDisabled: !initialized || isDisabledBecauseFrozen(currentChannel) || 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__default.createElement(FileViewer, __assign({}, props)); }, renderRemoveMessageModal: function (props) { return React__default.createElement(RemoveMessageModal, __assign({}, props)); }, usedInLegacy: false, onBeforeDownloadFileMessage: onBeforeDownloadFileMessage })));
};

export { Message, Message as default };
//# sourceMappingURL=Message.js.map
