"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 StatusBar
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatusBarIndicator = void 0;
const React = require("react");
const Popup_1 = require("./popup/Popup");
const Field_1 = require("./Field");
/** General-purpose [[StatusBar]] indicator.
 * @beta
 * @deprecated in 4.14.0. Use [iTwinUI Button](https://itwinui.bentley.com/docs/button) (or other components) and {@link StatusBarPopover AppUI StatusBarPopover} instead.
 */
// eslint-disable-next-line deprecation/deprecation
function StatusBarIndicator(props) {
    const hasClickAction = !!props.onClick || !!props.popup;
    const [isOpen, setIsOpen] = React.useState(!!props.defaultIsOpen);
    const handleOnIndicatorClick = () => {
        setIsOpen(!isOpen);
        props.onClick?.();
    };
    const target = React.useRef(null);
    return (React.createElement(React.Fragment, null,
        React.createElement(Field_1.StatusBarField, { ref: target, className: props.className, title: props.title, style: props.style, onClick: hasClickAction ? handleOnIndicatorClick : undefined }, props.children),
        props.popup && (
        // eslint-disable-next-line deprecation/deprecation
        React.createElement(Popup_1.StatusBarPopup, { target: target.current, onClose: () => setIsOpen(false), isOpen: isOpen }, props.popup))));
}
exports.StatusBarIndicator = StatusBarIndicator;
//# sourceMappingURL=Indicator.js.map