define(["exports","./../../dom.js","./../../layoutmanager.js","./../../actionsheet/actionsheet.js","./../../focusmanager.js"],function(_exports,_dom,_layoutmanager,_actionsheet,_focusmanager){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;var ActionSheet=_actionsheet.default.constructor;function onFocus(){var _this$labelElement;document.attachIME&&document.attachIME(this),null!=(_this$labelElement=this.labelElement)&&_this$labelElement.classList.add("inputLabelFocused")}function onBlur(){var _this$labelElement2;null!=(_this$labelElement2=this.labelElement)&&_this$labelElement2.classList.remove("inputLabelFocused")}function destroyActionSheet(elem){clearInputTimer(elem);var actionsheet=elem.actionsheet;actionsheet&&(actionsheet.isShowing()&&actionsheet.close(),actionsheet.destroy(),elem.actionsheet=null)}function clearInputTimer(elem){elem.inputTimeout&&clearTimeout(elem.inputTimeout)}function onInput(){clearInputTimer(this);var value=this.value.trim();!value||value.length<2?destroyActionSheet(this):this.inputTimeout=setTimeout(function(){var options,refocus,elem=this,value=elem.value.trim();if(console.log("onInputTimeout: "+value),!value||value.length<2)destroyActionSheet(elem);else{if(!elem.actionsheet)return value=new ActionSheet,elem.actionsheet=value,options={getItems:elem.getItems,enableVirtualScroller:!1,positionTo:elem,resolveWithSelectedItem:!0,hasItemIcon:!0,iconRight:!1,fields:["Name","Type","ParentName"],dialogClass:"emby-input-actionsheet",offsetTop:2,refocus:!1,artist:!1,enableDefaultIcon:!0,imageSize:"small",hasItemImage:!0,setCurrentFocusScope:!1},_layoutmanager.default.tv||(options.positionY="bottom",options.positionX="match",options.transformOrigin="center top",options.minWidthToElement=!0),refocus="false"!==elem.getAttribute("data-refocus"),elem.dispatchEvent(new CustomEvent("selectionopen",{bubbles:!1,cancelable:!1,detail:{}})),value.show(options).then(function(item){elem.value=item.Name,elem.dispatchEvent(new CustomEvent("itemselected",{bubbles:!1,cancelable:!1,detail:{item:item}})),refocus&&_focusmanager.default.focus(elem),elem.dispatchEvent(new CustomEvent("selectionclose",{bubbles:!1,cancelable:!1,detail:{}})),destroyActionSheet(elem)},function(){elem.dispatchEvent(new CustomEvent("selectioncancel",{bubbles:!1,cancelable:!1,detail:{}})),refocus&&_focusmanager.default.focus(elem),elem.dispatchEvent(new CustomEvent("selectionclose",{bubbles:!1,cancelable:!1,detail:{}})),destroyActionSheet(elem)});elem.actionsheet.refreshItems()}}.bind(this),400)}require(["css!modules/emby-elements/emby-input/emby-input.css"]);var inputId=0;function onInit(){var label,parentNode=this.parentNode;parentNode&&(this.hasInit||(this.hasInit=!0,this.id||(this.id="embyinput"+inputId,inputId++),this.classList.contains("emby-input"))?this.labelElement&&(this.labelElement.htmlFor=this.id):(this.classList.add("emby-input"),_layoutmanager.default.tv&&this.classList.add("emby-input-tv"),(label=this.ownerDocument.createElement("label")).innerHTML=this.getAttribute("label")||"",label.classList.add("inputLabel"),label.htmlFor=this.id,parentNode.insertBefore(label,this),this.labelElement=label,_dom.default.addEventListener(this,"focus",onFocus,{passive:!0}),_dom.default.addEventListener(this,"blur",onBlur,{passive:!0}),"true"===this.getAttribute("data-autocompleteitems")&&_dom.default.addEventListener(this,"input",onInput,{passive:!0})))}function roundMsToStep(ms,step){return step=step||1,step*=1e3,ms-ms%(step=Math.floor(step))}var supportsValueAsNumber=void 0!==document.createElement("input").valueAsNumber,supportsValueAsDate=void 0!==document.createElement("input").valueAsDate;function pad(num,size){for(var s=num+"";s.length