import { jsx as _jsx } from "react/jsx-runtime";
/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { createContext, useContext, useReducer, useMemo, } from 'react';
import { sessionReducer, } from '../reducers/sessionReducer.js';
// Create the context
const SessionStateContext = createContext(undefined);
// Provider component
export const SessionStateProvider = ({ children, initialState, }) => {
    const [state, dispatch] = useReducer(sessionReducer, initialState);
    // Memoize the context value to prevent unnecessary re-renders
    const contextValue = useMemo(() => [state, dispatch], [state, dispatch]);
    return (_jsx(SessionStateContext.Provider, { value: contextValue, children: children }));
};
// Hook to use the session state context
export const useSessionState = () => {
    const context = useContext(SessionStateContext);
    if (!context) {
        throw new Error('useSessionState must be used within SessionStateProvider');
    }
    return context;
};
//# sourceMappingURL=SessionStateContext.js.map