"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.Indicator = void 0;
require("./Indicator.scss");
const classnames_1 = require("classnames");
const React = require("react");
const appui_abstract_1 = require("@itwin/appui-abstract");
const core_react_1 = require("@itwin/core-react");
const appui_layout_react_1 = require("@itwin/appui-layout-react");
/** General-purpose [[Footer]] indicator. Shows an icon and supports an optional popup dialog.
 * @deprecated in 3.6. Use [[StatusBarIndicator]] or [[StatusBarLabelIndicator]] instead.
 * @beta
 */
function Indicator(props) {
    // eslint-disable-next-line deprecation/deprecation
    const { className, contentType, dialog, iconName, iconSpec, isInFooterMode, isLabelVisible, label, labelSide, onClick, opened, style, toolTip } = props;
    const hasClickAction = React.useMemo(() => !!onClick || !!dialog, [dialog, onClick]);
    const [isOpen, setIsOpen] = React.useState(!!opened);
    const handleOnIndicatorClick = React.useCallback(() => {
        if (dialog) {
            setIsOpen(!isOpen);
        }
        onClick && onClick();
    }, [dialog, isOpen, onClick]);
    const inFooter = React.useMemo(() => false === isInFooterMode ? false : true, [isInFooterMode]);
    const target = React.useRef(null);
    const icon = React.useMemo(() => iconSpec !== null && iconSpec !== void 0 ? iconSpec : iconName, [iconSpec, iconName]);
    const title = React.useMemo(() => toolTip !== null && toolTip !== void 0 ? toolTip : label, [toolTip, label]);
    const classNames = (0, classnames_1.default)("uifw-footer-label-left", "uifw-footer-indicator", inFooter && "nz-footer-mode", hasClickAction && "uifw-footer-action", labelSide === appui_abstract_1.StatusBarLabelSide.Right && "uifw-footer-label-reversed", // eslint-disable-line deprecation/deprecation
    className);
    return (React.createElement(React.Fragment, null,
        React.createElement("div", { ref: target, role: "button", tabIndex: -1, className: classNames, title: title, style: style, onClick: handleOnIndicatorClick },
            isLabelVisible && label && React.createElement("span", { className: "nz-label" }, appui_abstract_1.ConditionalStringValue.getValue(label)),
            icon && React.createElement("div", { className: "uifw-indicator-icon" },
                React.createElement(core_react_1.Icon, { iconSpec: icon }))),
        dialog && React.createElement(appui_layout_react_1.FooterPopup, { contentType: contentType, target: target.current, onClose: () => setIsOpen(false), isOpen: isOpen }, dialog)));
}
exports.Indicator = Indicator;
//# sourceMappingURL=Indicator.js.map