"use client";
import { useCallback, useState } from "react";
/**
 * @since 6.0.0 Renamed from `useTreeItemExpansion` and uses a Set
 * instead of a list to increase performance.
 */ export function useTreeExpansion(defaultExpandedIds) {
    const [expandedIds, setExpandedIds] = useState(()=>{
        const defaultIds = typeof defaultExpandedIds === "function" ? defaultExpandedIds() : defaultExpandedIds;
        return new Set(defaultIds);
    });
    const toggleTreeItemExpansion = useCallback((itemId)=>{
        setExpandedIds((prevExpandedIds)=>{
            const expandedIds = new Set(prevExpandedIds);
            if (expandedIds.has(itemId)) {
                expandedIds.delete(itemId);
            } else {
                expandedIds.add(itemId);
            }
            return expandedIds;
        });
    }, []);
    return {
        expandedIds,
        toggleTreeItemExpansion,
        expandMultipleTreeItems: setExpandedIds
    };
}

//# sourceMappingURL=useTreeExpansion.js.map