define(["dialogHelper","voiceReceiver","voiceProcessor","globalize","emby-button","css!./voice.css","material-icons","css!./../formdialog"],function(dialogHelper,voicereceiver,voiceprocessor,globalize){"use strict";function shuffleArray(array){for(var temporaryValue,randomIndex,currentIndex=array.length;0!==currentIndex;)randomIndex=Math.floor(Math.random()*currentIndex),currentIndex-=1,temporaryValue=array[currentIndex],array[currentIndex]=array[randomIndex],array[randomIndex]=temporaryValue;return array}function getSampleCommands(groupid){return voiceprocessor.getCommandGroups().then(function(commandGroups){groupid="undefined"!=typeof groupid?groupid:"";var commands=[];return commandGroups.map(function(group){group.items&&group.items.length>0&&(groupid!==group.groupid||""===groupid)&&group.items.map(function(item){item.commandtemplates&&item.commandtemplates.length>0&&item.commandtemplates.map(function(templates){commands.push(templates)})})}),shuffleArray(commands)})}function getCommandGroup(groupid){return voicereceiver.getCommandGroups().then(function(commandgroups){if(commandgroups){var idx=-1;return idx=commandgroups.map(function(e){return e.groupid}).indexOf(groupid),idx>-1?commandgroups[idx]:null}return null})}function renderSampleCommands(elem,commands){commands.length=Math.min(commands.length,4),commands=commands.map(function(c){return'
"'+c+'"
'}).join(""),elem.querySelector(".exampleCommands").innerHTML=commands}function showVoiceHelp(groupid,title){function onCancelClick(){dialogHelper.close(dlg)}console.log("Showing Voice Help",groupid,title);var dlg,isNewDialog=!1;if(!currentDialog){isNewDialog=!0,dlg=dialogHelper.createDialog({size:"medium",removeOnClose:!0}),dlg.classList.add("formDialog");var html="";html+='
',html+='',html+='

',html+=globalize.translate("sharedcomponents#VoiceInput"),html+="

",html+="
",html+="
",html+='
',html+='
',html+='
',html+='
',html+='

'+globalize.translate("sharedcomponents#HeaderSaySomethingLike")+"

",html+='
',html+="
",html+="
",html+='
',html+='

'+globalize.translate("sharedcomponents#HeaderYouSaid")+"

",html+='

',html+="

"+globalize.translate("sharedcomponents#MessageWeDidntRecognizeCommand")+"

",html+="
",html+='",html+='

'+globalize.translate("sharedcomponents#MessageIfYouBlockedVoice")+"

",html+="
",html+="
",html+="
",html+="
",html+="
",dlg.innerHTML=html,dialogHelper.open(dlg),currentDialog=dlg,dlg.addEventListener("close",function(){voicereceiver.cancel(),currentDialog=null});for(var closeButtons=dlg.querySelectorAll(".btnCancelVoiceInput"),i=0,length=closeButtons.length;i