/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { brand } from "../util/index.js";
export const sequenceIdComparator = (a, b) => a.sequenceNumber !== b.sequenceNumber
    ? a.sequenceNumber - b.sequenceNumber
    : (a.indexInBatch ?? 0) - (b.indexInBatch ?? 0);
export const equalSequenceIds = (a, b) => sequenceIdComparator(a, b) === 0;
export const minSequenceId = (a, b) => sequenceIdComparator(a, b) < 0 ? a : b;
export const maxSequenceId = (a, b) => sequenceIdComparator(a, b) > 0 ? a : b;
export const decrementSequenceId = (sequenceId) => {
    return sequenceId.indexInBatch !== undefined
        ? {
            sequenceNumber: brand(sequenceId.sequenceNumber),
            indexInBatch: sequenceId.indexInBatch - 1,
        }
        : { sequenceNumber: brand(sequenceId.sequenceNumber - 1) };
};
//# sourceMappingURL=sequenceIdUtils.js.map