'use client';
import { createContext, useContext, useMemo, useState } from 'react';
const AccordionContext = createContext(undefined);
export function AccordionContextProvider({ children, }) {
    const [activated, setActivated] = useState([]);
    const stableActivated = useMemo(() => [...activated], [activated]);
    const toggleId = (id) => {
        if (activated.includes(id)) {
            setActivated(activated.filter((item) => item !== id));
        }
        else {
            setActivated([...activated, id]);
        }
    };
    const value = useMemo(() => ({
        activated: stableActivated,
        toggleId,
    }), [stableActivated]);
    return (<AccordionContext.Provider value={value}>
      {children}
    </AccordionContext.Provider>);
}
export function useAccordionContext() {
    const context = useContext(AccordionContext);
    if (!context) {
        throw new Error('useAccordionContext must be used within a AccordionContextProvider');
    }
    return context;
}
//# sourceMappingURL=AccordionContext.jsx.map