"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__, {
    getHandleActionPortal: ()=>getHandleActionPortal,
    getInwardHandleLayout: ()=>getInwardHandleLayout
});
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
const external_constants_cjs_namespaceObject = require("../../constants.cjs");
const external_ButtonHandleStyleUtils_cjs_namespaceObject = require("./ButtonHandleStyleUtils.cjs");
const INWARD_HANDLE_ANCHOR_SIZE_PX = external_constants_cjs_namespaceObject.GRID_SPACING;
const INWARD_HANDLE_ANCHOR_RADIUS_PX = INWARD_HANDLE_ANCHOR_SIZE_PX / 2;
const INWARD_NOTCH_OVERLAP_PX = {
    artifact: 5,
    input: 4,
    output: 6
};
function getHandleActionPortal({ nodeId, position, positionPercent, total, nodeWidth, nodeHeight }) {
    if (!nodeWidth || !nodeHeight) return;
    const edgeCoverageRatio = external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_EDGE_COVERAGE_RATIO / total;
    const horizontalWidth = nodeWidth * edgeCoverageRatio;
    const verticalHeight = nodeHeight * edgeCoverageRatio;
    const x = positionPercent / 100 * nodeWidth;
    const y = positionPercent / 100 * nodeHeight;
    switch(position){
        case react_cjs_namespaceObject.Position.Top:
            return {
                nodeId,
                left: x,
                top: 0,
                width: horizontalWidth,
                height: external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
                transform: 'translate(-50%, -50%)'
            };
        case react_cjs_namespaceObject.Position.Bottom:
            return {
                nodeId,
                left: x,
                top: nodeHeight - external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
                width: horizontalWidth,
                height: external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
                transform: 'translate(-50%, 50%)'
            };
        case react_cjs_namespaceObject.Position.Left:
            return {
                nodeId,
                left: 0,
                top: y,
                width: external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
                height: verticalHeight,
                transform: 'translate(-50%, -50%)'
            };
        case react_cjs_namespaceObject.Position.Right:
            return {
                nodeId,
                left: nodeWidth - external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
                top: y,
                width: external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
                height: verticalHeight,
                transform: 'translate(50%, -50%)'
            };
    }
}
function getInwardHandleLayout(position, handleType) {
    const notchOverlap = -INWARD_NOTCH_OVERLAP_PX[handleType];
    const anchorSize = {
        width: INWARD_HANDLE_ANCHOR_SIZE_PX,
        height: INWARD_HANDLE_ANCHOR_SIZE_PX
    };
    switch(position){
        case react_cjs_namespaceObject.Position.Left:
            return {
                rootTransform: 'translate(0, -50%)',
                contentDirectionClassName: 'flex-row',
                notchStyle: {
                    marginLeft: notchOverlap
                },
                anchorStyle: {
                    ...anchorSize,
                    left: `calc(100% - ${INWARD_HANDLE_ANCHOR_RADIUS_PX}px)`,
                    top: '50%',
                    transform: 'translateY(-50%)'
                }
            };
        case react_cjs_namespaceObject.Position.Right:
            return {
                rootTransform: 'translate(0, -50%)',
                contentDirectionClassName: 'flex-row-reverse',
                notchStyle: {
                    marginRight: notchOverlap
                },
                anchorStyle: {
                    ...anchorSize,
                    left: -INWARD_HANDLE_ANCHOR_RADIUS_PX,
                    top: '50%',
                    transform: 'translateY(-50%)'
                }
            };
        case react_cjs_namespaceObject.Position.Top:
            return {
                rootTransform: 'translate(-50%, 0)',
                contentDirectionClassName: 'flex-col',
                notchStyle: {
                    marginTop: notchOverlap
                },
                anchorStyle: {
                    ...anchorSize,
                    left: '50%',
                    top: `calc(100% - ${INWARD_HANDLE_ANCHOR_RADIUS_PX}px)`,
                    transform: 'translateX(-50%)'
                }
            };
        case react_cjs_namespaceObject.Position.Bottom:
            return {
                rootTransform: 'translate(-50%, 0)',
                contentDirectionClassName: 'flex-col-reverse',
                notchStyle: {
                    marginBottom: notchOverlap
                },
                anchorStyle: {
                    ...anchorSize,
                    left: '50%',
                    top: -INWARD_HANDLE_ANCHOR_RADIUS_PX,
                    transform: 'translateX(-50%)'
                }
            };
    }
}
exports.getHandleActionPortal = __webpack_exports__.getHandleActionPortal;
exports.getInwardHandleLayout = __webpack_exports__.getInwardHandleLayout;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "getHandleActionPortal",
    "getInwardHandleLayout"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
