/**
 * Reconnection Manager
 *
 * A shared reconnection utility with exponential backoff for channel adapters.
 * Provides consistent reconnection behavior across all channel implementations.
 *
 * Features:
 * - Exponential backoff with configurable multiplier
 * - Random jitter to prevent thundering herd
 * - Maximum retry limit with exhaustion detection
 * - Event-based notification of state changes
 * - Cancellation support for pending reconnections
 */
import { EventEmitter } from 'events';
/**
 * Configuration for reconnection behavior
 */
export interface ReconnectionConfig {
    /** Maximum number of retry attempts before giving up (default: 10) */
    maxRetries: number;
    /** Initial delay in milliseconds before the first retry (default: 1000) */
    initialDelayMs: number;
    /** Maximum delay in milliseconds between retries (default: 60000) */
    maxDelayMs: number;
    /** Multiplier applied to delay after each retry (default: 2) */
    backoffMultiplier: number;
    /** Random jitter in milliseconds added to delay (default: 500) */
    jitterMs: number;
}
/**
 * Events emitted by the ReconnectionManager
 */
export interface ReconnectionEvents {
    /** Emitted when a reconnection attempt is about to start */
    reconnecting: (attempt: number, delayMs: number) => void;
    /** Emitted when a reconnection attempt succeeds */
    reconnected: (attempt: number) => void;
    /** Emitted when all retry attempts are exhausted */
    exhausted: (totalAttempts: number) => void;
    /** Emitted when a reconnection attempt fails */
    error: (error: Error, attempt: number) => void;
}
/**
 * Manages reconnection attempts with exponential backoff for a named channel.
 *
 * Usage:
 * ```typescript
 * const reconnector = new ReconnectionManager('discord');
 *
 * // On connection loss
 * reconnector.scheduleReconnect(async () => {
 *   await channel.connect();
 * });
 *
 * // On successful connection
 * reconnector.onConnected();
 *
 * // On shutdown
 * reconnector.cancel();
 * ```
 */
export declare class ReconnectionManager extends EventEmitter {
    private readonly name;
    private readonly config;
    private retryCount;
    private pendingTimer;
    private active;
    constructor(name: string, config?: Partial<ReconnectionConfig>);
    /**
     * Schedule a reconnection attempt.
     *
     * Calculates the appropriate delay using exponential backoff with jitter
     * and schedules the provided connect function. If max retries have been
     * exceeded, emits the 'exhausted' event instead.
     *
     * @param connectFn - Async function that performs the connection attempt
     */
    scheduleReconnect(connectFn: () => Promise<void>): void;
    /**
     * Reset retry counter on successful connection.
     *
     * Call this when the channel has successfully connected
     * (whether from an initial connect or a reconnection attempt).
     */
    onConnected(): void;
    /**
     * Check if maximum retries have been exceeded.
     */
    isExhausted(): boolean;
    /**
     * Get current retry count.
     */
    getRetryCount(): number;
    /**
     * Cancel any pending reconnection attempt.
     */
    cancel(): void;
    /**
     * Get the delay for the next retry attempt.
     *
     * Uses exponential backoff: initialDelay * multiplier^(retryCount-1)
     * Capped at maxDelayMs. Adds random jitter.
     */
    getCurrentDelay(): number;
    /**
     * Check if a reconnection is currently pending.
     */
    isPending(): boolean;
    /**
     * Get the channel name this manager is for.
     */
    getName(): string;
    /**
     * Get the current configuration.
     */
    getConfig(): Readonly<ReconnectionConfig>;
}
