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