(function(e){function t(t){for(var s,a,r=t[0],c=t[1],l=t[2],u=0,d=[];uv.startGame())}," START ",8,c)]),Object(s["d"])("div",l,[Object(s["d"])("button",{disabled:!k.started,onClick:t[1]||(t[1]=e=>v.reset())}," RESET ",8,h)])]),Object(s["d"])("div",u,[(Object(s["f"])(!0),Object(s["c"])(s["a"],null,Object(s["g"])(k.spaces,(e,t)=>(Object(s["f"])(),Object(s["c"])("div",{key:e,onClick:e=>v.checkInput(t),class:Object(s["e"])([[e.klass,{fail:k.fail,blink:k.blink==t||k.success}],"simeon-game-spaces"])},[Object(s["d"])("div",p,[Object(s["d"])("div",b,Object(s["h"])(e.key),1)])],10,d))),128))])])])}n("14d9");const k=()=>{let e=null,t=!0;try{if(window.AudioContext=window.AudioContext||window.webkitAudioContext,e=new AudioContext,t&&"suspended"===e.state){var n=function(){e.resume(),setTimeout((function(){"running"===e.state&&document.body.removeEventListener("touchend",n,!1)}),0)};document.body.addEventListener("touchend",n,!1)}return e}catch(s){return t=!1,alert("Sorry, Web Audio API is not supported in this browser"),null}};var v={name:"App",components:{},data(){return{colors:["green","red","blue","yellow"],started:!1,audioContext:null,oscMain:null,gainMain:null,volume:60,count:4,score:0,blink:null,check:[],pattern:[],fail:!1,success:!1,playing:!1,spaces:[{key:"Q",tone:220,klass:"piece-t-l"},{key:"W",tone:261.63,klass:"piece-t-r"},{key:"A",tone:293.66,klass:"piece-b-l"},{key:"S",tone:329.63,klass:"piece-b-r"}]}},created(){window.addEventListener("keyup",e=>{switch(e.key){case"q":this.playOSC(this.spaces[0].tone),this.checkInput(0);break;case"w":this.playOSC(this.spaces[1].tone),this.checkInput(1);break;case"a":this.playOSC(this.spaces[2].tone),this.checkInput(2);break;case"s":this.playOSC(this.spaces[3].tone),this.checkInput(3);break}})},mounted(){},methods:{playOSC:function(e=440,t="triangle"){null!=this.oscMain&&(this.oscMain.stop(),this.oscMain=null),this.oscMain=null,this.oscMain=this.audioContext.createOscillator(),this.oscMain.type=t,this.oscMain.frequency.value=e,this.gainMain=this.gainMain||this.audioContext.createGain(),this.gainMain.gain.value=this.volume/100,this.oscMain.connect(this.gainMain),this.gainMain.connect(this.audioContext.destination),this.oscMain.start(),this.oscMain.stop(this.audioContext.currentTime+.2)},checkInput(e){if(!this.playing&&this.started){this.blink=e,this.check.length{this.success=!1,this.fail=!1,this.addToPattern(),this.playPattern()},200))}},startGame(){this.started=!0,this.audioContext||(this.audioContext=k()),this.reset()},reset(){this.fail=!1,this.success=!1,this.pattern=[],this.check=[],this.score=0,this.addToPattern(),this.playPattern()},playPattern(){var e=0;this.playing=!0;var t=setInterval(()=>{this.blink=this.pattern[e],this.playOSC(this.spaces[this.pattern[e]].tone),e++,setTimeout(()=>{this.blink=null},500),e>=this.pattern.length&&(clearInterval(t),setTimeout(()=>{this.blink=null,this.playing=!1},200))},600)},addToPattern(){this.pattern.push(Math.floor(4*Math.random()))}}},y=(n("e829"),n("6b0d")),g=n.n(y);const O=g()(v,[["render",f]]);var m=O,j=n("9483");Object(j["a"])("service-worker.js",{ready(){console.log("App is being served from cache by a service worker.\nFor more details, visit https://goo.gl/AFskqB")},registered(){console.log("Service worker has been registered.")},cached(){console.log("Content has been cached for offline use.")},updatefound(){console.log("New content is downloading.")},updated(){console.log("New content is available; please refresh.")},offline(){console.log("No internet connection found. App is running in offline mode.")},error(e){console.error("Error during service worker registration:",e)}}),Object(s["b"])(m).mount("#app")},8530:function(e,t,n){},e829:function(e,t,n){"use strict";n("8530")}}); //# sourceMappingURL=app.4b99dfb1.js.map