define(["exports","./../dom.js","./../emby-apiclient/connectionmanager.js","./../emby-apiclient/events.js","./../common/pluginmanager.js","./../layoutmanager.js","./../common/servicelocator.js","./../common/appsettings.js","./../common/inputmanager.js","./../focusmanager.js","./../input/keyboard.js"],function(_exports,_dom,_connectionmanager,_events,_pluginmanager,_layoutmanager,_servicelocator,_appsettings,_inputmanager,_focusmanager,_keyboard){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;var soundEffectsPlayer,effects={};function reload(){var soundeffectPlugin;_servicelocator.appHost.supports("soundeffects")&&(_inputmanager.default.off(window,onInputCommand,{passive:!0}),_dom.default.removeEventListener(window,"keydown",onKeyDown,{passive:!0}),_dom.default.removeEventListener(window,"userprompt",onUserPrompt,{passive:!0}),_events.default.off(_focusmanager.default,"move",onFocusManagerMove),_layoutmanager.default.tv)&&(_inputmanager.default.on(window,onInputCommand,{passive:!0}),_dom.default.addEventListener(window,"keydown",onKeyDown,{passive:!0}),_dom.default.addEventListener(window,"userprompt",onUserPrompt,{passive:!0}),_events.default.on(_focusmanager.default,"move",onFocusManagerMove),(soundeffectPlugin=function(){var soundeffectOption;try{soundeffectOption=_appsettings.default.soundEffects()}catch(err){}soundeffectOption=soundeffectOption||"defaultsoundeffects";if("none"===soundeffectOption)return null;var soundeffectPlugin=_pluginmanager.default.ofType("soundeffects").filter(function(i){return i.id===soundeffectOption})[0];soundeffectPlugin=soundeffectPlugin||_pluginmanager.default.ofType("soundeffects").filter(function(i){return"defaultsoundeffects"===i.id})[0];return soundeffectPlugin}())?function(soundeffectPlugin){var i,effectDictionary=soundeffectPlugin.getEffects(),temp={};for(i in effectDictionary)temp[i]=_pluginmanager.default.mapPath(soundeffectPlugin,effectDictionary[i]);effects=temp}(soundeffectPlugin):effects={})}function onFocusManagerMove(e){play("navigation")}function onInputCommand(evt){var pendingSound,activeElement;if(pendingSound="select"===evt.detail.command&&(pendingSound="miniselect",activeElement=document.activeElement)&&"BUTTON"===activeElement.tagName&&activeElement.classList.contains("button-submit")?"select":pendingSound){if(activeElement)switch(activeElement.type){case"text":case"textarea":case"tel":case"search":case"password":case"number":return}play(pendingSound)}}function onKeyDown(evt){var pendingSound,activeElement;switch(_keyboard.default.normalizeKeyFromEvent(evt)){case"Enter":case" ":pendingSound="miniselect",(activeElement=document.activeElement)&&"BUTTON"===activeElement.tagName&&activeElement.classList.contains("button-submit")&&(pendingSound="select")}if(pendingSound){if(activeElement)switch(activeElement.type){case"text":case"textarea":case"tel":case"search":case"password":case"number":return}play(pendingSound)}}function onUserPrompt(evt){if(evt.detail)switch(evt.detail.promptType){case"alert":play("error");break;case"confirm":play("question")}}function play(type){var effect=effects[type];(effect=effect||"miniselect"!==type?effect:effects.select)&&(soundEffectsPlayer?soundEffectsPlayer.play({path:effect}):require(["soundEffectsPlayer"],function(soundEffectsPlayer_){(soundEffectsPlayer=soundEffectsPlayer_).play({path:effect})}))}reload(),_events.default.on(_connectionmanager.default,"localusersignedin",reload),_events.default.on(_appsettings.default,"change",function(e,name){"soundeffects"===name&&reload()});_exports.default={}});