/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module IModelComponents
 */
/* eslint-disable deprecation/deprecation */
import * as React from "react";
import { useControlledPresentationTreeFiltering } from "@itwin/presentation-components";
import { TreeImageLoader, TreeNodeRenderer, TreeRenderer, } from "@itwin/components-react";
import { ImageCheckBox } from "@itwin/core-react";
/**
 * Creates Visibility tree renderer which renders nodes with eye checkbox.
 * @alpha
 * @deprecated in 3.6. Was moved to `@itwin/tree-widget-react` package.
 */
export const useVisibilityTreeRenderer = (iconsEnabled, descriptionsEnabled) => {
    // eslint-disable-next-line react-hooks/exhaustive-deps
    const nodeRenderer = React.useCallback(createVisibilityTreeNodeRenderer(iconsEnabled, descriptionsEnabled), [iconsEnabled, descriptionsEnabled]);
    return React.useCallback((props) => (React.createElement(TreeRenderer, { ...props, nodeRenderer: nodeRenderer })), [nodeRenderer]);
};
const imageLoader = new TreeImageLoader();
/**
 * Creates node renderer which renders node with eye checkbox.
 * @alpha
 * @deprecated in 3.6. Was moved to `@itwin/tree-widget-react` package.
 */
export const createVisibilityTreeNodeRenderer = (iconsEnabled, descriptionEnabled) => {
    return (props) => ( // eslint-disable-line react/display-name
    React.createElement(TreeNodeRenderer, { ...props, checkboxRenderer: visibilityTreeNodeCheckboxRenderer, descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: "with-checkbox" }));
};
/**
 * Checkbox renderer that renders an eye.
 * @alpha
 * @deprecated in 3.6. Was moved to `@itwin/tree-widget-react` package.
 */
export const visibilityTreeNodeCheckboxRenderer = (props) => (React.createElement(ImageCheckBox, { checked: props.checked, disabled: props.disabled, imageOn: "icon-visibility", imageOff: "icon-visibility-hide-2", onClick: props.onChange, tooltip: props.title }));
/**
 * Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.
 * @alpha
 * @deprecated in 3.6. Was moved to `@itwin/tree-widget-react` package.
 */
export const useVisibilityTreeFiltering = (nodeLoader, filterInfo, onFilterApplied) => {
    const { filter, activeMatchIndex } = filterInfo !== null && filterInfo !== void 0 ? filterInfo : { filter: undefined, activeMatchIndex: undefined };
    const { filteredNodeLoader, isFiltering, matchesCount, nodeHighlightingProps, } = useControlledPresentationTreeFiltering({ nodeLoader, filter, activeMatchIndex });
    React.useEffect(() => {
        if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader)
            onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);
    }, [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied]);
    return { filteredNodeLoader, isFiltering, nodeHighlightingProps };
};
/**
 * Renders message that no nodes was found for filter.
 * @alpha
 * @deprecated in 3.6. Was moved to `@itwin/tree-widget-react` package.
 */
export function VisibilityTreeNoFilteredData(props) {
    return (React.createElement("div", { className: "components-tree-errormessage" },
        React.createElement("span", { className: "errormessage-header" }, props.title),
        React.createElement("span", { className: "errormessage-body" }, props.message)));
}
//# sourceMappingURL=VisibilityTreeRenderer.js.map