export class EventReplayBuffer {
    capacity;
    nextSeq = 1;
    events = [];
    constructor(options) {
        this.capacity = Math.max(1, options?.capacity ?? 500);
    }
    append(event) {
        const sequenced = {
            seq: this.nextSeq++,
            ...event
        };
        this.events.push(sequenced);
        if (this.events.length > this.capacity) {
            this.events.splice(0, this.events.length - this.capacity);
        }
        return sequenced;
    }
    replayAfter(seq) {
        const floor = seq ?? 0;
        return this.events.filter((event) => event.seq > floor);
    }
    latestSeq() {
        return this.nextSeq - 1;
    }
}
//# sourceMappingURL=event-buffer.js.map