/*!
 * Copyright 2017 - 2020 by ChartIQ, Inc.
 * All rights reserved.
 */
/**
 * The Dialog Manager Client simplifies interacting with dialog windows by spawning them and getting data back from them.
 * In this context, a dialog window is simply a child window spawned to interact with the user, such as a confirmation dialog.
 * Functions are provided here for both the parent-window side and the dialog/child-window side.
 *
 *`FSBL.Clients.DialogManager` is always pre-initialized with one instance of the Dialog Manager in the Finsemble Library (making it essentially, a singleton when referenced in the same window). This means when developing Finsemble components, you directly access the Dialog Manager without using the constructor (e.g., `FSBL.Clients.DialogManager.spawnDialog(...);`). **The constructor is not exposed to components.**
 *
 * @module DialogManagerClient
 */
import { SpawnResponse } from "./launcherClient";
import { FinsembleWindow } from "../common/FinsembleWindow";
import { SpawnParams } from "../services/window/types";
import { WindowIdentifier } from "../services/window/types";
import { StandardErrorCallback, StandardError, StandardPromise } from "../types";
import { ResponderMessage } from "./routerClient";
import { StoreModel } from "./StoreModel";
export declare class DialogManagerClientController {
    initialized: boolean;
    /**
     * Can be used to set a specific timeout
     */
    userInputTimeout: number | null;
    /**
     * A global store used to track which windows are registered as dialogs and their state.
     * Dialogs are put in the "available" pool when they are available for use. They are put
     * in the "open" pool when they are in use.
     */
    DialogStore: StoreModel | null;
    /**
     * Will be set to true if the current window is a dialog
     */
    isDialog: boolean;
    /**
     * Contains a unique channel name that a dialog can use to communicate back to
     * its originating window. The channel is created by the originating window as
     * a query responder.
     */
    RESPONDER_CHANNEL: string | null;
    /**
     * Used to send a message back to whoever opened this dialog
     */
    openerMessage: ResponderMessage | null;
    /**
     * Same as FEAGlobals.finsembleWindow
     */
    finsembleWindow: FinsembleWindow | null;
    /**
     * Will be set with the spawn data, which contains the input params and responseChannel
     */
    spawnData: any;
    /**
     * Checks to see whether the window is a dialog, setting this.isDialog to true or false
     * @param {cb} cb The callback to be invoked after the method completes successfully.
     */
    checkIfWindowIsDialog(cb?: (err?: StandardError) => void): Promise<void>;
    /**
     * Registers the window as a dialog with the global store. If the component is incapable of being used as a dialog (this is set in the component's config), the callback is immediately invoked.
     *
     * <b>Note:</b> This method will check to see whether the calling window is a dialog.
     * @param {function} callback The callback to be invoked after the method completes successfully.
     */
    registerWithStore(cb?: () => void): Promise<void>;
    /**
     * Establishes a connection to the distributed store that is used
     * by all dialogs. This function may be called many times but will
     * only initialize one time.
     */
    initializeOnce(): Promise<void>;
    /**
     * Creates the global store if it doesn't exist.
     * @param {function} callback
     */
    createStore(cb?: () => void): Promise<void>;
    /**
     */
    getFinsembleWindow(cb?: () => void): Promise<void>;
    getAvailableDialog(type: string, cb?: (dialog: WindowIdentifier | null) => void): Promise<WindowIdentifier | null>;
    /**
     * State management - just moves an opened dialog back to the "available" pool.
     * @param {object} identifier window identifier of the dialog.
     */
    moveDialogFromOpenedToAvailable(identifier: WindowIdentifier): Promise<string | null>;
    /**
     * State management - just moves an available dialog out of the "available" pool.
     * @param {object} identifier window identifier of the dialog.
     */
    moveDialogFromAvailableToOpened(identifier: WindowIdentifier): Promise<string | null>;
}
/**
 * Registers this window as a modal that can be used by the dialog manager. This will set
 * the window as a "scrim" – taking up the entire size of the monitor and being invisible or lightly opaque.
 *
 * Sometimes, clicking anywhere on this window will dismiss the modal.
 */
export declare const registerModal: () => Promise<string | null>;
/**
 * Shows a semi-transparent black modal behind the dialog.
 * @param {function} cb The callback to be invoked after the method completes successfully.
 */
export declare const showModal: (cb?: ((error?: string | undefined) => void) | undefined) => Promise<string | null>;
/**
 * Hides the dialog's modal.
 */
export declare const hideModal: () => Promise<string | null>;
/**
 * Spawns an app or url in "dialog mode". The app's window will not be dockable.
 * The app does not need to be explicitly coded as a dialog.
 *
 * Parameters passed as `params.inputParams` can be retrieved in the dialog window by
 * calling `FSBL.Clients.DialogManager.getParametersFromInDialog()`.
 *
 * ```JavaScript
 * FSBL.Clients.DialogManager.spawnDialog(
 * {
 * 	name: "dialogTemplate",
 * 	height:300,
 * 	width:400,
 * 	url:"http://localhost/components/system/dialogs/dialog1.html"
 * },
 * {
 * 	someData: 12345
 * },
 * (error, responseParameters) => {
 *	if (!error) {
 * 		console.log(">>>> spawnDialog response: " + JSON.stringify(responseParameters));
 *	}
 * });
 * ```
 * @param {object} params Parameters. Same as <a href="tutorial-LauncherClient.html#spawn">LauncherClient.spawn()</a> with the following exceptions.
 * @param {string} params.url URL of dialog to launch
 * @param {string} [params.name] - The name of the dialog
 * @param {number|string} params.x - Same as <a href="tutorial-LauncherClient.html#spawn">LauncherClient.spawn()</a> except defaults to "center".
 * @param {number | string} [params.y="center"] - Same as <a href="tutorial-LauncherClient.html#spawn">LauncherClient.spawn()</a> except defaults to "center".
 * @param {object} inputParams Object or any data type needed by your dialog.
 * @param {function} dialogResponseCallback called when response received back from dialog window (typically on dialog completion). `responseParameters` is defined by the dialog.
 * @param {function} cb Returns response from <a href="tutorial-LauncherClient.html#spawn">LauncherClient.spawn()</a>
 */
