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'