import { jsx as _jsx } from "@emotion/react/jsx-runtime";
import React, { useEffect, useContext, } from 'react';
import { ROOT_SCOPE } from '../../../consts/scopes';
import { CommandContext } from './command-provider';
export const CommandScopeContext = React.createContext(ROOT_SCOPE);
export const CommandScopeProvider = ({ name = ROOT_SCOPE, children, }) => {
    const { store, setActiveScope } = useContext(CommandContext);
    useEffect(() => {
        setActiveScope(name);
        return () => {
            setActiveScope(ROOT_SCOPE);
        };
    }, [name]);
    useEffect(() => () => {
        store.clean({ scope: name });
    }, []);
    return (_jsx(CommandScopeContext.Provider, { value: name, children: children }));
};
