"use strict";
/*---------------------------------------------------------------------------------------------
 * 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
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccuDrawPopupManager = void 0;
const React = require("react");
const core_frontend_1 = require("@itwin/core-frontend");
const PopupManager_1 = require("../popup/PopupManager");
const MenuItem_1 = require("../shared/MenuItem");
const CalculatorPopup_1 = require("./CalculatorPopup");
const MenuButtonPopup_1 = require("./MenuButtonPopup");
const angle_svg_1 = require("./angle.svg");
const distance_svg_1 = require("./distance.svg");
const height_2_svg_1 = require("./height-2.svg");
/** AccuDraw Popup Manager class
 * @public
 */
class AccuDrawPopupManager {
    static showMenuButton(id, el, pt, menuItemsProps) {
        // eslint-disable-next-line deprecation/deprecation
        const menuItems = MenuItem_1.MenuItemHelpers.createMenuItems(menuItemsProps);
        // eslint-disable-next-line deprecation/deprecation
        const menuContent = MenuItem_1.MenuItemHelpers.createMenuItemNodes(menuItems);
        const component = (React.createElement(MenuButtonPopup_1.MenuButtonPopup, { id: id, el: el, pt: pt, offset: PopupManager_1.PopupManager.defaultOffset, content: menuContent }));
        const popupInfo = {
            id,
            pt,
            component,
            parentDocument: el.ownerDocument,
            parent: el.ownerDocument,
        };
        PopupManager_1.PopupManager.addOrUpdatePopup(popupInfo);
        return true;
    }
    static hideMenuButton(id) {
        return PopupManager_1.PopupManager.removePopup(id);
    }
    static showCalculator(el, pt, initialValue, resultIcon, onOk, onCancel) {
        const id = AccuDrawPopupManager._calculatorId;
        const component = (
        // eslint-disable-next-line deprecation/deprecation
        React.createElement(CalculatorPopup_1.CalculatorPopup, { id: id, el: el, pt: pt, offset: PopupManager_1.PopupManager.defaultOffset, initialValue: initialValue, resultIcon: resultIcon, onOk: onOk, onCancel: onCancel }));
        const popupInfo = {
            id,
            pt,
            component,
            parentDocument: el.ownerDocument,
            parent: el.ownerDocument,
        };
        PopupManager_1.PopupManager.addOrUpdatePopup(popupInfo);
        return true;
    }
    static hideCalculator() {
        return PopupManager_1.PopupManager.removePopup(AccuDrawPopupManager._calculatorId);
    }
    static showAngleEditor(el, pt, value, onCommit, onCancel) {
        const propertyDescription = new core_frontend_1.AngleDescription(undefined, undefined, angle_svg_1.default);
        return PopupManager_1.PopupManager.showInputEditor(el, pt, value, propertyDescription, onCommit, onCancel);
    }
    /** @internal */
    static showDimensionEditor(dimension, el, pt, value, onCommit, onCancel) {
        if (dimension === "height") {
            return AccuDrawPopupManager.showHeightEditor(el, pt, value, onCommit, onCancel);
        }
        return AccuDrawPopupManager.showLengthEditor(el, pt, value, onCommit, onCancel);
    }
    static showLengthEditor(el, pt, value, onCommit, onCancel) {
        const propertyDescription = new core_frontend_1.LengthDescription(undefined, undefined, distance_svg_1.default);
        return PopupManager_1.PopupManager.showInputEditor(el, pt, value, propertyDescription, onCommit, onCancel);
    }
    static showHeightEditor(el, pt, value, onCommit, onCancel) {
        const propertyDescription = new core_frontend_1.LengthDescription(undefined, undefined, height_2_svg_1.default);
        return PopupManager_1.PopupManager.showInputEditor(el, pt, value, propertyDescription, onCommit, onCancel);
    }
}
exports.AccuDrawPopupManager = AccuDrawPopupManager;
AccuDrawPopupManager._calculatorId = "Calculator";
//# sourceMappingURL=AccuDrawPopupManager.js.map