import { Channel, DesktopAgent, Context, ContextHandler, Listener, AppIntent, IntentResolution, ImplementationMetadata, TargetApp } from "../../typedefs/FDC3";
import { IRouterClient } from "../routerClientInstance";
import { Startup } from "../Startup/Startup";
/**
 * See https://stackoverflow.com/questions/45847399/friend-class-in-typescript for implementation of "friend" class
 */
export declare class FinsembleDesktopAgent implements DesktopAgent {
    #private;
    constructor({ routerClient, startup }: {
        routerClient: IRouterClient;
        startup: Startup;
    });
    private meta;
    private handleHeartbeat;
    private triggerContextListeners;
    private triggerIntentListeners;
    private handleIncoming;
    /**
     * Releases the queue, sending API calls to the interop service that had been deferred until a connection
     * was established.
     */
    private releaseQueue;
    /**
     * This is the central point for exchanging data with the interop service. Even though some FDC3
     * calls such as broadcast() are one way, we always perform a query/response with the server, at
     * least getting an empty response to know that it was handled.
     */
    private exchange;
    /**
     * Performs the handshake to the interop service and starts hearbeats.
     * @internal
     */
    private connect;
    /**
     * Connect to the interop service. This method can be safely called multiple times. It will only
     * establish a single connection.
     * This function is called by FSBLDesktop and FSBLFreestanding.
     * @internal
     */
    start(): Promise<void>;
    /**
     * Only used by unit tests. Stops the client and puts it back into queuing state. The client
     * can be restarted by calling connect().
     * @internal
     */
    private stop;
    /**
     * Registers handlers which will be called if the client is disconnected from Finsemble. This is only useful when
     * running in freestanding apps that might continue running after Finsemble has been terminated. Users should be
     * prompted to restart their freestanding app when a disconnect is received.
     *
     * {(string) => void} @param cb Handler function.
     * @experimental This method is not part of the FDC3 standard and may be replaced in the future with alternative mechanisms.
     */
    onDisconnect(cb: (error: string) => void): void;
    /** @internal */
    channelGetCurrentContext(channel: string, contextType?: string): Promise<Context | null | undefined>;
    /**
     * Publishes context to other apps on the desktop.
     * Calling broadcast at the DesktopAgent scope will push the context to whatever Channel the app is joined to.
     * If the app is not currently joined to a channel, calling fdc3.broadcast will have no effect.
     * Apps can still directly broadcast and listen to context on any channel via the methods on the Channel class.
     * @param context
     */
    broadcast(context: Context): void;
    /** @internal */
    channelBroadcast(channel: string, context: Context): void;
    /**
     * Retrieves a list of the System channels available for the app to join.
     * This should include the 'global' channel.
     */
    getSystemChannels(): Promise<Channel[]>;
    /**
     * Launches/links to an app by name.
     * If a Context object is passed in, this object will be provided to the opened application via a contextListener.
     * The Context argument is functionally equivalent to opening the target app with no context and broadcasting the context directly to it.
     * If opening errors, it returns an Error with a string from the OpenError enumeration.
     *
     * @param target
     * @param context
     */
    open(target: TargetApp, context?: Context): Promise<void>;
    /**
     * Find out more information about a particular intent by passing its name, and optionally its context.
     *
     * findIntent is effectively granting programmatic access to the Desktop Agent's resolver.
     * A promise resolving to the intent, its metadata and metadata about the apps that registered it is returned.
     * This can be used to raise the intent against a specific app.
     *
     * If the resolution fails, the promise will return an `Error` with a string from the `ResolveError` enumeration.
     *
     * @param intent
     * @param context
     */
    findIntent(intent: string, context?: Context): Promise<AppIntent>;
    /**
     * Find all the available intents for a particular context.
     *
     * findIntents is effectively granting programmatic access to the Desktop Agent's resolver.
     * A promise resolving to all the intents, their metadata and metadata about the apps that registered it is returned,
     * based on the context types the intents have registered.
     *
     * If the resolution fails, the promise will return an `Error` with a string from the `ResolveError` enumeration.
     * @param context
     */
    findIntentsByContext(context?: Context): Promise<Array<AppIntent>>;
    /**
     * Raises an intent to the desktop agent to resolve.
     * @param intent
     * @param context
     * @param target
     */
    raiseIntent(intent: string, context?: Context, target?: TargetApp): Promise<IntentResolution>;
    /**
     * Finds and raises an intent against a target app based purely on context data.
     *
     * raiseIntentForContext is essentially a raiseIntent without a specific intent specified, hence the same "raiseIntent" Interop message is used.
     *
     * @param context
     * @param target
     */
    raiseIntentForContext(context?: Context, target?: TargetApp): Promise<IntentResolution>;
    /**
     * Adds a listener for incoming Intents from the Agent.
     * @param intent
     * @param handler
     */
    addIntentListener(intent: string, handler: ContextHandler): Listener;
    /** @internal */
    channelAddContextListener(channel: string | null, contextTypeOrHandler: string | null | ContextHandler, handler?: ContextHandler): Listener;
    /**
     * Adds a listener for incoming context broadcast from the Desktop Agent.
     * If the consumer is only interested in a context of a particular type, they can use the relevant overload that allows the type to be specified.
     * @param contextTypeOrHandler
     * @param handler
     */
    addContextListener(contextTypeOrHandler: string | null | ContextHandler, handler?: ContextHandler): Listener;
    /**
     * Joins the app to the specified channel.
     * If an app is joined to a channel, all fdc3.broadcast calls will go to the channel, and all listeners assigned via fdc3.addContextListener will listen on the channel.
     * An app can only be joined to one channel at a time.
     * Rejects with error if the channel is unavailable or the join request is denied.
     * Error with a string from the ChannelError enumeration.
     * @param channelId
     */
    joinChannel(channelId: string): Promise<void>;
    /**
     * Returns a Channel object for the specified channel, creating it (as an App channel) - if it does not exist.
     * Error with a string from the ChannelError enumeration if channel could not be created or access was denied.
     * @param channelId
     */
    getOrCreateChannel(channelId: string): Promise<Channel>;
    /**
     * FDC3 2.0 pre-release
     *
     * Get all joined channels
     *
     * Known race condition: getCurrentChannels() can return an empty string if it is called before the InteropService's linker module
     * has completed initializing the app. This can occur if fdc3.getCurrentChannels() is the very first call that an app makes. To work around
     * this issue, use the interop.autoConnect config flag. A future version of the InteropService will hold off on completed registrations
     * until submodules have finished their work.
     */
    getCurrentChannels(): Promise<Channel[] | null>;
    /**
     * Returns the Channel object for the current channel membership.
     * Returns null if the app is not joined to a channel.
     */
    getCurrentChannel(): Promise<Channel | null>;
    /**
     * Removes the app from any channel membership.
     * Context broadcast and listening through the top-level fdc3.broadcast and fdc3.addContextListener will be in a no-op when the app is not on a channel.
     */
    leaveCurrentChannel(): Promise<void>;
    /**
     * Retrieves information about the FDC3 Desktop Agent implementation, such as
     * the implemented version of the FDC3 specification and the name of the implementation
     * provider.
     */
    getInfo(): ImplementationMetadata;
}
//# sourceMappingURL=FinsembleDesktopAgent.d.ts.map