-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathgladius-input.min.js
14 lines (11 loc) · 20.5 KB
/
gladius-input.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
Copyright (c) 2011-2012, Mozilla Foundation
Copyright (c) 2011-2012, Alan Kligman
Copyright (c) 2011-2012, Robert Richter
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the Mozilla Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/(function(a,b){if(typeof exports=="object")module.exports=b();else if(typeof define=="function"&&define.amd)define(b);else{if(!a.Gladius)throw new Error("failed to load gladius-input; depends on Gladius");a.Gladius["gladius-input"]=b()}})(this,function(){var a,b,c;(function(d){function l(a,b){var c=b&&b.split("/"),d=g.map,e=d&&d["*"]||{},f,h,i,j,k,l,m;if(a&&a.charAt(0)==="."&&b){c=c.slice(0,c.length-1),a=c.concat(a.split("/"));for(k=0;m=a[k];k++)if(m===".")a.splice(k,1),k-=1;else if(m===".."){if(k===1&&(a[2]===".."||a[0]===".."))return!0;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}if((c||e)&&d){f=a.split("/");for(k=f.length;k>0;k-=1){h=f.slice(0,k).join("/");if(c)for(l=c.length;l>0;l-=1){i=d[c.slice(0,l).join("/")];if(i){i=i[h];if(i){j=i;break}}}j=j||e[h];if(j){f.splice(0,k,j),a=f.join("/");break}}}return a}function m(a,b){return function(){return k.apply(d,i.call(arguments,0).concat([a,b]))}}function n(a){return function(b){return l(b,a)}}function o(a){return function(b){e[a]=b}}function p(a){if(f.hasOwnProperty(a)){var b=f[a];delete f[a],h[a]=!0,j.apply(d,b)}if(!e.hasOwnProperty(a))throw new Error("No "+a);return e[a]}function q(a,b){var c,d,e=a.indexOf("!");return e!==-1?(c=l(a.slice(0,e),b),a=a.slice(e+1),d=p(c),d&&d.normalize?a=d.normalize(a,n(b)):a=l(a,b)):a=l(a,b),{f:c?c+"!"+a:a,n:a,p:d}}function r(a){return function(){return g&&g.config&&g.config[a]||{}}}var e={},f={},g={},h={},i=[].slice,j,k;j=function(a,b,c,g){var i=[],j,k,l,n,s,t;g=g||a;if(typeof c=="function"){b=!b.length&&c.length?["require","exports","module"]:b;for(t=0;t<b.length;t++){s=q(b[t],g),l=s.f;if(l==="require")i[t]=m(a);else if(l==="exports")i[t]=e[a]={},j=!0;else if(l==="module")k=i[t]={id:a,uri:"",exports:e[a],config:r(a)};else if(e.hasOwnProperty(l)||f.hasOwnProperty(l))i[t]=p(l);else if(s.p)s.p.load(s.n,m(g,!0),o(l),{}),i[t]=e[l];else if(!h[l])throw new Error(a+" missing "+l)}n=c.apply(e[a],i);if(a)if(k&&k.exports!==d&&k.exports!==e[a])e[a]=k.exports;else if(n!==d||!j)e[a]=n}else a&&(e[a]=c)},a=b=k=function(a,b,c,e){return typeof a=="string"?p(q(a,b).f):(a.splice||(g=a,b.splice?(a=b,b=c,c=null):a=d),b=b||function(){},e?j(d,a,b,c):setTimeout(function(){j(d,a,b,c)},15),k)},k.config=function(a){return g=a,k},c=function(a,b,c){b.splice||(c=b,b=[]),f[a]=[a,b,c]},c.amd={jQuery:!0}})(),c("../tools/almond",function(){});if(typeof c!="function")var c=b("amdefine")(module);c("base/extension",["require"],function(a){var b=function(a,b){if(typeof a!="string"||a.length===0)throw new Error("extension needs a non-trivial name");this.name=a,b=b||{};var c,d,e,f,g,h,i,j,k,l,m,n,o;this.services={};if(b.hasOwnProperty("services")){c=Object.keys(b.services);for(l=0,m=c.length;l<m;++l){d=c[l],e=b.services[d];if(typeof e=="function")this.services[d]=e;else{if(typeof e!="object")throw new Error("malformed extension");this.services[d]={},this.services[d].service=e.service;if(e.hasOwnProperty("components")){this.services[d].components={},f=Object.keys(e.components);for(n=0,o=f.length;n<o;++n)g=f[n],this.services[d].components[g]=e.components[g]}if(e.hasOwnProperty("resources")){this.services[d].resources={},i=Object.keys(e.resources);for(n=0,o=i.length;n<o;++n)j=i[n],this.services[d].resources[j]=e.resources[j]}}}}this.components={},b.hasOwnProperty("components")&&(this.components=b.components),this.resources={},b.hasOwnProperty("resources")&&(this.resources=b.resources)};return b});if(typeof c!="function")var c=b("amdefine")(module);c("common/guid",["require"],function(a){function b(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=Math.random()*16|0,c=a=="x"?b:b&3|8;return c.toString(16)}).toUpperCase()}return b}),function(a){a("when",[],function(){function d(){}function e(a){return new Array(a)}function f(){}function g(b){var d=new f;return d.then=function(a){i(arguments);var d;try{return a&&(d=a(b)),m(d===c?b:d)}catch(e){return h(e)}},a(d)}function h(b){var d=new f;return d.then=function(a,d){i(arguments);var e;try{return d?(e=d(b),m(e===c?b:e)):h(b)}catch(f){return h(f)}},a(d)}function i(a){var b,c=a.length;while(c){b=a[--c];if(b!=null&&typeof b!="function")throw new Error("callback is not a function")}}function j(){function o(a,b,c){return l(a,b,c)}function p(a){n(g(a))}function q(a){n(h(a))}function r(a){m(a)}var b,d,e,k,l,m,n;return e=[],k=[],l=function(b,c,d){i(arguments);var f=j();return e.push(function(a){a.then(b,c).then(f.resolve,f.reject,f.progress)}),d&&k.push(d),f.promise},m=function(a){var b,c=0;while(b=k[c++])b(a)},n=function(a){var b,d=0;l=a.then,n=m=function(){throw new Error("already completed")},k=c;while(b=e[d++])b(a);e=[]},b={},d=new f,d.then=b.then=o,b.promise=a(d),b.resolver=a({resolve:b.resolve=p,reject:b.reject=q,progress:b.progress=r}),b}function k(a){return a&&typeof a.then=="function"}function l(a,b,c,d){var e=m(a);return e.then(b,c,d)}function m(a){var b,c;return a instanceof f?b=a:(c=j(),k(a)?(a.then(c.resolve,c.reject,c.progress),b=c.promise):(c.resolve(a),b=c.promise)),b}function n(a,b,c,e,f){function r(a){m(a)}function s(a){n(a)}function t(a){o(a)}function u(){m=n=o=d}var g,h,i,k,m,n,o,p,q;p=a.length>>>0,g=Math.max(0,Math.min(b,p)),h=[],k=j(),i=l(k,c,e,f);if(!g)k.resolve(h);else{m=function(a){h.push(a),--g||(u(),k.resolve(h))},n=function(a){u(),k.reject(a)},o=k.progress;for(q=0;q<p;++q)q in a&&l(a[q],r,s,t)}return i}function o(a,b,c,d){var f,g;return f=e(a.length),g=s(a,p,f),l(g,b,c,d)}function p(a,b,c){return a[c]=b,a}function q(a,b,c,d){function e(a){return b(a[0])}return n(a,1,e,c,d)}function r(a,b){var c,d;d=a.length,c=e(d);for(;d>=0;--d)d in a&&(c[d]=l(a[d],b));return s(c,p,c)}function s(a,c,d){var e,f;return e=a.length,f=[function(a,b,d){return l(a,function(a){return l(b,function(b){return c(a,b,d,e)})})}],arguments.length>=3&&f.push(d),m(b.apply(a,f))}function t(a,b,c){var d=arguments.length>2;return l(a,function(a){return d&&(a=c),b.resolve(a),a},function(a){return b.reject(a),h(a)},b.progress)}var a,b,c;return a=Object.freeze||function(a){return a},b=[].reduce||function(a){var b,c,d,e,f;f=0,b=Object(this),e=b.length>>>0,c=arguments;if(c.length<=1)for(;;){if(f in b){d=b[f++];break}if(++f>=e)throw new TypeError}else d=c[1];for(;f<e;++f)f in b&&(d=a(d,b[f],f,b));return d},l.defer=j,l.isPromise=k,l.some=n,l.all=o,l.any=q,l.reduce=s,l.map=r,l.chain=t,l})}(typeof c=="function"?c:function(a){typeof module!="undefined"?module.exports=a():this.when=a()});if(typeof c!="function")var c=b("amdefine")(module);c("core/function-task",["require","common/guid","when"],function(a){function o(a){this._schedule=a||this._schedule;if(this._taskState!==g)throw new Error("task is already started or completed");return this._taskState=f,this._runState!==k&&this._scheduler.insert(this,this.id,this._schedule),this}function p(){if(this._runState===j)throw new Error("task can only be paused while blocked");return this._taskState=g,this._scheduler.remove(this.id),this}function q(){if(this._runState===j)throw new Error("tasks can only be cancelled while blocked");return this._taskState=h,this._scheduler.insert(this,this.id),this}function r(){return this._taskState===f}function s(){return this._runState===j}function t(){return this._taskState===i}function u(){var a=this,b=a.result;a.result=undefined,a._scheduler.current=a;try{a._runState=j;if(a._taskState===h)a._runState=l,a._taskState=i;else{if(a._taskState!==f)throw Error("task is not runnable");b=a._thunk.call(this._context,b),a._runState=k,b instanceof d?(a.result=b.value,a._taskState=i,a._runState=l,a._deferred.resolve(a.result)):a.result=c(b,function(b){a.result=b,a._runState=l,a._taskState===f&&a._scheduler.insert(a,a.id,a._schedule)},function(b){a.result=b,a._runState=m,a._threadState===f&&a._scheduler.insert(a,a.id,a._schedule)})}}catch(e){a.result=e,a._runState=m,a._deferred.reject(e)}return a._scheduler.current=null,this}function v(){return"[object FunctionTask "+this.id+"]"}var b=a("common/guid"),c=a("when"),d=function(a){if(!(this instanceof d))return new d(a);this.value=a},e=function(){if(!(this instanceof e))return new e;this.tags=[],this.dependsOn=[]},f=0,g=1,h=2,i=3,j=0,k=1,l=2,m=3,n=function(a,d,f,h){this.id=b(),this._thunk=d,this._taskState=g,this._runState=l,this._scheduler=a,this._schedule=f||e(),this.result=undefined,this._deferred=c.defer(),this.then=this._deferred.promise.then,this._context=h||this};return n.prototype={pause:p,start:o,cancel:q,isStarted:r,isRunning:s,isComplete:t,toString:v,run:u,when:c,Complete:d},n});if(typeof c!="function")var c=b("amdefine")(module);c("base/service",["require","core/function-task"],function(a){function d(a,b){return this._registeredComponents.hasOwnProperty(b.type)||(this._registeredComponents[b.type]={}),this._registeredComponents[b.type][a]=b,this}function e(a,b){return this._registeredComponents.hasOwnProperty(b.type)&&this._registeredComponents[b.type].hasOwnProperty(a)&&delete this._registeredComponents[b.type][a],this}function f(){var a,b,c=Object.keys(this._tasks);for(a=0,b=c.length;a<b;++a){var d=c[a];this._tasks[d].pause()}return this}function g(){var a,b,c=Object.keys(this._tasks);for(a=0,b=c.length;a<b;++a){var d=c[a],e=this._schedules[d]||{};this._tasks[d].start(e)}return this}function h(a){var b,c;if("on"+a.type in this){var d=this["on"+a.type];try{d.call(this,a)}catch(e){console.log(e)}}}var b=a("core/function-task"),c=function(a,c,d){this._schedules=c||{},this.dependsOn=d||[],this._tasks={},this._registeredComponents={};if(a){var e,f,g=Object.keys(this._schedules);for(e=0,f=g.length;e<f;++e){var h=g[e];if(!this[h])throw new Error("missing scheduler target: "+h);var i=this._schedules[h]||{};this._tasks[h]=new b(a,this[h],i,this),this._tasks[h].start()}}};return c.prototype={registerComponent:d,unregisterComponent:e,suspend:f,resume:g,handleEvent:h},c});if(typeof c!="function")var c=b("amdefine")(module);c("core/event",["require"],function(a){function b(){var a=Array.prototype.slice.call(arguments,0),b,c;a.length>0&&Array.isArray(a[0])&&(a=a[0]);for(b=0,c=a.length;b<c;++b)try{var d=a[b];d.handleEvent&&d.handleEvent.call(d,this)}catch(e){console.log(e)}}var c=function(a,c,d){if(undefined===a||a.length<1)throw new Error("event must have a non-trivial type");this.type=a,this.data=c,undefined===d&&(d=!0),this.queue=d,this.dispatch=b.bind(this)};return c});if(typeof c!="function")var c=b("amdefine")(module);c("src/services/DOMKeyMapper",["require"],function(a){function b(){this.keys=[],this._keyCodes.forEach(function(a){var b=a[0],c=a[1];this.keys[c]=b}.bind(this))}function c(a){return this.keys[a]}return b.prototype._keyCodes=[["BACK",8],["TAB",9],["CLEAR",12],["RETURN",13],["SHIFT",16],["CONTROL",17],["MENU",18],["PAUSE",19],["CAPITAL",20],["KANA",21],["HANGUL",21],["JUNJA",23],["FINAL",24],["HANJA",25],["KANJI",25],["ESCAPE",27],["CONVERT",28],["NONCONVERT",29],["ACCEPT",30],["MODECHANGE",31],["SPACE",32],["PRIOR",33],["NEXT",34],["END",35],["HOME",36],["LEFT",37],["UP",38],["RIGHT",39],["DOWN",40],["SELECT",41],["PRINT",42],["EXECUTE",43],["SNAPSHOT",44],["INSERT",45],["DELETE",46],["HELP",47],["0",48],["1",49],["2",50],["3",51],["4",52],["5",53],["6",54],["7",55],["8",56],["9",57],["A",65],["B",66],["C",67],["D",68],["E",69],["F",70],["G",71],["H",72],["I",73],["J",74],["K",75],["L",76],["M",77],["N",78],["O",79],["P",80],["Q",81],["R",82],["S",83],["T",84],["U",85],["V",86],["W",87],["X",88],["Y",89],["Z",90],["LWIN",91],["RWIN",92],["APPS",93],["SLEEP",95],["NUMPAD0",96],["NUMPAD1",97],["NUMPAD2",98],["NUMPAD3",99],["NUMPAD4",100],["NUMPAD5",101],["NUMPAD6",102],["NUMPAD7",103],["NUMPAD8",104],["NUMPAD9",105],["MULTIPLY",106],["ADD",107],["SEPARATOR",108],["SUBTRACT",109],["DECIMAL",110],["DIVIDE",111],["F1",112],["F2",113],["F3",114],["F4",115],["F5",116],["F6",117],["F7",118],["F8",119],["F9",120],["F10",121],["F11",122],["F12",123],["F13",124],["F14",125],["F15",126],["F16",127],["F17",128],["F18",129],["F19",130],["F20",131],["F21",132],["F22",133],["F23",134],["F24",135],["NUMLOCK",144],["SCROLL",145],["LSHIFT",160],["RSHIFT",161],["LCONTROL",162],["RCONTROL",163],["LMENU",164],["RMENU",165],["BROWSER_BACK",166],["BROWSER_FORWARD",167],["BROWSER_REFRESH",168],["BROWSER_STOP",169],["BROWSER_SEARCH",170],["BROWSER_FAVORITES",171],["BROWSER_HOME",172],["VOLUME_MUTE",173],["VOLUME_DOWN",174],["VOLUME_UP",175],["MEDIA_NEXT_TRACK",176],["MEDIA_PREV_TRACK",177],["MEDIA_STOP",178],["MEDIA_PLAY_PAUSE",179],["MEDIA_LAUNCH_MAIL",180],["MEDIA_LAUNCH_MEDIA_SELECT",181],["MEDIA_LAUNCH_APP1",182],["MEDIA_LAUNCH_APP2",183],["OEM_1",186],["OEM_PLUS",187],["OEM_COMMA",188],["OEM_MINUS",189],["OEM_PERIOD",190],["OEM_2",191],["OEM_3",192],["OEM_4",219],["OEM_5",220],["OEM_6",221],["OEM_7",222],["OEM_8",223],["OEM_102",226],["PROCESSKEY",229],["PACKET",231],["ATTN",246],["CRSEL",247],["EXSEL",248],["EREOF",249],["PLAY",250],["ZOOM",251],["NONAME",252],["PA1",253],["OEM_CLEAR",254],["UNKNOWN",0]],b.prototype.getKeyName=c,b});if(typeof c!="function")var c=b("amdefine")(module);c("src/services/dispatcher",["require","base/service","core/event","src/services/DOMKeyMapper"],function(a){function f(){var a=this._registeredComponents.Controller,b=Object.keys(a),d,e,f,g,h,i,j,k;for(h=0,i=this._queue.length;h<i;++h){d=this._queue[h],f=d.which?d.which:d.keyCode,e=this.DOMKeyMapper.getKeyName(f);if(d.type==="keydown")g=new c("KeyDown",e);else{if(d.type!=="keyup")throw new Error("A DOM event type was encountered which was not keydown or keyup in dispatcher");g=new c("KeyUp",e)}for(j=0,k=b.length;j<k;++j)g.dispatch(a[b[j]])}this._queue=[];var l,m,n=this._registeredComponents,o=new c("Update",undefined,!1);for(var p in n)for(m in n[p]){l=n[p][m];while(l.handleQueuedEvent());o.dispatch(l)}}var b=a("base/service"),c=a("core/event"),d=a("src/services/DOMKeyMapper"),e=function(a,c){function g(a){f._queue.push(a)}c=c||{};var e={dispatch:{tags:["@input"],dependsOn:[]}};b.call(this,a,e),"element"in c?this.element=c.element:this.element=document,this.DOMKeyMapper=new d,this._queue=[];var f=this;this.element.addEventListener("keydown",g,!1),this.element.addEventListener("keyup",g,!1)};return e.prototype=new b,e.prototype.constructor=e,e.prototype.dispatch=f,e});if(typeof c!="function")var c=b("amdefine")(module);c("common/extend",["require"],function(a){function b(a,b){for(var c in b)!a.hasOwnProperty(c)&&b.hasOwnProperty(c)&&(a[c]=b[c]);return a}return b});if(typeof c!="function")var c=b("amdefine")(module);c("base/component",["require","core/event"],function(a){function d(a){if(a!==this.owner){var c=this.owner;this.owner=a;var d=new b("ComponentOwnerChanged",{current:a,previous:c},!1);d.dispatch(this)}}function e(a){if("on"+a.type in this)if(a.queue)this._queuedEvents.push(a);else{var b=this["on"+a.type];try{b.call(this,a)}catch(c){console.log(c)}}}function f(){if(this._queuedEvents.length>0){var a=this._queuedEvents.shift();if("on"+a.type in this){var b=this["on"+a.type];try{b.call(this,a)}catch(c){console.log(c)}}}return this._queuedEvents.length}var b=a("core/event"),c=function(a,b,c){this.type=a,this.provider=b,this.dependsOn=c||[],this.owner=null,this._queuedEvents=[]};return c.prototype={setOwner:d,handleEvent:e,handleQueuedEvent:f},c});if(typeof c!="function")var c=b("amdefine")(module);c("src/resources/map",["require"],function(a){var b=function(a){a=a||{},typeof a=="string"&&(a=JSON.parse(a)),this.States=undefined!==a.States?a.States:{},this.Actions=undefined!==a.Actions?a.Actions:{},this._validate()};return b.prototype={_validate:function(){this._validateSubmap(this.Actions,"action"),this._validateSubmap(this.States,"state")},_validateSubmap:function(b,c){var d,e,f=Object.keys(b);for(e=0,d=f.length;e<d;++e)if(typeof b[f[e]]!="string"){if(!Array.isArray(b[f[e]]))throw new Error("map contains "+c+" "+f[e]+" that is not a string or array");var g,h,i=b[f[e]];if(i.length===0)throw new Error("map contains a(n) "+c+" array called "+f[e]+" of length 0");for(g=0,h=i.length;g<h;++g)if(typeof i[g]!="string")throw new Error("map contains "+c+" "+i[g]+" in a(n) "+c+" array. That "+c+" is not a string and the map is invalid as a result")}}},b});if(typeof c!="function")var c=b("amdefine")(module);c("src/components/controller",["require","common/extend","base/component","src/resources/map","core/event"],function(a){function g(a,b,c){var d=a[b];undefined===d?a[b]=c:typeof d=="string"?a[b]=[d,c]:a[b][d.length]=c}function h(a){}function i(a){var b=a.data;if(undefined!==this._stateMapping[b])if(Array.isArray(this._stateMapping[b])){var c,d;for(c=0,d=this._stateMapping[b].length;c<d;++c)this.states[this._stateMapping[b][c]]=!0;if(this.owner)for(c=0,d=this._stateMapping[b].length;c<d;++c)this.owner.handleEvent(new e(this._stateMapping[b][c],!0))}else this.states[this._stateMapping[b]]=!0,this.owner&&this.owner.handleEvent(new e(this._stateMapping[b],!0));if(undefined!==this._actionMapping[b])if(Array.isArray(this._actionMapping[b]))for(var c=0,d=this._actionMapping[b].length;c<d;++c)this.owner.handleEvent(new e(this._actionMapping[b][c]));else this.owner&&this.owner.handleEvent(new e(this._actionMapping[b]))}function j(a){var b=a.data;if(undefined!==this._stateMapping[b])if(Array.isArray(this._stateMapping[b])){var c,d;for(c=0,d=this._stateMapping[b].length;c<d;++c)this.states[this._stateMapping[b][c]]=!1;if(this.owner)for(c=0,d=this._stateMapping[b].length;c<d;++c)this.owner.handleEvent(new e(this._stateMapping[b][c],!1))}else this.states[this._stateMapping[b]]=!1,this.owner&&this.owner.handleEvent(new e(this._stateMapping[b],!1))}function k(a){var b=a.data;b.previous===null&&b.current!==null&&this.owner!==null&&this.provider.registerComponent(this.owner.id,this),b.previous!==null&&b.current===null&&this.owner!==null&&this.provider.unregisterComponent(this.owner.id,this)}function l(a){var b=a.data;b.previous===null&&this.owner!==null&&this.provider.registerComponent(this.owner.id,this),this.owner===null&&b.previous!==null&&this.provider.unregisterComponent(b.previous.id,this)}function m(a){var b=a.data;b?this.provider.registerComponent(this.owner.id,this):this.provider.unregisterComponent(this.owner.id,this)}var b=a("common/extend"),c=a("base/component"),d=a("src/resources/map"),e=a("core/event"),f=function(a,b){c.call(this,"Controller",a,[]);var e=this,f,g,h,i,j,k;this.map=undefined!==b?b:new d,this.states={},this._stateMapping={};var l=Object.keys(this.map.States);for(f=0,g=l.length;f<g;++f){var m=this.map.States[l[f]];if(Array.isArray(m))for(h=0,i=m.length;h<i;++h)this._mapKey(this._stateMapping,m[h],l[f]);else this._mapKey(this._stateMapping,m,l[f]);this.states[l[f]]=!1}this._actionMapping={};var n=Object.keys(this.map.Actions);for(j=0,k=n.length;j<k;++j){var m=this.map.Actions[n[j]];if(Array.isArray(m))for(h=0,i=m.length;h<i;++h)this._mapKey(this._actionMapping,m[h],n[j]);else this._mapKey(this._actionMapping,m,n[j])}};f.prototype=new c,f.prototype.constructor=f;var n={_mapKey:g,onKeyDown:i,onKeyUp:j,onUpdate:h,onEntitySpaceChanged:k,onComponentOwnerChanged:l,onEntityActivationChanged:m};return b(f.prototype,n),f});if(typeof c!="function")var c=b("amdefine")(module);c("../src/gladius-input",["require","base/extension","src/services/dispatcher","src/components/controller","src/resources/map"],function(a){var b=a("base/extension");return new b("gladius-input",{services:{dispatcher:{service:a("src/services/dispatcher"),components:{Controller:a("src/components/controller")},resources:{}}},components:{},resources:{Map:a("src/resources/map")}})});var d=b("../src/gladius-input");return d});