import { State } from './state';
import { IPubSub } from './types';
type Key = string | number | symbol;
type MsgFilter = string | Promise<string> | ((op: any, msg: any) => boolean);
export type EventDef<T extends Key> = {
    [key in T]: MsgFilter;
};
type MsgHandler = (op: string, msg: any) => void;
type EventHandler = {
    [key in Key]: MsgHandler[] | MsgHandler;
};
interface IDappletApi {
    [name: string]: any;
}
export type AutoProperty = {
    name: string;
    set: (setter: (value: any) => void) => void;
};
export type Listener = {
    f?: MsgFilter;
    h?: EventHandler | IDappletApi;
    p: AutoProperty[];
};
export interface IConnection {
    open(id?: string): Promise<any>;
    send(op: any, msg?: any): Promise<any>;
    sendAndListen(topic: string, message: any, h: MsgHandler | EventHandler): this;
    declare(dappletApi: IDappletApi): this;
    listen(h: MsgHandler | EventHandler): this;
}
export declare class Connection<T> implements IConnection {
    private _bus?;
    private _eventDef?;
    state: State<T>;
    private readonly _listeners;
    private readonly _listenerContextMap;
    constructor(_bus?: IPubSub, _eventDef?: EventDef<any>);
    open(id?: string): Promise<any>;
    send(op: any, msg?: any): Promise<any>;
    sendAndListen(topic: string, message: any, h: MsgHandler | EventHandler): this;
    /**
     * @deprecated Since version 0.46.1. Will be deleted in version 0.50.0. Use declare instead.
     */
    listen(h: MsgHandler | EventHandler): this;
    declare(dappletApi: IDappletApi): this;
    private listener;
    private _topicMatch;
    subscribeToObservable(id: string, key: string, setter: (v: any) => void): void;
    onMessage(op: any, msg: any): void;
}
export {};
