import { i as isSameDay } from '../../chunks/bundle-C8TP-mjp.js';
import { compareMessagesForGrouping } from './compareMessagesForGrouping.js';
import '../../chunks/bundle-DYBTopZK.js';
import '../../chunks/bundle-Dy1IZ181.js';
import '../../chunks/bundle-BYOddwmS.js';
import '../../chunks/bundle-CgLhYjm5.js';
import '../../chunks/bundle-B8Grfnrx.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-Ob7Cw3V-.js';

/**
 * exported, should be backward compatible
 */
var getMessagePartsInfo = function (_a) {
    var allMessages = _a.allMessages, stringSet = _a.stringSet, _b = _a.isMessageGroupingEnabled, isMessageGroupingEnabled = _b === void 0 ? true : _b, _c = _a.currentIndex, currentIndex = _c === void 0 ? 0 : _c, currentMessage = _a.currentMessage, _d = _a.currentChannel, currentChannel = _d === void 0 ? null : _d, _e = _a.replyType, replyType = _e === void 0 ? '' : _e;
    var previousMessage = allMessages[currentIndex - 1];
    var nextMessage = allMessages[currentIndex + 1];
    var _f = isMessageGroupingEnabled
        ? compareMessagesForGrouping(previousMessage, currentMessage, nextMessage, stringSet, currentChannel, replyType)
        : [false, false], chainTop = _f[0], chainBottom = _f[1];
    var previousMessageCreatedAt = previousMessage === null || previousMessage === void 0 ? void 0 : previousMessage.createdAt;
    var currentCreatedAt = currentMessage.createdAt;
    // NOTE: for pending/failed messages
    var isLocalMessage = 'sendingStatus' in currentMessage && (currentMessage.sendingStatus !== 'succeeded');
    // https://stackoverflow.com/a/41855608
    var hasSeparator = isLocalMessage ? false : !(previousMessageCreatedAt && (isSameDay(currentCreatedAt, previousMessageCreatedAt)));
    return {
        chainTop: chainTop,
        chainBottom: chainBottom,
        hasSeparator: hasSeparator,
    };
};

export { getMessagePartsInfo };
//# sourceMappingURL=getMessagePartsInfo.js.map
