"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    SegmentDragHandle: ()=>SegmentDragHandle_SegmentDragHandle
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const external_constants_cjs_namespaceObject = require("../constants.cjs");
const external_geometry_cjs_namespaceObject = require("../geometry.cjs");
const { INTERACTION_STROKE_WIDTH } = external_constants_cjs_namespaceObject.EDGE_CONSTANTS;
const SEGMENT_CURSOR = {
    horizontal: 'ns-resize',
    vertical: 'ew-resize'
};
const HANDLE_RECT = {
    horizontal: {
        x: -12,
        y: -5,
        width: 24,
        height: 10
    },
    vertical: {
        x: -5,
        y: -12,
        width: 10,
        height: 24
    }
};
const SegmentDragHandle_SegmentDragHandle = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(function({ segment, segmentIndex, handlers }) {
    const [isHovered, setIsHovered] = (0, external_react_namespaceObject.useState)(false);
    const midpoint = (0, external_geometry_cjs_namespaceObject.getSegmentMidpoint)(segment);
    const cursor = SEGMENT_CURSOR[segment.orientation];
    const rect = HANDLE_RECT[segment.orientation];
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("line", {
                className: "nopan",
                x1: segment.start.x,
                y1: segment.start.y,
                x2: segment.end.x,
                y2: segment.end.y,
                stroke: "transparent",
                strokeWidth: INTERACTION_STROKE_WIDTH,
                style: {
                    cursor,
                    pointerEvents: 'stroke'
                },
                onMouseEnter: ()=>setIsHovered(true),
                onMouseLeave: ()=>setIsHovered(false),
                onMouseDown: (e)=>handlers.onMouseDown(segment, e),
                onDoubleClick: (e)=>handlers.onDoubleClick(segmentIndex, e)
            }),
            isHovered && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
                children: [
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("line", {
                        x1: segment.start.x,
                        y1: segment.start.y,
                        x2: segment.end.x,
                        y2: segment.end.y,
                        stroke: external_constants_cjs_namespaceObject.EDGE_COLORS.selected,
                        strokeWidth: 4,
                        opacity: 0.4,
                        style: {
                            pointerEvents: 'none'
                        }
                    }),
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("g", {
                        transform: `translate(${midpoint.x}, ${midpoint.y})`,
                        style: {
                            pointerEvents: 'none'
                        },
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("rect", {
                            x: rect.x,
                            y: rect.y,
                            width: rect.width,
                            height: rect.height,
                            rx: 5,
                            fill: external_constants_cjs_namespaceObject.EDGE_COLORS.selected,
                            stroke: "white",
                            strokeWidth: 2
                        })
                    })
                ]
            })
        ]
    });
});
exports.SegmentDragHandle = __webpack_exports__.SegmentDragHandle;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "SegmentDragHandle"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
