/**
 * joinSound shim — voice channel join-sound manager + preferences.
 */

export function playJoinSound(_url?: string | null): void {}
export function playLeaveSound(): void {}
export function stopAllSounds(): void {}

export function getJoinSoundEnabled(): boolean {
	if (typeof localStorage === 'undefined') return true;
	const v = localStorage.getItem('joinSoundEnabled');
	return v === null ? true : v === 'true';
}

export function setJoinSoundEnabled(enabled: boolean): void {
	if (typeof localStorage !== 'undefined') {
		localStorage.setItem('joinSoundEnabled', enabled ? 'true' : 'false');
	}
}

export function getJoinSoundVolume(): number {
	if (typeof localStorage === 'undefined') return 100;
	const v = parseInt(localStorage.getItem('joinSoundVolume') || '100', 10);
	return Number.isFinite(v) ? v : 100;
}

export function setJoinSoundVolume(volume: number): void {
	if (typeof localStorage !== 'undefined') {
		localStorage.setItem('joinSoundVolume', String(volume));
	}
}

export default {
	playJoinSound,
	playLeaveSound,
	stopAllSounds,
	getJoinSoundEnabled,
	setJoinSoundEnabled,
	getJoinSoundVolume,
	setJoinSoundVolume,
};
