var __hasProp=Object.prototype.hasOwnProperty,__extends=function(a,b){function d(){this.constructor=a}for(var c in b)__hasProp.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a},__indexOf=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(this[b]===a)return b;return-1},__bind=function(a,b){return function(){return a.apply(b,arguments)}};define(["backbone","common/views/collection","common/models/state","common/views/state"],function(a,b,c,d){var e,f,g,h;return f=function(){function a(){a.__super__.constructor.apply(this,arguments)}return __extends(a,c.Model),a}(),g=function(){function b(){b.__super__.constructor.apply(this,arguments)}return __extends(b,a.Collection),b.prototype.model=f,b.prototype.query=function(a){return this.$.get(this.url,{q:a},__bind(function(a){return this.each(function(b){var c;return(c=b.id,__indexOf.call(a,c)<0)?b.disable():b.enable()})},this))},b}(),e=function(){function b(){b.__super__.constructor.apply(this,arguments)}return __extends(b,a.View),b.prototype.events={focus:"focus",blur:"blur",keyup:"keyup"},b.prototype.focus=function(){this.focused=!0;if(this.el.val()!=="")return this.results.show()},b.prototype.blur=function(){this.focused=!1;if(!this.results.entered)return this.results.hide()},b.prototype.keyup=function(){return this.results.show(),clearTimeout(this._searchTimer),this._searchTimer=setTimeout(__bind(function(){return this.results.query(this.el.val())},this),200)},b}(),h=function(){function a(){this.reposition=__bind(this.reposition,this),a.__super__.constructor.apply(this,arguments)}return __extends(a,b.View),a.prototype.inputViewClass=e,a.prototype.defaultContent='<div class="info">No results found</div>',a.prototype.elements={".content":"content"},a.prototype.events={mouseenter:"mouseenter",mouseleave:"mouseleave"},a.prototype.initialize=function(b){return this.input||(this.input=new this.inputViewClass,this.input.results=this,this.defaultContent=this.$(this.defaultContent)),this.render(),a.__super__.initialize.apply(this,arguments)},a.prototype.insertChild=function(a){return this.content.append(a.el)},a.prototype.render=function(){return this.el.appendTo("body"),this.$(window).bind("resize",this.reposition),this},a.prototype.reposition=function(){var a,b,c,d;return d=this.el.outerWidth(),b=this.input.el.offset(),a=this.input.el.outerHeight(),c=this.input.el.outerWidth(),this.el.css({top:b.top+a+5,left:b.left-(d-c)/2})},a.prototype.query=function(a){return this.collection.query(a).success(__bind(function(a){return a.length?this.defaultContent.detach():this.defaultContent.show().prependTo(this.content)},this))},a.prototype.mouseenter=function(){return this.entered=!0},a.prototype.mouseleave=function(){this.entered=!1;if(!this.input.focused)return this.hide()},a.prototype.show=function(){return this.reposition(),this.el.fadeIn("fast")},a.prototype.hide=function(){return this.el.fadeOut("fast")},a}(),{ResultModel:f,ResultCollection:g,ResultListView:h,InputView:e}})