import type { SystemInfoConfig } from './types'

export const mailConfig: SystemInfoConfig = {
  title: 'Unified Inbox System-Info',
  description: 'E-Mail-Management mit KI-Analyse und Automatisierung.',
  version: '1.0',
  architecture: {
    layers: [
      { title: 'Inbox UI', components: ['Mail List', 'Compose', 'AI Summary'], color: '#3b82f6' },
      { title: 'Mail Service', components: ['IMAP Sync', 'SMTP Send', 'Parser'], color: '#8b5cf6' },
      { title: 'AI Pipeline', components: ['Classification', 'Summarization', 'Response Draft'], color: '#10b981' },
      { title: 'Storage', components: ['PostgreSQL', 'MinIO (Attachments)', 'Vector DB'], color: '#f59e0b' },
    ],
  },
  features: [
    { name: 'Multi-Account Support', status: 'active', description: 'Mehrere E-Mail-Konten' },
    { name: 'KI-Zusammenfassung', status: 'planned', description: 'Automatische E-Mail-Zusammenfassung' },
    { name: 'Smart Categorization', status: 'planned', description: 'KI-basierte Kategorisierung' },
    { name: 'Response Suggestions', status: 'planned', description: 'Antwort-Vorschlaege' },
  ],
  roadmap: [
    { phase: 'Phase 1: Core (Q1)', priority: 'high', items: ['IMAP/SMTP Integration', 'Multi-Account', 'Search', 'Attachments'] },
    { phase: 'Phase 2: AI (Q2)', priority: 'high', items: ['E-Mail Classification', 'Priority Detection', 'Sentiment Analysis', 'Spam Detection'] },
    { phase: 'Phase 3: Automation (Q3)', priority: 'medium', items: ['Auto-Responses', 'Rules Engine', 'Workflow Triggers', 'CRM Integration'] },
  ],
  technicalDetails: [
    { component: 'IMAP', technology: 'imaplib/imapclient', description: 'E-Mail Empfang' },
    { component: 'SMTP', technology: 'smtplib', description: 'E-Mail Versand' },
    { component: 'AI', technology: 'OpenAI GPT-4', description: 'Text Analysis' },
    { component: 'Search', technology: 'PostgreSQL FTS', description: 'Volltextsuche' },
  ],
  auditInfo: [
    {
      category: 'E-Mail Konten',
      items: [
        { label: 'Konfigurierte Konten', value: 'Variabel', status: 'ok' },
        { label: 'IMAP Sync', value: 'Aktiviert', status: 'ok' },
        { label: 'SMTP Versand', value: 'Aktiviert', status: 'ok' },
        { label: 'OAuth2 Support', value: 'Google, Microsoft', status: 'ok' },
      ],
    },
    {
      category: 'Sicherheit',
      items: [
        { label: 'Verschluesselung', value: 'TLS Required', status: 'ok' },
        { label: 'Credential Storage', value: 'Encrypted', status: 'ok' },
        { label: 'Spam-Filter', value: 'SpamAssassin', status: 'ok' },
        { label: 'Virus-Scan', value: 'ClamAV', status: 'ok' },
      ],
    },
    {
      category: 'KI-Features',
      items: [
        { label: 'Kategorisierung', value: 'Geplant', status: 'warning' },
        { label: 'Zusammenfassung', value: 'Geplant', status: 'warning' },
        { label: 'Antwort-Vorschlaege', value: 'Geplant', status: 'warning' },
        { label: 'Sentiment Analysis', value: 'Geplant', status: 'warning' },
      ],
    },
  ],
  fullDocumentation: `
<h2>Unified Inbox - E-Mail Management</h2>

<h3>1. Uebersicht</h3>
<p>Der Unified Inbox aggregiert E-Mails aus mehreren Konten in einer zentralen Oberflaeche. Geplant ist die Integration von KI-Features fuer automatische Kategorisierung und Zusammenfassung.</p>

<h3>2. Architektur</h3>
<pre>
┌─────────────────────────────────────────────────────────────────────┐
│                         Unified Inbox UI                             │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────────────┐  │
│  │   Inbox      │  │   Compose    │  │   AI Summary (planned)   │  │
│  └──────────────┘  └──────────────┘  └──────────────────────────┘  │
└─────────────────────────────┬───────────────────────────────────────┘
                              │
                              v
┌─────────────────────────────────────────────────────────────────────┐
│                        Mail Service                                  │
│  ┌────────────┐  ┌────────────┐  ┌────────────┐  ┌────────────┐    │
│  │ IMAP Sync  │  │ SMTP Send  │  │  Parser    │  │ AI Pipeline│    │
│  └────────────┘  └────────────┘  └────────────┘  └────────────┘    │
└─────────────────────────────┬───────────────────────────────────────┘
                              │
          ┌───────────────────┴───────────────────┐
          │                                       │
          v                                       v
┌─────────────────────────┐         ┌─────────────────────────┐
│    External Mail        │         │    Internal Storage     │
│  ├── Gmail              │         │  ├── PostgreSQL         │
│  ├── Outlook            │         │  ├── MinIO (Attachments)│
│  └── Custom IMAP        │         │  └── Qdrant (Embeddings)│
└─────────────────────────┘         └─────────────────────────┘
</pre>

<h3>3. Unterstuetzte Provider</h3>
<table>
  <tr><th>Provider</th><th>Auth-Methode</th><th>Features</th></tr>
  <tr><td>Gmail</td><td>OAuth2</td><td>Labels, Push-Sync</td></tr>
  <tr><td>Outlook/365</td><td>OAuth2</td><td>Folders, Categories</td></tr>
  <tr><td>Custom IMAP</td><td>User/Pass</td><td>Standard IMAP</td></tr>
  <tr><td>Exchange</td><td>OAuth2/EWS</td><td>Geplant</td></tr>
</table>

<h3>4. API Endpoints</h3>
<table>
  <tr><th>Endpoint</th><th>Methode</th><th>Beschreibung</th></tr>
  <tr><td>/api/mail/accounts</td><td>GET</td><td>Konfigurierte Konten</td></tr>
  <tr><td>/api/mail/accounts</td><td>POST</td><td>Konto hinzufuegen</td></tr>
  <tr><td>/api/mail/messages</td><td>GET</td><td>E-Mails abrufen</td></tr>
  <tr><td>/api/mail/messages</td><td>POST</td><td>E-Mail senden</td></tr>
  <tr><td>/api/mail/messages/{id}</td><td>GET</td><td>E-Mail-Details</td></tr>
  <tr><td>/api/mail/sync</td><td>POST</td><td>Manueller Sync</td></tr>
</table>

<h3>5. Sync-Strategie</h3>
<pre>
Initial Sync
     │
     v
┌───────────────────────────────────────┐
│  1. Fetch Folder Structure            │
│  2. Sync Last 30 Days                 │
│  3. Index Messages                    │
│  4. Generate Embeddings (optional)    │
└─────────────────┬─────────────────────┘
                  │
                  v
Incremental Sync (alle 5 Min)
     │
     v
┌───────────────────────────────────────┐
│  1. Check for new Messages (IDLE)     │
│  2. Fetch new Messages                │
│  3. Update Index                      │
│  4. Process AI Pipeline               │
└───────────────────────────────────────┘
</pre>

<h3>6. Sicherheit</h3>
<ul>
  <li><strong>Credentials:</strong> AES-256 verschluesselt in DB</li>
  <li><strong>OAuth Tokens:</strong> Refresh Token rotiert</li>
  <li><strong>Transport:</strong> TLS 1.2+ required</li>
  <li><strong>Attachments:</strong> Virus-Scan vor Speicherung</li>
  <li><strong>Spam:</strong> SpamAssassin Score-basiert</li>
</ul>

<h3>7. Datenschutz</h3>
<table>
  <tr><th>Aspekt</th><th>Massnahme</th></tr>
  <tr><td>E-Mail-Inhalte</td><td>Lokal gespeichert, nicht an Dritte</td></tr>
  <tr><td>KI-Verarbeitung</td><td>Opt-in, PII-Filterung</td></tr>
  <tr><td>Retention</td><td>Spiegelt Provider-Einstellung</td></tr>
  <tr><td>Loeschung</td><td>Sync mit Provider</td></tr>
</table>
`,
}
