-
Notifications
You must be signed in to change notification settings - Fork 25
/
humaninput-1.1.15-full.min.js
1 lines (1 loc) · 52.5 KB
/
humaninput-1.1.15-full.min.js
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["humaninput-full"]=e():(t.HumanInput=t.HumanInput||{},t.HumanInput["humaninput-full"]=e())}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=28)}([function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){(function(e){t.exports=e.HumanInput=n(10)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(4)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(5)}).call(e,n(0))},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}e.__esModule=!0;var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),a=n(14),l=n(3),c=n(1),u=n(13),h=n(11),p=n(12);(0,a.polyfill)();var d=window.HumanInput,f=window.screen,g=window.document,v=["blur","click","compositionend","compositionstart","compositionupdate","contextmenu","focus","hold","input","keydown","keypress","keyup","reset","submit"],m=[],w=[],y=0,_=!1,b=!1;Object.keys(window.KeyboardEvent.prototype).includes("key")&&(b=!0);var S=function(t){function e(n,s){var r;i(this,e);var a={listenEvents:e.defaultListenEvents,addEvents:[],removeEvents:[],eventOptions:{},noKeyRepeat:!0,sequenceTimeout:3500,holdInterval:250,maxSequenceBuf:12,uniqueNumpad:!1,swipeThreshold:50,moveThreshold:5,disableSequences:!1,disableSelectors:!1,eventMap:{},translate:c.noop,logLevel:"INFO",logPrefix:(0,c.getLoggingName)(n)};for(var l in s)a[l]=s[l];s=a;var h=new u.Logger(s.logLevel,s.logPrefix),d=o(this,t.call(this,h));if(m.length)for(var f in m)if(m[f].elem===n){var v;return v=m[f],o(d,v)}m.push(d),d.l=s.translate,(r=s.listenEvents).push.apply(r,s.addEvents),s.removeEvents.length&&(s.listenEvents=s.listenEvents.filter(function(t){return!s.removeEvents.includes(t)})),d.settings=s,d.elem=(0,c.getNode)(n||window),d.Logger=u.Logger,d.log=h,d.VERSION="1.1.15",d.plugin_instances=[],d.eventMap={forward:{},reverse:{}},d.keyMaps={0:{},1:{},2:{}},p.keyMaps&&(d.keyMaps=p.keyMaps),s.disableSequences&&(d._handleSeqEvents=c.noop),s.disableSelectors&&(d._handleSelectors=c.noop),["_composition","_contextmenu","_holdCounter","_resetSeqTimeout","_resetStates","_keydown","_keypress","_keyup","trigger"].forEach(function(t){d[t]=d[t].bind(d)}),d._compositionstart=d._composition,d._compositionupdate=d._composition,d._compositionend=d._composition,void 0!==g.hidden&&g.addEventListener("visibilitychange",function(t){g.hidden?d.trigger("document:hidden",t):d.trigger("document:visible",t)},!1);var w=d._genericEvent.bind(d,"window");return void 0!==window.onblur&&(0,c.addListeners)(window,["blur","focus"],w,!0),d.elem===window&&((0,c.addListeners)(window,["beforeunload","hashchange","languagechange"],w,!0),window.addEventListener("resize",(0,c.debounce)(w,250),!0),void 0!==window.orientation&&window.addEventListener("orientationchange",function(t){var e="window:orientation";d.trigger(e,t),90===Math.abs(window.orientation)?d.trigger(e+":landscape",t):d.trigger(e+":portrait",t)},!1)),d.init(),d}return s(e,t),e.prototype.map=function(t){for(var e in t)this.eventMap.forward[e]=t[e],this.eventMap.reverse[t[e]]=e},e.prototype.init=function(){var t=this,e=this.settings,n=e.listenEvents,i=this.log.debug;this.eventCount&&this.trigger("hi:reset"),this.scope="",this.state={down:[],downAlt:[],holdStart:null,holdArgs:[],seqBuffer:[]},this.events={},this.eventMap={forward:{},reverse:{}},this.map(e.eventMap),_=!1,this.elem===window&&this.on("window:resize",function(){window.outerWidth===f.width&&window.outerHeight===f.height?(t.state.fullscreen=!0,t.trigger("fullscreen",!0)):t.state.fullscreen&&(t.state.fullscreen=!1,t.trigger("fullscreen",!1))}),this.on("window:blur",this._resetStates);for(var o=0;o<w.length;o++){this.plugin_instances[o]instanceof w[o]||(this.plugin_instances[o]=new w[o](this));var s=this.plugin_instances[o];if(i(this.l("Initializing Plugin:"),s.constructor.name),(0,c.isFunction)(s.init)){var r=s.init(this);for(var a in r.exports)this[a]=r.exports[a]}}this.off("hi:pause"),this.on("hi:pause",function(){i(t.l("Pause: Removing event listeners ",n)),n.forEach(function(n){var i=e.eventOptions[n]||!0;(0,c.isFunction)(t["_"+n])&&t.elem.removeEventListener(n,t["_"+n],i)})}),this.off(["hi:initialized","hi:resume"]),this.on(["hi:initialized","hi:resume"],function(){i("HumanInput Version: "+t.VERSION),i(t.l("Start/Resume: Addding event listeners"),n),n.forEach(function(n){var i=e.eventOptions[n]||!0;(0,c.isFunction)(t["_"+n])?(t.elem.removeEventListener(n,t["_"+n],i),t.elem.addEventListener(n,t["_"+n],i)):(t["_"+n]=t._genericEvent.bind(t,""),t.elem.addEventListener(n,t["_"+n],i))})}),this.trigger("hi:initialized",this)},e.prototype.noConflict=function(){return window.HumanInput=d,e},e.prototype._resetStates=function(){var t=this.state;t.seqBuffer=[],t.down=[],t.downAlt=[],t.holdArgs=[],y=0,_=!1,clearTimeout(t.holdTimeout),this.trigger("hi:resetstates")},e.prototype._resetSeqTimeout=function(){var t=this;clearTimeout(this.state.seqTimer),this.state.seqTimer=setTimeout(function(){t.log.debug(t.l("Resetting event sequence states due to timeout")),t._resetStates()},this.settings.sequenceTimeout)},e.prototype._genericEvent=function(t,e){var n,i=this.filter(e);i&&(t.type&&(e=t,t=null),t?t+=":":t="",n=this.trigger(this.scope+t+e.type,e),e.target&&(n=n.concat(this._handleSelectors(t+e.type,e))),(0,c.handlePreventDefault)(e,n))},e.prototype._handleSelectors=function(t){var e,n=[],i=Array.from(arguments).slice(1),o=this;if(i[0]&&i[0].target&&(o=i[0].target,o.id&&(e=t+":#"+o.id,n=this.trigger.apply(o,[e].concat(i))),o.classList&&o.classList.length))for(var s=0;s<o.classList.length;s++)e=t+":."+o.classList.item(s),n=n.concat(this.trigger.apply(o,[e].concat(i)));return n},e.prototype._addDown=function(t,e){var n=this.state,i=n.down.indexOf(t);-1==i&&(i=n.downAlt.indexOf(t)),-1==i&&e&&(i=n.downAlt.indexOf(e)),-1==i&&(n.down.push(t),e?n.downAlt.push(e):n.downAlt.push(t)),this.trigger("hi:adddown",t,e)},e.prototype._removeDown=function(t){var e=this.state,n=this.settings,i=e.down,o=e.downAlt,s=e.down.indexOf(t);clearTimeout(e.holdTimeout),-1===s&&(s=o.indexOf(t)),-1===s&&(s=o.indexOf(t.toUpperCase())),-1!==s&&(i.splice(s,1),o.splice(s,1)),y=i.length,n.listenEvents.includes("hold")&&(e.holdArgs.pop(),e.heldTime=n.holdInterval,e.holdStart=Date.now(),i.length&&(e.holdTimeout=setTimeout(this._holdCounter,n.holdInterval))),this.trigger("hi:removedown",t)},e.prototype._doDownEvent=function(t){var e=Array.from(arguments).slice(1);this._addDown(t);var n=this._handleDownEvents.apply(this,e);return this._handleSeqEvents(e[0]),this._removeDown(t),n},e.prototype._keyEvent=function(t){return l.CONTROLKEYS.includes(t)?l.ControlKeyEvent:l.ALTKEYS.includes(t)?l.AltKeyEvent:l.SHIFTKEYS.includes(t)?l.ShiftKeyEvent:l.OSKEYS.includes(t)?l.OSKeyEvent:t.toLowerCase()},e.prototype._contextmenu=function(t){if(this.filter(t)){var e=this._triggerWithSelectors(t.type,[t]);(0,c.handlePreventDefault)(t,e)||this._resetStates()}},e.prototype._handleShifted=function(t){for(var e=t.length-1,n=-1,i=0;i<t.length&&-1==(n=t[i].indexOf("Shift"));i++);if(-1!=n&&t[e]!=this.state.downAlt[e])return t.splice(n,1),!0},e.prototype._handleDownEvents=function(){for(var t=this.settings,e=this.state,n=this._downEvents(),i=[],o=Array.from(arguments),s=0;s<n.length;s++)i=i.concat(this._triggerWithSelectors(n[s],o));return t.listenEvents.includes("hold")&&(e.holdArgs.push(o),e.heldTime=t.holdInterval,e.holdStart=Date.now(),clearTimeout(e.holdTimeout),e.holdTimeout=setTimeout(this._holdCounter,t.holdInterval)),i},e.prototype._handleSeqEvents=function(t){var e=this.state,n=e.seqBuffer,i=[],o=e.down.slice(0);if(y<o.length&&this.sequenceFilter(t)&&(this._handleShifted(o),(0,c.sortEvents)(o),n.push(o),n.length>this.settings.maxSequenceBuf&&n.shift(),n.length>1)){for(var s=this._seqCombinations(n),r=0;r<s.length;r++)for(var a=(0,c.seqSlicer)(s[r]),l=0;l<a.length;l++)i=i.concat(this.trigger(this.scope+a[l],this));i.length&&(n=[])}this._resetSeqTimeout()},e.prototype._normSpecial=function(t,e,n){return" "==e?n:(n.hasOwnProperty("includes")&&(n.includes("Left")||n.includes("Right"))&&(e=n),this.settings.uniqueNumpad&&3===t?"numpad"+e:(e.startsWith("Arrow")&&(e=e.substr(5)),e))},e.prototype._holdCounter=function(){var t=this.state,e=this.settings,n=this._downEvents();if(n.length){clearTimeout(t.holdTimeout);var i=t.holdArgs[t.holdArgs.length-1]||[],o=Date.now()-t.holdStart;this._resetSeqTimeout();for(var s=0;s<n.length;s++)this.trigger("hold",n[s],o),this._triggerWithSelectors("hold:"+t.heldTime+":"+n[s],i.concat([o]));t.heldTime+=e.holdInterval,t.heldTime<5001&&(t.holdTimeout=setTimeout(this._holdCounter,e.holdInterval))}},e.prototype._triggerWithSelectors=function(t,e){var n=[],i=this.scope+t;return n=n.concat(this.trigger.apply(this,[i].concat(e))),n=n.concat(this._handleSelectors.apply(this,[i].concat(e)))},e.prototype._seqCombinations=function(t,e){var n,i,o=e||"-",s=(0,c.cloneArray)(t),r=[],a=[];for(n=0;n<t.length;n++)for(r.push(s[n].join(o).toLowerCase()),i=0;i<t[n].length;i++)s[n][i]=[this._keyEvent(t[n][i])];for(r=[r.join(" ")],n=0;n<s.length;n++)s[n].length&&a.push((0,c.arrayCombinations)(s[n],o));for(n=0;n<a.length;n++)a[n]=this.eventMap.forward[a[n]]||a[n];return a=a.join(" "),a!=r[0]&&r.push(a),r},e.prototype._downEvents=function(){var t,e=[],n=this.state.down.slice(0),i=n.length,o=this.state.downAlt.slice(0);if(i){if(1===i)return this._seqCombinations([n]);i>1&&(t=this._handleShifted(n),e=e.concat(this._seqCombinations([n],"->")),t&&(e=e.concat(this._seqCombinations([o],"->")))),n.length>1&&((0,c.sortEvents)(n),e=e.concat(this._seqCombinations([n]))),t&&((0,c.sortEvents)(o),e=e.concat(this._seqCombinations([o])))}return e},e.prototype._keydown=function(t){var e,n=this.state,i=t.which||t.keyCode,o=t.location||0,s=this.keyMaps[o][i]||this.keyMaps[0][i]||t.code,r=t.key||s,a=t.type,l=this.filter(t),u=this.scope+"faceplant";return t.repeat&&l&&this.settings.noKeyRepeat?(t.preventDefault(),!1):"Compose"==(r=this._normSpecial(o,r,s))?void(n.composing=!0):(n.down.includes(r)||this._addDown(r,s),this._resetSeqTimeout(),void(l&&(e=this._triggerWithSelectors(a,[t,r,s]),e=e.concat(this._triggerWithSelectors(a+=":"+r.toLowerCase(),[t,r,s])),n.down.length>5&&(e=e.concat(this.trigger(u,t))),b&&(e=e.concat(this._handleDownEvents(t,r,s))),(0,c.handlePreventDefault)(t,e))))},e.prototype._keypress=function(t){var e=t.charCode||t.which,n=t.key||String.fromCharCode(e);!b&&e>47&&n.length&&(this.state.down.pop(),this.state.down.push(n))},e.prototype._keyup=function(t){var e,n=this.state,i=t.which||t.keyCode,o=t.location||0,s=this.keyMaps[o][i]||this.keyMaps[0][i]||t.code,r=t.key||s,a=t.type;if(r=this._normSpecial(o,r,s),l.MACOS&&l.OSKEYS.includes(r)){for(var u=[],h=0;h<n.down.length;h++)l.AllModifiers.includes(n.down[h])||u.push(n.down[h]);for(var p=0;p<u.length;p++)this._removeDown(u[p])}if(n.downAlt.length){if(n.composing)return void(n.composing=!1);this.filter(t)&&(b||this._handleDownEvents(t),e=this._triggerWithSelectors(a,[t,r,s]),e=e.concat(this._triggerWithSelectors(a+":"+r.toLowerCase(),[t,r,s])),this._handleSeqEvents(t),(0,c.handlePreventDefault)(t,e)),this._removeDown(r)}},e.prototype._composition=function(t){var e=t.data,n="compos";if(this.filter(t)){var i=this._triggerWithSelectors(t.type,[t,e]);e&&("compositionupdate"==t.type?n+='ing:"'+e+'"':"compositionend"==t.type&&(n+='ed:"'+e+'"'),i=i.concat(this._triggerWithSelectors(n,[t])),(0,c.handlePreventDefault)(t,i))}},e.prototype.filter=function(t){var e=(t.target||t.srcElement).tagName,n=["keydown","keyup","keypress"];return!t.type||!n.includes(t.type)||!("INPUT"==e||"SELECT"==e||"TEXTAREA"==e)},e.prototype.sequenceFilter=function(t){return!0},e.prototype.pushScope=function(t){this.scope.length?this.scope=this.scope.slice(0,-1)+"."+t+":":this.scope=t+":"},e.prototype.popScope=function(){this.scope.length&&(this.scope=this.scope.slice(0,-1).split(".").slice(0,-1).join(".")+":"),":"==this.scope&&(this.scope="")},e.prototype.pause=function(){this.state.paused=!0,this.trigger("hi:pause",this)},e.prototype.resume=function(){this.state.paused=!1,this.trigger("hi:resume",this)},e.prototype.startRecording=function(){this.state.recording=!0,this.state.recordedEvents=[]},e.prototype.stopRecording=function(t){var e,n=this.state.recordedEvents,i=new RegExp(t),o=function(t){return!(t.includes(":#")||t.includes(":."))};if(this.state.recording=!1,!t)return n;if("keystroke"==t){var s=n.filter(o);i=new RegExp("keyup");for(var r=0;r<s.length&&!i.test(s[r]);r++)e=s[r];return e}return n.filter(function(t){return i.test(t)})},e.prototype.getSelText=function(){var t="";if(window.getSelection)t=window.getSelection();else{if(!g.selection)return;t=g.selection.createRange().text}return t.toString()},e.prototype.isDown=function(t){var e=this.state,n=this._downEvents();if(t=t.toLowerCase(),t=this.eventMap.reverse[t]||t,n.includes(t))return!0;for(var i=0;i<e.down.length;i++){var o=e.down[i].toLowerCase(),s=e.downAlt[i].toLowerCase();if(t==o||t==s)return!0;if(l.SHIFTKEYS.includes(e.down[i])){if(t==l.ShiftKeyEvent)return!0}else if(l.CONTROLKEYS.includes(e.down[i])){if(t==l.ControlKeyEvent)return!0}else if(l.ALTKEYS.includes(e.down[i])){if(t==l.AltKeyEvent)return!0}else if(l.OSKEYS.includes(e.down[i])&&t==l.OSKeyEvent)return!0}return!1},e.prototype.getDown=function(){for(var t=(0,c.sortEvents)(this.state.down.slice(0)),e=new RegExp("-$"),n="",i=0;i<t.length;i++)n+=this._keyEvent(t[i])+"-";return n.replace(e,"")},r(e,[{key:"instances",get:function(){return m}},{key:"plugins",get:function(){return w}}]),e}(h.EventHandler);S.instances=m,S.plugins=w,S.defaultListenEvents=v,e.default=S,t.exports=e.default},function(t,e,n){"use strict";e.__esModule=!0;for(var i=e.OSKEYS=["OS","OSLeft","OSRight"],o=e.CONTROLKEYS=["Control","ControlLeft","ControlRight"],s=e.ALTKEYS=["Alt","AltLeft","AltRight"],r=e.SHIFTKEYS=["Shift","ShiftLeft","ShiftRight","⇧"],a=(e.ControlKeyEvent="ctrl",e.ShiftKeyEvent="shift",e.AltKeyEvent="alt",e.OSKeyEvent="os",e.AltAltNames=["option","⌥"]),l=e.AltOSNames=["meta","win","⌘","cmd","command"],c=(e.AllModifiers=[].concat.apply([],[i,o,s,r]),e.MODPRIORITY={}),u=(e.MACOS=window.navigator.userAgent.includes("Mac OS X"),o.concat(["ctrl"])),h=s.concat(a),p=i.concat(l),d=0;d<u.length;d++)c[u[d].toLowerCase()]=5;for(var f=0;f<r.length;f++)c[r[f].toLowerCase()]=4;for(var g=0;g<h.length;g++)c[h[g].toLowerCase()]=3;for(var v=0;v<p.length;v++)c[p[v].toLowerCase()]=2},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.EventHandler=void 0;var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),s=n(1);e.EventHandler=function(){function t(e){i(this,t),this.aliases={anykey:"keyup",tap:"click",taphold:"hold:1500:pointer:left",clickhold:"hold:1500:pointer:left",middleclick:"pointer:middle",rightclick:"pointer:right",doubleclick:"dblclick",konami:"up up down down left right left right b a enter",portrait:"window:orientation:portrait",landscape:"window:orientation:landscape",hulksmash:"faceplant",twofingertap:"multitouch:2:tap",threefingertap:"multitouch:3:tap",fourfingertap:"multitouch:4:tap"},this.events={},this.log=e,this.one=this.once,this.emit=this.trigger}return t.prototype._handleAliases=function(t){return t=this.aliases[t]||t,1===t.length&&(0,s.isUpper)(t)&&(t="shift-"+t),t},t.prototype.on=function(t,e,n,i){var o=this;return(0,s.normEvents)(t).forEach(function(t){if(t.includes(":"))var r=":";else if(t.includes(" "))var r=" ";if(r){var a=new RegExp(r+'(?=(?:(?:[^"]*"){2})*[^"]*$)',"g"),l=t.split(a);t="";for(var c=0;c<l.length;c++)t+=o._handleAliases(l[c])+r;t=t.replace(new RegExp(r+"$"),"")}else t=o._handleAliases(t);t=t.toLowerCase(),t.includes("-")&&(t.includes("->")||(t=(0,s.normCombo)(t))),n||(n={});var u={callback:e,context:n,times:i};o.events[t]||(o.events[t]=[]),o.events[t].push(u)}),this},t.prototype.once=function(t,e,n){return this.on(t,e,n,1)},t.prototype.off=function(t,e,n){if(arguments.length){t=t?(0,s.normEvents)(t):Object.keys(this.events);for(var i in t){var o=t[i],r=this.events[o];if(r){var a=[];if(!n&&!e){delete this.events[o];break}for(var l=0;l<r.length;l++)e?r[l].callback.toString()==e.toString()&&(null!==n&&void 0!==n||!r[l].context)?(0,s.isEqual)(r[l].context,n)||a.push(r[l]):a.push(r[l]):n&&r[l].context!==n&&a.push(r[l]);a.length?this.events[o]=a:delete this.events[o]}}}else this.events={};return this},t.prototype.trigger=function(t){var e=this,n=[],i=Array.from(arguments).slice(1);return(0,s.normEvents)(t).forEach(function(t){t=e.aliases[t]||t,t=e.eventMap.forward[t]||t,e.log.debug("Triggering:",t,i.length?i:""),e.state.recording&&e.state.recordedEvents.push(t);var o=e.events[t];if(o)for(var s=0;s<o.length;s++){var r=o[s];r.context!==window&&(r.context.HIEvent=t),r.times&&(r.times-=1,0===r.times&&e.off(t,r.callback,r.context)),n.push(r.callback.apply(r.context||e,i))}}),n},o(t,[{key:"eventCount",get:function(){var t=0;for(var e in this.events)t++;return t}}]),t}()},function(t,e,n){"use strict";e.__esModule=!0,e.keyMaps=void 0;for(var i=n(3),o=e.keyMaps={0:{Backspace:8,Tab:9,Enter:13,Shift:16,Control:17,Alt:18,Pause:19,CapsLock:20,Escape:27,Space:32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,Left:37,ArrowUp:38,Up:38,ArrowRight:39,Right:39,ArrowDown:40,Down:40,PrintScreen:42,Insert:45,Delete:46,Semicolon:59,"=":61,OS:92,Select:93,NumLock:144,ScrollLock:145,VolumeDown:174,VolumeUp:175,MediaTrackPrevious:177,MediaPlayPause:179,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222,AltGraph:225,Compose:229},1:{ShiftLeft:16,ControlLeft:17,AltLeft:18,OSLeft:91},2:{ShiftRight:16,ControlRight:17,AltRight:18,OSRight:92},3:{"*":106,"+":107,"-":109,".":46,"/":111}},s=48;s<=57;s++)o[0][s]=""+(s-48);for(var r=65;r<=90;r++)o[0][r]=String.fromCharCode(r);for(var a=96;a<=105;a++)o[3][a]="Numpad"+(a-96);for(var l=112;l<=123;l++)o[0][l]="F"+(l-112+1);if(i.MACOS){var c={3:"Enter",63289:"NumpadClear",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"ArrowLeft",63232:"ArrowUp",63235:"ArrowRight",63233:"ArrowDown",63302:"Insert",63272:"Delete"};for(var u in c)o[0][u]=c[u];for(var h=63236;h<=63242;h++)o[0][h]="F"+(h-63236+1)}for(var p=0;p<=3;p++)!function(t){Object.keys(o[t]).forEach(function(e){e.length>1&&!isNaN(e)&&(e=parseInt(e)),o[t][o[t][e]]=e})}(p)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.Logger=void 0;var o=n(1),s=window.console,r={40:"ERROR",30:"WARNING",20:"INFO",10:"DEBUG",ERROR:40,WARNING:30,INFO:20,DEBUG:10};e.Logger=function(){function t(e,n){i(this,t),this.prefix=n,this.setLevel(e),this.writeErr=this.fallback,this.writeWarn=this.fallback,this.writeInfo=this.fallback,this.writeDebug=this.fallback,(0,o.isFunction)(s.error)&&(this.writeErr=s.error),(0,o.isFunction)(s.warn)&&(this.writeWarn=s.warn),(0,o.isFunction)(s.info)&&(this.writeInfo=s.info),(0,o.isFunction)(s.debug)&&(this.writeDebug=s.debug)}return t.prototype.setLevel=function(t){t=t.toUpperCase(),this.error=this.write.bind(this,40),this.warn=this.write.bind(this,30),this.info=this.write.bind(this,20),this.debug=this.write.bind(this,10),this.logLevel=t,isNaN(t)&&(this.logLevel=t=r[t]),t>40&&(this.error=o.noop),t>30&&(this.warn=o.noop),t>20&&(this.info=o.noop),t>10&&(this.debug=o.noop)},t.prototype.fallback=function(t){var e=Array.from(arguments);e[0]=this.prefix+r[t]+" "+e[0],(0,o.isFunction)(s.log)&&s.log.apply(s,e)},t.prototype.write=function(t){var e=this.logLevel,n=Array.from(arguments).slice(1);this.prefix.length&&n.unshift(this.prefix),40===t&&e<=40?this.writeErr.apply(s,n):30===t&&e<=30?this.writeWarn.apply(s,n):20===t&&e<=20?this.writeInfo.apply(s,n):10===t&&e<=10&&this.writeDebug.apply(s,n)},t}()},function(t,e,n){"use strict";function i(){Array.from||(Array.prototype.from=function(t){return[].slice.call(t)}),Array.prototype.includes||(Array.prototype.includes=function(t){var e,n,i=Object(this),o=parseInt(i.length,10)||0,s=parseInt(arguments[1],10)||0;if(0===o)return!1;for(s>=0?e=s:(e=o+s)<0&&(e=0);e<o;){if(n=i[e],t===n||t!==t&&n!==n)return!0;e++}return!1}),String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var n=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>n.length)&&(e=n.length),e-=t.length;var i=n.indexOf(t,e);return-1!==i&&i===e}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t})}e.__esModule=!0,e.polyfill=i},function(t,e,n){"use strict";function i(t){return t}function o(t){var e="";return t.name?e+=" "+t.name:t.id?e+=" "+t.id:t.nodeName&&(e+=" "+t.nodeName),"[HI"+e+"]"}function s(t){if("string"==typeof t){return document.querySelector(t)}return t}function r(t){return p(t)?[t]:t}function a(t,e){if(e.includes(!1))return t.preventDefault(),!0}function l(t){var e,n,i,o=[];for(t=t.split(/ +(?=(?:(?:[^"]*"){2})*[^"]*$)/g),e=0;e<t.length-1;e++)n=t.slice(e),i=n.join(" "),o.includes(i)||o.push(i);return o}function c(t){if(k(t)){for(var e=t.slice(0),n=0;n<e.length;n++)e[n]=c(e[n]);return e}return t}function u(t,e){var n=[];if(1===t.length)return t[0];for(var i=u(t.slice(1),e),o=0;o<i.length;o++)for(var s=0;s<t[0].length;s++)n.push(t[0][s]+e+i[o]);return n}function h(t){return"[object Function]"==E.call(t)}function p(t){return"[object String]"==E.call(t)}function d(t){var e=Array.from(arguments).slice(1);return function(){return t.apply(this,e.concat(Array.from(arguments)))}}function f(t,e,n){var i,o;return function(){var s=this,r=arguments,a=function(){i=null,n||(o=t.apply(s,r))},l=n&&!i;return clearTimeout(i),i=setTimeout(a,e),l&&(o=t.apply(s,r)),o}}function g(t,e){return t&&e&&"object"===(void 0===t?"undefined":b(t))&&"object"===(void 0===e?"undefined":b(e))?Object.keys(t).length===Object.keys(e).length&&Object.keys(t).reduce(function(n,i){return n&&g(t[i],e[i])},!0):t===e}function v(t){if(t==t.toUpperCase()&&t!=t.toLowerCase())return!0}function m(t){var e=S.MODPRIORITY;return t.sort(function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}),t.sort(function(t,e){return e.length-t.length}),t.sort(function(t,n){return t=t.toLowerCase(),n=n.toLowerCase(),t in e?n in e?e[t]>e[n]?-1:e[t]<e[n]?1:0:-1:n in e?1:0}),t}function w(t){for(var e=t.split("-"),n=0;n<e.length;n++)e[n]=e[n].toLowerCase(),e[n]=function(t){return"control"==t?S.ControlKeyEvent:t}(e[n]),e[n]=function(t){for(var e=0;e<S.AltAltNames.length;e++)if(t==S.AltAltNames[e])return S.AltKeyEvent;return t}(e[n]),e[n]=function(t){for(var e=0;e<S.AltOSNames.length;e++)if(t==S.AltOSNames[e])return S.OSKeyEvent;return t}(e[n]);return m(e),e.join("-")}function y(t,e,n,i){e.forEach(function(e){t.addEventListener(e,n,i)})}function _(t,e,n,i){e.forEach(function(e){t.removeEventListener(e,n,i)})}e.__esModule=!0,e.isArray=e.toString=void 0;var b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};e.noop=i,e.getLoggingName=o,e.getNode=s,e.normEvents=r,e.handlePreventDefault=a,e.seqSlicer=l,e.cloneArray=c,e.arrayCombinations=u,e.isFunction=h,e.isString=p,e.partial=d,e.debounce=f,e.isEqual=g,e.isUpper=v,e.sortEvents=m,e.normCombo=w,e.addListeners=y,e.removeListeners=_;var S=n(3),E=e.toString=Object.prototype.toString,k=e.isArray=Array.isArray},function(t,e,n){(function(e){t.exports=e.HumanInput=n(6)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(7)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(8)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(9)}).call(e,n(0))},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var o=n(2),s=i(o),r=n(25),a=(i(r),n(31)),l=(i(a),n(30)),c=(i(l),n(32)),u=(i(c),n(27)),h=(i(u),n(24)),p=(i(h),n(29)),d=(i(p),n(26));i(d);e.default=s.default,t.exports=e.default},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ClapperPlugin=void 0;var o=n(2),s=function(t){return t&&t.__esModule?t:{default:t}}(o);s.default.defaultListenEvents.push("clapper"),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia;var r=window.AudioContext||window.webkitAudioContext,a=function(t){return t.reduce(function(t,e){return t+e})},l=function(t){for(var e=[],n=1;n<t.length-1;++n)t[n-1]<t[n]&&t[n]>t[n+1]&&e.push(n);return e},c=e.ClapperPlugin=function(){function t(e){i(this,t),this.HI=e,this.l=e.l,this.exports={},this.history=[],this.rollingAvg=[],this.calcHistoryAverage=this.calcHistoryAverage.bind(this),this.startClapper=this.startClapper.bind(this),this.stopClapper=this.stopClapper.bind(this)}return t.prototype.init=function(t){var e=this;t.state;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Clapper]"),t.settings.autostartClapper=t.settings.autostartClapper||!1,t.settings.clapThreshold=t.settings.clapThreshold||130,t.settings.autotoggleClapper=t.settings.autotoggleClapper||!0,-1!=t.settings.listenEvents.indexOf("clapper")&&(r?(t.settings.autostartClapper&&this.startClapper(),t.settings.autotoggleClapper&&(t.on("document:hidden",function(){e._started&&e.stopClapper()}),t.on("document:visible",function(){!e._started&&t.settings.autostartClapper&&e.startClapper()}))):(this.startClapper=t.noop,this.stopClapper=t.noop)),this.exports.startClapper=this.startClapper,this.exports.stopClapper=this.stopClapper,this},t.prototype.calcHistoryAverage=function(){var t,e,n=0;for(t=0;t<this.analyser.frequencyBinCount;t++)if(this.history[t]){for(e=0;e<this.history.length;e++)n+=this.history[e][t];this.rollingAvg[t]=n/this.history.length,n=0}},t.prototype.startClapper=function(){var t=this,e=function(e){var n,i,o;t.stream=e,t.scriptProcessor.connect(t.context.destination),t.analyser.smoothingTimeConstant=.4,t.analyser.fftSize=128,t.streamSource=t.context.createMediaStreamSource(e),t.streamSource.connect(t.analyser),t.analyser.connect(t.scriptProcessor),t.scriptProcessor.onaudioprocess=function(){var e,s,r,c,u,h,p,d,f,g=Date.now();n||(n=g,i=g),e=g-n,s=g-i,r=g-o,e>60&&(t.freqData=new Uint8Array(t.analyser.frequencyBinCount),t.analyser.getByteFrequencyData(t.freqData),u=l(t.freqData),h=t.freqData.indexOf(Math.max.apply(null,t.freqData)),t.freqData[h],p=t.freqData[h]-t.rollingAvg[h],s>=240&&h<8&&p>t.HI.settings.clapThreshold&&(d=a(t.freqData.slice(0,10))/a(t.freqData.slice(10,20)),f=a(t.freqData.slice(0,3))/a(t.freqData.slice(3,6)),d<1.8&&f<1.4&&u.length>2&&(c="clap",s<480&&(c="doubleclap",o=g,r<720&&(c="applause")),t.HI._addDown(c),t.HI._handleDownEvents(),t.HI._handleSeqEvents(),t.HI._removeDown(c),i=g)),n=g,i!=g&&(t.history.push(t.freqData),t.history.length>50&&t.history.shift(),t.calcHistoryAverage()))}};this.context=new r,this.scriptProcessor=this.context.createScriptProcessor(1024,1,1),this.analyser=this.context.createAnalyser(),this.freqData=new Uint8Array(this.analyser.frequencyBinCount),this.log.debug(this.l("Starting clap detection")),this._started=!0,navigator.mediaDevices.getUserMedia({audio:!0}).then(e,function(e){t.log.error(t.l("Could not get audio stream"),e)})},t.prototype.stopClapper=function(){this.log.debug(this.l("Stopping clap detection")),this.stream.getAudioTracks().forEach(function(t){t.stop()}),this.stream.getVideoTracks().forEach(function(t){t.stop()}),this.streamSource.disconnect(this.analyser),this.analyser.disconnect(this.scriptProcessor),this.scriptProcessor.disconnect(this.context.destination),this._started=!1},t}();s.default.plugins.push(c)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ClipboardPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents=r.default.defaultListenEvents.concat(["cut","copy","paste","select"]);var a=e.ClipboardPlugin=function(){function t(e){i(this,t),this.HI=e,e._clipboard=this._clipboard.bind(e),this._paste=this._clipboard,this._copy=this._clipboard,this._cut=this._clipboard,e._select=this._select.bind(e),this._input=this._select}return t.prototype.init=function(t){return this},t.prototype._clipboard=function(t){var e,n=t.type+':"';if(this.filter(t)&&(window.clipboardData?e=window.clipboardData.getData("Text"):t.clipboardData&&(e=t.clipboardData.getData("text/plain")),e||"copy"!=t.type&&"cut"!=t.type||(e=this.getSelText()),e)){var i=this._triggerWithSelectors(t.type,[t,e]);i=i.concat(this._triggerWithSelectors(n+e+'"',[t])),(0,o.handlePreventDefault)(t,i)}},t.prototype._select=function(t){var e=t.type+':"';if("select"==t.type)var n=this.getSelText();else if("input"==t.type)var n=t.data||t.target.value;if(this.filter(t)){var i=this._triggerWithSelectors(t.type,[t,n]);n&&(i=i.concat(this._triggerWithSelectors(e+n+'"',[t])),(0,o.handlePreventDefault)(t,i))}},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sine",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,o=c.createGain(),s=c.createOscillator();s.connect(o),o.connect(c.destination),s.frequency.value=e,o.gain.value=i,s.type=n,s.start(),setTimeout(function(){s.stop()},t||50)}e.__esModule=!0,e.FeedbackPlugin=void 0;var s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s),a=n(1),l=n(3),c=new(window.AudioContext||window.webkitAudioContext||window.audioContext),u=["keydown","dblclick","wheel:down","wheel:up","wheel:left","wheel:right","pointer:left:down","pointer:middle:down","pointer:right:down","scroll:up","scroll:down","scroll:left","scroll:right"],h=["keydown","dblclick","wheel:down","wheel:up","wheel:left","wheel:right","pointer:down"],p=["pointer:down"],d=e.FeedbackPlugin=function(){function t(e){return i(this,t),this.HI=e,this.l=e.l,this.exports={beep:o},this.vibrationInterval=null,this}return t.prototype.init=function(t){var e=this;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Feedback]"),this.lastActivity=new Date,this.timeout=null,t.settings.visualEvents=t.settings.visualEvents||u,t.settings.audioEvents=t.settings.audioEvents||h,t.settings.vibrationEvents=t.settings.vibrationEvents||p,t.settings.visualFeedback=t.settings.visualFeedback||!1,t.settings.audioFeedback=t.settings.audioFeedback||!1,t.settings.vibrationFeedback=t.settings.vibrationFeedback||!1,t.settings.feedbackClass=t.settings.feedbackClass||"event",this.feedbackElem=(0,a.getNode)(t.settings.feedbackElem),this.feedbackElem||(this.feedbackElem=(0,a.getNode)("#hi_feedback")),this.feedbackElem||(t.settings.feedbackElem="#hi_feedback",this.feedbackStyle=document.createElement("style"),this.feedbackStyle.type="text/css",this.feedbackStyle.appendChild(document.createTextNode("\n#hi_feedback {\n position: fixed;\n top: 1em;\n right: 1em;\n align-items: flex-end;\n justify-content: flex-end;\n font-size: 2em;\n display: flex;\n flex-flow: row wrap;\n width: 8em;\n}\n\n#hi_feedback .event {\n transition: all .5s ease-in-out;\n transform-origin: right bottom;\n opacity: 0;\n border: black .15rem solid;\n border-radius: .2em;\n text-align: center;\n padding: .2rem;\n min-width: 1em;\n padding: .2em;\n background-color: rgba(0,0,0,0.7);\n color: #fff;\n z-index: 9999;\n}\n")),document.body.appendChild(this.feedbackStyle),this.feedbackElem=document.createElement("div"),this.feedbackElem.id="hi_feedback",t.elem!==window?t.elem.appendChild(this.feedbackElem):document.body.appendChild(this.feedbackElem)),t.settings.visualFeedback&&t.on(t.settings.visualEvents,this.visualEvent,this),t.settings.audioFeedback&&t.on(t.settings.audioEvents,this.audioEvent,this),t.settings.vibrationFeedback&&(t.on(t.settings.vibrationEvents,this.vibrationEvent,this),t.settings.vibrationEvents.forEach(function(n){n.endsWith("down")&&t.on(n.split("down",1)[0]+"up",e.stopVibration,e)})),this},t.prototype.containsModifiers=function(t,e,n){return l.AllModifiers.includes(t)},t.prototype.visualEvent=function(t){var e=this.HIEvent,n=["cut","copy","paste","select"],i=HI.getDown(),o=document.createElement("div");if(o.classList.add(this.HI.settings.feedbackClass),n.includes(t.type)&&(arguments.length<=1?0:arguments.length-1))o.innerHTML=e+":"+(arguments.length<=1?void 0:arguments[1]);else if("keydown"==t.type)e=arguments.length<=1?void 0:arguments[1],o.innerHTML=e,l.AllModifiers.includes(e)&&!i.includes("-")?o.innerHTML=e.toLowerCase():HI.state.down.some(this.containsModifiers)&&(o.innerHTML=i);else if(e.startsWith("pointer")){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",100),s.setAttribute("height",100),s.style.position="fixed",s.style.top=t.clientY-50+"px",s.style.left=t.clientX-50+"px",s.style.transition="all .33s ease-out",s.style.transform="scale(0.1)",s.style.zIndex=1e4,s.innerHTML='<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" />',document.body.appendChild(s),setTimeout(function(){s.style.transform="scale(2)",s.style.opacity=0,setTimeout(function(){s.parentNode.removeChild(s)},500)},10),e.includes(":down")&&(e=e.substr(0,e.length-5)),o.innerHTML=e}else i.length?o.innerHTML=i:o.innerHTML=e;o.style.opacity=1,this.feedbackElem.appendChild(o),setTimeout(function(){o.style.opacity=0,showEventTimeout=setTimeout(function(){o.parentNode.removeChild(o)},500)},1e3)},t.prototype.audioEvent=function(t){o(33,500,"triangle")},t.prototype.startVibration=function(){navigator.vibrate(150)},t.prototype.stopVibration=function(){clearInterval(this.vibrationInterval),navigator.vibrate(0)},t.prototype.vibrationEvent=function(t){navigator.vibrate(150),clearInterval(this.vibrationInterval),this.vibrationInterval=setInterval(this.startVibration,100)},t}();r.default.plugins.push(d)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.GamepadPlugin=void 0;var o=(n(1),n(2)),s=function(t){return t&&t.__esModule?t:{default:t}}(o),r=function(t){for(var e=navigator.getGamepads(),n=0;n<e.length;n++)if(e[n]&&e[n].index==t)return!0},a=e.GamepadPlugin=function(){function t(e){return i(this,t),this.HI=e,this.log=new e.Logger(e.settings.logLevel||"INFO","[HI Gamepad]"),this.gamepads=[],this._gamepadTimer=null,this.exports={gamepads:this.gamepads,_gamepadTimer:this._gamepadTimer,gamepadUpdate:this.gamepadUpdate.bind(this),loadController:this.loadController.bind(this),stopGamepadUpdates:this.stopGamepadUpdates.bind(this),startGamepadUpdates:this.startGamepadUpdates.bind(this)},this}return t.prototype.init=function(t){var e=t.settings;return e.gpadInterval=e.gpadInterval||100,e.gpadCheckInterval=e.gpadCheckInterval||3e3,clearInterval(this._gamepadTimer),e.listenEvents.includes("gamepad")&&(this.gamepadUpdate(),this.startGamepadUpdates(),t.on("document:hidden",this.stopGamepadUpdates.bind(this)),t.on("document:visible",this.startGamepadUpdates.bind(this)),t.on("gpad:connected",this.startGamepadUpdates.bind(this))),this},t.prototype.gamepadUpdate=function(){var t,e,n,i,o,s,a,l,c={type:"gamepad",target:this.HI.elem},u=navigator.getGamepads();for(t=0;t<this.gamepads.length;t++)this.gamepads[t]&&!r(t)&&(this.HI.trigger("gpad:disconnected",this.gamepads[t]),this.gamepads[t]=null);for(t=0;t<u.length;++t)if(u[t]){if(n=u[t].index,!(o=this.gamepads[n])){for(this.log.debug("Gamepad "+n+" detected:",u[t]),this.HI.trigger("gpad:connected",u[t]),this.gamepads[n]={axes:[],buttons:[],timestamp:u[t].timestamp,id:u[t].id},o=this.gamepads[n],e=0;e<u[t].buttons.length;e++)o.buttons[e]={value:0,pressed:!1};for(e=0;e<u[t].axes.length;e++)o.axes[e]=0;continue}if(o.timestamp==u[t].timestamp)continue;for(i=JSON.parse(JSON.stringify(o)),o.timestamp=u[t].timestamp,o.axes=u[t].axes.slice(0),e=0;e<i.buttons.length;e++)o.buttons[e].pressed=u[t].buttons[e].pressed,o.buttons[e].value=u[t].buttons[e].value;if(this.HI.filter(c)){for(e=0;e<o.buttons.length;e++)s="up",o.buttons[e].pressed&&1==o.buttons[e].value&&(s="down"),a="gpad:button:"+e,"down"==s?this.HI.isDown(a)||this.HI._addDown(a):this.HI.isDown(a)&&(this.HI._handleSeqEvents(),this.HI._removeDown(a)),o.buttons[e].pressed!=i.buttons[e].pressed?(this.HI.trigger(this.HI.scope+a,o.buttons[e].value,u[t]),this.HI.trigger(this.HI.scope+"gpad:button:"+s,o.buttons[e].value,u[t]),this.HI.trigger(this.HI.scope+a+":"+s,o.buttons[e].value,u[t]),l=!0):o.buttons[e].value!=i.buttons[e].value&&this.HI.trigger(HI.scope+a,o.buttons[e].value,u[t]);for(e=0;e<i.axes.length;e++)o.axes[e]!=i.axes[e]&&(a="gpad:axis:"+e,this.HI.trigger(HI.scope+a,o.axes[e],u[t]));l&&this.HI._handleDownEvents(u[t])}}},t.prototype.loadController=function(t){for(var e in t)this.HI.aliases[e]=t[e]},t.prototype.stopGamepadUpdates=function(){this.log.debug("Stopping gamepad updates.",this),clearInterval(this._gamepadTimer)},t.prototype.startGamepadUpdates=function(){this.log.debug("Starting gamepad updates.",this);var t=this.gamepadUpdate.bind(this);clearInterval(this._gamepadTimer),this.gamepads.length?this._gamepadTimer=setInterval(t,this.HI.settings.gpadInterval):this._gamepadTimer=setInterval(t,this.HI.settings.gpadCheckInterval)},t}();s.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t){if(isNaN(t)){var e=parseInt(t.slice(0,-1));return t.endsWith("s")?1e3*e:t.endsWith("m")?1e3*e*60:t.endsWith("h")?1e3*e*60*60:t.endsWith("d")?1e3*e*60*60*24:t.endsWith("M")?1e3*e*60*60*24*30:t.endsWith("y")?1e3*e*60*60*24*365:parseInt(t)}return t}e.__esModule=!0,e.IdlePlugin=void 0;var s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("idle");var a=e.IdlePlugin=function(){function t(e){return i(this,t),this.HI=e,this.l=e.l,this.startIdleChecker=this.startIdleChecker.bind(this),this.stopIdleChecker=this.stopIdleChecker.bind(this),this.mouseMoveCheck=this.mouseMoveCheck.bind(this),this.resetTimeout=this.resetTimeout.bind(this),this.idleCheck=this.idleCheck.bind(this),this.exports={startIdleChecker:this.startIdleChecker,stopIdleChecker:this.stopIdleChecker},this}return t.prototype.init=function(t){var e,n;return this.log=new t.Logger(t.settings.logLevel||"INFO","[HI Idle]"),this.lastActivity=new Date,this.timeout=null,t.settings.autostartIdle=t.settings.autostartIdle||!0,e=t.settings.idleTimeout||"5m",this.idleTimeout=o(e),n=t.settings.idleCheckInterval||"5s",this.idleCheckInterval=o(n),t.settings.listenEvents.includes("idle")&&t.settings.autostartIdle&&this.startIdleChecker(),this},t.prototype.mouseMoveCheck=function(){var t=this;clearTimeout(this.mouseMoveTimeout),this.lastActivity=new Date,window.removeEventListener("mousemove",this.mouseMoveCheck,!0),window.removeEventListener("mousemove",this.resetTimeout,!0),this.mouseMoveTimeout=setTimeout(function(){window.addEventListener("mousemove",t.mouseMoveCheck,!0)},this.idleCheckInterval)},t.prototype.resetTimeout=function(){this.log.debug(this.l("Activity detected; resetting idle timeout")),this.mouseMoveCheck(),clearTimeout(this.timeout),this.timeout=setTimeout(this.idleCheck,this.idleCheckInterval)},t.prototype.startIdleChecker=function(){var t=this;this.HI.on(["click","keydown","scroll"],this.resetTimeout),this.resetTimeout(),this.HI.on("idle",function(){t.stopIdleChecker(),t.HI.once(["click","keydown","scroll"],t.resetTimeout),window.addEventListener("mousemove",t.resetTimeout,!0)}),this.HI.once("hi:reset",this.stopIdleChecker)},t.prototype.stopIdleChecker=function(){window.removeEventListener("mousemove",this.mouseMoveCheck,!0),this.HI.off(["click","keydown","scroll"],this.resetTimeout),clearTimeout(this.timeout),clearTimeout(this.mouseMoveTimeout)},t.prototype.idleCheck=function(){clearTimeout(this.timeout),Date.now()-this.lastActivity.getTime()>this.idleTimeout?this.HI.trigger("idle",this.lastActivity):this.timeout=setTimeout(this.idleCheck,this.idleCheckInterval)},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.PointerPlugin=void 0;var o,s=n(1),r=n(2),a=function(t){return t&&t.__esModule?t:{default:t}}(r),l=["pan","mousedown","mouseup","touchstart","touchend","touchcancel","wheel"],c=["pointermove"];a.default.defaultListenEvents=a.default.defaultListenEvents.concat(l),c=["mousemove","touchmove"];var u=e.PointerPlugin=function(){function t(e){var n=this;i(this,t),this.HI=e,["_click","_dragendPointerup","_pointerdown","_pointerup","_pointercancel","_pointerMoveCheck","_trackMotion","_wheel"].forEach(function(t){e[t]=n[t].bind(e)}),e.on("hold",function(t){t.includes("pointer:")&&((0,s.removeListeners)(window,c,e._pointerMoveCheck,!0),(0,s.addListeners)(window,c,e._pointerMoveCheck,!0))}),e._mousedown=e._pointerdown,e._touchstart=e._pointerdown,e._mouseup=e._pointerup,e._touchend=e._pointerup,e._touchcancel=e._pointercancel,e._tap=e._click,e.on("hi:resetstates",this._resetStates,e),e.on("hi:removedown",function(t){(0,s.removeListeners)(window,c,e._pointerMoveCheck,!0)}),e.on("hold",this._holdCheck,e)}return t.prototype.init=function(t){var e=t.state;return e.multitap=0,e.pointerCount=0,e.pointers={},e.scrollX=0,e.scrollY=0,(0,s.removeListeners)(window,c,t._pointerMoveCheck,!0),(0,s.removeListeners)(t.elem,c,t._trackMotion,!0),this.exports={mouse:this.mouse},this},t.prototype._resetStates=function(){(0,s.removeListeners)(window,c,this._pointerMoveCheck,!0),(0,s.removeListeners)(this.elem,c,this._trackMotion,!0),this.state.pointers={},this.state.pointerCount=0},t.prototype._holdCheck=function(t){t.includes("pointer:")&&((0,s.removeListeners)(window,c,this._pointerMoveCheck,!0),(0,s.addListeners)(window,c,this._pointerMoveCheck,!0))},t.prototype._pointerMoveCheck=function(t){var e,n,i,o,r=this.settings.moveThreshold,a=this.state.pointers,l=t.touches;if(t.pointerType||"mousemove"==t.type)i=t.pointerId||1;else if(l&&l.length)for(var u=0;u<l.length;u++)i=l[u].identifier;(o=a[i])&&(e=t.clientX||o.event.clientX,n=t.clientY||o.event.clientY,e&&n&&(Math.abs(o.x-e)>r||Math.abs(o.y-n)>r)&&(clearTimeout(this.state.holdTimeout),(0,s.removeListeners)(window,c,this._pointerMoveCheck,!0)))},t.prototype._trackMotion=function(t){var e,n,i=[],o="pan",r={},a=this.state.pointers,l=t.touches;if(t.pointerType||"mousemove"==t.type){if(e=t.pointerId||1,!(n=a[e]))return;n.event=t}else if(l&&l.length)for(var c=0;c<l.length;c++){if(e=l[c].identifier,!(n=a[e]))return;n.event=l[c]}r.xOrig=n.x,r.yOrig=n.y,r.xPrev=n.xPrev||n.x,r.yPrev=n.yPrev||n.y,r.x=t.clientX||n.event.clientX,r.y=t.clientY||n.event.clientY,r.xMoved=r.x-r.xPrev,r.yMoved=r.y-r.yPrev,n.xPrev=r.x,n.yPrev=r.y,this._resetSeqTimeout(),this.filter(t)&&(this.state.pointerCount>1?(o="multitouch:",i=i.concat(this._triggerWithSelectors(o+"pan",[t,a])),i=i.concat(this._triggerWithSelectors(o+this.state.pointerCount+":pan",[t,a]))):i=i.concat(this._triggerWithSelectors(o,[t,r])),(0,s.handlePreventDefault)(t,i))},t.prototype._dragendPointerup=function(t){var e=t.pointerId||1,n=this.state.pointers,i={bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY,isPrimary:!0,layerX:t.layerX,layerY:t.layerY,offsetX:t.offsetX,offsetY:t.offsetY,pageX:t.pageX,pageY:t.pageY,pointerId:e,pressure:t.pressure||0,relatedTarget:window,screenX:t.screenX,screenY:t.screenY,target:t.target,tiltX:t.tiltX||0,tiltY:t.tiltY||0,view:window,x:t.x,y:t.y};new MouseEvent("mouseup",i);n[e]&&(this._pointerup(t),window.removeEventListener("dragend",this._dragendPointerup,!0))},t.prototype._pointerdown=function(t){var e,n,i=this.state,r=this.mouse(t),a=t.changedTouches,l=t.pointerType,u="pointer",h=":down";if("mousedown"!=t.type||!o){if(l||"mousedown"==t.type)e=t.pointerId||1,i.pointers[e]={x:t.clientX,y:t.clientY,event:t,timestamp:Date.now()};else if(a&&a.length){for(var p=0;p<a.length;p++)e=a[p].identifier,i.pointers[e]={x:a[p].clientX,y:a[p].clientY,event:a[p],timestamp:Date.now()};o=!0,r.buttonName="left"}window.addEventListener("dragend",this._dragendPointerup,!0),i.pointerCount++,(i.pointerCount>1||this.settings.listenEvents.includes("pan"))&&((0,s.removeListeners)(window,c,this._trackMotion,!0),(0,s.addListeners)(window,c,this._trackMotion,!0)),this._addDown(u+":"+r.buttonName),this._resetSeqTimeout(),this.filter(t)&&(n=this._triggerWithSelectors(u+h,[t]),void 0!==r.buttonName&&(u+=":"+r.buttonName,n=n.concat(this._triggerWithSelectors(u+h,[t]))),n=n.concat(this._handleDownEvents(t)),(0,s.handlePreventDefault)(t,n))}},t.prototype._pointerup=function(t){var e,n,i,r,a=this.state,l=this.settings.moveThreshold,u=t.clientX,h=t.clientY,p=a.pointers,d={},f=t.changedTouches,g=t.pointerType,v=this.settings.swipeThreshold,m="pointer:",w=this.filter(t);if("mouseup"==t.type&&o)return void(o=!1);if(g||"mouseup"==t.type)e=t.pointerId||1;else if(f&&f.length)for(var y=0;y<f.length;y++)e=f[y].identifier,u=f[y].clientX,h=f[y].clientY;p[e]&&(d.x=p[e].x-u,d.y=p[e].y-h),this._resetSeqTimeout(),w&&(r=this._triggerWithSelectors(m+"up",[t]),n=this.mouse(t),void 0!==n.buttonName?m+=n.buttonName:m+="left",r=r.concat(this._triggerWithSelectors(m+":up",[t])),i="swipe:",Math.abs(d.x)>Math.abs(d.y)?d.x>v?i+="left":d.x<-v&&(i+="right"):d.y>v?i+="up":d.y<-v&&(i+="down")),o=!1,delete p[e],a.pointerCount--,a.pointerCount>0?d.x<l&&d.y<l?a.multitap++:a.multitap=0:(a.multitap?(i="multitouch:"+(a.multitap+1)+":tap",r=this._triggerWithSelectors(i,[t]),this._removeDown(m),this._addDown(i),w&&(r=r.concat(this._handleDownEvents(t)),this._handleSeqEvents(t)),this._removeDown(i),a.multitap=0):"swipe:"!=i?(this._removeDown(m),this._addDown(i),w&&(r=r.concat(this._handleDownEvents(t)),this._handleSeqEvents(t)),this._removeDown(i)):(w&&this._handleSeqEvents(t),this._removeDown(m)),(0,s.handlePreventDefault)(t,r),(0,s.removeListeners)(window,c,this._trackMotion,!0))},t.prototype._pointercancel=function(t){var e,n=this.state,i=n.pointers,o=t.changedTouches,r=t.pointerType,a=this.mouse(t);if(r||t.type.includes("mouse"))e=t.pointerId||1,i[e]&&delete i[e];else if(o&&o.length){for(var l=0;l<o.length;l++)e=o[l].identifier,i[e]&&delete i[e];a.buttonName="left"}this._removeDown("pointer:"+a.buttonName),--n.pointerCount||(0,s.removeListeners)(window,c,this._trackMotion,!0)},t.prototype._click=function(t){var e=t.type,n=t.detail;if(2===n?e="dblclick":3===n&&(e="tripleclick"),this._resetSeqTimeout(),this.filter(t)){var i=this._triggerWithSelectors(e,[t]);(0,s.handlePreventDefault)(t,i)}},t.prototype._wheel=function(t){var e="wheel";if(this._resetSeqTimeout(),this.filter(t)){var n=this._triggerWithSelectors(e,[t]);t.deltaY>0?n=n.concat(this._doDownEvent("wheel:down",t)):t.deltaY<0&&(n=n.concat(this._doDownEvent("wheel:up",t))),t.deltaZ>0?n=n.concat(this._doDownEvent("wheel:out",t)):t.deltaZ<0&&(n=n.concat(this._doDownEvent("wheel:in",t))),t.deltaX>0?(n=n.concat(this._doDownEvent("wheel:right",t)),this.isDown("shift")&&(n=n.concat(this._triggerWithSelectors("wheel:right",[t])))):t.deltaX<0&&(n=n.concat(this._doDownEvent("wheel:left",t)),this.isDown("shift")&&(n=n.concat(this._triggerWithSelectors("wheel:left",[t])))),(0,s.handlePreventDefault)(t,n)}},t.prototype.mouse=function(t){var e={type:t.type};return"mousemove"!=t.type&&"wheel"!=t.type&&(0===t.button?(e.left=!0,e.buttonName="left"):1===t.button?(e.middle=!0,e.buttonName="middle"):2===t.button?(e.right=!0,e.buttonName="right"):3===t.button?(e.back=!0,e.buttonName="back"):4===t.button?(e.forward=!0,e.buttonName="forward"):5===t.button?(e.forward=!0,e.buttonName="eraser"):e.buttonName=t.button),e.button=t.button,e},t}();a.default.plugins.push(u)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.ScrollPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("scroll");var a=e.ScrollPlugin=function(){function t(e){i(this,t),this.HI=e,e._scroll=(0,o.debounce)(this._scroll.bind(e),50),e.on("hi:resetstates",this._resetStates,e)}return t.prototype.init=function(t){var e=t.state;return e.scrollX=0,e.scrollY=0,this},t.prototype._resetStates=function(){this.state.scrollX=0,this.state.scrollY=0},t.prototype._scroll=function(t){var e,n,i,s=this.state,r=t.target,a=r.scrollLeft,l=r.scrollTop;r.scrollingElement&&(a=r.scrollingElement.scrollLeft,l=r.scrollingElement.scrollTop),n=a-s.scrollX,0===(i=l-s.scrollY)&&0===n||(e=this._triggerWithSelectors(t.type,[t,{x:n,y:i}]),void 0!==a&&a!==s.scrollX&&(n=Math.abs(n),e=a>s.scrollX?e.concat(this._triggerWithSelectors(t.type+":right",[t,n])):e.concat(this._triggerWithSelectors(t.type+":left",[t,n])),s.scrollX=a),void 0!==l&&l!==s.scrollY&&(i=Math.abs(i),e=l>s.scrollY?e.concat(this._triggerWithSelectors(t.type+":down",[t,i])):e.concat(this._triggerWithSelectors(t.type+":up",[t,i])),s.scrollY=l),(0,o.handlePreventDefault)(t,e))},t}();r.default.plugins.push(a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.SpeechRecPlugin=void 0;var o=n(1),s=n(2),r=function(t){return t&&t.__esModule?t:{default:t}}(s);r.default.defaultListenEvents.push("speech");var a=window.SpeechRecognition||window.webkitSpeechRecognition||window.mozSpeechRecognition||window.msSpeechRecognition||window.oSpeechRecognition,l=e.SpeechRecPlugin=function(){function t(e){return i(this,t),this.exports={startSpeechRec:this.startSpeechRec.bind(this),stopSpeechRec:this.stopSpeechRec.bind(this)},this.HI=e,this.l=e.l,this.log=new e.Logger(e.settings.logLevel||"INFO","[HI SpeechRec]"),this._rtSpeech=[],this._rtSpeechTimer=null,this}return t.prototype.init=function(){var t=this,e=this.HI,n=e.settings;return n.autostartSpeech=n.autostartSpeech||!1,n.listenEvents.includes("speech")&&(a?(n.autostartSpeech&&this.startSpeechRec(),e.on("document:hidden",function(){t._started&&t.stopSpeechRec()}),e.on("document:visible",function(){!t._started&&n.autostartSpeech&&t.startSpeechRec()})):(this.startSpeechRec=o.noop,this.stopSpeechRec=o.noop)),this},t.prototype.startSpeechRec=function(){var t=this,e=this.HI;this._recognition=new a,this.log.debug(this.l("Starting speech recognition"),this._recognition),this._recognition.lang=e.settings.speechLang||navigator.language||"en-US",this._recognition.continuous=!0,this._recognition.interimResults=!0,this._recognition.onresult=function(e){for(var n=e.resultIndex;n<e.results.length;++n){var i="speech",o=e.results[n][0].transcript.trim();e.results[n].isFinal?(t.HI._addDown(i),t.HI._handleDownEvents(e,o),t.HI._removeDown(i),i+=':"'+o.replace(/-/g,"–")+'"',t.HI._addDown(i),t.HI._handleDownEvents(e,o),t.HI._handleSeqEvents(),t.HI._removeDown(i)):(i+=":rt",t.HI._addDown(i),t.HI._handleDownEvents(e,o),t.HI._removeDown(i),i+=':"'+o.replace(/-/g,"–")+'"',-1==t._rtSpeech.indexOf(i)&&(t._rtSpeech.push(i),t.HI._addDown(i),t.HI._handleDownEvents(e,o),t.HI._removeDown(i)))}},this._started=!0,this._recognition.start()},t.prototype.stopSpeechRec=function(){this.log.debug(this.l("Stopping speech recognition")),this._recognition.stop(),this._started=!1},t}();r.default.plugins.push(l)},function(t,e,n){(function(e){t.exports=e.HumanInput=n(16)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(17)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(18)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(19)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(15)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(20)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(21)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(22)}).call(e,n(0))},function(t,e,n){(function(e){t.exports=e.HumanInput=n(23)}).call(e,n(0))}])});