export class FixedStepAccumulator {
    fixedDelta;
    maxSteps;
    accumulator = 0;
    constructor(fixedDelta, maxSteps) {
        this.fixedDelta = fixedDelta;
        this.maxSteps = maxSteps;
        if (!Number.isFinite(fixedDelta) || fixedDelta <= 0)
            throw new RangeError("fixedDelta must be finite and positive.");
        if (!Number.isInteger(maxSteps) || maxSteps <= 0)
            throw new RangeError("maxSteps must be a positive integer.");
    }
    add(delta) {
        if (!Number.isFinite(delta) || delta < 0)
            throw new RangeError("delta must be finite and non-negative.");
        this.accumulator += delta;
        const possibleSteps = Math.floor(this.accumulator / this.fixedDelta);
        const steps = Math.min(possibleSteps, this.maxSteps);
        this.accumulator -= steps * this.fixedDelta;
        let droppedTime = 0;
        if (possibleSteps > this.maxSteps) {
            droppedTime = this.accumulator;
            this.accumulator = 0;
        }
        return Object.freeze({ steps, alpha: this.alpha, droppedTime });
    }
    get alpha() {
        return this.accumulator / this.fixedDelta;
    }
    reset() {
        this.accumulator = 0;
    }
}
//# sourceMappingURL=FixedStepAccumulator.js.map