/*!
 * Copyright 2017 - 2020 by ChartIQ, Inc.
 * All rights reserved.
 */
/**
 * The Workspace Client manages all calls to load, save, rename, and delete workspaces.
 *
 * The Workspace Client uses the `windowIdentifier` parameter. <a href="/docs/productivity/componentTypesAndWindowNames">Learn more about them here</a>.
 *
 * See the <a href="/docs/productivity/Workspaces">Workspace tutorial</a> for an overview of using the Workspace Client.
 * @module WorkspaceClient
 */
import { RouterResponse } from "./routerClient";
import { StateType, CompleteWindowState } from "../platform/services/workspace/types";
import FinsembleEvent from "../common/events/FinsembleEvent";
import PublicEventManager from "../common/events/PublicEventManager";
import { StandardErrorCallback } from "../types";
import { WorkspaceEventName, Workspace, ActiveWorkspace } from "../platform/services/workspace/types";
export type FinsembleEventHandler = (event: FinsembleEvent) => void;
export { FinsembleEvent, Workspace };
export { WorkspaceBase, GroupData, WorkspaceEventName } from "../platform/services/workspace/types";
export { FinsembleEventParams } from "../common/events/FinsembleEvent";
/**
 * @phantom Don't display in Typedoc
 */
export declare class WorkspaceClientController {
    /**
     * List of all workspaces names within the application.
     */
    workspaces: string[];
    /**
     * Utility for managing event listeners - much like EventEmitter
     */
    publicEventManager: PublicEventManager;
    /**
     * Reference to the activeWorkspace object
     */
    activeWorkspace: ActiveWorkspace | undefined;
    constructor();
}
/**
 * @ignore
 */
export declare const getControllerInstance: () => WorkspaceClientController;
/**
 * @language javascript, java, dotnet
 * This provides the ability to listen to workspace events.
 * The load-requested event provides a way to merge data into the workspace prior to loading.
 * The close-requested and save-requested event, allow you to perform actions prior to the actual save and close.
 * The rest of the events are informational only.
 * To tell the workspace service to wait, you must call event.wait() in less than one second.
 * Calling event.wait() will wait indefinitely.
 * After event.wait() is called, event.done() must be called to resume operation.
 * If the event is cancelable, event.cancel() may also be called after event.wait() to cancel the event.
 * To send data event.done(data) must be called, otherwise done with no data is assumed.
 *
 * ```javascript
 * // Sync examples:
 * FSBL.Clients.WorkspaceClient.addEventListener("close-requested", (event) => { doSomething(); })
 * FSBL.Clients.WorkspaceClient.addEventListener("load-requested", (event) => { const data = doSomething(); event.done(data); })
 *
 * // Async examples:
 * FSBL.Clients.WorkspaceClient.addEventListener("close-requested", async (event) => { event.wait(); await doSomething(); event.done(); })
 * FSBL.Clients.WorkspaceClient.addEventListener("load-requested", async (event) => { event.wait(); const data = await doSomething(); event.done(data); })
 * ```
 * @param event The workspace event to listen for
 * @param handler A function to handle the event
 */
export declare const addEventListener: (event: WorkspaceEventName, handler: FinsembleEventHandler) => void;
/**
 * @language javascript, java, dotnet
 * Removes an event listener.
 *
 * @param event The workspace event that is listened on
 * @param handler The handler that is in effect
 */
export declare const removeEventListener: (event: WorkspaceEventName, handler: FinsembleEventHandler) => void;
/**
 * @language javascript, java, dotnet
 * Gets the currently active workspace.
 * This function is useful for setting the initial state of a menu or dialog. It is used in the toolbar component to set the initial state.
 *
 * ```javascript
 * FSBL.Clients.WorkspaceClient.getActiveWorkspace((err, response) => {
 * 	// do something with the response.
 * });
 * ```
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const getActiveWorkspace: (cb?: StandardErrorCallback<{
    data: Workspace;
}>) => Promise<{
    data: Workspace;
}>;
/**
 * @language javascript, java, dotnet
 * Returns the list of saved workspaces. This function is useful for setting the initial state of a menu or dialog.
 *
 * ```javascript
 * FSBL.Clients.WorkspaceClient.getWorkspaces((err, response) => {
 *   //do something with the array of workspace objects
 *   console.log(response)
 * });
 * ```
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const getWorkspaces: (cb?: Function) => Promise<unknown>;
/**
 * @language javascript, dotnet
 * Gets workspace actions defined as constants. Allows users to filter
 * updates
 *
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const getWorkspaceActions: (cb?: StandardErrorCallback<Record<string, string>>) => Record<string, string>;
/**
 * @language javascript, dotnet
 * Returns a list of workspace names. This function returns the list of all the workspace.
 *
 * ```javascript
 * FSBL.Clients.WorkspaceClient.getWorkspaceNames((err, response) => {
 *   console.log(JSON.stringify(response, null, 2));
 * });
 *
 *
 * Output:
 * [
 *   "Default Workspace",
 *   "Another workspace"
 * ]
 *
 * ```
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const getWorkspaceNames: (cb?: StandardErrorCallback<string[]>) => Promise<string[]>;
/**
 * @language javascript, dotnet
 * Sets the ordering of workspaces (e.g. to control the ordering of workspaces listed in a menu.)
 *
 * @param params
 * @param cb
 * @returns
 * @ignore Keep private until params can be documented
 */
