"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.CalculatorPopup = void 0;
const React = require("react");
const core_react_1 = require("@itwin/core-react");
const PopupManager_1 = require("../popup/PopupManager");
const PositionPopup_1 = require("../popup/PositionPopup");
const Calculator_1 = require("./Calculator");
/** Popup component for Calculator
 * @alpha
 */
class CalculatorPopup extends React.PureComponent {
    constructor() {
        super(...arguments);
        /** @internal */
        this.state = {
            size: new core_react_1.Size(-1, -1),
        };
        this._onSizeKnown = (newSize) => {
            if (!this.state.size.equals(newSize))
                this.setState({ size: core_react_1.Size.create(newSize) });
        };
    }
    /** @internal */
    render() {
        const point = PopupManager_1.PopupManager.getPopupPosition(this.props.el, this.props.pt, this.props.offset, this.state.size);
        return (React.createElement(PositionPopup_1.PositionPopup, { key: this.props.id, point: point, className: "uifw-calculator-host", onSizeKnown: this._onSizeKnown },
            React.createElement(core_react_1.DivWithOutsideClick, { onOutsideClick: this.props.onCancel },
                React.createElement(PositionPopup_1.PositionPopupContent, null,
                    React.createElement(Calculator_1.Calculator, { initialValue: this.props.initialValue, resultIcon: React.createElement(core_react_1.Icon, { iconSpec: this.props.resultIcon }), onOk: this.props.onOk, onCancel: this.props.onCancel })))));
    }
}
exports.CalculatorPopup = CalculatorPopup;
//# sourceMappingURL=CalculatorPopup.js.map