import type { ImapFlowError } from './errors.js';
export declare const CONNECT_TIMEOUT: number;
/**
 * One deadline for an entire connection attempt.
 *
 * DNS resolution, proxy negotiation and the transport handshake all draw from the same budget, so
 * a phase that stalls cannot extend the documented `connectionTimeout`. Every expiry - whether it
 * comes from this deadline or is normalized from a dependency - is reported with the same
 * `CONNECT_TIMEOUT` error shape, so callers do not need to know which phase was blocked.
 */
export declare class ConnectionDeadline {
    timeout: number;
    startedAt: number;
    /**
     * @param timeout Configured connection timeout in milliseconds. Normalized once
     *   here; 0 and any other falsy or invalid value fall back to the 90 second default.
     */
    constructor(timeout?: number | string | undefined);
    /**
     * @returns Milliseconds left in the budget, never negative.
     */
    remaining(): number;
    /**
     * @returns The shared `CONNECT_TIMEOUT` error.
     */
    error(): ImapFlowError;
    /**
     * Maps a dependency's own expiry onto the shared `CONNECT_TIMEOUT` shape, so callers see one
     * timeout error whichever layer noticed first. The original error is kept as `_err`. Anything
     * that is not a timeout is returned unchanged.
     *
     * @param err Error raised by a dependency during a connection phase.
     * @returns Either the normalized timeout error or the original error.
     */
    normalize<T extends ImapFlowError | null | undefined>(err: T): T | ImapFlowError;
    /**
     * Throws before a phase is started if the budget is already used up, so no work is begun
     * that could only ever time out.
     */
    check(): void;
    /**
     * Races a phase against the remaining budget. The timer is always cleared, so a completed
     * phase never leaves a pending timer behind.
     *
     * @param promise Phase to run under the deadline.
     * @returns Resolves with the phase result, rejects with `CONNECT_TIMEOUT`.
     */
    race<T>(promise: Promise<T>): Promise<T>;
}
