"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useContext, useMemo } from "react";
// Allow the hook to correct typecast this instead
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const context = /*#__PURE__*/ createContext(undefined);
context.displayName = "Tree";
const { Provider } = context;
/**
 * This can be used for a custom tree item renderer.
 *
 * @see The `Tree` component for an example.
 * @remarks \@since 6.0.0
 */ export function useTreeContext() {
    const value = useContext(context);
    if (!value) {
        throw new Error("Cannot find a parent Tree component");
    }
    return value;
}
/**
 * **Client Component**
 *
 * @internal
 * @remarks \@since 6.0.0
 */ export function TreeProvider(props) {
    const { children, data, rootId, multiSelect, expanderIcon, expanderLeft, expansionMode, metadataLookup, disableTransition, temporaryChildItems, linkComponent, expandedIds, selectedIds, expandMultipleTreeItems, toggleTreeItemExpansion, selectMultipleTreeItems, toggleTreeItemSelection } = props;
    const value = useMemo(()=>({
            data,
            rootId,
            multiSelect,
            expanderIcon,
            expanderLeft,
            expansionMode,
            metadataLookup,
            disableTransition,
            temporaryChildItems,
            linkComponent,
            expandedIds,
            selectedIds,
            expandMultipleTreeItems,
            toggleTreeItemExpansion,
            selectMultipleTreeItems,
            toggleTreeItemSelection
        }), [
        data,
        disableTransition,
        expandMultipleTreeItems,
        expandedIds,
        expanderIcon,
        expanderLeft,
        expansionMode,
        linkComponent,
        metadataLookup,
        multiSelect,
        rootId,
        selectMultipleTreeItems,
        selectedIds,
        temporaryChildItems,
        toggleTreeItemExpansion,
        toggleTreeItemSelection
    ]);
    return /*#__PURE__*/ _jsx(Provider, {
        value: value,
        children: children
    });
}

//# sourceMappingURL=TreeProvider.js.map