'use client';
import React from 'react';
const AddClientFunctionContext = /*#__PURE__*/ React.createContext(()=>null);
const ClientFunctionsContext = /*#__PURE__*/ React.createContext({});
export const ClientFunctionProvider = ({ children })=>{
    const [clientFunctions, setClientFunctions] = React.useState({});
    const addClientFunction = React.useCallback((args)=>{
        setClientFunctions((state)=>{
            const newState = {
                ...state
            };
            newState[args.key] = args.func;
            return newState;
        });
    }, []);
    return /*#__PURE__*/ React.createElement(AddClientFunctionContext.Provider, {
        value: addClientFunction
    }, /*#__PURE__*/ React.createElement(ClientFunctionsContext.Provider, {
        value: clientFunctions
    }, children));
};
export const useAddClientFunction = (key, func)=>{
    const addClientFunction = React.useContext(AddClientFunctionContext);
    React.useEffect(()=>{
        addClientFunction({
            func,
            key
        });
    }, [
        func,
        key,
        addClientFunction
    ]);
};
export const useClientFunctions = ()=>{
    return React.useContext(ClientFunctionsContext);
};

//# sourceMappingURL=index.js.map