import { BaseTelegramClient } from '../base.js';
import { RespondFn, WorkerCustomMethods, WorkerMessageHandler } from './protocol.js';
export interface TelegramWorkerOptions<T extends WorkerCustomMethods> {
    client: BaseTelegramClient;
    /** mtcute worker ID to disambiguate multiple clients within the same underlying worker */
    workerId?: string;
    /**
     * What to do when the last connection to the worker is closed?
     *
     * - `destroy`: destroy the client, terminating the worker
     * - `disconnect`: disconnect the client, but keep the worker running until `forceDestroy` is called
     * - `nothing`: do nothing, lifecycle is managed manually
     * - function: call this function when the last connection is closed, then execute the action returned by the function
     *
     * @default 'nothing'
     */
    onLastDisconnected?: 'destroy' | 'disconnect' | 'nothing' | (() => 'destroy' | 'disconnect' | 'nothing');
    /** additional custom methods to expose */
    customMethods?: T;
}
export declare abstract class TelegramWorker<T extends WorkerCustomMethods> {
    readonly params: TelegramWorkerOptions<T>;
    readonly client: BaseTelegramClient;
    broadcast: RespondFn;
    private _cleanup;
    private _heartbeatSweep;
    private _mounted;
    abstract registerWorker(handler: WorkerMessageHandler): [RespondFn, VoidFunction];
    readonly activeConnections: Set<string>;
    readonly connectionLastSeen: Map<string, number>;
    readonly pendingAborts: Map<string, Map<number, AbortController>>;
    readonly workerId: string;
    private _disconnecting?;
    private _destroying?;
    constructor(params: TelegramWorkerOptions<T>);
    mount(): this;
    private getConnectionAborts;
    private deletePendingAbort;
    private touchConnection;
    private respondConnectionExpired;
    private sweepExpiredConnections;
    private onRelease;
    private disconnectSharedClient;
    private forceDestroy;
    private shouldSyncCurrentUser;
    private onInvoke;
    destroy(): void;
}
