function onYouTubeIframeAPIReady(){bindYtBtn()}function preventDefault(t){t=t||window.event,t.preventDefault&&t.preventDefault(),t.returnValue=!1}function preventDefaultForScrollKeys(t){return keys[t.keyCode]?(preventDefault(t),!1):void 0}function disableScroll(){}function enableScroll(){window.removeEventListener&&window.removeEventListener("DOMMouseScroll",preventDefault,!1),window.onmousewheel=document.onmousewheel=null,window.onwheel=null,window.ontouchmove=null,document.onkeydown=null}function getDevice(){var t=viewport().width;return t>=992?"desktop":"mobile"}function viewport(){var t=window,e="inner";return"innerWidth"in window||(e="client",t=document.documentElement||document.body),{width:t[e+"Width"],height:t[e+"Height"]}}function bindOverlayClose(){$(".overlay .bg").on("click",function(){var t=$(".overlay");$("iframe",t).length>0?t.removeClass("open").data("player").pauseVideo():($("img",t).removeClass("initial").removeClass("animate"),t.removeClass("open"))})}function bindEmailSubmit(){var t=$("#mailForm");$("#mailForm input.input-lg"),$("#mailForm").data("working",!1),t.on("submit",function(e){if(!$("#mailForm").data("working")){$("input",t).blur();var n=$("input",t).val();validateEmail(n)?sendMail(n):alertEmailMalformed()}return e.preventDefault(),!1})}function alertEmailSuccess(){$(".signup").addClass("success")}function alertEmailMalformed(){$(".signup").addClass("error")}function alertNetworkProblem(){$(".signup").addClass("networkProblem")}function sendMail(t){$("#mailForm").data("working",!0),$.ajax({url:"//api.ccpgames.com/v1/interest",type:"POST",contentType:"application/json",data:JSON.stringify({email:t,json:"",PartitionKey:"Gunjack"}),dataType:"json",complete:function(t){switch(t.status){case 200:alertEmailSuccess();break;case 202:alertEmailSuccess();break;case 500:alertEmailMalformed();break;default:alertNetworkProblem()}$("#mailForm").data("working",!1)}})}function validateEmail(t){var e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return e.test(t)}function bindImgNav(){var t=$(".overlay .btnLeft");$(".overlay .btnRight"),$(".overlay img"),$(".overlay img").attr("src"),$(".screenshot-tumbs"),t.on("click",function(){})}function bindScreenShotThumbs(){var t=$(".section-game-features .underlay");"desktop"==getDevice()?$(".screenshot-thumbs a.thumbnail").on("click",function(e){var n=$(this).attr("href"),a=$("img",t).not(".original"),i='';return $("img.original"),a.addClass("animOut"),setTimeout(function(){a.remove(),$(i).appendTo(t),setTimeout(function(){$("img",t).removeClass("initial").css({marginLeft:"-"+$("img",t).width()/2+"px"})},200)},500),loadCloseBtn(),!1}):$(".screenshot-thumbs a.thumbnail").on("click",function(t){return t.preventDefault(),!1})}function loadCloseBtn(){$(".section-game-features .closeBtn").off().removeClass("show"),$(".section-game-features .closeBtn").on("click",function(){$(this).removeClass("show"),$(".section-game-features .underlay img").not(".original").addClass("animOut"),setTimeout(function(){$(".section-game-features .underlay img").not(".original").remove()},500)}),setTimeout(function(){$(".section-game-features .closeBtn").addClass("show")},700)}function bindYtBtn(){var t=$(".overlay"),e=$(".inner",t);$(".play-btn").on("click",function(){t.hasClass("open")||(t.addClass("open"),0==$("iframe",e).length?(e.html('
'),bindVidToCurrent(t,"player",$(this).attr("data-yt"))):t.data("player").playVideo()),bindOverlayClose()})}function bindVidToCurrent(t,e,n){t.data("player",new YT.Player(e,{videoId:n,events:{onReady:onPlayerReady,onStateChange:onPlayerStateChange},playerVars:{rel:0}}))}function onPlayerReady(t){t.target.playVideo()}function onPlayerStateChange(t){2!=t.data&&0!=t.data||2==$(".closeBtn").data("playerPause")||$(".closeBtn").data("playerPause",1).click()}function startGyroLoop(){var t=$(".vr-experience img.under");$(".vr-experience img.over"),$(".vr-experience .underlay").css({left:"50%",marginLeft:"-"+t.width()/2+"px"}),t.css({top:"-20%"}),gyro.frequency=33,gyro.startTracking(function(e){$(window).scrollTop()>$(".vr-experience").position().top?($(".vr-experience .underlay").hasClass("fixed")||$(".vr-experience .underlay").addClass("fixed"),t.css({transform:"translate3d("+5*e.x+"%,"+e.beta*-.2+"%,0)"})):$(window).scrollTop()<$(".vr-experience").position().top&&$(".vr-experience .underlay").hasClass("fixed")&&$(".vr-experience .underlay").removeClass("fixed")})}function spawn(){(new Date).getTime()>lastTime+minSpawnTime&&(lastTime=(new Date).getTime(),parts.push(new smoke(emitterX,emitterY)))}function render(){var t=parts.length;for(ctx.clearRect(0,0,canvas.width,canvas.height);t--;)if(parts[t].y<0||parts[t].lifeTime>maxLifeTime)parts.splice(t,1);else{parts[t].update(),ctx.save();var e=-parts[t].size/2,n=-parts[t].size/2;ctx.translate(parts[t].x-e,parts[t].y-n),ctx.rotate(parts[t].angle/-180*Math.PI),ctx.globalAlpha=parts[t].alpha,ctx.drawImage(smokeImage,e,n,parts[t].size,parts[t].size),ctx.restore()}spawn(),requestAnimationFrame(render)}function smoke(t,e,n){this.x=Math.random()*$(window).width()-150,this.y=e,this.size=1.5,this.startSize=720,this.endSize=720,this.angle=0,this.startLife=(new Date).getTime(),this.lifeTime=0,this.velY=-2.5*Math.random(),this.velX=2*Math.random()-1}function resizeMe(){canvas.height=$(window).height()}function onYouTubeIframeAPIReady(){bindYtBtn()}function preventDefault(t){t=t||window.event,t.preventDefault&&t.preventDefault(),t.returnValue=!1}function preventDefaultForScrollKeys(t){return keys[t.keyCode]?(preventDefault(t),!1):void 0}function disableScroll(){}function enableScroll(){window.removeEventListener&&window.removeEventListener("DOMMouseScroll",preventDefault,!1),window.onmousewheel=document.onmousewheel=null,window.onwheel=null,window.ontouchmove=null,document.onkeydown=null}function getDevice(){var t=viewport().width;return t>=992?"desktop":"mobile"}function viewport(){var t=window,e="inner";return"innerWidth"in window||(e="client",t=document.documentElement||document.body),{width:t[e+"Width"],height:t[e+"Height"]}}function bindOverlayClose(){$(".overlay .bg").on("click",function(){var t=$(".overlay");$("iframe",t).length>0?t.removeClass("open").data("player").pauseVideo():($("img",t).removeClass("initial").removeClass("animate"),t.removeClass("open"))})}function bindEmailSubmit(){var t=$("#mailForm");$("#mailForm input.input-lg");$("#mailForm").data("working",!1),t.on("submit",function(e){if(!$("#mailForm").data("working")){$("input",t).blur();var n=$("input",t).val();validateEmail(n)?sendMail(n):alertEmailMalformed()}return e.preventDefault(),!1})}function alertEmailSuccess(){$(".signup").addClass("success")}function alertEmailMalformed(){$(".signup").addClass("error")}function alertNetworkProblem(){$(".signup").addClass("networkProblem")}function sendMail(t){$("#mailForm").data("working",!0),$.ajax({url:"//api.ccpgames.com/v1/interest",type:"POST",contentType:"application/json",data:JSON.stringify({email:t,json:"",PartitionKey:"Gunjack"}),dataType:"json",complete:function(t){switch(t.status){case 200:alertEmailSuccess();break;case 202:alertEmailSuccess();break;case 500:alertEmailMalformed();break;default:alertNetworkProblem()}$("#mailForm").data("working",!1)}})}function validateEmail(t){var e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return e.test(t)}function bindImgNav(){var t=$(".overlay .btnLeft");$(".overlay .btnRight"),$(".overlay img"),$(".overlay img").attr("src"),$(".screenshot-tumbs");t.on("click",function(){})}function bindScreenShotThumbs(){var t=$(".section-game-features .underlay");"desktop"==getDevice()?$(".screenshot-thumbs a.thumbnail").on("click",function(e){var n=$(this).attr("href"),a=$("img",t).not(".original"),i='';$("img.original");return a.addClass("animOut"),setTimeout(function(){a.remove(),$(i).appendTo(t),setTimeout(function(){$("img",t).removeClass("initial").css({marginLeft:"-"+$("img",t).width()/2+"px"})},200)},500),loadCloseBtn(),!1}):$(".screenshot-thumbs a.thumbnail").on("click",function(t){return t.preventDefault(),!1})}function loadCloseBtn(){$(".section-game-features .closeBtn").off().removeClass("show"),$(".section-game-features .closeBtn").on("click",function(){$(this).removeClass("show"),$(".section-game-features .underlay img").not(".original").addClass("animOut"),setTimeout(function(){$(".section-game-features .underlay img").not(".original").remove()},500)}),setTimeout(function(){$(".section-game-features .closeBtn").addClass("show")},700)}function bindYtBtn(){var t=$(".overlay"),e=$(".inner",t);$(".play-btn").on("click",function(){t.hasClass("open")||(t.addClass("open"),0==$("iframe",e).length?(e.html('
'),bindVidToCurrent(t,"player",$(this).attr("data-yt"))):t.data("player").playVideo()),bindOverlayClose()})}function bindVidToCurrent(t,e,n){t.data("player",new YT.Player(e,{videoId:n,events:{onReady:onPlayerReady,onStateChange:onPlayerStateChange},playerVars:{rel:0}}))}function onPlayerReady(t){t.target.playVideo()}function onPlayerStateChange(t){2!=t.data&&0!=t.data||2==$(".closeBtn").data("playerPause")||$(".closeBtn").data("playerPause",1).click()}function startGyroLoop(){var t=$(".vr-experience img.under");$(".vr-experience img.over");$(".vr-experience .underlay").css({left:"50%",marginLeft:"-"+t.width()/2+"px"}),t.css({top:"-20%"}),gyro.frequency=33,gyro.startTracking(function(e){$(window).scrollTop()>$(".vr-experience").position().top?($(".vr-experience .underlay").hasClass("fixed")||$(".vr-experience .underlay").addClass("fixed"),t.css({transform:"translate3d("+5*e.x+"%,"+e.beta*-.2+"%,0)"})):$(window).scrollTop()<$(".vr-experience").position().top&&$(".vr-experience .underlay").hasClass("fixed")&&$(".vr-experience .underlay").removeClass("fixed")})}function spawn(){(new Date).getTime()>lastTime+minSpawnTime&&(lastTime=(new Date).getTime(),parts.push(new smoke(emitterX,emitterY)))}function render(){var t=parts.length;for(ctx.clearRect(0,0,canvas.width,canvas.height);t--;)if(parts[t].y<0||parts[t].lifeTime>maxLifeTime)parts.splice(t,1);else{parts[t].update(),ctx.save();var e=-parts[t].size/2,n=-parts[t].size/2;ctx.translate(parts[t].x-e,parts[t].y-n),ctx.rotate(parts[t].angle/-180*Math.PI),ctx.globalAlpha=parts[t].alpha,ctx.drawImage(smokeImage,e,n,parts[t].size,parts[t].size),ctx.restore()}spawn(),requestAnimationFrame(render)}function smoke(t,e,n){this.x=Math.random()*$(window).width()-150,this.y=e,this.size=1.5,this.startSize=720,this.endSize=720,this.angle=0,this.startLife=(new Date).getTime(),this.lifeTime=0,this.velY=-2.5*Math.random(),this.velX=2*Math.random()-1}function resizeMe(){canvas.height=$(window).height()}var lastScrollTop=0,isScrolling=!1,gAlphaBase=0;$(document).ready(function(){$(".signup .input-lg").on("focusin",function(){$(".signup .border-bottom").addClass("on"),$(this).data("placeholder",$(this).attr("placeholder")),$(this).attr("placeholder",""),$(".signup").removeClass("error")}),$(".signup .input-lg").on("focusout",function(){0==$(this).val().length&&$(".signup .border-bottom").removeClass("on"),$(this).attr("placeholder",$(this).data("placeholder"))}),$(".section-game-features .underlay img").addClass("original"),bindScreenShotThumbs(),smokeImage.src="/_assets/images/Smoke2.png",smokeImage.onload=function(){render()},bindEmailSubmit(),$(".section-hero canvas").css({bottom:$(".signup").outerHeight()})}),$(window).load(function(){$(".section").each(function(){$(window).scrollTop()>=$(this).position().top&&$(window).scrollTop()<=$(this).position().top+$(this).height()&&($(".section").removeClass("current"),$(this).addClass("current"))}),$(".overlay .inner").css({marginTop:"-"+.5625*$(".overlay .inner").width()/2+"px"}),"desktop"!=getDevice()&&(gAlphaBase=gyro.getOrientation().alpha,startGyroLoop())}),$(window).resize(function(){$(".overlay .inner").css({marginTop:"-"+.5625*$(".overlay .inner").width()/2+"px"})});var keys={37:1,38:1,39:1,40:1};!function(){var t=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;window.requestAnimationFrame=t}();var canvas=document.getElementById("canvas"),ctx=canvas.getContext("2d");canvas.height=$(window).height(),canvas.width=$(window).width();var parts=[],minSpawnTime=160,lastTime=(new Date).getTime(),maxLifeTime=1e4,emitterX=canvas.width/2-50,emitterY=canvas.height-20,smokeImage=new Image;smoke.prototype.update=function(){this.lifeTime=(new Date).getTime()-this.startLife;var t=this.lifeTime/maxLifeTime*100;this.size=this.startSize+(this.endSize-this.startSize)*t*.1,this.alpha=1-.01*t,this.alpha=Math.max(this.alpha,0),this.x+=this.velX,this.y+=this.velY},window.onresize=resizeMe,window.onload=resizeMe;var lastScrollTop=0,isScrolling=!1,gAlphaBase=0;$(document).ready(function(){$(".signup .input-lg").on("focusin",function(){$(".signup .border-bottom").addClass("on"),$(this).data("placeholder",$(this).attr("placeholder")),$(this).attr("placeholder",""),$(".signup").removeClass("error")}),$(".signup .input-lg").on("focusout",function(){0==$(this).val().length&&$(".signup .border-bottom").removeClass("on"),$(this).attr("placeholder",$(this).data("placeholder"))}),$(".section-game-features .underlay img").addClass("original"),bindScreenShotThumbs(),smokeImage.src="/_assets/images/Smoke2.png",smokeImage.onload=function(){render()},bindEmailSubmit(),$(".section-hero canvas").css({bottom:$(".signup").outerHeight()})}),$(window).load(function(){$(".section").each(function(){$(window).scrollTop()>=$(this).position().top&&$(window).scrollTop()<=$(this).position().top+$(this).height()&&($(".section").removeClass("current"),$(this).addClass("current"))}),$(".overlay .inner").css({marginTop:"-"+.5625*$(".overlay .inner").width()/2+"px"}),"desktop"!=getDevice()&&(gAlphaBase=gyro.getOrientation().alpha,startGyroLoop())}),$(window).resize(function(){$(".overlay .inner").css({marginTop:"-"+.5625*$(".overlay .inner").width()/2+"px"})});var keys={37:1,38:1,39:1,40:1};!function(){var t=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;window.requestAnimationFrame=t}();var canvas=document.getElementById("canvas"),ctx=canvas.getContext("2d");canvas.height=$(window).height(),canvas.width=$(window).width();var parts=[],minSpawnTime=160,lastTime=(new Date).getTime(),maxLifeTime=1e4,emitterX=canvas.width/2-50,emitterY=canvas.height-20,smokeImage=new Image;smoke.prototype.update=function(){this.lifeTime=(new Date).getTime()-this.startLife;var t=this.lifeTime/maxLifeTime*100;this.size=this.startSize+(this.endSize-this.startSize)*t*.1,this.alpha=1-.01*t,this.alpha=Math.max(this.alpha,0),this.x+=this.velX,this.y+=this.velY},window.onresize=resizeMe,window.onload=resizeMe,function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.gyro=e()}(this,function(){function t(t){var e=Math.PI/180,n=t.beta*e,a=t.gamma*e,i=t.alpha*e,o=Math.cos(n/2),r=Math.cos(a/2),s=Math.cos(i/2),l=Math.sin(n/2),c=Math.sin(a/2),u=Math.sin(i/2),m=o*r*s-l*c*u;return n=l*r*s-o*c*u,a=o*c*s+l*r*u,i=o*r*u+l*c*s,{x:n,y:a,z:i,w:m}}function e(t,e){return{w:t.w*e.w-t.x*e.x-t.y*e.y-t.z*e.z,x:t.w*e.x+t.x*e.w+t.y*e.z-t.z*e.y,y:t.w*e.y-t.x*e.z+t.y*e.w+t.z*e.x,z:t.w*e.z+t.x*e.y-t.y*e.x+t.z*e.w}}function n(t,n){return t=e(n,{x:t.x,y:t.y,z:t.z,w:0}),t=e(t,{w:n.w,x:-n.x,y:-n.y,z:-n.z}),{x:t.x,y:t.y,z:t.z}}function a(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}function i(t){var e=180/Math.PI,i=n({x:0,y:1,z:0},t),o=0==i.x&&0==i.y?0:-Math.atan2(i.x,i.y),r=Math.atan2(i.z,Math.sqrt(i.x*i.x+i.y*i.y)),s={x:Math.cos(o),y:Math.sin(o),z:0},l={x:Math.sin(o)*Math.sin(r),y:-Math.cos(o)*Math.sin(r),z:Math.cos(r)},c=n({x:0,y:0,z:1},t),u=Math.atan2(a(c,s),a(c,l));return 0>o&&(o+=2*Math.PI),u>=.5*Math.PI?(u-=Math.PI,o+=Math.PI,r=r>0?Math.PI-r:-Math.PI-r):u0?Math.PI-r:-Math.PI-r),o>=2*Math.PI&&(o-=2*Math.PI),{alpha:o*e,beta:r*e,gamma:u*e}}function o(){function n(t){c.push("MozOrientation"),t.target.removeEventListener("MozOrientation",n,!0),t.target.addEventListener("MozOrientation",function(t){r.x=t.x-s.x,r.y=t.y-s.y,r.z=t.z-s.z},!0)}function a(t){c.push("devicemotion"),t.target.removeEventListener("devicemotion",a,!0),t.target.addEventListener("devicemotion",function(t){r.x=t.accelerationIncludingGravity.x-s.x,r.y=t.accelerationIncludingGravity.y-s.y,r.z=t.accelerationIncludingGravity.z-s.z},!0)}function o(n){c.push("deviceorientation"),n.target.removeEventListener("deviceorientation",o,!0),n.target.addEventListener("deviceorientation",function(n){var a=t({alpha:s.rawAlpha,beta:s.rawBeta,gamma:s.rawGamma});a.x*=-1,a.y*=-1,a.z*=-1;var o=t({alpha:n.alpha,beta:n.beta,gamma:n.gamma}),l=e(a,o),c=i(l);r.alpha=c.alpha,r.beta=c.beta,r.gamma=c.gamma,r.rawAlpha=n.alpha,r.rawBeta=n.beta,r.rawGamma=n.gamma},!0)}window.addEventListener("MozOrientation",n,!0),window.addEventListener("devicemotion",a,!0),window.addEventListener("deviceorientation",o,!0)}var r={x:null,y:null,z:null,alpha:null,beta:null,gamma:null},s={x:0,y:0,z:0,alpha:0,beta:0,gamma:0,rawAlpha:0,rawBeta:0,rawGamma:0},l=null,c=[],u={};return u.frequency=500,u.calibrate=function(){for(var t in r)s[t]="number"==typeof r[t]?r[t]:0},u.getOrientation=function(){return r},u.startTracking=function(t){l=setInterval(function(){t(r)},u.frequency)},u.stopTracking=function(){clearInterval(l)},u.hasFeature=function(t){for(var e in c)if(t==c[e])return!0;return!1},u.getFeatures=function(){return c},u.eulerToQuaternion=t,window&&window.addEventListener&&o(),u}),function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function e(t){return"function"==typeof t}function n(t){return"object"==typeof t&&null!==t}function a(t){B=t}function i(t){Q=t}function o(){return function(){process.nextTick(u)}}function r(){return function(){N(u)}}function s(){var t=0,e=new Z(u),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function l(){var t=new MessageChannel;return t.port1.onmessage=u,function(){t.port2.postMessage(0)}}function c(){return function(){setTimeout(u,1)}}function u(){for(var t=0;q>t;t+=2){var e=W[t],n=W[t+1];e(n),W[t]=void 0,W[t+1]=void 0}q=0}function m(){try{var t=require,e=t("vertx");return N=e.runOnLoop||e.runOnContext,r()}catch(n){return c()}}function h(){}function d(){return new TypeError("You cannot resolve a promise with itself")}function p(){return new TypeError("A promises callback cannot return that same promise.")}function f(t){try{return t.then}catch(e){return et.error=e,et}}function v(t,e,n,a){try{t.call(e,n,a)}catch(i){return i}}function y(t,e,n){Q(function(t){var a=!1,i=v(n,e,function(n){a||(a=!0,e!==n?b(t,n):x(t,n))},function(e){a||(a=!0,$(t,e))},"Settle: "+(t._label||" unknown promise"));!a&&i&&(a=!0,$(t,i))},t)}function g(t,e){e._state===J?x(t,e._result):e._state===tt?$(t,e._result):M(e,void 0,function(e){b(t,e)},function(e){$(t,e)})}function w(t,n){if(n.constructor===t.constructor)g(t,n);else{var a=f(n);a===et?$(t,et.error):void 0===a?x(t,n):e(a)?y(t,n,a):x(t,n)}}function b(e,n){e===n?$(e,d()):t(n)?w(e,n):x(e,n)}function A(t){t._onerror&&t._onerror(t._result),T(t)}function x(t,e){t._state===K&&(t._result=e,t._state=J,0!==t._subscribers.length&&Q(T,t))}function $(t,e){t._state===K&&(t._state=tt,t._result=e,Q(A,t))}function M(t,e,n,a){var i=t._subscribers,o=i.length;t._onerror=null,i[o]=e,i[o+J]=n,i[o+tt]=a,0===o&&t._state&&Q(T,t)}function T(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var a,i,o=t._result,r=0;rr;r++)M(a.resolve(t[r]),void 0,e,n);return i}function L(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(h);return b(n,t),n}function S(t){var e=this,n=new e(h);return $(n,t),n}function O(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function F(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function D(t){this._id=lt++,this._state=void 0,this._result=void 0,this._subscribers=[],h!==t&&(e(t)||O(),this instanceof D||F(),I(this,t))}function G(){var t;if("undefined"!=typeof global)t=global;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;n&&"[object Promise]"===Object.prototype.toString.call(n.resolve())&&!n.cast||(t.Promise=ct)}var P;P=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var N,B,j,Y=P,q=0,Q=({}.toString,function(t,e){W[q]=t,W[q+1]=e,q+=2,2===q&&(B?B(u):j())}),X="undefined"!=typeof window?window:void 0,V=X||{},Z=V.MutationObserver||V.WebKitMutationObserver,U="undefined"!=typeof process&&"[object process]"==={}.toString.call(process),H="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,W=new Array(1e3);j=U?o():Z?s():H?l():void 0===X&&"function"==typeof require?m():c();var K=void 0,J=1,tt=2,et=new _,nt=new _;C.prototype._validateInput=function(t){return Y(t)},C.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},C.prototype._init=function(){this._result=new Array(this.length)};var at=C;C.prototype._enumerate=function(){for(var t=this,e=t.length,n=t.promise,a=t._input,i=0;n._state===K&&e>i;i++)t._eachEntry(a[i],i)},C.prototype._eachEntry=function(t,e){var a=this,i=a._instanceConstructor;n(t)?t.constructor===i&&t._state!==K?(t._onerror=null,a._settledAt(t._state,e,t._result)):a._willSettleAt(i.resolve(t),e):(a._remaining--,a._result[e]=t)},C.prototype._settledAt=function(t,e,n){var a=this,i=a.promise;i._state===K&&(a._remaining--,t===tt?$(i,n):a._result[e]=n),0===a._remaining&&x(i,a._result)},C.prototype._willSettleAt=function(t,e){var n=this;M(t,void 0,function(t){n._settledAt(J,e,t)},function(t){n._settledAt(tt,e,t)})};var it=R,ot=k,rt=L,st=S,lt=0,ct=D;D.all=it,D.race=ot,D.resolve=rt,D.reject=st,D._setScheduler=a,D._setAsap=i,D._asap=Q,D.prototype={constructor:D,then:function(t,e){var n=this,a=n._state;if(a===J&&!t||a===tt&&!e)return this;var i=new this.constructor(h),o=n._result;if(a){var r=arguments[a-1];Q(function(){z(a,i,r,o)})}else M(n,i,t,e);return i},"catch":function(t){return this.then(null,t)}};var ut=G,mt={Promise:ct,polyfill:ut};"function"==typeof define&&define.amd?define(function(){return mt}):"undefined"!=typeof module&&module.exports?module.exports=mt:"undefined"!=typeof this&&(this.ES6Promise=mt),ut()}.call(this),!function(t){function e(t){return t=+t,0===t||isNaN(t)?t:t>0?1:-1}function n(t){var e=new Promise(function(e,n){var a=function(i){setTimeout(function(){t&&t.data?e():i>=20?n():a(++i)},50)};a(0)});return e}function a(){p=d?(t.screen.orientation.angle||0)*c:(t.orientation||0)*c}function i(t){m.orientation.data=t;for(var e in m.orientation.callbacks)m.orientation.callbacks[e].call(this)}function o(t){m.motion.data=t;for(var e in m.motion.callbacks)m.motion.callbacks[e].call(this)}if(void 0===t.FULLTILT||null===t.FULLTILT){var r=Math.PI,s=r/2,l=2*r,c=r/180,u=180/r,m={orientation:{active:!1,callbacks:[],data:void 0},motion:{active:!1,callbacks:[],data:void 0}},h=!1,d=!(!t.screen||!t.screen.orientation||void 0===t.screen.orientation.angle||null===t.screen.orientation.angle),p=(d?t.screen.orientation.angle:t.orientation||0)*c,f=s,v=r,y=l/3,g=-s,w={};w.version="0.5.3",w.getDeviceOrientation=function(t){var e=new Promise(function(e,a){var i=new w.DeviceOrientation(t);i.start();var o=new n(m.orientation);o.then(function(){i._alphaAvailable=m.orientation.data.alpha&&null!==m.orientation.data.alpha,i._betaAvailable=m.orientation.data.beta&&null!==m.orientation.data.beta,i._gammaAvailable=m.orientation.data.gamma&&null!==m.orientation.data.gamma,e(i)})["catch"](function(){i.stop(),a("DeviceOrientation is not supported")})});return e},w.getDeviceMotion=function(t){var e=new Promise(function(e,a){var i=new w.DeviceMotion(t);i.start();var o=new n(m.motion);o.then(function(){i._accelerationXAvailable=m.motion.data.acceleration&&m.motion.data.acceleration.x,i._accelerationYAvailable=m.motion.data.acceleration&&m.motion.data.acceleration.y,i._accelerationZAvailable=m.motion.data.acceleration&&m.motion.data.acceleration.z,i._accelerationIncludingGravityXAvailable=m.motion.data.accelerationIncludingGravity&&m.motion.data.accelerationIncludingGravity.x,i._accelerationIncludingGravityYAvailable=m.motion.data.accelerationIncludingGravity&&m.motion.data.accelerationIncludingGravity.y,i._accelerationIncludingGravityZAvailable=m.motion.data.accelerationIncludingGravity&&m.motion.data.accelerationIncludingGravity.z,i._rotationRateAlphaAvailable=m.motion.data.rotationRate&&m.motion.data.rotationRate.alpha,i._rotationRateBetaAvailable=m.motion.data.rotationRate&&m.motion.data.rotationRate.beta,i._rotationRateGammaAvailable=m.motion.data.rotationRate&&m.motion.data.rotationRate.gamma,e(i)})["catch"](function(){i.stop(),a("DeviceMotion is not supported")})});return e},w.Quaternion=function(t,n,a,i){var o;this.set=function(t,e,n,a){this.x=t||0,this.y=e||0,this.z=n||0,this.w=a||1},this.copy=function(t){this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w},this.setFromEuler=function(){var t,e,n,a,i,o,r,s,l,u,m,h;return function(d){return d=d||{},n=(d.alpha||0)*c,t=(d.beta||0)*c,e=(d.gamma||0)*c,o=n/2,a=t/2,i=e/2,r=Math.cos(a),s=Math.cos(i),l=Math.cos(o),u=Math.sin(a),m=Math.sin(i),h=Math.sin(o),this.set(u*s*l-r*m*h,r*m*l+u*s*h,r*s*h+u*m*l,r*s*l-u*m*h),this.normalize(),this}}(),this.setFromRotationMatrix=function(){var t;return function(n){return t=n.elements,this.set(.5*Math.sqrt(1+t[0]-t[4]-t[8])*e(t[7]-t[5]),.5*Math.sqrt(1-t[0]+t[4]-t[8])*e(t[2]-t[6]),.5*Math.sqrt(1-t[0]-t[4]+t[8])*e(t[3]-t[1]),.5*Math.sqrt(1+t[0]+t[4]+t[8])),this}}(),this.multiply=function(t){return o=w.Quaternion.prototype.multiplyQuaternions(this,t),this.copy(o),this},this.rotateX=function(t){return o=w.Quaternion.prototype.rotateByAxisAngle(this,[1,0,0],t),this.copy(o),this},this.rotateY=function(t){return o=w.Quaternion.prototype.rotateByAxisAngle(this,[0,1,0],t),this.copy(o),this},this.rotateZ=function(t){return o=w.Quaternion.prototype.rotateByAxisAngle(this,[0,0,1],t),this.copy(o),this},this.normalize=function(){return w.Quaternion.prototype.normalize(this)},this.set(t,n,a,i)},w.Quaternion.prototype={constructor:w.Quaternion,multiplyQuaternions:function(){var t=new w.Quaternion;return function(e,n){var a=e.x,i=e.y,o=e.z,r=e.w,s=n.x,l=n.y,c=n.z,u=n.w;return t.set(a*u+r*s+i*c-o*l,i*u+r*l+o*s-a*c,o*u+r*c+a*l-i*s,r*u-a*s-i*l-o*c),t}}(),normalize:function(t){var e=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w);return 0===e?(t.x=0,t.y=0,t.z=0,t.w=1):(e=1/e,t.x*=e,t.y*=e,t.z*=e,t.w*=e),t},rotateByAxisAngle:function(){var t,e,n=new w.Quaternion,a=new w.Quaternion;return function(i,o,r){return t=(r||0)/2,e=Math.sin(t),a.set((o[0]||0)*e,(o[1]||0)*e,(o[2]||0)*e,Math.cos(t)),n=w.Quaternion.prototype.multiplyQuaternions(i,a),w.Quaternion.prototype.normalize(n)}}()},w.RotationMatrix=function(t,e,n,a,i,o,r,s,l){var u;this.elements=new Float32Array(9),this.identity=function(){return this.set(1,0,0,0,1,0,0,0,1),this},this.set=function(t,e,n,a,i,o,r,s,l){this.elements[0]=t||1,this.elements[1]=e||0,this.elements[2]=n||0,this.elements[3]=a||0,this.elements[4]=i||1,this.elements[5]=o||0,this.elements[6]=r||0,this.elements[7]=s||0,this.elements[8]=l||1},this.copy=function(t){this.elements[0]=t.elements[0],this.elements[1]=t.elements[1],this.elements[2]=t.elements[2],this.elements[3]=t.elements[3],this.elements[4]=t.elements[4],this.elements[5]=t.elements[5],this.elements[6]=t.elements[6],this.elements[7]=t.elements[7],this.elements[8]=t.elements[8]},this.setFromEuler=function(){var t,e,n,a,i,o,r,s,l;return function(u){return u=u||{},n=(u.alpha||0)*c,t=(u.beta||0)*c,e=(u.gamma||0)*c,a=Math.cos(t),i=Math.cos(e),o=Math.cos(n),r=Math.sin(t),s=Math.sin(e),l=Math.sin(n),this.set(o*i-l*r*s,-a*l,i*l*r+o*s,i*l+o*r*s,o*a,l*s-o*i*r,-a*s,r,a*i),this.normalize(),this}}(),this.setFromQuaternion=function(){var t,e,n,a;return function(i){return t=i.w*i.w,e=i.x*i.x,n=i.y*i.y,a=i.z*i.z,this.set(t+e-n-a,2*(i.x*i.y-i.w*i.z),2*(i.x*i.z+i.w*i.y),2*(i.x*i.y+i.w*i.z),t-e+n-a,2*(i.y*i.z-i.w*i.x),2*(i.x*i.z-i.w*i.y),2*(i.y*i.z+i.w*i.x),t-e-n+a),this}}(),this.multiply=function(t){return u=w.RotationMatrix.prototype.multiplyMatrices(this,t),this.copy(u),this},this.rotateX=function(t){return u=w.RotationMatrix.prototype.rotateByAxisAngle(this,[1,0,0],t),this.copy(u),this},this.rotateY=function(t){return u=w.RotationMatrix.prototype.rotateByAxisAngle(this,[0,1,0],t),this.copy(u),this},this.rotateZ=function(t){return u=w.RotationMatrix.prototype.rotateByAxisAngle(this,[0,0,1],t),this.copy(u),this},this.normalize=function(){return w.RotationMatrix.prototype.normalize(this)},this.set(t,e,n,a,i,o,r,s,l)},w.RotationMatrix.prototype={constructor:w.RotationMatrix,multiplyMatrices:function(){var t,e,n=new w.RotationMatrix;return function(a,i){return t=a.elements,e=i.elements,n.set(t[0]*e[0]+t[1]*e[3]+t[2]*e[6],t[0]*e[1]+t[1]*e[4]+t[2]*e[7],t[0]*e[2]+t[1]*e[5]+t[2]*e[8],t[3]*e[0]+t[4]*e[3]+t[5]*e[6],t[3]*e[1]+t[4]*e[4]+t[5]*e[7],t[3]*e[2]+t[4]*e[5]+t[5]*e[8],t[6]*e[0]+t[7]*e[3]+t[8]*e[6],t[6]*e[1]+t[7]*e[4]+t[8]*e[7],t[6]*e[2]+t[7]*e[5]+t[8]*e[8]),n}}(),normalize:function(t){var e=t.elements,n=e[0]*e[4]*e[8]-e[0]*e[5]*e[7]-e[1]*e[3]*e[8]+e[1]*e[5]*e[6]+e[2]*e[3]*e[7]-e[2]*e[4]*e[6];return e[0]/=n,e[1]/=n,e[2]/=n,e[3]/=n,e[4]/=n,e[5]/=n,e[6]/=n,e[7]/=n,e[8]/=n,t.elements=e,t},rotateByAxisAngle:function(){var t,e,n=new w.RotationMatrix,a=new w.RotationMatrix,i=!1;return function(o,r,s){return a.identity(),i=!1,t=Math.sin(s),e=Math.cos(s),1===r[0]&&0===r[1]&&0===r[2]?(i=!0,a.elements[4]=e,a.elements[5]=-t,a.elements[7]=t,a.elements[8]=e):1===r[1]&&0===r[0]&&0===r[2]?(i=!0,a.elements[0]=e,a.elements[2]=t,a.elements[6]=-t,a.elements[8]=e):1===r[2]&&0===r[0]&&0===r[1]&&(i=!0,a.elements[0]=e,a.elements[1]=-t,a.elements[3]=t,a.elements[4]=e),i?(n=w.RotationMatrix.prototype.multiplyMatrices(o,a),n=w.RotationMatrix.prototype.normalize(n)):n=o,n}}()},w.Euler=function(t,e,n){this.set=function(t,e,n){this.alpha=t||0,this.beta=e||0,this.gamma=n||0},this.copy=function(t){this.alpha=t.alpha,this.beta=t.beta,this.gamma=t.gamma},this.setFromRotationMatrix=function(){var t,e,n,a;return function(i){t=i.elements,t[8]>0?(e=Math.atan2(-t[1],t[4]),n=Math.asin(t[7]),a=Math.atan2(-t[6],t[8])):t[8]<0?(e=Math.atan2(t[1],-t[4]),n=-Math.asin(t[7]),n+=n>=0?-r:r,a=Math.atan2(t[6],-t[8])):t[6]>0?(e=Math.atan2(-t[1],t[4]),n=Math.asin(t[7]),a=-s):t[6]<0?(e=Math.atan2(t[1],-t[4]),n=-Math.asin(t[7]),n+=n>=0?-r:r,a=-s):(e=Math.atan2(t[3],t[0]),n=t[7]>0?s:-s,a=0),0>e&&(e+=l),e*=u,n*=u,a*=u,this.set(e,n,a)}}(),this.setFromQuaternion=function(){var t,e,n;return function(a){var i=a.w*a.w,o=a.x*a.x,c=a.y*a.y,m=a.z*a.z,h=i+o+c+m,d=a.w*a.x+a.y*a.z,p=1e-6; if(d>(.5-p)*h)t=2*Math.atan2(a.y,a.w),e=s,n=0;else if((-.5+p)*h>d)t=-2*Math.atan2(a.y,a.w),e=-s,n=0;else{var f=i-o+c-m,v=2*(a.w*a.z-a.x*a.y),y=i-o-c+m,g=2*(a.w*a.y-a.x*a.z);y>0?(t=Math.atan2(v,f),e=Math.asin(2*d/h),n=Math.atan2(g,y)):(t=Math.atan2(-v,-f),e=-Math.asin(2*d/h),e+=0>e?r:-r,n=Math.atan2(-g,-y))}0>t&&(t+=l),t*=u,e*=u,n*=u,this.set(t,e,n)}}(),this.rotateX=function(t){return w.Euler.prototype.rotateByAxisAngle(this,[1,0,0],t),this},this.rotateY=function(t){return w.Euler.prototype.rotateByAxisAngle(this,[0,1,0],t),this},this.rotateZ=function(t){return w.Euler.prototype.rotateByAxisAngle(this,[0,0,1],t),this},this.set(t,e,n)},w.Euler.prototype={constructor:w.Euler,rotateByAxisAngle:function(){var t=new w.RotationMatrix;return function(e,n,a){return t.setFromEuler(e),t=w.RotationMatrix.prototype.rotateByAxisAngle(t,n,a),e.setFromRotationMatrix(t),e}}()},w.DeviceOrientation=function(e){this.options=e||{};var n=0,a=200,i=0,o=10;if(this.alphaOffsetScreen=0,this.alphaOffsetDevice=void 0,"game"===this.options.type){var r=function(e){return null!==e.alpha&&(this.alphaOffsetDevice=new w.Euler(e.alpha,0,0),this.alphaOffsetDevice.rotateZ(-p),++i>=o)?void t.removeEventListener("deviceorientation",r,!1):void(++n>=a&&t.removeEventListener("deviceorientation",r,!1))}.bind(this);t.addEventListener("deviceorientation",r,!1)}else if("world"===this.options.type){var s=function(e){return e.absolute!==!0&&void 0!==e.webkitCompassAccuracy&&null!==e.webkitCompassAccuracy&&+e.webkitCompassAccuracy>=0&&+e.webkitCompassAccuracy<50&&(this.alphaOffsetDevice=new w.Euler(e.webkitCompassHeading,0,0),this.alphaOffsetDevice.rotateZ(p),this.alphaOffsetScreen=p,++i>=o)?void t.removeEventListener("deviceorientation",s,!1):void(++n>=a&&t.removeEventListener("deviceorientation",s,!1))}.bind(this);t.addEventListener("deviceorientation",s,!1)}},w.DeviceOrientation.prototype={constructor:w.DeviceOrientation,start:function(e){e&&"[object Function]"==Object.prototype.toString.call(e)&&m.orientation.callbacks.push(e),h||(d?t.screen.orientation.addEventListener("change",a,!1):t.addEventListener("orientationchange",a,!1)),m.orientation.active||(t.addEventListener("deviceorientation",i,!1),m.orientation.active=!0)},stop:function(){m.orientation.active&&(t.removeEventListener("deviceorientation",i,!1),m.orientation.active=!1)},listen:function(t){this.start(t)},getFixedFrameQuaternion:function(){var t=new w.Euler,e=new w.RotationMatrix,n=new w.Quaternion;return function(){var a=m.orientation.data||{alpha:0,beta:0,gamma:0},i=a.alpha;return this.alphaOffsetDevice&&(e.setFromEuler(this.alphaOffsetDevice),e.rotateZ(-this.alphaOffsetScreen),t.setFromRotationMatrix(e),t.alpha<0&&(t.alpha+=360),t.alpha%=360,i-=t.alpha),t.set(i,a.beta,a.gamma),n.setFromEuler(t),n}}(),getScreenAdjustedQuaternion:function(){var t;return function(){return t=this.getFixedFrameQuaternion(),t.rotateZ(-p),t}}(),getFixedFrameMatrix:function(){var t=new w.Euler,e=new w.RotationMatrix;return function(){var n=m.orientation.data||{alpha:0,beta:0,gamma:0},a=n.alpha;return this.alphaOffsetDevice&&(e.setFromEuler(this.alphaOffsetDevice),e.rotateZ(-this.alphaOffsetScreen),t.setFromRotationMatrix(e),t.alpha<0&&(t.alpha+=360),t.alpha%=360,a-=t.alpha),t.set(a,n.beta,n.gamma),e.setFromEuler(t),e}}(),getScreenAdjustedMatrix:function(){var t;return function(){return t=this.getFixedFrameMatrix(),t.rotateZ(-p),t}}(),getFixedFrameEuler:function(){var t,e=new w.Euler;return function(){return t=this.getFixedFrameMatrix(),e.setFromRotationMatrix(t),e}}(),getScreenAdjustedEuler:function(){var t,e=new w.Euler;return function(){return t=this.getScreenAdjustedMatrix(),e.setFromRotationMatrix(t),e}}(),isAbsolute:function(){return!(!m.orientation.data||m.orientation.data.absolute!==!0)},getLastRawEventData:function(){return m.orientation.data||{}},_alphaAvailable:!1,_betaAvailable:!1,_gammaAvailable:!1,isAvailable:function(t){switch(t){case this.ALPHA:return this._alphaAvailable;case this.BETA:return this._betaAvailable;case this.GAMMA:return this._gammaAvailable}},ALPHA:"alpha",BETA:"beta",GAMMA:"gamma"},w.DeviceMotion=function(t){this.options=t||{}},w.DeviceMotion.prototype={constructor:w.DeviceMotion,start:function(e){e&&"[object Function]"==Object.prototype.toString.call(e)&&m.motion.callbacks.push(e),h||(d?t.screen.orientation.addEventListener("change",a,!1):t.addEventListener("orientationchange",a,!1)),m.motion.active||(t.addEventListener("devicemotion",o,!1),m.motion.active=!0)},stop:function(){m.motion.active&&(t.removeEventListener("devicemotion",o,!1),m.motion.active=!1)},listen:function(t){this.start(t)},getScreenAdjustedAcceleration:function(){var t=m.motion.data&&m.motion.data.acceleration?m.motion.data.acceleration:{x:0,y:0,z:0},e={};switch(p){case f:e.x=-t.y,e.y=t.x;break;case v:e.x=-t.x,e.y=-t.y;break;case y:case g:e.x=t.y,e.y=-t.x;break;default:e.x=t.x,e.y=t.y}return e.z=t.z,e},getScreenAdjustedAccelerationIncludingGravity:function(){var t=m.motion.data&&m.motion.data.accelerationIncludingGravity?m.motion.data.accelerationIncludingGravity:{x:0,y:0,z:0},e={};switch(p){case f:e.x=-t.y,e.y=t.x;break;case v:e.x=-t.x,e.y=-t.y;break;case y:case g:e.x=t.y,e.y=-t.x;break;default:e.x=t.x,e.y=t.y}return e.z=t.z,e},getScreenAdjustedRotationRate:function(){var t=m.motion.data&&m.motion.data.rotationRate?m.motion.data.rotationRate:{alpha:0,beta:0,gamma:0},e={};switch(p){case f:e.beta=-t.gamma,e.gamma=t.beta;break;case v:e.beta=-t.beta,e.gamma=-t.gamma;break;case y:case g:e.beta=t.gamma,e.gamma=-t.beta;break;default:e.beta=t.beta,e.gamma=t.gamma}return e.alpha=t.alpha,e},getLastRawEventData:function(){return m.motion.data||{}},_accelerationXAvailable:!1,_accelerationYAvailable:!1,_accelerationZAvailable:!1,_accelerationIncludingGravityXAvailable:!1,_accelerationIncludingGravityYAvailable:!1,_accelerationIncludingGravityZAvailable:!1,_rotationRateAlphaAvailable:!1,_rotationRateBetaAvailable:!1,_rotationRateGammaAvailable:!1,isAvailable:function(t){switch(t){case this.ACCELERATION_X:return this._accelerationXAvailable;case this.ACCELERATION_Y:return this._accelerationYAvailable;case this.ACCELERATION_Z:return this._accelerationZAvailable;case this.ACCELERATION_INCLUDING_GRAVITY_X:return this._accelerationIncludingGravityXAvailable;case this.ACCELERATION_INCLUDING_GRAVITY_Y:return this._accelerationIncludingGravityYAvailable;case this.ACCELERATION_INCLUDING_GRAVITY_Z:return this._accelerationIncludingGravityZAvailable;case this.ROTATION_RATE_ALPHA:return this._rotationRateAlphaAvailable;case this.ROTATION_RATE_BETA:return this._rotationRateBetaAvailable;case this.ROTATION_RATE_GAMMA:return this._rotationRateGammaAvailable}},ACCELERATION_X:"accelerationX",ACCELERATION_Y:"accelerationY",ACCELERATION_Z:"accelerationZ",ACCELERATION_INCLUDING_GRAVITY_X:"accelerationIncludingGravityX",ACCELERATION_INCLUDING_GRAVITY_Y:"accelerationIncludingGravityY",ACCELERATION_INCLUDING_GRAVITY_Z:"accelerationIncludingGravityZ",ROTATION_RATE_ALPHA:"rotationRateAlpha",ROTATION_RATE_BETA:"rotationRateBeta",ROTATION_RATE_GAMMA:"rotationRateGamma"},t.FULLTILT=w}}(window),!function(t,e){"function"==typeof define&&define.amd?define(function(){return t.GyroNorm=e()}):"object"==typeof module&&module.exports?module.exports=t.GyroNorm=e():t.GyroNorm=e()}(this,function(){function t(t){return Math.round(t*Math.pow(10,w))/Math.pow(10,w)}function e(){var e={};e=A?p.getScreenAdjustedEuler():p.getFixedFrameEuler();var n=f.getScreenAdjustedAcceleration(),i=f.getScreenAdjustedAccelerationIncludingGravity(),o=f.getScreenAdjustedRotationRate(),r=0;g===a?(r=e.alpha-u,r=0>r?360-Math.abs(r):r):r=e.alpha;var s={"do":{alpha:t(r),beta:t(e.beta),gamma:t(e.gamma),absolute:p.isAbsolute()},dm:{x:t(n.x),y:t(n.y),z:t(n.z),gx:t(i.x),gy:t(i.y),gz:t(i.z),alpha:t(o.alpha),beta:t(o.beta),gamma:t(o.gamma)}};return y&&(s.dm.gx*=m,s.dm.gy*=m,s.dm.gz*=m),s}function n(t){b&&("string"==typeof t&&(t={message:t,code:0}),b(t))}var a="game",i="world",o="deviceorientation",r="acceleration",s="accelerationinludinggravity",l="rotationrate",c=null,u=0,m=0,h=!1,d=!1,p=null,f=null,v=50,y=!0,g=a,w=2,b=null,A=!1,x=function(t){};return x.GAME=a,x.WORLD=i,x.DEVICE_ORIENTATION=o,x.ACCELERATION=r,x.ACCELERATION_INCLUDING_GRAVITY=s,x.ROTATION_RATE=l,x.prototype.init=function(t){t&&t.frequency&&(v=t.frequency),t&&t.gravityNormalized&&(y=t.gravityNormalized),t&&t.orientationBase&&(g=t.orientationBase),t&&t.decimalCount&&(w=t.decimalCount),t&&t.logger&&(b=t.logger),t&&t.screenAdjusted&&(A=t.screenAdjusted);var e=new FULLTILT.getDeviceOrientation({type:g}).then(function(t){p=t}),n=(new FULLTILT.getDeviceMotion).then(function(t){f=t,m=f.getScreenAdjustedAccelerationIncludingGravity().z>0?-1:1});return Promise.all([e,n]).then(function(){d=!0})},x.prototype.end=function(){try{d=!1,this.stop(),f.stop(),p.stop()}catch(t){n(t)}},x.prototype.start=function(t){return d?(c=setInterval(function(){t(e())},v),void(h=!0)):void n({message:'GyroNorm is not initialized yet. First call the "init()" function.',code:1})},x.prototype.stop=function(){c&&(clearInterval(c),h=!1)},x.prototype.normalizeGravity=function(t){y=!!t},x.prototype.setHeadDirection=function(){return A||g===i?!1:(u=p.getFixedFrameEuler().alpha,!0)},x.prototype.startLogging=function(t){t&&(b=t)},x.prototype.stopLogging=function(){b=null},x.prototype.isAvailable=function(t){var e=p.getScreenAdjustedEuler(),n=f.getScreenAdjustedAcceleration(),a=f.getScreenAdjustedAccelerationIncludingGravity(),i=f.getScreenAdjustedRotationRate();switch(t){case o:return e.alpha&&null!==e.alpha&&e.beta&&null!==e.beta&&e.gamma&&null!==e.gamma;case r:return n&&n.x&&n.y&&n.z;case s:return a&&a.x&&a.y&&a.z;case l:return i&&i.alpha&&i.beta&&i.gamma;default:return{deviceOrientationAvailable:e.alpha&&null!==e.alpha&&e.beta&&null!==e.beta&&e.gamma&&null!==e.gamma,accelerationAvailable:n&&n.x&&n.y&&n.z,accelerationIncludingGravityAvailable:a&&a.x&&a.y&&a.z,rotationRateAvailable:i&&i.alpha&&i.beta&&i.gamma}}},x.prototype.isRunning=function(){return h},x});