/*---------------------------------------------------------------------------------------------
 * 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 { PopupManager } from "../popup/PopupManager.js";
import { MenuItemHelpers } from "../shared/MenuItem.js";
import { CalculatorPopup } from "./CalculatorPopup.js";
import { MenuButtonPopup } from "./MenuButtonPopup.js";
import { SvgDistance } from "../icons/SvgDistance.js";
import { SvgAngle } from "../icons/SvgAngle.js";
import { addIconNodeParam } from "@itwin/components-react/internal";
import { SvgHeight } from "../icons/SvgHeight.js";
/** AccuDraw Popup Manager class
 * @public
 */
export class AccuDrawPopupManager {
    static showMenuButton(id, el, pt, menuItemsProps) {
        // eslint-disable-next-line @typescript-eslint/no-deprecated
        const menuItems = MenuItemHelpers.createMenuItems(menuItemsProps);
        // eslint-disable-next-line @typescript-eslint/no-deprecated
        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,
            parent: 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 = (
        // eslint-disable-next-line @typescript-eslint/no-deprecated
        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,
            parent: 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();
        addIconNodeParam(propertyDescription, React.createElement(SvgAngle, null));
        return 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 LengthDescription();
        addIconNodeParam(propertyDescription, React.createElement(SvgDistance, null));
        return PopupManager.showInputEditor(el, pt, value, propertyDescription, onCommit, onCancel);
    }
    static showHeightEditor(el, pt, value, onCommit, onCancel) {
        const propertyDescription = new LengthDescription();
        addIconNodeParam(propertyDescription, React.createElement(SvgHeight, null));
        return PopupManager.showInputEditor(el, pt, value, propertyDescription, onCommit, onCancel);
    }
}
AccuDrawPopupManager._calculatorId = "Calculator";
//# sourceMappingURL=AccuDrawPopupManager.js.map