text: (function(a,b){if(typeof define==="function"&&define.amd){define("sifter",b)}else{if(typeof exports==="object"){module.exports=b()}else{a.Sifter=b()}}}(this,function(){var h=function(j,k){this.items=j;this.settings=k||{diacritics:true}};h.prototype.tokenize=function(m){m=b(String(m||"").toLowerCase());if(!m||!m.length){return[]}var j,q,l,k;var o=[];var p=m.split(/ +/);for(j=0,q=p.length;j<q;j++){l=e(p[j]);if(this.settings.diacritics){for(k in i){if(i.hasOwnProperty(k)){l=l.replace(new RegExp(k,"g"),i[k])}}}o.push({string:p[j],regex:new RegExp(l,"i")})}return o};h.prototype.iterator=function(j,l){var k;if(c(j)){k=Array.prototype.forEach||function(p){for(var m=0,o=this.length;m<o;m++){p(this[m],m,this)}}}else{k=function(n){for(var m in this){if(this.hasOwnProperty(m)){n(this[m],m,this)}}}}k.apply(j,[l])};h.prototype.getScoreFunction=function(q,r){var p,l,n,o,k;p=this;q=p.prepareSearch(q,r);n=q.tokens;l=q.options.fields;o=n.length;k=q.options.nesting;var m=function(t,s){var u,v;if(!t){return 0}t=String(t||"");v=t.search(s.regex);if(v===-1){return 0}u=s.string.length/t.length;if(v===0){u+=0.5}return u};var j=(function(){var s=l.length;if(!s){return function(){return 0}}if(s===1){return function(t,u){return m(a(u,l[0],k),t)}}return function(u,w){for(var t=0,v=0;t<s;t++){v+=m(a(w,l[t],k),u)}return v/s}})();if(!o){return function(){return 0}}if(o===1){return function(s){return j(n[0],s)}}if(q.options.conjunction==="and"){return function(u){var v;for(var s=0,t=0;s<o;s++){v=j(n[s],u);if(v<=0){return 0}t+=v}return t/o}}else{return function(u){for(var s=0,t=0;s<o;s++){t+=j(n[s],u)}return t/o}}};h.prototype.getSortFunction=function(v,w){var q,j,u,s,r,l,t,o,k,m,p;u=this;v=u.prepareSearch(v,w);p=(!v.query&&w.sort_empty)||w.sort;k=function(x,n){if(x==="$score"){return n.score}return a(u.items[n.id],x,w.nesting)};r=[];if(p){for(q=0,j=p.length;q<j;q++){if(v.query||p[q].field!=="$score"){r.push(p[q])}}}if(v.query){m=true;for(q=0,j=r.length;q<j;q++){if(r[q].field==="$score"){m=false;break}}if(m){r.unshift({field:"$score",direction:"desc"})}}else{for(q=0,j=r.length;q<j;q++){if(r[q].field==="$score"){r.splice(q,1);break}}}o=[];for(q=0,j=r.length;q<j;q++){o.push(r[q].direction==="desc"?-1:1)}l=r.length;if(!l){return null}else{if(l===1){s=r[0].field;t=o[0];return function(x,n){return t*f(k(s,x),k(s,n))}}else{return function(z,x){var B,n,y,A,C;for(B=0;B<l;B++){C=r[B].field;n=o[B]*f(k(C,z),k(C,x));if(n){return n}}return 0}}}};h.prototype.prepareSearch=function(m,j){if(typeof m==="object"){return m}j=d({},j);var l=j.fields;var n=j.sort;var k=j.sort_empty;if(l&&!c(l)){j.fields=[l]}if(n&&!c(n)){j.sort=[n]}if(k&&!c(k)){j.sort_empty=[k]}return{options:j,query:String(m||"").toLowerCase(),tokens:this.tokenize(m),total:0,items:[]}};h.prototype.search=function(m,r){var p=this,o,k,q,l;var j;var n;q=this.prepareSearch(m,r);r=q.options;m=q.query;n=r.score||p.getScoreFunction(q);if(m.length){p.iterator(p.items,function(s,t){k=n(s);if(r.filter===false||k>0){q.items.push({score:k,id:t})}})}else{p.iterator(p.items,function(s,t){q.items.push({score:1,id:t})})}j=p.getSortFunction(q,r);if(j){q.items.sort(j)}q.total=q.items.length;if(typeof r.limit==="number"){q.items=q.items.slice(0,r.limit)}return q};var f=function(k,j){if(typeof k==="number"&&typeof j==="number"){return k>j?1:(k<j?-1:0)}k=g(String(k||""));j=g(String(j||""));if(k>j){return 1}if(j>k){return -1}return 0};var d=function(l,j){var p,q,m,o;for(p=1,q=arguments.length;p<q;p++){o=arguments[p];if(!o){continue}for(m in o){if(o.hasOwnProperty(m)){l[m]=o[m]}}}return l};var a=function(m,j,k){if(!m||!j){return}if(!k){return m[j]}var l=j.split(".");while(l.length&&(m=m[l.shift()])){}return m};var b=function(j){return(j+"").replace(/^\s+|\s+$|/g,"")};var e=function(j){return(j+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")};var c=Array.isArray||(typeof $!=="undefined"&&$.isArray)||function(j){return Object.prototype.toString.call(j)==="[object Array]"};var i={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄＣｃ]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅＤｄð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇＥｅɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪＩｉ]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟＬｌ]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴＮｎŊŋ]",o:"[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]",p:"[pṔṕṖṗⱣᵽƤƥᵱ]",q:"[qꝖꝗʠɊɋꝘꝙq̃]",r:"[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]",s:"[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]",t:"[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]",u:"[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]",v:"[vṼṽṾṿƲʋꝞꝟⱱʋ]",w:"[wẂẃẀẁŴŵẄẅẆẇẈẉ]",x:"[xẌẍẊẋχ]",y:"[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]",z:"[zŹźẐẑŽžŻżẒẓẔẕƵƶ]"};var g=(function(){var o,r,j,m;var l="";var q={};for(j in i){if(i.hasOwnProperty(j)){m=i[j].substring(2,i[j].length-1);l+=m;for(o=0,r=m.length;o<r;o++){q[m.charAt(o)]=j}}}var p=new RegExp("["+l+"]","g");return function(k){return k.replace(p,function(n){return q[n]}).toLowerCase()}})();return h}));(function(a,b){if(typeof define==="function"&&define.amd){define("microplugin",b)}else{if(typeof exports==="object"){module.exports=b()}else{a.MicroPlugin=b()}}}(this,function(){var a={};a.mixin=function(c){c.plugins={};c.prototype.initializePlugins=function(e){var h,j,g;var f=this;var d=[];f.plugins={names:[],settings:{},requested:{},loaded:{}};if(b.isArray(e)){for(h=0,j=e.length;h<j;h++){if(typeof e[h]==="string"){d.push(e[h])}else{f.plugins.settings[e[h].name]=e[h].options;d.push(e[h].name)}}}else{if(e){for(g in e){if(e.hasOwnProperty(g)){f.plugins.settings[g]=e[g];d.push(g)}}}}while(d.length){f.require(d.shift())}};c.prototype.loadPlugin=function(f){var e=this;var d=e.plugins;var g=c.plugins[f];if(!c.plugins.hasOwnProperty(f)){throw new Error('Unable to find "'+f+'" plugin')}d.requested[f]=true;d.loaded[f]=g.fn.apply(e,[e.plugins.settings[f]||{}]);d.names.push(f)};c.prototype.require=function(f){var e=this;var d=e.plugins;if(!e.plugins.loaded.hasOwnProperty(f)){if(d.requested[f]){throw new Error('Plugin has circular dependency ("'+f+'")')}e.loadPlugin(f)}return d.loaded[f]};c.define=function(d,e){c.plugins[d]={name:d,fn:e}}};var b={isArray:Array.isArray||function(c){return Object.prototype.toString.call(c)==="[object Array]"}};return a}));(function(a,b){if(typeof define==="function"&&define.amd){define("selectize",["jquery","sifter","microplugin"],b)}else{if(typeof exports==="object"){module.exports=b(require("jquery"),require("sifter"),require("microplugin"))}else{a.Selectize=b(a.jQuery,a.Sifter,a.MicroPlugin)}}}(this,function(v,m,i){var M=function(P,S){if(typeof S==="string"&&!S.length){return}var R=(typeof S==="string")?new RegExp(S,"i"):S;var Q=function(V){var ab=0;if(V.nodeType===3){var aa=V.data.search(R);if(aa>=0&&V.data.length>0){var Z=V.data.match(R);var Y=document.createElement("span");Y.className="highlight";var W=V.splitText(aa);var T=W.splitText(Z[0].length);var U=W.cloneNode(true);Y.appendChild(U);W.parentNode.replaceChild(Y,W);ab=1}}else{if(V.nodeType===1&&V.childNodes&&!/(script|style)/i.test(V.tagName)){for(var X=0;X<V.childNodes.length;++X){X+=Q(V.childNodes[X])}}}return ab};return P.each(function(){Q(this)})};v.fn.removeHighlight=function(){return this.find("span.highlight").each(function(){this.parentNode.firstChild.nodeName;var P=this.parentNode;P.replaceChild(this.firstChild,this);P.normalize()}).end()};var G=function(){};G.prototype={on:function(Q,P){this._events=this._events||{};this._events[Q]=this._events[Q]||[];this._events[Q].push(P)},off:function(Q,P){var R=arguments.length;if(R===0){return delete this._events}if(R===1){return delete this._events[Q]}this._events=this._events||{};if(Q in this._events===false){return}this._events[Q].splice(this._events[Q].indexOf(P),1)},trigger:function(Q){this._events=this._events||{};if(Q in this._events===false){return}for(var P=0;P<this._events[Q].length;P++){this._events[Q][P].apply(this,Array.prototype.slice.call(arguments,1))}}};G.mixin=function(P){var R=["on","off","trigger"];for(var Q=0;Q<R.length;Q++){P.prototype[R[Q]]=G.prototype[R[Q]]}};var b=/Mac/.test(navigator.userAgent);var I=65;var N=188;var z=13;var w=27;var p=37;var H=38;var x=80;var t=39;var u=40;var B=78;var o=8;var q=46;var j=16;var J=b?91:17;var e=b?18:17;var F=9;var k=1;var h=2;var C=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity;var O=function(P){return typeof P!=="undefined"};var y=function(P){if(typeof P==="undefined"||P===null){return null}if(typeof P==="boolean"){return P?"1":"0"}return P+""};var D=function(P){return(P+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")};var f=function(P){return(P+"").replace(/\$/g,"$$$$")};var s={};s.before=function(P,S,R){var Q=P[S];P[S]=function(){R.apply(P,arguments);return Q.apply(P,arguments)}};s.after=function(P,S,R){var Q=P[S];P[S]=function(){var T=Q.apply(P,arguments);R.apply(P,arguments);return T}};var r=function(P){var Q=false;return function(){if(Q){return}Q=true;P.apply(this,arguments)}};var g=function(Q,P){var R;return function(){var S=this;var T=arguments;window.clearTimeout(R);R=window.setTimeout(function(){Q.apply(S,T)},P)}};var a=function(P,R,T){var S;var Q=P.trigger;var U={};P.trigger=function(){var V=arguments[0];if(R.indexOf(V)!==-1){U[V]=arguments}else{return Q.apply(P,arguments)}};T.apply(P,[]);P.trigger=Q;for(S in U){if(U.hasOwnProperty(S)){Q.apply(P,U[S])}}};var A=function(S,R,P,Q){S.on(R,P,function(T){var U=T.target;while(U&&U.parentNode!==S[0]){U=U.parentNode}T.currentTarget=U;return Q.apply(this,[T])})};var l=function(R){var Q={};if("selectionStart" in R){Q.start=R.selectionStart;Q.length=R.selectionEnd-Q.start}else{if(document.selection){R.focus();var S=document.selection.createRange();var P=document.selection.createRange().text.length;S.moveStart("character",-R.value.length);Q.start=S.text.length-P;Q.length=P}}return Q};var n=function(S,T,Q){var P,U,R={};if(Q){for(P=0,U=Q.length;P<U;P++){R[Q[P]]=S.css(Q[P])}}else{R=S.css()}T.css(R)};var K=function(S,R){if(!S){return 0}var Q=v("<test>").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).text(S).appendTo("body");n(R,Q,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]);var P=Q.width();Q.remove();return P};var L=function(R){var P=null;var Q=function(V,ab){var Z,aa,W,Y,S;var T,U,X;V=V||window.event||{};ab=ab||{};if(V.metaKey||V.altKey){return}if(!ab.force&&R.data("grow")===false){return}Z=R.val();if(V.type&&V.type.toLowerCase()==="keydown"){aa=V.keyCode;W=((aa>=97&&aa<=122)||(aa>=65&&aa<=90)||(aa>=48&&aa<=57)||aa===32);if(aa===q||aa===o){X=l(R[0]);if(X.length){Z=Z.substring(0,X.start)+Z.substring(X.start+X.length)}else{if(aa===o&&X.start){Z=Z.substring(0,X.start-1)+Z.substring(X.start+1)}else{if(aa===q&&typeof X.start!=="undefined"){Z=Z.substring(0,X.start)+Z.substring(X.start+1)}}}}else{if(W){T=V.shiftKey;U=String.fromCharCode(V.keyCode);if(T){U=U.toUpperCase()}else{U=U.toLowerCase()}Z+=U}}}Y=R.attr("placeholder");if(!Z&&Y){Z=Y}S=K(Z,R)+4;if(S!==P){P=S;R.width(S);R.triggerHandler("resize")}};R.on("keydown keyup update blur",Q);Q()};var E=function(Q){var P=document.createElement("div");P.appendChild(Q.cloneNode(true));return P.innerHTML};var d=function(R,Q){if(!Q){Q={}}var P="Selectize";console.error(P+": "+R);if(Q.explanation){if(console.group){console.group()}console.error(Q.explanation);if(console.group){console.groupEnd()}}};var c=function(U,R){var W,S,P,Q,V,X=this;V=U[0];V.selectize=X;var T=window.getComputedStyle&&window.getComputedStyle(V,null);Q=T?T.getPropertyValue("direction"):V.currentStyle&&V.currentStyle.direction;Q=Q||U.parents("[dir]:first").attr("dir")||"";v.extend(X,{order:0,settings:R,$input:U,tabIndex:U.attr("tabindex")||"",tagType:V.tagName.toLowerCase()==="select"?k:h,rtl:/rtl/i.test(Q),eventNS:".selectize"+(++c.count),highlightedValue:null,isOpen:false,isDisabled:false,isRequired:U.is("[required]"),isInvalid:false,isLocked:false,isFocused:false,isInputHidden:false,isSetup:false,isShiftDown:false,isCmdDown:false,isCtrlDown:false,ignoreFocus:false,ignoreBlur:false,ignoreHover:false,hasOptions:false,currentResults:null,lastValue:"",caretPos:0,loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:R.loadThrottle===null?X.onSearchChange:g(X.onSearchChange,R.loadThrottle)});X.sifter=new m(this.options,{diacritics:R.diacritics});if(X.settings.options){for(S=0,P=X.settings.options.length;S<P;S++){X.registerOption(X.settings.options[S])}delete X.settings.options}if(X.settings.optgroups){for(S=0,P=X.settings.optgroups.length;S<P;S++){X.registerOptionGroup(X.settings.optgroups[S])}delete X.settings.optgroups}X.settings.mode=X.settings.mode||(X.settings.maxItems===1?"single":"multi");if(typeof X.settings.hideSelected!=="boolean"){X.settings.hideSelected=X.settings.mode==="multi"}X.initializePlugins(X.settings.plugins);X.setupCallbacks();X.setupTemplates();X.setup()};G.mixin(c);if(typeof i!=="undefined"){i.mixin(c)}else{d("Dependency MicroPlugin is missing",{explanation:'Make sure you either: (1) are using the "standalone" version of Selectize, or (2) require MicroPlugin before you load Selectize.'})}v.extend(c.prototype,{setup:function(){var V=this;var ac=V.settings;var Y=V.eventNS;var U=v(window);var ag=v(document);var R=V.$input;var aa;var ae;var Q;var S;var W;var ab;var ah;var T;var af;var ad;var X;var Z;ah=V.settings.mode;ad=R.attr("class")||"";aa=v("<div>").addClass(ac.wrapperClass).addClass(ad).addClass(ah);ae=v("<div>").addClass(ac.inputClass).addClass("items").appendTo(aa);Q=v('<input type="text" autocomplete="off" />').appendTo(ae).attr("tabindex",R.is(":disabled")?"-1":V.tabIndex);ab=v(ac.dropdownParent||aa);S=v("<div>").addClass(ac.dropdownClass).addClass(ah).hide().appendTo(ab);W=v("<div>").addClass(ac.dropdownContentClass).appendTo(S);if(Z=R.attr("id")){Q.attr("id",Z+"-selectized");v("label[for='"+Z+"']").attr("for",Z+"-selectized")}if(V.settings.copyClassesToDropdown){S.addClass(ad)}aa.css({width:R[0].style.width});if(V.plugins.names.length){X="plugin-"+V.plugins.names.join(" plugin-");aa.addClass(X);S.addClass(X)}if((ac.maxItems===null||ac.maxItems>1)&&V.tagType===k){R.attr("multiple","multiple")}if(V.settings.placeholder){Q.attr("placeholder",ac.placeholder)}if(!V.settings.splitOn&&V.settings.delimiter){var P=V.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");V.settings.splitOn=new RegExp("\\s*"+P+"+\\s*")}if(R.attr("autocorrect")){Q.attr("autocorrect",R.attr("autocorrect"))}if(R.attr("autocapitalize")){Q.attr("autocapitalize",R.attr("autocapitalize"))}V.$wrapper=aa;V.$control=ae;V.$control_input=Q;V.$dropdown=S;V.$dropdown_content=W;S.on("mouseenter","[data-selectable]",function(){return V.onOptionHover.apply(V,arguments)});S.on("mousedown click","[data-selectable]",function(){return V.onOptionSelect.apply(V,arguments)});A(ae,"mousedown","*:not(input)",function(){return V.onItemSelect.apply(V,arguments)});L(Q);ae.on({mousedown:function(){return V.onMouseDown.apply(V,arguments)},click:function(){return V.onClick.apply(V,arguments)}});Q.on({mousedown:function(ai){ai.stopPropagation()},keydown:function(){return V.onKeyDown.apply(V,arguments)},keyup:function(){return V.onKeyUp.apply(V,arguments)},keypress:function(){return V.onKeyPress.apply(V,arguments)},resize:function(){V.positionDropdown.apply(V,[])},blur:function(){return V.onBlur.apply(V,arguments)},focus:function(){V.ignoreBlur=false;return V.onFocus.apply(V,arguments)},paste:function(){return V.onPaste.apply(V,arguments)}});ag.on("keydown"+Y,function(ai){V.isCmdDown=ai[b?"metaKey":"ctrlKey"];V.isCtrlDown=ai[b?"altKey":"ctrlKey"];V.isShiftDown=ai.shiftKey});ag.on("keyup"+Y,function(ai){if(ai.keyCode===e){V.isCtrlDown=false}if(ai.keyCode===j){V.isShiftDown=false}if(ai.keyCode===J){V.isCmdDown=false}});ag.on("mousedown"+Y,function(ai){if(V.isFocused){if(ai.target===V.$dropdown[0]||ai.target.parentNode===V.$dropdown[0]){return false}if(!V.$control.has(ai.target).length&&ai.target!==V.$control[0]){V.blur(ai.target)}}});U.on(["scroll"+Y,"resize"+Y].join(" "),function(){if(V.isOpen){V.positionDropdown.apply(V,arguments)}});U.on("mousemove"+Y,function(){V.ignoreHover=false});this.revertSettings={$children:R.children().detach(),tabindex:R.attr("tabindex")};R.attr("tabindex",-1).hide().after(V.$wrapper);if(v.isArray(ac.items)){V.setValue(ac.items);delete ac.items}if(C){R.on("invalid"+Y,function(ai){ai.preventDefault();V.isInvalid=true;V.refreshState()})}V.updateOriginalInput();V.refreshItems();V.refreshState();V.updatePlaceholder();V.isSetup=true;if(R.is(":disabled")){V.disable()}V.on("change",this.onChange);R.data("selectize",V);R.addClass("selectized");V.trigger("initialize");if(ac.preload===true){V.onSearchChange("")}},setupTemplates:function(){var Q=this;var P=Q.settings.labelField;var R=Q.settings.optgroupLabelField;var S={optgroup:function(T){return'<div class="optgroup">'+T.html+"</div>"},optgroup_header:function(U,T){return'<div class="optgroup-header">'+T(U[R])+"</div>"},option:function(U,T){return'<div class="option">'+T(U[P])+"</div>"},item:function(U,T){return'<div class="item">'+T(U[P])+"</div>"},option_create:function(U,T){return'<div class="create">Add <strong>'+T(U.input)+"</strong>&hellip;</div>"}};Q.settings.render=v.extend({},S,Q.settings.render)},setupCallbacks:function(){var P,Q,R={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(P in R){if(R.hasOwnProperty(P)){Q=this.settings[R[P]];if(Q){this.on(P,Q)}}}},onClick:function(Q){var P=this;if(!P.isFocused){P.focus();Q.preventDefault()}},onMouseDown:function(S){var Q=this;var R=S.isDefaultPrevented();var P=v(S.target);if(Q.isFocused){if(S.target!==Q.$control_input[0]){if(Q.settings.mode==="single"){Q.isOpen?Q.close():Q.open()}else{if(!R){Q.setActiveItem(null)}}return false}}else{if(!R){window.setTimeout(function(){Q.focus()},0)}}},onChange:function(){this.$input.trigger("change")},onPaste:function(Q){var P=this;if(P.isFull()||P.isInputHidden||P.isLocked){Q.preventDefault();return}if(P.settings.splitOn){setTimeout(function(){var S=P.$control_input.val();if(!S.match(P.settings.splitOn)){return}var R=v.trim(S).split(P.settings.splitOn);for(var T=0,U=R.length;T<U;T++){P.createItem(R[T])}},0)}},onKeyPress:function(Q){if(this.isLocked){return Q&&Q.preventDefault()}var P=String.fromCharCode(Q.keyCode||Q.which);if(this.settings.create&&this.settings.mode==="multi"&&P===this.settings.delimiter){this.createItem();Q.preventDefault();return false}},lastKeyDown:null,onKeyDown:function(T){var S=T.target===this.$control_input[0];var R=this;if(R.isLocked){if(T.keyCode!==F){T.preventDefault()}return}switch(T.keyCode){case I:if(R.isCmdDown){R.selectAll();return}break;case w:if(R.isOpen){T.preventDefault();T.stopPropagation();R.close()}return;case B:if(!T.ctrlKey||T.altKey){break}case u:if(!R.isOpen&&R.hasOptions){R.open()}else{if(R.$activeOption){R.ignoreHover=true;var P=R.getAdjacentOption(R.$activeOption,1);if(P.length){R.setActiveOption(P,true,true)}}}T.preventDefault();return;case x:if(!T.ctrlKey||T.altKey){break}case H:if(R.$activeOption){R.ignoreHover=true;var Q=R.getAdjacentOption(R.$activeOption,-1);if(Q.length){R.setActiveOption(Q,true,true)}}T.preventDefault();return;case z:if(R.isOpen&&R.$activeOption){R.onOptionSelect({currentTarget:R.$activeOption});T.preventDefault()}if(!R.settings.submitOnReturn){return false}return;case p:R.advanceSelection(-1,T);return;case t:R.advanceSelection(1,T);return;case F:if(R.settings.selectOnTab&&R.isOpen&&R.$activeOption){R.onOptionSelect({currentTarget:R.$activeOption});if(!R.isFull()){T.preventDefault()}}if(R.settings.create&&R.createItem()){T.preventDefault()}return;case o:case q:R.deleteSelection(T);return}if((R.isFull()||R.isInputHidden)&&!(b?T.metaKey:T.ctrlKey)){T.preventDefault();return}},onKeyUp:function(R){var P=this;if(P.isLocked){return R&&R.preventDefault()}var Q=P.$control_input.val()||"";if(P.lastValue!==Q){P.lastValue=Q;P.onSearchChange(Q);P.refreshOptions();P.trigger("type",Q)}},onSearchChange:function(R){var P=this;var Q=P.settings.load;if(!Q){return}if(P.loadedSearches.hasOwnProperty(R)){return}P.loadedSearches[R]=true;P.load(function(S){Q.apply(P,[R,S])})},onFocus:function(R){var P=this;var Q=P.isFocused;if(P.isDisabled){P.blur();R&&R.preventDefault();return false}if(P.ignoreFocus){return}P.isFocused=true;if(P.settings.preload==="focus"){P.onSearchChange("")}if(!Q){P.trigger("focus")}if(!P.$activeItems.length){P.showInput();P.setActiveItem(null);P.refreshOptions(!!P.settings.openOnFocus)}P.refreshState()},onBlur:function(S,Q){var P=this;if(!P.isFocused){return}P.isFocused=false;if(P.ignoreFocus){return}else{if(!P.ignoreBlur&&document.activeElement===P.$dropdown_content[0]){P.ignoreBlur=true;P.onFocus(S);return}}var R=function(){P.close();P.setTextboxValue("");P.setActiveItem(null);P.setActiveOption(null);P.setCaret(P.items.length);P.refreshState();Q&&Q.focus&&Q.focus();P.ignoreFocus=false;P.trigger("blur")};P.ignoreFocus=true;if(P.settings.create&&P.settings.createOnBlur){P.createItem(null,false,R)}else{R()}},onOptionHover:function(P){if(this.ignoreHover){return}this.setActiveOption(P.currentTarget,false)},onOptionSelect:function(T){var R,P,S,Q=this;if(T.preventDefault){T.preventDefault();T.stopPropagation()}P=v(T.currentTarget);if(P.hasClass("create")){Q.createItem(null,function(){if(Q.settings.closeAfterSelect){Q.close();console.log("1")}})}else{R=P.attr("data-value");if(typeof R!=="undefined"){Q.lastQuery=null;Q.setTextboxValue("");Q.addItem(R);if(Q.settings.closeAfterSelect){Q.close();Q.blur()}else{if(!Q.settings.hideSelected&&T.type&&/mouse/.test(T.type)){Q.setActiveOption(Q.getOption(R))}}}}},onItemSelect:function(Q){var P=this;if(P.isLocked){return}if(P.settings.mode==="multi"){Q.preventDefault();P.setActiveItem(Q.currentTarget,Q)}},load:function(Q){var P=this;var R=P.$wrapper.addClass(P.settings.loadingClass);P.loading++;Q.apply(P,[function(S){P.loading=Math.max(P.loading-1,0);if(S&&S.length){P.addOption(S);P.refreshOptions(P.isFocused&&!P.isInputHidden)}if(!P.loading){R.removeClass(P.settings.loadingClass)}P.trigger("load",S)}])},setTextboxValue:function(P){var R=this.$control_input;var Q=R.val()!==P;if(Q){R.val(P).triggerHandler("update");this.lastValue=P}},getValue:function(){if(this.tagType===k&&this.$input.attr("multiple")){return this.items}else{return this.items.join(this.settings.delimiter)}},setValue:function(R,P){var Q=P?[]:["change"];a(this,Q,function(){this.clear(P);this.addItems(R,P)})},setActiveItem:function(W,U){var Z=this;var T;var S,X,P,R,Y,Q;var V;if(Z.settings.mode==="single"){return}W=v(W);if(!W.length){v(Z.$activeItems).removeClass("active");Z.$activeItems=[];if(Z.isFocused){Z.showInput()}return}T=U&&U.type.toLowerCase();if(T==="mousedown"&&Z.isShiftDown&&Z.$activeItems.length){V=Z.$control.children(".active:last");P=Array.prototype.indexOf.apply(Z.$control[0].childNodes,[V[0]]);R=Array.prototype.indexOf.apply(Z.$control[0].childNodes,[W[0]]);if(P>R){Q=P;P=R;R=Q}for(S=P;S<=R;S++){Y=Z.$control[0].childNodes[S];if(Z.$activeItems.indexOf(Y)===-1){v(Y).addClass("active");Z.$activeItems.push(Y)}}U.preventDefault()}else{if((T==="mousedown"&&Z.isCtrlDown)||(T==="keydown"&&this.isShiftDown)){if(W.hasClass("active")){X=Z.$activeItems.indexOf(W[0]);Z.$activeItems.splice(X,1);W.removeClass("active")}else{Z.$activeItems.push(W.addClass("active")[0])}}else{v(Z.$activeItems).removeClass("active");Z.$activeItems=[W.addClass("active")[0]]}}Z.hideInput();if(!this.isFocused){Z.focus()}},setActiveOption:function(P,V,R){var Q,W,U;var T,S;var X=this;if(X.$activeOption){X.$activeOption.removeClass("active")}X.$activeOption=null;P=v(P);if(!P.length){return}X.$activeOption=P.addClass("active");if(V||!O(V)){Q=X.$dropdown_content.height();W=X.$activeOption.outerHeight(true);V=X.$dropdown_content.scrollTop()||0;U=X.$activeOption.offset().top-X.$dropdown_content.offset().top+V;T=U;S=U-Q+W;if(U+W>Q+V){X.$dropdown_content.stop().animate({scrollTop:S},R?X.settings.scrollDuration:0)}else{if(U<V){X.$dropdown_content.stop().animate({scrollTop:T},R?X.settings.scrollDuration:0)}}}},selectAll:function(){var P=this;if(P.settings.mode==="single"){return}P.$activeItems=Array.prototype.slice.apply(P.$control.children(":not(input)").addClass("active"));if(P.$activeItems.length){P.hideInput();P.close()}P.focus()},hideInput:function(){var P=this;P.setTextboxValue("");P.$control_input.css({opacity:0,position:"absolute",left:P.rtl?10000:-10000});P.isInputHidden=true},showInput:function(){this.$control_input.css({opacity:1,position:"relative",left:0});this.isInputHidden=false},focus:function(){var P=this;if(P.isDisabled){return}P.ignoreFocus=true;P.$control_input[0].focus();window.setTimeout(function(){P.ignoreFocus=false;P.onFocus()},0)},blur:function(P){this.$control_input[0].blur();this.onBlur(null,P)},getScoreFunction:function(P){return this.sifter.getScoreFunction(P,this.getSearchOptions())},getSearchOptions:function(){var Q=this.settings;var P=Q.sortField;if(typeof P==="string"){P=[{field:P}]}return{fields:Q.searchField,conjunction:Q.searchConjunction,sort:P}},search:function(T){var S,U,P,X,R;var V=this;var Q=V.settings;var W=this.getSearchOptions();if(Q.score){R=V.settings.score.apply(this,[T]);if(typeof R!=="function"){throw new Error('Selectize "score" setting must be a function that returns a function')}}if(T!==V.lastQuery){V.lastQuery=T;X=V.sifter.search(T,v.extend(W,{score:R}));V.currentResults=X}else{X=v.extend(true,{},V.currentResults)}if(Q.hideSelected){for(S=X.items.length-1;S>=0;S--){if(V.items.indexOf(y(X.items[S].id))!==-1){X.items.splice(S,1)}}}return X},refreshOptions:function(Z){var ag,af,ae,ac,aj,P,V,ah,R,ad,T,ai,U;var S,Y,aa;if(typeof Z==="undefined"){Z=true}var X=this;var Q=v.trim(X.$control_input.val());var ab=X.search(Q);var W=X.$dropdown_content;var ak=X.$activeOption&&y(X.$activeOption.attr("data-value"));ac=ab.items.length;if(typeof X.settings.maxOptions==="number"){ac=Math.min(ac,X.settings.maxOptions)}aj={};P=[];for(ag=0;ag<ac;ag++){V=X.options[ab.items[ag].id];ah=X.render("option",V);R=V[X.settings.optgroupField]||"";ad=v.isArray(R)?R:[R];for(af=0,ae=ad&&ad.length;af<ae;af++){R=ad[af];if(!X.optgroups.hasOwnProperty(R)){R=""}if(!aj.hasOwnProperty(R)){aj[R]=document.createDocumentFragment();P.push(R)}aj[R].appendChild(ah)}}if(this.settings.lockOptgroupOrder){P.sort(function(am,al){var an=X.optgroups[am].$order||0;var ao=X.optgroups[al].$order||0;return an-ao})}T=document.createDocumentFragment();for(ag=0,ac=P.length;ag<ac;ag++){R=P[ag];if(X.optgroups.hasOwnProperty(R)&&aj[R].childNodes.length){ai=document.createDocumentFragment();ai.appendChild(X.render("optgroup_header",X.optgroups[R]));ai.appendChild(aj[R]);T.appendChild(X.render("optgroup",v.extend({},X.optgroups[R],{html:E(ai),dom:ai})))}else{T.appendChild(aj[R])}}W.html(T);if(X.settings.highlight&&ab.query.length&&ab.tokens.length){W.removeHighlight();for(ag=0,ac=ab.tokens.length;ag<ac;ag++){M(W,ab.tokens[ag].regex)}}if(!X.settings.hideSelected){for(ag=0,ac=X.items.length;ag<ac;ag++){X.getOption(X.items[ag]).addClass("selected")}}U=X.canCreate(Q);if(U){W.prepend(X.render("option_create",{input:Q}));aa=v(W[0].childNodes[0])}X.hasOptions=ab.items.length>0||U;if(X.hasOptions){if(ab.items.length>0){Y=ak&&X.getOption(ak);if(Y&&Y.length){S=Y}else{if(X.settings.mode==="single"&&X.items.length){S=X.getOption(X.items[0])}}if(!S||!S.length){if(aa&&!X.settings.addPrecedence){S=X.getAdjacentOption(aa,1)}else{S=W.find("[data-selectable]:first")}}}else{S=aa}X.setActiveOption(S);if(Z&&!X.isOpen){X.open()}}else{X.setActiveOption(null);if(Z&&X.isOpen){X.close()}}},addOption:function(S){var Q,T,R,P=this;if(v.isArray(S)){for(Q=0,T=S.length;Q<T;Q++){P.addOption(S[Q])}return}if(R=P.registerOption(S)){P.userOptions[R]=true;P.lastQuery=null;P.trigger("option_add",R,S)}},registerOption:function(Q){var P=y(Q[this.settings.valueField]);if(typeof P==="undefined"||P===null||this.options.hasOwnProperty(P)){return false}Q.$order=Q.$order||++this.order;this.options[P]=Q;return P},registerOptionGroup:function(Q){var P=y(Q[this.settings.optgroupValueField]);if(!P){return false}Q.$order=Q.$order||++this.order;this.optgroups[P]=Q;return P},addOptionGroup:function(Q,P){P[this.settings.optgroupValueField]=Q;if(Q=this.registerOptionGroup(P)){this.trigger("optgroup_add",Q,P)}},removeOptionGroup:function(P){if(this.optgroups.hasOwnProperty(P)){delete this.optgroups[P];this.renderCache={};this.trigger("optgroup_remove",P)}},clearOptionGroups:function(){this.optgroups={};this.renderCache={};this.trigger("optgroup_clear")},updateOption:function(W,U){var Y=this;var X,P;var R,S,V,Q,T;W=y(W);R=y(U[Y.settings.valueField]);if(W===null){return}if(!Y.options.hasOwnProperty(W)){return}if(typeof R!=="string"){throw new Error("Value must be set in option data")}T=Y.options[W].$order;if(R!==W){delete Y.options[W];S=Y.items.indexOf(W);if(S!==-1){Y.items.splice(S,1,R)}}U.$order=U.$order||T;Y.options[R]=U;V=Y.renderCache.item;Q=Y.renderCache.option;if(V){delete V[W];delete V[R]}if(Q){delete Q[W];delete Q[R]}if(Y.items.indexOf(R)!==-1){X=Y.getItem(W);P=v(Y.render("item",U));if(X.hasClass("active")){P.addClass("active")}X.replaceWith(P)}Y.lastQuery=null;if(Y.isOpen){Y.refreshOptions(false)}},removeOption:function(T,R){var Q=this;T=y(T);var P=Q.renderCache.item;var S=Q.renderCache.option;if(P){delete P[T]}if(S){delete S[T]}delete Q.userOptions[T];delete Q.options[T];Q.lastQuery=null;Q.trigger("option_remove",T);Q.removeItem(T,R)},clearOptions:function(){var P=this;P.loadedSearches={};P.userOptions={};P.renderCache={};P.options=P.sifter.items={};P.lastQuery=null;P.trigger("option_clear");P.clear()},getOption:function(P){return this.getElementWithValue(P,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(S,R){var P=this.$dropdown.find("[data-selectable]");var Q=P.index(S)+R;return Q>=0&&Q<P.length?P.eq(Q):v()},getElementWithValue:function(R,Q){R=y(R);if(typeof R!=="undefined"&&R!==null){for(var P=0,S=Q.length;P<S;P++){if(Q[P].getAttribute("data-value")===R){return v(Q[P])}}}return v()},getItem:function(P){return this.getElementWithValue(P,this.$control.children())},addItems:function(R,Q){var P=v.isArray(R)?R:[R];for(var S=0,T=P.length;S<T;S++){this.isPending=(S<T-1);this.addItem(P[S],Q)}},addItem:function(R,P){var Q=P?[]:["change"];a(this,Q,function(){var Z,T,X;var aa=this;var S=aa.settings.mode;var W,V,Y,U;R=y(R);if(aa.items.indexOf(R)!==-1){if(S==="single"){aa.close()}return}if(!aa.options.hasOwnProperty(R)){return}if(S==="single"){aa.clear(P)}if(S==="multi"&&aa.isFull()){return}Z=v(aa.render("item",aa.options[R]));U=aa.isFull();aa.items.splice(aa.caretPos,0,R);aa.insertAtCaret(Z);if(!aa.isPending||(!U&&aa.isFull())){aa.refreshState()}if(aa.isSetup){X=aa.$dropdown_content.find("[data-selectable]");if(!aa.isPending){T=aa.getOption(R);Y=aa.getAdjacentOption(T,1).attr("data-value");aa.refreshOptions(aa.isFocused&&S!=="single");if(Y){aa.setActiveOption(aa.getOption(Y))}}if(!X.length||aa.isFull()){aa.close()}else{aa.positionDropdown()}aa.updatePlaceholder();aa.trigger("item_add",R,Z);aa.updateOriginalInput({silent:P})}})},removeItem:function(U,S){var R=this;var Q,T,P;Q=(U instanceof v)?U:R.getItem(U);U=y(Q.attr("data-value"));T=R.items.indexOf(U);if(T!==-1){Q.remove();if(Q.hasClass("active")){P=R.$activeItems.indexOf(Q[0]);R.$activeItems.splice(P,1)}R.items.splice(T,1);R.lastQuery=null;if(!R.settings.persist&&R.userOptions.hasOwnProperty(U)){R.removeOption(U,S)}if(T<R.caretPos){R.setCaret(R.caretPos-1)}R.refreshState();R.updatePlaceholder();R.updateOriginalInput({silent:S});R.positionDropdown();R.trigger("item_remove",U,Q)}},createItem:function(S,U){var R=this;var V=R.caretPos;S=S||v.trim(R.$control_input.val()||"");var W=arguments[arguments.length-1];if(typeof W!=="function"){W=function(){}}if(typeof U!=="boolean"){U=true}if(!R.canCreate(S)){W();return false}R.lock();var P=(typeof R.settings.create==="function")?this.settings.create:function(X){var Y={};Y[R.settings.labelField]=X;Y[R.settings.valueField]=X;return Y};var T=r(function(Y){R.unlock();if(!Y||typeof Y!=="object"){return W()}var X=y(Y[R.settings.valueField]);if(typeof X!=="string"){return W()}R.setTextboxValue("");R.addOption(Y);R.setCaret(V);R.addItem(X);R.refreshOptions(U&&R.settings.mode!=="single");W(Y)});var Q=P.apply(this,[S,T]);if(typeof Q!=="undefined"){T(Q)}return true},refreshItems:function(){this.lastQuery=null;if(this.isSetup){this.addItem(this.items)}this.refreshState();this.updateOriginalInput()},refreshState:function(){this.refreshValidityState();this.refreshClasses()},refreshValidityState:function(){if(!this.isRequired){return false}var P=!this.items.length;this.isInvalid=P;this.$control_input.prop("required",P);this.$input.prop("required",!P)},refreshClasses:function(){var P=this;var Q=P.isFull();var R=P.isLocked;P.$wrapper.toggleClass("rtl",P.rtl);P.$control.toggleClass("focus",P.isFocused).toggleClass("disabled",P.isDisabled).toggleClass("required",P.isRequired).toggleClass("invalid",P.isInvalid).toggleClass("locked",R).toggleClass("full",Q).toggleClass("not-full",!Q).toggleClass("input-active",P.isFocused&&!P.isInputHidden).toggleClass("dropdown-active",P.isOpen).toggleClass("has-options",!v.isEmptyObject(P.options)).toggleClass("has-items",P.items.length>0);P.$control_input.data("grow",!Q&&!R)},isFull:function(){return this.settings.maxItems!==null&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(T){var S,U,R,Q,P=this;T=T||{};if(P.tagType===k){R=[];for(S=0,U=P.items.length;S<U;S++){Q=P.options[P.items[S]][P.settings.labelField]||"";R.push('<option value="'+D(P.items[S])+'" selected="selected">'+D(Q)+"</option>")}if(!R.length&&!this.$input.attr("multiple")){R.push('<option value="" selected="selected"></option>')}P.$input.html(R.join(""))}else{P.$input.val(P.getValue());P.$input.attr("value",P.$input.val())}if(P.isSetup){if(!T.silent){P.trigger("change",P.$input.val())}}},updatePlaceholder:function(){if(!this.settings.placeholder){return}var P=this.$control_input;if(this.items.length){P.removeAttr("placeholder")}else{P.attr("placeholder",this.settings.placeholder)}P.triggerHandler("update",{force:true})},open:function(){var P=this;if(P.isLocked||P.isOpen||(P.settings.mode==="multi"&&P.isFull())){return}P.focus();P.isOpen=true;P.refreshState();P.$dropdown.css({visibility:"hidden",display:"block"});P.positionDropdown();P.$dropdown.css({visibility:"visible"});P.trigger("dropdown_open",P.$dropdown)},close:function(){var P=this;var Q=P.isOpen;if(P.settings.mode==="single"&&P.items.length){P.hideInput();P.$control_input.blur()}P.isOpen=false;P.$dropdown.hide();P.setActiveOption(null);P.refreshState();if(Q){P.trigger("dropdown_close",P.$dropdown)}},positionDropdown:function(){var P=this.$control;var Q=this.settings.dropdownParent==="body"?P.offset():P.position();Q.top+=P.outerHeight(true);this.$dropdown.css({width:P.outerWidth(),top:Q.top,left:Q.left})},clear:function(Q){var P=this;if(!P.items.length){return}P.$control.children(":not(input)").remove();P.items=[];P.lastQuery=null;P.setCaret(0);P.setActiveItem(null);P.updatePlaceholder();P.updateOriginalInput({silent:Q});P.refreshState();P.showInput();P.trigger("clear")},insertAtCaret:function(P){var Q=Math.min(this.caretPos,this.items.length);if(Q===0){this.$control.prepend(P)}else{v(this.$control[0].childNodes[Q]).before(P)}this.setCaret(Q+1)},deleteSelection:function(S){var Q,P,W,X,Y,U,T,V,R;var Z=this;W=(S&&S.keyCode===o)?-1:1;X=l(Z.$control_input[0]);if(Z.$activeOption&&!Z.settings.hideSelected){T=Z.getAdjacentOption(Z.$activeOption,-1).attr("data-value")}Y=[];if(Z.$activeItems.length){R=Z.$control.children(".active:"+(W>0?"last":"first"));U=Z.$control.children(":not(input)").index(R);if(W>0){U++}for(Q=0,P=Z.$activeItems.length;Q<P;Q++){Y.push(v(Z.$activeItems[Q]).attr("data-value"))}if(S){S.preventDefault();S.stopPropagation()}}else{if((Z.isFocused||Z.settings.mode==="single")&&Z.items.length){if(W<0&&X.start===0&&X.length===0){Y.push(Z.items[Z.caretPos-1])}else{if(W>0&&X.start===Z.$control_input.val().length){Y.push(Z.items[Z.caretPos])}}}}if(!Y.length||(typeof Z.settings.onDelete==="function"&&Z.settings.onDelete.apply(Z,[Y])===false)){return false}if(typeof U!=="undefined"){Z.setCaret(U)}while(Y.length){Z.removeItem(Y.pop())}Z.showInput();Z.positionDropdown();Z.refreshOptions(true);if(T){V=Z.getOption(T);if(V.length){Z.setActiveOption(V)}}return true},advanceSelection:function(T,Q){var R,U,V,W,S,P;var X=this;if(T===0){return}if(X.rtl){T*=-1}R=T>0?"last":"first";U=l(X.$control_input[0]);if(X.isFocused&&!X.isInputHidden){W=X.$control_input.val().length;S=T<0?U.start===0&&U.length===0:U.start===W;if(S&&!W){X.advanceCaret(T,Q)}}else{P=X.$control.children(".active:"+R);if(P.length){V=X.$control.children(":not(input)").index(P);X.setActiveItem(null);X.setCaret(T>0?V+1:V)}}},advanceCaret:function(T,S){var P=this,R,Q;if(T===0){return}R=T>0?"next":"prev";if(P.isShiftDown){Q=P.$control_input[R]();if(Q.length){P.hideInput();P.setActiveItem(Q);S&&S.preventDefault()}}else{P.setCaret(P.caretPos+T)}},setCaret:function(S){var Q=this;if(Q.settings.mode==="single"){S=Q.items.length}else{S=Math.max(0,Math.min(Q.items.length,S))}if(!Q.isPending){var R,V,T,P,U;P=Q.$control.children(":not(input)");for(R=0,V=P.length;R<V;R++){U=v(P[R]).detach();if(R<S){Q.$control_input.before(U)}else{Q.$control.append(U)}}}Q.caretPos=S},lock:function(){this.close();this.isLocked=true;this.refreshState()},unlock:function(){this.isLocked=false;this.refreshState()},disable:function(){var P=this;P.$input.prop("disabled",true);P.$control_input.prop("disabled",true).prop("tabindex",-1);P.isDisabled=true;P.lock()},enable:function(){var P=this;P.$input.prop("disabled",false);P.$control_input.prop("disabled",false).prop("tabindex",P.tabIndex);P.isDisabled=false;P.unlock()},destroy:function(){var P=this;var R=P.eventNS;var Q=P.revertSettings;P.trigger("destroy");P.off();P.$wrapper.remove();P.$dropdown.remove();P.$input.html("").append(Q.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:Q.tabindex}).show();P.$control_input.removeData("grow");P.$input.removeData("selectize");v(window).off(R);v(document).off(R);v(document.body).off(R);delete P.$input[0].selectize},render:function(X,R){var V,Q,U;var S="";var P=false;var W=this;var T=/^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;if(X==="option"||X==="item"){V=y(R[W.settings.valueField]);P=!!V}if(P){if(!O(W.renderCache[X])){W.renderCache[X]={}}if(W.renderCache[X].hasOwnProperty(V)){return W.renderCache[X][V]}}S=v(W.settings.render[X].apply(this,[R,D]));if(X==="option"||X==="option_create"){S.attr("data-selectable","")}else{if(X==="optgroup"){Q=R[W.settings.optgroupValueField]||"";S.attr("data-group",Q)}}if(X==="option"||X==="item"){S.attr("data-value",V||"")}if(P){W.renderCache[X][V]=S[0]}return S[0]},clearCache:function(P){var Q=this;if(typeof P==="undefined"){Q.renderCache={}}else{delete Q.renderCache[P]}},canCreate:function(Q){var P=this;if(!P.settings.create){return false}var R=P.settings.createFilter;return Q.length&&(typeof R!=="function"||R.apply(P,[Q]))&&(typeof R!=="string"||new RegExp(R).test(Q))&&(!(R instanceof RegExp)||R.test(Q))}});c.count=0;c.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:true,diacritics:true,create:false,createOnBlur:false,createFilter:null,highlight:true,openOnFocus:true,maxOptions:1000,maxItems:null,hideSelected:null,addPrecedence:false,selectOnTab:false,preload:false,allowEmptyOption:false,closeAfterSelect:false,submitOnReturn:true,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:"data-data",optgroupField:"optgroup",valueField:"value",labelField:"text",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:false,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"selectize-control",inputClass:"selectize-input",dropdownClass:"selectize-dropdown",dropdownContentClass:"selectize-dropdown-content",dropdownParent:null,copyClassesToDropdown:true,render:{}};v.fn.selectize=function(V){var R=v.fn.selectize.defaults;var Q=v.extend({},R,V);var S=Q.dataAttr;var Y=Q.labelField;var Z=Q.valueField;var X=Q.optgroupField;var T=Q.optgroupLabelField;var U=Q.optgroupValueField;var P=function(ah,af){var ac,ag,aa,ad;var ab=ah.attr(S);if(!ab){var ae=v.trim(ah.val()||"");if(!Q.allowEmptyOption&&!ae.length){return}aa=ae.split(Q.delimiter);for(ac=0,ag=aa.length;ac<ag;ac++){ad={};ad[Y]=aa[ac];ad[Z]=aa[ac];af.options.push(ad)}af.items=aa}else{af.options=JSON.parse(ab);for(ac=0,ag=af.options.length;ac<ag;ac++){af.items.push(af.options[ac][Z])}}};var W=function(ah,af){var ag,ac,ad,ak,ae=0;var al=af.options;var aj={};var aa=function(am){var an=S&&am.attr(S);if(typeof an==="string"&&an.length){return JSON.parse(an)}return null};var ai=function(aq,ap){aq=v(aq);var ao=y(aq.val());if(!ao&&!Q.allowEmptyOption){return}if(aj.hasOwnProperty(ao)){if(ap){var am=aj[ao][X];if(!am){aj[ao][X]=ap}else{if(!v.isArray(am)){aj[ao][X]=[am,ap]}else{am.push(ap)}}}return}var an=aa(aq)||{};an[Y]=an[Y]||aq.text();an[Z]=an[Z]||ao;an[X]=an[X]||ap;aj[ao]=an;al.push(an);if(aq.is(":selected")){af.items.push(ao)}};var ab=function(an){var ap,ar,aq,ao,am;an=v(an);aq=an.attr("label");if(aq){ao=aa(an)||{};ao[T]=aq;ao[U]=aq;af.optgroups.push(ao)}am=v("option",an);for(ap=0,ar=am.length;ap<ar;ap++){ai(am[ap],aq)}};af.maxItems=ah.attr("multiple")?null:1;ak=ah.children();for(ag=0,ac=ak.length;ag<ac;ag++){ad=ak[ag].tagName.toLowerCase();if(ad==="optgroup"){ab(ak[ag])}else{if(ad==="option"){ai(ak[ag])}}}};return this.each(function(){if(this.selectize){return}var aa;var ae=v(this);var ad=this.tagName.toLowerCase();var ac=ae.attr("placeholder")||ae.attr("data-placeholder");if(!ac&&!Q.allowEmptyOption){ac=ae.children('option[value=""]').text()}var ab={placeholder:ac,options:[],optgroups:[],items:[]};if(ad==="select"){W(ae,ab)}else{P(ae,ab)}aa=new c(ae,v.extend(true,{},R,ab,V))})};v.fn.selectize.defaults=c.defaults;v.fn.selectize.support={validity:C};c.define("drag_drop",function(Q){if(!v.fn.sortable){throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".')}if(this.settings.mode!=="multi"){return}var P=this;P.lock=(function(){var R=P.lock;return function(){var S=P.$control.data("sortable");if(S){S.disable()}return R.apply(P,arguments)}})();P.unlock=(function(){var R=P.unlock;return function(){var S=P.$control.data("sortable");if(S){S.enable()}return R.apply(P,arguments)}})();P.setup=(function(){var R=P.setup;return function(){R.apply(this,arguments);var S=P.$control.sortable({items:"[data-value]",forcePlaceholderSize:true,disabled:P.isLocked,start:function(U,T){T.placeholder.css("width",T.helper.css("width"));S.css({overflow:"visible"})},stop:function(){S.css({overflow:"hidden"});var U=P.$activeItems?P.$activeItems.slice():null;var T=[];S.children("[data-value]").each(function(){T.push(v(this).attr("data-value"))});P.setValue(T);P.setActiveItem(U)}})}})()});c.define("dropdown_header",function(Q){var P=this;Q=v.extend({title:"Untitled",headerClass:"selectize-dropdown-header",titleRowClass:"selectize-dropdown-header-title",labelClass:"selectize-dropdown-header-label",closeClass:"selectize-dropdown-header-close",html:function(R){return('<div class="'+R.headerClass+'"><div class="'+R.titleRowClass+'"><span class="'+R.labelClass+'">'+R.title+'</span><a href="javascript:void(0)" class="'+R.closeClass+'">&times;</a></div></div>')}},Q);P.setup=(function(){var R=P.setup;return function(){R.apply(P,arguments);P.$dropdown_header=v(Q.html(Q));P.$dropdown.prepend(P.$dropdown_header)}})()});c.define("optgroup_columns",function(R){var Q=this;R=v.extend({equalizeWidth:true,equalizeHeight:true},R);this.getAdjacentOption=function(W,V){var T=W.closest("[data-group]").find("[data-selectable]");var U=T.index(W)+V;return U>=0&&U<T.length?T.eq(U):v()};this.onKeyDown=(function(){var T=Q.onKeyDown;return function(Y){var W,X,U,V;if(this.isOpen&&(Y.keyCode===p||Y.keyCode===t)){Q.ignoreHover=true;V=this.$activeOption.closest("[data-group]");W=V.find("[data-selectable]").index(this.$activeOption);if(Y.keyCode===p){V=V.prev("[data-group]")}else{V=V.next("[data-group]")}U=V.find("[data-selectable]");X=U.eq(Math.min(U.length-1,W));if(X.length){this.setActiveOption(X)}return}return T.apply(this,arguments)}})();var P=function(){var V;var T=P.width;var U=document;if(typeof T==="undefined"){V=U.createElement("div");V.innerHTML='<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>';V=V.firstChild;U.body.appendChild(V);T=P.width=V.offsetWidth-V.clientWidth;U.body.removeChild(V)}return T};var S=function(){var U,Z,T,V,Y,X,W;W=v("[data-group]",Q.$dropdown_content);Z=W.length;if(!Z||!Q.$dropdown_content.width()){return}if(R.equalizeHeight){T=0;for(U=0;U<Z;U++){T=Math.max(T,W.eq(U).height())}W.css({height:T})}if(R.equalizeWidth){X=Q.$dropdown_content.innerWidth()-P();V=Math.round(X/Z);W.css({width:V});if(Z>1){Y=X-V*(Z-1);W.eq(Z-1).css({width:Y})}}};if(R.equalizeHeight||R.equalizeWidth){s.after(this,"positionDropdown",S);s.after(this,"refreshOptions",S)}});c.define("remove_button",function(P){P=v.extend({label:"&times;",title:"Remove",className:"remove",append:true},P);var Q=function(W,U){U.className="remove-single";var T=W;var V='<a href="javascript:void(0)" class="'+U.className+'" tabindex="-1" title="'+D(U.title)+'">'+U.label+"</a>";var S=function(X,Y){return X+Y};W.setup=(function(){var X=T.setup;return function(){if(U.append){var aa=v(T.$input.context).attr("id");var Z=v("#"+aa);var Y=T.settings.render.item;T.settings.render.item=function(ab){return S(Y.apply(W,arguments),V)}}X.apply(W,arguments);W.$control.on("click","."+U.className,function(ab){ab.preventDefault();if(T.isLocked){return}T.clear()})}})()};var R=function(W,U){var T=W;var V='<a href="javascript:void(0)" class="'+U.className+'" tabindex="-1" title="'+D(U.title)+'">'+U.label+"</a>";var S=function(X,Y){var Z=X.search(/(<\/[^>]+>\s*)$/);return X.substring(0,Z)+Y+X.substring(Z)};W.setup=(function(){var X=T.setup;return function(){if(U.append){var Y=T.settings.render.item;T.settings.render.item=function(Z){return S(Y.apply(W,arguments),V)}}X.apply(W,arguments);W.$control.on("click","."+U.className,function(aa){aa.preventDefault();if(T.isLocked){return}var Z=v(aa.currentTarget).parent();T.setActiveItem(Z);if(T.deleteSelection()){T.setCaret(T.items.length)}})}})()};if(this.settings.mode==="single"){Q(this,P);return}else{R(this,P)}});c.define("restore_on_backspace",function(Q){var P=this;Q.text=Q.text||function(R){return R[this.settings.labelField]};this.onKeyDown=(function(){var R=P.onKeyDown;return function(U){var S,T;if(U.keyCode===o&&this.$control_input.val()===""&&!this.$activeItems.length){S=this.caretPos-1;if(S>=0&&S<this.items.length){T=this.options[this.items[S]];if(this.deleteSelection(U)){this.setTextboxValue(Q.text.apply(this,[T]));this.refreshOptions(true)}U.preventDefault();return}}return R.apply(this,arguments)}})()});return c}));