import { jsx, jsxs } from "react/jsx-runtime";
import { forwardRef, memo, useCallback } from "react";
import { BrushCleaning, Scan, ZoomIn, ZoomOut } from "lucide-react";
import { useReactFlow } from "../../xyflow/react.js";
import { ToolbarButton } from "../ToolbarButton.js";
import { useSafeLingui } from "../../../i18n/index.js";
const ZOOM_ICON_BUTTON_CLASS = 'text-foreground-muted hover:bg-surface-hover hover:text-foreground [&_svg]:size-[18px] [&_svg]:transition-all hover:[&_svg]:size-[22px] disabled:hover:[&_svg]:size-[18px]';
const CanvasZoomControls_CanvasZoomControls = /*#__PURE__*/ memo(/*#__PURE__*/ forwardRef(function({ orientation = 'vertical', fitViewOptions, zoomInOptions, zoomOutOptions, onOrganize, onFitView }, ref) {
    const { zoomIn, zoomOut, fitView } = useReactFlow();
    const { _ } = useSafeLingui();
    const isVertical = 'vertical' === orientation;
    const tooltipSide = isVertical ? 'left' : 'top';
    const handleZoomIn = useCallback(()=>{
        zoomIn(zoomInOptions);
    }, [
        zoomIn,
        zoomInOptions
    ]);
    const handleZoomOut = useCallback(()=>{
        zoomOut(zoomOutOptions);
    }, [
        zoomOut,
        zoomOutOptions
    ]);
    const handleFitView = useCallback(()=>{
        if (onFitView) onFitView();
        else fitView(fitViewOptions);
    }, [
        onFitView,
        fitView,
        fitViewOptions
    ]);
    return /*#__PURE__*/ jsxs("div", {
        ref: ref,
        "data-testid": "canvas-controls",
        className: `flex gap-1 items-center rounded-xl border border-border-subtle bg-surface-raised text-foreground p-1 backdrop-blur-sm shadow-lg ${isVertical ? 'flex-col' : 'flex-row'}`,
        children: [
            /*#__PURE__*/ jsx(ToolbarButton, {
                testId: "zoom-in-button",
                label: _({
                    id: 'canvas.zoom.zoom_in',
                    message: 'Zoom in'
                }),
                tooltipSide: tooltipSide,
                onClick: handleZoomIn,
                className: ZOOM_ICON_BUTTON_CLASS,
                children: /*#__PURE__*/ jsx(ZoomIn, {})
            }),
            /*#__PURE__*/ jsx(ToolbarButton, {
                testId: "zoom-out-button",
                label: _({
                    id: 'canvas.zoom.zoom_out',
                    message: 'Zoom out'
                }),
                tooltipSide: tooltipSide,
                onClick: handleZoomOut,
                className: ZOOM_ICON_BUTTON_CLASS,
                children: /*#__PURE__*/ jsx(ZoomOut, {})
            }),
            /*#__PURE__*/ jsx(ToolbarButton, {
                testId: "fit-to-view-button",
                label: _({
                    id: 'canvas.zoom.fit_to_screen',
                    message: 'Fit to screen'
                }),
                tooltipSide: tooltipSide,
                onClick: handleFitView,
                className: ZOOM_ICON_BUTTON_CLASS,
                children: /*#__PURE__*/ jsx(Scan, {})
            }),
            onOrganize && /*#__PURE__*/ jsx(ToolbarButton, {
                testId: "organize-button",
                label: _({
                    id: 'canvas.zoom.tidy_up',
                    message: 'Tidy up'
                }),
                tooltipSide: tooltipSide,
                onClick: onOrganize,
                className: ZOOM_ICON_BUTTON_CLASS,
                children: /*#__PURE__*/ jsx(BrushCleaning, {})
            })
        ]
    });
}));
CanvasZoomControls_CanvasZoomControls.displayName = 'CanvasZoomControls';
export { CanvasZoomControls_CanvasZoomControls as CanvasZoomControls };
