/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Widget
 */
import * as React from "react";
import { ToolbarComposer } from "../toolbar/ToolbarComposer.js";
import { NavigationWidgetComposer } from "./NavigationWidgetComposer.js";
import { ToolbarOrientation, ToolbarUsage } from "../toolbar/ToolbarItem.js";
import { ToolbarItems } from "../tools/ToolbarItems.js";
/** Basic Navigation Widget that provides standard tools to manipulate views containing element data.
 * Supports the specification of additional horizontal and vertical toolbar items through props.
 * @public
 */
// eslint-disable-next-line @typescript-eslint/no-deprecated
export function BasicNavigationWidget(props) {
    const getHorizontalToolbarItems = React.useCallback(() => {
        const items = [
            ToolbarItems.createRotateView({
                itemPriority: 10,
            }),
            ToolbarItems.createPanView({
                itemPriority: 20,
            }),
            ToolbarItems.createFitView({
                itemPriority: 30,
            }),
            ToolbarItems.createWindowArea({
                itemPriority: 40,
            }),
            ToolbarItems.createViewUndo({
                itemPriority: 50,
            }),
            ToolbarItems.createViewRedo({
                itemPriority: 60,
            }),
        ];
        if (props.additionalHorizontalItems)
            items.push(...props.additionalHorizontalItems);
        return items;
    }, [props.additionalHorizontalItems]);
    const getVerticalToolbarItems = React.useCallback(() => {
        const items = [];
        items.push(ToolbarItems.createWalkView({
            itemPriority: 10,
        }), ToolbarItems.createToggleCameraView({
            itemPriority: 20,
        }));
        if (props.additionalVerticalItems)
            items.push(...props.additionalVerticalItems);
        return items;
    }, [props.additionalVerticalItems]);
    const [horizontalItems, setHorizontalItems] = React.useState(() => getHorizontalToolbarItems());
    const [verticalItems, setVerticalItems] = React.useState(() => getVerticalToolbarItems());
    const isInitialMount = React.useRef(true);
    React.useEffect(() => {
        if (isInitialMount.current)
            isInitialMount.current = false;
        else {
            setHorizontalItems(getHorizontalToolbarItems());
            setVerticalItems(getVerticalToolbarItems());
        }
    }, [
        props.additionalHorizontalItems,
        props.additionalVerticalItems,
        getHorizontalToolbarItems,
        getVerticalToolbarItems,
    ]);
    return (React.createElement(NavigationWidgetComposer, { horizontalToolbar: React.createElement(ToolbarComposer, { items: horizontalItems, usage: ToolbarUsage.ViewNavigation, orientation: ToolbarOrientation.Horizontal }), verticalToolbar: React.createElement(ToolbarComposer, { items: verticalItems, usage: ToolbarUsage.ViewNavigation, orientation: ToolbarOrientation.Vertical }) }));
}
//# sourceMappingURL=BasicNavigationWidget.js.map