"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DepartureCalculator = void 0;
class DepartureCalculator {
    /**
     * Calculates the predicted departure time based on the scheduled departure time, arrival time and delay.
     **/
    static getPredictedDepartureTime(departureTime, arrivalTime, delayInSeconds) {
        let delayInSecondsWithDefault = delayInSeconds ?? 0;
        let adjustedDepartureTime = new Date(departureTime.getTime() + delayInSecondsWithDefault * 1000);
        if (arrivalTime !== null && delayInSecondsWithDefault > 0) {
            const dwellInSeconds = (departureTime.getTime() - arrivalTime.getTime()) / 1000;
            const minDwellInSeconds = Math.min(delayInSecondsWithDefault, dwellInSeconds);
            adjustedDepartureTime.setTime(adjustedDepartureTime.getTime() - minDwellInSeconds * 1000);
        }
        return adjustedDepartureTime;
    }
    /**
     * Calculates the number of minutes until the predicted departure time.
     **/
    static getDepartureMinutes(predictedDepartureTime) {
        return Math.round((predictedDepartureTime.getTime() - new Date().getTime()) / (60 * 1000));
    }
}
exports.DepartureCalculator = DepartureCalculator;
//# sourceMappingURL=DepartureCalculator.js.map