"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__, {
    useButtonHandles: ()=>useButtonHandles
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const react_namespaceObject = require("@xyflow/react");
const external_react_namespaceObject = require("react");
const manifest_resolver_cjs_namespaceObject = require("../../utils/manifest-resolver.cjs");
const ConnectedHandlesContext_cjs_namespaceObject = require("../BaseCanvas/ConnectedHandlesContext.cjs");
const external_index_cjs_namespaceObject = require("./index.cjs");
const useButtonHandles = ({ handleConfigurations, shouldShowHandles, handleAction, handleMouseEnter, handleMouseLeave, nodeId, selected, hovered, showAddButton, showNotches, shouldShowAddButtonFn, nodeWidth, nodeHeight, portalActions })=>{
    const connectedHandleIds = (0, ConnectedHandlesContext_cjs_namespaceObject.useConnectedHandles)(nodeId);
    const node = (0, react_namespaceObject.useNodesData)(nodeId);
    const handleElements = (0, external_react_namespaceObject.useMemo)(()=>{
        if (!handleConfigurations || !Array.isArray(handleConfigurations) || 0 === handleConfigurations.length) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {});
        const resolvedHandles = (0, manifest_resolver_cjs_namespaceObject.resolveHandles)(handleConfigurations, node?.data ?? {});
        const elements = resolvedHandles.map((config, i)=>{
            const groupVisible = shouldShowHandles && (config.visible ?? true);
            const enhancedHandles = config.handles.map((handle)=>({
                    ...handle,
                    showHandle: connectedHandleIds.has(handle.id) || groupVisible,
                    onAction: handle.onAction || handleAction,
                    onMouseEnter: handle.onMouseEnter || handleMouseEnter,
                    onMouseLeave: handle.onMouseLeave || handleMouseLeave
                }));
            return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ButtonHandles, {
                nodeId: nodeId,
                handles: enhancedHandles,
                position: config.position,
                selected: selected,
                hovered: hovered,
                showAddButton: showAddButton,
                showNotches: showNotches,
                customPositionAndOffsets: config.customPositionAndOffsets,
                shouldShowAddButtonFn: shouldShowAddButtonFn,
                nodeWidth: nodeWidth,
                nodeHeight: nodeHeight,
                portalActions: portalActions
            }, `${i}:${config.position}:${config.handles.map((h)=>h.id).join(',')}`);
        });
        return elements;
    }, [
        handleConfigurations,
        selected,
        hovered,
        shouldShowHandles,
        connectedHandleIds,
        handleAction,
        handleMouseEnter,
        handleMouseLeave,
        nodeId,
        showAddButton,
        showNotches,
        shouldShowAddButtonFn,
        nodeWidth,
        nodeHeight,
        portalActions,
        node?.data
    ]);
    return handleElements;
};
exports.useButtonHandles = __webpack_exports__.useButtonHandles;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "useButtonHandles"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
