text: /*!
   * bootstrap-tokenfield
   * https://github.com/sliptree/bootstrap-tokenfield
   * Copyright 2013-2014 Sliptree and other contributors; Licensed MIT
   */
  (function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof exports==="object"){module.exports=global.window&&global.window.$?a(global.window.$):function(b){if(!b.$&&!b.fn){throw new Error("Tokenfield requires a window object with jQuery or a jQuery instance")}return a(b.$||b)}}else{a(jQuery,window)}}}(function(d,c){var b=function(g,j){var k=this;this.$element=d(g);this.textDirection=this.$element.css("direction");this.options=d.extend(true,{},d.fn.tokenfield.defaults,{tokens:this.$element.val()},this.$element.data(),j);this._delimiters=(typeof this.options.delimiter==="string")?[this.options.delimiter]:this.options.delimiter;this._triggerKeys=d.map(this._delimiters,function(x){return x.charCodeAt(0)});this._firstDelimiter=this._delimiters[0];var u=d.inArray(" ",this._delimiters),q=d.inArray("-",this._delimiters);if(u>=0){this._delimiters[u]="\\s"}if(q>=0){delete this._delimiters[q];this._delimiters.unshift("-")}var n=["\\","$","[","{","^",".","|","?","*","+","(",")"];d.each(this._delimiters,function(x,y){var z=d.inArray(y,n);if(z>=0){k._delimiters[x]="\\"+y}});var o=(c&&typeof c.getMatchedCSSRules==="function")?c.getMatchedCSSRules(g):null,e=g.style.width,v,s=this.$element.width();if(o){d.each(o,function(x,y){if(y.style.width){v=y.style.width}})}var m=d("body").css("direction")==="rtl"?"right":"left",r={position:this.$element.css("position")};r[m]=this.$element.css(m);this.$element.data("original-styles",r).data("original-tabindex",this.$element.prop("tabindex")).css("position","absolute").css(m,"-10000px").prop("tabindex",-1);this.$wrapper=d('<div class="tokenfield form-control" />');if(this.$element.hasClass("input-lg")){this.$wrapper.addClass("input-lg")}if(this.$element.hasClass("input-sm")){this.$wrapper.addClass("input-sm")}if(this.textDirection==="rtl"){this.$wrapper.addClass("rtl")}var t=this.$element.prop("id")||new Date().getTime()+""+Math.floor((1+Math.random())*100);this.$input=d('<input type="'+this.options.inputType+'" class="token-input" autocomplete="off" />').appendTo(this.$wrapper).prop("placeholder",this.$element.prop("placeholder")).prop("id",t+"-tokenfield").prop("tabindex",this.$element.data("original-tabindex"));var w=d('label[for="'+this.$element.prop("id")+'"]');if(w.length){w.prop("for",this.$input.prop("id"))}this.$copyHelper=d('<input type="text" />').css("position","absolute").css(m,"-10000px").prop("tabindex",-1).prependTo(this.$wrapper);if(e){this.$wrapper.css("width",e)}else{if(v){this.$wrapper.css("width",v)}else{if(this.$element.parents(".form-inline").length){this.$wrapper.width(s)}}}if(this.$element.prop("disabled")||this.$element.parents("fieldset[disabled]").length){this.disable()}if(this.$element.prop("readonly")){this.readonly()}this.$mirror=d('<span style="position:absolute; top:-999px; left:0; white-space:pre;"/>');this.$input.css("min-width",this.options.minWidth+"px");d.each(["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent"],function(x,y){k.$mirror[0].style[y]=k.$input.css(y)});this.$mirror.appendTo("body");this.$wrapper.insertBefore(this.$element);this.$element.prependTo(this.$wrapper);this.update();this.setTokens(this.options.tokens,false,!this.$element.val()&&this.options.tokens);this.listen();if(!d.isEmptyObject(this.options.autocomplete)){var f=this.textDirection==="rtl"?"right":"left",l=d.extend({minLength:this.options.showAutocompleteOnFocus?0:null,position:{my:f+" top",at:f+" bottom",of:this.$wrapper}},this.options.autocomplete);this.$input.autocomplete(l)}if(!d.isEmptyObject(this.options.typeahead)){var h=this.options.typeahead,p={minLength:this.options.showAutocompleteOnFocus?0:null},i=d.isArray(h)?h:[h,h];i[0]=d.extend({},p,i[0]);this.$input.typeahead.apply(this.$input,i);this.typeahead=true}};b.prototype={constructor:b,createToken:function(h,g){var e=this;if(typeof h==="string"){h={value:h,label:h}}else{h=d.extend({},h)}if(typeof g==="undefined"){g=true}h.value=d.trim(h.value.toString());h.label=h.label&&h.label.length?d.trim(h.label):h.value;if(!h.value.length||!h.label.length||h.label.length<=this.options.minLength){return}if(this.options.limit&&this.getTokens().length>=this.options.limit){return}var i=d.Event("tokenfield:createtoken",{attrs:h});this.$element.trigger(i);if(!i.attrs||i.isDefaultPrevented()){return}var f=d('<div class="token" />').append('<span class="token-label" />').append('<a href="#" class="close" tabindex="-1">&times;</a>').data("attrs",h);if(this.$input.hasClass("tt-input")){this.$input.parent().before(f)}else{this.$input.before(f)}this.$input.css("width",this.options.minWidth+"px");var k=f.find(".token-label"),j=f.find(".close");if(!this.maxTokenWidth){this.maxTokenWidth=this.$wrapper.width()-j.outerWidth()-parseInt(j.css("margin-left"),10)-parseInt(j.css("margin-right"),10)-parseInt(f.css("border-left-width"),10)-parseInt(f.css("border-right-width"),10)-parseInt(f.css("padding-left"),10)-parseInt(f.css("padding-right"),10);
      parseInt(k.css("border-left-width"),10)-parseInt(k.css("border-right-width"),10)-parseInt(k.css("padding-left"),10)-parseInt(k.css("padding-right"),10);parseInt(k.css("margin-left"),10)-parseInt(k.css("margin-right"),10)}k.css("max-width",this.maxTokenWidth);if(this.options.html){k.html(h.label)}else{k.text(h.label)}f.on("mousedown",function(l){if(e._disabled||e._readonly){return false}e.preventDeactivation=true}).on("click",function(l){if(e._disabled||e._readonly){return false}e.preventDeactivation=false;if(l.ctrlKey||l.metaKey){l.preventDefault();return e.toggle(f)}e.activate(f,l.shiftKey,l.shiftKey)}).on("dblclick",function(l){if(e._disabled||e._readonly||!e.options.allowEditing){return false}e.edit(f)});j.on("click",d.proxy(this.remove,this));this.$element.trigger(d.Event("tokenfield:createdtoken",{attrs:h,relatedTarget:f.get(0)}));if(g){this.$element.val(this.getTokensList()).trigger(d.Event("change",{initiator:"tokenfield"}))}var e=this;setTimeout(function(){e.update()},0);return this.$element.get(0)},setTokens:function(h,g,f){if(!g){this.$wrapper.find(".token").remove()}if(!h){return}if(typeof f==="undefined"){f=true}if(typeof h==="string"){if(this._delimiters.length){h=h.split(new RegExp("["+this._delimiters.join("")+"]"))}else{h=[h]}}var e=this;d.each(h,function(k,j){e.createToken(j,f)});return this.$element.get(0)},getTokenData:function(e){var f=e.map(function(){var g=d(this);return g.data("attrs")}).get();if(f.length==1){f=f[0]}return f},getTokens:function(h){var e=this,g=[],f=h?".active":"";this.$wrapper.find(".token"+f).each(function(){g.push(e.getTokenData(d(this)))});return g},getTokensList:function(e,f,h){e=e||this._firstDelimiter;f=(typeof f!=="undefined"&&f!==null)?f:this.options.beautify;var g=e+(f&&e!==" "?" ":"");return d.map(this.getTokens(h),function(i){return i.value}).join(g)},getInput:function(){return this.$input.val()},setInput:function(e){if(this.$input.hasClass("tt-input")){this.$input.typeahead("val",e)}else{this.$input.val(e)}},listen:function(){var e=this;this.$element.on("change",d.proxy(this.change,this));this.$wrapper.on("mousedown",d.proxy(this.focusInput,this));this.$input.on("focus",d.proxy(this.focus,this)).on("blur",d.proxy(this.blur,this)).on("paste",d.proxy(this.paste,this)).on("keydown",d.proxy(this.keydown,this)).on("keypress",d.proxy(this.keypress,this)).on("keyup",d.proxy(this.keyup,this));this.$copyHelper.on("focus",d.proxy(this.focus,this)).on("blur",d.proxy(this.blur,this)).on("keydown",d.proxy(this.keydown,this)).on("keyup",d.proxy(this.keyup,this));this.$input.on("keypress",d.proxy(this.update,this)).on("keyup",d.proxy(this.update,this));this.$input.on("autocompletecreate",function(){var f=d(this).data("ui-autocomplete").menu.element;var g=e.$wrapper.outerWidth()-parseInt(f.css("border-left-width"),10)-parseInt(f.css("border-right-width"),10);f.css("min-width",g+"px")}).on("autocompleteselect",function(g,f){if(e.createToken(f.item)){e.$input.val("");if(e.$input.data("edit")){e.unedit(true)}}return false}).on("typeahead:selected typeahead:autocompleted",function(h,f,g){if(e.createToken(f)){e.$input.typeahead("val","");if(e.$input.data("edit")){e.unedit(true)}}});d(c).on("resize",d.proxy(this.update,this))},keydown:function(i){if(!this.focused){return}var f=this;switch(i.keyCode){case 8:if(!this.$input.is(document.activeElement)){break}this.lastInputValue=this.$input.val();break;case 37:h(this.textDirection==="rtl"?"next":"prev");break;case 38:g("prev");break;case 39:h(this.textDirection==="rtl"?"prev":"next");break;case 40:g("next");break;case 65:if(this.$input.val().length>0||!(i.ctrlKey||i.metaKey)){break}this.activateAll();i.preventDefault();break;case 9:case 13:if(this.$input.data("ui-autocomplete")&&this.$input.data("ui-autocomplete").menu.element.find("li:has(a.ui-state-focus), li.ui-state-focus").length){break}if(this.$input.hasClass("tt-input")&&this.$wrapper.find(".tt-cursor").length){break}if(this.$input.hasClass("tt-input")&&this.$wrapper.find(".tt-hint").val()&&this.$wrapper.find(".tt-hint").val().length){break}if(this.$input.is(document.activeElement)&&this.$input.val().length||this.$input.data("edit")){return this.createTokensFromInput(i,this.$input.data("edit"))}if(i.keyCode===13){if(!this.$copyHelper.is(document.activeElement)||this.$wrapper.find(".token.active").length!==1){break}if(!f.options.allowEditing){break}this.edit(this.$wrapper.find(".token.active"))}}function h(j){if(f.$input.is(document.activeElement)){if(f.$input.val().length>0){return}j+="All";var e=f.$input.hasClass("tt-input")?f.$input.parent()[j](".token:first"):f.$input[j](".token:first");if(!e.length){return}f.preventInputFocus=true;f.preventDeactivation=true;f.activate(e);i.preventDefault()}else{f[j](i.shiftKey);i.preventDefault()}}function g(l){if(!i.shiftKey){return}if(f.$input.is(document.activeElement)){if(f.$input.val().length>0){return}var j=f.$input.hasClass("tt-input")?f.$input.parent()[l+"All"](".token:first"):f.$input[l+"All"](".token:first");if(!j.length){return
  }f.activate(j)}var k=l==="prev"?"next":"prev",e=l==="prev"?"first":"last";f.$firstActiveToken[k+"All"](".token").each(function(){f.deactivate(d(this))});f.activate(f.$wrapper.find(".token:"+e),true,true);i.preventDefault()}this.lastKeyDown=i.keyCode},keypress:function(f){if(d.inArray(f.which,this._triggerKeys)!==-1&&this.$input.is(document.activeElement)){if(this.$input.val()){this.createTokensFromInput(f)}return false}},keyup:function(g){this.preventInputFocus=false;if(!this.focused){return}switch(g.keyCode){case 8:if(this.$input.is(document.activeElement)){if(this.$input.val().length||this.lastInputValue.length&&this.lastKeyDown===8){break}this.preventDeactivation=true;var f=this.$input.hasClass("tt-input")?this.$input.parent().prevAll(".token:first"):this.$input.prevAll(".token:first");if(!f.length){break}this.activate(f)}else{this.remove(g)}break;case 46:this.remove(g,"next");break}this.lastKeyUp=g.keyCode},focus:function(f){this.focused=true;this.$wrapper.addClass("focus");if(this.$input.is(document.activeElement)){this.$wrapper.find(".active").removeClass("active");this.$firstActiveToken=null;if(this.options.showAutocompleteOnFocus){this.search()}}},blur:function(f){this.focused=false;this.$wrapper.removeClass("focus");if(!this.preventDeactivation&&!this.$element.is(document.activeElement)){this.$wrapper.find(".active").removeClass("active");this.$firstActiveToken=null}if(!this.preventCreateTokens&&(this.$input.data("edit")&&!this.$input.is(document.activeElement)||this.options.createTokensOnBlur)){this.createTokensFromInput(f)}this.preventDeactivation=false;this.preventCreateTokens=false},paste:function(g){var f=this;if(f.options.allowPasting){setTimeout(function(){f.createTokensFromInput(g)},1)}},change:function(f){if(f.initiator==="tokenfield"){return}this.setTokens(this.$element.val())},createTokensFromInput:function(h,g){if(this.$input.val().length<this.options.minLength){return}var f=this.getTokensList();this.setTokens(this.$input.val(),true);if(f==this.getTokensList()&&this.$input.val().length){return false}this.setInput("");if(this.$input.data("edit")){this.unedit(g)}return false},next:function(g){if(g){var e=this.$wrapper.find(".active:first"),f=e&&this.$firstActiveToken?e.index()<this.$firstActiveToken.index():false;if(f){return this.deactivate(e)}}var i=this.$wrapper.find(".active:last"),h=i.nextAll(".token:first");if(!h.length){this.$input.focus();return}this.activate(h,g)},prev:function(h){if(h){var i=this.$wrapper.find(".active:last"),g=i&&this.$firstActiveToken?i.index()>this.$firstActiveToken.index():false;if(g){return this.deactivate(i)}}var f=this.$wrapper.find(".active:first"),e=f.prevAll(".token:first");if(!e.length){e=this.$wrapper.find(".token:first")}if(!e.length&&!h){this.$input.focus();return}this.activate(e,h)},activate:function(g,k,j,l){if(!g){return}if(typeof l==="undefined"){var l=true}if(j){var k=true}this.$copyHelper.focus();if(!k){this.$wrapper.find(".active").removeClass("active");if(l){this.$firstActiveToken=g}else{delete this.$firstActiveToken}}if(j&&this.$firstActiveToken){var h=this.$firstActiveToken.index()-2,f=g.index()-2,e=this;this.$wrapper.find(".token").slice(Math.min(h,f)+1,Math.max(h,f)).each(function(){e.activate(d(this),true)})}g.addClass("active");this.$copyHelper.val(this.getTokensList(null,null,true)).select()},activateAll:function(){var e=this;this.$wrapper.find(".token").each(function(f){e.activate(d(this),f!==0,false,false)})},deactivate:function(e){if(!e){return}e.removeClass("active");this.$copyHelper.val(this.getTokensList(null,null,true)).select()},toggle:function(e){if(!e){return}e.toggleClass("active");this.$copyHelper.val(this.getTokensList(null,null,true)).select()},edit:function(g){if(!g){return}var j=g.data("attrs");var i={attrs:j,relatedTarget:g.get(0)};var f=d.Event("tokenfield:edittoken",i);this.$element.trigger(f);if(f.isDefaultPrevented()){return}g.find(".token-label").text(j.value);var h=g.outerWidth();var e=this.$input.hasClass("tt-input")?this.$input.parent():this.$input;g.replaceWith(e);this.preventCreateTokens=true;this.$input.val(j.value).select().data("edit",true).width(h);this.update();this.$element.trigger(d.Event("tokenfield:editedtoken",i))},unedit:function(g){var f=this.$input.hasClass("tt-input")?this.$input.parent():this.$input;f.appendTo(this.$wrapper);this.$input.data("edit",false);this.$mirror.text("");this.update();if(g){var e=this;setTimeout(function(){e.$input.focus()},1)}},remove:function(m,l){if(this.$input.is(document.activeElement)||this._disabled||this._readonly){return}var f=(m.type==="click")?d(m.target).closest(".token"):this.$wrapper.find(".token.active");if(m.type!=="click"){if(!l){var l="prev"}this[l]();if(l==="prev"){var g=f.first().prevAll(".token:first").length===0}}var h={attrs:this.getTokenData(f),relatedTarget:f.get(0)},k=d.Event("tokenfield:removetoken",h);this.$element.trigger(k);if(k.isDefaultPrevented()){return}var j=d.Event("tokenfield:removedtoken",h),i=d.Event("change",{initiator:"tokenfield"});
      f.remove();this.$element.val(this.getTokensList()).trigger(j).trigger(i);if(!this.$wrapper.find(".token").length||m.type==="click"||g){this.$input.focus()}this.$input.css("width",this.options.minWidth+"px");this.update();m.preventDefault();m.stopPropagation()},update:function(k){var j=this.$input.val(),i=parseInt(this.$input.css("padding-left"),10),l=parseInt(this.$input.css("padding-right"),10),h=i+l;if(this.$input.data("edit")){if(!j){j=this.$input.prop("placeholder")}if(j===this.$mirror.text()){return}this.$mirror.text(j);var g=this.$mirror.width()+10;if(g>this.$wrapper.width()){return this.$input.width(this.$wrapper.width())}this.$input.width(g)}else{this.$input.width(this.options.minWidth);var f=(this.textDirection==="rtl")?this.$input.offset().left+this.$input.outerWidth()-this.$wrapper.offset().left-parseInt(this.$wrapper.css("padding-left"),10)-h-1:this.$wrapper.offset().left+this.$wrapper.width()+parseInt(this.$wrapper.css("padding-left"),10)-this.$input.offset().left-h;isNaN(f)?this.$input.width("100%"):this.$input.width(f)}},focusInput:function(g){if(d(g.target).closest(".token").length||d(g.target).closest(".token-input").length||d(g.target).closest(".tt-dropdown-menu").length){return}var f=this;setTimeout(function(){f.$input.focus()},0)},search:function(){if(this.$input.data("ui-autocomplete")){this.$input.autocomplete("search")}},disable:function(){this.setProperty("disabled",true)},enable:function(){this.setProperty("disabled",false)},readonly:function(){this.setProperty("readonly",true)},writeable:function(){this.setProperty("readonly",false)},setProperty:function(f,e){this["_"+f]=e;this.$input.prop(f,e);this.$element.prop(f,e);this.$wrapper[e?"addClass":"removeClass"](f)},destroy:function(){this.$element.val(this.getTokensList());this.$element.css(this.$element.data("original-styles"));this.$element.prop("tabindex",this.$element.data("original-tabindex"));var e=d('label[for="'+this.$input.prop("id")+'"]');if(e.length){e.prop("for",this.$element.prop("id"))}this.$element.insertBefore(this.$wrapper);this.$element.removeData("original-styles").removeData("original-tabindex").removeData("bs.tokenfield");this.$wrapper.remove();this.$mirror.remove();var f=this.$element;return f}};var a=d.fn.tokenfield;d.fn.tokenfield=function(f,i){var h,e=[];Array.prototype.push.apply(e,arguments);var g=this.each(function(){var l=d(this),k=l.data("bs.tokenfield"),j=typeof f=="object"&&f;if(typeof f==="string"&&k&&k[f]){e.shift();h=k[f].apply(k,e)}else{if(!k&&typeof f!=="string"&&!i){l.data("bs.tokenfield",(k=new b(this,j)));l.trigger("tokenfield:initialize")}}});return typeof h!=="undefined"?h:g};d.fn.tokenfield.defaults={minWidth:60,minLength:0,html:true,allowEditing:true,allowPasting:true,limit:0,autocomplete:{},typeahead:{},showAutocompleteOnFocus:false,createTokensOnBlur:false,delimiter:",",beautify:true,inputType:"text"};d.fn.tokenfield.Constructor=b;d.fn.tokenfield.noConflict=function(){d.fn.tokenfield=a;return this};return b}));