import type { MailAccountDiscoverResult } from "@/lib/api/types"

/** Local preset when user skips DNS/provider autodetection. */
export function manualMailDiscoverResult(email: string): MailAccountDiscoverResult {
  const normalized = email.trim().toLowerCase()
  const domain = normalized.split("@")[1] ?? ""

  return {
    email: normalized,
    domain,
    provider_id: "custom",
    provider_name: "Configuration manuelle",
    source: "manual",
    confidence: "low",
    imap_host: domain ? `imap.${domain}` : "",
    imap_port: 993,
    imap_tls: true,
    smtp_host: domain ? `smtp.${domain}` : "",
    smtp_port: 587,
    smtp_tls: true,
    username_hint: "email",
    auth_methods: ["password"],
    notes: [
      "Configuration saisie manuellement — vérifiez les paramètres serveur avant d'enregistrer.",
    ],
  }
}
