/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module AccuDraw
 */
import * as React from "react";
import { AngleDescription, LengthDescription } from "@itwin/core-frontend";
import { IconSpecUtilities } from "@itwin/appui-abstract";
import { PopupManager } from "../popup/PopupManager";
import { MenuItemHelpers } from "../shared/MenuItem";
import { CalculatorPopup } from "./CalculatorPopup";
import { MenuButtonPopup } from "./MenuButtonPopup";
import angleIcon from "./angle.svg";
import lengthIcon from "./distance.svg";
import heightIcon from "./height-2.svg";
/** AccuDraw Popup Manager class
 * @alpha
 */
export class AccuDrawPopupManager {
    static showMenuButton(id, el, pt, menuItemsProps) {
        const menuItems = MenuItemHelpers.createMenuItems(menuItemsProps);
        const menuContent = MenuItemHelpers.createMenuItemNodes(menuItems);
        const component = (React.createElement(MenuButtonPopup, { id: id, el: el, pt: pt, offset: PopupManager.defaultOffset, content: menuContent }));
        const popupInfo = {
            id, pt, component, parentDocument: el.ownerDocument,
        };
        PopupManager.addOrUpdatePopup(popupInfo);
        return true;
    }
    static hideMenuButton(id) {
        return PopupManager.removePopup(id);
    }
    static showCalculator(el, pt, initialValue, resultIcon, onOk, onCancel) {
        const id = AccuDrawPopupManager._calculatorId;
        const component = (React.createElement(CalculatorPopup, { id: id, el: el, pt: pt, offset: PopupManager.defaultOffset, initialValue: initialValue, resultIcon: resultIcon, onOk: onOk, onCancel: onCancel }));
        const popupInfo = {
            id, pt, component, parentDocument: el.ownerDocument,
        };
        PopupManager.addOrUpdatePopup(popupInfo);
        return true;
    }
    static hideCalculator() {
        return PopupManager.removePopup(AccuDrawPopupManager._calculatorId);
    }
    static showAngleEditor(el, pt, value, onCommit, onCancel) {
        const propertyDescription = new AngleDescription(undefined, undefined, IconSpecUtilities.createWebComponentIconSpec(angleIcon));
        return PopupManager.showInputEditor(el, pt, value, propertyDescription, onCommit, onCancel);
    }
    static showLengthEditor(el, pt, value, onCommit, onCancel) {
        const propertyDescription = new LengthDescription(undefined, undefined, IconSpecUtilities.createWebComponentIconSpec(lengthIcon));
        return PopupManager.showInputEditor(el, pt, value, propertyDescription, onCommit, onCancel);
    }
    static showHeightEditor(el, pt, value, onCommit, onCancel) {
        const propertyDescription = new LengthDescription(undefined, undefined, IconSpecUtilities.createWebComponentIconSpec(heightIcon));
        return PopupManager.showInputEditor(el, pt, value, propertyDescription, onCommit, onCancel);
    }
}
AccuDrawPopupManager._calculatorId = "Calculator";
//# sourceMappingURL=AccuDrawPopupManager.js.map