import type { CallOptions, MethodParams, ServerMethods } from '../utils';
import { Presentation, PromiseQueue } from '../utils';
import { ClientChannel } from './client-channel';
import { ClientHttp } from './client-http';
import { ClientSocket } from './client-socket';
import { IdleTimeout } from './idle-timeout';
import Timeout = NodeJS.Timeout;
export type ErrorHandler = (error: Record<string, any>) => any;
export type WebSocketOptions = {
    path?: string;
    /**
     * Workaround for Safari not reconnecting after the app is brought back to the foreground.
     */
    disconnectOnPageHide?: boolean;
};
export type WebSocketRequestParams = {
    [x: string]: any;
    [x: number]: any;
};
export type ClientOptions = {
    host?: string;
    port?: number;
    secure?: boolean;
    ws?: WebSocketOptions;
    errorHandler?: ErrorHandler;
    debug?: boolean;
    allowedContextKeys?: string[];
    meta?: Record<string, any>;
    idlenessTimeout?: number;
};
export type ProxyMethodCall = {
    [key: string]: ProxyMethodCall;
} & (<T = any, R = any>(params?: MethodParams<T>, options?: CallOptions) => Promise<R>);
/**
 * When working with Next.js, it is probably a good idea to not run this in the
 * server side by using it inside a `useEffect` hook.
 */
export declare class Client<MethodsType extends ServerMethods = ServerMethods> extends ClientChannel {
    #private;
    uuid: string;
    queue: PromiseQueue;
    clientSocket: ClientSocket;
    clientHttp: ClientHttp;
    context: Record<string, any>;
    errorHandler: ErrorHandler;
    channels: Map<string, ClientChannel>;
    timeouts: Set<Timeout>;
    initialized: boolean;
    authenticated: boolean;
    options: ClientOptions;
    initializing: boolean;
    idleTimeout: IdleTimeout;
    m: MethodsType;
    static ENABLE_HEARTBEAT: boolean;
    constructor(options?: ClientOptions);
    get isConnecting(): boolean;
    get isOffline(): boolean;
    get isOnline(): boolean;
    get connected(): boolean;
    connect(): Promise<void>;
    debugger(...args: any[]): void;
    loadContext(): void;
    setContext(context: Record<string, any>): void;
    setContextAndReInit(context: Record<string, any>): Promise<void>;
    updateContext(context: any): void;
    clearContext(): void;
    close(): Promise<void>;
    /**
     * Initializes the client. It should be called before any other method.
     *
     * It should be called whenever a transport is connected, either on reconnection or from calling `connect`.
     */
    initialize(): Promise<boolean>;
    /**
     * The login method is always called via http so a http-only cookie can be set if the user so prefers.
     */
    login(params: WebSocketRequestParams, opts?: CallOptions): Promise<void>;
    logout(): Promise<void>;
    resubscribeAllChannels(): Promise<void>;
    disconnect(): Promise<void>;
    /**
     * Calls a method without expecting a return value.
     */
    void<T = any>(method: string, params?: MethodParams<T>, { http, httpFallback }?: CallOptions): Promise<void>;
    call<P = Record<string, any>, R = any>(method: string, params?: P, options?: CallOptions): Promise<R>;
    typed<T extends ServerMethods>(types: T): Client<T>;
    combine<T extends Client>(methods: T): Client<InferClientMethods<T> & MethodsType>;
    handleError(payload: Presentation.Payload): void;
    handleEvent(payload: Presentation.Payload): boolean;
    handleResult(payload: Presentation.Payload): void;
    payloadRouter(payload: Presentation.Payload): boolean | void;
    /**
     * Generates a URL path from string parts. The last argument can be a query
     * string object definition.
     */
    href(...path: (string | Record<string, any>)[]): string;
    channel(name?: string | object): ClientChannel;
    isConnected(): Promise<unknown>;
    attachDevTools(): Promise<void>;
    fetch(url: string, options: any): Promise<Response>;
}
export type InferClientMethods<T extends Client> = T['m'];
