import { useCallback } from 'react';
import { playSound, type SoundName } from './sounds';
import type { PlayOptions } from './engine';

/**
 * Returns a stable `play(name, opts?)` function. The engine respects the
 * global enabled/volume state from the sound effects store, so callers don't
 * need to subscribe themselves.
 */
export function useSoundEffect() {
  const play = useCallback((name: SoundName, opts?: PlayOptions) => {
    playSound(name, opts);
  }, []);
  return { play };
}
