"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DecayEngine = void 0;
class DecayEngine {
    lambdaStable;
    lambdaVolatile;
    alphaStable;
    alphaVolatile;
    vacationDays;
    hoursPerDay;
    constructor(lambdaStable = 0.01, lambdaVolatile = 0.05, alphaStable = 0.3, alphaVolatile = 0.7, vacationDays = 5, hoursPerDay = 8) {
        this.lambdaStable = lambdaStable;
        this.lambdaVolatile = lambdaVolatile;
        this.alphaStable = alphaStable;
        this.alphaVolatile = alphaVolatile;
        this.vacationDays = vacationDays;
        this.hoursPerDay = hoursPerDay;
    }
    decay(initialConfidence, usageHoursSinceLastSignal, isVolatile = false, daysSinceLastCommit = 0) {
        const lambda = isVolatile ? this.lambdaVolatile : this.lambdaStable;
        const alpha = isVolatile ? this.alphaVolatile : this.alphaStable;
        if (daysSinceLastCommit >= this.vacationDays) {
            const vacationDecay = 0.5 + (initialConfidence - 0.5) * Math.pow(1 + lambda * 0.1 * daysSinceLastCommit, -alpha * 0.1);
            return Math.round(vacationDecay * 1000) / 1000;
        }
        const decayed = 0.5 + (initialConfidence - 0.5) * Math.pow(1 + lambda * usageHoursSinceLastSignal, -alpha);
        return Math.round(decayed * 1000) / 1000;
    }
    getDecayAfterHours(initialConfidence, hours, isVolatile = false) {
        return this.decay(initialConfidence, hours, isVolatile, 0);
    }
    getDecayAfterDays(initialConfidence, days, isVolatile = false) {
        const usageHours = days * this.hoursPerDay;
        return this.decay(initialConfidence, usageHours, isVolatile, 0);
    }
    isInVacationMode(daysSinceLastCommit) {
        return daysSinceLastCommit >= this.vacationDays;
    }
}
exports.DecayEngine = DecayEngine;
//# sourceMappingURL=decay-engine.js.map