import { jsx } from "react/jsx-runtime";
import { createContext, useContext, useMemo } from "react";
import { useDataSourceKey } from "../data-source/DataSourceProvider.mjs";
import { CollectionManagerProvider } from "./CollectionManagerProvider.mjs";
const ExtendCollectionsContext = /*#__PURE__*/ createContext(null);
ExtendCollectionsContext.displayName = 'ExtendCollectionsContext';
const ExtendCollectionsProvider = (param)=>{
    let { children, collections } = param;
    const parentCollections = useExtendCollections();
    const extendCollections = useMemo(()=>parentCollections ? [
            ...parentCollections,
            ...collections
        ] : collections, [
        parentCollections,
        collections
    ]);
    const dataSource = useDataSourceKey();
    return /*#__PURE__*/ jsx(ExtendCollectionsContext.Provider, {
        value: extendCollections,
        children: /*#__PURE__*/ jsx(CollectionManagerProvider, {
            dataSource: dataSource,
            children: children
        })
    });
};
function useExtendCollections() {
    const context = useContext(ExtendCollectionsContext);
    return context;
}
export { ExtendCollectionsContext, ExtendCollectionsProvider, useExtendCollections };
