import { i as isSameDay } from '../../chunks/bundle-nD2ZWBq4.js';
import { compareMessagesForGrouping } from './compareMessagesForGrouping.js';
import '../../chunks/bundle-hDx2-CRe.js';
import '../../chunks/bundle-ULVw0l0r.js';
import '../../chunks/bundle-N9hMnIRl.js';
import '../../chunks/bundle-BA7tv0JB.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-aKXnhi3A.js';

/**
 * exported, should be backward compatible
 */
var getMessagePartsInfo = function (_a) {
    var _b = _a.allMessages, allMessages = _b === void 0 ? [] : _b, _c = _a.isMessageGroupingEnabled, isMessageGroupingEnabled = _c === void 0 ? true : _c, _d = _a.currentIndex, currentIndex = _d === void 0 ? 0 : _d, _e = _a.currentMessage, currentMessage = _e === void 0 ? null : _e, _f = _a.currentChannel, currentChannel = _f === void 0 ? null : _f, _g = _a.replyType, replyType = _g === void 0 ? '' : _g;
    var previousMessage = allMessages[currentIndex - 1];
    var nextMessage = allMessages[currentIndex + 1];
    var _h = isMessageGroupingEnabled
        ? compareMessagesForGrouping(previousMessage, currentMessage, nextMessage, currentChannel, replyType)
        : [false, false], chainTop = _h[0], chainBottom = _h[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
