import { providerCommitMessageDefaultModel, providerModelCapability } from './agent-provider-catalog.js';
export const DEFAULT_APP_SETTINGS = {
    commitMessageProvider: 'codex',
    commitMessageModel: providerCommitMessageDefaultModel('codex') ?? 'gpt-5.4-mini',
    timeFormat: '12h',
    dateFormat: 'locale',
    telegramBotToken: null,
    telegramChatId: null
};
function isDateFormat(value) {
    return value === 'locale' || value === 'iso' || value === 'us' || value === 'eu' || value === 'long';
}
function isTimeFormat(value) {
    return value === '12h' || value === '24h';
}
export function normalizeAppSettings(input) {
    const provider = input.commitMessageProvider === 'claude' ? 'claude' : 'codex';
    const requestedModel = input.commitMessageModel?.trim() ?? '';
    const model = providerModelCapability(provider, requestedModel)?.value ??
        providerCommitMessageDefaultModel(provider) ??
        DEFAULT_APP_SETTINGS.commitMessageModel;
    return {
        commitMessageProvider: provider,
        commitMessageModel: model,
        timeFormat: isTimeFormat(input.timeFormat) ? input.timeFormat : DEFAULT_APP_SETTINGS.timeFormat,
        dateFormat: isDateFormat(input.dateFormat) ? input.dateFormat : DEFAULT_APP_SETTINGS.dateFormat,
        telegramBotToken: typeof input.telegramBotToken === 'string' ? input.telegramBotToken.trim() || null : null,
        telegramChatId: typeof input.telegramChatId === 'string' ? input.telegramChatId.trim() || null : null
    };
}
//# sourceMappingURL=app-settings.js.map