System.register(["./p-4f5dbe8b.system.js"],function(e){"use strict";var t,s,i,n;return{setters:[function(e){t=e.r;s=e.c;i=e.h;n=e.H}],execute:function(){var l=e("materials_autocomplete",function(){function e(e){t(this,e);this.dense=false;this.showSuggestions=false;this.selectedIndex=-1;this.change=s(this,"change",7)}e.prototype.componentDidLoad=function(){var e=this;this.watchValue();this.textElement.addEventListener("keydown",function(t){return e.navigateSuggestions(t)})};e.prototype.componentWillLoad=function(){this.watchValue()};e.prototype.watchValue=function(){if(this.value){this.value.label=this.value.label?this.value.label:this.value.value}else{this.value={value:null,label:null}}};e.prototype.navigateSuggestions=function(e){if(this.suggestions&&this.suggestions.size>0){var t=void 0;var s=Array.from(this.suggestions.keys());switch(e.key){case"ArrowDown":t=this.selectedIndex!==null?this.selectedIndex+1:0;if(t>=this.suggestions.size){t=0}this.selectedIndex=t;break;case"ArrowUp":t=this.selectedIndex!==null?this.selectedIndex-1:this.suggestions.size-1;if(t<0){t=this.suggestions.size-1}this.selectedIndex=t;break;case"Enter":if(this.selectedIndex===null){this.selectedIndex=0}this.selectSuggestion(s[this.selectedIndex]);this.change.emit(this.value);this.clearSuggestions();return;default:return}e.preventDefault()}};e.prototype.clearSuggestions=function(){this.selectedIndex=-1;this.suggestions=null};e.prototype.selectSuggestion=function(e){this.showSuggestions=false;if(this.suggestions){var t={value:e,label:this.suggestions.get(e)};this.value=Object.assign({},t)}};e.prototype.execAutocomplete=function(e){var t=this;this.value.label=e.target.value;this.autocomplete(e.target.value).then(function(e){return t.suggestions=e});this.showSuggestions=this.suggestions&&this.suggestions.size>0};e.prototype.handleChange=function(){if(!this.textElement.value){this.value=null;this.change.emit(this.value)}else{this.change.emit(this.value)}};e.prototype.render=function(){var e=this;return i(n,{style:{position:"relative"},onBlur:function(){e.change.emit(e.value);e.showSuggestions=false}},i("materials-text-field",{ref:function(t){return e.textElement=t},"trailing-icon":this.trailingIcon,dense:this.dense,label:this.label,focused:!!this.value.label,value:this.value.label,onInput:function(t){return e.execAutocomplete(t)},onChange:function(t){t.stopPropagation();t.preventDefault();e.handleChange()}}),this.showSuggestions&&i("materials-list",{style:{position:"absolute",top:this.textElement.getBoundingClientRect().bottom-this.textElement.getBoundingClientRect().top+"px"}},Array.from(this.suggestions.keys()).map(function(t,s){return s<e.maxSuggestions?i("materials-list-item",{selected:s===e.selectedIndex,onClick:function(){e.selectSuggestion(t);e.change.emit(e.value);e.clearSuggestions()},label:e.suggestions.get(t)}):null})))};Object.defineProperty(e,"watchers",{get:function(){return{value:["watchValue"]}},enumerable:true,configurable:true});Object.defineProperty(e,"style",{get:function(){return":host{display:block}materials-list{z-index:1;background-color:#fff;width:100%;overflow-y:visible;-webkit-box-shadow:0 2px 4px 0 #aaa;box-shadow:0 2px 4px 0 #aaa}"},enumerable:true,configurable:true});return e}())}}});