export declare const setWorkspaceOrder: (params: any, cb?: Function) => Promise<unknown>;
/**
 * @language javascript, java, dotnet
 * Removes a workspace. Either the workspace object or its name must be provided.
 *
 * The following examples both remove 'My Workspace' from the main menu and the default storage tied to the application.
 *
 * ```javascript
 * FSBL.Clients.WorkspaceClient.remove({
 *   name: 'My Workspace'
 * }, function(err, response) {
 * 	//You typically won't do anything here. If you'd like to do something when a workspace change happens, we suggest listening on the `Finsemble.WorkspaceService.update` channel.
 * });
 *
 * FSBL.Clients.WorkspaceClient.remove({
 * 	 workspace: {
 *     version: "1.0.0",
 *     name: 'My Workspace',
 *     type: "workspace",
 *     // ...
 *   }
 * });
 * ```
 * @param params Parameters object specifying the workspace name to remove, either directly as `name` or by passing in the `workspace` from which the name will be extracted.
 * @param params.workspace A workspace data object.
 * @param params.workspace.name The workspace name, embedded in the workspace object, that removal is requested for.
 * @param params.name The workspace name removal is requested for.
 * @param cb Callback to fire after 'Finsemble.WorkspaceService.update' is transmitted.
 */
export declare const remove: (params: {
    workspace?: {
        name: string;
    };
    name?: string;
}, cb?: Function) => Promise<unknown>;
/**
 * @language javascript, java, dotnet
 * Renames the workspace with the provided name. Also removes all references in storage to the old workspace's name.
 * This method is used to rename workspaces. It is used in the main Menu component.
 *
 * :::note
 * If you attempt to rename a Workspace to a name that already exists a `({next number})` will be added to the newName.
 * :::
 *
 * ```javascript
 * FSBL.Clients.WorkspaceClient.rename({
 * 	oldName: 'My Workspace',
 * 	newName: 'The best workspace',
 * 	removeOldWorkspace: true,
 * }, function(err, response) {
 * 	//Do something.
 * });
 * ```
 * @param params
 * @param params.oldName Name of workspace to rename.
 * @param params.newName What to rename the workspace to.
 * @param params.removeOldWorkspace Whether to remove references to old workspace after renaming.
 * @param params.overwriteExisting Whether to overwrite an existing workspace.
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const rename: (params: {
    oldName: string;
    newName: string;
    removeOldWorkspace?: boolean;
    overwriteExisting?: boolean;
}, cb?: Function) => Promise<unknown>;
/**
 * @language javascript, java, dotnet
 * Saves the current active workspace.
 *
 * This example persists the currently active workspace.
 * ```javascript
 * FSBL.Clients.WorkspaceClient.save(function(err) {
 * 	//Do something.
 * });
 * ```
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const save: (cb?: Function) => Promise<unknown>;
/**
 * @language javascript, java, dotnet
 * Saves the currently active workspace with the provided name.
 *
 * This example persists the currently active workspace with the provided name.
 * ```javascript
 * FSBL.Clients.WorkspaceClient.saveAs({
 * 	name: 'My Workspace',
 * }, function(err, response) {
 * 	//Do something.
 * });
 * ```
 * @param params
 * @param params.name The new name you want to save the workspace under.
 * @param params.force Whether to overwrite a workspace already saved with the provided name.
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const saveAs: (params: {
    name: string;
    force?: boolean;
}, cb?: Function) => Promise<unknown>;
/**
 * @language javascript, java, dotnet
 * Switches to a workspace.
 *
 * This example loads the workspace 'My Workspace' from the storage tied to the application.
 * ```javascript
 * FSBL.Clients.WorkspaceClient.switchTo({
 * 	name: 'My Workspace',
 * }, function(err, response) {
 * 	//Do something.
 * });
 * ```
 * @param params
 * @param params.name The name of the workspace you want to switch to.
 * @param cb The callback to be invoked after the method completes successfully.
 */
