import { jsx } from "react/jsx-runtime";
import { createContext, useContext, useMemo } from "react";
const SelectionStateContext = /*#__PURE__*/ createContext(null);
function SelectionStateProvider({ children, nodes }) {
    const multipleNodesSelected = useMemo(()=>{
        if (!nodes) return false;
        let count = 0;
        for (const node of nodes)if (node.selected) {
            count++;
            if (count > 1) return true;
        }
        return false;
    }, [
        nodes
    ]);
    const value = useMemo(()=>({
            multipleNodesSelected
        }), [
        multipleNodesSelected
    ]);
    return /*#__PURE__*/ jsx(SelectionStateContext.Provider, {
        value: value,
        children: children
    });
}
function useSelectionState() {
    const context = useContext(SelectionStateContext);
    return context ?? {
        multipleNodesSelected: false
    };
}
export { SelectionStateProvider, useSelectionState };
