(function(c,g){"function"==typeof t&&t.amd?t("sifter",g):"object"==typeof exports?module.exports=g():c.Sifter=g()})(this,function(){var c=function(c,h){this.items=c;this.settings=h||{diacritics:!0}};c.prototype.tokenize=function(c){if(c=((""+(c||"")).toLowerCase()+"").replace(/^\s+|\s+$|/g,""),!c||!c.length)return[];var h,
e,j,A=[],l=c.split(/ +/);for(c=0,h=l.length;c<h;c++){if(e=(l[c]+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),this.settings.diacritics)for(j in o)o.hasOwnProperty(j)&&(e=e.replace(RegExp(j,"g"),o[j]));A.push({string:l[c],regex:RegExp(e,"i")})}return A};c.prototype.iterator=function(c,h){var e;e=r(c)?Array.prototype.forEach||function(c){for(var e=0,h=this.length;e<h;e++)c(this[e],e,this)}:function(c){for(var e in this)this.hasOwnProperty(e)&&c(this[e],e,this)};e.apply(c,[h])};c.prototype.getScoreFunction=
function(c,h){var e,j,l,g;c=this.prepareSearch(c,h);j=c.tokens;e=c.options.fields;l=j.length;g=c.options.nesting;var q=function(c,e){var h,j;return c?(c=""+(c||""),j=c.search(e.regex),-1===j?0:(h=e.string.length/c.length,0===j&&(h+=0.5),h)):0},o=function(){var c=e.length;return c?1===c?function(c,h){return q(u(h,e[0],g),c)}:function(h,j){for(var l=0,w=0;l<c;l++)w+=q(u(j,e[l],g),h);return w/c}:function(){return 0}}();return l?1===l?function(c){return o(j[0],c)}:"and"===c.options.conjunction?function(c){for(var e,
h=0,w=0;h<l;h++){if(e=o(j[h],c),0>=e)return 0;w+=e}return w/l}:function(c){for(var e=0,h=0;e<l;e++)h+=o(j[e],c);return h/l}:function(){return 0}};c.prototype.getSortFunction=function(c,h){var e,j,l,o,q,r,t,y,B,z;if(l=this,c=l.prepareSearch(c,h),z=!c.query&&h.sort_empty||h.sort,B=function(c,a){return"$score"===c?a.score:u(l.items[a.id],c,h.nesting)},q=[],z)for(e=0,j=z.length;e<j;e++)(c.query||"$score"!==z[e].field)&&q.push(z[e]);if(c.query){for(z=!0,e=0,j=q.length;e<j;e++)if("$score"===q[e].field){z=
!1;break}z&&q.unshift({field:"$score",direction:"desc"})}else for(e=0,j=q.length;e<j;e++)if("$score"===q[e].field){q.splice(e,1);break}for(y=[],e=0,j=q.length;e<j;e++)y.push("desc"===q[e].direction?-1:1);return r=q.length,r?1===r?(o=q[0].field,t=y[0],function(c,a){return t*g(B(o,c),B(o,a))}):function(c,a){var b,d,i;for(b=0;b<r;b++)if(i=q[b].field,d=y[b]*g(B(i,c),B(i,a)))return d;return 0}:null};c.prototype.prepareSearch=function(c,h){if("object"==typeof c)return c;var h=l({},h),e=h.fields,j=h.sort,
g=h.sort_empty;return e&&!r(e)&&(h.fields=[e]),j&&!r(j)&&(h.sort=[j]),g&&!r(g)&&(h.sort_empty=[g]),{options:h,query:(""+(c||"")).toLowerCase(),tokens:this.tokenize(c),total:0,items:[]}};c.prototype.search=function(c,h){var e,j,l,g;return j=this.prepareSearch(c,h),h=j.options,c=j.query,g=h.score||this.getScoreFunction(j),c.length?this.iterator(this.items,function(c,l){e=g(c);(!1===h.filter||0<e)&&j.items.push({score:e,id:l})}):this.iterator(this.items,function(c,e){j.items.push({score:1,id:e})}),l=
this.getSortFunction(j,h),l&&j.items.sort(l),j.total=j.items.length,"number"==typeof h.limit&&(j.items=j.items.slice(0,h.limit)),j};var g=function(c,h){return"number"==typeof c&&"number"==typeof h?c>h?1:c<h?-1:0:(c=t(""+(c||"")),h=t(""+(h||"")),c>h?1:h>c?-1:0)},l=function(c,h){var e,l,g,u;for(e=1,l=arguments.length;e<l;e++)if(u=arguments[e])for(g in u)u.hasOwnProperty(g)&&(c[g]=u[g]);return c},u=function(c,h,e){if(c&&h){if(!e)return c[h];for(h=h.split(".");h.length&&(c=c[h.shift()]););return c}},
r=Array.isArray||"undefined"!=typeof E&&E.isArray||function(c){return"[object Array]"===Object.prototype.toString.call(c)},o={a:"[a\u1e00\u1e01\u0102\u0103\u00c2\u00e2\u01cd\u01ce\u023a\u2c65\u0226\u0227\u1ea0\u1ea1\u00c4\u00e4\u00c0\u00e0\u00c1\u00e1\u0100\u0101\u00c3\u00e3\u00c5\u00e5\u0105\u0104\u00c3\u0105\u0104]",b:"[b\u2422\u03b2\u0392B\u0e3f\ud800\udf01\u16d2]",c:"[c\u0106\u0107\u0108\u0109\u010c\u010d\u010a\u010bC\u0304c\u0304\u00c7\u00e7\u1e08\u1e09\u023b\u023c\u0187\u0188\u0255\u1d04\uff23\uff43]",
d:"[d\u010e\u010f\u1e0a\u1e0b\u1e10\u1e11\u1e0c\u1e0d\u1e12\u1e13\u1e0e\u1e0f\u0110\u0111D\u0326d\u0326\u0189\u0256\u018a\u0257\u018b\u018c\u1d6d\u1d81\u1d91\u0221\u1d05\uff24\uff44\u00f0]",e:"[e\u00c9\u00e9\u00c8\u00e8\u00ca\u00ea\u1e18\u1e19\u011a\u011b\u0114\u0115\u1ebc\u1ebd\u1e1a\u1e1b\u1eba\u1ebb\u0116\u0117\u00cb\u00eb\u0112\u0113\u0228\u0229\u0118\u0119\u1d92\u0246\u0247\u0204\u0205\u1ebe\u1ebf\u1ec0\u1ec1\u1ec4\u1ec5\u1ec2\u1ec3\u1e1c\u1e1d\u1e16\u1e17\u1e14\u1e15\u0206\u0207\u1eb8\u1eb9\u1ec6\u1ec7\u2c78\u1d07\uff25\uff45\u0258\u01dd\u018f\u0190\u03b5]",
f:"[f\u0191\u0192\u1e1e\u1e1f]",g:"[g\u0262\u20b2\u01e4\u01e5\u011c\u011d\u011e\u011f\u0122\u0123\u0193\u0260\u0120\u0121]",h:"[h\u0124\u0125\u0126\u0127\u1e28\u1e29\u1e96\u1e96\u1e24\u1e25\u1e22\u1e23\u0266\u02b0\u01f6\u0195]",i:"[i\u00cd\u00ed\u00cc\u00ec\u012c\u012d\u00ce\u00ee\u01cf\u01d0\u00cf\u00ef\u1e2e\u1e2f\u0128\u0129\u012e\u012f\u012a\u012b\u1ec8\u1ec9\u0208\u0209\u020a\u020b\u1eca\u1ecb\u1e2c\u1e2d\u0197\u0268\u0268\u0306\u1d7b\u1d96\u0130iI\u0131\u026a\uff29\uff49]",j:"[j\u0237\u0134\u0135\u0248\u0249\u029d\u025f\u02b2]",
k:"[k\u0198\u0199\ua740\ua741\u1e30\u1e31\u01e8\u01e9\u1e32\u1e33\u1e34\u1e35\u03ba\u03f0\u20ad]",l:"[l\u0141\u0142\u013d\u013e\u013b\u013c\u0139\u013a\u1e36\u1e37\u1e38\u1e39\u1e3c\u1e3d\u1e3a\u1e3b\u013f\u0140\u023d\u019a\u2c60\u2c61\u2c62\u026b\u026c\u1d85\u026d\u0234\u029f\uff2c\uff4c]",n:"[n\u0143\u0144\u01f8\u01f9\u0147\u0148\u00d1\u00f1\u1e44\u1e45\u0145\u0146\u1e46\u1e47\u1e4a\u1e4b\u1e48\u1e49N\u0308n\u0308\u019d\u0272\u0220\u019e\u1d70\u1d87\u0273\u0235\u0274\uff2e\uff4e\u014a\u014b]",o:"[o\u00d8\u00f8\u00d6\u00f6\u00d3\u00f3\u00d2\u00f2\u00d4\u00f4\u01d1\u01d2\u0150\u0151\u014e\u014f\u022e\u022f\u1ecc\u1ecd\u019f\u0275\u01a0\u01a1\u1ece\u1ecf\u014c\u014d\u00d5\u00f5\u01ea\u01eb\u020c\u020d\u0555\u0585]",
p:"[p\u1e54\u1e55\u1e56\u1e57\u2c63\u1d7d\u01a4\u01a5\u1d71]",q:"[q\ua756\ua757\u02a0\u024a\u024b\ua758\ua759q\u0303]",r:"[r\u0154\u0155\u024c\u024d\u0158\u0159\u0156\u0157\u1e58\u1e59\u0210\u0211\u0212\u0213\u1e5a\u1e5b\u2c64\u027d]",s:"[s\u015a\u015b\u1e60\u1e61\u1e62\u1e63\ua7a8\ua7a9\u015c\u015d\u0160\u0161\u015e\u015f\u0218\u0219S\u0308s\u0308]",t:"[t\u0164\u0165\u1e6a\u1e6b\u0162\u0163\u1e6c\u1e6d\u01ae\u0288\u021a\u021b\u1e70\u1e71\u1e6e\u1e6f\u01ac\u01ad]",u:"[u\u016c\u016d\u0244\u0289\u1ee4\u1ee5\u00dc\u00fc\u00da\u00fa\u00d9\u00f9\u00db\u00fb\u01d3\u01d4\u0170\u0171\u016c\u016d\u01af\u01b0\u1ee6\u1ee7\u016a\u016b\u0168\u0169\u0172\u0173\u0214\u0215\u222a]",
v:"[v\u1e7c\u1e7d\u1e7e\u1e7f\u01b2\u028b\ua75e\ua75f\u2c71\u028b]",w:"[w\u1e82\u1e83\u1e80\u1e81\u0174\u0175\u1e84\u1e85\u1e86\u1e87\u1e88\u1e89]",x:"[x\u1e8c\u1e8d\u1e8a\u1e8b\u03c7]",y:"[y\u00dd\u00fd\u1ef2\u1ef3\u0176\u0177\u0178\u00ff\u1ef8\u1ef9\u1e8e\u1e8f\u1ef4\u1ef5\u024e\u024f\u01b3\u01b4]",z:"[z\u0179\u017a\u1e90\u1e91\u017d\u017e\u017b\u017c\u1e92\u1e93\u1e94\u1e95\u01b5\u01b6]"},t=function(){var c,h,e,l,g="",u={};for(e in o)if(o.hasOwnProperty(e))for(l=o[e].substring(2,o[e].length-1),
g+=l,c=0,h=l.length;c<h;c++)u[l.charAt(c)]=e;var q=RegExp("["+g+"]","g");return function(c){return c.replace(q,function(c){return u[c]}).toLowerCase()}}();return c});(function(c,g){"function"==typeof t&&t.amd?t("microplugin",g):"object"==typeof exports?module.exports=g():c.MicroPlugin=g()})(this,function(){var c={isArray:Array.isArray||function(c){return"[object Array]"===Object.prototype.toString.call(c)}};return{mixin:function(g){g.plugins={};g.prototype.initializePlugins=function(l){var g,r,o=
[];if(this.plugins={names:[],settings:{},requested:{},loaded:{}},c.isArray(l))for(g=0,r=l.length;g<r;g++)"string"==typeof l[g]?o.push(l[g]):(this.plugins.settings[l[g].name]=l[g].options,o.push(l[g].name));else if(l)for(g in l)l.hasOwnProperty(g)&&(this.plugins.settings[g]=l[g],o.push(g));for(;o.length;)this.require(o.shift())};g.prototype.loadPlugin=function(c){var u=this.plugins,r=g.plugins[c];if(!g.plugins.hasOwnProperty(c))throw Error('Unable to find "'+c+'" plugin');u.requested[c]=!0;u.loaded[c]=
r.fn.apply(this,[this.plugins.settings[c]||{}]);u.names.push(c)};g.prototype.require=function(c){var g=this.plugins;if(!this.plugins.loaded.hasOwnProperty(c)){if(g.requested[c])throw Error('Plugin has circular dependency ("'+c+'")');this.loadPlugin(c)}return g.loaded[c]};g.define=function(c,u){g.plugins[c]={name:c,fn:u}}}}});(function(c,g){"function"==typeof t&&t.amd?t("selectize",["jquery","sifter","microplugin"],g):"object"==typeof exports?module.exports=g(D("jquery"),D("sifter"),D("microplugin")):
c.Selectize=g(c.jQuery,c.Sifter,c.MicroPlugin)})(this,function(c,g,l){var u=function(a,b){if("string"!=typeof b||b.length){var d="string"==typeof b?RegExp(b,"i"):b,c=function(a){var b=0;if(3===a.nodeType){var p=a.data.search(d);if(0<=p&&0<a.data.length){var e=a.data.match(d),b=document.createElement("span");b.className="highlight";a=a.splitText(p);p=(a.splitText(e[0].length),a.cloneNode(!0));b.appendChild(p);a.parentNode.replaceChild(b,a);b=1}}else if(1===a.nodeType&&a.childNodes&&!/(script|style)/i.test(a.tagName))for(p=
0;p<a.childNodes.length;++p)p+=c(a.childNodes[p]);return b};return a.each(function(){c(this)})}},r=function(){};r.prototype={on:function(a,b){this._events=this._events||{};this._events[a]=this._events[a]||[];this._events[a].push(b)},off:function(a,b){var d=arguments.length;return 0===d?delete this._events:1===d?delete this._events[a]:(this._events=this._events||{},void(!1!=a in this._events&&this._events[a].splice(this._events[a].indexOf(b),1)))},trigger:function(a){if(this._events=this._events||
{},!1!=a in this._events)for(var b=0;b<this._events[a].length;b++)this._events[a][b].apply(this,Array.prototype.slice.call(arguments,1))}};r.mixin=function(a){for(var b=["on","off","trigger"],d=0;d<b.length;d++)a.prototype[b[d]]=r.prototype[b[d]]};var o=/Mac/.test(navigator.userAgent),t=o?91:17,w=o?18:17,h=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("form").validity,e=function(a){return"undefined"==typeof a||null===a?null:"boolean"==typeof a?a?"1":"0":a+""},j=function(a){return(a+
"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},A={};A.before=function(a,b,d){var c=a[b];a[b]=function(){return d.apply(a,arguments),c.apply(a,arguments)}};A.after=function(a,b,d){var c=a[b];a[b]=function(){var b=c.apply(a,arguments);return d.apply(a,arguments),b}};var C=function(a){var b=!1;return function(){b||(b=!0,a.apply(this,arguments))}},q=function(a,b){var d;return function(){var c=this,k=arguments;window.clearTimeout(d);d=window.setTimeout(function(){a.apply(c,
k)},b)}},D=function(a,b,d){var c,k=a.trigger,m={};a.trigger=function(){var d=arguments[0];return-1===b.indexOf(d)?k.apply(a,arguments):void(m[d]=arguments)};d.apply(a,[]);a.trigger=k;for(c in m)m.hasOwnProperty(c)&&k.apply(a,m[c])},E=function(a,b,d,c){a.on(b,d,function(b){for(var d=b.target;d&&d.parentNode!==a[0];)d=d.parentNode;return b.currentTarget=d,c.apply(this,[b])})},y=function(a){var b={};if("selectionStart"in a)b.start=a.selectionStart,b.length=a.selectionEnd-b.start;else if(document.selection){a.focus();
var d=document.selection.createRange(),c=document.selection.createRange().text.length;d.moveStart("character",-a.value.length);b.start=d.text.length-c;b.length=c}return b},B=function(a){var b=null,d=function(d,k){var m,p,e,h,f,g,j,l;d=d||window.event||{};k=k||{};if(!d.metaKey&&!d.altKey&&(k.force||!1!==a.data("grow"))){m=a.val();d.type&&"keydown"===d.type.toLowerCase()&&(p=d.keyCode,e=97<=p&&122>=p||65<=p&&90>=p||48<=p&&57>=p||32===p,46===p||8===p?(l=y(a[0]),l.length?m=m.substring(0,l.start)+m.substring(l.start+
l.length):8===p&&l.start?m=m.substring(0,l.start-1)+m.substring(l.start+1):46===p&&"undefined"!=typeof l.start&&(m=m.substring(0,l.start)+m.substring(l.start+1))):e&&(g=d.shiftKey,j=String.fromCharCode(d.keyCode),j=g?j.toUpperCase():j.toLowerCase(),m+=j));h=a.attr("placeholder");!m&&h&&(m=h);if(m){m=c("<test>").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).text(m).appendTo("body");p=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"];
g={};if(p)for(e=0,h=p.length;e<h;e++)g[p[e]]=a.css(p[e]);else g=a.css();m.css(g);p=m.width();m=(m.remove(),p)}else m=0;f=m+4;f!==b&&(b=f,a.width(f),a.triggerHandler("resize"))}};a.on("keydown keyup update blur",d);d()},z=function(a){var b=document.createElement("div");return b.appendChild(a.cloneNode(!0)),b.innerHTML},s=function(a,b){var d,i;i=a[0];i.selectize=this;var k=window.getComputedStyle&&window.getComputedStyle(i,null);if(d=k?k.getPropertyValue("direction"):i.currentStyle&&i.currentStyle.direction,
d=d||a.parents("[dir]:first").attr("dir")||"",c.extend(this,{order:0,settings:b,$input:a,tabIndex:a.attr("tabindex")||"",tagType:"select"===i.tagName.toLowerCase()?1:2,rtl:/rtl/i.test(d),eventNS:".selectize"+ ++s.count,highlightedValue:null,isOpen:!1,isDisabled:!1,isRequired:a.is("[required]"),isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!1,isShiftDown:!1,isCmdDown:!1,isCtrlDown:!1,ignoreFocus:!1,ignoreBlur:!1,ignoreHover:!1,hasOptions:!1,currentResults:null,lastValue:"",caretPos:0,
loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:null===b.loadThrottle?this.onSearchChange:q(this.onSearchChange,b.loadThrottle)}),this.sifter=new g(this.options,{diacritics:b.diacritics}),this.settings.options){for(d=0,i=this.settings.options.length;d<i;d++)this.registerOption(this.settings.options[d]);delete this.settings.options}if(this.settings.optgroups){for(d=0,i=this.settings.optgroups.length;d<i;d++)this.registerOptionGroup(this.settings.optgroups[d]);
delete this.settings.optgroups}this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi");"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode);this.initializePlugins(this.settings.plugins);this.setupCallbacks();this.setupTemplates();this.setup()};return r.mixin(s),l.mixin(s),c.extend(s.prototype,{setup:function(){var a,b,d,i,k,m,e,g,l,f=this,j=f.settings,x=f.eventNS,F=c(window),q=c(document),v=f.$input;if(e=f.settings.mode,
g=v.attr("class")||"",a=c("<div>").addClass(j.wrapperClass).addClass(g).addClass(e),b=c("<div>").addClass(j.inputClass).addClass("items").appendTo(a),d=c('<input type="text" autocomplete="off" />').appendTo(b).attr("tabindex",v.is(":disabled")?"-1":f.tabIndex),m=c(j.dropdownParent||a),i=c("<div>").addClass(j.dropdownClass).addClass(e).hide().appendTo(m),k=c("<div>").addClass(j.dropdownContentClass).appendTo(i),f.settings.copyClassesToDropdown&&i.addClass(g),a.css({width:v[0].style.width}),f.plugins.names.length&&
(l="plugin-"+f.plugins.names.join(" plugin-"),a.addClass(l),i.addClass(l)),(null===j.maxItems||1<j.maxItems)&&1===f.tagType&&v.attr("multiple","multiple"),f.settings.placeholder&&d.attr("placeholder",j.placeholder),!f.settings.splitOn&&f.settings.delimiter)m=f.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),f.settings.splitOn=RegExp("\\s*"+m+"+\\s*");v.attr("autocorrect")&&d.attr("autocorrect",v.attr("autocorrect"));v.attr("autocapitalize")&&d.attr("autocapitalize",v.attr("autocapitalize"));
f.$wrapper=a;f.$control=b;f.$control_input=d;f.$dropdown=i;f.$dropdown_content=k;i.on("mouseenter","[data-selectable]",function(){return f.onOptionHover.apply(f,arguments)});i.on("mousedown click","[data-selectable]",function(){return f.onOptionSelect.apply(f,arguments)});E(b,"mousedown","*:not(input)",function(){return f.onItemSelect.apply(f,arguments)});B(d);b.on({mousedown:function(){return f.onMouseDown.apply(f,arguments)},click:function(){return f.onClick.apply(f,arguments)}});d.on({mousedown:function(a){a.stopPropagation()},
keydown:function(){return f.onKeyDown.apply(f,arguments)},keyup:function(){return f.onKeyUp.apply(f,arguments)},keypress:function(){return f.onKeyPress.apply(f,arguments)},resize:function(){f.positionDropdown.apply(f,[])},blur:function(){return f.onBlur.apply(f,arguments)},focus:function(){return f.ignoreBlur=!1,f.onFocus.apply(f,arguments)},paste:function(){return f.onPaste.apply(f,arguments)}});q.on("keydown"+x,function(a){f.isCmdDown=a[o?"metaKey":"ctrlKey"];f.isCtrlDown=a[o?"altKey":"ctrlKey"];
f.isShiftDown=a.shiftKey});q.on("keyup"+x,function(a){a.keyCode===w&&(f.isCtrlDown=!1);16===a.keyCode&&(f.isShiftDown=!1);a.keyCode===t&&(f.isCmdDown=!1)});q.on("mousedown"+x,function(a){if(f.isFocused){if(a.target===f.$dropdown[0]||a.target.parentNode===f.$dropdown[0])return!1;f.$control.has(a.target).length||a.target===f.$control[0]||f.blur(a.target)}});F.on(["scroll"+x,"resize"+x].join(" "),function(){f.isOpen&&f.positionDropdown.apply(f,arguments)});F.on("mousemove"+x,function(){f.ignoreHover=
!1});this.revertSettings={$children:v.children().detach(),tabindex:v.attr("tabindex")};v.attr("tabindex",-1).hide().after(f.$wrapper);c.isArray(j.items)&&(f.setValue(j.items),delete j.items);h&&v.on("invalid"+x,function(a){a.preventDefault();f.isInvalid=!0;f.refreshState()});f.updateOriginalInput();f.refreshItems();f.refreshState();f.updatePlaceholder();f.isSetup=!0;v.is(":disabled")&&f.disable();f.on("change",this.onChange);v.data("selectize",f);v.addClass("selectized");f.trigger("initialize");!0===
j.preload&&f.onSearchChange("")},setupTemplates:function(){var a=this.settings.labelField,b=this.settings.optgroupLabelField;this.settings.render=c.extend({},{optgroup:function(a){return'<div class="optgroup">'+a.html+"</div>"},optgroup_header:function(a,c){return'<div class="optgroup-header">'+c(a[b])+"</div>"},option:function(b,c){return'<div class="option">'+c(b[a])+"</div>"},item:function(b,c){return'<div class="item">'+c(b[a])+"</div>"},option_create:function(a,b){return'<div class="create">Add <strong>'+
b(a.input)+"</strong>&hellip;</div>"}},this.settings.render)},setupCallbacks:function(){var a,b,d={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(a in d)d.hasOwnProperty(a)&&(b=this.settings[d[a]],b&&this.on(a,b))},onClick:function(a){this.isFocused||(this.focus(),a.preventDefault())},onMouseDown:function(a){var b=this,d=a.isDefaultPrevented();c(a.target);if(b.isFocused){if(a.target!==b.$control_input[0])return"single"===b.settings.mode?b.isOpen?b.close():b.open():d||b.setActiveItem(null),!1}else d||window.setTimeout(function(){b.focus()},0)},onChange:function(){this.$input.trigger("change")},onPaste:function(a){var b=this;
b.isFull()||b.isInputHidden||b.isLocked?a.preventDefault():b.settings.splitOn&&setTimeout(function(){for(var a=c.trim(b.$control_input.val()||"").split(b.settings.splitOn),i=0,k=a.length;i<k;i++)b.createItem(a[i])},0)},onKeyPress:function(a){if(this.isLocked)return a&&a.preventDefault();var b=String.fromCharCode(a.keyCode||a.which);return this.settings.create&&"multi"===this.settings.mode&&b===this.settings.delimiter?(this.createItem(),a.preventDefault(),!1):void 0},onKeyDown:function(a){if(this.isLocked)return void(9!==
a.keyCode&&a.preventDefault());switch(a.keyCode){case 65:if(this.isCmdDown)return void this.selectAll();break;case 27:return void(this.isOpen&&(a.preventDefault(),a.stopPropagation(),this.close()));case 78:if(!a.ctrlKey||a.altKey)break;case 40:if(!this.isOpen&&this.hasOptions)this.open();else if(this.$activeOption){this.ignoreHover=!0;var b=this.getAdjacentOption(this.$activeOption,1);b.length&&this.setActiveOption(b,!0,!0)}return void a.preventDefault();case 80:if(!a.ctrlKey||a.altKey)break;case 38:if(this.$activeOption)this.ignoreHover=
!0,b=this.getAdjacentOption(this.$activeOption,-1),b.length&&this.setActiveOption(b,!0,!0);return void a.preventDefault();case 13:return void(this.isOpen&&this.$activeOption&&(this.onOptionSelect({currentTarget:this.$activeOption}),a.preventDefault()));case 37:return void this.advanceSelection(-1,a);case 39:return void this.advanceSelection(1,a);case 9:return this.settings.selectOnTab&&this.isOpen&&this.$activeOption&&(this.onOptionSelect({currentTarget:this.$activeOption}),this.isFull()||a.preventDefault()),
void(this.settings.create&&this.createItem()&&a.preventDefault());case 8:case 46:return void this.deleteSelection(a)}return!this.isFull()&&!this.isInputHidden||(o?a.metaKey:a.ctrlKey)?void 0:void a.preventDefault()},onKeyUp:function(a){if(this.isLocked)return a&&a.preventDefault();a=this.$control_input.val()||"";this.lastValue!==a&&(this.lastValue=a,this.onSearchChange(a),this.refreshOptions(),this.trigger("type",a))},onSearchChange:function(a){var b=this,d=b.settings.load;d&&(b.loadedSearches.hasOwnProperty(a)||
(b.loadedSearches[a]=!0,b.load(function(c){d.apply(b,[a,c])})))},onFocus:function(a){var b=this.isFocused;return this.isDisabled?(this.blur(),a&&a.preventDefault(),!1):void(this.ignoreFocus||(this.isFocused=!0,"focus"===this.settings.preload&&this.onSearchChange(""),b||this.trigger("focus"),this.$activeItems.length||(this.showInput(),this.setActiveItem(null),this.refreshOptions(!!this.settings.openOnFocus)),this.refreshState()))},onBlur:function(a,b){var d=this;if(d.isFocused&&(d.isFocused=!1,!d.ignoreFocus)){if(!d.ignoreBlur&&
document.activeElement===d.$dropdown_content[0])return d.ignoreBlur=!0,void d.onFocus(a);var c=function(){d.close();d.setTextboxValue("");d.setActiveItem(null);d.setActiveOption(null);d.setCaret(d.items.length);d.refreshState();b&&b.focus();d.ignoreFocus=!1;d.trigger("blur")};d.ignoreFocus=!0;d.settings.create&&d.settings.createOnBlur?d.createItem(null,!1,c):c()}},onOptionHover:function(a){this.ignoreHover||this.setActiveOption(a.currentTarget,!1)},onOptionSelect:function(a){var b,d,i=this;a.preventDefault&&
(a.preventDefault(),a.stopPropagation());d=c(a.currentTarget);d.hasClass("create")?i.createItem(null,function(){i.settings.closeAfterSelect&&i.close()}):(b=d.attr("data-value"),"undefined"!=typeof b&&(i.lastQuery=null,i.setTextboxValue(""),i.addItem(b),i.settings.closeAfterSelect?i.close():!i.settings.hideSelected&&a.type&&/mouse/.test(a.type)&&i.setActiveOption(i.getOption(b))))},onItemSelect:function(a){this.isLocked||"multi"===this.settings.mode&&(a.preventDefault(),this.setActiveItem(a.currentTarget,
a))},load:function(a){var b=this,d=b.$wrapper.addClass(b.settings.loadingClass);b.loading++;a.apply(b,[function(a){b.loading=Math.max(b.loading-1,0);a&&a.length&&(b.addOption(a),b.refreshOptions(b.isFocused&&!b.isInputHidden));b.loading||d.removeClass(b.settings.loadingClass);b.trigger("load",a)}])},setTextboxValue:function(a){var b=this.$control_input;b.val()!==a&&(b.val(a).triggerHandler("update"),this.lastValue=a)},getValue:function(){return 1===this.tagType&&this.$input.attr("multiple")?this.items:
this.items.join(this.settings.delimiter)},setValue:function(a,b){D(this,b?[]:["change"],function(){this.clear(b);this.addItems(a,b)})},setActiveItem:function(a,b){var d,i,k,m,e,h,g;if("single"!==this.settings.mode){if(a=c(a),!a.length)return c(this.$activeItems).removeClass("active"),this.$activeItems=[],void(this.isFocused&&this.showInput());if(d=b&&b.type.toLowerCase(),"mousedown"===d&&this.isShiftDown&&this.$activeItems.length){for(g=this.$control.children(".active:last"),k=Array.prototype.indexOf.apply(this.$control[0].childNodes,
[g[0]]),m=Array.prototype.indexOf.apply(this.$control[0].childNodes,[a[0]]),k>m&&(h=k,k=m,m=h),d=k;d<=m;d++)e=this.$control[0].childNodes[d],-1===this.$activeItems.indexOf(e)&&(c(e).addClass("active"),this.$activeItems.push(e));b.preventDefault()}else"mousedown"===d&&this.isCtrlDown||"keydown"===d&&this.isShiftDown?a.hasClass("active")?(i=this.$activeItems.indexOf(a[0]),this.$activeItems.splice(i,1),a.removeClass("active")):this.$activeItems.push(a.addClass("active")[0]):(c(this.$activeItems).removeClass("active"),
this.$activeItems=[a.addClass("active")[0]]);this.hideInput();this.isFocused||this.focus()}},setActiveOption:function(a,b,d){var i,k,m,e;this.$activeOption&&this.$activeOption.removeClass("active");this.$activeOption=null;a=c(a);a.length&&(this.$activeOption=a.addClass("active"),!b&&"undefined"!=typeof b||(i=this.$dropdown_content.height(),k=this.$activeOption.outerHeight(!0),b=this.$dropdown_content.scrollTop()||0,m=this.$activeOption.offset().top-this.$dropdown_content.offset().top+b,e=m-i+k,m+
k>i+b?this.$dropdown_content.stop().animate({scrollTop:e},d?this.settings.scrollDuration:0):m<b&&this.$dropdown_content.stop().animate({scrollTop:m},d?this.settings.scrollDuration:0)))},selectAll:function(){"single"!==this.settings.mode&&(this.$activeItems=Array.prototype.slice.apply(this.$control.children(":not(input)").addClass("active")),this.$activeItems.length&&(this.hideInput(),this.close()),this.focus())},hideInput:function(){this.setTextboxValue("");this.$control_input.css({opacity:0,position:"absolute",
left:this.rtl?1E4:-1E4});this.isInputHidden=!0},showInput:function(){this.$control_input.css({opacity:1,position:"relative",left:0});this.isInputHidden=!1},focus:function(){var a=this;a.isDisabled||(a.ignoreFocus=!0,a.$control_input[0].focus(),window.setTimeout(function(){a.ignoreFocus=!1;a.onFocus()},0))},blur:function(a){this.$control_input[0].blur();this.onBlur(null,a)},getScoreFunction:function(a){return this.sifter.getScoreFunction(a,this.getSearchOptions())},getSearchOptions:function(){var a=
this.settings,b=a.sortField;return"string"==typeof b&&(b=[{field:b}]),{fields:a.searchField,conjunction:a.searchConjunction,sort:b}},search:function(a){var b,d,i=this.settings,k=this.getSearchOptions();if(i.score&&(d=this.settings.score.apply(this,[a]),"function"!=typeof d))throw Error('Selectize "score" setting must be a function that returns a function');if(a!==this.lastQuery?(this.lastQuery=a,b=this.sifter.search(a,c.extend(k,{score:d})),this.currentResults=b):b=c.extend(!0,{},this.currentResults),
i.hideSelected)for(a=b.items.length-1;0<=a;a--)-1!==this.items.indexOf(e(b.items[a].id))&&b.items.splice(a,1);return b},refreshOptions:function(a){var b,d,i,k,m,h,g,j,f,l,x,o,q,v,r;"undefined"==typeof a&&(a=!0);var n=this,t=c.trim(n.$control_input.val()),s=n.search(t),w=n.$dropdown_content,y=n.$activeOption&&e(n.$activeOption.attr("data-value"));for(k=s.items.length,"number"==typeof n.settings.maxOptions&&(k=Math.min(k,n.settings.maxOptions)),m={},h=[],b=0;b<k;b++)for(g=n.options[s.items[b].id],j=
n.render("option",g),f=g[n.settings.optgroupField]||"",l=c.isArray(f)?f:[f],d=0,i=l&&l.length;d<i;d++)f=l[d],n.optgroups.hasOwnProperty(f)||(f=""),m.hasOwnProperty(f)||(m[f]=document.createDocumentFragment(),h.push(f)),m[f].appendChild(j);for(this.settings.lockOptgroupOrder&&h.sort(function(a,b){return(n.optgroups[a].$order||0)-(n.optgroups[b].$order||0)}),d=document.createDocumentFragment(),b=0,k=h.length;b<k;b++)f=h[b],n.optgroups.hasOwnProperty(f)&&m[f].childNodes.length?(x=document.createDocumentFragment(),
x.appendChild(n.render("optgroup_header",n.optgroups[f])),x.appendChild(m[f]),d.appendChild(n.render("optgroup",c.extend({},n.optgroups[f],{html:z(x),dom:x})))):d.appendChild(m[f]);if(w.html(d),n.settings.highlight&&s.query.length&&s.tokens.length)for(b=0,k=s.tokens.length;b<k;b++)u(w,s.tokens[b].regex);if(!n.settings.hideSelected)for(b=0,k=n.items.length;b<k;b++)n.getOption(n.items[b]).addClass("selected");o=n.canCreate(t);o&&(w.prepend(n.render("option_create",{input:t})),r=c(w[0].childNodes[0]));
n.hasOptions=0<s.items.length||o;n.hasOptions?(0<s.items.length?(v=y&&n.getOption(y),v&&v.length?q=v:"single"===n.settings.mode&&n.items.length&&(q=n.getOption(n.items[0])),q&&q.length||(q=r&&!n.settings.addPrecedence?n.getAdjacentOption(r,1):w.find("[data-selectable]:first"))):q=r,n.setActiveOption(q),a&&!n.isOpen&&n.open()):(n.setActiveOption(null),a&&n.isOpen&&n.close())},addOption:function(a){var b,d;if(c.isArray(a))for(b=0,d=a.length;b<d;b++)this.addOption(a[b]);else(b=this.registerOption(a))&&
(this.userOptions[b]=!0,this.lastQuery=null,this.trigger("option_add",b,a))},registerOption:function(a){var b=e(a[this.settings.valueField]);return"undefined"!=typeof b&&null!==b&&!this.options.hasOwnProperty(b)&&(a.$order=a.$order||++this.order,this.options[b]=a,b)},registerOptionGroup:function(a){var b=e(a[this.settings.optgroupValueField]);return!!b&&(a.$order=a.$order||++this.order,this.optgroups[b]=a,b)},addOptionGroup:function(a,b){b[this.settings.optgroupValueField]=a;(a=this.registerOptionGroup(b))&&
this.trigger("optgroup_add",a,b)},removeOptionGroup:function(a){this.optgroups.hasOwnProperty(a)&&(delete this.optgroups[a],this.renderCache={},this.trigger("optgroup_remove",a))},clearOptionGroups:function(){this.optgroups={};this.renderCache={};this.trigger("optgroup_clear")},updateOption:function(a,b){var d,i,k,m,h,g,j;if(a=e(a),k=e(b[this.settings.valueField]),null!==a&&this.options.hasOwnProperty(a)){if("string"!=typeof k)throw Error("Value must be set in option data");j=this.options[a].$order;
k!==a&&(delete this.options[a],m=this.items.indexOf(a),-1!==m&&this.items.splice(m,1,k));b.$order=b.$order||j;this.options[k]=b;h=this.renderCache.item;g=this.renderCache.option;h&&(delete h[a],delete h[k]);g&&(delete g[a],delete g[k]);-1!==this.items.indexOf(k)&&(d=this.getItem(a),i=c(this.render("item",b)),d.hasClass("active")&&i.addClass("active"),d.replaceWith(i));this.lastQuery=null;this.isOpen&&this.refreshOptions(!1)}},removeOption:function(a,b){var a=e(a),d=this.renderCache.item,c=this.renderCache.option;
d&&delete d[a];c&&delete c[a];delete this.userOptions[a];delete this.options[a];this.lastQuery=null;this.trigger("option_remove",a);this.removeItem(a,b)},clearOptions:function(){this.loadedSearches={};this.userOptions={};this.renderCache={};this.options=this.sifter.items={};this.lastQuery=null;this.trigger("option_clear");this.clear()},getOption:function(a){return this.getElementWithValue(a,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(a,b){var d=this.$dropdown.find("[data-selectable]"),
i=d.index(a)+b;return 0<=i&&i<d.length?d.eq(i):c()},getElementWithValue:function(a,b){if(a=e(a),"undefined"!=typeof a&&null!==a)for(var d=0,i=b.length;d<i;d++)if(b[d].getAttribute("data-value")===a)return c(b[d]);return c()},getItem:function(a){return this.getElementWithValue(a,this.$control.children())},addItems:function(a,b){for(var d=c.isArray(a)?a:[a],i=0,k=d.length;i<k;i++)this.isPending=i<k-1,this.addItem(d[i],b)},addItem:function(a,b){D(this,b?[]:["change"],function(){var d,i,k,m,h,g=this.settings.mode;
return a=e(a),-1!==this.items.indexOf(a)?void("single"===g&&this.close()):void(this.options.hasOwnProperty(a)&&("single"===g&&this.clear(b),"multi"===g&&this.isFull()||(d=c(this.render("item",this.options[a])),h=this.isFull(),this.items.splice(this.caretPos,0,a),this.insertAtCaret(d),(!this.isPending||!h&&this.isFull())&&this.refreshState(),this.isSetup&&(k=this.$dropdown_content.find("[data-selectable]"),this.isPending||(i=this.getOption(a),m=this.getAdjacentOption(i,1).attr("data-value"),this.refreshOptions(this.isFocused&&
"single"!==g),m&&this.setActiveOption(this.getOption(m))),!k.length||this.isFull()?this.close():this.positionDropdown(),this.updatePlaceholder(),this.trigger("item_add",a,d),this.updateOriginalInput({silent:b})))))})},removeItem:function(a,b){var d,i,k;d=a instanceof c?a:this.getItem(a);a=e(d.attr("data-value"));i=this.items.indexOf(a);-1!==i&&(d.remove(),d.hasClass("active")&&(k=this.$activeItems.indexOf(d[0]),this.$activeItems.splice(k,1)),this.items.splice(i,1),this.lastQuery=null,!this.settings.persist&&
this.userOptions.hasOwnProperty(a)&&this.removeOption(a,b),i<this.caretPos&&this.setCaret(this.caretPos-1),this.refreshState(),this.updatePlaceholder(),this.updateOriginalInput({silent:b}),this.positionDropdown(),this.trigger("item_remove",a,d))},createItem:function(a,b){var d=this,i=d.caretPos,a=a||c.trim(d.$control_input.val()||""),k=arguments[arguments.length-1];if("function"!=typeof k&&(k=function(){}),"boolean"!=typeof b&&(b=!0),!d.canCreate(a))return k(),!1;d.lock();var m="function"==typeof d.settings.create?
this.settings.create:function(a){var b={};return b[d.settings.labelField]=a,b[d.settings.valueField]=a,b},h=C(function(a){if(d.unlock(),!a||"object"!=typeof a)return k();var c=e(a[d.settings.valueField]);return"string"!=typeof c?k():(d.setTextboxValue(""),d.addOption(a),d.setCaret(i),d.addItem(c),d.refreshOptions(b&&"single"!==d.settings.mode),void k(a))}),m=m.apply(this,[a,h]);return"undefined"!=typeof m&&h(m),!0},refreshItems:function(){this.lastQuery=null;this.isSetup&&this.addItem(this.items);
this.refreshState();this.updateOriginalInput()},refreshState:function(){this.isRequired&&(this.items.length&&(this.isInvalid=!1),this.$control_input.prop("required",void 0));this.refreshClasses()},refreshClasses:function(){var a=this.isFull(),b=this.isLocked;this.$wrapper.toggleClass("rtl",this.rtl);this.$control.toggleClass("focus",this.isFocused).toggleClass("disabled",this.isDisabled).toggleClass("required",this.isRequired).toggleClass("invalid",this.isInvalid).toggleClass("locked",b).toggleClass("full",
a).toggleClass("not-full",!a).toggleClass("input-active",this.isFocused&&!this.isInputHidden).toggleClass("dropdown-active",this.isOpen).toggleClass("has-options",!c.isEmptyObject(this.options)).toggleClass("has-items",0<this.items.length);this.$control_input.data("grow",!a&&!b)},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(a){var b,d,c,k;if(a=a||{},1===this.tagType){for(c=[],b=0,d=this.items.length;b<d;b++)k=this.options[this.items[b]][this.settings.labelField]||
"",c.push('<option value="'+j(this.items[b])+'" selected="selected">'+j(k)+"</option>");c.length||this.$input.attr("multiple")||c.push('<option value="" selected="selected"></option>');this.$input.html(c.join(""))}else this.$input.val(this.getValue()),this.$input.attr("value",this.$input.val());this.isSetup&&(a.silent||this.trigger("change",this.$input.val()))},updatePlaceholder:function(){if(this.settings.placeholder){var a=this.$control_input;this.items.length?a.removeAttr("placeholder"):a.attr("placeholder",
this.settings.placeholder);a.triggerHandler("update",{force:!0})}},open:function(){this.isLocked||this.isOpen||"multi"===this.settings.mode&&this.isFull()||(this.focus(),this.isOpen=!0,this.refreshState(),this.$dropdown.css({visibility:"hidden",display:"block"}),this.positionDropdown(),this.$dropdown.css({visibility:"visible"}),this.trigger("dropdown_open",this.$dropdown))},close:function(){var a=this.isOpen;"single"===this.settings.mode&&this.items.length&&this.hideInput();this.isOpen=!1;this.$dropdown.hide();
this.setActiveOption(null);this.refreshState();a&&this.trigger("dropdown_close",this.$dropdown)},positionDropdown:function(){var a=this.$control,b="body"===this.settings.dropdownParent?a.offset():a.position();b.top+=a.outerHeight(!0);this.$dropdown.css({width:a.outerWidth(),top:b.top,left:b.left})},clear:function(a){this.items.length&&(this.$control.children(":not(input)").remove(),this.items=[],this.lastQuery=null,this.setCaret(0),this.setActiveItem(null),this.updatePlaceholder(),this.updateOriginalInput({silent:a}),
this.refreshState(),this.showInput(),this.trigger("clear"))},insertAtCaret:function(a){var b=Math.min(this.caretPos,this.items.length);0===b?this.$control.prepend(a):c(this.$control[0].childNodes[b]).before(a);this.setCaret(b+1)},deleteSelection:function(a){var b,d,i,k,e,h,g;if(b=a&&8===a.keyCode?-1:1,d=y(this.$control_input[0]),this.$activeOption&&!this.settings.hideSelected&&(e=this.getAdjacentOption(this.$activeOption,-1).attr("data-value")),i=[],this.$activeItems.length){for(g=this.$control.children(".active:"+
(0<b?"last":"first")),k=this.$control.children(":not(input)").index(g),0<b&&k++,b=0,d=this.$activeItems.length;b<d;b++)i.push(c(this.$activeItems[b]).attr("data-value"));a&&(a.preventDefault(),a.stopPropagation())}else(this.isFocused||"single"===this.settings.mode)&&this.items.length&&(0>b&&0===d.start&&0===d.length?i.push(this.items[this.caretPos-1]):0<b&&d.start===this.$control_input.val().length&&i.push(this.items[this.caretPos]));if(!i.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete.apply(this,
[i]))return!1;for("undefined"!=typeof k&&this.setCaret(k);i.length;)this.removeItem(i.pop());return this.showInput(),this.positionDropdown(),this.refreshOptions(!0),e&&(h=this.getOption(e),h.length&&this.setActiveOption(h)),!0},advanceSelection:function(a,b){var d,c,k,e,h,g;0!==a&&(this.rtl&&(a*=-1),d=0<a?"last":"first",c=y(this.$control_input[0]),this.isFocused&&!this.isInputHidden?(e=this.$control_input.val().length,h=0>a?0===c.start&&0===c.length:c.start===e,h&&!e&&this.advanceCaret(a,b)):(g=this.$control.children(".active:"+
d),g.length&&(k=this.$control.children(":not(input)").index(g),this.setActiveItem(null),this.setCaret(0<a?k+1:k))))},advanceCaret:function(a,b){var d,c;0!==a&&(d=0<a?"next":"prev",this.isShiftDown?(c=this.$control_input[d](),c.length&&(this.hideInput(),this.setActiveItem(c),b&&b.preventDefault())):this.setCaret(this.caretPos+a))},setCaret:function(a){if(a="single"===this.settings.mode?this.items.length:Math.max(0,Math.min(this.items.length,a)),!this.isPending){var b,d,i,k;for(i=this.$control.children(":not(input)"),
b=0,d=i.length;b<d;b++)k=c(i[b]).detach(),b<a?this.$control_input.before(k):this.$control.append(k)}this.caretPos=a},lock:function(){this.close();this.isLocked=!0;this.refreshState()},unlock:function(){this.isLocked=!1;this.refreshState()},disable:function(){this.$input.prop("disabled",!0);this.$control_input.prop("disabled",!0).prop("tabindex",-1);this.isDisabled=!0;this.lock()},enable:function(){this.$input.prop("disabled",!1);this.$control_input.prop("disabled",!1).prop("tabindex",this.tabIndex);
this.isDisabled=!1;this.unlock()},destroy:function(){var a=this.eventNS,b=this.revertSettings;this.trigger("destroy");this.off();this.$wrapper.remove();this.$dropdown.remove();this.$input.html("").append(b.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:b.tabindex}).show();this.$control_input.removeData("grow");this.$input.removeData("selectize");c(window).off(a);c(document).off(a);c(document.body).off(a);delete this.$input[0].selectize},render:function(a,b){var d,i,k="",
h=!1;return"option"!==a&&"item"!==a||(d=e(b[this.settings.valueField]),h=!!d),h&&("undefined"!=typeof this.renderCache[a]||(this.renderCache[a]={}),this.renderCache[a].hasOwnProperty(d))?this.renderCache[a][d]:(k=c(this.settings.render[a].apply(this,[b,j])),"option"===a||"option_create"===a?k.attr("data-selectable",""):"optgroup"===a&&(i=b[this.settings.optgroupValueField]||"",k.attr("data-group",i)),"option"!==a&&"item"!==a||k.attr("data-value",d||""),h&&(this.renderCache[a][d]=k[0]),k[0])},clearCache:function(a){"undefined"==
typeof a?this.renderCache={}:delete this.renderCache[a]},canCreate:function(a){if(!this.settings.create)return!1;var b=this.settings.createFilter;return a.length&&("function"!=typeof b||b.apply(this,[a]))&&("string"!=typeof b||RegExp(b).test(a))&&(!(b instanceof RegExp)||b.test(a))}}),s.count=0,s.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1E3,maxItems:null,hideSelected:null,
addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:"data-data",optgroupField:"optgroup",valueField:"value",labelField:"text",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"selectize-control",inputClass:"selectize-input",dropdownClass:"selectize-dropdown",dropdownContentClass:"selectize-dropdown-content",
dropdownParent:null,copyClassesToDropdown:!0,render:{}},c.fn.selectize=function(a){var b=c.fn.selectize.defaults,d=c.extend({},b,a),i=d.dataAttr,k=d.labelField,h=d.valueField,g=d.optgroupField,j=d.optgroupLabelField,l=d.optgroupValueField,f=function(a,b){var f,q,o,r,n=b.options,s={},t=function(a){a=i&&a.attr(i);return"string"==typeof a&&a.length?JSON.parse(a):null},u=function(a,f){var a=c(a),i=e(a.val());if(i||d.allowEmptyOption)if(s.hasOwnProperty(i)){if(f){var j=s[i][g];j?c.isArray(j)?j.push(f):
s[i][g]=[j,f]:s[i][g]=f}}else j=t(a)||{},j[k]=j[k]||a.text(),j[h]=j[h]||i,j[g]=j[g]||f,s[i]=j,n.push(j),a.is(":selected")&&b.items.push(i)},w=function(a){var d,i,f,k,e;for(a=c(a),f=a.attr("label"),f&&(k=t(a)||{},k[j]=f,k[l]=f,b.optgroups.push(k)),e=c("option",a),d=0,i=e.length;d<i;d++)u(e[d],f)};for(b.maxItems=a.attr("multiple")?null:1,r=a.children(),f=0,q=r.length;f<q;f++)o=r[f].tagName.toLowerCase(),"optgroup"===o?w(r[f]):"option"===o&&u(r[f])};return this.each(function(){if(!this.selectize){var e=
c(this),g=this.tagName.toLowerCase(),j=e.attr("placeholder")||e.attr("data-placeholder");j||d.allowEmptyOption||(j=e.children('option[value=""]').text());j={placeholder:j,options:[],optgroups:[],items:[]};if("select"===g)f(e,j);else{var l,p,o;if(g=e.attr(i))for(j.options=JSON.parse(g),g=0,l=j.options.length;g<l;g++)j.items.push(j.options[g][h]);else if(g=c.trim(e.val()||""),d.allowEmptyOption||g.length){for(p=g.split(d.delimiter),g=0,l=p.length;g<l;g++)o={},o[k]=p[g],o[h]=p[g],j.options.push(o);j.items=
p}}new s(e,c.extend(!0,{},b,j,a))}})},c.fn.selectize.defaults=s.defaults,c.fn.selectize.support={validity:h},s.define("drag_drop",function(){if(!c.fn.sortable)throw Error('The "drag_drop" plugin requires jQuery UI "sortable".');if("multi"===this.settings.mode){var a=this;a.lock=function(){var b=a.lock;return function(){var d=a.$control.data("sortable");return d&&d.disable(),b.apply(a,arguments)}}();a.unlock=function(){var b=a.unlock;return function(){var d=a.$control.data("sortable");return d&&d.enable(),
b.apply(a,arguments)}}();a.setup=function(){var b=a.setup;return function(){b.apply(this,arguments);var d=a.$control.sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:a.isLocked,start:function(a,b){b.placeholder.css("width",b.helper.css("width"));d.css({overflow:"visible"})},stop:function(){d.css({overflow:"hidden"});var b=a.$activeItems?a.$activeItems.slice():null,e=[];d.children("[data-value]").each(function(){e.push(c(this).attr("data-value"))});a.setValue(e);a.setActiveItem(b)}})}}()}}),
s.define("dropdown_header",function(a){var b=this;a=c.extend({title:"Untitled",headerClass:"selectize-dropdown-header",titleRowClass:"selectize-dropdown-header-title",labelClass:"selectize-dropdown-header-label",closeClass:"selectize-dropdown-header-close",html:function(a){return'<div class="'+a.headerClass+'"><div class="'+a.titleRowClass+'"><span class="'+a.labelClass+'">'+a.title+'</span><a href="javascript:void(0)" class="'+a.closeClass+'">&times;</a></div></div>'}},a);b.setup=function(){var d=
b.setup;return function(){d.apply(b,arguments);b.$dropdown_header=c(a.html(a));b.$dropdown.prepend(b.$dropdown_header)}}()}),s.define("optgroup_columns",function(a){var b=this;a=c.extend({equalizeWidth:!0,equalizeHeight:!0},a);this.getAdjacentOption=function(a,b){var d=a.closest("[data-group]").find("[data-selectable]"),e=d.index(a)+b;return 0<=e&&e<d.length?d.eq(e):c()};this.onKeyDown=function(){var a=b.onKeyDown;return function(d){var c,e,i,f;return!this.isOpen||37!==d.keyCode&&39!==d.keyCode?a.apply(this,
arguments):(b.ignoreHover=!0,f=this.$activeOption.closest("[data-group]"),c=f.find("[data-selectable]").index(this.$activeOption),f=37===d.keyCode?f.prev("[data-group]"):f.next("[data-group]"),i=f.find("[data-selectable]"),e=i.eq(Math.min(i.length-1,c)),void(e.length&&this.setActiveOption(e)))}}();var d=function(){var a,b=d.width,c=document;return"undefined"==typeof b&&(a=c.createElement("div"),a.innerHTML='<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>',
a=a.firstChild,c.body.appendChild(a),b=d.width=a.offsetWidth-a.clientWidth,c.body.removeChild(a)),b},e=function(){var e,i,g,h,j,f,l;if(l=c("[data-group]",b.$dropdown_content),i=l.length,i&&b.$dropdown_content.width()){if(a.equalizeHeight){for(g=0,e=0;e<i;e++)g=Math.max(g,l.eq(e).height());l.css({height:g})}a.equalizeWidth&&(f=b.$dropdown_content.innerWidth()-d(),h=Math.round(f/i),l.css({width:h}),1<i&&(j=f-h*(i-1),l.eq(i-1).css({width:j})))}};(a.equalizeHeight||a.equalizeWidth)&&(A.after(this,"positionDropdown",
e),A.after(this,"refreshOptions",e))}),s.define("remove_button",function(a){var a=c.extend({label:"&times;",title:"Remove",className:"remove",append:!0},a),b=function(a,b){var e='<a href="javascript:void(0)" class="'+b.className+'" tabindex="-1" title="'+j(b.title)+'">'+b.label+"</a>";a.setup=function(){var g=a.setup;return function(){if(b.append){var h=a.settings.render.item;a.settings.render.item=function(b){var c=h.apply(a,arguments),f=c.search(/(<\/[^>]+>\s*)$/);return c.substring(0,f)+e+c.substring(f)}}g.apply(a,
arguments);a.$control.on("click","."+b.className,function(b){if(b.preventDefault(),!a.isLocked)b=c(b.currentTarget).parent(),a.setActiveItem(b),a.deleteSelection()&&a.setCaret(a.items.length)})}}()};return"single"===this.settings.mode?void function(a,b){b.className="remove-single";var e='<a href="javascript:void(0)" class="'+b.className+'" tabindex="-1" title="'+j(b.title)+'">'+b.label+"</a>";a.setup=function(){var g=a.setup;return function(){if(b.append){var h=c(a.$input.context).attr("id"),j=(c("#"+
h),a.settings.render.item);a.settings.render.item=function(b){return j.apply(a,arguments)+e}}g.apply(a,arguments);a.$control.on("click","."+b.className,function(b){b.preventDefault();a.isLocked||a.clear()})}}()}(this,a):void b(this,a)}),s.define("restore_on_backspace",function(a){var b=this;a.text=a.text||function(a){return a[this.settings.labelField]};this.onKeyDown=function(){var c=b.onKeyDown;return function(b){var e,g;return 8===b.keyCode&&""===this.$control_input.val()&&!this.$activeItems.length&&
(e=this.caretPos-1,0<=e&&e<this.items.length)?(g=this.options[this.items[e]],this.deleteSelection(b)&&(this.setTextboxValue(a.text.apply(this,[g])),this.refreshOptions(!0)),void b.preventDefault()):c.apply(this,arguments)}}()}),s});