import { jsx, jsxs } from "react/jsx-runtime";
import { OrganizeIcon, ZoomToFitIcon } from "../icons/index.js";
import { Column, Row } from "../layouts/index.js";
import { useReactFlow } from "../xyflow/react.js";
import { Button } from "@uipath/apollo-wind";
import { memo, useCallback } from "react";
import { CanvasIcon } from "../utils/icon-registry.js";
import { BASE_CANVAS_DEFAULTS } from "./BaseCanvas/BaseCanvas.constants.js";
import { CanvasTooltip } from "./CanvasTooltip.js";
const CanvasPositionControls = /*#__PURE__*/ memo(({ orientation = 'horizontal', fitViewOptions, zoomInOptions, zoomOutOptions, translations, onOrganize })=>{
    const { zoomIn, zoomOut, fitView } = useReactFlow();
    const handleZoomIn = useCallback(()=>zoomIn(zoomInOptions), [
        zoomIn,
        zoomInOptions
    ]);
    const handleZoomOut = useCallback(()=>zoomOut(zoomOutOptions), [
        zoomOut,
        zoomOutOptions
    ]);
    const handleFitToView = useCallback(()=>fitView(fitViewOptions ?? BASE_CANVAS_DEFAULTS.fitViewOptions), [
        fitView,
        fitViewOptions
    ]);
    const handleOrganize = useCallback(()=>onOrganize?.(), [
        onOrganize
    ]);
    const showOrganize = !!onOrganize;
    let RootComponent = Column;
    let placement = 'left';
    if ('horizontal' === orientation) {
        RootComponent = Row;
        placement = 'top';
    }
    return /*#__PURE__*/ jsxs(RootComponent, {
        "data-testid": "canvas-controls",
        children: [
            showOrganize && /*#__PURE__*/ jsx(CanvasTooltip, {
                content: translations.organize,
                placement: placement,
                children: /*#__PURE__*/ jsx(Button, {
                    variant: "ghost",
                    size: "icon",
                    className: "h-8 w-8",
                    "aria-label": translations.organize,
                    onClick: handleOrganize,
                    children: /*#__PURE__*/ jsx(OrganizeIcon, {})
                })
            }),
            /*#__PURE__*/ jsx(CanvasTooltip, {
                content: translations.zoomIn,
                placement: placement,
                children: /*#__PURE__*/ jsx(Button, {
                    variant: "ghost",
                    size: "icon",
                    className: "h-8 w-8",
                    "aria-label": translations.zoomIn,
                    onClick: handleZoomIn,
                    children: /*#__PURE__*/ jsx(CanvasIcon, {
                        icon: "plus",
                        size: 16
                    })
                })
            }),
            /*#__PURE__*/ jsx(CanvasTooltip, {
                content: translations.zoomOut,
                placement: placement,
                children: /*#__PURE__*/ jsx(Button, {
                    variant: "ghost",
                    size: "icon",
                    className: "h-8 w-8",
                    "aria-label": translations.zoomOut,
                    onClick: handleZoomOut,
                    children: /*#__PURE__*/ jsx(CanvasIcon, {
                        icon: "minus",
                        size: 16
                    })
                })
            }),
            /*#__PURE__*/ jsx(CanvasTooltip, {
                content: translations.zoomToFit,
                placement: placement,
                children: /*#__PURE__*/ jsx(Button, {
                    variant: "ghost",
                    size: "icon",
                    className: "h-8 w-8",
                    "aria-label": translations.zoomToFit,
                    onClick: handleFitToView,
                    children: /*#__PURE__*/ jsx(ZoomToFitIcon, {})
                })
            })
        ]
    });
});
export { CanvasPositionControls };
