"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__, {
    StageNodeHandles: ()=>StageNodeHandles
});
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
const external_react_namespaceObject = require("react");
const ConnectedHandlesContext_cjs_namespaceObject = require("../BaseCanvas/ConnectedHandlesContext.cjs");
const useButtonHandles_cjs_namespaceObject = require("../ButtonHandle/useButtonHandles.cjs");
const StageNodeHandlesInner = ({ id, isReadOnly, selected, isHovered, isException })=>{
    const isConnecting = (0, react_cjs_namespaceObject.useStore)((state)=>!!state.connectionClickStartHandle);
    const connectedHandleIds = (0, ConnectedHandlesContext_cjs_namespaceObject.useConnectedHandles)(id);
    const hasConnections = connectedHandleIds.size > 0;
    const shouldShowHandles = (0, external_react_namespaceObject.useMemo)(()=>!isReadOnly && (selected || isHovered || isConnecting || hasConnections), [
        hasConnections,
        isConnecting,
        selected,
        isHovered,
        isReadOnly
    ]);
    const handleConfigurations = (0, external_react_namespaceObject.useMemo)(()=>isException ? [] : [
            {
                position: react_cjs_namespaceObject.Position.Left,
                handles: [
                    {
                        id: `${id}____target____left`,
                        type: 'target',
                        handleType: 'input'
                    }
                ],
                visible: selected || isHovered || isConnecting,
                customPositionAndOffsets: {
                    top: 0,
                    height: 64
                }
            },
            {
                position: react_cjs_namespaceObject.Position.Right,
                handles: [
                    {
                        id: `${id}____source____right`,
                        type: 'source',
                        handleType: 'output'
                    }
                ],
                visible: selected || isHovered || isConnecting,
                customPositionAndOffsets: {
                    top: 0,
                    height: 64
                }
            },
            {
                position: react_cjs_namespaceObject.Position.Bottom,
                handles: [
                    {
                        id: `${id}____target____bottom`,
                        type: 'target',
                        handleType: 'input'
                    }
                ],
                visible: selected || isHovered || isConnecting
            },
            {
                position: react_cjs_namespaceObject.Position.Bottom,
                handles: [
                    {
                        id: `${id}____source____bottom`,
                        type: 'source',
                        handleType: 'output'
                    }
                ],
                visible: selected || isHovered || isConnecting
            }
        ], [
        isException,
        id,
        selected,
        isHovered,
        isConnecting
    ]);
    const handleElements = (0, useButtonHandles_cjs_namespaceObject.useButtonHandles)({
        handleConfigurations,
        shouldShowHandles,
        nodeId: id,
        selected
    });
    return handleElements;
};
const StageNodeHandles = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(StageNodeHandlesInner);
exports.StageNodeHandles = __webpack_exports__.StageNodeHandles;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "StageNodeHandles"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
