"use client"; import { useCallback, useState } from "react"; import { soundManager } from "@/lib/sound/manager"; /** * React hook exposing the procedural sound manager. * Handles hydration mismatch by defaulting to muted until the client * reads the persisted preference from localStorage. * * @returns play - function to trigger a named sound effect * @returns muted - current mute state * @returns toggleMute - toggle mute on/off */ export function useSound() { const [muted, setMuted] = useState(() => soundManager.isMuted()); const play = useCallback((name: Parameters[0]) => { soundManager.play(name); }, []); const toggleMute = useCallback(() => { const newMuted = soundManager.toggleMute(); setMuted(newMuted); return newMuted; }, []); return { play, muted, toggleMute }; }