"use client"; import React, { createContext, useContext, useCallback } from 'react'; const SoundContext = createContext(undefined); export function SoundProvider({ children }) { const [enabled, setEnabled] = React.useState(true); const playSound = useCallback((sound) => { if (!enabled) return; const audio = new Audio(); audio.play().catch((err) => console.error('Failed to play sound:', err)); }, [enabled]); return ( {children} ); } export function useSound() { const context = React.useContext(SoundContext); if (!context) { throw new Error('useSound must be used within SoundProvider'); } return context; }