/**
 * src/web-chat/email-providers.ts
 *
 * Auto-detect SMTP settings from an email address. Lets the user paste
 *   EMAIL=me@gmail.com
 *   EMAIL_PASSWORD=app-password-here
 * and have Muassis figure out the right SMTP host / port / encryption
 * — no manual configuration, no docs reading.
 *
 * Most modern providers (Gmail, Outlook, Yahoo, …) require an
 * "app password" instead of the regular account password for SMTP.
 * When we detect those, the inline reply tells the user exactly which
 * URL to visit and what to paste next.
 */
// Smtp setup for the major free + business providers. Source of truth
// is each provider's published SMTP docs. Gmail, Yahoo, Outlook, AOL,
// iCloud, Microsoft 365 all require app-specific passwords now (2FA
// landscape). The few that still accept a normal account password
// (Zoho, Fastmail) say so in authNote.
const PROVIDERS = {
    'gmail.com': {
        label: 'Gmail',
        smtpHost: 'smtp.gmail.com',
        smtpPort: 587,
        secure: false,
        appPasswordUrl: 'https://myaccount.google.com/apppasswords',
        authNote: 'Gmail يحتاج "App Password" خاص بدلاً من كلمة المرور العادية. ' +
            'سوّ واحد من https://myaccount.google.com/apppasswords ثم ألصقه هنا كـ ' +
            '`EMAIL_PASSWORD=app-password-here` (16 حرف بدون مسافات).',
    },
    'googlemail.com': {
        label: 'Gmail',
        smtpHost: 'smtp.gmail.com',
        smtpPort: 587,
        secure: false,
        appPasswordUrl: 'https://myaccount.google.com/apppasswords',
        authNote: 'Gmail يحتاج "App Password" خاص. أنشئ واحد من https://myaccount.google.com/apppasswords ' +
            'ثم ألصقه كـ `EMAIL_PASSWORD=...`.',
    },
    'outlook.com': {
        label: 'Outlook',
        smtpHost: 'smtp.office365.com',
        smtpPort: 587,
        secure: false,
        appPasswordUrl: 'https://account.microsoft.com/security',
        authNote: 'Outlook يحتاج App Password إذا كان عندك 2FA. أنشئ واحد من ' +
            'https://account.microsoft.com/security ثم ألصقه كـ `EMAIL_PASSWORD=...`.',
    },
    'hotmail.com': {
        label: 'Hotmail',
        smtpHost: 'smtp.office365.com',
        smtpPort: 587,
        secure: false,
        appPasswordUrl: 'https://account.microsoft.com/security',
        authNote: 'Hotmail يحتاج App Password إذا كان عندك 2FA. أنشئ واحد من ' +
            'https://account.microsoft.com/security ثم ألصقه كـ `EMAIL_PASSWORD=...`.',
    },
    'live.com': {
        label: 'Microsoft Live',
        smtpHost: 'smtp.office365.com',
        smtpPort: 587,
        secure: false,
        appPasswordUrl: 'https://account.microsoft.com/security',
        authNote: 'يحتاج App Password من https://account.microsoft.com/security',
    },
    'office365.com': {
        label: 'Microsoft 365',
        smtpHost: 'smtp.office365.com',
        smtpPort: 587,
        secure: false,
        authNote: 'Microsoft 365 — استخدم App Password من Azure portal، أو فعّل SMTP AUTH على ' +
            'الحساب لو سياسة الشركة تسمح.',
    },
    'yahoo.com': {
        label: 'Yahoo',
        smtpHost: 'smtp.mail.yahoo.com',
        smtpPort: 587,
        secure: false,
        appPasswordUrl: 'https://login.yahoo.com/account/security',
        authNote: 'Yahoo يحتاج App Password. أنشئ واحد من ' +
            'https://login.yahoo.com/account/security → Generate app password.',
    },
    'icloud.com': {
        label: 'iCloud',
        smtpHost: 'smtp.mail.me.com',
        smtpPort: 587,
        secure: false,
        appPasswordUrl: 'https://appleid.apple.com',
        authNote: 'iCloud يحتاج App-Specific Password. أنشئ واحد من https://appleid.apple.com ' +
            '→ Sign-In and Security → App-Specific Passwords.',
    },
    'me.com': {
        label: 'iCloud',
        smtpHost: 'smtp.mail.me.com',
        smtpPort: 587,
        secure: false,
        appPasswordUrl: 'https://appleid.apple.com',
        authNote: 'iCloud يحتاج App-Specific Password من https://appleid.apple.com.',
    },
    'mac.com': {
        label: 'iCloud (mac.com)',
        smtpHost: 'smtp.mail.me.com',
        smtpPort: 587,
        secure: false,
        appPasswordUrl: 'https://appleid.apple.com',
        authNote: 'iCloud يحتاج App-Specific Password من https://appleid.apple.com.',
    },
    'zoho.com': {
        label: 'Zoho',
        smtpHost: 'smtp.zoho.com',
        smtpPort: 465,
        secure: true,
        authNote: 'Zoho يقبل كلمة المرور العادية إذا كان 2FA معطل، وإلا فيحتاج App Password.',
    },
    'fastmail.com': {
        label: 'Fastmail',
        smtpHost: 'smtp.fastmail.com',
        smtpPort: 465,
        secure: true,
        appPasswordUrl: 'https://www.fastmail.com/settings/security/tokens',
        authNote: 'Fastmail يحتاج App Password من ' +
            'https://www.fastmail.com/settings/security/tokens.',
    },
    'aol.com': {
        label: 'AOL',
        smtpHost: 'smtp.aol.com',
        smtpPort: 587,
        secure: false,
        appPasswordUrl: 'https://login.aol.com/account/security',
        authNote: 'AOL يحتاج App Password من ' +
            'https://login.aol.com/account/security.',
    },
    'yandex.com': {
        label: 'Yandex',
        smtpHost: 'smtp.yandex.com',
        smtpPort: 465,
        secure: true,
        authNote: 'Yandex يقبل كلمة المرور العادية أو App Password.',
    },
    'yandex.ru': {
        label: 'Yandex',
        smtpHost: 'smtp.yandex.com',
        smtpPort: 465,
        secure: true,
        authNote: 'Yandex يقبل كلمة المرور العادية أو App Password.',
    },
    'mail.ru': {
        label: 'Mail.ru',
        smtpHost: 'smtp.mail.ru',
        smtpPort: 465,
        secure: true,
        authNote: 'Mail.ru يحتاج "Application Password" من إعدادات الحساب.',
    },
    'protonmail.com': {
        label: 'ProtonMail',
        smtpHost: '127.0.0.1',
        smtpPort: 1025,
        secure: false,
        authNote: 'ProtonMail يتطلّب تثبيت Proton Mail Bridge على الجهاز ' +
            '(https://proton.me/mail/bridge). Bridge يفتح SMTP محلي على 127.0.0.1:1025 ' +
            'وكلمة المرور تُولّد منه — ليست كلمة Proton الأصلية.',
    },
    'proton.me': {
        label: 'Proton Mail',
        smtpHost: '127.0.0.1',
        smtpPort: 1025,
        secure: false,
        authNote: 'Proton Mail يتطلّب Bridge — راجع https://proton.me/mail/bridge.',
    },
    'gmx.com': {
        label: 'GMX',
        smtpHost: 'mail.gmx.com',
        smtpPort: 587,
        secure: false,
        authNote: 'GMX يحتاج تفعيل SMTP من إعدادات الحساب أولاً.',
    },
};
/**
 * Look up the SMTP profile for an email address. Returns null if the
 * domain isn't in the table — callers should ask the user for explicit
 * SMTP_HOST / SMTP_PORT in that case.
 */
export function detectProvider(email) {
    const idx = email.lastIndexOf('@');
    if (idx === -1)
        return null;
    const domain = email.slice(idx + 1).toLowerCase().trim();
    return PROVIDERS[domain] ?? null;
}
//# sourceMappingURL=email-providers.js.map