export declare const spawnDialog: (params: SpawnParams, inputParams: any, dialogResponseCallback: StandardErrorCallback<any>, cb?: StandardErrorCallback<SpawnResponse> | undefined) => StandardPromise<SpawnResponse>;
/**
 * Opens an existing dialog that is registered under the requested type.
 * If no dialog is found then one will be spawned (with the options passed as the second parameter).
 *
 * Resolves to an error string if the dialog could not be opened, or null if it was successfully opened.
 *
 * @param {string} type Component type to open. The <code>type</code> must be a key in the finsemble.components configuration object.
 * @param {object} options Options to pass into the opened window.
 * @param {function} onUserInput Callback to be invoked when the user interacts with the dialog.
 */
export declare const open: (type: string, options: any, onUserInput: StandardErrorCallback<any>) => Promise<string | null>;
/**
 * Called from within a dialog window to get the `inputParams` passed by the originating window when
 * it called `spawnDialog()`.
 *
 * ```JavaScript
 * var dialogData = FSBL.Clients.DialogManager.getParametersFromInDialog();
 * ```
 */
export declare const getParametersFromInDialog: () => any;
/**
 * Called within a dialog to pass a response back to the originating window.
 * This will invoke the originating window's callback function that it passed to `spawnDialog()`.
 *
 * ```JavaScript
 * FSBL.Clients.DialogManager.respondAndExitFromInDialog({ choice: response });
 * ```
 * @param {object} responseParameters Data to be returned to the originating window's callback
 */
export declare const respondAndExitFromInDialog: (responseParameters: any) => void;
/**
 * Must be called by the dialog window when it is ready to be displayed.
 */
export declare const showDialog: () => Promise<void>;
/**
 * Dialog windows *must* run this method so that results can be sent back to
 * originating windows. This method must *only* be run once in any given dialog window.
 *
 * ```JavaScript
 * FSBL.Clients.DialogManager.registerDialogCallback((err, request) => {
 *    if(err) return;
 *    console.log("Originating window sent", request.data);
 *    request.sendQueryResponse("your response");
 *    FSBL.System.Window.getCurrent().hide();
 * });
 *
 * ```
 *
 * @param {function} callback Callback that is invoked when the originating window
 * connects. Data passed by the originating window can be found in the `data` member of the
 * second parameter to the callback.
 */
export declare const registerDialogCallback: (cb?: StandardErrorCallback<ResponderMessage<any, any>> | undefined) => Promise<void>;
/**
 * Dialogs may call this to respond to the originating window (instead of responding
 * directly to callbacks from `registerDialogCallback()`). The main advantage of using
 * this method is that it automatically hides the dialog.
 *
 * The modal scrim will automatically be hidden unless `data` is an object with
 * member `hideModalOnClose` set to `false`.
 *
 * @param {any} data Data to be passed back to the originating window.
 */
export declare const respondToOpener: (data?: any) => Promise<void>;
/**
 * @ignore
 */
export declare const DialogManagerClient: {
    /**
     * Used to set a timeout. This will be refactored.
     */
    userInputTimeout: number | null;
    /**
     * Used to check response from dialog. This will be refactored.
     */
    readonly openerMessage: ResponderMessage<any, any> | null;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    initialize: () => void;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    onReady: (cb?: any) => void;
    createStore: (cb?: (() => void) | undefined) => Promise<void>;
    getAvailableDialog: (type: string, cb?: ((dialog: WindowIdentifier | null) => void) | undefined) => Promise<WindowIdentifier | null>;
    sendQueryToDialog: (identifier: WindowIdentifier, options: any, onUserInput: StandardErrorCallback<any>) => Promise<void>;
    open: (type: string, options: any, onUserInput: StandardErrorCallback<any>) => Promise<string | null>;
    spawnDialog: (params: SpawnParams, inputParams: any, dialogResponseCallback: StandardErrorCallback<any>, cb?: StandardErrorCallback<SpawnResponse> | undefined) => StandardPromise<SpawnResponse>;
    registerDialogCallback: (cb?: StandardErrorCallback<ResponderMessage<any, any>> | undefined) => Promise<void>;
    getParametersFromInDialog: () => any;
    respondAndExitFromInDialog: (responseParameters: any) => void;
    showDialog: () => Promise<void>;
    registerModal: () => Promise<string | null>;
    showModal: (cb?: ((error?: string | undefined) => void) | undefined) => Promise<string | null>;
    hideModal: () => Promise<string | null>;
    respondToOpener: (data?: any) => Promise<void>;
};
/**
 * @ignore
 */
export default DialogManagerClient;
//# sourceMappingURL=dialogManagerClient.d.ts.map