import { UserTier } from "../types/tiers.js";
// ─── Per-tier configs ────────────────────────────────────────────────────────
export const FREE_RATE_LIMIT_CONFIG = {
    callsPerMinute: 10,
    callsPerDay: 100,
    burstWindow10s: 3,
    retryAfterSeconds: 60,
};
export const PAID_RATE_LIMIT_CONFIG = {
    callsPerMinute: 60,
    callsPerDay: 5_000,
    burstWindow10s: 15,
    retryAfterSeconds: 10,
};
// ─── Lookup helper ───────────────────────────────────────────────────────────
/** Returns the RateLimitConfig for a given UserTier. */
export function getRateLimitConfig(tier) {
    switch (tier) {
        case UserTier.PAID:
            return PAID_RATE_LIMIT_CONFIG;
        case UserTier.FREE:
        default:
            return FREE_RATE_LIMIT_CONFIG;
    }
}
// ─── Durable Object alarm interval ──────────────────────────────────────────
/**
 * Milliseconds until midnight UTC from the given timestamp.
 * Used to schedule the Durable Object alarm that resets daily call counters.
 */
export function msUntilMidnightUtc(nowMs = Date.now()) {
    const now = new Date(nowMs);
    const midnight = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + 1, 0, 0, 0, 0));
    return midnight.getTime() - nowMs;
}
//# sourceMappingURL=rate-limits.js.map