define(["dom","focusManager","css!./alphanumericshortcuts"],function(dom,focusManager){"use strict";var inputDisplayElement,alpanumericShortcutTimeout,currentDisplayText="";function onKeyDown(e){var options,tagName,key,chr;e.ctrlKey||e.shiftKey||e.altKey||(options=this.options)&&options.focusScope===focusManager.getCurrentScope()&&"INPUT"!==(tagName=e.target.tagName)&&"TEXTAREA"!==tagName&&(chr=(key=e.key)?key.match(/^[0-9a-zA-Z]+$/):null)&&1===(chr=chr.toString().toUpperCase()).length&&(options.itemsContainer,function(instance,chr){if(3<=currentDisplayText.length)return;inputDisplayElement||((inputDisplayElement=document.createElement("div")).classList.add("alphanumeric-shortcut"),inputDisplayElement.classList.add("hide"),document.body.appendChild(inputDisplayElement)),currentDisplayText+=chr,inputDisplayElement.innerHTML=currentDisplayText,inputDisplayElement.classList.remove("hide"),function(instance){clearAlphaNumericShortcutTimeout(),alpanumericShortcutTimeout=setTimeout(function(){var value=currentDisplayText;currentDisplayText="",inputDisplayElement.innerHTML="",inputDisplayElement.classList.add("hide"),clearAlphaNumericShortcutTimeout(),function(instance,value){if(instance.onAlphaNumericValueEntered&&instance.onAlphaNumericValueEntered(value));}(this,value)}.bind(instance),2e3)}(instance)}(this,chr))}function clearAlphaNumericShortcutTimeout(){alpanumericShortcutTimeout&&(clearTimeout(alpanumericShortcutTimeout),alpanumericShortcutTimeout=null)}function AlphaNumericShortcuts(options){(this.options=options).focusScope=focusManager.getCurrentScope(),this.keyDownHandler=onKeyDown.bind(this),this.addEventListeners()}return AlphaNumericShortcuts.prototype.addEventListeners=function(){var keyDownHandler;this._eventHandlersBound||(this._eventHandlersBound=!0,(keyDownHandler=this.keyDownHandler)&&dom.addEventListener(window,"keydown",keyDownHandler,{passive:!0}))},AlphaNumericShortcuts.prototype.removeEventListeners=function(){this._eventHandlersBound=null;var keyDownHandler=this.keyDownHandler;keyDownHandler&&dom.removeEventListener(window,"keydown",keyDownHandler,{passive:!0})},AlphaNumericShortcuts.prototype.pause=function(){this.removeEventListeners()},AlphaNumericShortcuts.prototype.resume=function(){this.addEventListeners()},AlphaNumericShortcuts.prototype.destroy=function(){this.removeEventListeners(),this.keyDownHandler=null,this.options=null},AlphaNumericShortcuts});