text: /*! kabu 20-10-2016 */
  +function($){"use strict";function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data("bs.alert");data||$this.data("bs.alert",data=new Alert(this)),"string"==typeof option&&data[option].call($this)})}var dismiss='[data-dismiss="alert"]',Alert=function(el){$(el).on("click",dismiss,this.close)};Alert.prototype.close=function(e){function removeElement(){$parent.detach().trigger("closed.bs.alert").remove()}var $this=$(this),selector=$this.attr("data-target");selector||(selector=$this.attr("href"),selector=selector&&selector.replace(/.*(?=#[^\s]*$)/,""));var $parent=$(selector);e&&e.preventDefault(),$parent.length||($parent=$this.hasClass("alert")?$this:$this.parent()),$parent.trigger(e=$.Event("close.bs.alert")),e.isDefaultPrevented()||($parent.removeClass("in"),$.support.transition&&$parent.hasClass("fade")?$parent.one($.support.transition.end,removeElement).emulateTransitionEnd(150):removeElement())};var old=$.fn.alert;$.fn.alert=Plugin,$.fn.alert.Constructor=Alert,$.fn.alert.noConflict=function(){return $.fn.alert=old,this},$(document).on("click.bs.alert.data-api",dismiss,Alert.prototype.close)}(jQuery),+function($){"use strict";function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data("bs.button"),options="object"==typeof option&&option;data||$this.data("bs.button",data=new Button(this,options)),"toggle"==option?data.toggle():option&&data.setState(option)})}var Button=function(element,options){this.$element=$(element),this.options=$.extend({},Button.DEFAULTS,options),this.isLoading=!1};Button.DEFAULTS={loadingText:"loading..."},Button.prototype.setState=function(state){var d="disabled",$el=this.$element,val=$el.is("input")?"val":"html",data=$el.data();state+="Text",null==data.resetText&&$el.data("resetText",$el[val]()),$el[val](null==data[state]?this.options[state]:data[state]),setTimeout($.proxy(function(){"loadingText"==state?(this.isLoading=!0,$el.addClass(d).attr(d,d)):this.isLoading&&(this.isLoading=!1,$el.removeClass(d).removeAttr(d))},this),0)},Button.prototype.toggle=function(){var changed=!0,$parent=this.$element.closest('[data-toggle="buttons"]');if($parent.length){var $input=this.$element.find("input");"radio"==$input.prop("type")&&($input.prop("checked")&&this.$element.hasClass("active")?changed=!1:$parent.find(".active").removeClass("active")),changed&&$input.prop("checked",!this.$element.hasClass("active")).trigger("change")}changed&&this.$element.toggleClass("active")};var old=$.fn.button;$.fn.button=Plugin,$.fn.button.Constructor=Button,$.fn.button.noConflict=function(){return $.fn.button=old,this},$(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(e){var $btn=$(e.target);$btn.hasClass("btn")||($btn=$btn.closest(".btn")),Plugin.call($btn,"toggle"),e.preventDefault()})}(jQuery),function(){$(function(){$('input[data-toggle="clear"]').each(function(){$input=$(this),$clear=$("<i></i>").addClass("icon icon-remove-sign clear quiet").click(function(){$input.val("").focus(),$(this).hide()}),$input.after($clear),$input.keyup(function(){$clear.toggle(Boolean($input.val()))}),$clear.toggle(Boolean($input.val()))})})}.call(this),+function($){"use strict";function clearMenus(e){e&&3===e.which||($(backdrop).remove(),$(toggle).each(function(){var $parent=getParent($(this)),relatedTarget={relatedTarget:this};$parent.hasClass("open")&&($parent.trigger(e=$.Event("hide.bs.dropdown",relatedTarget)),e.isDefaultPrevented()||$parent.removeClass("open").trigger("hidden.bs.dropdown",relatedTarget))}))}function getParent($this){var selector=$this.attr("data-target");selector||(selector=$this.attr("href"),selector=selector&&/#[A-Za-z]/.test(selector)&&selector.replace(/.*(?=#[^\s]*$)/,""));var $parent=selector&&$(selector);return $parent&&$parent.length?$parent:$this.parent()}function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data("bs.dropdown");data||$this.data("bs.dropdown",data=new Dropdown(this)),"string"==typeof option&&data[option].call($this)})}var backdrop=".dropdown-backdrop",toggle='[data-toggle="dropdown"]',Dropdown=function(element){$(element).on("click.bs.dropdown",this.toggle)};Dropdown.prototype.toggle=function(e){var $this=$(this);if(!$this.is(".disabled, :disabled")){var $parent=getParent($this),isActive=$parent.hasClass("open");if(clearMenus(),!isActive){"ontouchstart"in document.documentElement&&!$parent.closest(".navbar-nav").length&&$('<div class="dropdown-backdrop"/>').insertAfter($(this)).on("click",clearMenus);var relatedTarget={relatedTarget:this};if($parent.trigger(e=$.Event("show.bs.dropdown",relatedTarget)),e.isDefaultPrevented())return;$this.trigger("focus"),$parent.toggleClass("open").trigger("shown.bs.dropdown",relatedTarget)}return!1}},Dropdown.prototype.keydown=function(e){if(/(38|40|27)/.test(e.keyCode)){var $this=$(this);if(e.preventDefault(),e.stopPropagation(),!$this.is(".disabled, :disabled")){var $parent=getParent($this),isActive=$parent.hasClass("open");if(!isActive||isActive&&27==e.keyCode)return 27==e.which&&$parent.find(toggle).trigger("focus"),$this.trigger("click");var desc=" li:not(.divider):visible a",$items=$parent.find('[role="menu"]'+desc+', [role="listbox"]'+desc);if($items.length){var index=$items.index($items.filter(":focus"));38==e.keyCode&&index>0&&index--,40==e.keyCode&&index<$items.length-1&&index++,~index||(index=0),$items.eq(index).trigger("focus")}}}};var old=$.fn.dropdown;$.fn.dropdown=Plugin,$.fn.dropdown.Constructor=Dropdown,$.fn.dropdown.noConflict=function(){return $.fn.dropdown=old,this},$(document).on("click.bs.dropdown.data-api",clearMenus).on("click.bs.dropdown.data-api",".dropdown form",function(e){e.stopPropagation()}).on("click.bs.dropdown.data-api",toggle,Dropdown.prototype.toggle).on("keydown.bs.dropdown.data-api",toggle+', [role="menu"], [role="listbox"]',Dropdown.prototype.keydown)}(jQuery),+function($){"use strict";var isIE="Microsoft Internet Explorer"==window.navigator.appName,Fileupload=function(element,options){if(this.$element=$(element),this.$input=this.$element.find(":file"),0!==this.$input.length){this.name=this.$input.attr("name")||options.name,this.$hidden=this.$element.find('input[type=hidden][name="'+this.name+'"]'),0===this.$hidden.length&&(this.$hidden=$('<input type="hidden" />'),this.$element.prepend(this.$hidden)),this.$preview=this.$element.find(".fileinput-preview");var height=this.$preview.css("height");"inline"!=this.$preview.css("display")&&"0px"!=height&&"none"!=height&&this.$preview.css("line-height",height),this.original={exists:this.$element.hasClass("fileinput-exists"),preview:this.$preview.html(),hiddenVal:this.$hidden.val()},this.inline_flag=this.$element.find(".input-group").length,this.inline_flag&&(this.$change=this.$element.find('[data-role="change"]'),this.$select_file=this.$element.find('[data-role="select-file"]')),this.listen()}};Fileupload.prototype.listen=function(){this.$input.on("change.bs.fileinput",$.proxy(this.change,this)),$(this.$input[0].form).on("reset.bs.fileinput",$.proxy(this.reset,this)),this.inline_flag&&this.$element.on("mousemove.bs.fileinput",$.proxy(this.checkmove,this)).on("mouseout.bs.fileinput",$.proxy(this.resetControlsClass,this)).on("mousedown.bs.fileinput",$.proxy(this.activateControls,this)),this.$element.find('[data-trigger="fileinput"]').on("click.bs.fileinput",$.proxy(this.trigger,this)),this.$element.find('[data-dismiss="fileinput"]').on("click.bs.fileinput",$.proxy(this.clear,this))},Fileupload.prototype.change=function(e){if(void 0===e.target.files&&(e.target.files=e.target&&e.target.value?[{name:e.target.value.replace(/^.+\\/,"")}]:[]),0!==e.target.files.length){this.$hidden.val(""),this.$hidden.attr("name",""),this.$input.attr("name",this.name);var file=e.target.files[0];if(this.$preview.length>0&&("undefined"!=typeof file.type?file.type.match("image.*"):file.name.match(/\.(gif|png|jpe?g)$/i))&&"undefined"!=typeof FileReader){var reader=new FileReader,preview=this.$preview,element=this.$element;reader.onload=function(re){var $img=$("<img>");$img[0].src=re.target.result,e.target.files[0].result=re.target.result,element.find(".fileinput-filename").text(file.name),"none"!=preview.css("max-height")&&$img.css("max-height",parseInt(preview.css("max-height"),10)-parseInt(preview.css("padding-top"),10)-parseInt(preview.css("padding-bottom"),10)-parseInt(preview.css("border-top"),10)-parseInt(preview.css("border-bottom"),10)),preview.html($img),element.addClass("fileinput-exists").removeClass("fileinput-new"),element.trigger("change.bs.fileinput",e.target.files)},reader.readAsDataURL(file)}else this.$element.find(".fileinput-filename").text(file.name),this.$preview.text(file.name),this.$element.addClass("fileinput-exists").removeClass("fileinput-new"),this.$element.trigger("change.bs.fileinput")}},Fileupload.prototype.clear=function(e){if(e&&e.preventDefault(),this.$hidden.val(""),this.$hidden.attr("name",this.name),this.$input.attr("name",""),isIE){var inputClone=this.$input.clone(!0);this.$input.after(inputClone),this.$input.remove(),this.$input=inputClone}else this.$input.val("");this.$preview.html(""),this.$element.find(".fileinput-filename").text(""),this.$element.addClass("fileinput-new").removeClass("fileinput-exists"),e!==!1&&(this.$input.trigger("change"),this.$element.trigger("clear.bs.fileinput"))},Fileupload.prototype.reset=function(){this.clear(!1),this.$hidden.val(this.original.hiddenVal),this.$preview.html(this.original.preview),this.$element.find(".fileinput-filename").text(""),this.original.exists?this.$element.addClass("fileinput-exists").removeClass("fileinput-new"):this.$element.addClass("fileinput-new").removeClass("fileinput-exists"),this.$element.trigger("reset.bs.fileinput")},Fileupload.prototype.checkmove=function(e){var select_file_pos=this.$select_file.offset().left,change_pos=this.$change.offset().left;this.$change.is(":hidden")?e.pageX>select_file_pos&&e.pageX<select_file_pos+this.$select_file.width()?this.$select_file.addClass("hover"):this.$select_file.removeClass("hover"):e.pageX>change_pos&&e.pageX<change_pos+this.$select_file.width()?this.$change.addClass("hover"):this.$change.removeClass("hover")},Fileupload.prototype.activateControls=function(){this.$change.is(":hidden")?this.$select_file.addClass("active"):this.$change.addClass("active")},Fileupload.prototype.resetControlsClass=function(){this.$change.removeClass("hover active"),this.$select_file.removeClass("hover active")},Fileupload.prototype.trigger=function(e){this.$input.trigger("click"),e.preventDefault()},$.fn.fileinput=function(options){return this.each(function(){var $this=$(this),data=$this.data("fileinput");data||$this.data("fileinput",data=new Fileupload(this,options)),"string"==typeof options&&data[options]()})},$.fn.fileinput.Constructor=Fileupload,$(document).on("click.fileinput.data-api",'[data-provides="fileinput"]',function(e){var $target=$(e.target).closest('[data-dismiss="fileinput"], [data-trigger="fileinput"]');$target.length>0&&e.preventDefault()}),$(function(){$('[data-provides="fileinput"]').each(function(){var $this=$(this);$this.data("fileinput")||$this.fileinput($this.data())})})}(window.jQuery),+function($){"use strict";function Plugin(option,_relatedTarget){return this.each(function(){var $this=$(this),data=$this.data("bs.modal"),options=$.extend({},Modal.DEFAULTS,$this.data(),"object"==typeof option&&option);data||$this.data("bs.modal",data=new Modal(this,options)),"string"==typeof option?data[option](_relatedTarget):options.show&&data.show(_relatedTarget)})}var Modal=function(element,options){this.options=options,this.$body=$(document.body),this.$element=$(element),this.isShown=null,this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,$.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};Modal.DEFAULTS={keyboard:!0,show:!0},Modal.prototype.toggle=function(_relatedTarget){return this.isShown?this.hide():this.show(_relatedTarget)},Modal.prototype.show=function(_relatedTarget){var that=this,e=$.Event("show.bs.modal",{relatedTarget:_relatedTarget});if(this.$element.trigger(e),!this.isShown&&!e.isDefaultPrevented()){this.isShown=!0,this.$body.addClass("clip"),this.escape(),this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',$.proxy(this.hide,this)),that.$element.parent().length||that.$element.appendTo(that.$body),that.$element.show().scrollTop(0),that.$element.addClass("active").attr("aria-hidden",!1),that.enforceFocus();var e=$.Event("shown.bs.modal",{relatedTarget:_relatedTarget});that.$element.trigger("focus").trigger(e)}},Modal.prototype.hide=function(e){e&&e.preventDefault(),e=$.Event("hide.bs.modal"),this.$element.trigger(e),this.isShown&&!e.isDefaultPrevented()&&(this.isShown=!1,this.$body.removeClass("clip"),this.escape(),$(document).off("focusin.bs.modal"),this.$element.removeClass("active").attr("aria-hidden",!0).off("click.dismiss.bs.modal"),this.hideModal())},Modal.prototype.enforceFocus=function(){$(document).off("focusin.bs.modal").on("focusin.bs.modal",$.proxy(function(e){this.$element[0]===e.target||this.$element.has(e.target).length||this.$element.trigger("focus")},this))},Modal.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.bs.modal",$.proxy(function(e){27==e.which&&this.hide()},this)):this.isShown||this.$element.off("keyup.dismiss.bs.modal")},Modal.prototype.hideModal=function(){var that=this;this.$element.hide(),that.$element.trigger("hidden.bs.modal")};var old=$.fn.modal;$.fn.modal=Plugin,$.fn.modal.Constructor=Modal,$.fn.modal.noConflict=function(){return $.fn.modal=old,this},$(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(e){var $this=$(this),href=$this.attr("href"),$target=$($this.attr("data-target")||href&&href.replace(/.*(?=#[^\s]+$)/,"")),option=$target.data("bs.modal")?"toggle":$.extend({remote:!/#/.test(href)&&href},$target.data(),$this.data());$this.is("a")&&e.preventDefault(),Plugin.call($target,option,this),$target.one("hide",function(){$this.is(":visible")&&$this.trigger("focus")})})}(jQuery),function(){$(function(){$('[data-toggle="offcanvas"]').click(function(){target=$(this).data("target"),$(target).toggleClass("active")}),$('[data-dismiss="offcanvas"]').click(function(){$(this).parent().toggleClass("active")})})}.call(this),function(root,factory){"use strict";var moment;if("object"==typeof exports){try{moment=require("moment")}catch(e){}module.exports=factory(moment)}else"function"==typeof define&&define.amd?define(function(req){var id="moment";try{moment=req(id)}catch(e){}return factory(moment)}):root.Pikaday=factory(root.moment)}(this,function(moment){"use strict";var hasMoment="function"==typeof moment,hasEventListeners=!!window.addEventListener,document=window.document,sto=window.setTimeout,addEvent=function(el,e,callback,capture){hasEventListeners?el.addEventListener(e,callback,!!capture):el.attachEvent("on"+e,callback)},removeEvent=function(el,e,callback,capture){hasEventListeners?el.removeEventListener(e,callback,!!capture):el.detachEvent("on"+e,callback)},fireEvent=function(el,eventName,data){var ev;document.createEvent?(ev=document.createEvent("HTMLEvents"),ev.initEvent(eventName,!0,!1),ev=extend(ev,data),el.dispatchEvent(ev)):document.createEventObject&&(ev=document.createEventObject(),ev=extend(ev,data),el.fireEvent("on"+eventName,ev))},trim=function(str){return str.trim?str.trim():str.replace(/^\s+|\s+$/g,"")},hasClass=function(el,cn){return-1!==(" "+el.className+" ").indexOf(" "+cn+" ")},addClass=function(el,cn){hasClass(el,cn)||(el.className=""===el.className?cn:el.className+" "+cn)},removeClass=function(el,cn){el.className=trim((" "+el.className+" ").replace(" "+cn+" "," "))},isArray=function(obj){return/Array/.test(Object.prototype.toString.call(obj))},isDate=function(obj){return/Date/.test(Object.prototype.toString.call(obj))&&!isNaN(obj.getTime())},isLeapYear=function(year){return year%4===0&&year%100!==0||year%400===0},getDaysInMonth=function(year,month){return[31,isLeapYear(year)?29:28,31,30,31,30,31,31,30,31,30,31][month]},setToStartOfDay=function(date){isDate(date)&&date.setHours(0,0,0,0)},compareDates=function(a,b){return a.getTime()===b.getTime()},extend=function(to,from,overwrite){var prop,hasProp;for(prop in from)hasProp=void 0!==to[prop],hasProp&&"object"==typeof from[prop]&&null!==from[prop]&&void 0===from[prop].nodeName?isDate(from[prop])?overwrite&&(to[prop]=new Date(from[prop].getTime())):isArray(from[prop])?overwrite&&(to[prop]=from[prop].slice(0)):to[prop]=extend({},from[prop],overwrite):(overwrite||!hasProp)&&(to[prop]=from[prop]);return to},adjustCalendar=function(calendar){return calendar.month<0&&(calendar.year-=Math.ceil(Math.abs(calendar.month)/12),calendar.month+=12),calendar.month>11&&(calendar.year+=Math.floor(Math.abs(calendar.month)/12),calendar.month-=12),calendar},defaults={field:null,bound:void 0,position:"bottom left",reposition:!0,format:"YYYY-MM-DD",defaultDate:null,setDefaultDate:!1,firstDay:0,minDate:null,maxDate:null,yearRange:10,showWeekNumber:!1,minYear:0,maxYear:9999,minMonth:void 0,maxMonth:void 0,isRTL:!1,yearSuffix:"",showMonthAfterYear:!1,numberOfMonths:1,mainCalendar:"left",container:void 0,i18n:{previousMonth:"Previous Month",nextMonth:"Next Month",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["S","M","T","W","T","F","S"]},onSelect:null,onOpen:null,onClose:null,onDraw:null},renderDayName=function(opts,day,abbr){for(day+=opts.firstDay;day>=7;)day-=7;return abbr?opts.i18n.weekdaysShort[day]:opts.i18n.weekdays[day]},renderDay=function(d,m,y,isSelected,isToday,isDisabled,isEmpty){if(isEmpty)return'<td class="is-empty"></td>';var arr=[];return isDisabled&&arr.push("is-disabled"),isToday&&arr.push("is-today"),isSelected&&arr.push("is-selected"),'<td data-day="'+d+'" class="'+arr.join(" ")+'"><a href="#" class="block pika-button pika-day" data-pika-year="'+y+'" data-pika-month="'+m+'" data-pika-day="'+d+'">'+d+"</a></td>"},renderWeek=function(d,m,y){var onejan=new Date(y,0,1),weekNum=Math.ceil(((new Date(y,m,d)-onejan)/864e5+onejan.getDay()+1)/7);return'<td class="pika-week">'+weekNum+"</td>"},renderRow=function(days,isRTL){return"<tr>"+(isRTL?days.reverse():days).join("")+"</tr>"},renderBody=function(rows){return"<tbody>"+rows.join("")+"</tbody>"},renderHead=function(opts){var i,arr=[];for(opts.showWeekNumber&&arr.push("<th></th>"),i=0;7>i;i++)arr.push("<th>"+renderDayName(opts,i,!0)+"</th>");return"<thead>"+(opts.isRTL?arr.reverse():arr).join("")+"</thead>"},renderTitle=function(instance,c,year,month,refYear){var i,j,arr,monthHtml,yearHtml,opts=instance._o,isMinYear=year===opts.minYear,isMaxYear=year===opts.maxYear,html='<div class="pika-title pad2 round-top fill-blue dark keyline-bottom contain center">',prev=!0,next=!0;for(arr=[],i=0;12>i;i++)arr.push('<option value="'+(year===refYear?i-c:12+i-c)+'"'+(i===month?" selected":"")+(isMinYear&&i<opts.minMonth||isMaxYear&&i>opts.maxMonth?"disabled":"")+">"+opts.i18n.months[i]+"</option>");for(monthHtml='<h4 class="pika-label inline contain truncate">'+opts.i18n.months[month]+'<select class="pika-select pika-select-month inline pin-left">'+arr.join("")+"</select></h4>",isArray(opts.yearRange)?(i=opts.yearRange[0],j=opts.yearRange[1]+1):(i=year-opts.yearRange,j=1+year+opts.yearRange),arr=[];j>i&&i<=opts.maxYear;i++)i>=opts.minYear&&arr.push('<option value="'+i+'"'+(i===year?" selected":"")+">"+i+"</option>");return yearHtml='<h4 class="pika-label inline contain truncate">&nbsp;'+year+opts.yearSuffix+'&nbsp;<select class="pika-select pika-select-year inline pin-left">'+arr.join("")+"</select></h4>",html+=opts.showMonthAfterYear?yearHtml+monthHtml:monthHtml+yearHtml,isMinYear&&(0===month||opts.minMonth>=month)&&(prev=!1),isMaxYear&&(11===month||opts.maxMonth<=month)&&(next=!1),0===c&&(html+='<i class="icon icon-chevron-left pull-left pad0x small'+(prev?"":" is-disabled")+'"></i>'),c===instance._o.numberOfMonths-1&&(html+='<i class="icon icon-chevron-right pull-right pad0x small'+(next?"":" is-disabled")+'"></i>'),html+="</div>"},renderTable=function(opts,data){return'<div class="pad2"><table class="pika-table fixed small">'+renderHead(opts)+renderBody(data)+"</table></div>"},Pikaday=function(options){var self=this,opts=self.config(options);self._onMouseDown=function(e){if(self._v){e=e||window.event;var target=e.target||e.srcElement;if(target){if(!hasClass(target,"is-disabled")){if(hasClass(target,"pika-button")&&!hasClass(target,"is-empty"))return self.setDate(new Date(target.getAttribute("data-pika-year"),target.getAttribute("data-pika-month"),target.getAttribute("data-pika-day"))),void(opts.bound&&sto(function(){self.hide(),opts.field&&opts.field.blur()},100));hasClass(target,"icon-chevron-left")?self.prevMonth():hasClass(target,"icon-chevron-right")&&self.nextMonth()}if(hasClass(target,"pika-select"))self._c=!0;else{if(!e.preventDefault)return e.returnValue=!1,!1;e.preventDefault()}}}},self._onChange=function(e){e=e||window.event;var target=e.target||e.srcElement;target&&(hasClass(target,"pika-select-month")?self.gotoMonth(target.value):hasClass(target,"pika-selected-year")&&self.gotoYear(target.value))},self._onInputChange=function(e){var date;e.firedBy!==self&&(hasMoment?(date=moment(opts.field.value,opts.format),date=date&&date.isValid()?date.toDate():null):date=new Date(Date.parse(opts.field.value)),self.setDate(isDate(date)?date:null),self._v||self.show())},self._onInputFocus=function(){self.show()},self._onInputClick=function(){self.show()},self._onInputBlur=function(){var pEl=document.activeElement;do if(hasClass(pEl,"pika-single"))return;while(pEl=pEl.parentNode);self._c||(self._b=sto(function(){self.hide()},50)),self._c=!1},self._onClick=function(e){e=e||window.event;var target=e.target||e.srcElement,pEl=target;if(target){!hasEventListeners&&hasClass(target,"pika-select")&&(target.onchange||(target.setAttribute("onchange","return;"),addEvent(target,"change",self._onChange)));do if(hasClass(pEl,"pika-single")||pEl===opts.trigger)return;while(pEl=pEl.parentNode);self._v&&target!==opts.trigger&&pEl!==opts.trigger&&self.hide()}},self.el=document.createElement("div"),self.el.className="pika-single keyline-all fill-white lift round contain clearfix"+(opts.isRTL?" is-rtl":""),addEvent(self.el,"mousedown",self._onMouseDown,!0),addEvent(self.el,"change",self._onChange),opts.field&&(opts.container?opts.container.appendChild(self.el):opts.bound?document.body.appendChild(self.el):opts.field.parentNode.insertBefore(self.el,opts.field.nextSibling),addEvent(opts.field,"change",self._onInputChange),opts.defaultDate||(opts.defaultDate=hasMoment&&opts.field.value?moment(opts.field.value,opts.format).toDate():new Date(Date.parse(opts.field.value)),opts.setDefaultDate=!0));var defDate=opts.defaultDate;isDate(defDate)?opts.setDefaultDate?self.setDate(defDate,!0):self.gotoDate(defDate):self.gotoDate(new Date),opts.bound?(this.hide(),self.el.className+=" is-bound",addEvent(opts.trigger,"click",self._onInputClick),addEvent(opts.trigger,"focus",self._onInputFocus),addEvent(opts.trigger,"blur",self._onInputBlur)):this.show()};return Pikaday.prototype={config:function(options){this._o||(this._o=extend({},defaults,!0));var opts=extend(this._o,options,!0);opts.isRTL=!!opts.isRTL,opts.field=opts.field&&opts.field.nodeName?opts.field:null,opts.bound=!!(void 0!==opts.bound?opts.field&&opts.bound:opts.field),opts.trigger=opts.trigger&&opts.trigger.nodeName?opts.trigger:opts.field;var nom=parseInt(opts.numberOfMonths,10)||1;if(opts.numberOfMonths=nom>4?4:nom,isDate(opts.minDate)||(opts.minDate=!1),isDate(opts.maxDate)||(opts.maxDate=!1),opts.minDate&&opts.maxDate&&opts.maxDate<opts.minDate&&(opts.maxDate=opts.minDate=!1),opts.minDate&&(setToStartOfDay(opts.minDate),opts.minYear=opts.minDate.getFullYear(),opts.minMonth=opts.minDate.getMonth()),opts.maxDate&&(setToStartOfDay(opts.maxDate),opts.maxYear=opts.maxDate.getFullYear(),opts.maxMonth=opts.maxDate.getMonth()),isArray(opts.yearRange)){var fallback=(new Date).getFullYear()-10;opts.yearRange[0]=parseInt(opts.yearRange[0],10)||fallback,opts.yearRange[1]=parseInt(opts.yearRange[1],10)||fallback}else opts.yearRange=Math.abs(parseInt(opts.yearRange,10))||defaults.yearRange,opts.yearRange>100&&(opts.yearRange=100);return opts},toString:function(format){return isDate(this._d)?hasMoment?moment(this._d).format(format||this._o.format):this._d.toDateString():""},getMoment:function(){return hasMoment?moment(this._d):null},setMoment:function(date,preventOnSelect){hasMoment&&moment.isMoment(date)&&this.setDate(date.toDate(),preventOnSelect)},getDate:function(){return isDate(this._d)?new Date(this._d.getTime()):null},setDate:function(date,preventOnSelect){if(!date)return this._d=null,this._o.field&&(this._o.field.value="",fireEvent(this._o.field,"change",{firedBy:this})),this.draw();if("string"==typeof date&&(date=new Date(Date.parse(date))),isDate(date)){var min=this._o.minDate,max=this._o.maxDate;isDate(min)&&min>date?date=min:isDate(max)&&date>max&&(date=max),this._d=new Date(date.getTime()),setToStartOfDay(this._d),this.gotoDate(this._d),this._o.field&&(this._o.field.value=this.toString(),fireEvent(this._o.field,"change",{firedBy:this})),preventOnSelect||"function"!=typeof this._o.onSelect||this._o.onSelect.call(this,this.getDate())}},gotoDate:function(date){var newCalendar=!0;if(isDate(date)){if(this.calendars){var firstVisibleDate=new Date(this.calendars[0].year,this.calendars[0].month,1),lastVisibleDate=new Date(this.calendars[this.calendars.length-1].year,this.calendars[this.calendars.length-1].month,1),visibleDate=date.getTime();lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1),lastVisibleDate.setDate(lastVisibleDate.getDate()-1),newCalendar=visibleDate<firstVisibleDate.getTime()||lastVisibleDate.getTime()<visibleDate}newCalendar&&(this.calendars=[{month:date.getMonth(),year:date.getFullYear()}],"right"===this._o.mainCalendar&&(this.calendars[0].month+=1-this._o.numberOfMonths)),this.adjustCalendars()}},adjustCalendars:function(){this.calendars[0]=adjustCalendar(this.calendars[0]);for(var c=1;c<this._o.numberOfMonths;c++)this.calendars[c]=adjustCalendar({month:this.calendars[0].month+c,year:this.calendars[0].year});this.draw()},gotoToday:function(){this.gotoDate(new Date)},gotoMonth:function(month){isNaN(month)||(this.calendars[0].month=parseInt(month,10),this.adjustCalendars())},nextMonth:function(){this.calendars[0].month++,this.adjustCalendars()},prevMonth:function(){this.calendars[0].month--,this.adjustCalendars()},gotoYear:function(year){isNaN(year)||(this.calendars[0].year=parseInt(year,10),this.adjustCalendars())},setMinDate:function(value){this._o.minDate=value},setMaxDate:function(value){this._o.maxDate=value},draw:function(force){if(this._v||force){var opts=this._o,minYear=opts.minYear,maxYear=opts.maxYear,minMonth=opts.minMonth,maxMonth=opts.maxMonth,html="";this._y<=minYear&&(this._y=minYear,!isNaN(minMonth)&&this._m<minMonth&&(this._m=minMonth)),this._y>=maxYear&&(this._y=maxYear,!isNaN(maxMonth)&&this._m>maxMonth&&(this._m=maxMonth));for(var c=0;c<opts.numberOfMonths;c++)html+=renderTitle(this,c,this.calendars[c].year,this.calendars[c].month,this.calendars[0].year)+this.render(this.calendars[c].year,this.calendars[c].month);if(this.el.innerHTML=html,opts.bound&&"hidden"!==opts.field.type&&sto(function(){opts.trigger.focus()},1),"function"==typeof this._o.onDraw){var self=this;sto(function(){self._o.onDraw.call(self)},0)}}},adjustPosition:function(){if(!this._o.container){var left,top,clientRect,field=this._o.trigger,pEl=field,width=this.el.offsetWidth,height=this.el.offsetHeight,viewportWidth=window.innerWidth||document.documentElement.clientWidth,viewportHeight=window.innerHeight||document.documentElement.clientHeight,scrollTop=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;if("function"==typeof field.getBoundingClientRect)clientRect=field.getBoundingClientRect(),left=clientRect.left+window.pageXOffset,top=clientRect.bottom+window.pageYOffset+5;else for(left=pEl.offsetLeft,top=pEl.offsetTop+pEl.offsetHeight;pEl=pEl.offsetParent;)left+=pEl.offsetLeft,top+=pEl.offsetTop;(this._o.reposition&&left+width>viewportWidth||this._o.position.indexOf("right")>-1&&left-width+field.offsetWidth>0)&&(left=left-width+field.offsetWidth),(this._o.reposition&&top+height>viewportHeight+scrollTop||this._o.position.indexOf("top")>-1&&top-height-field.offsetHeight>0)&&(top=top-height-field.offsetHeight-15),this.el.style.cssText=["position: absolute","left: "+left+"px","top: "+top+"px"].join(";")}},render:function(year,month){var opts=this._o,now=new Date,days=getDaysInMonth(year,month),before=new Date(year,month,1).getDay(),data=[],row=[];setToStartOfDay(now),opts.firstDay>0&&(before-=opts.firstDay,0>before&&(before+=7));for(var cells=days+before,after=cells;after>7;)after-=7;cells+=7-after;for(var i=0,r=0;cells>i;i++){var day=new Date(year,month,1+(i-before)),isDisabled=opts.minDate&&day<opts.minDate||opts.maxDate&&day>opts.maxDate,isSelected=isDate(this._d)?compareDates(day,this._d):!1,isToday=compareDates(day,now),isEmpty=before>i||i>=days+before;row.push(renderDay(1+(i-before),month,year,isSelected,isToday,isDisabled,isEmpty)),7===++r&&(opts.showWeekNumber&&row.unshift(renderWeek(i-before,month,year)),data.push(renderRow(row,opts.isRTL)),row=[],r=0)}return renderTable(opts,data)},isVisible:function(){return this._v},show:function(){this._v||(removeClass(this.el,"hidden"),this._v=!0,this.draw(),this._o.bound&&(addEvent(document,"click",this._onClick),this.adjustPosition()),"function"==typeof this._o.onOpen&&this._o.onOpen.call(this))},hide:function(){var v=this._v;v!==!1&&(this._o.bound&&removeEvent(document,"click",this._onClick),this.el.style.cssText="",addClass(this.el,"hidden"),this._v=!1,void 0!==v&&"function"==typeof this._o.onClose&&this._o.onClose.call(this))},destroy:function(){this.hide(),removeEvent(this.el,"mousedown",this._onMouseDown,!0),removeEvent(this.el,"change",this._onChange),this._o.field&&(removeEvent(this._o.field,"change",this._onInputChange),this._o.bound&&(removeEvent(this._o.trigger,"click",this._onInputClick),removeEvent(this._o.trigger,"focus",this._onInputFocus),removeEvent(this._o.trigger,"blur",this._onInputBlur))),this.el.parentNode&&this.el.parentNode.removeChild(this.el)}},Pikaday}),function(){$(function(){$('[data-toggle="popup"]').click(function(){$popup=$(this).next(".popup"),$popup.toggleClass("active")}),$('[data-dismiss="popup"]').click(function(){$(this).parent().toggleClass("active")})})}.call(this),+function($){"use strict";function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data("bs.tab");data||$this.data("bs.tab",data=new Tab(this)),"string"==typeof option&&data[option]()})}var Tab=function(element){this.element=$(element)};Tab.prototype.show=function(){var $this=this.element,$tabs=$this.parent(),selector=$this.data("target");if(selector||(selector=$this.attr("href"),selector=selector&&selector.replace(/.*(?=#[^\s]*$)/,"")),!$this.hasClass("active")){var previous=$tabs.find(".active:last")[0],e=$.Event("show.bs.tab",{relatedTarget:previous});if($this.trigger(e),!e.isDefaultPrevented()){var $target=$(selector);this.activate($this,$tabs),this.activate($target,$target.parent(),function(){$this.trigger({type:"shown.bs.tab",relatedTarget:previous})})}}},Tab.prototype.activate=function(element,container,callback){function next(){$active.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),element.addClass("active"),transition?(element[0].offsetWidth,element.addClass("in")):element.removeClass("fade"),element.parent(".dropdown-menu")&&element.closest("li.dropdown").addClass("active"),callback&&callback()}var $active=container.find("> .active"),transition=callback&&$.support.transition&&$active.hasClass("fade");transition?$active.one($.support.transition.end,next).emulateTransitionEnd(150):next(),$active.removeClass("in")
  };var old=$.fn.tab;$.fn.tab=Plugin,$.fn.tab.Constructor=Tab,$.fn.tab.noConflict=function(){return $.fn.tab=old,this},$(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(e){e.preventDefault(),Plugin.call($(this),"show")})}(jQuery),function($){"use strict";function TagsInput(element,options){this.isInit=!0,this.itemsArray=[],this.$element=$(element),this.$element.hide(),this.isSelect="SELECT"===element.tagName,this.multiple=this.isSelect&&element.hasAttribute("multiple"),this.objectItems=options&&options.itemValue,this.placeholderText=element.hasAttribute("placeholder")?this.$element.attr("placeholder"):"",this.inputSize=Math.max(1,this.placeholderText.length),this.$container=$('<div class="bootstrap-tagsinput form-control block text-left"></div>'),this.$input=$('<input type="text" placeholder="'+this.placeholderText+'"/>').appendTo(this.$container),this.$element.before(this.$container),this.build(options),this.isInit=!1}function makeOptionItemFunction(options,key){if("function"!=typeof options[key]){var propertyName=options[key];options[key]=function(item){return item[propertyName]}}}function makeOptionFunction(options,key){if("function"!=typeof options[key]){var value=options[key];options[key]=function(){return value}}}function htmlEncode(value){return value?htmlEncodeContainer.text(value).html():""}function doGetCaretPosition(oField){var iCaretPos=0;if(document.selection){oField.focus();var oSel=document.selection.createRange();oSel.moveStart("character",-oField.value.length),iCaretPos=oSel.text.length}else(oField.selectionStart||"0"==oField.selectionStart)&&(iCaretPos=oField.selectionStart);return iCaretPos}function keyCombinationInList(keyPressEvent,lookupList){var found=!1;return $.each(lookupList,function(index,keyCombination){if("number"==typeof keyCombination&&keyPressEvent.which===keyCombination)return found=!0,!1;if(keyPressEvent.which===keyCombination.which){var alt=!keyCombination.hasOwnProperty("altKey")||keyPressEvent.altKey===keyCombination.altKey,shift=!keyCombination.hasOwnProperty("shiftKey")||keyPressEvent.shiftKey===keyCombination.shiftKey,ctrl=!keyCombination.hasOwnProperty("ctrlKey")||keyPressEvent.ctrlKey===keyCombination.ctrlKey;if(alt&&shift&&ctrl)return found=!0,!1}}),found}var defaultOptions={tagClass:function(){return null},focusClass:"focus",itemValue:function(item){return item?item.toString():item},itemText:function(item){return this.itemValue(item)},itemTitle:function(){return null},freeInput:!0,addOnBlur:!0,maxTags:void 0,maxChars:void 0,confirmKeys:[13,44],delimiter:",",delimiterRegex:null,cancelConfirmKeysOnEmpty:!1,onTagExists:function(item,$tag){$tag.hide().fadeIn()},trimValue:!1,allowDuplicates:!1,triggerChange:!0};TagsInput.prototype={constructor:TagsInput,add:function(item,dontPushVal,options){var self=this;if(!(self.options.maxTags&&self.itemsArray.length>=self.options.maxTags||item!==!1&&!item)){if("string"==typeof item&&self.options.trimValue&&(item=$.trim(item)),"object"==typeof item&&!self.objectItems)throw"Can't add objects when itemValue option is not set";if(!item.toString().match(/^\s*$/)){if(self.isSelect&&!self.multiple&&self.itemsArray.length>0&&self.remove(self.itemsArray[0]),"string"==typeof item&&"INPUT"===this.$element[0].tagName){var delimiter=self.options.delimiterRegex?self.options.delimiterRegex:self.options.delimiter,items=item.split(delimiter);if(items.length>1){for(var i=0;i<items.length;i++)this.add(items[i],!0);return void(dontPushVal||self.pushVal(self.options.triggerChange))}}var itemValue=self.options.itemValue(item),itemText=self.options.itemText(item),tagClass=self.options.tagClass(item),itemTitle=self.options.itemTitle(item),existing=$.grep(self.itemsArray,function(item){return self.options.itemValue(item)===itemValue})[0];if(!existing||self.options.allowDuplicates){if(!(self.items().toString().length+item.length+1>self.options.maxInputLength)){var beforeItemAddEvent=$.Event("beforeItemAdd",{item:item,cancel:!1,options:options});if(self.$element.trigger(beforeItemAddEvent),!beforeItemAddEvent.cancel){self.itemsArray.push(item);var $tag=$('<span class="tag fill-blue dark small round inline clip '+htmlEncode(tagClass)+(null!==itemTitle?'" title="'+itemTitle:"")+'"><span class="pad0y pad2x inline contain animate">'+htmlEncode(itemText)+'<i data-role="remove" class="pin-topright text-right micro dark icon icon-remove pad1x pad0y animate"></i></span></span>');$tag.data("item",item),self.findInputWrapper().before($tag),$tag.after(" ");var optionExists=$('option[value="'+encodeURIComponent(itemValue)+'"]',self.$element).length||$('option[value="'+htmlEncode(itemValue)+'"]',self.$element).length;if(self.isSelect&&!optionExists){var $option=$("<option selected>"+htmlEncode(itemText)+"</option>");$option.data("item",item),$option.attr("value",itemValue),self.$element.append($option)}dontPushVal||self.pushVal(self.options.triggerChange),(self.options.maxTags===self.itemsArray.length||self.items().toString().length===self.options.maxInputLength)&&self.$container.addClass("bootstrap-tagsinput-max"),$(".typeahead, .twitter-typeahead",self.$container).length&&self.$input.typeahead("val",""),self.$element.trigger(this.isInit?$.Event("itemAddedOnInit",{item:item,options:options}):$.Event("itemAdded",{item:item,options:options}))}}}else if(self.options.onTagExists){var $existingTag=$(".tag",self.$container).filter(function(){return $(this).data("item")===existing});self.options.onTagExists(item,$existingTag)}}}},remove:function(item,dontPushVal,options){var self=this;if(self.objectItems&&(item="object"==typeof item?$.grep(self.itemsArray,function(other){return self.options.itemValue(other)==self.options.itemValue(item)}):$.grep(self.itemsArray,function(other){return self.options.itemValue(other)==item}),item=item[item.length-1]),item){var beforeItemRemoveEvent=$.Event("beforeItemRemove",{item:item,cancel:!1,options:options});if(self.$element.trigger(beforeItemRemoveEvent),beforeItemRemoveEvent.cancel)return;$(".tag",self.$container).filter(function(){return $(this).data("item")===item}).remove(),$("option",self.$element).filter(function(){return $(this).data("item")===item}).remove(),-1!==$.inArray(item,self.itemsArray)&&self.itemsArray.splice($.inArray(item,self.itemsArray),1)}dontPushVal||self.pushVal(self.options.triggerChange),self.options.maxTags>self.itemsArray.length&&self.$container.removeClass("bootstrap-tagsinput-max"),self.$element.trigger($.Event("itemRemoved",{item:item,options:options}))},removeAll:function(){var self=this;for($(".tag",self.$container).remove(),$("option",self.$element).remove();self.itemsArray.length>0;)self.itemsArray.pop();self.pushVal(self.options.triggerChange)},refresh:function(){var self=this;$(".tag",self.$container).each(function(){var $tag=$(this),item=$tag.data("item"),itemValue=self.options.itemValue(item),itemText=self.options.itemText(item),tagClass=self.options.tagClass(item);if($tag.attr("class",null),$tag.addClass("tag "+htmlEncode(tagClass)),$tag.contents().filter(function(){return 3==this.nodeType})[0].nodeValue=htmlEncode(itemText),self.isSelect){var option=$("option",self.$element).filter(function(){return $(this).data("item")===item});option.attr("value",itemValue)}})},items:function(){return this.itemsArray},pushVal:function(){var self=this,val=$.map(self.items(),function(item){return self.options.itemValue(item).toString()});self.$element.val(val,!0),self.options.triggerChange&&self.$element.trigger("change")},build:function(options){var self=this;if(self.options=$.extend({},defaultOptions,options),self.objectItems&&(self.options.freeInput=!1),makeOptionItemFunction(self.options,"itemValue"),makeOptionItemFunction(self.options,"itemText"),makeOptionFunction(self.options,"tagClass"),self.options.typeahead){var typeahead=self.options.typeahead||{};makeOptionFunction(typeahead,"source"),self.$input.typeahead($.extend({},typeahead,{source:function(query,process){function processItems(items){for(var texts=[],i=0;i<items.length;i++){var text=self.options.itemText(items[i]);map[text]=items[i],texts.push(text)}process(texts)}this.map={};var map=this.map,data=typeahead.source(query);$.isFunction(data.success)?data.success(processItems):$.isFunction(data.then)?data.then(processItems):$.when(data).then(processItems)},updater:function(text){return self.add(this.map[text]),this.map[text]},matcher:function(text){return-1!==text.toLowerCase().indexOf(this.query.trim().toLowerCase())},sorter:function(texts){return texts.sort()},highlighter:function(text){var regex=new RegExp("("+this.query+")","gi");return text.replace(regex,"<strong>$1</strong>")}}))}if(self.options.typeaheadjs){var typeaheadConfig=null,typeaheadDatasets={},typeaheadjs=self.options.typeaheadjs;$.isArray(typeaheadjs)?(typeaheadConfig=typeaheadjs[0],typeaheadDatasets=typeaheadjs[1]):typeaheadDatasets=typeaheadjs,self.$input.typeahead(typeaheadConfig,typeaheadDatasets).on("typeahead:selected",$.proxy(function(obj,datum){self.add(typeaheadDatasets.valueKey?datum[typeaheadDatasets.valueKey]:datum),self.$input.typeahead("val","")},self))}self.$container.on("click",$.proxy(function(){self.$element.attr("disabled")||self.$input.removeAttr("disabled"),self.$input.focus()},self)),self.options.addOnBlur&&self.options.freeInput&&self.$input.on("focusout",$.proxy(function(){0===$(".typeahead, .twitter-typeahead",self.$container).length&&(self.add(self.$input.val()),self.$input.val(""))},self)),self.$container.on({focusin:function(){self.$container.addClass(self.options.focusClass)},focusout:function(){self.$container.removeClass(self.options.focusClass)}}),self.$container.on("keydown","input",$.proxy(function(event){var $input=$(event.target),$inputWrapper=self.findInputWrapper();if(self.$element.attr("disabled"))return void self.$input.attr("disabled","disabled");switch(event.which){case 8:if(0===doGetCaretPosition($input[0])){var prev=$inputWrapper.prev();prev.length&&self.remove(prev.data("item"))}break;case 46:if(0===doGetCaretPosition($input[0])){var next=$inputWrapper.next();next.length&&self.remove(next.data("item"))}break;case 37:var $prevTag=$inputWrapper.prev();0===$input.val().length&&$prevTag[0]&&($prevTag.before($inputWrapper),$input.focus());break;case 39:var $nextTag=$inputWrapper.next();0===$input.val().length&&$nextTag[0]&&($nextTag.after($inputWrapper),$input.focus())}{var textLength=$input.val().length;Math.ceil(textLength/5)}$input.attr("size",Math.max(this.inputSize,$input.val().length))},self)),self.$container.on("keypress","input",$.proxy(function(event){var $input=$(event.target);if(self.$element.attr("disabled"))return void self.$input.attr("disabled","disabled");var text=$input.val(),maxLengthReached=self.options.maxChars&&text.length>=self.options.maxChars;self.options.freeInput&&(keyCombinationInList(event,self.options.confirmKeys)||maxLengthReached)&&(0!==text.length&&(self.add(maxLengthReached?text.substr(0,self.options.maxChars):text),$input.val("")),self.options.cancelConfirmKeysOnEmpty===!1&&event.preventDefault());{var textLength=$input.val().length;Math.ceil(textLength/5)}$input.attr("size",Math.max(this.inputSize,$input.val().length))},self)),self.$container.on("click","[data-role=remove]",$.proxy(function(event){self.$element.attr("disabled")||self.remove($(event.target).closest(".tag").data("item"))},self)),self.options.itemValue===defaultOptions.itemValue&&("INPUT"===self.$element[0].tagName?self.add(self.$element.val()):$("option",self.$element).each(function(){self.add($(this).attr("value"),!0)}))},destroy:function(){var self=this;self.$container.off("keypress","input"),self.$container.off("click","[role=remove]"),self.$container.remove(),self.$element.removeData("tagsinput"),self.$element.show()},focus:function(){this.$input.focus()},input:function(){return this.$input},findInputWrapper:function(){for(var elt=this.$input[0],container=this.$container[0];elt&&elt.parentNode!==container;)elt=elt.parentNode;return $(elt)}},$.fn.tagsinput=function(arg1,arg2,arg3){var results=[];return this.each(function(){var tagsinput=$(this).data("tagsinput");if(tagsinput)if(arg1||arg2){if(void 0!==tagsinput[arg1]){if(3===tagsinput[arg1].length&&void 0!==arg3)var retVal=tagsinput[arg1](arg2,null,arg3);else var retVal=tagsinput[arg1](arg2);void 0!==retVal&&results.push(retVal)}}else results.push(tagsinput);else tagsinput=new TagsInput(this,arg1),$(this).data("tagsinput",tagsinput),results.push(tagsinput),"SELECT"===this.tagName&&$("option",$(this)).attr("selected","selected"),$(this).val($(this).val())}),"string"==typeof arg1?results.length>1?results:results[0]:results},$.fn.tagsinput.Constructor=TagsInput;var htmlEncodeContainer=$("<div />");$(function(){$("input[data-role=tagsinput], select[multiple][data-role=tagsinput]").tagsinput()})}(window.jQuery),+function($){"use strict";function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data("bs.tooltip"),options="object"==typeof option&&option,selector=options&&options.selector;(data||"destroy"!=option)&&(selector?(data||$this.data("bs.tooltip",data={}),data[selector]||(data[selector]=new Tooltip(this,options))):data||$this.data("bs.tooltip",data=new Tooltip(this,options)),"string"==typeof option&&data[option]())})}var Tooltip=function(element,options){this.type=this.options=this.enabled=this.timeout=this.hoverState=this.$element=null,this.init("tooltip",element,options)};Tooltip.VERSION="3.3.0",Tooltip.TRANSITION_DURATION=150,Tooltip.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},Tooltip.prototype.init=function(type,element,options){this.enabled=!0,this.type=type,this.$element=$(element),this.options=this.getOptions(options),this.$viewport=this.options.viewport&&$(this.options.viewport.selector||this.options.viewport);for(var triggers=this.options.trigger.split(" "),i=triggers.length;i--;){var trigger=triggers[i];if("click"==trigger)this.$element.on("click."+this.type,this.options.selector,$.proxy(this.toggle,this));else if("manual"!=trigger){var eventIn="hover"==trigger?"mouseenter":"focusin",eventOut="hover"==trigger?"mouseleave":"focusout";this.$element.on(eventIn+"."+this.type,this.options.selector,$.proxy(this.enter,this)),this.$element.on(eventOut+"."+this.type,this.options.selector,$.proxy(this.leave,this))}}this.options.selector?this._options=$.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},Tooltip.prototype.getDefaults=function(){return Tooltip.DEFAULTS},Tooltip.prototype.getOptions=function(options){return options=$.extend({},this.getDefaults(),this.$element.data(),options),options.delay&&"number"==typeof options.delay&&(options.delay={show:options.delay,hide:options.delay}),options},Tooltip.prototype.getDelegateOptions=function(){var options={},defaults=this.getDefaults();return this._options&&$.each(this._options,function(key,value){defaults[key]!=value&&(options[key]=value)}),options},Tooltip.prototype.enter=function(obj){var self=obj instanceof this.constructor?obj:$(obj.currentTarget).data("bs."+this.type);return self&&self.$tip&&self.$tip.is(":visible")?void(self.hoverState="in"):(self||(self=new this.constructor(obj.currentTarget,this.getDelegateOptions()),$(obj.currentTarget).data("bs."+this.type,self)),clearTimeout(self.timeout),self.hoverState="in",self.options.delay&&self.options.delay.show?void(self.timeout=setTimeout(function(){"in"==self.hoverState&&self.show()},self.options.delay.show)):self.show())},Tooltip.prototype.leave=function(obj){var self=obj instanceof this.constructor?obj:$(obj.currentTarget).data("bs."+this.type);return self||(self=new this.constructor(obj.currentTarget,this.getDelegateOptions()),$(obj.currentTarget).data("bs."+this.type,self)),clearTimeout(self.timeout),self.hoverState="out",self.options.delay&&self.options.delay.hide?void(self.timeout=setTimeout(function(){"out"==self.hoverState&&self.hide()},self.options.delay.hide)):self.hide()},Tooltip.prototype.show=function(){var e=$.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(e);var inDom=$.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(e.isDefaultPrevented()||!inDom)return;var that=this,$tip=this.tip(),tipId=this.getUID(this.type);this.setContent(),$tip.attr("id",tipId),this.$element.attr("aria-describedby",tipId),this.options.animation&&$tip.addClass("fade");var placement="function"==typeof this.options.placement?this.options.placement.call(this,$tip[0],this.$element[0]):this.options.placement,autoToken=/\s?auto?\s?/i,autoPlace=autoToken.test(placement);autoPlace&&(placement=placement.replace(autoToken,"")||"top"),$tip.detach().css({top:0,left:0,display:"block"}).addClass(placement).data("bs."+this.type,this),this.options.container?$tip.appendTo(this.options.container):$tip.insertAfter(this.$element);var pos=this.getPosition(),actualWidth=$tip[0].offsetWidth,actualHeight=$tip[0].offsetHeight;if(autoPlace){var orgPlacement=placement,$container=this.options.container?$(this.options.container):this.$element.parent(),containerDim=this.getPosition($container);placement="bottom"==placement&&pos.bottom+actualHeight>containerDim.bottom?"top":"top"==placement&&pos.top-actualHeight<containerDim.top?"bottom":"right"==placement&&pos.right+actualWidth>containerDim.width?"left":"left"==placement&&pos.left-actualWidth<containerDim.left?"right":placement,$tip.removeClass(orgPlacement).addClass(placement)}var calculatedOffset=this.getCalculatedOffset(placement,pos,actualWidth,actualHeight);this.applyPlacement(calculatedOffset,placement);var complete=function(){var prevHoverState=that.hoverState;that.$element.trigger("shown.bs."+that.type),that.hoverState=null,"out"==prevHoverState&&that.leave(that)};$.support.transition&&this.$tip.hasClass("fade")?$tip.one("bsTransitionEnd",complete).emulateTransitionEnd(Tooltip.TRANSITION_DURATION):complete()}},Tooltip.prototype.applyPlacement=function(offset,placement){var $tip=this.tip(),width=$tip[0].offsetWidth,height=$tip[0].offsetHeight,marginTop=parseInt($tip.css("margin-top"),10),marginLeft=parseInt($tip.css("margin-left"),10);isNaN(marginTop)&&(marginTop=0),isNaN(marginLeft)&&(marginLeft=0),offset.top=offset.top+marginTop,offset.left=offset.left+marginLeft,$.offset.setOffset($tip[0],$.extend({using:function(props){$tip.css({top:Math.round(props.top),left:Math.round(props.left)})}},offset),0),$tip.addClass("in");var actualWidth=$tip[0].offsetWidth,actualHeight=$tip[0].offsetHeight;"top"==placement&&actualHeight!=height&&(offset.top=offset.top+height-actualHeight);var delta=this.getViewportAdjustedDelta(placement,offset,actualWidth,actualHeight);delta.left?offset.left+=delta.left:offset.top+=delta.top;var isVertical=/top|bottom/.test(placement),arrowDelta=isVertical?2*delta.left-width+actualWidth:2*delta.top-height+actualHeight,arrowOffsetPosition=isVertical?"offsetWidth":"offsetHeight";$tip.offset(offset),this.replaceArrow(arrowDelta,$tip[0][arrowOffsetPosition],isVertical)},Tooltip.prototype.replaceArrow=function(delta,dimension,isHorizontal){this.arrow().css(isHorizontal?"left":"top",50*(1-delta/dimension)+"%").css(isHorizontal?"top":"left","")},Tooltip.prototype.setContent=function(){var $tip=this.tip(),title=this.getTitle();$tip.find(".tooltip-inner")[this.options.html?"html":"text"](title),$tip.removeClass("fade in top bottom left right")},Tooltip.prototype.hide=function(callback){function complete(){"in"!=that.hoverState&&$tip.detach(),that.$element.removeAttr("aria-describedby").trigger("hidden.bs."+that.type),callback&&callback()}var that=this,$tip=this.tip(),e=$.Event("hide.bs."+this.type);return this.$element.trigger(e),e.isDefaultPrevented()?void 0:($tip.removeClass("in"),$.support.transition&&this.$tip.hasClass("fade")?$tip.one("bsTransitionEnd",complete).emulateTransitionEnd(Tooltip.TRANSITION_DURATION):complete(),this.hoverState=null,this)},Tooltip.prototype.fixTitle=function(){var $e=this.$element;($e.attr("title")||"string"!=typeof $e.attr("data-original-title"))&&$e.attr("data-original-title",$e.attr("title")||"").attr("title","")},Tooltip.prototype.hasContent=function(){return this.getTitle()},Tooltip.prototype.getPosition=function($element){$element=$element||this.$element;var el=$element[0],isBody="BODY"==el.tagName,elRect=el.getBoundingClientRect();null==elRect.width&&(elRect=$.extend({},elRect,{width:elRect.right-elRect.left,height:elRect.bottom-elRect.top}));var elOffset=isBody?{top:0,left:0}:$element.offset(),scroll={scroll:isBody?document.documentElement.scrollTop||document.body.scrollTop:$element.scrollTop()},outerDims=isBody?{width:$(window).width(),height:$(window).height()}:null;return $.extend({},elRect,scroll,outerDims,elOffset)},Tooltip.prototype.getCalculatedOffset=function(placement,pos,actualWidth,actualHeight){return"bottom"==placement?{top:pos.top+pos.height,left:pos.left+pos.width/2-actualWidth/2}:"top"==placement?{top:pos.top-actualHeight,left:pos.left+pos.width/2-actualWidth/2}:"left"==placement?{top:pos.top+pos.height/2-actualHeight/2,left:pos.left-actualWidth}:{top:pos.top+pos.height/2-actualHeight/2,left:pos.left+pos.width}},Tooltip.prototype.getViewportAdjustedDelta=function(placement,pos,actualWidth,actualHeight){var delta={top:0,left:0};if(!this.$viewport)return delta;var viewportPadding=this.options.viewport&&this.options.viewport.padding||0,viewportDimensions=this.getPosition(this.$viewport);if(/right|left/.test(placement)){var topEdgeOffset=pos.top-viewportPadding-viewportDimensions.scroll,bottomEdgeOffset=pos.top+viewportPadding-viewportDimensions.scroll+actualHeight;topEdgeOffset<viewportDimensions.top?delta.top=viewportDimensions.top-topEdgeOffset:bottomEdgeOffset>viewportDimensions.top+viewportDimensions.height&&(delta.top=viewportDimensions.top+viewportDimensions.height-bottomEdgeOffset)}else{var leftEdgeOffset=pos.left-viewportPadding,rightEdgeOffset=pos.left+viewportPadding+actualWidth;leftEdgeOffset<viewportDimensions.left?delta.left=viewportDimensions.left-leftEdgeOffset:rightEdgeOffset>viewportDimensions.width&&(delta.left=viewportDimensions.left+viewportDimensions.width-rightEdgeOffset)}return delta},Tooltip.prototype.getTitle=function(){var title,$e=this.$element,o=this.options;return title=$e.attr("data-original-title")||("function"==typeof o.title?o.title.call($e[0]):o.title)},Tooltip.prototype.getUID=function(prefix){do prefix+=~~(1e6*Math.random());while(document.getElementById(prefix));return prefix},Tooltip.prototype.tip=function(){return this.$tip=this.$tip||$(this.options.template)},Tooltip.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},Tooltip.prototype.enable=function(){this.enabled=!0},Tooltip.prototype.disable=function(){this.enabled=!1},Tooltip.prototype.toggleEnabled=function(){this.enabled=!this.enabled},Tooltip.prototype.toggle=function(e){var self=this;e&&(self=$(e.currentTarget).data("bs."+this.type),self||(self=new this.constructor(e.currentTarget,this.getDelegateOptions()),$(e.currentTarget).data("bs."+this.type,self))),self.tip().hasClass("in")?self.leave(self):self.enter(self)},Tooltip.prototype.destroy=function(){var that=this;clearTimeout(this.timeout),this.hide(function(){that.$element.off("."+that.type).removeData("bs."+that.type)})};var old=$.fn.tooltip;$.fn.tooltip=Plugin,$.fn.tooltip.Constructor=Tooltip,$.fn.tooltip.noConflict=function(){return $.fn.tooltip=old,this}}(jQuery),+function($){"use strict";function transitionEnd(){var el=document.createElement("bootstrap"),transEndEventNames={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var name in transEndEventNames)if(void 0!==el.style[name])return{end:transEndEventNames[name]};return!1}$.fn.emulateTransitionEnd=function(duration){var called=!1,$el=this;$(this).one("bsTransitionEnd",function(){called=!0});var callback=function(){called||$($el).trigger($.support.transition.end)};return setTimeout(callback,duration),this},$(function(){$.support.transition=transitionEnd(),$.support.transition&&($.event.special.bsTransitionEnd={bindType:$.support.transition.end,delegateType:$.support.transition.end,handle:function(e){return $(e.target).is(this)?e.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),function($){var _=function(){"use strict";return{isMsie:function(){return/(msie|trident)/i.test(navigator.userAgent)?navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]:!1},isBlankString:function(str){return!str||/^\s*$/.test(str)},escapeRegExChars:function(str){return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isString:function(obj){return"string"==typeof obj},isNumber:function(obj){return"number"==typeof obj},isArray:$.isArray,isFunction:$.isFunction,isObject:$.isPlainObject,isUndefined:function(obj){return"undefined"==typeof obj},toStr:function(s){return _.isUndefined(s)||null===s?"":s+""},bind:$.proxy,each:function(collection,cb){function reverseArgs(index,value){return cb(value,index)}$.each(collection,reverseArgs)},map:$.map,filter:$.grep,every:function(obj,test){var result=!0;return obj?($.each(obj,function(key,val){return(result=test.call(null,val,key,obj))?void 0:!1}),!!result):result},some:function(obj,test){var result=!1;return obj?($.each(obj,function(key,val){return(result=test.call(null,val,key,obj))?!1:void 0}),!!result):result},mixin:$.extend,getUniqueId:function(){var counter=0;return function(){return counter++}}(),templatify:function(obj){function template(){return String(obj)}return $.isFunction(obj)?obj:template},defer:function(fn){setTimeout(fn,0)},debounce:function(func,wait,immediate){var timeout,result;return function(){var later,callNow,context=this,args=arguments;return later=function(){timeout=null,immediate||(result=func.apply(context,args))},callNow=immediate&&!timeout,clearTimeout(timeout),timeout=setTimeout(later,wait),callNow&&(result=func.apply(context,args)),result}},throttle:function(func,wait){var context,args,timeout,result,previous,later;return previous=0,later=function(){previous=new Date,timeout=null,result=func.apply(context,args)},function(){var now=new Date,remaining=wait-(now-previous);return context=this,args=arguments,0>=remaining?(clearTimeout(timeout),timeout=null,previous=now,result=func.apply(context,args)):timeout||(timeout=setTimeout(later,remaining)),result}},noop:function(){}}}(),VERSION="0.10.5",tokenizers=function(){"use strict";function whitespace(str){return str=_.toStr(str),str?str.split(/\s+/):[]}function nonword(str){return str=_.toStr(str),str?str.split(/\W+/):[]}function getObjTokenizer(tokenizer){return function(){var args=[].slice.call(arguments,0);return function(o){var tokens=[];return _.each(args,function(k){tokens=tokens.concat(tokenizer(_.toStr(o[k])))}),tokens}}}return{nonword:nonword,whitespace:whitespace,obj:{nonword:getObjTokenizer(nonword),whitespace:getObjTokenizer(whitespace)}}}(),LruCache=function(){"use strict";function LruCache(maxSize){this.maxSize=_.isNumber(maxSize)?maxSize:100,this.reset(),this.maxSize<=0&&(this.set=this.get=$.noop)}function List(){this.head=this.tail=null}function Node(key,val){this.key=key,this.val=val,this.prev=this.next=null}return _.mixin(LruCache.prototype,{set:function(key,val){var node,tailItem=this.list.tail;this.size>=this.maxSize&&(this.list.remove(tailItem),delete this.hash[tailItem.key]),(node=this.hash[key])?(node.val=val,this.list.moveToFront(node)):(node=new Node(key,val),this.list.add(node),this.hash[key]=node,this.size++)},get:function(key){var node=this.hash[key];return node?(this.list.moveToFront(node),node.val):void 0},reset:function(){this.size=0,this.hash={},this.list=new List}}),_.mixin(List.prototype,{add:function(node){this.head&&(node.next=this.head,this.head.prev=node),this.head=node,this.tail=this.tail||node},remove:function(node){node.prev?node.prev.next=node.next:this.head=node.next,node.next?node.next.prev=node.prev:this.tail=node.prev},moveToFront:function(node){this.remove(node),this.add(node)}}),LruCache}(),PersistentStorage=function(){"use strict";function PersistentStorage(namespace){this.prefix=["__",namespace,"__"].join(""),this.ttlKey="__ttl__",this.keyMatcher=new RegExp("^"+_.escapeRegExChars(this.prefix))}function now(){return(new Date).getTime()}function encode(val){return JSON.stringify(_.isUndefined(val)?null:val)}function decode(val){return JSON.parse(val)}var ls,methods;try{ls=window.localStorage,ls.setItem("~~~","!"),ls.removeItem("~~~")}catch(err){ls=null}return methods=ls&&window.JSON?{_prefix:function(key){return this.prefix+key},_ttlKey:function(key){return this._prefix(key)+this.ttlKey},get:function(key){return this.isExpired(key)&&this.remove(key),decode(ls.getItem(this._prefix(key)))},set:function(key,val,ttl){return _.isNumber(ttl)?ls.setItem(this._ttlKey(key),encode(now()+ttl)):ls.removeItem(this._ttlKey(key)),ls.setItem(this._prefix(key),encode(val))},remove:function(key){return ls.removeItem(this._ttlKey(key)),ls.removeItem(this._prefix(key)),this},clear:function(){var i,key,keys=[],len=ls.length;for(i=0;len>i;i++)(key=ls.key(i)).match(this.keyMatcher)&&keys.push(key.replace(this.keyMatcher,""));for(i=keys.length;i--;)this.remove(keys[i]);return this},isExpired:function(key){var ttl=decode(ls.getItem(this._ttlKey(key)));return _.isNumber(ttl)&&now()>ttl?!0:!1}}:{get:_.noop,set:_.noop,remove:_.noop,clear:_.noop,isExpired:_.noop},_.mixin(PersistentStorage.prototype,methods),PersistentStorage}(),Transport=function(){"use strict";function Transport(o){o=o||{},this.cancelled=!1,this.lastUrl=null,this._send=o.transport?callbackToDeferred(o.transport):$.ajax,this._get=o.rateLimiter?o.rateLimiter(this._get):this._get,this._cache=o.cache===!1?new LruCache(0):sharedCache}function callbackToDeferred(fn){return function(url,o){function onSuccess(resp){_.defer(function(){deferred.resolve(resp)})}function onError(err){_.defer(function(){deferred.reject(err)})}var deferred=$.Deferred();return fn(url,o,onSuccess,onError),deferred}}var pendingRequestsCount=0,pendingRequests={},maxPendingRequests=6,sharedCache=new LruCache(10);return Transport.setMaxPendingRequests=function(num){maxPendingRequests=num},Transport.resetCache=function(){sharedCache.reset()},_.mixin(Transport.prototype,{_get:function(url,o,cb){function done(resp){cb&&cb(null,resp),that._cache.set(url,resp)}function fail(){cb&&cb(!0)}function always(){pendingRequestsCount--,delete pendingRequests[url],that.onDeckRequestArgs&&(that._get.apply(that,that.onDeckRequestArgs),that.onDeckRequestArgs=null)}var jqXhr,that=this;this.cancelled||url!==this.lastUrl||((jqXhr=pendingRequests[url])?jqXhr.done(done).fail(fail):maxPendingRequests>pendingRequestsCount?(pendingRequestsCount++,pendingRequests[url]=this._send(url,o).done(done).fail(fail).always(always)):this.onDeckRequestArgs=[].slice.call(arguments,0))},get:function(url,o,cb){var resp;return _.isFunction(o)&&(cb=o,o={}),this.cancelled=!1,this.lastUrl=url,(resp=this._cache.get(url))?_.defer(function(){cb&&cb(null,resp)}):this._get(url,o,cb),!!resp},cancel:function(){this.cancelled=!0}}),Transport}(),SearchIndex=function(){"use strict";function SearchIndex(o){o=o||{},o.datumTokenizer&&o.queryTokenizer||$.error("datumTokenizer and queryTokenizer are both required"),this.datumTokenizer=o.datumTokenizer,this.queryTokenizer=o.queryTokenizer,this.reset()}function normalizeTokens(tokens){return tokens=_.filter(tokens,function(token){return!!token}),tokens=_.map(tokens,function(token){return token.toLowerCase()})}function newNode(){return{ids:[],children:{}}}function unique(array){for(var seen={},uniques=[],i=0,len=array.length;len>i;i++)seen[array[i]]||(seen[array[i]]=!0,uniques.push(array[i]));return uniques}function getIntersection(arrayA,arrayB){function compare(a,b){return a-b}var ai=0,bi=0,intersection=[];arrayA=arrayA.sort(compare),arrayB=arrayB.sort(compare);
  for(var lenArrayA=arrayA.length,lenArrayB=arrayB.length;lenArrayA>ai&&lenArrayB>bi;)arrayA[ai]<arrayB[bi]?ai++:arrayA[ai]>arrayB[bi]?bi++:(intersection.push(arrayA[ai]),ai++,bi++);return intersection}return _.mixin(SearchIndex.prototype,{bootstrap:function(o){this.datums=o.datums,this.trie=o.trie},add:function(data){var that=this;data=_.isArray(data)?data:[data],_.each(data,function(datum){var id,tokens;id=that.datums.push(datum)-1,tokens=normalizeTokens(that.datumTokenizer(datum)),_.each(tokens,function(token){var node,chars,ch;for(node=that.trie,chars=token.split("");ch=chars.shift();)node=node.children[ch]||(node.children[ch]=newNode()),node.ids.push(id)})})},get:function(query){var tokens,matches,that=this;return tokens=normalizeTokens(this.queryTokenizer(query)),_.each(tokens,function(token){var node,chars,ch,ids;if(matches&&0===matches.length)return!1;for(node=that.trie,chars=token.split("");node&&(ch=chars.shift());)node=node.children[ch];return node&&0===chars.length?(ids=node.ids.slice(0),void(matches=matches?getIntersection(matches,ids):ids)):(matches=[],!1)}),matches?_.map(unique(matches),function(id){return that.datums[id]}):[]},reset:function(){this.datums=[],this.trie=newNode()},serialize:function(){return{datums:this.datums,trie:this.trie}}}),SearchIndex}(),oParser=function(){"use strict";function getLocal(o){return o.local||null}function getPrefetch(o){var prefetch,defaults;return defaults={url:null,thumbprint:"",ttl:864e5,filter:null,ajax:{}},(prefetch=o.prefetch||null)&&(prefetch=_.isString(prefetch)?{url:prefetch}:prefetch,prefetch=_.mixin(defaults,prefetch),prefetch.thumbprint=VERSION+prefetch.thumbprint,prefetch.ajax.type=prefetch.ajax.type||"GET",prefetch.ajax.dataType=prefetch.ajax.dataType||"json",!prefetch.url&&$.error("prefetch requires url to be set")),prefetch}function getRemote(o){function byDebounce(wait){return function(fn){return _.debounce(fn,wait)}}function byThrottle(wait){return function(fn){return _.throttle(fn,wait)}}var remote,defaults;return defaults={url:null,cache:!0,wildcard:"%QUERY",replace:null,rateLimitBy:"debounce",rateLimitWait:300,send:null,filter:null,ajax:{}},(remote=o.remote||null)&&(remote=_.isString(remote)?{url:remote}:remote,remote=_.mixin(defaults,remote),remote.rateLimiter=/^throttle$/i.test(remote.rateLimitBy)?byThrottle(remote.rateLimitWait):byDebounce(remote.rateLimitWait),remote.ajax.type=remote.ajax.type||"GET",remote.ajax.dataType=remote.ajax.dataType||"json",delete remote.rateLimitBy,delete remote.rateLimitWait,!remote.url&&$.error("remote requires url to be set")),remote}return{local:getLocal,prefetch:getPrefetch,remote:getRemote}}();!function(root){"use strict";function Bloodhound(o){o&&(o.local||o.prefetch||o.remote)||$.error("one of local, prefetch, or remote is required"),this.limit=o.limit||5,this.sorter=getSorter(o.sorter),this.dupDetector=o.dupDetector||ignoreDuplicates,this.local=oParser.local(o),this.prefetch=oParser.prefetch(o),this.remote=oParser.remote(o),this.cacheKey=this.prefetch?this.prefetch.cacheKey||this.prefetch.url:null,this.index=new SearchIndex({datumTokenizer:o.datumTokenizer,queryTokenizer:o.queryTokenizer}),this.storage=this.cacheKey?new PersistentStorage(this.cacheKey):null}function getSorter(sortFn){function sort(array){return array.sort(sortFn)}function noSort(array){return array}return _.isFunction(sortFn)?sort:noSort}function ignoreDuplicates(){return!1}var old,keys;return old=root.Bloodhound,keys={data:"data",protocol:"protocol",thumbprint:"thumbprint"},root.Bloodhound=Bloodhound,Bloodhound.noConflict=function(){return root.Bloodhound=old,Bloodhound},Bloodhound.tokenizers=tokenizers,_.mixin(Bloodhound.prototype,{_loadPrefetch:function(o){function handlePrefetchResponse(resp){that.clear(),that.add(o.filter?o.filter(resp):resp),that._saveToStorage(that.index.serialize(),o.thumbprint,o.ttl)}var serialized,deferred,that=this;return(serialized=this._readFromStorage(o.thumbprint))?(this.index.bootstrap(serialized),deferred=$.Deferred().resolve()):deferred=$.ajax(o.url,o.ajax).done(handlePrefetchResponse),deferred},_getFromRemote:function(query,cb){function handleRemoteResponse(err,resp){cb(err?[]:that.remote.filter?that.remote.filter(resp):resp)}var url,uriEncodedQuery,that=this;if(this.transport)return query=query||"",uriEncodedQuery=encodeURIComponent(query),url=this.remote.replace?this.remote.replace(this.remote.url,query):this.remote.url.replace(this.remote.wildcard,uriEncodedQuery),this.transport.get(url,this.remote.ajax,handleRemoteResponse)},_cancelLastRemoteRequest:function(){this.transport&&this.transport.cancel()},_saveToStorage:function(data,thumbprint,ttl){this.storage&&(this.storage.set(keys.data,data,ttl),this.storage.set(keys.protocol,location.protocol,ttl),this.storage.set(keys.thumbprint,thumbprint,ttl))},_readFromStorage:function(thumbprint){var isExpired,stored={};return this.storage&&(stored.data=this.storage.get(keys.data),stored.protocol=this.storage.get(keys.protocol),stored.thumbprint=this.storage.get(keys.thumbprint)),isExpired=stored.thumbprint!==thumbprint||stored.protocol!==location.protocol,stored.data&&!isExpired?stored.data:null},_initialize:function(){function addLocalToIndex(){that.add(_.isFunction(local)?local():local)}var deferred,that=this,local=this.local;return deferred=this.prefetch?this._loadPrefetch(this.prefetch):$.Deferred().resolve(),local&&deferred.done(addLocalToIndex),this.transport=this.remote?new Transport(this.remote):null,this.initPromise=deferred.promise()},initialize:function(force){return!this.initPromise||force?this._initialize():this.initPromise},add:function(data){this.index.add(data)},get:function(query,cb){function returnRemoteMatches(remoteMatches){var matchesWithBackfill=matches.slice(0);_.each(remoteMatches,function(remoteMatch){var isDuplicate;return isDuplicate=_.some(matchesWithBackfill,function(match){return that.dupDetector(remoteMatch,match)}),!isDuplicate&&matchesWithBackfill.push(remoteMatch),matchesWithBackfill.length<that.limit}),cb&&cb(that.sorter(matchesWithBackfill))}var that=this,matches=[],cacheHit=!1;matches=this.index.get(query),matches=this.sorter(matches).slice(0,this.limit),matches.length<this.limit?cacheHit=this._getFromRemote(query,returnRemoteMatches):this._cancelLastRemoteRequest(),cacheHit||(matches.length>0||!this.transport)&&cb&&cb(matches)},clear:function(){this.index.reset()},clearPrefetchCache:function(){this.storage&&this.storage.clear()},clearRemoteCache:function(){this.transport&&Transport.resetCache()},ttAdapter:function(){return _.bind(this.get,this)}}),Bloodhound}(this);var html=function(){return{wrapper:'<span class="twitter-typeahead inline col-xs-12"></span>',dropdown:'<span class="tt-dropdown-menu dropdown-menu col-xs-12"></span>',dataset:'<div class="tt-dataset-%CLASS%"></div>',suggestions:'<span class="tt-suggestions block"></span>',suggestion:'<div class="tt-suggestion pad0y pad2x"></div>'}}(),css=function(){"use strict";var css={wrapper:{},hint:{borderColor:"transparent",boxShadow:"none",opacity:"1"},input:{position:"relative",verticalAlign:"top"},inputWithNoHint:{position:"relative",verticalAlign:"top"},dropdown:{position:"absolute",top:"100%",left:"0",zIndex:"100",display:"none"},suggestions:{},suggestion:{whiteSpace:"nowrap",cursor:"pointer"},suggestionChild:{whiteSpace:"normal"},ltr:{left:"0",right:"auto"},rtl:{left:"auto",right:" 0"}};return _.isMsie()&&_.mixin(css.input,{backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)"}),_.isMsie()&&_.isMsie()<=7&&_.mixin(css.input,{marginTop:"-1px"}),css}(),EventBus=function(){"use strict";function EventBus(o){o&&o.el||$.error("EventBus initialized without el"),this.$el=$(o.el)}var namespace="typeahead:";return _.mixin(EventBus.prototype,{trigger:function(type){var args=[].slice.call(arguments,1);this.$el.trigger(namespace+type,args)}}),EventBus}(),EventEmitter=function(){"use strict";function on(method,types,cb,context){var type;if(!cb)return this;for(types=types.split(splitter),cb=context?bindContext(cb,context):cb,this._callbacks=this._callbacks||{};type=types.shift();)this._callbacks[type]=this._callbacks[type]||{sync:[],async:[]},this._callbacks[type][method].push(cb);return this}function onAsync(types,cb,context){return on.call(this,"async",types,cb,context)}function onSync(types,cb,context){return on.call(this,"sync",types,cb,context)}function off(types){var type;if(!this._callbacks)return this;for(types=types.split(splitter);type=types.shift();)delete this._callbacks[type];return this}function trigger(types){var type,callbacks,args,syncFlush,asyncFlush;if(!this._callbacks)return this;for(types=types.split(splitter),args=[].slice.call(arguments,1);(type=types.shift())&&(callbacks=this._callbacks[type]);)syncFlush=getFlush(callbacks.sync,this,[type].concat(args)),asyncFlush=getFlush(callbacks.async,this,[type].concat(args)),syncFlush()&&nextTick(asyncFlush);return this}function getFlush(callbacks,context,args){function flush(){for(var cancelled,i=0,len=callbacks.length;!cancelled&&len>i;i+=1)cancelled=callbacks[i].apply(context,args)===!1;return!cancelled}return flush}function getNextTick(){var nextTickFn;return nextTickFn=window.setImmediate?function(fn){setImmediate(function(){fn()})}:function(fn){setTimeout(function(){fn()},0)}}function bindContext(fn,context){return fn.bind?fn.bind(context):function(){fn.apply(context,[].slice.call(arguments,0))}}var splitter=/\s+/,nextTick=getNextTick();return{onSync:onSync,onAsync:onAsync,off:off,trigger:trigger}}(),highlight=function(doc){"use strict";function getRegex(patterns,caseSensitive,wordsOnly){for(var regexStr,escapedPatterns=[],i=0,len=patterns.length;len>i;i++)escapedPatterns.push(_.escapeRegExChars(patterns[i]));return regexStr=wordsOnly?"\\b("+escapedPatterns.join("|")+")\\b":"("+escapedPatterns.join("|")+")",caseSensitive?new RegExp(regexStr):new RegExp(regexStr,"i")}var defaults={node:null,pattern:null,tagName:"strong",className:null,wordsOnly:!1,caseSensitive:!1};return function(o){function hightlightTextNode(textNode){var match,patternNode,wrapperNode;return(match=regex.exec(textNode.data))&&(wrapperNode=doc.createElement(o.tagName),o.className&&(wrapperNode.className=o.className),patternNode=textNode.splitText(match.index),patternNode.splitText(match[0].length),wrapperNode.appendChild(patternNode.cloneNode(!0)),textNode.parentNode.replaceChild(wrapperNode,patternNode)),!!match}function traverse(el,hightlightTextNode){for(var childNode,TEXT_NODE_TYPE=3,i=0;i<el.childNodes.length;i++)childNode=el.childNodes[i],childNode.nodeType===TEXT_NODE_TYPE?i+=hightlightTextNode(childNode)?1:0:traverse(childNode,hightlightTextNode)}var regex;o=_.mixin({},defaults,o),o.node&&o.pattern&&(o.pattern=_.isArray(o.pattern)?o.pattern:[o.pattern],regex=getRegex(o.pattern,o.caseSensitive,o.wordsOnly),traverse(o.node,hightlightTextNode))}}(window.document),Input=function(){"use strict";function Input(o){var onBlur,onFocus,onKeydown,onInput,that=this;o=o||{},o.input||$.error("input is missing"),onBlur=_.bind(this._onBlur,this),onFocus=_.bind(this._onFocus,this),onKeydown=_.bind(this._onKeydown,this),onInput=_.bind(this._onInput,this),this.$hint=$(o.hint),this.$input=$(o.input).on("blur.tt",onBlur).on("focus.tt",onFocus).on("keydown.tt",onKeydown),0===this.$hint.length&&(this.setHint=this.getHint=this.clearHint=this.clearHintIfInvalid=_.noop),_.isMsie()?this.$input.on("keydown.tt keypress.tt cut.tt paste.tt",function($e){specialKeyCodeMap[$e.which||$e.keyCode]||_.defer(_.bind(that._onInput,that,$e))}):this.$input.on("input.tt",onInput),this.query=this.$input.val(),this.$overflowHelper=buildOverflowHelper(this.$input)}function buildOverflowHelper($input){return $('<pre aria-hidden="true"></pre>').css({position:"absolute",visibility:"hidden",whiteSpace:"pre",fontFamily:$input.css("font-family"),fontSize:$input.css("font-size"),fontStyle:$input.css("font-style"),fontVariant:$input.css("font-variant"),fontWeight:$input.css("font-weight"),wordSpacing:$input.css("word-spacing"),letterSpacing:$input.css("letter-spacing"),textIndent:$input.css("text-indent"),textRendering:$input.css("text-rendering"),textTransform:$input.css("text-transform")}).insertAfter($input)}function areQueriesEquivalent(a,b){return Input.normalizeQuery(a)===Input.normalizeQuery(b)}function withModifier($e){return $e.altKey||$e.ctrlKey||$e.metaKey||$e.shiftKey}var specialKeyCodeMap;return specialKeyCodeMap={9:"tab",27:"esc",37:"left",39:"right",13:"enter",38:"up",40:"down"},Input.normalizeQuery=function(str){return(str||"").replace(/^\s*/g,"").replace(/\s{2,}/g," ")},_.mixin(Input.prototype,EventEmitter,{_onBlur:function(){this.resetInputValue(),this.trigger("blurred")},_onFocus:function(){this.trigger("focused")},_onKeydown:function($e){var keyName=specialKeyCodeMap[$e.which||$e.keyCode];this._managePreventDefault(keyName,$e),keyName&&this._shouldTrigger(keyName,$e)&&this.trigger(keyName+"Keyed",$e)},_onInput:function(){this._checkInputValue()},_managePreventDefault:function(keyName,$e){var preventDefault,hintValue,inputValue;switch(keyName){case"tab":hintValue=this.getHint(),inputValue=this.getInputValue(),preventDefault=hintValue&&hintValue!==inputValue&&!withModifier($e);break;case"up":case"down":preventDefault=!withModifier($e);break;default:preventDefault=!1}preventDefault&&$e.preventDefault()},_shouldTrigger:function(keyName,$e){var trigger;switch(keyName){case"tab":trigger=!withModifier($e);break;default:trigger=!0}return trigger},_checkInputValue:function(){var inputValue,areEquivalent,hasDifferentWhitespace;inputValue=this.getInputValue(),areEquivalent=areQueriesEquivalent(inputValue,this.query),hasDifferentWhitespace=areEquivalent?this.query.length!==inputValue.length:!1,this.query=inputValue,areEquivalent?hasDifferentWhitespace&&this.trigger("whitespaceChanged",this.query):this.trigger("queryChanged",this.query)},focus:function(){this.$input.focus()},blur:function(){this.$input.blur()},getQuery:function(){return this.query},setQuery:function(query){this.query=query},getInputValue:function(){return this.$input.val()},setInputValue:function(value,silent){this.$input.val(value),silent?this.clearHint():this._checkInputValue()},resetInputValue:function(){this.setInputValue(this.query,!0)},getHint:function(){return this.$hint.val()},setHint:function(value){this.$hint.val(value)},clearHint:function(){this.setHint("")},clearHintIfInvalid:function(){var val,hint,valIsPrefixOfHint,isValid;val=this.getInputValue(),hint=this.getHint(),valIsPrefixOfHint=val!==hint&&0===hint.indexOf(val),isValid=""!==val&&valIsPrefixOfHint&&!this.hasOverflow(),!isValid&&this.clearHint()},getLanguageDirection:function(){return(this.$input.css("direction")||"ltr").toLowerCase()},hasOverflow:function(){var constraint=this.$input.width()-2;return this.$overflowHelper.text(this.getInputValue()),this.$overflowHelper.width()>=constraint},isCursorAtEnd:function(){var valueLength,selectionStart,range;return valueLength=this.$input.val().length,selectionStart=this.$input[0].selectionStart,_.isNumber(selectionStart)?selectionStart===valueLength:document.selection?(range=document.selection.createRange(),range.moveStart("character",-valueLength),valueLength===range.text.length):!0},destroy:function(){this.$hint.off(".tt"),this.$input.off(".tt"),this.$hint=this.$input=this.$overflowHelper=null}}),Input}(),Dataset=function(){"use strict";function Dataset(o){o=o||{},o.templates=o.templates||{},o.source||$.error("missing source"),o.name&&!isValidName(o.name)&&$.error("invalid dataset name: "+o.name),this.query=null,this.highlight=!!o.highlight,this.name=o.name||_.getUniqueId(),this.source=o.source,this.displayFn=getDisplayFn(o.display||o.displayKey),this.templates=getTemplates(o.templates,this.displayFn),this.$el=$(html.dataset.replace("%CLASS%",this.name))}function getDisplayFn(display){function displayFn(obj){return obj[display]}return display=display||"value",_.isFunction(display)?display:displayFn}function getTemplates(templates,displayFn){function suggestionTemplate(context){return"<p>"+displayFn(context)+"</p>"}return{empty:templates.empty&&_.templatify(templates.empty),header:templates.header&&_.templatify(templates.header),footer:templates.footer&&_.templatify(templates.footer),suggestion:templates.suggestion||suggestionTemplate}}function isValidName(str){return/^[_a-zA-Z0-9-]+$/.test(str)}var datasetKey="ttDataset",valueKey="ttValue",datumKey="ttDatum";return Dataset.extractDatasetName=function(el){return $(el).data(datasetKey)},Dataset.extractValue=function(el){return $(el).data(valueKey)},Dataset.extractDatum=function(el){return $(el).data(datumKey)},_.mixin(Dataset.prototype,EventEmitter,{_render:function(query,suggestions){function getEmptyHtml(){return that.templates.empty({query:query,isEmpty:!0})}function getSuggestionsHtml(){function getSuggestionNode(suggestion){var $el;return $el=$(html.suggestion).append(that.templates.suggestion(suggestion)).data(datasetKey,that.name).data(valueKey,that.displayFn(suggestion)).data(datumKey,suggestion),$el.children().each(function(){$(this).css(css.suggestionChild)}),$el}var $suggestions,nodes;return $suggestions=$(html.suggestions).css(css.suggestions),nodes=_.map(suggestions,getSuggestionNode),$suggestions.append.apply($suggestions,nodes),that.highlight&&highlight({className:"tt-highlight",node:$suggestions[0],pattern:query}),$suggestions}function getHeaderHtml(){return that.templates.header({query:query,isEmpty:!hasSuggestions})}function getFooterHtml(){return that.templates.footer({query:query,isEmpty:!hasSuggestions})}if(this.$el){var hasSuggestions,that=this;this.$el.empty(),hasSuggestions=suggestions&&suggestions.length,!hasSuggestions&&this.templates.empty?this.$el.html(getEmptyHtml()).prepend(that.templates.header?getHeaderHtml():null).append(that.templates.footer?getFooterHtml():null):hasSuggestions&&this.$el.html(getSuggestionsHtml()).prepend(that.templates.header?getHeaderHtml():null).append(that.templates.footer?getFooterHtml():null),this.trigger("rendered")}},getRoot:function(){return this.$el},update:function(query){function render(suggestions){that.canceled||query!==that.query||that._render(query,suggestions)}var that=this;this.query=query,this.canceled=!1,this.source(query,render)},cancel:function(){this.canceled=!0},clear:function(){this.cancel(),this.$el.empty(),this.trigger("rendered")},isEmpty:function(){return this.$el.is(":empty")},destroy:function(){this.$el=null}}),Dataset}(),Dropdown=function(){"use strict";function Dropdown(o){var onSuggestionClick,onSuggestionMouseEnter,onSuggestionMouseLeave,that=this;o=o||{},o.menu||$.error("menu is required"),this.isOpen=!1,this.isEmpty=!0,this.datasets=_.map(o.datasets,initializeDataset),onSuggestionClick=_.bind(this._onSuggestionClick,this),onSuggestionMouseEnter=_.bind(this._onSuggestionMouseEnter,this),onSuggestionMouseLeave=_.bind(this._onSuggestionMouseLeave,this),this.$menu=$(o.menu).on("click.tt",".tt-suggestion",onSuggestionClick).on("mouseenter.tt",".tt-suggestion",onSuggestionMouseEnter).on("mouseleave.tt",".tt-suggestion",onSuggestionMouseLeave),_.each(this.datasets,function(dataset){that.$menu.append(dataset.getRoot()),dataset.onSync("rendered",that._onRendered,that)})}function initializeDataset(oDataset){return new Dataset(oDataset)}return _.mixin(Dropdown.prototype,EventEmitter,{_onSuggestionClick:function($e){this.trigger("suggestionClicked",$($e.currentTarget))},_onSuggestionMouseEnter:function($e){this._removeCursor(),this._setCursor($($e.currentTarget),!0)},_onSuggestionMouseLeave:function(){this._removeCursor()},_onRendered:function(){function isDatasetEmpty(dataset){return dataset.isEmpty()}this.isEmpty=_.every(this.datasets,isDatasetEmpty),this.isEmpty?this._hide():this.isOpen&&this._show(),this.trigger("datasetRendered")},_hide:function(){this.$menu.hide()},_show:function(){this.$menu.css("display","block")},_getSuggestions:function(){return this.$menu.find(".tt-suggestion")},_getCursor:function(){return this.$menu.find(".tt-cursor").first()},_setCursor:function($el,silent){$el.first().addClass("tt-cursor fill-darken0"),!silent&&this.trigger("cursorMoved")},_removeCursor:function(){this._getCursor().removeClass("tt-cursor fill-darken0")},_moveCursor:function(increment){var $suggestions,$oldCursor,newCursorIndex,$newCursor;if(this.isOpen){if($oldCursor=this._getCursor(),$suggestions=this._getSuggestions(),this._removeCursor(),newCursorIndex=$suggestions.index($oldCursor)+increment,newCursorIndex=(newCursorIndex+1)%($suggestions.length+1)-1,-1===newCursorIndex)return void this.trigger("cursorRemoved");-1>newCursorIndex&&(newCursorIndex=$suggestions.length-1),this._setCursor($newCursor=$suggestions.eq(newCursorIndex)),this._ensureVisible($newCursor)}},_ensureVisible:function($el){var elTop,elBottom,menuScrollTop,menuHeight;elTop=$el.position().top,elBottom=elTop+$el.outerHeight(!0),menuScrollTop=this.$menu.scrollTop(),menuHeight=this.$menu.height()+parseInt(this.$menu.css("paddingTop"),10)+parseInt(this.$menu.css("paddingBottom"),10),0>elTop?this.$menu.scrollTop(menuScrollTop+elTop):elBottom>menuHeight&&this.$menu.scrollTop(menuScrollTop+(elBottom-menuHeight))},close:function(){this.isOpen&&(this.isOpen=!1,this._removeCursor(),this._hide(),this.trigger("closed"))},open:function(){this.isOpen||(this.isOpen=!0,!this.isEmpty&&this._show(),this.trigger("opened"))},setLanguageDirection:function(dir){this.$menu.css("ltr"===dir?css.ltr:css.rtl)},moveCursorUp:function(){this._moveCursor(-1)},moveCursorDown:function(){this._moveCursor(1)},getDatumForSuggestion:function($el){var datum=null;return $el.length&&(datum={raw:Dataset.extractDatum($el),value:Dataset.extractValue($el),datasetName:Dataset.extractDatasetName($el)}),datum},getDatumForCursor:function(){return this.getDatumForSuggestion(this._getCursor().first())},getDatumForTopSuggestion:function(){return this.getDatumForSuggestion(this._getSuggestions().first())},update:function(query){function updateDataset(dataset){dataset.update(query)}_.each(this.datasets,updateDataset)},empty:function(){function clearDataset(dataset){dataset.clear()}_.each(this.datasets,clearDataset),this.isEmpty=!0},isVisible:function(){return this.isOpen&&!this.isEmpty},destroy:function(){function destroyDataset(dataset){dataset.destroy()}this.$menu.off(".tt"),this.$menu=null,_.each(this.datasets,destroyDataset)}}),Dropdown}(),Typeahead=function(){"use strict";function Typeahead(o){var $menu,$input,$hint;o=o||{},o.input||$.error("missing input"),this.isActivated=!1,this.autoselect=!!o.autoselect,this.minLength=_.isNumber(o.minLength)?o.minLength:1,this.$node=buildDom(o.input,o.withHint),$menu=this.$node.find(".tt-dropdown-menu"),$input=this.$node.find(".tt-input"),$hint=this.$node.find(".tt-hint"),$input.on("blur.tt",function($e){var active,isActive,hasActive;active=document.activeElement,isActive=$menu.is(active),hasActive=$menu.has(active).length>0,_.isMsie()&&(isActive||hasActive)&&($e.preventDefault(),$e.stopImmediatePropagation(),_.defer(function(){$input.focus()}))}),$menu.on("mousedown.tt",function($e){$e.preventDefault()}),this.eventBus=o.eventBus||new EventBus({el:$input}),this.dropdown=new Dropdown({menu:$menu,datasets:o.datasets}).onSync("suggestionClicked",this._onSuggestionClicked,this).onSync("cursorMoved",this._onCursorMoved,this).onSync("cursorRemoved",this._onCursorRemoved,this).onSync("opened",this._onOpened,this).onSync("closed",this._onClosed,this).onAsync("datasetRendered",this._onDatasetRendered,this),this.input=new Input({input:$input,hint:$hint}).onSync("focused",this._onFocused,this).onSync("blurred",this._onBlurred,this).onSync("enterKeyed",this._onEnterKeyed,this).onSync("tabKeyed",this._onTabKeyed,this).onSync("escKeyed",this._onEscKeyed,this).onSync("upKeyed",this._onUpKeyed,this).onSync("downKeyed",this._onDownKeyed,this).onSync("leftKeyed",this._onLeftKeyed,this).onSync("rightKeyed",this._onRightKeyed,this).onSync("queryChanged",this._onQueryChanged,this).onSync("whitespaceChanged",this._onWhitespaceChanged,this),this._setLanguageDirection()}function buildDom(input,withHint){var $input,$wrapper,$dropdown,$hint;$input=$(input),$wrapper=$(html.wrapper).css(css.wrapper),$dropdown=$(html.dropdown).css(css.dropdown),$hint=$input.clone().css(css.hint).css(getBackgroundStyles($input)),$hint.val("").removeData().addClass("tt-hint pin-topleft").removeAttr("id name placeholder required").prop("readonly",!0).attr({autocomplete:"off",spellcheck:"false",tabindex:-1}),$input.data(attrsKey,{dir:$input.attr("dir"),autocomplete:$input.attr("autocomplete"),spellcheck:$input.attr("spellcheck"),style:$input.attr("style")}),$input.addClass("tt-input").attr({autocomplete:"off",spellcheck:!1}).css(withHint?css.input:css.inputWithNoHint);try{!$input.attr("dir")&&$input.attr("dir","auto")}catch(e){}return $input.wrap($wrapper).parent().prepend(withHint?$hint:null).append($dropdown)}function getBackgroundStyles($el){return{backgroundAttachment:$el.css("background-attachment"),backgroundClip:$el.css("background-clip"),backgroundColor:$el.css("background-color"),backgroundImage:$el.css("background-image"),backgroundOrigin:$el.css("background-origin"),backgroundPosition:$el.css("background-position"),backgroundRepeat:$el.css("background-repeat"),backgroundSize:$el.css("background-size")}}function destroyDomStructure($node){var $input=$node.find(".tt-input");_.each($input.data(attrsKey),function(val,key){_.isUndefined(val)?$input.removeAttr(key):$input.attr(key,val)}),$input.detach().removeData(attrsKey).removeClass("tt-input").insertAfter($node),$node.remove()}var attrsKey="ttAttrs";return _.mixin(Typeahead.prototype,{_onSuggestionClicked:function(type,$el){var datum;(datum=this.dropdown.getDatumForSuggestion($el))&&this._select(datum)},_onCursorMoved:function(){var datum=this.dropdown.getDatumForCursor();this.input.setInputValue(datum.value,!0),this.eventBus.trigger("cursorchanged",datum.raw,datum.datasetName)},_onCursorRemoved:function(){this.input.resetInputValue(),this._updateHint()},_onDatasetRendered:function(){this._updateHint()},_onOpened:function(){this._updateHint(),this.eventBus.trigger("opened")},_onClosed:function(){this.input.clearHint(),this.eventBus.trigger("closed")},_onFocused:function(){this.isActivated=!0,this.dropdown.open()},_onBlurred:function(){this.isActivated=!1,this.dropdown.empty(),this.dropdown.close()},_onEnterKeyed:function(type,$e){var cursorDatum,topSuggestionDatum;cursorDatum=this.dropdown.getDatumForCursor(),topSuggestionDatum=this.dropdown.getDatumForTopSuggestion(),cursorDatum?(this._select(cursorDatum),$e.preventDefault()):this.autoselect&&topSuggestionDatum&&(this._select(topSuggestionDatum),$e.preventDefault())},_onTabKeyed:function(type,$e){var datum;(datum=this.dropdown.getDatumForCursor())?(this._select(datum),$e.preventDefault()):this._autocomplete(!0)},_onEscKeyed:function(){this.dropdown.close(),this.input.resetInputValue()},_onUpKeyed:function(){var query=this.input.getQuery();this.dropdown.isEmpty&&query.length>=this.minLength?this.dropdown.update(query):this.dropdown.moveCursorUp(),this.dropdown.open()},_onDownKeyed:function(){var query=this.input.getQuery();this.dropdown.isEmpty&&query.length>=this.minLength?this.dropdown.update(query):this.dropdown.moveCursorDown(),this.dropdown.open()},_onLeftKeyed:function(){"rtl"===this.dir&&this._autocomplete()},_onRightKeyed:function(){"ltr"===this.dir&&this._autocomplete()},_onQueryChanged:function(e,query){this.input.clearHintIfInvalid(),query.length>=this.minLength?this.dropdown.update(query):this.dropdown.empty(),this.dropdown.open(),this._setLanguageDirection()},_onWhitespaceChanged:function(){this._updateHint(),this.dropdown.open()},_setLanguageDirection:function(){var dir;this.dir!==(dir=this.input.getLanguageDirection())&&(this.dir=dir,this.$node.css("direction",dir),this.dropdown.setLanguageDirection(dir))},_updateHint:function(){var datum,val,query,escapedQuery,frontMatchRegEx,match;datum=this.dropdown.getDatumForTopSuggestion(),datum&&this.dropdown.isVisible()&&!this.input.hasOverflow()?(val=this.input.getInputValue(),query=Input.normalizeQuery(val),escapedQuery=_.escapeRegExChars(query),frontMatchRegEx=new RegExp("^(?:"+escapedQuery+")(.+$)","i"),match=frontMatchRegEx.exec(datum.value),match?this.input.setHint(val+match[1]):this.input.clearHint()):this.input.clearHint()},_autocomplete:function(laxCursor){var hint,query,isCursorAtEnd,datum;hint=this.input.getHint(),query=this.input.getQuery(),isCursorAtEnd=laxCursor||this.input.isCursorAtEnd(),hint&&query!==hint&&isCursorAtEnd&&(datum=this.dropdown.getDatumForTopSuggestion(),datum&&this.input.setInputValue(datum.value),this.eventBus.trigger("autocompleted",datum.raw,datum.datasetName))},_select:function(datum){this.input.setQuery(datum.value),this.input.setInputValue(datum.value,!0),this._setLanguageDirection(),this.eventBus.trigger("selected",datum.raw,datum.datasetName),this.dropdown.close(),_.defer(_.bind(this.dropdown.empty,this.dropdown))},open:function(){this.dropdown.open()},close:function(){this.dropdown.close()},setVal:function(val){val=_.toStr(val),this.isActivated?this.input.setInputValue(val):(this.input.setQuery(val),this.input.setInputValue(val,!0)),this._setLanguageDirection()},getVal:function(){return this.input.getQuery()},destroy:function(){this.input.destroy(),this.dropdown.destroy(),destroyDomStructure(this.$node),this.$node=null}}),Typeahead}();!function(){"use strict";var old,typeaheadKey,methods;old=$.fn.typeahead,typeaheadKey="ttTypeahead",methods={initialize:function(o,datasets){function attach(){var eventBus,typeahead,$input=$(this);_.each(datasets,function(d){d.highlight=!!o.highlight}),typeahead=new Typeahead({input:$input,eventBus:eventBus=new EventBus({el:$input}),withHint:_.isUndefined(o.hint)?!0:!!o.hint,minLength:o.minLength,autoselect:o.autoselect,datasets:datasets}),$input.data(typeaheadKey,typeahead)}return datasets=_.isArray(datasets)?datasets:[].slice.call(arguments,1),o=o||{},this.each(attach)},open:function(){function openTypeahead(){var typeahead,$input=$(this);(typeahead=$input.data(typeaheadKey))&&typeahead.open()}return this.each(openTypeahead)},close:function(){function closeTypeahead(){var typeahead,$input=$(this);(typeahead=$input.data(typeaheadKey))&&typeahead.close()}return this.each(closeTypeahead)},val:function(newVal){function setVal(){var typeahead,$input=$(this);(typeahead=$input.data(typeaheadKey))&&typeahead.setVal(newVal)}function getVal($input){var typeahead,query;return(typeahead=$input.data(typeaheadKey))&&(query=typeahead.getVal()),query}return arguments.length?this.each(setVal):getVal(this.first())},destroy:function(){function unattach(){var typeahead,$input=$(this);(typeahead=$input.data(typeaheadKey))&&(typeahead.destroy(),$input.removeData(typeaheadKey))}return this.each(unattach)}},$.fn.typeahead=function(method){var tts;return methods[method]&&"initialize"!==method?(tts=this.filter(function(){return!!$(this).data(typeaheadKey)}),methods[method].apply(tts,[].slice.call(arguments,1))):methods.initialize.apply(this,arguments)},$.fn.typeahead.noConflict=function(){return $.fn.typeahead=old,this}}()}(window.jQuery);