import { jsx, jsxs } from "react/jsx-runtime";
import { useDragSession } from "./useDragSession.js";
const HANDLES = [
    {
        edges: {
            top: true,
            left: true
        },
        style: {
            top: -4,
            left: -4
        },
        cursor: 'nwse-resize'
    },
    {
        edges: {
            top: true,
            right: true
        },
        style: {
            top: -4,
            right: -4
        },
        cursor: 'nesw-resize'
    },
    {
        edges: {
            bottom: true,
            right: true
        },
        style: {
            bottom: -4,
            right: -4
        },
        cursor: 'nwse-resize'
    },
    {
        edges: {
            bottom: true,
            left: true
        },
        style: {
            bottom: -4,
            left: -4
        },
        cursor: 'nesw-resize'
    }
];
function ProbeResizeHandles({ active, onResizeStart, onResize, onResizeEnd }) {
    return /*#__PURE__*/ jsxs("div", {
        "aria-hidden": true,
        className: `pointer-events-none absolute inset-0 transition-opacity duration-100 ${active ? 'opacity-100' : 'opacity-0'}`,
        children: [
            /*#__PURE__*/ jsx("div", {
                className: "absolute inset-0 rounded-[20px] outline outline-2 outline-foreground-accent-muted"
            }),
            HANDLES.map((h, i)=>/*#__PURE__*/ jsx(ResizeHandle, {
                    edges: h.edges,
                    style: h.style,
                    cursor: h.cursor,
                    onResizeStart: onResizeStart,
                    onResize: onResize,
                    onResizeEnd: onResizeEnd
                }, i))
        ]
    });
}
function ResizeHandle({ edges, style, cursor, onResizeStart, onResize, onResizeEnd }) {
    const handleMouseDown = useDragSession({
        onStart: onResizeStart,
        onMove: (delta)=>onResize(delta, edges),
        onEnd: onResizeEnd
    });
    return /*#__PURE__*/ jsx("div", {
        onMouseDown: handleMouseDown,
        style: {
            ...style,
            cursor,
            position: 'absolute'
        },
        className: "pointer-events-auto h-2 w-2 rounded-full bg-brand"
    });
}
export { ProbeResizeHandles };
