text: !function(e){"use strict";angular.module("cc-combo-breaker",[]).filter("ccComboFilter",function(){function e(e,t){return e.toLowerCase()===t.toLowerCase()?0:0===e.toLowerCase().indexOf(t.toLowerCase())?1:e.toLowerCase().indexOf(t.toLowerCase())>-1?2:void 0}return function(t,o){var i;return o?(i=t.filter(function(e){return e.toLowerCase().indexOf(o.toLowerCase())>-1}),i.sort(function(t,i){var s=e(t,o),c=e(i,o);return s===c?t.toLowerCase().localeCompare(i.toLowerCase()):s-c}),i):t}}).directive("combobreaker",["$document",function(t){return{restrict:"E",replace:!0,template:'<div class=cc-combo-wrapper><input type=text class=cc-search-text autocomplete=off ng-model=ccSearch><div class=cc-input-wrapper><input type=text class=cc-combo-input autocomplete=off placeholder={{placeholder}}> <span class=button></span></div><div class=cc-suggestions><ul class=cc-list><li ng-repeat="item in list | ccComboFilter: ccSearch | limitTo: ccLimit">{{item}}</li></ul></div></div>',scope:{list:"=",ngModel:"=",suggestionLimit:"@?",strict:"@?",placeholder:"@?"},link:function(o,i){var s=i.find(".cc-combo-input"),c=i.find(".cc-search-text"),r=o.strict?"change":"input",n=i.find(".cc-list"),l=o.list.map(function(e){return e.toLowerCase()});o.$watch("ngModel",function(e){o.strict?e&&l.indexOf(e.toLowerCase())>-1?s.val(e):(o.ngModel="",s.val("")):s.val(e)}),isNaN(o.suggestionLimit)||Number(o.suggestionLimit)<=1?o.ccLimit=1/0:o.ccLimit=parseInt(o.suggestionLimit,10),t.on("mousedown",function(t){var o,c,n=e(t.target);i.hasClass("focus")?(o=i.find("li"),c=i.find(".button"),n.is(o)?s.val(n.text()).trigger(r).trigger("blur"):n.is(c)&&s.trigger(r).trigger("blur")):n.closest(i).length&&s.trigger("focus")}),i.on("mousedown",function(t){e(t.target).is(s)||t.preventDefault()}),n.on("mousemove","li",function(t){var o=e(t.target);o.addClass("selected").siblings().removeClass("selected")}),s.on("focus",function(){var t,c;i.addClass("focus"),o.$apply(function(){o.ccSearch=""}),setTimeout(function(){s.trigger("select")},50),i.find(".selected").length||(t=i.find("li"),c=t.filter(function(){return e(this).text().toLowerCase()===s.val().toLowerCase()}),c.length?c.addClass("selected"):t.first().addClass("selected"))}),s.on("blur",function(){var e=i.find(".cc-suggestions"),t=i.find("li");this.selectionStart=this.selectionEnd,i.removeClass("focus"),e.scrollTop(0),t.removeClass("selected")}),s.on("keydown",function(e){var t,c,n,l=i.find(".cc-suggestions"),a=l.height(),d=i.find(".selected");27===e.which?""===s.val()?s.val("").trigger(r).trigger("blur"):s.val(o.ngModel).trigger(r).trigger("blur"):9===e.which||13===e.which?d.length&&(e.preventDefault(),s.val(d.text()).trigger(r).trigger("blur")):38===e.which?(event.preventDefault(),t=i.find("li").first(),d.is(t)||(d=d.removeClass("selected").prev().addClass("selected"),c=d.position(),n=d.outerHeight(),c.top<l.scrollTop()?l.scrollTop(c.top):c.top+n>l.scrollTop()+a&&l.scrollTop(c.top+n-l.height()))):40===e.which&&(event.preventDefault(),t=i.find("li").last(),d.is(t)||(d=d.removeClass("selected").next().addClass("selected"),c=d.position(),n=d.outerHeight(),c.top<l.scrollTop()?l.scrollTop(c.top):c.top+n>l.scrollTop()+a&&l.scrollTop(c.top+n-l.height())))}),s.on("input",function(){var e=i.find("li.selected"),t=i.find(".cc-suggestions");o.$apply(function(){o.ccSearch=s.val()}),e.removeClass("selected"),i.find("li").first().addClass("selected"),t.scrollTop(0),o.strict||o.$apply(function(){o.ngModel=o.ccSearch})}),o.strict&&(s.on("change",function(){""===s.val()?(i.find("li").first().addClass("selected"),o.$apply(function(){o.ngModel=null})):l.indexOf(s.val().toLowerCase())>-1?o.$apply(function(){o.ngModel=s.val()}):(i.addClass("cc-error"),s.val(o.ngModel).trigger(r),c.val(o.ngModel).trigger(r))}),i.on("animationend",function(t){e(t.target).is(s)&&i.hasClass("cc-error")&&i.removeClass("cc-error")}))}}}])}(jQuery);