export declare const switchTo: (params: {
    name: string;
}, cb?: StandardErrorCallback<{
    data: Workspace;
}>) => Promise<{
    data: Workspace;
}>;
/**
 * Sets the stored state of a given window in the active workspace. `state` may include
 * keys for `windowData`, `componentState`, or both; the state of each key will be completely
 * overwritten by the provided state. If the update results in dirtying change, the active
 * workspace will be marked dirty (or, if auto save is on, persisted directly to storage).
 *
 * @ignore This function is only called by the Window and Assimilation services. It should be
 * moved into workspaceService/workspaceAdminAPI. But, the code uses the locally cached
 * activeWorkspace which may or may not be for legitimate performance reasons. Therefore we're
 * leaving this here until it can be safely refactored.
 */
export declare const setWindowState: (params: {
    windowName: string;
    state: Partial<CompleteWindowState>;
}) => Promise<RouterResponse<boolean>>;
/**
 * @language javascript, dotnet
 * Checks to see if the workspace is dirty, i.e., if its state has been changed since the last save. If it's already dirty, the window doesn't need to compare its state to the saved state.
 *
 * This example will let you know if the active workspace is dirty.
 * ```javascript
 * FSBL.Clients.WorkspaceClient.isWorkspaceDirty(function(err, response) {
 *     if (response.data === true) {
 *         //Do something like prompt the user if they'd like to save the currently loaded workspace before switching.
 *    } else {
 *        //Workspace is clean
 *    }
 * });
 * ```
 * @param cb `cb(err,response)` with response set to true if dirty and false otherwise (when no error).
 */
export declare const isWorkspaceDirty: (cb?: Function) => Promise<boolean>;
/**
 * @language javascript, java, dotnet
 * Creates a new workspace, returning a promise for the final name of
 * the new workspace as a string. After creation, if "switchAfterCreation" is true,
 * the new workspace becomes the active workspace.
 *
 * If the requested name already exists, a new workspace will be created
 * with the form "[name] (1)" (or "[name] (2)", etc.)
 *
 * This example creates the workspace 'My Workspace'.
 * ```javascript
 * FSBL.Clients.WorkspaceClient.createWorkspace(
 * 	"My workspace",
 *  {switchAfterCreation:true},
 *  function(err, response) {
 *		if (!err) {
 *			//Do something, such as notify the user that the workspace has been created.
 *		}
 *  }
 * );
 * ```
 * @param workspaceName Name for new workspace. If the workspaceName is empty, the workspace is given the name "Untitled." Subsequent creations with empty strings would result in "Untitled1", "Untitled2", etc.
 * @param params Optional params
 * @param params.switchAfterCreation Whether to switch to the new workspace after creating it. Defaults to true.
 * @param cb `cb(err,response)` With response, set to new workspace object if no error.
 */
export declare const createWorkspace: (workspaceName: string, params?: {
    switchAfterCreation?: boolean;
}, cb?: (err: any, result: {
    workspaceName: string;
}) => void) => Promise<{
    workspaceName: string;
}>;
/**
 * @rename export
 * @language javascript, java
 * Gets a workspace definition in JSON form.
 *
 * ```javascript
 * FSBL.Clients.WorkspaceClient.export({'workspaceName': 'linker'}, function(err, workspaceDefinition) {
 * 	//do something with the workspace definition
 * });
 * ```
 * @param params
 * @param params.workspaceName The name of the workspace you want to export.
 * @param cb callback(error, workspaceDefinition)
 */
export declare const exportWorkspace: (params: {
    workspaceName: string;
}, cb: Function) => Promise<unknown>;
/**
 * @rename import
 * @language javascript, java
 * Adds a workspace definition to the list of available workspaces.
 *
 * ```javascript
 * FSBL.Clients.WorkspaceClient.import({force: false, workspaceJSONDefinition: workspaceDefinition}, function(err) {
 *		if (!err) console.log("import success.");
 * });
 * ```
 * @param params
 * @param params.workspaceJSONDefinition The JSON for the workspace definition, as exported by the User Preferences menu in Finsemble Connect.
 * @param params.force Whether to overwrite any workspace of the same name that already exists
 * @param cb `cb(err)` where the operation was successful if !err; otherwise, err carries diagnostics
 */
