(function(e,t){e.widget("ui.combobox",{version:"@VERSION",widgetEventPrefix:"combobox",uiCombo:null,uiInput:null,_wasOpen:false,_create:function(){var t=this,n=this.element.hide(),r,i;r=this.uiInput=e("<input />").insertAfter(n).addClass("ui-widget ui-widget-content ui-corner-left ui-combobox-input").val(n.children(":selected").text()).attr("tabindex",n.attr("tabindex"));i=this.uiCombo=r.wrap("<span>").parent().addClass("ui-combobox").insertAfter(n);r.autocomplete({delay:0,minLength:0,appendTo:i,source:e.proxy(this,"_linkSelectList")});e("<button>").attr("tabIndex",-1).attr("type","button").insertAfter(r).button({icons:{primary:"ui-icon-triangle-1-s"},text:false}).removeClass("ui-corner-all").addClass("ui-corner-right ui-button-icon ui-combobox-button");r.data("ui-autocomplete")._renderItem=function(t,n){return e("<li>").append(e("<a>").html(n.label)).appendTo(t)};this._on(this._events)},_linkSelectList:function(t,n){var r=new RegExp(e.ui.autocomplete.escapeRegex(t.term),"i");n(this.element.children("option").map(function(){var n=e(this).text();if(this.value&&(!t.term||r.test(n))){var i={label:n,value:n,option:this};if(t.term){i.label=n.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+e.ui.autocomplete.escapeRegex(t.term)+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>")}return i}}))},_events:{"autocompletechange input":function(t,n){var r=e(t.currentTarget);var i=n.item?n.item.option:null;if(!n.item){var s=new RegExp("^"+e.ui.autocomplete.escapeRegex(r.val())+"$","i"),o=false,u=null,a=0,f=-1,l=-1,c=null;if(this.options.autofillsinglematch){u=new RegExp(e.ui.autocomplete.escapeRegex(r.val()),"i")}this.element.children("option").each(function(){var t=e(this).text();if(t.match(s)){this.selected=o=true;return false}if(u){f++;if(t.match(u)){a++;c=e(this);l=f}}});if(!o){if(a==1){i=c[0];i.selected=true;var h=c.text();r.val(h);r.data("ui-autocomplete").term=h;this.element.prop("selectedIndex",l);console.log("Found single match with '"+h+"'")}else{r.val("");r.data("ui-autocomplete").term="";this.element.prop("selectedIndex",-1)}}}this._trigger("change",t,{item:i})},"autocompleteselect input":function(e,t){t.item.option.selected=true;this._trigger("select",e,{item:t.item.option})},"autocompleteopen input":function(e,t){this.uiCombo.children(".ui-autocomplete").outerWidth(this.uiCombo.outerWidth(true))},"mousedown .ui-combobox-button":function(e){this._wasOpen=this.uiInput.autocomplete("widget").is(":visible")},"click .ui-combobox-button":function(e){this.uiInput.focus();if(this._wasOpen)return;this.uiInput.autocomplete("search","")}},value:function(e){var t=this.element,n=false,r;if(!arguments.length){r=t.children(":selected");return r.length>0?r.val():null}t.prop("selectedIndex",-1);t.children("option").each(function(){if(this.value==e){this.selected=n=true;return false}});if(n){this.uiInput.val(t.children(":selected").text())}else{this.uiInput.val("");this.element.prop("selectedIndex",-1)}},_destroy:function(){this.element.show();this.uiCombo.replaceWith(this.element)},widget:function(){return this.uiCombo},_getCreateEventData:function(){return{select:this.element,combo:this.uiCombo,input:this.uiInput}}})})(jQuery)