/**
 * Email Service
 *
 * Unified email service combining IMAP, SMTP, and webhook functionality.
 */
import { EventEmitter } from 'events';
import { ImapClient } from './client.js';
import { SmtpClient } from './client.js';
import type { EmailServiceConfig, EmailServiceStats, EmailMessage, EmailFolder, ImapSearchCriteria, SendMailOptions, SendMailResult, EmailWebhookConfig, EmailWebhookEvent, EmailWebhookPayload, EmailFlag } from './types.js';
export declare class WebhookManager extends EventEmitter {
    private webhooks;
    constructor(webhooks?: EmailWebhookConfig[]);
    /**
     * Add a webhook
     */
    addWebhook(webhook: EmailWebhookConfig): void;
    /**
     * Remove a webhook
     */
    removeWebhook(url: string): boolean;
    /**
     * Get all webhooks
     */
    getWebhooks(): EmailWebhookConfig[];
    /**
     * Trigger webhooks for an event
     */
    trigger(event: EmailWebhookEvent, data: EmailWebhookPayload['data']): Promise<void>;
    /**
     * Send a webhook request
     */
    private sendWebhook;
    private simulateWebhookRequest;
}
export declare class EmailService extends EventEmitter {
    private config;
    private imapClient;
    private smtpClient;
    private webhookManager;
    private pollInterval;
    private startTime;
    private stats;
    constructor(config: EmailServiceConfig);
    /**
     * Connect to email servers
     */
    connect(): Promise<void>;
    /**
     * Disconnect from servers
     */
    disconnect(): Promise<void>;
    /**
     * Check if connected
     */
    isConnected(): boolean;
    /**
     * List all folders
     */
    listFolders(): Promise<EmailFolder[]>;
    /**
     * Select a folder
     */
    selectFolder(path: string): Promise<EmailFolder>;
    /**
     * Search for messages
     */
    search(criteria: ImapSearchCriteria, folder?: string): Promise<number[]>;
    /**
     * Fetch messages
     */
    fetchMessages(uids: number | number[], folder?: string): Promise<EmailMessage[]>;
    /**
     * Fetch a single message
     */
    fetchMessage(uid: number, folder?: string): Promise<EmailMessage | null>;
    /**
     * Mark messages as read
     */
    markAsRead(uids: number | number[], folder?: string): Promise<void>;
    /**
     * Mark messages as unread
     */
    markAsUnread(uids: number | number[], folder?: string): Promise<void>;
    /**
     * Flag messages
     */
    flagMessages(uids: number | number[], flags: EmailFlag | EmailFlag[], folder?: string): Promise<void>;
    /**
     * Move messages
     */
    moveMessages(uids: number | number[], destFolder: string, srcFolder?: string): Promise<void>;
    /**
     * Delete messages
     */
    deleteMessages(uids: number | number[], folder?: string, permanent?: boolean): Promise<void>;
    /**
     * Create a folder
     */
    createFolder(path: string): Promise<EmailFolder>;
    /**
     * Delete a folder
     */
    deleteFolder(path: string): Promise<void>;
    /**
     * Send an email
     */
    sendEmail(options: SendMailOptions): Promise<SendMailResult>;
    /**
     * Reply to an email
     */
    replyToEmail(originalMessage: EmailMessage, options: Omit<SendMailOptions, 'to' | 'subject' | 'inReplyTo' | 'references'>): Promise<SendMailResult>;
    /**
     * Forward an email
     */
    forwardEmail(originalMessage: EmailMessage, options: Omit<SendMailOptions, 'subject' | 'text' | 'html'>): Promise<SendMailResult>;
    /**
     * Add a webhook
     */
    addWebhook(webhook: EmailWebhookConfig): void;
    /**
     * Remove a webhook
     */
    removeWebhook(url: string): boolean;
    /**
     * Get all webhooks
     */
    getWebhooks(): EmailWebhookConfig[];
    /**
     * Sync folder and check for new messages
     */
    syncFolder(folder?: string): Promise<number>;
    /**
     * Start polling for new messages
     */
    startPolling(interval?: number): void;
    /**
     * Stop polling
     */
    stopPolling(): void;
    /**
     * Start IDLE mode
     */
    startIdle(): Promise<void>;
    /**
     * Get service statistics
     */
    getStats(): EmailServiceStats;
    /**
     * Reset statistics
     */
    resetStats(): void;
    /**
     * Add a mock message (for testing)
     */
    addMockMessage(folder: string, message: Partial<EmailMessage>): number;
    /**
     * Get IMAP client (for testing)
     */
    getImapClient(): ImapClient | null;
    /**
     * Get SMTP client (for testing)
     */
    getSmtpClient(): SmtpClient | null;
    private ensureImapConnected;
    private ensureSmtpConnected;
    private setupImapListeners;
    private setupSmtpListeners;
}
export declare function getEmailService(config?: EmailServiceConfig): EmailService;
export declare function resetEmailService(): void;