export declare const importWorkspace: (params: {
    workspaceJSONDefinition: Record<string, Workspace | string>;
    force: boolean;
}, cb?: Function) => Promise<Record<string, string>>;
/**
 * Saves one or more template definitions in a selected file. Note the
 * end user is prompted to identify file location during this save
 * operation. The file can optionally be imported during config
 * initialization (see importConfig) although this requires administration
 * support on the configuration/server side. The file can also be read
 * using readWorkspaceTemplateFromConfigFile();
 *
 * @param params
 * @param params.workspaceTemplateDefinition legal template definition returned by either
 * getWorkspaceTemplateDefinition() or convertWorkspaceDefinitionToTemplate()
 * @ignore This isn't used anywhere. Is it in use by customers?
 */
export declare const exportToFile: (params: {
    workspaceTemplateDefinition: any;
}) => void;
/**
 * Re-export so that typedoc will associate the docs with this module
 */
export { bringWindowsToFront, minimizeWindows as minimizeAll, autoArrange } from "../common/Desktop";
/**
 * @ignore
 */
export declare const WorkspaceClient: {
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    saveWorkspaceTemplateToConfigFile: (params: any) => void;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    addWorkspaceDefinition: (params: any, cb: any) => Promise<Record<string, string>>;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    getWorkspaceDefinition: (params: any, cb: any) => Promise<unknown>;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    createNewWorkspace: (workspaceName: any, params: any, cb: any) => Promise<{
        workspaceName: string;
    }>;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    setWorkspaces: (params: any, cb: any) => Promise<unknown>;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    initialize: () => void;
    /**
     * For backward compatibility
     * @private
     * @deprecated
     */
    onReady: (cb?: any) => void;
    removeWindow: (params: any, cb: any) => void;
    addWindow: (params: any, cb: any) => void;
    readonly workspaces: string[];
    readonly activeWorkspace: Workspace | undefined;
    export: (params: {
        workspaceName: string;
    }, cb: Function) => Promise<unknown>;
    import: (params: {
        workspaceJSONDefinition: Record<string, Workspace | string>;
        force: boolean;
    }, cb?: Function) => Promise<Record<string, string>>;
    exportToFile: (params: {
        workspaceTemplateDefinition: any;
    }) => void;
    createWorkspace: (workspaceName: string, params?: {
        switchAfterCreation?: boolean;
    }, cb?: (err: any, result: {
        workspaceName: string;
    }) => void) => Promise<{
        workspaceName: string;
    }>;
    isWorkspaceDirty: (cb?: Function) => Promise<boolean>;
    _getWindowState: (params: {
        windowName: string;
        stateVars: StateType[];
    }) => Promise<RouterResponse<Partial<CompleteWindowState>>>;
    _setWindowState: (params: any) => Promise<RouterResponse<boolean>>;
    switchTo: (params: {
        name: string;
    }, cb?: StandardErrorCallback<{
        data: Workspace;
    }>) => Promise<{
        data: Workspace;
    }>;
    saveAs: (params: {
        name: string;
        force?: boolean;
    }, cb?: Function) => Promise<unknown>;
    workspaceExists: (workspaceName: any) => void;
    save: (cb?: Function) => Promise<unknown>;
    rename: (params: {
        oldName: string;
        newName: string;
        removeOldWorkspace?: boolean;
        overwriteExisting?: boolean;
    }, cb?: Function) => Promise<unknown>;
    remove: (params: {
        workspace?: {
            name: string;
        };
        name?: string;
    }, cb?: Function) => Promise<unknown>;
    setWorkspaceOrder: (params: any, cb?: Function) => Promise<unknown>;
    getWorkspaceNames: (cb?: StandardErrorCallback<string[]>) => Promise<string[]>;
    getWorkspaceActions: (cb?: StandardErrorCallback<Record<string, string>>) => Record<string, string>;
    getWorkspaces: (cb?: Function) => Promise<unknown>;
    getActiveWorkspace: (cb?: StandardErrorCallback<{
        data: Workspace;
    }>) => Promise<{
        data: Workspace;
    }>;
    bringWindowsToFront: (params?: {
        windowList?: string[];
    }, cb?: StandardErrorCallback<void>) => import("../typedoc-types").StandardPromise<void>;
    minimizeAll: (params?: {
        windowList?: string[];
    }, cb?: StandardErrorCallback<void>) => import("../typedoc-types").StandardPromise<void>;
    autoArrange: (params: any, cb?: StandardErrorCallback<void>) => import("../typedoc-types").StandardPromise<void>;
    addEventListener: (event: WorkspaceEventName, handler: FinsembleEventHandler) => void;
    removeEventListener: (event: WorkspaceEventName, handler: FinsembleEventHandler) => void;
};
/**
 * @ignore
 */
export default WorkspaceClient;
//# sourceMappingURL=workspaceClient.d.ts.map