import { _ as __assign } from '../../chunks/bundle-CyKcXwxv.js';
import React__default from 'react';
import { useIIFE } from '@sendbird/uikit-tools';
import { useSendbirdStateContext } from '../../useSendbirdStateContext.js';
import { l as isSendableMessage, g as getSuggestedReplies } from '../../chunks/bundle-DCvGHvPz.js';
import { i as isDisabledBecauseFrozen, a as isDisabledBecauseMuted } from '../../chunks/bundle-zh5Jl1yd.js';
import { useGroupChannelContext } from '../context.js';
import { M as MessageView } from '../../chunks/bundle-GG7FwOCN.js';
import { FileViewer } from './FileViewer.js';
import { RemoveMessageModal } from './RemoveMessageModal.js';
import { T as ThreadReplySelectType } from '../../chunks/bundle-N7XRO_Ma.js';
import '../../withSendbird.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-BFKFmP-d.js';
import '../../chunks/bundle-DAYMi6vw.js';
import '../../chunks/bundle-vddg8rUR.js';
import '@sendbird/chat/message';
import '../../chunks/bundle-DV19ISeX.js';
import '../../chunks/bundle-DIM08oup.js';
import '../../chunks/bundle-B43BrwWe.js';
import 'react-dom';
import '../../chunks/bundle-C_RTy-wB.js';
import '../../chunks/bundle-xzHlqm91.js';
import '../../chunks/bundle-yFfkfO0O.js';
import '../../ui/IconButton.js';
import '../../ui/Button.js';
import '../../chunks/bundle-bz4PqMYo.js';
import '../../ui/Icon.js';
import 'css-vars-ponyfill';
import '@sendbird/chat';
import '../../chunks/bundle-BUQ58hWb.js';
import '@sendbird/chat/openChannel';
import '../../chunks/bundle-CKwMZR9c.js';
import '../../chunks/bundle-Bien0gJP.js';
import '../../ui/SortByRow.js';
import '../../chunks/bundle-GyANJ9jq.js';
import '../../chunks/bundle-By4qJA7N.js';
import '../../chunks/bundle-BH8KNCSz.js';
import '../../chunks/bundle-BCRvYX9G.js';
import '../../chunks/bundle-DmBEox5Y.js';
import '../../chunks/bundle-rAzWFbt-.js';
import '../../Message/hooks/useDirtyGetMentions.js';
import '../../ui/DateSeparator.js';
import '../../chunks/bundle-GXXt0WAx.js';
import '../../ui/MessageInput.js';
import '../../chunks/bundle-NEplso7H.js';
import '../../chunks/bundle-CdOhleNh.js';
import 'dompurify';
import '../../chunks/bundle-2Qim3Dap.js';
import '../../chunks/bundle-fX_liw7W.js';
import '../../chunks/bundle-rk3bNfCF.js';
import '../../chunks/bundle-CXmeegua.js';
import '../../ui/MessageContent.js';
import '../../chunks/bundle-DO6Om5Ct.js';
import '../../ui/Loader.js';
import '../../chunks/bundle-BKYxwr2v.js';
import '../../chunks/bundle-DDXgauuR.js';
import '../../chunks/bundle-D3wwnhPQ.js';
import '../../ui/MessageItemReactionMenu.js';
import '../../ui/ImageRenderer.js';
import '../../ui/ReactionButton.js';
import '../../chunks/bundle-D91-xsQ4.js';
import '../../ui/EmojiReactions.js';
import '../../ui/ReactionBadge.js';
import '../../ui/BottomSheet.js';
import '../../ui/UserListItem.js';
import '../../chunks/bundle-BUD_vgZ5.js';
import '../../chunks/bundle-Dmj05jBl.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-Cw9lWLKX.js';
import '../../ui/MobileMenu.js';
import '../../ui/ThreadReplies.js';
import '../../chunks/bundle-B-ZON1no.js';
import '../../ui/OGMessageItemBody.js';
import '../../chunks/bundle-DK6h-KUk.js';
import '../../ui/MentionLabel.js';
import '../../ui/LinkLabel.js';
import '../../ui/TextMessageItemBody.js';
import '../../ui/FileMessageItemBody.js';
import '../../ui/TextButton.js';
import '../../chunks/bundle-DfMC2kfy.js';
import '../../ui/FileViewer.js';
import '../../chunks/bundle-RRVvccZ1.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-BfPwsSYD.js';
import '../../ui/FallbackTemplateMessageItemBody.tsx.js';
import '../../ui/LoadingTemplateMessageItemBody.tsx.js';
import '../../ui/MessageFeedbackFailedModal.js';
import '../../ui/FeedbackIconButton.js';
import '../../ui/MobileFeedbackMenu.js';
import '../../ui/MessageFeedbackModal.js';
import '../../ui/Input.js';
import '../../chunks/bundle-Zi-DQlYN.js';
import './SuggestedReplies.js';
import '../../chunks/bundle-B5Xnb7gI.js';
import '../../chunks/bundle-DMP0TlRl.js';
import '../../chunks/bundle-CtcN5584.js';
import '../../chunks/bundle-DVRTAl51.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, filterEmojiCategoryIds = _b.filterEmojiCategoryIds, 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 = 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 = isSendableMessage(lastMessageInView) && lastMessageInView.sendingStatus !== 'succeeded';
        var showSuggestedReplies = showSuggestedRepliesFor === 'all_messages'
            ? true
            : message.messageId === lastMessageInView.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 !== null && currentChannel !== void 0 ? currentChannel : undefined)
            || 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 : 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.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
