window.AudioContext = window.AudioContext || window.webkitAudioContext;

function SoundLoader() {
	this.sounds = {};
	this.totalSounds = 0;
	this.loadedSounds = 0;
	this.muted = false;

	this.context = new AudioContext();
}
SoundLoader.prototype.load = function(name, path) {
	var that = this;

	if (this.totalSounds === 0) {
		// safari on iOS mutes sounds until they're played in response to user input
		// play a dummy sound on first touch
		var firstTouchHandler = function(event) {
			window.removeEventListener("click", firstTouchHandler);
			window.removeEventListener("keydown", firstTouchHandler);
			window.removeEventListener("touchstart", firstTouchHandler);

			var source = that.context.createOscillator();
			source.connect(that.context.destination);
			source.start(0);
			source.stop(0);

			if (that.firstPlay) {
				that.play(that.firstPlay);
			} else {
				that.firstPlay = "workaround";
			}

		};
		window.addEventListener("click", firstTouchHandler);
		window.addEventListener("keydown", firstTouchHandler);
		window.addEventListener("touchstart", firstTouchHandler);
	}

	this.totalSounds++;

	var request = new XMLHttpRequest();
	request.open("GET", path, true);
	request.responseType = "arraybuffer";
	request.addEventListener("readystatechange", function() {
		if (request.readyState != 4) {
			return;
		}
		if (request.status !== 200 && request.status !== 0) {
			console.error("Error loading sound " + path);
			return;
		}
		that.context.decodeAudioData(request.response, function(buffer) {
			that.sounds[name] = buffer;
			that.loadedSounds++;
		});
	});
	request.addEventListener("error", function() {
		console.error("Error loading sound " + path);
	});
	request.send();
};
SoundLoader.prototype.allLoaded = function() {
	return this.totalSounds == this.loadedSounds;
};
SoundLoader.prototype.play = function(name) {
	if (!this.firstPlay) {
		// let the iOS user input workaround handle it
		this.firstPlay = name;
		return;
	}
	if (this.muted) {
		return;
	}
	var snd = this.sounds[name];
	if (snd === undefined) {
		console.error("Unknown sound: " + name);
	}
	var source = this.context.createBufferSource();
	source.buffer = snd;
	source.connect(this.context.destination);
	source.start(0);
};

if (window.AudioContext) {
	module.exports = SoundLoader;
} else {
	console.log("This browser doesn't support the Web Audio API");
	module.exports = function() { };
	module.exports = function() { };
	module.exports = function() { return true; };
	module.exports = function() { };
}

@@ -2232,16 +2232,25 @@
 %7D;%0A%0Aif (
+false && 
 window.A
@@ -2264,16 +2264,16 @@
 text) %7B%0A
-
 %09module.
@@ -2369,30 +2369,35 @@
 API%22);%0A%09
-module.exports
+var fakeSoundLoader
  = funct
@@ -2403,35 +2403,50 @@
 tion() %7B
- 
 %7D;%0A%09
-module.exports
+fakeSoundLoader.prototype.load
  = funct
@@ -2456,91 +2456,161 @@
 () %7B
- 
 %7D;%0A%09
-module.exports = function() %7B return true; %7D;%0A%09module.exports = function() %7B %7D
+fakeSoundLoader.prototype.allLoaded = function() %7B return true; %7D;%0A%09fakeSoundLoader.prototype.play = function() %7B%7D;%0A%09module.exports = fakeSoundLoader
 ;%0A%7D%0A

Fix fake SoundLoader for browserify.