"use strict";
/**
 * Auto-Yes Configuration Constants
 *
 * Shared config for Auto-Yes duration settings.
 * Used by both server (auto-yes-manager.ts, route.ts) and client
 * (AutoYesConfirmDialog.tsx, AutoYesToggle.tsx) components.
 *
 * Issue #225: Duration selection feature
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.DURATION_LABELS = exports.DEFAULT_AUTO_YES_DURATION = exports.ALLOWED_DURATIONS = void 0;
exports.isAllowedDuration = isAllowedDuration;
exports.formatTimeRemaining = formatTimeRemaining;
/** Allowed Auto-Yes durations in milliseconds */
exports.ALLOWED_DURATIONS = [3600000, 10800000, 28800000];
/** Default Auto-Yes duration (1 hour = 3600000ms) */
exports.DEFAULT_AUTO_YES_DURATION = 3600000;
/** i18n translation keys for each duration value */
exports.DURATION_LABELS = {
    3600000: 'autoYes.durations.1h',
    10800000: 'autoYes.durations.3h',
    28800000: 'autoYes.durations.8h',
};
/**
 * Type guard: check whether a value is a valid AutoYesDuration.
 * Replaces `as AutoYesDuration` casts with a runtime-safe check.
 */
function isAllowedDuration(value) {
    return typeof value === 'number' && exports.ALLOWED_DURATIONS.includes(value);
}
/** Milliseconds per second */
const MS_PER_SECOND = 1000;
/** Milliseconds per minute */
const MS_PER_MINUTE = 60000;
/** Milliseconds per hour */
const MS_PER_HOUR = 3600000;
/**
 * Format remaining time as MM:SS (under 1 hour) or H:MM:SS (1 hour or more).
 *
 * Extracted from AutoYesToggle.tsx for direct testability and reuse.
 * Negative remaining time is clamped to 0.
 */
function formatTimeRemaining(expiresAt) {
    const remaining = Math.max(0, expiresAt - Date.now());
    const hours = Math.floor(remaining / MS_PER_HOUR);
    const minutes = Math.floor((remaining % MS_PER_HOUR) / MS_PER_MINUTE);
    const seconds = Math.floor((remaining % MS_PER_MINUTE) / MS_PER_SECOND);
    if (hours > 0) {
        return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
    }
    return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
}
