import { TunnelTail, ClientCloseEvent, ClientErrorEvent } from '@bpinternal/tunnel';
import { Logger } from '../logger';
import { EventEmitter } from './event-emitter';
export type ReconnectionTriggerEvent = {
    type: 'init';
    ev: null;
} | {
    type: 'error';
    ev: ClientErrorEvent;
} | {
    type: 'close';
    ev: ClientCloseEvent;
};
export type ReconnectedEvent = {
    tunnel: TunnelTail;
    ev: ReconnectionTriggerEvent;
};
export declare class ReconnectionFailedError extends Error {
    readonly event: ReconnectionTriggerEvent;
    constructor(event: ReconnectionTriggerEvent);
    private static _reason;
}
export declare class TunnelSupervisor {
    private _tunnelUrl;
    private _tunnelId;
    private _logger;
    private _tunnel?;
    private _closed;
    private _started;
    readonly events: EventEmitter<{
        connectionFailed: ReconnectionTriggerEvent;
        manuallyClosed: null;
        connected: {
            tunnel: TunnelTail;
            ev: ReconnectionTriggerEvent;
        };
    }>;
    constructor(_tunnelUrl: string, _tunnelId: string, _logger: Logger);
    start(): Promise<void>;
    get closed(): boolean;
    /**
     * @returns Promise that rejects when a reconnection attempt fails and resolves when the tunnel is closed manually
     */
    wait(): Promise<void>;
    close(): void;
    private _reconnectSync;
    private _reconnect;
    private _registerListeners;
}
