"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 ToolSettings
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.DockedToolSettingsHandle = void 0;
require("./Handle.scss");
const classnames_1 = require("classnames");
const React = require("react");
const core_react_1 = require("@itwin/core-react");
const DragManager_1 = require("../base/DragManager");
const NineZone_1 = require("../base/NineZone");
const TabBar_1 = require("../widget/TabBar");
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
const itwinui_react_1 = require("@itwin/itwinui-react");
/** Component that displays tool settings as a bar across the top of the content view.
 * @internal
 */
function DockedToolSettingsHandle(props) {
    const dispatch = React.useContext(NineZone_1.NineZoneDispatchContext);
    const resizeObserverRef = (0, core_react_1.useResizeObserver)(props.onResize);
    const newFloatingWidgetId = React.useMemo(() => (0, NineZone_1.getUniqueId)(), []);
    const onDragStart = (0, DragManager_1.useDragToolSettings)({ newFloatingWidgetId });
    const handleDragStart = React.useCallback((initialPointerPosition) => {
        onDragStart({
            initialPointerPosition,
            pointerPosition: initialPointerPosition,
        });
        dispatch({
            type: "TOOL_SETTINGS_DRAG_START",
            newFloatingWidgetId,
        });
    }, [dispatch, newFloatingWidgetId, onDragStart]);
    const dragRef = (0, TabBar_1.useDrag)(handleDragStart);
    const refs = (0, core_react_1.useRefs)(dragRef, resizeObserverRef);
    const title = (0, NineZone_1.useLabel)("toolSettingsHandleTitle");
    const className = (0, classnames_1.default)("nz-toolSettings-handle", props.className);
    return (React.createElement("div", { className: className, ref: refs, style: props.style, title: title },
        React.createElement(itwinui_react_1.Icon, { size: "large" },
            React.createElement(itwinui_icons_react_1.SvgDragHandleVertical, null))));
}
exports.DockedToolSettingsHandle = DockedToolSettingsHandle;
//# sourceMappingURL=Handle.js.map