define(["apphost","layoutManager","pluginManager","userSettings","connectionManager","events","dom"],function(appHost,layoutManager,pluginManager,userSettings,connectionManager,events,dom){"use strict";var soundEffectsPlayer,effects={};function reload(){var soundeffectPlugin;appHost.supports("soundeffects")&&(dom.removeEventListener(window,"keydown",onKeyDown,{passive:!0}),layoutManager.tv&&(dom.addEventListener(window,"keydown",onKeyDown,{passive:!0}),(soundeffectPlugin=function(){var soundeffectOption;try{soundeffectOption=userSettings.soundEffects()}catch(err){}soundeffectOption=soundeffectOption||"defaultsoundeffects";if("none"===soundeffectOption)return null;var soundeffectPlugin=pluginManager.ofType("soundeffects").filter(function(i){return i.id===soundeffectOption})[0];soundeffectPlugin=soundeffectPlugin||pluginManager.ofType("soundeffects").filter(function(i){return"defaultsoundeffects"===i.id})[0];return soundeffectPlugin}())?function(soundeffectPlugin){var effectDictionary=soundeffectPlugin.getEffects(),temp={};for(var i in effectDictionary)temp[i]=pluginManager.mapPath(soundeffectPlugin,effectDictionary[i]);effects=temp}(soundeffectPlugin):effects={}))}function onKeyDown(evt){switch(evt.keyCode){case 37:case 38:case 39:case 40:evt.altKey||play("navigation");break;case 13:play("select")}}function play(type){var effect=effects[type];effect&&(soundEffectsPlayer?soundEffectsPlayer.play({path:effect}):require(["soundEffectsPlayer"],function(soundEffectsPlayer_){(soundEffectsPlayer=soundEffectsPlayer_).play({path:effect})}))}return reload(),events.on(connectionManager,"localusersignedin",reload),events.on(userSettings,"change",function(e,name){"soundeffects"===name&&reload()}),{}});