/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Notification
 */
import { ActivityMessageEndReason, NotificationManager, ToolAssistance, } from "@itwin/core-frontend";
import { ElementTooltip } from "../feedback/ElementTooltip.js";
import { UiFramework } from "../UiFramework.js";
import { MessageManager } from "./MessageManager.js";
import { PointerMessage } from "./Pointer.js";
/** Subclass of `NotificationManager` in `@itwin/core-frontend` to be used to initialize `IModelApp`.
 *
 * This implementation uses themed react components to display alerts, messages, prompts and tooltips.
 *
 * ```ts
 * await IModelApp.startup({
 *   notifications: new AppNotificationManager()
 * });
 * ```
 * @public
 */
export class AppNotificationManager extends NotificationManager {
    /** Output a prompt, given an i18n key.
     */
    outputPromptByKey(key) {
        this.outputPrompt(UiFramework.translate(key));
    }
    /** Output a prompt to the user. A 'prompt' indicates an action the user should take to proceed.
     */
    outputPrompt(prompt) {
        MessageManager.outputPrompt(prompt);
        const mainInstruction = ToolAssistance.createInstruction("", prompt);
        const instructions = ToolAssistance.createInstructions(mainInstruction);
        MessageManager.setToolAssistance(instructions);
    }
    /** Output a message and/or alert to the user. */
    outputMessage(message) {
        MessageManager.outputMessage(message);
    }
    /** Output a MessageBox and wait for response from the user.
     * @param mbType       The MessageBox type.
     * @param message      The message to display.
     * @param icon         The MessageBox icon type.
     * @return the response from the user.
     */
    async openMessageBox(mbType, message, icon) {
        return MessageManager.openMessageBox(mbType, message, icon);
    }
    /**
     * Set up for activity messages.
     * @param details  The activity message details.
     * @return true if the message was displayed, false if an invalid priority is specified.
     */
    setupActivityMessage(details) {
        return MessageManager.setupActivityMessageDetails(details);
    }
    /**
     * Output an activity message to the user.
     * @param messageText      The message text.
     * @param percentComplete  The percentage of completion.
     * @return true if the message was displayed, false if the message could not be displayed.
     */
    outputActivityMessage(messageText, percentComplete) {
        return MessageManager.setupActivityMessageValues(messageText, percentComplete);
    }
    /**
     * End an activity message.
     * @param reason       Reason for the end of the Activity Message.
     * @return true if the message was ended successfully, false if the activityMessage could not be ended.
     */
    endActivityMessage(reason) {
        let result = false;
        switch (reason) {
            case ActivityMessageEndReason.Completed:
                result = MessageManager.endActivityMessage(true);
                break;
            case ActivityMessageEndReason.Cancelled:
                result = MessageManager.endActivityMessage(false);
                break;
        }
        return result;
    }
    /** Update message position created with [[OutputMessageType.Pointer]].
     * @param displayPoint        Point at which to display the Pointer type message.
     * @param relativePosition    Position relative to displayPoint at which to display the Pointer type message.
     */
    updatePointerMessage(displayPoint, relativePosition) {
        PointerMessage.updateMessage(displayPoint, relativePosition);
    }
    /** Hides the Pointer message. */
    closePointerMessage() {
        PointerMessage.hideMessage();
    }
    /** Return true if _showTooltip has an implementation and will display a tooltip. */
    get isToolTipSupported() {
        return true;
    }
    /** Return true if the tooltip is currently open. */
    get isToolTipOpen() {
        return ElementTooltip.isTooltipVisible;
    }
    /** Clear the ToolTip if it is currently open. If not open, does nothing. */
    clearToolTip() {
        if (this.isToolTipOpen)
            ElementTooltip.hideTooltip();
    }
    /** Show a ToolTip window.
     * @param el       The HTMLElement that anchors the toolTip.
     * @param message  The message to display inside the ToolTip
     * @param pt       An optional location, relative to the origin of el, for the ToolTip. If undefined, center of el.
     * @param options  Options that supply additional information about how the ToolTip should function.
     */
    _showToolTip(el, message, pt, options) {
        ElementTooltip.showTooltip(el, message, pt, options);
    }
    /** Hide a InputField message. */
    closeInputFieldMessage() {
        MessageManager.hideInputFieldMessage();
    }
    /** Setup tool assistance instructions for a tool. The instructions include the main instruction, which includes the current prompt.
     * @param instructions The tool assistance instructions.
     * @public
     */
    setToolAssistance(instructions) {
        MessageManager.outputPrompt(instructions ? instructions.mainInstruction.text : "");
        MessageManager.setToolAssistance(instructions);
    }
}
//# sourceMappingURL=AppNotificationManager.js.map