/*---------------------------------------------------------------------------------------------
* 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
 */
// cSpell:ignore statusfields
import * as React from "react";
import { useActiveViewport } from "../hooks/useActiveViewport";
import { Indicator } from "../statusfields/Indicator";
import { UiFramework } from "../UiFramework";
import { HideIsolateEmphasizeActionHandler } from "./HideIsolateEmphasizeManager";
/** Clear Emphasis StatusField
 * @beta
 * @deprecated in 3.0. Use clear emphasis tool button option instead.
 */
export function ClearEmphasisStatusField(props) {
    var _a;
    const [toolTip] = React.useState(UiFramework.translate("tools.clearVisibility"));
    const activeViewport = useActiveViewport();
    const [showIndicator, setShowIndicator] = React.useState(false);
    React.useEffect(() => {
        // istanbul ignore next
        const onEmphasizeChange = () => {
            // istanbul ignore next
            const hasEmphasizeElements = !!activeViewport && UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(activeViewport);
            setShowIndicator(hasEmphasizeElements || !props.hideWhenUnused);
        };
        // istanbul ignore next
        setShowIndicator((!!activeViewport && UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(activeViewport)) || !props.hideWhenUnused);
        HideIsolateEmphasizeActionHandler.emphasizeElementsChanged.addListener(onEmphasizeChange);
        // istanbul ignore if
        if (activeViewport)
            activeViewport.onFeatureOverridesChanged.addListener(onEmphasizeChange);
        return () => {
            // istanbul ignore if
            if (activeViewport)
                activeViewport.onFeatureOverridesChanged.removeListener(onEmphasizeChange);
            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.hideIsolateEmphasizeActionHandler.processClearEmphasize();
    };
    return (React.createElement(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 }));
}
//# sourceMappingURL=ClearEmphasisStatusField.js.map