"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.ClearEmphasisStatusField = void 0;
// cSpell:ignore statusfields
const React = require("react");
const useActiveViewport_1 = require("../hooks/useActiveViewport");
const Indicator_1 = require("../statusfields/Indicator");
const UiFramework_1 = require("../UiFramework");
const HideIsolateEmphasizeManager_1 = require("./HideIsolateEmphasizeManager");
/** Clear Emphasis StatusField
 * @beta
 * @deprecated in 3.0. Use clear emphasis tool button option instead.
 */
function ClearEmphasisStatusField(props) {
    var _a;
    const [toolTip] = React.useState(UiFramework_1.UiFramework.translate("tools.clearVisibility"));
    const activeViewport = (0, useActiveViewport_1.useActiveViewport)();
    const [showIndicator, setShowIndicator] = React.useState(false);
    React.useEffect(() => {
        // istanbul ignore next
        const onEmphasizeChange = () => {
            // istanbul ignore next
            const hasEmphasizeElements = !!activeViewport && UiFramework_1.UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(activeViewport);
            setShowIndicator(hasEmphasizeElements || !props.hideWhenUnused);
        };
        // istanbul ignore next
        setShowIndicator((!!activeViewport && UiFramework_1.UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(activeViewport)) || !props.hideWhenUnused);
        HideIsolateEmphasizeManager_1.HideIsolateEmphasizeActionHandler.emphasizeElementsChanged.addListener(onEmphasizeChange);
        // istanbul ignore if
        if (activeViewport)
            activeViewport.onFeatureOverridesChanged.addListener(onEmphasizeChange);
        return () => {
            // istanbul ignore if
            if (activeViewport)
                activeViewport.onFeatureOverridesChanged.removeListener(onEmphasizeChange);
            HideIsolateEmphasizeManager_1.HideIsolateEmphasizeActionHandler.emphasizeElementsChanged.removeListener(onEmphasizeChange);
        };
    }, [activeViewport, props.hideWhenUnused]);
    const classes = (showIndicator) ? "uifw-indicator-fade-in" : "uifw-indicator-fade-out";
    // istanbul ignore next
    const clearEmphasize = async () => {
        await UiFramework_1.UiFramework.hideIsolateEmphasizeActionHandler.processClearEmphasize();
    };
    return (React.createElement(Indicator_1.Indicator, { toolTip: toolTip, className: classes, opened: false, onClick: clearEmphasize, iconName: "icon-visibility" // eslint-disable-line deprecation/deprecation
        , 
        // eslint-disable-next-line deprecation/deprecation
        isInFooterMode: (_a = props.isInFooterMode) !== null && _a !== void 0 ? _a : true }));
}
exports.ClearEmphasisStatusField = ClearEmphasisStatusField;
//# sourceMappingURL=ClearEmphasisStatusField.js.map