import { _ as __assign } from '../../chunks/bundle-B8Grfnrx.js';
import React__default from 'react';
import { useIIFE } from '@sendbird/uikit-tools';
import { l as isSendableMessage, g as getSuggestedReplies } from '../../chunks/bundle-CgLhYjm5.js';
import { i as isDisabledBecauseFrozen, a as isDisabledBecauseMuted } from '../../chunks/bundle-D8xAej93.js';
import { M as MessageView } from '../../chunks/bundle-CuP5OWwY.js';
import { FileViewer } from './FileViewer.js';
import { RemoveMessageModal } from './RemoveMessageModal.js';
import { T as ThreadReplySelectType } from '../../chunks/bundle-BciLDE6M.js';
import { u as useGroupChannel } from '../../chunks/bundle-D4BlmM5H.js';
import { u as useSendbird } from '../../chunks/bundle-I25ah_Bv.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-BTxw_tIt.js';
import '../../chunks/bundle-De-3zaYV.js';
import '../../chunks/bundle-DYBTopZK.js';
import '../../chunks/bundle-Ob7Cw3V-.js';
import '../../chunks/bundle-Dy1IZ181.js';
import '../../chunks/bundle-BYOddwmS.js';
import '../../chunks/bundle-l_QLKq1Y.js';
import '../../chunks/bundle-Y2KBbxRr.js';
import '../../Message/hooks/useDirtyGetMentions.js';
import '../../ui/DateSeparator.js';
import '../../chunks/bundle-DED6q4Ti.js';
import '../../chunks/bundle-HspRRkmy.js';
import '../../ui/MessageInput.js';
import '../../chunks/bundle-DXneAdAp.js';
import '../../ui/IconButton.js';
import '../../ui/Button.js';
import '../../chunks/bundle-DwLTEVMK.js';
import 'dompurify';
import '../../chunks/bundle-Dp_oW1ks.js';
import '../../chunks/bundle-Cn2czFA-.js';
import '../../chunks/bundle-4w9Y7uxA.js';
import '../../ui/Icon.js';
import '../../chunks/bundle-CDcu1I4f.js';
import '../../chunks/bundle-DT1VcdMs.js';
import '../../ui/MessageContent.js';
import '../../chunks/bundle-Dd7rgmeQ.js';
import '../../ui/Loader.js';
import '../../chunks/bundle-Dhf37wzM.js';
import '../../chunks/bundle-C8TP-mjp.js';
import '../../chunks/bundle-CQAiZVNS.js';
import '../../chunks/bundle-QCH8CZT8.js';
import 'react-dom';
import '@sendbird/chat';
import '@sendbird/chat/openChannel';
import '../../ui/SortByRow.js';
import '../../chunks/bundle-CTkGIdt8.js';
import '../../chunks/bundle-C4OmfIXk.js';
import '../../ui/MessageItemReactionMenu.js';
import '../../ui/ImageRenderer.js';
import '../../ui/ReactionButton.js';
import '../../chunks/bundle-CJmXP56m.js';
import '../../chunks/bundle-yKqHFFfz.js';
import '../../ui/EmojiReactions.js';
import '../../ui/ReactionBadge.js';
import '../../ui/BottomSheet.js';
import '../../hooks/useModal.js';
import '../../chunks/bundle-LnGQMQVt.js';
import '../../ui/UserListItem.js';
import '../../chunks/bundle-BYqblmEM.js';
import '../../chunks/bundle-DgFzcADJ.js';
import '../../chunks/bundle-C_ngoQD_.js';
import '../../ui/MutedAvatarOverlay.js';
import '../../ui/Checkbox.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';
import '../../chunks/bundle--1cImOGd.js';
import '../../ui/Tooltip.js';
import '../../ui/TooltipWrapper.js';
import '../../Message/context.js';
import '../../chunks/bundle-C6Hk5xTT.js';
import '../../ui/AdminMessage.js';
import '../../ui/QuoteMessage.js';
import '../../chunks/bundle-tFnb24Id.js';
import '@sendbird/chat/message';
import '../../ui/MobileMenu.js';
import '../../ui/ThreadReplies.js';
import '../../chunks/bundle-CEE3GJSk.js';
import '../../ui/OGMessageItemBody.js';
import '../../chunks/bundle-Do9UFGCD.js';
import '../../ui/MentionLabel.js';
import '../../ui/LinkLabel.js';
import '../../ui/TextMessageItemBody.js';
import '../../ui/FileMessageItemBody.js';
import '../../ui/TextButton.js';
import '../../chunks/bundle-BFJ4ctRk.js';
import '../../ui/FileViewer.js';
import '../../chunks/bundle-DgpfIrde.js';
import '../../ui/VoiceMessageItemBody.js';
import '../../ui/ProgressBar.js';
import '../../VoicePlayer/useVoicePlayer.js';
import '../../chunks/bundle-zOZq2Vpt.js';
import '../../VoiceRecorder/context.js';
import '../../ui/PlaybackTime.js';
import '../../ui/ThumbnailMessageItemBody.js';
import '../../ui/UnknownMessageItemBody.js';
import '../../ui/TemplateMessageItemBody.js';
import '../../chunks/bundle-CwHldvb8.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-CFXaZ31h.js';
import './SuggestedReplies.js';
import '../../chunks/bundle-CF8V-ET_.js';
import '../../chunks/bundle-BGj68IUE.js';
import '../../chunks/bundle-C60pq62Y.js';
import '../../chunks/bundle-DDZn5buS.js';
import '../../chunks/bundle-Dx4-1s0A.js';
import '../../chunks/bundle-B5_aP8LE.js';
import '../../chunks/bundle-C5Pz6wMm.js';

var Message = function (props) {
    var state = useSendbird().state;
    var config = state.config, emojiManager = state.emojiManager;
    var _a = 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 = 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
