Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tom-select

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tom-select - npm Package Compare versions

Comparing version 1.0.0-b.1 to 1.0.0-b.2

src/plugins/change_listener/plugin.js

2

dist/js/tom-select.complete.min.js
/*! tom-select.js - v1.0.0-b.1 | https://github.com/orchidjs/tom-select | Apache License (v2) */
!function(t,e){"function"==typeof define&&define.amd?define("sifter",e):"object"==typeof exports?module.exports=e():t.Sifter=e()}(this,function(){function t(t,e){this.items=t,this.settings=e||{diacritics:!0}}t.prototype.tokenize=function(t){if(!(t=a(String(t||"").toLowerCase()))||!t.length)return[];for(var e,i,n=[],o=t.split(/ +/),s=0,r=o.length;s<r;s++){if(e=l(o[s]),this.settings.diacritics)for(i in u)u.hasOwnProperty(i)&&(e=e.replace(new RegExp(i,"g"),u[i]));n.push({string:o[s],regex:new RegExp(e,"i")})}return n},t.prototype.iterator=function(t,e){var i=r(t)?Array.prototype.forEach||function(t){for(var e=0,i=this.length;e<i;e++)t(this[e],e,this)}:function(t){for(var e in this)this.hasOwnProperty(e)&&t(this[e],e,this)};i.apply(t,[e])},t.prototype.getScoreFunction=function(t,e){var o,s,r,a;t=this.prepareSearch(t,e),s=t.tokens,o=t.options.fields,r=s.length,a=t.options.nesting;function l(t,e){var i,n;return!t||-1===(n=(t=String(t||"")).search(e.regex))?0:(i=e.string.length/t.length,0===n&&(i+=.5),i)}var u,c=(u=o.length)?1===u?function(t,e){return l(f(e,o[0],a),t)}:function(t,e){for(var i=0,n=0;i<u;i++)n+=l(f(e,o[i],a),t);return n/u}:function(){return 0};return r?1===r?function(t){return c(s[0],t)}:"and"===t.options.conjunction?function(t){for(var e,i=0,n=0;i<r;i++){if((e=c(s[i],t))<=0)return 0;n+=e}return n/r}:function(t){for(var e=0,i=0;e<r;e++)i+=c(s[e],t);return i/r}:function(){return 0}},t.prototype.getSortFunction=function(t,i){var e,n,o,s,r,a,l,u=this,c=!(t=u.prepareSearch(t,i)).query&&i.sort_empty||i.sort,p=function(t,e){return"$score"===t?e.score:f(u.items[e.id],t,i.nesting)},d=[];if(c)for(e=0,n=c.length;e<n;e++)!t.query&&"$score"===c[e].field||d.push(c[e]);if(t.query){for(l=!0,e=0,n=d.length;e<n;e++)if("$score"===d[e].field){l=!1;break}l&&d.unshift({field:"$score",direction:"desc"})}else for(e=0,n=d.length;e<n;e++)if("$score"===d[e].field){d.splice(e,1);break}for(a=[],e=0,n=d.length;e<n;e++)a.push("desc"===d[e].direction?-1:1);return(s=d.length)?1===s?(o=d[0].field,r=a[0],function(t,e){return r*h(p(o,t),p(o,e))}):function(t,e){for(var i,n,o=0;o<s;o++)if(n=d[o].field,i=a[o]*h(p(n,t),p(n,e)))return i;return 0}:null},t.prototype.prepareSearch=function(t,e){if("object"==typeof t)return t;var i=(e=s({},e)).fields,n=e.sort,o=e.sort_empty;return i&&!r(i)&&(e.fields=[i]),n&&!r(n)&&(e.sort=[n]),o&&!r(o)&&(e.sort_empty=[o]),{options:e,query:String(t||"").toLowerCase(),tokens:this.tokenize(t),total:0,items:[]}},t.prototype.search=function(t,i){var n,e,o,s=this,r=this.prepareSearch(t,i);return i=r.options,t=r.query,o=i.score||s.getScoreFunction(r),t.length?s.iterator(s.items,function(t,e){n=o(t),(!1===i.filter||0<n)&&r.items.push({score:n,id:e})}):s.iterator(s.items,function(t,e){r.items.push({score:1,id:e})}),(e=s.getSortFunction(r,i))&&r.items.sort(e),r.total=r.items.length,"number"==typeof i.limit&&(r.items=r.items.slice(0,i.limit)),r};var h=function(t,e){return"number"==typeof t&&"number"==typeof e?e<t?1:t<e?-1:0:(t=i(String(t||"")),(e=i(String(e||"")))<t?1:t<e?-1:0)},s=function(t,e){for(var i,n,o=1,s=arguments.length;o<s;o++)if(n=arguments[o])for(i in n)n.hasOwnProperty(i)&&(t[i]=n[i]);return t},f=function(t,e,i){if(t&&e){if(!i)return t[e];for(var n=e.split(".");n.length&&(t=t[n.shift()]););return t}},a=function(t){return(t+"").replace(/^\s+|\s+$|/g,"")},l=function(t){return(t+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},r=Array.isArray||"undefined"!=typeof $&&$.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},u={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},i=function(){var t,e,i,n,o="",s={};for(i in u)if(u.hasOwnProperty(i))for(o+=n=u[i].substring(2,u[i].length-1),t=0,e=n.length;t<e;t++)s[n.charAt(t)]=i;var r=new RegExp("["+o+"]","g");return function(t){return t.replace(r,function(t){return s[t]}).toLowerCase()}}();return t}),function(t,e){"function"==typeof define&&define.amd?define("microplugin",e):"object"==typeof exports?module.exports=e():t.MicroPlugin=e()}(this,function(){var t={mixin:function(n){n.plugins={},n.prototype.initializePlugins=function(t){var e,i,n,o=[];if(this.plugins={names:[],settings:{},requested:{},loaded:{}},s.isArray(t))for(e=0,i=t.length;e<i;e++)"string"==typeof t[e]?o.push(t[e]):(this.plugins.settings[t[e].name]=t[e].options,o.push(t[e].name));else if(t)for(n in t)t.hasOwnProperty(n)&&(this.plugins.settings[n]=t[n],o.push(n));for(;o.length;)this.require(o.shift())},n.prototype.loadPlugin=function(t){var e=this.plugins,i=n.plugins[t];if(!n.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');e.requested[t]=!0,e.loaded[t]=i.fn.apply(this,[this.plugins.settings[t]||{}]),e.names.push(t)},n.prototype.require=function(t){var e=this.plugins;if(!this.plugins.loaded.hasOwnProperty(t)){if(e.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")');this.loadPlugin(t)}return e.loaded[t]},n.define=function(t,e){n.plugins[t]={name:t,fn:e}}}},s={isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}};return t}),function(t,e){"function"==typeof define&&define.amd?define("tomselect",["sifter","microplugin"],e):"object"==typeof exports?module.exports=e(require("sifter"),require("microplugin")):t.TomSelect=e(t.Sifter,t.MicroPlugin)}(this,function(r,t){"use strict";function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function s(){}s.prototype={on:function(t,e){this._events=this._events||{},this._events[t]=this._events[t]||[],this._events[t].push(e)},off:function(t,e){var i=arguments.length;return 0===i?delete this._events:1===i?delete this._events[t]:(this._events=this._events||{},void(t in this._events!=!1&&this._events[t].splice(this._events[t].indexOf(e),1)))},trigger:function(t){if(this._events=this._events||{},t in this._events!=!1)for(var e=0;e<this._events[t].length;e++)this._events[t][e].apply(this,Array.prototype.slice.call(arguments,1))}},s.mixin=function(t){for(var e=["on","off","trigger"],i=0;i<e.length;i++)t.prototype[e[i]]=s.prototype[e[i]]};function a(u,t){var e,c=Object.assign({},D.defaults,t),p=c.dataAttr,d=c.labelField,h=c.valueField,f=c.disabledField,g=c.optgroupField,v=c.optgroupLabelField,m=c.optgroupValueField,i=u.tagName.toLowerCase(),n=u.getAttribute("placeholder")||u.getAttribute("data-placeholder");n||c.allowEmptyOption||(e=u.querySelector('option[value=""]'))&&(n=e.textContent);var y={placeholder:n,options:[],optgroups:[],items:[]};return("select"===i?function(){function r(t){var e=Object.assign({},t.dataset),i=p&&e[p];return"string"==typeof i&&i.length&&(e=Object.assign(e,JSON.parse(i))),e}function a(t,e){var i,n,o=k(t.value);(o||c.allowEmptyOption)&&(l.hasOwnProperty(o)?e&&((i=l[o][g])?Array.isArray(i)?i.push(e):l[o][g]=[i,e]:l[o][g]=e):((n=r(t))[d]=n[d]||t.textContent,n[h]=n[h]||o,n[f]=n[f]||t.disabled,n[g]=n[g]||e,l[o]=n,s.push(n),t.selected&&y.items.push(o)))}var t,e,i,n,s=y.options,l={};for(y.maxItems=u.hasAttribute("multiple")?null:1,t=0,e=(n=u.children).length;t<e;t++)"optgroup"===(i=n[t].tagName.toLowerCase())?function(t){var e,i=t.getAttribute("label");i&&((e=r(t))[v]=i,e[m]=i,e[f]=t.disabled,y.optgroups.push(e));for(var n,o=0,s=(n=t.children).length;o<s;o++)a(n[o],i)}(n[t]):"option"===i&&a(n[t])}:function(){var t,e,i,n,o=u.getAttribute(p);if(o)for(y.options=JSON.parse(o),t=0,e=y.options.length;t<e;t++)y.items.push(y.options[t][h]);else{var s=u.value.trim()||"";if(!c.allowEmptyOption&&!s.length)return;for(t=0,e=(i=s.split(c.delimiter)).length;t<e;t++)(n={})[d]=i[t],n[h]=i[t],y.options.push(n);y.items=i}})(),P(!0,{},D.defaults,y,t)}function l(t){return(t+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function i(e,i,t){var n,o=e.trigger,s={};for(n in e.trigger=function(){var t=arguments[0];if(-1===i.indexOf(t))return o.apply(e,arguments);s[t]=arguments},t.apply(e,[]),e.trigger=o,s)s.hasOwnProperty(n)&&o.apply(e,s[n])}function O(t){if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(-1<t.indexOf("<")){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild}return document.querySelector(t)}function u(t,e){var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!1),t.dispatchEvent(i)}function c(e,i){Object.keys(i).forEach(function(t){e.style[t]=i[t]})}function x(t){var e=y.apply(null,arguments);t=w(t);for(var i,n=0;n<t.length;n++){(i=t[n].classList).add.apply(i,o(e))}}function F(t){var e=y.apply(null,arguments);t=w(t);for(var i,n=0;n<t.length;n++){(i=t[n].classList).remove.apply(i,o(e))}}function C(i,t,n,o){for(var e=t.split(/\s/),s=function(t){var e=A(t.target,n,i);e&&(t.delegateTarget=e,o.call(e,t))},r=0;r<e.length;r++)i.addEventListener(e[r],s,!0)}function p(t,e){if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i}function f(t){var e,i;return!(!t||"[object Object]"!==toString.call(t))&&(!(e=_(t))||"function"==typeof(i=S.call(e,"constructor")&&e.constructor)&&I.call(i)===L)}var e=/Mac/.test(navigator.userAgent),d=e?91:17,g=e?18:17,v=e?"metaKey":"ctrlKey",m=e?"altKey":"ctrlKey",k=function(t){return null==t?null:"boolean"==typeof t?t?"1":"0":t+""},y=function(){for(var t=[],e=1;e<arguments.length;e++){var i=arguments[e];"string"==typeof i&&(i=i.trim().split(/[\11\12\14\15\40]/)),Array.isArray(i)&&(t=t.concat(i))}return t.filter(Boolean)},w=function(t){return Array.isArray(t)||(t=[t]),t},A=function(t,e,i){for(;t&&t.matches;){if(t.matches(e))return t;if(t==i)break;t=t.parentNode}},b=function(t,e){return 0<e?t[t.length-1]:t[0]},S={}.hasOwnProperty,I=S.toString,_=Object.getPrototypeOf,L=I.call(Object),P=function t(e){var i,n,o,s,r,a,l,u=e||{},c=1,p=arguments.length,d=!1;for("boolean"==typeof u&&(d=u,u=arguments[c]||{},c++),"object"===h(u)||"function"==typeof(l=u)&&"number"!=typeof l.nodeType||(u={}),c===p&&(u=this,c--);c<p;c++)if(null!=(i=arguments[c]))for(n in i)s=i[n],"__proto__"!==n&&u!==s&&(d&&s&&(f(s)||(r=Array.isArray(s)))?(o=u[n],a=r&&!Array.isArray(o)?[]:r||f(o)?o:{},r=!1,u[n]=t(d,a,s)):void 0!==s&&(u[n]=s));return u},D=function(t,e){var i,n,o=this;if((t=O(t)).tomselect)throw new Error("Tom Select already initialized on this element");t.tomselect=o,e=a(t,e);var s=(window.getComputedStyle&&window.getComputedStyle(t,null)).getPropertyValue("direction");for(Object.assign(o,{order:0,settings:e,input:t,tabIndex:t.getAttribute("tabindex")||"",is_select_tag:"select"===t.tagName.toLowerCase(),rtl:/rtl/i.test(s),highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:t.required,isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!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:{item:{},option:{}}}),o.settings.load&&o.settings.loadThrottle&&(o.settings.load=o.loadDebounce(o.settings.load,o.settings.loadThrottle)),o.sifter=new r(this.options,{diacritics:e.diacritics}),i=0,n=o.settings.options.length;i<n;i++)o.registerOption(o.settings.options[i]);for(delete o.settings.options,i=0,n=o.settings.optgroups.length;i<n;i++)o.registerOptionGroup(o.settings.optgroups[i]);delete o.settings.optgroups,o.settings.mode=o.settings.mode||(1===o.settings.maxItems?"single":"multi"),"boolean"!=typeof o.settings.hideSelected&&(o.settings.hideSelected="multi"===o.settings.mode),"string"==typeof o.settings.createFilter&&(o.settings.createFilter=new RegExp(o.settings.createFilter)),o.initializePlugins(o.settings.plugins),o.setupCallbacks(),o.setupTemplates(),o.setup()};if(void 0===t)throw'Dependency MicroPlugin is missing. Make sure you either: (1) are using the "complete" version of Tom Select, or (2) require MicroPlugin before you load Tom Select.';return s.mixin(D),t.mixin(D),Object.assign(D.prototype,{setup:function(){var i,t,e,n,o,s,r,a,l=this,u=l.settings,c=l.input,p=l.settings.mode,d=c.getAttribute("class")||"",h=O("<div>");if(x(h,u.wrapperClass,d,p),i=O('<div class="items">'),x(i,u.inputClass),h.append(i),e=O('<div style="display:none">'),x(e,u.dropdownClass,p),n=O('<div style="scroll-behavior: smooth;">'),x(n,u.dropdownContentClass),e.append(n),O(u.dropdownParent||h).appendChild(e),u.controlInput)t=O(u.controlInput);else{t=O('<input type="text" autocomplete="off" />');for(var f=["autocorrect","autocapitalize","autocomplete"],g=0;g<f.length;g++){var v=f[g];c.getAttribute(v)&&t.setAttribute(v,c.getAttribute(v))}}u.controlInput||(t.setAttribute("tabindex",c.disabled?"-1":l.tabIndex),i.appendChild(t)),(s=c.getAttribute("id"))&&(t.setAttribute("id",s+"-tomselected"),(r=document.querySelector("label[for='"+s+"']"))&&r.setAttribute("for",s+"-tomselected")),l.settings.copyClassesToDropdown&&x(e,d),h.style.width=c.style.width,l.plugins.names.length&&(o="plugin-"+l.plugins.names.join(" plugin-"),x([h,e],o)),(null===u.maxItems||1<u.maxItems)&&l.is_select_tag&&c.setAttribute("multiple","multiple"),l.settings.placeholder&&t.setAttribute("placeholder",u.placeholder),!l.settings.splitOn&&l.settings.delimiter&&(a=l.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),l.settings.splitOn=new RegExp("\\s*"+a+"+\\s*")),t.type=c.type,l.control=i,l.control_input=t,l.wrapper=h,l.dropdown=e,l.dropdown_content=n,C(e,"mouseenter","[data-selectable]",function(){return l.onOptionHover.apply(l,arguments)}),C(e,"mousedown","[data-selectable]",function(){return l.onOptionSelect.apply(l,arguments)}),i.addEventListener("mousedown",function(t){var e=A(t.target,"."+l.settings.itemClass,i);return e?(t.delegateTarget=e,l.onItemSelect.call(l,t)):l.onMouseDown.call(l,t)}),i.addEventListener("click",function(){return l.onClick.apply(l,arguments)}),t.addEventListener("mousedown",function(t){t.stopPropagation()}),t.addEventListener("keydown",function(){return l.onKeyDown.apply(l,arguments)}),t.addEventListener("keyup",function(){return l.onKeyUp.apply(l,arguments)}),t.addEventListener("keypress",function(){return l.onKeyPress.apply(l,arguments)}),t.addEventListener("resize",function(){l.positionDropdown.apply(l,[])}),t.addEventListener("blur",function(){return l.onBlur.apply(l,arguments)}),t.addEventListener("focus",function(){return l.ignoreBlur=!1,l.onFocus.apply(l,arguments)}),t.addEventListener("paste",function(){return l.onPaste.apply(l,arguments)});function m(t){if(l.isFocused){if(A(t.target,"."+l.settings.wrapperClass,l.wrapper))return!1;l.blur(t.target)}}function y(){l.isOpen&&l.positionDropdown.apply(l,arguments)}function w(){l.ignoreHover=!1}document.addEventListener("mousedown",m),window.addEventListener("sroll",y),window.addEventListener("resize",y),window.addEventListener("mousemove",w),l._destroy=function(){document.removeEventListener("mousedown",m),window.removeEventListener("mousemove",w),window.removeEventListener("sroll",y),window.removeEventListener("resize",y)};for(var b=[];0<c.children.length;)b.push(c.children[0]),c.children[0].remove();this.revertSettings={children:b,tabindex:c.getAttribute("tabindex")},c.setAttribute("tabindex",-1),c.setAttribute("hidden","hidden"),c.insertAdjacentElement("afterend",l.wrapper),l.setValue(u.items),delete u.items,l.supportsValidity()&&c.addEventListener("invalid",function(t){t.preventDefault(),l.isInvalid=!0,l.refreshState()}),l.updateOriginalInput(),l.refreshItems(),l.refreshState(),l.isSetup=!0,c.disabled&&l.disable(),l.on("change",this.onChange),x(c,"tomselected"),l.trigger("initialize"),!0===u.preload&&l.onSearchChange("")},supportsValidity:function(){return!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity},setupTemplates:function(){var i=this.settings.labelField,n=this.settings.optgroupLabelField,t={optgroup:function(){return'<div class="optgroup"></div>'},optgroup_header:function(t,e){return'<div class="optgroup-header">'+e(t[n])+"</div>"},option:function(t,e){return"<div>"+e(t[i])+"</div>"},item:function(t,e){return"<div>"+e(t[i])+"</div>"},option_create:function(t,e){return'<div class="create">Add <strong>'+e(t.input)+"</strong>&hellip;</div>"},no_results:function(){return'<div class="no-results">No results found</div>'}};this.settings.render=Object.assign({},t,this.settings.render)},setupCallbacks:function(){var t,e,i={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(t in i)(e=this.settings[i[t]])&&this.on(t,e)},onClick:function(t){this.isFocused&&this.isOpen||(this.focus(),t.preventDefault())},onMouseDown:function(t){var e=this;if(e.isFocused){if(t.target!==e.control_input)return"single"===e.settings.mode?e.isOpen?e.close():e.open():e.setActiveItem(null),!1}else window.setTimeout(function(){e.focus()},0)},onChange:function(){u(this.input,"change")},onPaste:function(t){var o=this;o.isFull()||o.isInputHidden||o.isLocked?t.preventDefault():o.settings.splitOn&&setTimeout(function(){var t=o.inputValue();if(t.match(o.settings.splitOn))for(var e=t.trim().split(o.settings.splitOn),i=0,n=e.length;i<n;i++)o.createItem(e[i])},0)},onKeyPress:function(t){if(this.isLocked)return t&&t.preventDefault();var e=String.fromCharCode(t.keyCode||t.which);return this.settings.create&&"multi"===this.settings.mode&&e===this.settings.delimiter?(this.createItem(),t.preventDefault(),!1):void 0},onKeyDown:function(t){t.target,this.control_input;var e,i,n=this;if(n.isLocked)9!==t.keyCode&&t.preventDefault();else{switch(t.keyCode){case 65:if(n.isKeyDown(d,t))return void n.selectAll();break;case 27:return void(n.isOpen&&(t.preventDefault(),t.stopPropagation(),n.close()));case 40:return!n.isOpen&&n.hasOptions?n.open():n.activeOption&&(n.ignoreHover=!0,(e=n.getAdjacent(n.activeOption,1))&&n.setActiveOption(e,!0)),void t.preventDefault();case 38:return n.activeOption&&(n.ignoreHover=!0,(i=n.getAdjacent(n.activeOption,-1))&&n.setActiveOption(i,!0)),void t.preventDefault();case 13:return void(n.isOpen&&n.activeOption&&(n.onOptionSelect({delegateTarget:n.activeOption}),t.preventDefault()));case 37:return void n.advanceSelection(-1,t);case 39:return void n.advanceSelection(1,t);case 9:return n.settings.selectOnTab&&n.isOpen&&n.activeOption&&(n.onOptionSelect({delegateTarget:n.activeOption}),t.preventDefault()),void(n.settings.create&&n.createItem()&&t.preventDefault());case 8:case 46:return void n.deleteSelection(t)}!n.isInputHidden||n.isKeyDown(d,t)||t.preventDefault()}},onKeyUp:function(t){var e=this;if(e.isLocked)return t&&t.preventDefault();var i=e.inputValue();e.lastValue!==i&&(e.lastValue=i,e.onSearchChange(i),e.refreshOptions(),e.trigger("type",i))},onSearchChange:function(e){var i=this,n=i.settings.load;n&&(i.loadedSearches.hasOwnProperty(e)||(i.loadedSearches[e]=!0,i.load(function(t){n.apply(i,[e,t])})))},onFocus:function(t){var e=this,i=e.isFocused;if(e.isDisabled)return e.blur(),t&&t.preventDefault(),!1;e.ignoreFocus||(e.isFocused=!0,"focus"===e.settings.preload&&e.onSearchChange(""),i||e.trigger("focus"),e.activeItems.length||(e.showInput(),e.setActiveItem(null),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())},onBlur:function(t,e){var i=this;if(i.isFocused){if(i.isFocused=!1,i.ignoreFocus=!1,!i.ignoreBlur&&document.activeElement===i.dropdown_content)return i.ignoreBlur=!0,void i.onFocus(t);var n=function(){i.close(),i.setActiveItem(null),i.setActiveOption(null),i.setCaret(i.items.length),i.refreshState(),e&&e.focus&&e.focus(),i.isBlurring=!1,i.trigger("blur")};i.isBlurring=!0,i.settings.create&&i.settings.createOnBlur?i.createItem(null,!1,n):n()}},onOptionHover:function(t){this.ignoreHover||this.setActiveOption(t.delegateTarget,!1)},onOptionSelect:function(t){var e,i=this;t.preventDefault&&(t.preventDefault(),t.stopPropagation());var n=t.delegateTarget;n&&(n.parentNode&&n.parentNode.matches("[data-disabled]")||(n.classList.contains("create")?i.createItem(null,function(){i.settings.closeAfterSelect&&i.close()}):void 0!==(e=n.dataset.value)&&(i.lastQuery=null,i.addItem(e),i.settings.closeAfterSelect?i.close():!i.settings.hideSelected&&t.type&&/mouse/.test(t.type)&&i.setActiveOption(i.getOption(e)))))},onItemSelect:function(t){this.isLocked||"multi"===this.settings.mode&&(t.preventDefault(),this.setActiveItem(t.delegateTarget,t))},load:function(t){var i=this;x(i.wrapper,i.settings.loadingClass),i.loading++,t.apply(i,[function(t,e){i.loading=Math.max(i.loading-1,0),e&&e.length&&e.forEach(function(t){i.addOptionGroup(t[i.settings.optgroupValueField],t)}),t&&t.length&&i.addOption(t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||F(i.wrapper,i.settings.loadingClass),i.trigger("load",t)}])},loadDebounce:function(i,n){var o;return function(){var t=this,e=arguments;o&&(t.loading=Math.max(t.loading-1,0)),window.clearTimeout(o),o=window.setTimeout(function(){o=null,i.apply(t,e)},n)}},setTextboxValue:function(t){var e=this.control_input;e.value!==t&&(e.value=t,u(e,"update"),this.lastValue=t)},getValue:function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)},setValue:function(t,e){i(this,e?[]:["change"],function(){this.clear(e),this.addItems(t,e)})},setActiveItem:function(t,e){var i,n,o,s,r,a;if("single"!==this.settings.mode){if(!t)return F(this.activeItems,"active"),this.activeItems=[],void(this.isFocused&&this.showInput());if("mousedown"===(i=e&&e.type.toLowerCase())&&this.isKeyDown(16,e)&&this.activeItems.length){for(a=this.getLastActive(),o=Array.prototype.indexOf.apply(this.control.children,[a]),(s=Array.prototype.indexOf.apply(this.control.children,[t]))<o&&(r=o,o=s,s=r),n=o;n<=s;n++)t=this.control.children[n],-1===this.activeItems.indexOf(t)&&this.setActiveItemClass(t);e.preventDefault()}else"mousedown"===i&&this.isKeyDown(g,e)||"keydown"===i&&this.isKeyDown(16,e)?t.classList.contains("active")?this.removeActiveItem(t):this.setActiveItemClass(t):(F(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(t));this.hideInput(),this.isFocused||this.focus()}},setActiveItemClass:function(t){var e=this.control.querySelector(".last-active");e&&F(e,"last-active"),x(t,"active last-active"),-1==this.activeItems.indexOf(t)&&this.activeItems.push(t)},removeActiveItem:function(t){var e=this.activeItems.indexOf(t);this.activeItems.splice(e,1),F(t,"active")},setActiveOption:function(t,e){var i,n,o;t!==this.activeOption&&(this.activeOption&&F(this.activeOption,"active"),this.activeOption=null,t&&(this.activeOption=t,x(t,"active"),!e&&void 0!==e||(i=this.dropdown_content.clientHeight,e=this.dropdown_content.scrollTop||0,n=this.activeOption.offsetHeight,i+e<(o=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+e)+n?this.dropdown_content.scrollTop=o-i+n:o<e&&(this.dropdown_content.scrollTop=o))))},selectAll:function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(x(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())},hideInput:function(){this.settings.controlInput||(this.setTextboxValue(""),c(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)},showInput:function(){this.settings.controlInput||(c(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)},inputValue:function(){return this.control_input.value.trim()},focus:function(){var t=this;t.isDisabled||(t.ignoreFocus=!0,t.control_input.focus(),window.setTimeout(function(){t.ignoreFocus=!1,t.onFocus()},0))},blur:function(t){this.control_input.blur(),this.onBlur(null,t)},getScoreFunction:function(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())},getSearchOptions:function(){var t=this.settings,e=t.sortField;return"string"==typeof e&&(e=[{field:e}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}},search:function(t){var e,i,n,o=this,s=o.settings,r=this.getSearchOptions();if(s.score&&"function"!=typeof(n=o.settings.score.apply(this,[t])))throw new Error('Tom Select "score" setting must be a function that returns a function');if(t!==o.lastQuery?(o.lastQuery=t,i=o.sifter.search(t,Object.assign(r,{score:n})),o.currentResults=i):i=P({},o.currentResults),s.hideSelected)for(e=i.items.length-1;0<=e;e--)-1!==o.items.indexOf(k(i.items[e].id))&&i.items.splice(e,1);return i},refreshOptions:function(t){var e,i,n,o,s,r;void 0===t&&(t=!0);var a,l,u,c,p,d,h=this,f=h.inputValue(),g=h.search(f),v=h.activeOption&&k(h.activeOption.dataset.value),m=!1,y=g.items.length;for("number"==typeof h.settings.maxOptions&&(y=Math.min(y,h.settings.maxOptions)),0<y&&(m=!0),i={},n=[],e=0;e<y;e++)for(var w,b=h.options[g.items[e].id],O=k(b[h.settings.valueField]),C=(C=h.getOption(O))||h.render("option",b),A=b[h.settings.optgroupField]||"",S=0,I=(w=Array.isArray(A)?A:[A])&&w.length;S<I;S++)A=w[S],h.optgroups.hasOwnProperty(A)||(A=""),i.hasOwnProperty(A)||(i[A]=document.createDocumentFragment(),n.push(A)),0<S&&(C=C.cloneNode(!0),F(C,"active")),i[A].appendChild(C);for(this.settings.lockOptgroupOrder&&n.sort(function(t,e){return(h.optgroups[t].$order||0)-(h.optgroups[e].$order||0)}),o=document.createDocumentFragment(),e=0,y=n.length;e<y;e++){A=n[e],h.optgroups.hasOwnProperty(A)&&i[A].children.length?((a=h.render("optgroup",h.optgroups[A])).appendChild(h.render("optgroup_header",h.optgroups[A])),a.appendChild(i[A]),o.appendChild(a)):o.appendChild(i[A])}if(h.dropdown_content.innerHTML="",h.dropdown_content.appendChild(o),h.settings.highlight&&(h.dropdown_content,l=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(l,function(t,e){var i=t.parentNode;i.replaceChild(t.firstChild,t),i.normalize()}),g.query.length&&g.tokens.length))for(e=0,y=g.tokens.length;e<y;e++)!function(t,e){var u,i;"string"==typeof e&&!e.length||(u="string"==typeof e?new RegExp(e,"i"):e,i=function t(e){var i=0;if(3===e.nodeType){var n,o,s,r,a=e.data.search(u);0<=a&&0<e.data.length&&(n=e.data.match(u),(o=document.createElement("span")).className="highlight",(s=e.splitText(a)).splitText(n[0].length),r=s.cloneNode(!0),o.appendChild(r),s.parentNode.replaceChild(o,s),i=1)}else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&("highlight"!==e.className||"SPAN"!==e.tagName))for(var l=0;l<e.childNodes.length;++l)l+=t(e.childNodes[l]);return i},i(t))}(h.dropdown_content,g.tokens[e].regex);if(!h.settings.hideSelected)for(e=0,y=h.items.length;e<y;e++){var _=h.getOption(h.items[e]);_&&x(_,"selected")}0===g.items.length&&h.settings.render.no_results&&!h.loading&&f.length&&(u=h.render("no_results",{input:f}),m=!0,h.dropdown_content.insertBefore(u,h.dropdown_content.firstChild)),(s=h.canCreate(f))&&(m=!0,r=h.render("option_create",{input:f}),h.dropdown_content.insertBefore(r,h.dropdown_content.firstChild)),h.hasOptions=0<g.items.length||s,m?(d=0<g.items.length?(p=v&&h.getOption(v))&&h.dropdown_content.contains(p)?p:"single"===h.settings.mode&&h.items.length?h.getOption(h.items[0]):(c=0,r&&!h.settings.addPrecedence&&(c=1),h.selectable()[c]):r,h.setActiveOption(d),t&&!h.isOpen&&h.open()):(h.setActiveOption(null),t&&h.isOpen&&h.close())},selectable:function(){return this.dropdown_content.querySelectorAll("[data-selectable]")},addOption:function(t){var e,i,n,o=this;if(Array.isArray(t))for(e=0,i=t.length;e<i;e++)o.addOption(t[e]);else(n=o.registerOption(t))&&(o.userOptions[n]=!0,o.lastQuery=null,o.trigger("option_add",n,t))},registerOption:function(t){var e=k(t[this.settings.valueField]);return null!=e&&!this.options.hasOwnProperty(e)&&(t.$order=t.$order||++this.order,this.options[e]=t,e)},registerOptionGroup:function(t){var e=k(t[this.settings.optgroupValueField]);return!!e&&(t.$order=t.$order||++this.order,this.optgroups[e]=t,e)},addOptionGroup:function(t,e){e[this.settings.optgroupValueField]=t,(t=this.registerOptionGroup(e))&&this.trigger("optgroup_add",t,e)},removeOptionGroup:function(t){this.optgroups.hasOwnProperty(t)&&(delete this.optgroups[t],this.clearCache(),this.trigger("optgroup_remove",t))},clearOptionGroups:function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")},updateOption:function(t,e){var i,n,o,s,r,a,l,u=this;if(t=k(t),o=k(e[u.settings.valueField]),null!==t&&u.options.hasOwnProperty(t)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=u.options[t].$order,o!==t&&(delete u.options[t],-1!==(s=u.items.indexOf(t))&&u.items.splice(s,1,o)),e.$order=e.$order||l,u.options[o]=e,r=u.renderCache.item,a=u.renderCache.option,r&&(delete r[t],delete r[o]),a&&(delete a[t],delete a[o]),-1!==u.items.indexOf(o)&&(i=u.getItem(t),n=u.render("item",e),i.classList.contains("active")&&x(n,"active"),i.parentNode.insertBefore(n,i),i.remove()),u.lastQuery=null,u.isOpen&&u.refreshOptions(!1)}},removeOption:function(t,e){var i=this;t=k(t);var n=i.renderCache.item,o=i.renderCache.option;n&&delete n[t],o&&delete o[t],delete i.userOptions[t],delete i.options[t],i.lastQuery=null,i.trigger("option_remove",t),i.removeItem(t,e)},clearOptions:function(){this.loadedSearches={},this.userOptions={},this.clearCache();var t={};for(key in this.options)this.options.hasOwnProperty(key)&&0<=this.items.indexOf(key)&&(t[key]=this.options[key]);this.options=this.sifter.items=t,this.lastQuery=null,this.trigger("option_clear")},getOption:function(t){return this.renderCache.option.hasOwnProperty(t)?this.renderCache.option[t]:this.getElementWithValue(t,this.selectable())},getAdjacent:function(t,e,i){var n=2<arguments.length&&void 0!==i?i:"option";if(t){var o=this.settings.optionClass,s=this.dropdown;"item"==n&&(s=this.control,o=this.settings.itemClass);for(var r=s.querySelectorAll("."+o),a=0;a<r.length;a++)if(r[a]==t)return 0<e?r[a+1]:r[a-1]}},getElementWithValue:function(t,e){if(null!=(t=k(t)))for(var i=0,n=e.length;i<n;i++)if(e[i].getAttribute("data-value")===t)return e[i]},getItem:function(t){return this.getElementWithValue(t,this.control.children)},addItems:function(t,e){this.buffer=document.createDocumentFragment();for(var i=this.control.children,n=0;n<i.length;n++)this.buffer.appendChild(i[n]);for(var o=Array.isArray(t)?t:[t],n=0,s=o.length;n<s;n++)this.isPending=n<s-1,this.addItem(o[n],e);var r=this.control;r.insertBefore(this.buffer,r.firstChild),this.buffer=null},addItem:function(a,l){i(this,l?[]:["change"],function(){var t,e,i,n,o,s=this,r=s.settings.mode;a=k(a),(-1===s.items.indexOf(a)||("single"===r&&s.close(),"single"!==r&&s.settings.duplicates))&&s.options.hasOwnProperty(a)&&("single"===r&&s.clear(l),"multi"===r&&s.isFull()||(o=s.render("item",s.options[a]),this.control.contains(o)&&(o=o.cloneNode(!0)),t=s.isFull(),s.items.splice(s.caretPos,0,a),s.insertAtCaret(o),s.isPending&&(t||!s.isFull())||s.refreshState(),s.isSetup&&(e=s.selectable(),s.isPending||(i=s.getOption(a),n=s.getAdjacent(i,1),s.refreshOptions(s.isFocused&&"single"!==r),n&&s.setActiveOption(n)),!e.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.trigger("item_add",a,o),s.isPending||s.updateOriginalInput({silent:l}))))})},removeItem:function(t,e){var i,n,o=this.getItem(t);o&&(t=k(o.dataset.value),-1!==(i=this.items.indexOf(t))&&(o.remove(),o.classList.contains("active")&&(n=this.activeItems.indexOf(o),this.activeItems.splice(n,1),F(o,"active")),this.items.splice(i,1),this.lastQuery=null,!this.settings.persist&&this.userOptions.hasOwnProperty(t)&&this.removeOption(t,e),i<this.caretPos&&this.setCaret(this.caretPos-1),this.refreshState(),this.updateOriginalInput({silent:e}),this.positionDropdown(),this.trigger("item_remove",t,o)))},createItem:function(t,i){var n=this,o=n.caretPos;t=t||n.inputValue();var s=arguments[arguments.length-1];if("function"!=typeof s&&(s=function(){}),"boolean"!=typeof i&&(i=!0),!n.canCreate(t))return s(),!1;n.lock();var e,r,a="function"==typeof n.settings.create?this.settings.create:function(t){var e={};return e[n.settings.labelField]=t,e[n.settings.valueField]=t,e},l=(r=!(e=function(t){if(n.unlock(),!t||"object"!==h(t))return s();var e=k(t[n.settings.valueField]);if("string"!=typeof e)return s();n.setTextboxValue(""),n.addOption(t),n.setCaret(o),n.addItem(e),n.refreshOptions(i&&"single"!==n.settings.mode),s(t)}),function(){r||(r=!0,e.apply(this,arguments))}),u=a.apply(this,[t,l]);return void 0!==u&&l(u),!0},refreshItems:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()},refreshState:function(){var t=this;t.refreshValidityState();var e=t.isFull(),i=t.isLocked;t.wrapper.classList.toggle("rtl",t.rtl);var n,o=t.control.classList;o.toggle("focus",t.isFocused),o.toggle("disabled",t.isDisabled),o.toggle("required",t.isRequired),o.toggle("invalid",t.isInvalid),o.toggle("locked",i),o.toggle("full",e),o.toggle("not-full",!e),o.toggle("input-active",t.isFocused&&!t.isInputHidden),o.toggle("dropdown-active",t.isOpen),o.toggle("has-options",(n=t.options,0===Object.keys(n).length)),o.toggle("has-items",0<t.items.length)},refreshValidityState:function(){if(!this.isRequired)return!1;var t=!this.items.length;this.isInvalid=t,this.control_input.required=t,this.input.required=!t},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(t){var e,i,n,o,s=this;if(t=t||{},s.is_select_tag){for(n=[],e=0,i=s.items.length;e<i;e++)o=s.options[s.items[e]][s.settings.labelField]||"",n.push('<option value="'+l(s.items[e])+'" selected="selected">'+l(o)+"</option>");n.length||this.input.hasAttribute("multiple")||n.push('<option value="" selected="selected"></option>'),s.input.innerHTML=n.join("")}else s.input.value=s.getValue(),s.input.setAttribute("value",s.input.value);s.isSetup&&(t.silent||s.trigger("change",s.input.value))},open:function(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.focus(),t.isOpen=!0,t.refreshState(),c(t.dropdown,{visibility:"hidden",display:"block"}),t.positionDropdown(),c(t.dropdown,{visibility:"visible",display:"block"}),t.trigger("dropdown_open",t.dropdown))},close:function(){var t=this,e=t.isOpen;"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.isBlurring||t.blur()),t.isOpen=!1,c(t.dropdown,{display:"none"}),t.setActiveOption(null),t.refreshState(),e&&t.trigger("dropdown_close",t.dropdown)},positionDropdown:function(){var t,e=0,i=this.control,n=i.offsetHeight;"body"===this.settings.dropdownParent?(n+=(t=i.getBoundingClientRect()).top+window.scrollY,e=t.left+window.scrollX):this.settings.dropdownParent?n=(i=O(this.settings.dropdownParent)).offsetHeight:(n+=i.offsetTop,e=i.offsetLeft),c(this.dropdown,{width:i.getBoundingClientRect().width+"px",top:n+"px",left:e+"px"})},clear:function(t){if(this.items.length){for(var e=this.controlChildren(),i=0;i<e.length;i++)e[i].remove();this.items=[],this.lastQuery=null,this.setCaret(0),this.setActiveItem(null),this.updateOriginalInput({silent:t}),this.refreshState(),this.showInput(),this.trigger("clear")}},insertAtCaret:function(t){var e=Math.min(this.caretPos,this.items.length),i=this.buffer||this.control;0===e?i.insertBefore(t,i.firstChild):i.insertBefore(t,i.children[e]),this.setCaret(e+1)},deleteSelection:function(t){var e,i,n,o,s,r=this,a=t&&8===t.keyCode?-1:1,l={start:(s=r.control_input).selectionStart,length:s.selectionEnd-s.selectionStart},u=[];if(r.activeItems.length){for(o=b(r.activeItems,a),n=p(o),0<a&&n++,e=0,i=r.activeItems.length;e<i;e++)u.push(r.activeItems[e].dataset.value);t&&(t.preventDefault(),t.stopPropagation())}else(r.isFocused||"single"===r.settings.mode)&&r.items.length&&(a<0&&0===l.start&&0===l.length?u.push(r.items[r.caretPos-1]):0<a&&l.start===r.inputValue().length&&u.push(r.items[r.caretPos]));if(!u.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.apply(r,[u,t]))return!1;for(void 0!==n&&r.setCaret(n);u.length;)r.removeItem(u.pop());return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0},advanceSelection:function(t,e){var i,n,o;0!==t&&(this.rtl&&(t*=-1),this.isKeyDown(g,e)||this.isKeyDown(16,e)?(n=this.getLastActive(t),(o=this.getAdjacent(n,t,"item"))&&(o.classList.contains("active")&&this.removeActiveItem(n),this.setActiveItemClass(o))):this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+t):(n=this.getLastActive(t))&&(i=p(n),this.setCaret(0<t?i+1:i),this.setActiveItem(null)))},getLastActive:function(t){var e=this.control.querySelector(".last-active");return e||function(t,e,i){var n=t.querySelectorAll(e);if(n)return b(n,i)}(this.control,".active",t)},setCaret:function(t){var e=this;if(t="single"===e.settings.mode||e.settings.controlInput?e.items.length:Math.max(0,Math.min(e.items.length,t)),!e.settings.controlInput&&!e.isPending)for(var i,n=this.controlChildren(),o=n.length,s=0;s<o;s++)i=n[s],s<t?e.control_input.insertAdjacentElement("beforebegin",i):e.control.appendChild(i);e.caretPos=t},controlChildren:function(){return Array.prototype.filter.call(this.control.children,function(t){return"INPUT"!==t.nodeName})},lock:function(){this.close(),this.isLocked=!0,this.refreshState()},unlock:function(){this.isLocked=!1,this.refreshState()},disable:function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()},enable:function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()},destroy:function(){var t=this.revertSettings;this.trigger("destroy"),this.off(),this.wrapper.remove(),this.dropdown.remove(),this.input.innerHTML="",t.tabindex?this.input.setAttribute("tabindex",t.tabindex):this.input.removeAttribute("tabindex"),F(this.input,"tomselected"),this.input.removeAttribute("hidden");for(var e=0;e<t.children.length;e++)this.input.appendChild(t.children[e]);this._destroy(),delete this.input.tomselect},render:function(t,e){var i,n,o="",s=this;return"option"!==t&&"item"!==t||(i=k(e[s.settings.valueField]),!s.renderCache[t].hasOwnProperty(i))?(o=O(s.settings.render[t].apply(this,[e,l])),"option"===t||"option_create"===t?e[s.settings.disabledField]||o.setAttribute("data-selectable",""):"optgroup"===t&&(n=e[s.settings.optgroupValueField],o.setAttribute("data-group",n),e[s.settings.disabledField]&&o.setAttribute("data-disabled","")),"option"!==t&&"item"!==t||(o.setAttribute("data-value",i),x(o,"item"===t?s.settings.itemClass:s.settings.optionClass),s.renderCache[t][i]=o),o):s.renderCache[t][i]},clearCache:function(t){void 0===t?this.renderCache={item:{},option:{}}:this.renderCache[t]={}},canCreate:function(t){if(!this.settings.create)return!1;var e=this.settings.createFilter;return t.length&&("function"!=typeof e||e.apply(this,[t]))&&(!(e instanceof RegExp)||e.test(t))},isKeyDown:function(t,e){if(e){if(t==g&&e[m])return!0;if(t==d&&e[v])return!0;if(16==t&&e.shiftKey)return!0}return!1},hook:function(i,t,n){var o=this,s=o[t];o[t]=function(){var t,e;return"after"===i&&(t=s.apply(o,arguments)),e=n.apply(o,arguments),"instead"===i?e:("before"===i&&(t=s.apply(o,arguments)),t)}}}),D.count=0,D.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,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"tomselect-control",inputClass:"tomselect-input",dropdownClass:"tomselect-dropdown",dropdownContentClass:"tomselect-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}},D.define("drag_drop",function(t){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');var e,i,n;"multi"===this.settings.mode&&(i=(e=this).lock,n=e.unlock,e.hook("instead","lock",function(){var t=e.control.dataset.sortable;return t&&t.disable(),i.apply(e,arguments)}),e.hook("instead","unlock",function(){var t=e.control.dataset.sortable;return t&&t.enable(),n.apply(e,arguments)}),e.hook("after","setup",function(){var i=$(e.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:e.isLocked,start:function(t,e){e.placeholder.css("width",e.helper.css("width")),i.css({overflow:"visible"})},stop:function(){i.css({overflow:"hidden"});var t=[];i.children("[data-value]").each(function(){t.push($(this).attr("data-value"))}),e.setValue(t)}})}))}),D.define("dropdown_header",function(e){var i=this;e=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:function(t){return'<div class="'+t.headerClass+'"><div class="'+t.titleRowClass+'"><span class="'+t.labelClass+'">'+t.title+'</span><a href="javascript:void(0)" class="'+t.closeClass+'">&times;</a></div></div>'}},e),i.hook("after","setup",function(){var t=O(e.html(e));i.dropdown.insertBefore(t,i.dropdown.firstChild)})}),D.define("input_autogrow",function(t){var a=this;a.hook("after","setup",function(){var t=document.createElement("span"),e=this.control_input;t.style.position="absolute",t.style.top="-99999px",t.style.left="-99999px",t.style.width="auto",t.style.padding=0,t.style.whiteSpace="pre",a.wrapper.appendChild(t);for(var i=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"],n=0,o=i.length;n<o;n++){var s=i[n];t.style[s]=e.style[s]}function r(){t.textContent=e.value,e.style.width=t.clientWidth+"px"}e.addEventListener("input",r),e.addEventListener("keyup",r),e.addEventListener("blur",r),e.addEventListener("update",r)})}),D.define("no_backspace_delete",function(t){this.hook("instead","setActiveItem",function(){}),this.hook("instead","selectAll",function(){}),this.settings.onDelete=function(t,e){if(0<t.length&&e&&(8==e.keyCode||46==e.keyCode))return!1}}),D.define("optgroup_columns",function(a){var l=this;a=Object.assign({equalizeWidth:!0,equalizeHeight:!0},a);var s=l.onKeyDown;l.hook("instead","onKeyDown",function(t){var e,i,n,o;return!l.isOpen||37!==t.keyCode&&39!==t.keyCode?s.apply(l,arguments):(l.ignoreHover=!0,o=A(l.activeOption,"[data-group]"),e=p(l.activeOption,"[data-selectable]"),void((o=37===t.keyCode?o.previousSibling:o.nextSibling)&&(i=(n=o.querySelectorAll("[data-selectable]"))[Math.min(n.length-1,e)])&&l.setActiveOption(i)))});function t(){var t,e,i,n,o,s=l.dropdown_content.querySelectorAll("[data-group]"),r=s.length;if(r&&l.dropdown_content.clientWidth){if(a.equalizeHeight){for(t=e=0;t<r;t++)e=Math.max(e,s[t].clientHeight);for(t=0;t<r;t++)s[t].style.height=e+"px"}if(r&&l.dropdown_content.clientWidth&&a.equalizeWidth){for(o=l.dropdown_content.clientWidth-function t(){var e,i=t.width,n=document;return void 0===i&&((e=n.createElement("div")).innerHTML='<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>',e=e.firstChild,n.body.appendChild(e),i=t.width=e.offsetWidth-e.clientWidth,n.body.removeChild(e)),i}(),i=Math.round(o/r),t=0;t<r;t++)s[t].style.width=i+"px";1<r&&(n=o-i*(r-1),s[r-1].style.width=n+"px")}}}(a.equalizeHeight||a.equalizeWidth)&&(l.hook("after","positionDropdown",t),l.hook("after","refreshOptions",t))}),D.define("remove_button",function(t){t=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},t);var o,s,r=this;t.append&&(o='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+l(t.title)+'">'+t.label+"</a>",s=r.render,r.hook("instead","render",function(t,e){var i,n=s.apply(r,arguments);return"item"==t&&(i=O(o),n.appendChild(i),i.addEventListener("click",function(t){var e;t.preventDefault(),"single"!==r.settings.mode&&t.stopPropagation(),r.isLocked||(e=n.dataset.value,r.removeItem(e))})),n}))}),D.define("restore_on_backspace",function(n){var o=this;n.text=n.text||function(t){return t[o.settings.labelField]};var s=o.onKeyDown;o.hook("instead","onKeyDown",function(t){var e,i;return 8===t.keyCode&&""===o.control_input.value&&!o.activeItems.length&&0<=(e=o.caretPos-1)&&e<o.items.length?(i=o.options[o.items[e]],o.deleteSelection(t)&&(o.setTextboxValue(n.text.apply(o,[i])),o.refreshOptions(!0)),void t.preventDefault()):s.apply(o,arguments)})}),D});var tomSelect=function(t,e){return new TomSelect(t,e)};
!function(e,t){"function"==typeof define&&define.amd?define("sifter",t):"object"==typeof exports?module.exports=t():e.Sifter=t()}(this,function(){function e(e,t){this.items=e,this.settings=t||{diacritics:!0}}e.prototype.tokenize=function(e){if(!(e=a(String(e||"").toLowerCase()))||!e.length)return[];for(var t,n,i=[],o=e.split(/ +/),r=0,s=o.length;r<s;r++){if(t=l(o[r]),this.settings.diacritics)for(n in u)u.hasOwnProperty(n)&&(t=t.replace(new RegExp(n,"g"),u[n]));i.push({string:o[r],regex:new RegExp(t,"i")})}return i},e.prototype.iterator=function(e,t){var n=s(e)?Array.prototype.forEach||function(e){for(var t=0,n=this.length;t<n;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)};n.apply(e,[t])},e.prototype.getScoreFunction=function(e,t){var o,r,s,a;e=this.prepareSearch(e,t),r=e.tokens,o=e.options.fields,s=r.length,a=e.options.nesting;function l(e,t){var n,i;return!e||-1===(i=(e=String(e||"")).search(t.regex))?0:(n=t.string.length/e.length,0===i&&(n+=.5),n)}var u,c=(u=o.length)?1===u?function(e,t){return l(f(t,o[0],a),e)}:function(e,t){for(var n=0,i=0;n<u;n++)i+=l(f(t,o[n],a),e);return i/u}:function(){return 0};return s?1===s?function(e){return c(r[0],e)}:"and"===e.options.conjunction?function(e){for(var t,n=0,i=0;n<s;n++){if((t=c(r[n],e))<=0)return 0;i+=t}return i/s}:function(e){for(var t=0,n=0;t<s;t++)n+=c(r[t],e);return n/s}:function(){return 0}},e.prototype.getSortFunction=function(e,n){var t,i,o,r,s,a,l,u=this,c=!(e=u.prepareSearch(e,n)).query&&n.sort_empty||n.sort,p=function(e,t){return"$score"===e?t.score:f(u.items[t.id],e,n.nesting)},d=[];if(c)for(t=0,i=c.length;t<i;t++)!e.query&&"$score"===c[t].field||d.push(c[t]);if(e.query){for(l=!0,t=0,i=d.length;t<i;t++)if("$score"===d[t].field){l=!1;break}l&&d.unshift({field:"$score",direction:"desc"})}else for(t=0,i=d.length;t<i;t++)if("$score"===d[t].field){d.splice(t,1);break}for(a=[],t=0,i=d.length;t<i;t++)a.push("desc"===d[t].direction?-1:1);return(r=d.length)?1===r?(o=d[0].field,s=a[0],function(e,t){return s*h(p(o,e),p(o,t))}):function(e,t){for(var n,i,o=0;o<r;o++)if(i=d[o].field,n=a[o]*h(p(i,e),p(i,t)))return n;return 0}:null},e.prototype.prepareSearch=function(e,t){if("object"==typeof e)return e;var n=(t=r({},t)).fields,i=t.sort,o=t.sort_empty;return n&&!s(n)&&(t.fields=[n]),i&&!s(i)&&(t.sort=[i]),o&&!s(o)&&(t.sort_empty=[o]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e),total:0,items:[]}},e.prototype.search=function(e,n){var i,t,o,r=this,s=this.prepareSearch(e,n);return n=s.options,e=s.query,o=n.score||r.getScoreFunction(s),e.length?r.iterator(r.items,function(e,t){i=o(e),(!1===n.filter||0<i)&&s.items.push({score:i,id:t})}):r.iterator(r.items,function(e,t){s.items.push({score:1,id:t})}),(t=r.getSortFunction(s,n))&&s.items.sort(t),s.total=s.items.length,"number"==typeof n.limit&&(s.items=s.items.slice(0,n.limit)),s};var h=function(e,t){return"number"==typeof e&&"number"==typeof t?t<e?1:e<t?-1:0:(e=n(String(e||"")),(t=n(String(t||"")))<e?1:e<t?-1:0)},r=function(e,t){for(var n,i,o=1,r=arguments.length;o<r;o++)if(i=arguments[o])for(n in i)i.hasOwnProperty(n)&&(e[n]=i[n]);return e},f=function(e,t,n){if(e&&t){if(!n)return e[t];for(var i=t.split(".");i.length&&(e=e[i.shift()]););return e}},a=function(e){return(e+"").replace(/^\s+|\s+$|/g,"")},l=function(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},s=Array.isArray||"undefined"!=typeof $&&$.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},u={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},n=function(){var e,t,n,i,o="",r={};for(n in u)if(u.hasOwnProperty(n))for(o+=i=u[n].substring(2,u[n].length-1),e=0,t=i.length;e<t;e++)r[i.charAt(e)]=n;var s=new RegExp("["+o+"]","g");return function(e){return e.replace(s,function(e){return r[e]}).toLowerCase()}}();return e}),function(e,t){"function"==typeof define&&define.amd?define("microplugin",t):"object"==typeof exports?module.exports=t():e.MicroPlugin=t()}(this,function(){var e={mixin:function(i){i.plugins={},i.prototype.initializePlugins=function(e){var t,n,i,o=[];if(this.plugins={names:[],settings:{},requested:{},loaded:{}},r.isArray(e))for(t=0,n=e.length;t<n;t++)"string"==typeof e[t]?o.push(e[t]):(this.plugins.settings[e[t].name]=e[t].options,o.push(e[t].name));else if(e)for(i in e)e.hasOwnProperty(i)&&(this.plugins.settings[i]=e[i],o.push(i));for(;o.length;)this.require(o.shift())},i.prototype.loadPlugin=function(e){var t=this.plugins,n=i.plugins[e];if(!i.plugins.hasOwnProperty(e))throw new Error('Unable to find "'+e+'" plugin');t.requested[e]=!0,t.loaded[e]=n.fn.apply(this,[this.plugins.settings[e]||{}]),t.names.push(e)},i.prototype.require=function(e){var t=this.plugins;if(!this.plugins.loaded.hasOwnProperty(e)){if(t.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")');this.loadPlugin(e)}return t.loaded[e]},i.define=function(e,t){i.plugins[e]={name:e,fn:t}}}},r={isArray:Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}};return e}),function(e,t){"function"==typeof define&&define.amd?define("tomselect",["sifter","microplugin"],t):"object"==typeof exports?module.exports=t(require("sifter"),require("microplugin")):e.TomSelect=t(e.Sifter,e.MicroPlugin)}(this,function(a,e){"use strict";function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(r){var s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t,n,i,o=p(r);return t=s?(e=p(this).constructor,Reflect.construct(o,arguments,e)):o.apply(this,arguments),n=this,!(i=t)||"object"!==l(i)&&"function"!=typeof i?c(n):i}}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function d(){}d.prototype={on:function(e,t){this._events=this._events||{},this._events[e]=this._events[e]||[],this._events[e].push(t)},off:function(e,t){var n=arguments.length;return 0===n?delete this._events:1===n?delete this._events[e]:(this._events=this._events||{},void(e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(t),1)))},trigger:function(e){if(this._events=this._events||{},e in this._events!=!1)for(var t=0;t<this._events[e].length;t++)this._events[e][t].apply(this,Array.prototype.slice.call(arguments,1))}};function h(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function f(t,n,e){var i,o=t.trigger,r={};for(i in t.trigger=function(){var e=arguments[0];if(-1===n.indexOf(e))return o.apply(t,arguments);r[e]=arguments},e.apply(t,[]),t.trigger=o,r)r.hasOwnProperty(i)&&o.apply(t,r[i])}function g(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!1),e.dispatchEvent(n)}function v(t,n){Object.keys(n).forEach(function(e){t.style[e]=n[e]})}function x(e){var t=C.apply(null,arguments);e=A(e);for(var n,i=0;i<e.length;i++){(n=e[i].classList).add.apply(n,r(t))}}function F(e){var t=C.apply(null,arguments);e=A(e);for(var n,i=0;i<e.length;i++){(n=e[i].classList).remove.apply(n,r(t))}}function O(n,e,i,o){for(var t=e.split(/\s/),r=function(e){var t=S(e.target,i,n);t&&(e.delegateTarget=t,o.call(t,e))},s=0;s<t.length;s++)n.addEventListener(t[s],r,!0)}function m(e,t){if(!e)return-1;t=t||e.nodeName;for(var n=0;e=e.previousElementSibling;)e.matches(t)&&n++;return n}var t=/Mac/.test(navigator.userAgent),y=t?18:17,b=t?"metaKey":"ctrlKey",w=function(u,e){var t,c=Object.assign({},_.defaults,e),p=c.dataAttr,d=c.labelField,h=c.valueField,f=c.disabledField,g=c.optgroupField,v=c.optgroupLabelField,m=c.optgroupValueField,n=u.tagName.toLowerCase(),i=u.getAttribute("placeholder")||u.getAttribute("data-placeholder");i||c.allowEmptyOption||(t=u.querySelector('option[value=""]'))&&(i=t.textContent);var y={placeholder:i,options:[],optgroups:[],items:[]};return("select"===n?function(){function s(e){var t=Object.assign({},e.dataset),n=p&&t[p];return"string"==typeof n&&n.length&&(t=Object.assign(t,JSON.parse(n))),t}function a(e,t){var n,i,o=P(e.value);(o||c.allowEmptyOption)&&(l.hasOwnProperty(o)?t&&((n=l[o][g])?Array.isArray(n)?n.push(t):l[o][g]=[n,t]:l[o][g]=t):((i=s(e))[d]=i[d]||e.textContent,i[h]=i[h]||o,i[f]=i[f]||e.disabled,i[g]=i[g]||t,l[o]=i,r.push(i),e.selected&&y.items.push(o)))}var e,t,n,i,r=y.options,l={};for(y.maxItems=u.hasAttribute("multiple")?null:1,e=0,t=(i=u.children).length;e<t;e++)"optgroup"===(n=i[e].tagName.toLowerCase())?function(e){var t,n=e.getAttribute("label");n&&((t=s(e))[v]=n,t[m]=n,t[f]=e.disabled,y.optgroups.push(t));for(var i,o=0,r=(i=e.children).length;o<r;o++)a(i[o],n)}(i[e]):"option"===n&&a(i[e])}:function(){var e,t,n,i,o=u.getAttribute(p);if(o)for(y.options=JSON.parse(o),e=0,t=y.options.length;e<t;e++)y.items.push(y.options[e][h]);else{var r=u.value.trim()||"";if(!c.allowEmptyOption&&!r.length)return;for(e=0,t=(n=r.split(c.delimiter)).length;e<t;e++)(i={})[d]=n[e],i[h]=n[e],y.options.push(i);y.items=n}})(),Object.assign({},_.defaults,y,e)},P=function(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""},k=function(e){if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(-1<e.indexOf("<")){var t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)},C=function(){for(var e=[],t=1;t<arguments.length;t++){var n=arguments[t];"string"==typeof n&&(n=n.trim().split(/[\11\12\14\15\40]/)),Array.isArray(n)&&(e=e.concat(n))}return e.filter(Boolean)},A=function(e){return Array.isArray(e)||(e=[e]),e},S=function(e,t,n){for(;e&&e.matches;){if(e.matches(t))return e;if(e==n)break;e=e.parentNode}},I=function(e,t){return 0<t?e[e.length-1]:e[0]},_=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(s,d);var e,t,n,r=u(s);function s(e,t){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s);var i=c(n=r.call(this));if((e=k(e)).tomselect)throw new Error("Tom Select already initialized on this element");e.tomselect=i,t=w(e,t);var o=(window.getComputedStyle&&window.getComputedStyle(e,null)).getPropertyValue("direction");return Object.assign(i,{order:0,settings:t,input:e,tabIndex:e.getAttribute("tabindex")||"",is_select_tag:"select"===e.tagName.toLowerCase(),rtl:/rtl/i.test(o),highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:e.required,isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!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:{item:{},option:{}}}),i.settings.load&&i.settings.loadThrottle&&(i.settings.load=i.loadDebounce(i.settings.load,i.settings.loadThrottle)),i.sifter=new a(n.options,{diacritics:t.diacritics}),i.setupOptions(i.settings.options,i.settings.optgroups),delete i.settings.optgroups,delete i.settings.options,i.settings.mode=i.settings.mode||(1===i.settings.maxItems?"single":"multi"),"boolean"!=typeof i.settings.hideSelected&&(i.settings.hideSelected="multi"===i.settings.mode),"string"==typeof i.settings.createFilter&&(i.settings.createFilter=new RegExp(i.settings.createFilter)),i.initializePlugins(i.settings.plugins),i.setupCallbacks(),i.setupTemplates(),i.setup(),n}return e=s,(t=[{key:"setup",value:function(){var n,e,t,i,o,r,s,a,l=this,u=l.settings,c=l.input,p=l.settings.mode,d=c.getAttribute("class")||"",h=k("<div>");if(x(h,u.wrapperClass,d,p),n=k('<div class="items">'),x(n,u.inputClass),h.append(n),t=k('<div style="display:none">'),x(t,u.dropdownClass,p),i=k('<div style="scroll-behavior: smooth;">'),x(i,u.dropdownContentClass),t.append(i),k(u.dropdownParent||h).appendChild(t),u.controlInput)e=k(u.controlInput);else{e=k('<input type="text" autocomplete="off" />');for(var f=["autocorrect","autocapitalize","autocomplete"],g=0;g<f.length;g++){var v=f[g];c.getAttribute(v)&&e.setAttribute(v,c.getAttribute(v))}}u.controlInput||(e.setAttribute("tabindex",c.disabled?"-1":l.tabIndex),n.appendChild(e)),(r=c.getAttribute("id"))&&(e.setAttribute("id",r+"-tomselected"),(s=document.querySelector("label[for='"+r+"']"))&&s.setAttribute("for",r+"-tomselected")),l.settings.copyClassesToDropdown&&x(t,d),h.style.width=c.style.width,l.plugins.names.length&&(o="plugin-"+l.plugins.names.join(" plugin-"),x([h,t],o)),(null===u.maxItems||1<u.maxItems)&&l.is_select_tag&&c.setAttribute("multiple","multiple"),l.settings.placeholder&&e.setAttribute("placeholder",u.placeholder),!l.settings.splitOn&&l.settings.delimiter&&(a=l.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),l.settings.splitOn=new RegExp("\\s*"+a+"+\\s*")),e.type=c.type,l.control=n,l.control_input=e,l.wrapper=h,l.dropdown=t,l.dropdown_content=i,O(t,"mouseenter","[data-selectable]",function(){return l.onOptionHover.apply(l,arguments)}),O(t,"mousedown","[data-selectable]",function(){return l.onOptionSelect.apply(l,arguments)}),n.addEventListener("mousedown",function(e){var t=S(e.target,"."+l.settings.itemClass,n);return t?(e.delegateTarget=t,l.onItemSelect.call(l,e)):l.onMouseDown.call(l,e)}),n.addEventListener("click",function(){return l.onClick.apply(l,arguments)}),e.addEventListener("mousedown",function(e){e.stopPropagation()}),e.addEventListener("keydown",function(){return l.onKeyDown.apply(l,arguments)}),e.addEventListener("keyup",function(){return l.onKeyUp.apply(l,arguments)}),e.addEventListener("keypress",function(){return l.onKeyPress.apply(l,arguments)}),e.addEventListener("resize",function(){l.positionDropdown.apply(l,[])}),e.addEventListener("blur",function(){return l.onBlur.apply(l,arguments)}),e.addEventListener("focus",function(){return l.ignoreBlur=!1,l.onFocus.apply(l,arguments)}),e.addEventListener("paste",function(){return l.onPaste.apply(l,arguments)});function m(e){if(l.isFocused){if(S(e.target,"."+l.settings.wrapperClass,l.wrapper))return!1;l.blur(e.target)}}function y(){l.isOpen&&l.positionDropdown.apply(l,arguments)}function b(){l.ignoreHover=!1}document.addEventListener("mousedown",m),window.addEventListener("sroll",y),window.addEventListener("resize",y),window.addEventListener("mousemove",b),l._destroy=function(){document.removeEventListener("mousedown",m),window.removeEventListener("mousemove",b),window.removeEventListener("sroll",y),window.removeEventListener("resize",y)};for(var w=[];0<c.children.length;)w.push(c.children[0]),c.children[0].remove();this.revertSettings={children:w,tabindex:c.getAttribute("tabindex")},c.setAttribute("tabindex",-1),c.setAttribute("hidden","hidden"),c.insertAdjacentElement("afterend",l.wrapper),l.setValue(u.items),delete u.items,l.supportsValidity()&&c.addEventListener("invalid",function(e){e.preventDefault(),l.isInvalid=!0,l.refreshState()}),l.updateOriginalInput(),l.refreshItems(),l.refreshState(),l.isSetup=!0,c.disabled&&l.disable(),l.on("change",this.onChange),x(c,"tomselected"),l.trigger("initialize"),!0===u.preload&&l.onSearchChange("")}},{key:"supportsValidity",value:function(){return!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity}},{key:"setupOptions",value:function(e,t){var n,i;for(t=t||[],n=0,i=(e=e||[]).length;n<i;n++)this.registerOption(e[n]);for(n=0,i=t.length;n<i;n++)this.registerOptionGroup(t[n])}},{key:"setupTemplates",value:function(){var n=this.settings.labelField,i=this.settings.optgroupLabelField,e={optgroup:function(e,t){var n=document.createElement("div");return n.className="optgroup",n.appendChild(e.options),n},optgroup_header:function(e,t){return'<div class="optgroup-header">'+t(e[i])+"</div>"},option:function(e,t){return"<div>"+t(e[n])+"</div>"},item:function(e,t){return"<div>"+t(e[n])+"</div>"},option_create:function(e,t){return'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>"},no_results:function(){return'<div class="no-results">No results found</div>'}};this.settings.render=Object.assign({},e,this.settings.render)}},{key:"setupCallbacks",value:function(){var e,t,n={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(e in n)(t=this.settings[n[e]])&&this.on(e,t)}},{key:"onClick",value:function(e){this.isFocused&&this.isOpen||(this.focus(),e.preventDefault())}},{key:"onMouseDown",value:function(e){var t=this;if(t.isFocused){if(e.target!==t.control_input)return"single"===t.settings.mode?t.isOpen?t.close():t.open():t.setActiveItem(null),!1}else window.setTimeout(function(){t.focus()},0)}},{key:"onChange",value:function(){g(this.input,"change")}},{key:"onPaste",value:function(e){var o=this;o.isFull()||o.isInputHidden||o.isLocked?e.preventDefault():o.settings.splitOn&&setTimeout(function(){var e=o.inputValue();if(e.match(o.settings.splitOn))for(var t=e.trim().split(o.settings.splitOn),n=0,i=t.length;n<i;n++)o.createItem(t[n])},0)}},{key:"onKeyPress",value:function(e){if(this.isLocked)return e&&e.preventDefault();var t=String.fromCharCode(e.keyCode||e.which);return this.settings.create&&"multi"===this.settings.mode&&t===this.settings.delimiter?(this.createItem(),e.preventDefault(),!1):void 0}},{key:"onKeyDown",value:function(e){e.target,this.control_input;var t,n,i=this;if(i.isLocked)9!==e.keyCode&&e.preventDefault();else{switch(e.keyCode){case 65:if(i.isKeyDown(y,e))return void i.selectAll();break;case 27:return void(i.isOpen&&(e.preventDefault(),e.stopPropagation(),i.close()));case 40:return!i.isOpen&&i.hasOptions?i.open():i.activeOption&&(i.ignoreHover=!0,(t=i.getAdjacent(i.activeOption,1))&&i.setActiveOption(t,!0)),void e.preventDefault();case 38:return i.activeOption&&(i.ignoreHover=!0,(n=i.getAdjacent(i.activeOption,-1))&&i.setActiveOption(n,!0)),void e.preventDefault();case 13:return void(i.isOpen&&i.activeOption&&(i.onOptionSelect({delegateTarget:i.activeOption}),e.preventDefault()));case 37:return void i.advanceSelection(-1,e);case 39:return void i.advanceSelection(1,e);case 9:return i.settings.selectOnTab&&i.isOpen&&i.activeOption&&(i.onOptionSelect({delegateTarget:i.activeOption}),e.preventDefault()),void(i.settings.create&&i.createItem()&&e.preventDefault());case 8:case 46:return void i.deleteSelection(e)}!i.isInputHidden||i.isKeyDown(y,e)||e.preventDefault()}}},{key:"onKeyUp",value:function(e){var t=this;if(t.isLocked)return e&&e.preventDefault();var n=t.inputValue();t.lastValue!==n&&(t.lastValue=n,t.onSearchChange(n),t.refreshOptions(),t.trigger("type",n))}},{key:"onSearchChange",value:function(t){var n=this,i=n.settings.load;i&&(n.loadedSearches.hasOwnProperty(t)||(n.loadedSearches[t]=!0,n.load(function(e){i.apply(n,[t,e])})))}},{key:"onFocus",value:function(e){var t=this,n=t.isFocused;if(t.isDisabled)return t.blur(),e&&e.preventDefault(),!1;t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.onSearchChange(""),n||t.trigger("focus"),t.activeItems.length||(t.showInput(),t.setActiveItem(null),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}},{key:"onBlur",value:function(e,t){var n=this;if(n.isFocused){if(n.isFocused=!1,n.ignoreFocus=!1,!n.ignoreBlur&&document.activeElement===n.dropdown_content)return n.ignoreBlur=!0,void n.onFocus(e);var i=function(){n.close(),n.setActiveItem(null),n.setActiveOption(null),n.setCaret(n.items.length),n.refreshState(),t&&t.focus&&t.focus(),n.isBlurring=!1,n.trigger("blur")};n.isBlurring=!0,n.settings.create&&n.settings.createOnBlur?n.createItem(null,!1,i):i()}}},{key:"onOptionHover",value:function(e){this.ignoreHover||this.setActiveOption(e.delegateTarget,!1)}},{key:"onOptionSelect",value:function(e){var t,n=this;e.preventDefault&&(e.preventDefault(),e.stopPropagation());var i=e.delegateTarget;i&&(i.parentNode&&i.parentNode.matches("[data-disabled]")||(i.classList.contains("create")?n.createItem(null,function(){n.settings.closeAfterSelect&&n.close()}):void 0!==(t=i.dataset.value)&&(n.lastQuery=null,n.addItem(t),n.settings.closeAfterSelect?n.close():!n.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&n.setActiveOption(n.getOption(t)))))}},{key:"onItemSelect",value:function(e){this.isLocked||"multi"===this.settings.mode&&(e.preventDefault(),this.setActiveItem(e.delegateTarget,e))}},{key:"load",value:function(e){var n=this;x(n.wrapper,n.settings.loadingClass),n.loading++,e.apply(n,[function(e,t){n.loading=Math.max(n.loading-1,0),n.setupOptions(e,t),n.refreshOptions(n.isFocused&&!n.isInputHidden),n.loading||F(n.wrapper,n.settings.loadingClass),n.trigger("load",e)}])}},{key:"loadDebounce",value:function(n,i){var o;return function(){var e=this,t=arguments;o&&(e.loading=Math.max(e.loading-1,0)),window.clearTimeout(o),o=window.setTimeout(function(){o=null,n.apply(e,t)},i)}}},{key:"setTextboxValue",value:function(e){var t=this.control_input;t.value!==e&&(t.value=e,g(t,"update"),this.lastValue=e)}},{key:"getValue",value:function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}},{key:"setValue",value:function(e,t){f(this,t?[]:["change"],function(){this.clear(t),this.addItems(e,t)})}},{key:"setActiveItem",value:function(e,t){var n,i,o,r,s,a;if("single"!==this.settings.mode){if(!e)return F(this.activeItems,"active"),this.activeItems=[],void(this.isFocused&&this.showInput());if("mousedown"===(n=t&&t.type.toLowerCase())&&this.isKeyDown(16,t)&&this.activeItems.length){for(a=this.getLastActive(),o=Array.prototype.indexOf.apply(this.control.children,[a]),(r=Array.prototype.indexOf.apply(this.control.children,[e]))<o&&(s=o,o=r,r=s),i=o;i<=r;i++)e=this.control.children[i],-1===this.activeItems.indexOf(e)&&this.setActiveItemClass(e);t.preventDefault()}else"mousedown"===n&&this.isKeyDown(y,t)||"keydown"===n&&this.isKeyDown(16,t)?e.classList.contains("active")?this.removeActiveItem(e):this.setActiveItemClass(e):(F(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(e));this.hideInput(),this.isFocused||this.focus()}}},{key:"setActiveItemClass",value:function(e){var t=this.control.querySelector(".last-active");t&&F(t,"last-active"),x(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}},{key:"removeActiveItem",value:function(e){var t=this.activeItems.indexOf(e);this.activeItems.splice(t,1),F(e,"active")}},{key:"setActiveOption",value:function(e,t){var n,i,o;e!==this.activeOption&&(this.activeOption&&F(this.activeOption,"active"),this.activeOption=null,e&&(this.activeOption=e,x(e,"active"),!t&&void 0!==t||(n=this.dropdown_content.clientHeight,t=this.dropdown_content.scrollTop||0,i=this.activeOption.offsetHeight,n+t<(o=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+t)+i?this.dropdown_content.scrollTop=o-n+i:o<t&&(this.dropdown_content.scrollTop=o))))}},{key:"selectAll",value:function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(x(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}},{key:"hideInput",value:function(){this.settings.controlInput||(this.setTextboxValue(""),v(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)}},{key:"showInput",value:function(){this.settings.controlInput||(v(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)}},{key:"inputValue",value:function(){return this.control_input.value.trim()}},{key:"focus",value:function(){var e=this;e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),window.setTimeout(function(){e.ignoreFocus=!1,e.onFocus()},0))}},{key:"blur",value:function(e){this.control_input.blur(),this.onBlur(null,e)}},{key:"getScoreFunction",value:function(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}},{key:"getSearchOptions",value:function(){var e=this.settings,t=e.sortField;return"string"==typeof t&&(t=[{field:t}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}},{key:"search",value:function(e){var t,n,i,o=this,r=o.settings,s=this.getSearchOptions();if(r.score&&"function"!=typeof(i=o.settings.score.apply(this,[e])))throw new Error('Tom Select "score" setting must be a function that returns a function');if(e!==o.lastQuery?(o.lastQuery=e,n=o.sifter.search(e,Object.assign(s,{score:i})),o.currentResults=n):n=Object.assign({},o.currentResults),r.hideSelected)for(t=n.items.length-1;0<=t;t--)-1!==o.items.indexOf(P(n.items[t].id))&&n.items.splice(t,1);return n}},{key:"refreshOptions",value:function(e){var t,n,i,o,r,s;void 0===e&&(e=!0);var a,l,u,c,p,d,h,f=this,g=f.inputValue(),v=f.search(g),m=f.activeOption&&P(f.activeOption.dataset.value),y=!1,b=v.items.length;for("number"==typeof f.settings.maxOptions&&(b=Math.min(b,f.settings.maxOptions)),0<b&&(y=!0),n={},i=[],t=0;t<b;t++)for(var w,O=f.options[v.items[t].id],k=P(O[f.settings.valueField]),C=(C=f.getOption(k))||f.render("option",O),A=O[f.settings.optgroupField]||"",S=0,I=(w=Array.isArray(A)?A:[A])&&w.length;S<I;S++)A=w[S],f.optgroups.hasOwnProperty(A)||(A=""),n.hasOwnProperty(A)||(n[A]=document.createDocumentFragment(),i.push(A)),0<S&&(C=C.cloneNode(!0),F(C,"active")),n[A].appendChild(C);for(this.settings.lockOptgroupOrder&&i.sort(function(e,t){return(f.optgroups[e].$order||0)-(f.optgroups[t].$order||0)}),o=document.createDocumentFragment(),t=0,b=i.length;t<b;t++){A=i[t],f.optgroups.hasOwnProperty(A)&&n[A].children.length?((a=document.createDocumentFragment()).appendChild(f.render("optgroup_header",f.optgroups[A])),a.appendChild(n[A]),l=f.render("optgroup",{group:f.optgroups[A],options:a}),o.appendChild(l)):o.appendChild(n[A])}if(f.dropdown_content.innerHTML="",f.dropdown_content.appendChild(o),f.settings.highlight&&(f.dropdown_content,u=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(u,function(e,t){var n=e.parentNode;n.replaceChild(e.firstChild,e),n.normalize()}),v.query.length&&v.tokens.length))for(t=0,b=v.tokens.length;t<b;t++)!function(e,t){var u,n;"string"==typeof t&&!t.length||(u="string"==typeof t?new RegExp(t,"i"):t,n=function e(t){var n=0;if(3===t.nodeType){var i,o,r,s,a=t.data.search(u);0<=a&&0<t.data.length&&(i=t.data.match(u),(o=document.createElement("span")).className="highlight",(r=t.splitText(a)).splitText(i[0].length),s=r.cloneNode(!0),o.appendChild(s),r.parentNode.replaceChild(o,r),n=1)}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var l=0;l<t.childNodes.length;++l)l+=e(t.childNodes[l]);return n},n(e))}(f.dropdown_content,v.tokens[t].regex);if(!f.settings.hideSelected)for(t=0,b=f.items.length;t<b;t++){var _=f.getOption(f.items[t]);_&&x(_,"selected")}0===v.items.length&&f.settings.render.no_results&&!f.loading&&g.length&&(c=f.render("no_results",{input:g}),y=!0,f.dropdown_content.insertBefore(c,f.dropdown_content.firstChild)),(r=f.canCreate(g))&&(y=!0,s=f.render("option_create",{input:g}),f.dropdown_content.insertBefore(s,f.dropdown_content.firstChild)),f.hasOptions=0<v.items.length||r,y?(h=0<v.items.length?(d=m&&f.getOption(m))&&f.dropdown_content.contains(d)?d:"single"===f.settings.mode&&f.items.length?f.getOption(f.items[0]):(p=0,s&&!f.settings.addPrecedence&&(p=1),f.selectable()[p]):s,f.setActiveOption(h),e&&!f.isOpen&&f.open()):(f.setActiveOption(null),e&&f.isOpen&&f.close())}},{key:"selectable",value:function(){return this.dropdown_content.querySelectorAll("[data-selectable]")}},{key:"addOption",value:function(e){var t,n,i,o=this;if(Array.isArray(e))for(t=0,n=e.length;t<n;t++)o.addOption(e[t]);else(i=o.registerOption(e))&&(o.userOptions[i]=!0,o.lastQuery=null,o.trigger("option_add",i,e))}},{key:"registerOption",value:function(e){var t=P(e[this.settings.valueField]);return null!=t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,this.options[t]=e,t)}},{key:"registerOptionGroup",value:function(e){var t=P(e[this.settings.optgroupValueField]);return!!t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}},{key:"addOptionGroup",value:function(e,t){t[this.settings.optgroupValueField]=e,(e=this.registerOptionGroup(t))&&this.trigger("optgroup_add",e,t)}},{key:"removeOptionGroup",value:function(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}},{key:"clearOptionGroups",value:function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}},{key:"updateOption",value:function(e,t){var n,i,o,r,s,a,l,u=this;if(e=P(e),o=P(t[u.settings.valueField]),null!==e&&u.options.hasOwnProperty(e)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=u.options[e].$order,o!==e&&(delete u.options[e],-1!==(r=u.items.indexOf(e))&&u.items.splice(r,1,o)),t.$order=t.$order||l,u.options[o]=t,s=u.renderCache.item,a=u.renderCache.option,s&&(delete s[e],delete s[o]),a&&(delete a[e],delete a[o]),-1!==u.items.indexOf(o)&&(n=u.getItem(e),i=u.render("item",t),n.classList.contains("active")&&x(i,"active"),n.parentNode.insertBefore(i,n),n.remove()),u.lastQuery=null,u.isOpen&&u.refreshOptions(!1)}}},{key:"removeOption",value:function(e,t){var n=this;e=P(e);var i=n.renderCache.item,o=n.renderCache.option;i&&delete i[e],o&&delete o[e],delete n.userOptions[e],delete n.options[e],n.lastQuery=null,n.trigger("option_remove",e),n.removeItem(e,t)}},{key:"clearOptions",value:function(){this.loadedSearches={},this.userOptions={},this.clearCache();var e={};for(var t in this.options)this.options.hasOwnProperty(t)&&0<=this.items.indexOf(t)&&(e[t]=this.options[t]);this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}},{key:"getOption",value:function(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}},{key:"getAdjacent",value:function(e,t,n){var i=2<arguments.length&&void 0!==n?n:"option";if(e){var o=this.settings.optionClass,r=this.dropdown;"item"==i&&(r=this.control,o=this.settings.itemClass);for(var s=r.querySelectorAll("."+o),a=0;a<s.length;a++)if(s[a]==e)return 0<t?s[a+1]:s[a-1]}}},{key:"getElementWithValue",value:function(e,t){if(null!=(e=P(e)))for(var n=0,i=t.length;n<i;n++)if(t[n].getAttribute("data-value")===e)return t[n]}},{key:"getItem",value:function(e){return this.getElementWithValue(e,this.control.children)}},{key:"addItems",value:function(e,t){this.buffer=document.createDocumentFragment();for(var n=this.control.children,i=0;i<n.length;i++)this.buffer.appendChild(n[i]);for(var o=Array.isArray(e)?e:[e],i=0,r=o.length;i<r;i++)this.isPending=i<r-1,this.addItem(o[i],t);var s=this.control;s.insertBefore(this.buffer,s.firstChild),this.buffer=null}},{key:"addItem",value:function(a,l){f(this,l?[]:["change"],function(){var e,t,n,i,o,r=this,s=r.settings.mode;a=P(a),(-1===r.items.indexOf(a)||("single"===s&&r.close(),"single"!==s&&r.settings.duplicates))&&r.options.hasOwnProperty(a)&&("single"===s&&r.clear(l),"multi"===s&&r.isFull()||(o=r.render("item",r.options[a]),this.control.contains(o)&&(o=o.cloneNode(!0)),e=r.isFull(),r.items.splice(r.caretPos,0,a),r.insertAtCaret(o),r.isPending&&(e||!r.isFull())||r.refreshState(),r.isSetup&&(t=r.selectable(),r.isPending||(n=r.getOption(a),i=r.getAdjacent(n,1),r.refreshOptions(r.isFocused&&"single"!==s),i&&r.setActiveOption(i)),!t.length||r.isFull()?r.close():r.isPending||r.positionDropdown(),r.trigger("item_add",a,o),r.isPending||r.updateOriginalInput({silent:l}))))})}},{key:"removeItem",value:function(e,t){var n,i,o=this.getItem(e);o&&(e=P(o.dataset.value),-1!==(n=this.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(i=this.activeItems.indexOf(o),this.activeItems.splice(i,1),F(o,"active")),this.items.splice(n,1),this.lastQuery=null,!this.settings.persist&&this.userOptions.hasOwnProperty(e)&&this.removeOption(e,t),n<this.caretPos&&this.setCaret(this.caretPos-1),this.refreshState(),this.updateOriginalInput({silent:t}),this.positionDropdown(),this.trigger("item_remove",e,o)))}},{key:"createItem",value:function(e,n){var t,i=this,o=i.caretPos;e=e||i.inputValue();var r=arguments[arguments.length-1];if("function"!=typeof r&&(r=function(){}),"boolean"!=typeof n&&(n=!0),!i.canCreate(e))return r(),!1;i.lock();function s(e){if(i.unlock(),!e||"object"!==l(e))return r();var t=P(e[i.settings.valueField]);if("string"!=typeof t)return r();i.setTextboxValue(""),i.addOption(e),i.setCaret(o),i.addItem(t),i.refreshOptions(n&&"single"!==i.settings.mode),r(e),a=!0}var a=!1;return"function"==typeof i.settings.create?t=i.settings.create.apply(this,[e,s]):((t={})[i.settings.labelField]=e,t[i.settings.valueField]=e),a||s(t),!0}},{key:"refreshItems",value:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()}},{key:"refreshState",value:function(){var e=this;e.refreshValidityState();var t=e.isFull(),n=e.isLocked;e.wrapper.classList.toggle("rtl",e.rtl);var i,o=e.control.classList;o.toggle("focus",e.isFocused),o.toggle("disabled",e.isDisabled),o.toggle("required",e.isRequired),o.toggle("invalid",e.isInvalid),o.toggle("locked",n),o.toggle("full",t),o.toggle("not-full",!t),o.toggle("input-active",e.isFocused&&!e.isInputHidden),o.toggle("dropdown-active",e.isOpen),o.toggle("has-options",(i=e.options,0===Object.keys(i).length)),o.toggle("has-items",0<e.items.length)}},{key:"refreshValidityState",value:function(){if(!this.isRequired)return!1;var e=!this.items.length;this.isInvalid=e,this.control_input.required=e,this.input.required=!e}},{key:"isFull",value:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}},{key:"updateOriginalInput",value:function(e){var t,n,i,o,r=this;if(e=e||{},r.is_select_tag){for(i=[],t=0,n=r.items.length;t<n;t++)o=r.options[r.items[t]][r.settings.labelField]||"",i.push('<option value="'+h(r.items[t])+'" selected="selected">'+h(o)+"</option>");i.length||this.input.hasAttribute("multiple")||i.push('<option value="" selected="selected"></option>'),r.input.innerHTML=i.join("")}else r.input.value=r.getValue(),r.input.setAttribute("value",r.input.value);r.isSetup&&(e.silent||r.trigger("change",r.input.value))}},{key:"open",value:function(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.focus(),e.isOpen=!0,e.refreshState(),v(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),v(e.dropdown,{visibility:"visible",display:"block"}),e.trigger("dropdown_open",e.dropdown))}},{key:"close",value:function(){var e=this,t=e.isOpen;"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.isBlurring||e.blur()),e.isOpen=!1,v(e.dropdown,{display:"none"}),e.setActiveOption(null),e.refreshState(),t&&e.trigger("dropdown_close",e.dropdown)}},{key:"positionDropdown",value:function(){var e,t=0,n=this.control,i=n.offsetHeight;"body"===this.settings.dropdownParent?(i+=(e=n.getBoundingClientRect()).top+window.scrollY,t=e.left+window.scrollX):this.settings.dropdownParent?i=(n=k(this.settings.dropdownParent)).offsetHeight:(i+=n.offsetTop,t=n.offsetLeft),v(this.dropdown,{width:n.getBoundingClientRect().width+"px",top:i+"px",left:t+"px"})}},{key:"clear",value:function(e){if(this.items.length){for(var t=this.controlChildren(),n=0;n<t.length;n++)t[n].remove();this.items=[],this.lastQuery=null,this.setCaret(0),this.setActiveItem(null),this.updateOriginalInput({silent:e}),this.refreshState(),this.showInput(),this.trigger("clear")}}},{key:"insertAtCaret",value:function(e){var t=Math.min(this.caretPos,this.items.length),n=this.buffer||this.control;0===t?n.insertBefore(e,n.firstChild):n.insertBefore(e,n.children[t]),this.setCaret(t+1)}},{key:"deleteSelection",value:function(e){var t,n,i,o,r,s=this,a=e&&8===e.keyCode?-1:1,l={start:(r=s.control_input).selectionStart,length:r.selectionEnd-r.selectionStart},u=[];if(s.activeItems.length){for(o=I(s.activeItems,a),i=m(o),0<a&&i++,t=0,n=s.activeItems.length;t<n;t++)u.push(s.activeItems[t].dataset.value);e&&(e.preventDefault(),e.stopPropagation())}else(s.isFocused||"single"===s.settings.mode)&&s.items.length&&(a<0&&0===l.start&&0===l.length?u.push(s.items[s.caretPos-1]):0<a&&l.start===s.inputValue().length&&u.push(s.items[s.caretPos]));if(!u.length||"function"==typeof s.settings.onDelete&&!1===s.settings.onDelete.apply(s,[u,e]))return!1;for(void 0!==i&&s.setCaret(i);u.length;)s.removeItem(u.pop());return s.showInput(),s.positionDropdown(),s.refreshOptions(!1),!0}},{key:"advanceSelection",value:function(e,t){var n,i,o;0!==e&&(this.rtl&&(e*=-1),this.isKeyDown(y,t)||this.isKeyDown(16,t)?(i=this.getLastActive(e),(o=this.getAdjacent(i,e,"item"))&&(o.classList.contains("active")&&this.removeActiveItem(i),this.setActiveItemClass(o))):this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+e):(i=this.getLastActive(e))&&(n=m(i),this.setCaret(0<e?n+1:n),this.setActiveItem(null)))}},{key:"getLastActive",value:function(e){var t=this.control.querySelector(".last-active");return t||function(e,t,n){var i=e.querySelectorAll(t);if(i)return I(i,n)}(this.control,".active",e)}},{key:"setCaret",value:function(e){var t=this;if(e="single"===t.settings.mode||t.settings.controlInput?t.items.length:Math.max(0,Math.min(t.items.length,e)),!t.settings.controlInput&&!t.isPending)for(var n,i=this.controlChildren(),o=i.length,r=0;r<o;r++)n=i[r],r<e?t.control_input.insertAdjacentElement("beforebegin",n):t.control.appendChild(n);t.caretPos=e}},{key:"controlChildren",value:function(){return Array.prototype.filter.call(this.control.children,function(e){return"INPUT"!==e.nodeName})}},{key:"lock",value:function(){this.close(),this.isLocked=!0,this.refreshState()}},{key:"unlock",value:function(){this.isLocked=!1,this.refreshState()}},{key:"disable",value:function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()}},{key:"enable",value:function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()}},{key:"destroy",value:function(){var e=this.revertSettings;this.trigger("destroy"),this.off(),this.wrapper.remove(),this.dropdown.remove(),this.input.innerHTML="",e.tabindex?this.input.setAttribute("tabindex",e.tabindex):this.input.removeAttribute("tabindex"),F(this.input,"tomselected"),this.input.removeAttribute("hidden");for(var t=0;t<e.children.length;t++)this.input.appendChild(e.children[t]);this._destroy(),delete this.input.tomselect}},{key:"render",value:function(e,t){var n,i,o="",r=this;return"option"!==e&&"item"!==e||(n=P(t[r.settings.valueField]),!r.renderCache[e].hasOwnProperty(n))?(o=k(r.settings.render[e].apply(this,[t,h])),"option"===e||"option_create"===e?t[r.settings.disabledField]||o.setAttribute("data-selectable",""):"optgroup"===e&&(i=t.group[r.settings.optgroupValueField],o.setAttribute("data-group",i),t.group[r.settings.disabledField]&&o.setAttribute("data-disabled","")),"option"!==e&&"item"!==e||(o.setAttribute("data-value",n),x(o,"item"===e?r.settings.itemClass:r.settings.optionClass),r.renderCache[e][n]=o),o):r.renderCache[e][n]}},{key:"clearCache",value:function(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}},{key:"canCreate",value:function(e){if(!this.settings.create)return!1;var t=this.settings.createFilter;return e.length&&("function"!=typeof t||t.apply(this,[e]))&&(!(t instanceof RegExp)||t.test(e))}},{key:"isKeyDown",value:function(e,t){return!!t&&(!t.altKey&&((!t[b]||!t.shiftKey)&&(!(e!=y||!t[b])||!(16!=e||!t.shiftKey))))}},{key:"hook",value:function(n,e,i){var o=this,r=o[e];o[e]=function(){var e,t;return"after"===n&&(e=r.apply(o,arguments)),t=i.apply(o,arguments),"instead"===n?t:("before"===n&&(e=r.apply(o,arguments)),e)}}}])&&i(e.prototype,t),n&&i(e,n),s}();if(void 0===e)throw'Dependency MicroPlugin is missing. Make sure you either: (1) are using the "complete" version of Tom Select, or (2) require MicroPlugin before you load Tom Select.';return e.mixin(_),_.count=0,_.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,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"tomselect-control",inputClass:"tomselect-input",dropdownClass:"tomselect-dropdown",dropdownContentClass:"tomselect-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}},_.define("change_listener",function(e){var t=this,n=!1;t.input.addEventListener("change",function(){var e;n?n=!1:(n=!0,e=w(t.input,{}),t.setupOptions(e.options,e.optgroups),t.setValue(e.items))})}),_.define("drag_drop",function(e){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');var t,n,i;"multi"===this.settings.mode&&(n=(t=this).lock,i=t.unlock,t.hook("instead","lock",function(){var e=t.control.dataset.sortable;return e&&e.disable(),n.apply(t,arguments)}),t.hook("instead","unlock",function(){var e=t.control.dataset.sortable;return e&&e.enable(),i.apply(t,arguments)}),t.hook("after","setup",function(){var n=$(t.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:t.isLocked,start:function(e,t){t.placeholder.css("width",t.helper.css("width")),n.css({overflow:"visible"})},stop:function(){n.css({overflow:"hidden"});var e=[];n.children("[data-value]").each(function(){e.push($(this).attr("data-value"))}),t.setValue(e)}})}))}),_.define("dropdown_header",function(t){var n=this;t=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:function(e){return'<div class="'+e.headerClass+'"><div class="'+e.titleRowClass+'"><span class="'+e.labelClass+'">'+e.title+'</span><a href="javascript:void(0)" class="'+e.closeClass+'">&times;</a></div></div>'}},t),n.hook("after","setup",function(){var e=k(t.html(t));n.dropdown.insertBefore(e,n.dropdown.firstChild)})}),_.define("input_autogrow",function(e){var a=this;a.hook("after","setup",function(){var e=document.createElement("span"),t=this.control_input;e.style.position="absolute",e.style.top="-99999px",e.style.left="-99999px",e.style.width="auto",e.style.padding=0,e.style.whiteSpace="pre",a.wrapper.appendChild(e);for(var n=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"],i=0,o=n.length;i<o;i++){var r=n[i];e.style[r]=t.style[r]}function s(){e.textContent=t.value,t.style.width=e.clientWidth+"px"}t.addEventListener("input",s),t.addEventListener("keyup",s),t.addEventListener("blur",s),t.addEventListener("update",s)})}),_.define("no_backspace_delete",function(e){this.hook("instead","setActiveItem",function(){}),this.hook("instead","selectAll",function(){}),this.hook("instead","deleteSelection",function(){})}),_.define("optgroup_columns",function(e){var r=this,s=r.onKeyDown;r.hook("instead","onKeyDown",function(e){var t,n,i,o;return!r.isOpen||37!==e.keyCode&&39!==e.keyCode?s.apply(r,arguments):(r.ignoreHover=!0,o=S(r.activeOption,"[data-group]"),t=m(r.activeOption,"[data-selectable]"),void((o=37===e.keyCode?o.previousSibling:o.nextSibling)&&(n=(i=o.querySelectorAll("[data-selectable]"))[Math.min(i.length-1,t)])&&r.setActiveOption(n)))})}),_.define("remove_button",function(e){e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e);var i,o=this;e.append&&(i='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+h(e.title)+'">'+e.label+"</a>",o.hook("after","setupTemplates",function(){var t=o.settings.render.item;o.settings.render.item=function(){var n=k(t.apply(o,arguments)),e=k(i);return n.appendChild(e),e.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation()}),e.addEventListener("click",function(e){var t;e.preventDefault(),e.stopPropagation(),"single"!==o.settings.mode&&e.stopPropagation(),o.isLocked||(t=n.dataset.value,o.removeItem(t),o.refreshOptions(!1))}),n}}))}),_.define("restore_on_backspace",function(i){var o=this;i.text=i.text||function(e){return e[o.settings.labelField]};var r=o.onKeyDown;o.hook("instead","onKeyDown",function(e){var t,n;return 8===e.keyCode&&""===o.control_input.value&&!o.activeItems.length&&0<=(t=o.caretPos-1)&&t<o.items.length?(n=o.options[o.items[t]],o.deleteSelection(e)&&(o.setTextboxValue(i.text.apply(o,[n])),o.refreshOptions(!0)),void e.preventDefault()):r.apply(o,arguments)})}),_});var tomSelect=function(e,t){return new TomSelect(e,t)};
/*! tom-select.js - v1.0.0-b.1 | https://github.com/orchidjs/tom-select | Apache License (v2) */
!function(t,e){"function"==typeof define&&define.amd?define(["sifter","microplugin"],e):"object"==typeof exports?module.exports=e(require("sifter"),require("microplugin")):t.TomSelect=e(t.Sifter,t.MicroPlugin)}(this,function(r,t){"use strict";function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function s(){}s.prototype={on:function(t,e){this._events=this._events||{},this._events[t]=this._events[t]||[],this._events[t].push(e)},off:function(t,e){var i=arguments.length;return 0===i?delete this._events:1===i?delete this._events[t]:(this._events=this._events||{},void(t in this._events!=!1&&this._events[t].splice(this._events[t].indexOf(e),1)))},trigger:function(t){if(this._events=this._events||{},t in this._events!=!1)for(var e=0;e<this._events[t].length;e++)this._events[t][e].apply(this,Array.prototype.slice.call(arguments,1))}},s.mixin=function(t){for(var e=["on","off","trigger"],i=0;i<e.length;i++)t.prototype[e[i]]=s.prototype[e[i]]};function l(u,t){var e,c=Object.assign({},E.defaults,t),d=c.dataAttr,p=c.labelField,h=c.valueField,g=c.disabledField,f=c.optgroupField,v=c.optgroupLabelField,m=c.optgroupValueField,i=u.tagName.toLowerCase(),n=u.getAttribute("placeholder")||u.getAttribute("data-placeholder");n||c.allowEmptyOption||(e=u.querySelector('option[value=""]'))&&(n=e.textContent);var y={placeholder:n,options:[],optgroups:[],items:[]};return("select"===i?function(){function r(t){var e=Object.assign({},t.dataset),i=d&&e[d];return"string"==typeof i&&i.length&&(e=Object.assign(e,JSON.parse(i))),e}function l(t,e){var i,n,o=k(t.value);(o||c.allowEmptyOption)&&(a.hasOwnProperty(o)?e&&((i=a[o][f])?Array.isArray(i)?i.push(e):a[o][f]=[i,e]:a[o][f]=e):((n=r(t))[p]=n[p]||t.textContent,n[h]=n[h]||o,n[g]=n[g]||t.disabled,n[f]=n[f]||e,a[o]=n,s.push(n),t.selected&&y.items.push(o)))}var t,e,i,n,s=y.options,a={};for(y.maxItems=u.hasAttribute("multiple")?null:1,t=0,e=(n=u.children).length;t<e;t++)"optgroup"===(i=n[t].tagName.toLowerCase())?function(t){var e,i=t.getAttribute("label");i&&((e=r(t))[v]=i,e[m]=i,e[g]=t.disabled,y.optgroups.push(e));for(var n,o=0,s=(n=t.children).length;o<s;o++)l(n[o],i)}(n[t]):"option"===i&&l(n[t])}:function(){var t,e,i,n,o=u.getAttribute(d);if(o)for(y.options=JSON.parse(o),t=0,e=y.options.length;t<e;t++)y.items.push(y.options[t][h]);else{var s=u.value.trim()||"";if(!c.allowEmptyOption&&!s.length)return;for(t=0,e=(i=s.split(c.delimiter)).length;t<e;t++)(n={})[p]=i[t],n[h]=i[t],y.options.push(n);y.items=i}})(),L(!0,{},E.defaults,y,t)}function a(t){return(t+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function i(e,i,t){var n,o=e.trigger,s={};for(n in e.trigger=function(){var t=arguments[0];if(-1===i.indexOf(t))return o.apply(e,arguments);s[t]=arguments},t.apply(e,[]),e.trigger=o,s)s.hasOwnProperty(n)&&o.apply(e,s[n])}function O(t){if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(-1<t.indexOf("<")){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild}return document.querySelector(t)}function u(t,e){var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!1),t.dispatchEvent(i)}function c(e,i){Object.keys(i).forEach(function(t){e.style[t]=i[t]})}function x(t){var e=y.apply(null,arguments);t=w(t);for(var i,n=0;n<t.length;n++){(i=t[n].classList).add.apply(i,o(e))}}function F(t){var e=y.apply(null,arguments);t=w(t);for(var i,n=0;n<t.length;n++){(i=t[n].classList).remove.apply(i,o(e))}}function C(i,t,n,o){for(var e=t.split(/\s/),s=function(t){var e=A(t.target,n,i);e&&(t.delegateTarget=e,o.call(e,t))},r=0;r<e.length;r++)i.addEventListener(e[r],s,!0)}function d(t,e){if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i}function g(t){var e,i;return!(!t||"[object Object]"!==toString.call(t))&&(!(e=S(t))||"function"==typeof(i=I.call(e,"constructor")&&e.constructor)&&_.call(i)===D)}var e=/Mac/.test(navigator.userAgent),p=e?91:17,f=e?18:17,v=e?"metaKey":"ctrlKey",m=e?"altKey":"ctrlKey",k=function(t){return null==t?null:"boolean"==typeof t?t?"1":"0":t+""},y=function(){for(var t=[],e=1;e<arguments.length;e++){var i=arguments[e];"string"==typeof i&&(i=i.trim().split(/[\11\12\14\15\40]/)),Array.isArray(i)&&(t=t.concat(i))}return t.filter(Boolean)},w=function(t){return Array.isArray(t)||(t=[t]),t},A=function(t,e,i){for(;t&&t.matches;){if(t.matches(e))return t;if(t==i)break;t=t.parentNode}},b=function(t,e){return 0<e?t[t.length-1]:t[0]},I={}.hasOwnProperty,_=I.toString,S=Object.getPrototypeOf,D=_.call(Object),L=function t(e){var i,n,o,s,r,l,a,u=e||{},c=1,d=arguments.length,p=!1;for("boolean"==typeof u&&(p=u,u=arguments[c]||{},c++),"object"===h(u)||"function"==typeof(a=u)&&"number"!=typeof a.nodeType||(u={}),c===d&&(u=this,c--);c<d;c++)if(null!=(i=arguments[c]))for(n in i)s=i[n],"__proto__"!==n&&u!==s&&(p&&s&&(g(s)||(r=Array.isArray(s)))?(o=u[n],l=r&&!Array.isArray(o)?[]:r||g(o)?o:{},r=!1,u[n]=t(p,l,s)):void 0!==s&&(u[n]=s));return u},E=function(t,e){var i,n,o=this;if((t=O(t)).tomselect)throw new Error("Tom Select already initialized on this element");t.tomselect=o,e=l(t,e);var s=(window.getComputedStyle&&window.getComputedStyle(t,null)).getPropertyValue("direction");for(Object.assign(o,{order:0,settings:e,input:t,tabIndex:t.getAttribute("tabindex")||"",is_select_tag:"select"===t.tagName.toLowerCase(),rtl:/rtl/i.test(s),highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:t.required,isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!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:{item:{},option:{}}}),o.settings.load&&o.settings.loadThrottle&&(o.settings.load=o.loadDebounce(o.settings.load,o.settings.loadThrottle)),o.sifter=new r(this.options,{diacritics:e.diacritics}),i=0,n=o.settings.options.length;i<n;i++)o.registerOption(o.settings.options[i]);for(delete o.settings.options,i=0,n=o.settings.optgroups.length;i<n;i++)o.registerOptionGroup(o.settings.optgroups[i]);delete o.settings.optgroups,o.settings.mode=o.settings.mode||(1===o.settings.maxItems?"single":"multi"),"boolean"!=typeof o.settings.hideSelected&&(o.settings.hideSelected="multi"===o.settings.mode),"string"==typeof o.settings.createFilter&&(o.settings.createFilter=new RegExp(o.settings.createFilter)),o.initializePlugins(o.settings.plugins),o.setupCallbacks(),o.setupTemplates(),o.setup()};if(void 0===t)throw'Dependency MicroPlugin is missing. Make sure you either: (1) are using the "complete" version of Tom Select, or (2) require MicroPlugin before you load Tom Select.';return s.mixin(E),t.mixin(E),Object.assign(E.prototype,{setup:function(){var i,t,e,n,o,s,r,l,a=this,u=a.settings,c=a.input,d=a.settings.mode,p=c.getAttribute("class")||"",h=O("<div>");if(x(h,u.wrapperClass,p,d),i=O('<div class="items">'),x(i,u.inputClass),h.append(i),e=O('<div style="display:none">'),x(e,u.dropdownClass,d),n=O('<div style="scroll-behavior: smooth;">'),x(n,u.dropdownContentClass),e.append(n),O(u.dropdownParent||h).appendChild(e),u.controlInput)t=O(u.controlInput);else{t=O('<input type="text" autocomplete="off" />');for(var g=["autocorrect","autocapitalize","autocomplete"],f=0;f<g.length;f++){var v=g[f];c.getAttribute(v)&&t.setAttribute(v,c.getAttribute(v))}}u.controlInput||(t.setAttribute("tabindex",c.disabled?"-1":a.tabIndex),i.appendChild(t)),(s=c.getAttribute("id"))&&(t.setAttribute("id",s+"-tomselected"),(r=document.querySelector("label[for='"+s+"']"))&&r.setAttribute("for",s+"-tomselected")),a.settings.copyClassesToDropdown&&x(e,p),h.style.width=c.style.width,a.plugins.names.length&&(o="plugin-"+a.plugins.names.join(" plugin-"),x([h,e],o)),(null===u.maxItems||1<u.maxItems)&&a.is_select_tag&&c.setAttribute("multiple","multiple"),a.settings.placeholder&&t.setAttribute("placeholder",u.placeholder),!a.settings.splitOn&&a.settings.delimiter&&(l=a.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),a.settings.splitOn=new RegExp("\\s*"+l+"+\\s*")),t.type=c.type,a.control=i,a.control_input=t,a.wrapper=h,a.dropdown=e,a.dropdown_content=n,C(e,"mouseenter","[data-selectable]",function(){return a.onOptionHover.apply(a,arguments)}),C(e,"mousedown","[data-selectable]",function(){return a.onOptionSelect.apply(a,arguments)}),i.addEventListener("mousedown",function(t){var e=A(t.target,"."+a.settings.itemClass,i);return e?(t.delegateTarget=e,a.onItemSelect.call(a,t)):a.onMouseDown.call(a,t)}),i.addEventListener("click",function(){return a.onClick.apply(a,arguments)}),t.addEventListener("mousedown",function(t){t.stopPropagation()}),t.addEventListener("keydown",function(){return a.onKeyDown.apply(a,arguments)}),t.addEventListener("keyup",function(){return a.onKeyUp.apply(a,arguments)}),t.addEventListener("keypress",function(){return a.onKeyPress.apply(a,arguments)}),t.addEventListener("resize",function(){a.positionDropdown.apply(a,[])}),t.addEventListener("blur",function(){return a.onBlur.apply(a,arguments)}),t.addEventListener("focus",function(){return a.ignoreBlur=!1,a.onFocus.apply(a,arguments)}),t.addEventListener("paste",function(){return a.onPaste.apply(a,arguments)});function m(t){if(a.isFocused){if(A(t.target,"."+a.settings.wrapperClass,a.wrapper))return!1;a.blur(t.target)}}function y(){a.isOpen&&a.positionDropdown.apply(a,arguments)}function w(){a.ignoreHover=!1}document.addEventListener("mousedown",m),window.addEventListener("sroll",y),window.addEventListener("resize",y),window.addEventListener("mousemove",w),a._destroy=function(){document.removeEventListener("mousedown",m),window.removeEventListener("mousemove",w),window.removeEventListener("sroll",y),window.removeEventListener("resize",y)};for(var b=[];0<c.children.length;)b.push(c.children[0]),c.children[0].remove();this.revertSettings={children:b,tabindex:c.getAttribute("tabindex")},c.setAttribute("tabindex",-1),c.setAttribute("hidden","hidden"),c.insertAdjacentElement("afterend",a.wrapper),a.setValue(u.items),delete u.items,a.supportsValidity()&&c.addEventListener("invalid",function(t){t.preventDefault(),a.isInvalid=!0,a.refreshState()}),a.updateOriginalInput(),a.refreshItems(),a.refreshState(),a.isSetup=!0,c.disabled&&a.disable(),a.on("change",this.onChange),x(c,"tomselected"),a.trigger("initialize"),!0===u.preload&&a.onSearchChange("")},supportsValidity:function(){return!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity},setupTemplates:function(){var i=this.settings.labelField,n=this.settings.optgroupLabelField,t={optgroup:function(){return'<div class="optgroup"></div>'},optgroup_header:function(t,e){return'<div class="optgroup-header">'+e(t[n])+"</div>"},option:function(t,e){return"<div>"+e(t[i])+"</div>"},item:function(t,e){return"<div>"+e(t[i])+"</div>"},option_create:function(t,e){return'<div class="create">Add <strong>'+e(t.input)+"</strong>&hellip;</div>"},no_results:function(){return'<div class="no-results">No results found</div>'}};this.settings.render=Object.assign({},t,this.settings.render)},setupCallbacks:function(){var t,e,i={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(t in i)(e=this.settings[i[t]])&&this.on(t,e)},onClick:function(t){this.isFocused&&this.isOpen||(this.focus(),t.preventDefault())},onMouseDown:function(t){var e=this;if(e.isFocused){if(t.target!==e.control_input)return"single"===e.settings.mode?e.isOpen?e.close():e.open():e.setActiveItem(null),!1}else window.setTimeout(function(){e.focus()},0)},onChange:function(){u(this.input,"change")},onPaste:function(t){var o=this;o.isFull()||o.isInputHidden||o.isLocked?t.preventDefault():o.settings.splitOn&&setTimeout(function(){var t=o.inputValue();if(t.match(o.settings.splitOn))for(var e=t.trim().split(o.settings.splitOn),i=0,n=e.length;i<n;i++)o.createItem(e[i])},0)},onKeyPress:function(t){if(this.isLocked)return t&&t.preventDefault();var e=String.fromCharCode(t.keyCode||t.which);return this.settings.create&&"multi"===this.settings.mode&&e===this.settings.delimiter?(this.createItem(),t.preventDefault(),!1):void 0},onKeyDown:function(t){t.target,this.control_input;var e,i,n=this;if(n.isLocked)9!==t.keyCode&&t.preventDefault();else{switch(t.keyCode){case 65:if(n.isKeyDown(p,t))return void n.selectAll();break;case 27:return void(n.isOpen&&(t.preventDefault(),t.stopPropagation(),n.close()));case 40:return!n.isOpen&&n.hasOptions?n.open():n.activeOption&&(n.ignoreHover=!0,(e=n.getAdjacent(n.activeOption,1))&&n.setActiveOption(e,!0)),void t.preventDefault();case 38:return n.activeOption&&(n.ignoreHover=!0,(i=n.getAdjacent(n.activeOption,-1))&&n.setActiveOption(i,!0)),void t.preventDefault();case 13:return void(n.isOpen&&n.activeOption&&(n.onOptionSelect({delegateTarget:n.activeOption}),t.preventDefault()));case 37:return void n.advanceSelection(-1,t);case 39:return void n.advanceSelection(1,t);case 9:return n.settings.selectOnTab&&n.isOpen&&n.activeOption&&(n.onOptionSelect({delegateTarget:n.activeOption}),t.preventDefault()),void(n.settings.create&&n.createItem()&&t.preventDefault());case 8:case 46:return void n.deleteSelection(t)}!n.isInputHidden||n.isKeyDown(p,t)||t.preventDefault()}},onKeyUp:function(t){var e=this;if(e.isLocked)return t&&t.preventDefault();var i=e.inputValue();e.lastValue!==i&&(e.lastValue=i,e.onSearchChange(i),e.refreshOptions(),e.trigger("type",i))},onSearchChange:function(e){var i=this,n=i.settings.load;n&&(i.loadedSearches.hasOwnProperty(e)||(i.loadedSearches[e]=!0,i.load(function(t){n.apply(i,[e,t])})))},onFocus:function(t){var e=this,i=e.isFocused;if(e.isDisabled)return e.blur(),t&&t.preventDefault(),!1;e.ignoreFocus||(e.isFocused=!0,"focus"===e.settings.preload&&e.onSearchChange(""),i||e.trigger("focus"),e.activeItems.length||(e.showInput(),e.setActiveItem(null),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())},onBlur:function(t,e){var i=this;if(i.isFocused){if(i.isFocused=!1,i.ignoreFocus=!1,!i.ignoreBlur&&document.activeElement===i.dropdown_content)return i.ignoreBlur=!0,void i.onFocus(t);var n=function(){i.close(),i.setActiveItem(null),i.setActiveOption(null),i.setCaret(i.items.length),i.refreshState(),e&&e.focus&&e.focus(),i.isBlurring=!1,i.trigger("blur")};i.isBlurring=!0,i.settings.create&&i.settings.createOnBlur?i.createItem(null,!1,n):n()}},onOptionHover:function(t){this.ignoreHover||this.setActiveOption(t.delegateTarget,!1)},onOptionSelect:function(t){var e,i=this;t.preventDefault&&(t.preventDefault(),t.stopPropagation());var n=t.delegateTarget;n&&(n.parentNode&&n.parentNode.matches("[data-disabled]")||(n.classList.contains("create")?i.createItem(null,function(){i.settings.closeAfterSelect&&i.close()}):void 0!==(e=n.dataset.value)&&(i.lastQuery=null,i.addItem(e),i.settings.closeAfterSelect?i.close():!i.settings.hideSelected&&t.type&&/mouse/.test(t.type)&&i.setActiveOption(i.getOption(e)))))},onItemSelect:function(t){this.isLocked||"multi"===this.settings.mode&&(t.preventDefault(),this.setActiveItem(t.delegateTarget,t))},load:function(t){var i=this;x(i.wrapper,i.settings.loadingClass),i.loading++,t.apply(i,[function(t,e){i.loading=Math.max(i.loading-1,0),e&&e.length&&e.forEach(function(t){i.addOptionGroup(t[i.settings.optgroupValueField],t)}),t&&t.length&&i.addOption(t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||F(i.wrapper,i.settings.loadingClass),i.trigger("load",t)}])},loadDebounce:function(i,n){var o;return function(){var t=this,e=arguments;o&&(t.loading=Math.max(t.loading-1,0)),window.clearTimeout(o),o=window.setTimeout(function(){o=null,i.apply(t,e)},n)}},setTextboxValue:function(t){var e=this.control_input;e.value!==t&&(e.value=t,u(e,"update"),this.lastValue=t)},getValue:function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)},setValue:function(t,e){i(this,e?[]:["change"],function(){this.clear(e),this.addItems(t,e)})},setActiveItem:function(t,e){var i,n,o,s,r,l;if("single"!==this.settings.mode){if(!t)return F(this.activeItems,"active"),this.activeItems=[],void(this.isFocused&&this.showInput());if("mousedown"===(i=e&&e.type.toLowerCase())&&this.isKeyDown(16,e)&&this.activeItems.length){for(l=this.getLastActive(),o=Array.prototype.indexOf.apply(this.control.children,[l]),(s=Array.prototype.indexOf.apply(this.control.children,[t]))<o&&(r=o,o=s,s=r),n=o;n<=s;n++)t=this.control.children[n],-1===this.activeItems.indexOf(t)&&this.setActiveItemClass(t);e.preventDefault()}else"mousedown"===i&&this.isKeyDown(f,e)||"keydown"===i&&this.isKeyDown(16,e)?t.classList.contains("active")?this.removeActiveItem(t):this.setActiveItemClass(t):(F(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(t));this.hideInput(),this.isFocused||this.focus()}},setActiveItemClass:function(t){var e=this.control.querySelector(".last-active");e&&F(e,"last-active"),x(t,"active last-active"),-1==this.activeItems.indexOf(t)&&this.activeItems.push(t)},removeActiveItem:function(t){var e=this.activeItems.indexOf(t);this.activeItems.splice(e,1),F(t,"active")},setActiveOption:function(t,e){var i,n,o;t!==this.activeOption&&(this.activeOption&&F(this.activeOption,"active"),this.activeOption=null,t&&(this.activeOption=t,x(t,"active"),!e&&void 0!==e||(i=this.dropdown_content.clientHeight,e=this.dropdown_content.scrollTop||0,n=this.activeOption.offsetHeight,i+e<(o=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+e)+n?this.dropdown_content.scrollTop=o-i+n:o<e&&(this.dropdown_content.scrollTop=o))))},selectAll:function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(x(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())},hideInput:function(){this.settings.controlInput||(this.setTextboxValue(""),c(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)},showInput:function(){this.settings.controlInput||(c(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)},inputValue:function(){return this.control_input.value.trim()},focus:function(){var t=this;t.isDisabled||(t.ignoreFocus=!0,t.control_input.focus(),window.setTimeout(function(){t.ignoreFocus=!1,t.onFocus()},0))},blur:function(t){this.control_input.blur(),this.onBlur(null,t)},getScoreFunction:function(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())},getSearchOptions:function(){var t=this.settings,e=t.sortField;return"string"==typeof e&&(e=[{field:e}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}},search:function(t){var e,i,n,o=this,s=o.settings,r=this.getSearchOptions();if(s.score&&"function"!=typeof(n=o.settings.score.apply(this,[t])))throw new Error('Tom Select "score" setting must be a function that returns a function');if(t!==o.lastQuery?(o.lastQuery=t,i=o.sifter.search(t,Object.assign(r,{score:n})),o.currentResults=i):i=L({},o.currentResults),s.hideSelected)for(e=i.items.length-1;0<=e;e--)-1!==o.items.indexOf(k(i.items[e].id))&&i.items.splice(e,1);return i},refreshOptions:function(t){var e,i,n,o,s,r;void 0===t&&(t=!0);var l,a,u,c,d,p,h=this,g=h.inputValue(),f=h.search(g),v=h.activeOption&&k(h.activeOption.dataset.value),m=!1,y=f.items.length;for("number"==typeof h.settings.maxOptions&&(y=Math.min(y,h.settings.maxOptions)),0<y&&(m=!0),i={},n=[],e=0;e<y;e++)for(var w,b=h.options[f.items[e].id],O=k(b[h.settings.valueField]),C=(C=h.getOption(O))||h.render("option",b),A=b[h.settings.optgroupField]||"",I=0,_=(w=Array.isArray(A)?A:[A])&&w.length;I<_;I++)A=w[I],h.optgroups.hasOwnProperty(A)||(A=""),i.hasOwnProperty(A)||(i[A]=document.createDocumentFragment(),n.push(A)),0<I&&(C=C.cloneNode(!0),F(C,"active")),i[A].appendChild(C);for(this.settings.lockOptgroupOrder&&n.sort(function(t,e){return(h.optgroups[t].$order||0)-(h.optgroups[e].$order||0)}),o=document.createDocumentFragment(),e=0,y=n.length;e<y;e++){A=n[e],h.optgroups.hasOwnProperty(A)&&i[A].children.length?((l=h.render("optgroup",h.optgroups[A])).appendChild(h.render("optgroup_header",h.optgroups[A])),l.appendChild(i[A]),o.appendChild(l)):o.appendChild(i[A])}if(h.dropdown_content.innerHTML="",h.dropdown_content.appendChild(o),h.settings.highlight&&(h.dropdown_content,a=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(a,function(t,e){var i=t.parentNode;i.replaceChild(t.firstChild,t),i.normalize()}),f.query.length&&f.tokens.length))for(e=0,y=f.tokens.length;e<y;e++)!function(t,e){var u,i;"string"==typeof e&&!e.length||(u="string"==typeof e?new RegExp(e,"i"):e,i=function t(e){var i=0;if(3===e.nodeType){var n,o,s,r,l=e.data.search(u);0<=l&&0<e.data.length&&(n=e.data.match(u),(o=document.createElement("span")).className="highlight",(s=e.splitText(l)).splitText(n[0].length),r=s.cloneNode(!0),o.appendChild(r),s.parentNode.replaceChild(o,s),i=1)}else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&("highlight"!==e.className||"SPAN"!==e.tagName))for(var a=0;a<e.childNodes.length;++a)a+=t(e.childNodes[a]);return i},i(t))}(h.dropdown_content,f.tokens[e].regex);if(!h.settings.hideSelected)for(e=0,y=h.items.length;e<y;e++){var S=h.getOption(h.items[e]);S&&x(S,"selected")}0===f.items.length&&h.settings.render.no_results&&!h.loading&&g.length&&(u=h.render("no_results",{input:g}),m=!0,h.dropdown_content.insertBefore(u,h.dropdown_content.firstChild)),(s=h.canCreate(g))&&(m=!0,r=h.render("option_create",{input:g}),h.dropdown_content.insertBefore(r,h.dropdown_content.firstChild)),h.hasOptions=0<f.items.length||s,m?(p=0<f.items.length?(d=v&&h.getOption(v))&&h.dropdown_content.contains(d)?d:"single"===h.settings.mode&&h.items.length?h.getOption(h.items[0]):(c=0,r&&!h.settings.addPrecedence&&(c=1),h.selectable()[c]):r,h.setActiveOption(p),t&&!h.isOpen&&h.open()):(h.setActiveOption(null),t&&h.isOpen&&h.close())},selectable:function(){return this.dropdown_content.querySelectorAll("[data-selectable]")},addOption:function(t){var e,i,n,o=this;if(Array.isArray(t))for(e=0,i=t.length;e<i;e++)o.addOption(t[e]);else(n=o.registerOption(t))&&(o.userOptions[n]=!0,o.lastQuery=null,o.trigger("option_add",n,t))},registerOption:function(t){var e=k(t[this.settings.valueField]);return null!=e&&!this.options.hasOwnProperty(e)&&(t.$order=t.$order||++this.order,this.options[e]=t,e)},registerOptionGroup:function(t){var e=k(t[this.settings.optgroupValueField]);return!!e&&(t.$order=t.$order||++this.order,this.optgroups[e]=t,e)},addOptionGroup:function(t,e){e[this.settings.optgroupValueField]=t,(t=this.registerOptionGroup(e))&&this.trigger("optgroup_add",t,e)},removeOptionGroup:function(t){this.optgroups.hasOwnProperty(t)&&(delete this.optgroups[t],this.clearCache(),this.trigger("optgroup_remove",t))},clearOptionGroups:function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")},updateOption:function(t,e){var i,n,o,s,r,l,a,u=this;if(t=k(t),o=k(e[u.settings.valueField]),null!==t&&u.options.hasOwnProperty(t)){if("string"!=typeof o)throw new Error("Value must be set in option data");a=u.options[t].$order,o!==t&&(delete u.options[t],-1!==(s=u.items.indexOf(t))&&u.items.splice(s,1,o)),e.$order=e.$order||a,u.options[o]=e,r=u.renderCache.item,l=u.renderCache.option,r&&(delete r[t],delete r[o]),l&&(delete l[t],delete l[o]),-1!==u.items.indexOf(o)&&(i=u.getItem(t),n=u.render("item",e),i.classList.contains("active")&&x(n,"active"),i.parentNode.insertBefore(n,i),i.remove()),u.lastQuery=null,u.isOpen&&u.refreshOptions(!1)}},removeOption:function(t,e){var i=this;t=k(t);var n=i.renderCache.item,o=i.renderCache.option;n&&delete n[t],o&&delete o[t],delete i.userOptions[t],delete i.options[t],i.lastQuery=null,i.trigger("option_remove",t),i.removeItem(t,e)},clearOptions:function(){this.loadedSearches={},this.userOptions={},this.clearCache();var t={};for(key in this.options)this.options.hasOwnProperty(key)&&0<=this.items.indexOf(key)&&(t[key]=this.options[key]);this.options=this.sifter.items=t,this.lastQuery=null,this.trigger("option_clear")},getOption:function(t){return this.renderCache.option.hasOwnProperty(t)?this.renderCache.option[t]:this.getElementWithValue(t,this.selectable())},getAdjacent:function(t,e,i){var n=2<arguments.length&&void 0!==i?i:"option";if(t){var o=this.settings.optionClass,s=this.dropdown;"item"==n&&(s=this.control,o=this.settings.itemClass);for(var r=s.querySelectorAll("."+o),l=0;l<r.length;l++)if(r[l]==t)return 0<e?r[l+1]:r[l-1]}},getElementWithValue:function(t,e){if(null!=(t=k(t)))for(var i=0,n=e.length;i<n;i++)if(e[i].getAttribute("data-value")===t)return e[i]},getItem:function(t){return this.getElementWithValue(t,this.control.children)},addItems:function(t,e){this.buffer=document.createDocumentFragment();for(var i=this.control.children,n=0;n<i.length;n++)this.buffer.appendChild(i[n]);for(var o=Array.isArray(t)?t:[t],n=0,s=o.length;n<s;n++)this.isPending=n<s-1,this.addItem(o[n],e);var r=this.control;r.insertBefore(this.buffer,r.firstChild),this.buffer=null},addItem:function(l,a){i(this,a?[]:["change"],function(){var t,e,i,n,o,s=this,r=s.settings.mode;l=k(l),(-1===s.items.indexOf(l)||("single"===r&&s.close(),"single"!==r&&s.settings.duplicates))&&s.options.hasOwnProperty(l)&&("single"===r&&s.clear(a),"multi"===r&&s.isFull()||(o=s.render("item",s.options[l]),this.control.contains(o)&&(o=o.cloneNode(!0)),t=s.isFull(),s.items.splice(s.caretPos,0,l),s.insertAtCaret(o),s.isPending&&(t||!s.isFull())||s.refreshState(),s.isSetup&&(e=s.selectable(),s.isPending||(i=s.getOption(l),n=s.getAdjacent(i,1),s.refreshOptions(s.isFocused&&"single"!==r),n&&s.setActiveOption(n)),!e.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.trigger("item_add",l,o),s.isPending||s.updateOriginalInput({silent:a}))))})},removeItem:function(t,e){var i,n,o=this.getItem(t);o&&(t=k(o.dataset.value),-1!==(i=this.items.indexOf(t))&&(o.remove(),o.classList.contains("active")&&(n=this.activeItems.indexOf(o),this.activeItems.splice(n,1),F(o,"active")),this.items.splice(i,1),this.lastQuery=null,!this.settings.persist&&this.userOptions.hasOwnProperty(t)&&this.removeOption(t,e),i<this.caretPos&&this.setCaret(this.caretPos-1),this.refreshState(),this.updateOriginalInput({silent:e}),this.positionDropdown(),this.trigger("item_remove",t,o)))},createItem:function(t,i){var n=this,o=n.caretPos;t=t||n.inputValue();var s=arguments[arguments.length-1];if("function"!=typeof s&&(s=function(){}),"boolean"!=typeof i&&(i=!0),!n.canCreate(t))return s(),!1;n.lock();var e,r,l="function"==typeof n.settings.create?this.settings.create:function(t){var e={};return e[n.settings.labelField]=t,e[n.settings.valueField]=t,e},a=(r=!(e=function(t){if(n.unlock(),!t||"object"!==h(t))return s();var e=k(t[n.settings.valueField]);if("string"!=typeof e)return s();n.setTextboxValue(""),n.addOption(t),n.setCaret(o),n.addItem(e),n.refreshOptions(i&&"single"!==n.settings.mode),s(t)}),function(){r||(r=!0,e.apply(this,arguments))}),u=l.apply(this,[t,a]);return void 0!==u&&a(u),!0},refreshItems:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()},refreshState:function(){var t=this;t.refreshValidityState();var e=t.isFull(),i=t.isLocked;t.wrapper.classList.toggle("rtl",t.rtl);var n,o=t.control.classList;o.toggle("focus",t.isFocused),o.toggle("disabled",t.isDisabled),o.toggle("required",t.isRequired),o.toggle("invalid",t.isInvalid),o.toggle("locked",i),o.toggle("full",e),o.toggle("not-full",!e),o.toggle("input-active",t.isFocused&&!t.isInputHidden),o.toggle("dropdown-active",t.isOpen),o.toggle("has-options",(n=t.options,0===Object.keys(n).length)),o.toggle("has-items",0<t.items.length)},refreshValidityState:function(){if(!this.isRequired)return!1;var t=!this.items.length;this.isInvalid=t,this.control_input.required=t,this.input.required=!t},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(t){var e,i,n,o,s=this;if(t=t||{},s.is_select_tag){for(n=[],e=0,i=s.items.length;e<i;e++)o=s.options[s.items[e]][s.settings.labelField]||"",n.push('<option value="'+a(s.items[e])+'" selected="selected">'+a(o)+"</option>");n.length||this.input.hasAttribute("multiple")||n.push('<option value="" selected="selected"></option>'),s.input.innerHTML=n.join("")}else s.input.value=s.getValue(),s.input.setAttribute("value",s.input.value);s.isSetup&&(t.silent||s.trigger("change",s.input.value))},open:function(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.focus(),t.isOpen=!0,t.refreshState(),c(t.dropdown,{visibility:"hidden",display:"block"}),t.positionDropdown(),c(t.dropdown,{visibility:"visible",display:"block"}),t.trigger("dropdown_open",t.dropdown))},close:function(){var t=this,e=t.isOpen;"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.isBlurring||t.blur()),t.isOpen=!1,c(t.dropdown,{display:"none"}),t.setActiveOption(null),t.refreshState(),e&&t.trigger("dropdown_close",t.dropdown)},positionDropdown:function(){var t,e=0,i=this.control,n=i.offsetHeight;"body"===this.settings.dropdownParent?(n+=(t=i.getBoundingClientRect()).top+window.scrollY,e=t.left+window.scrollX):this.settings.dropdownParent?n=(i=O(this.settings.dropdownParent)).offsetHeight:(n+=i.offsetTop,e=i.offsetLeft),c(this.dropdown,{width:i.getBoundingClientRect().width+"px",top:n+"px",left:e+"px"})},clear:function(t){if(this.items.length){for(var e=this.controlChildren(),i=0;i<e.length;i++)e[i].remove();this.items=[],this.lastQuery=null,this.setCaret(0),this.setActiveItem(null),this.updateOriginalInput({silent:t}),this.refreshState(),this.showInput(),this.trigger("clear")}},insertAtCaret:function(t){var e=Math.min(this.caretPos,this.items.length),i=this.buffer||this.control;0===e?i.insertBefore(t,i.firstChild):i.insertBefore(t,i.children[e]),this.setCaret(e+1)},deleteSelection:function(t){var e,i,n,o,s,r=this,l=t&&8===t.keyCode?-1:1,a={start:(s=r.control_input).selectionStart,length:s.selectionEnd-s.selectionStart},u=[];if(r.activeItems.length){for(o=b(r.activeItems,l),n=d(o),0<l&&n++,e=0,i=r.activeItems.length;e<i;e++)u.push(r.activeItems[e].dataset.value);t&&(t.preventDefault(),t.stopPropagation())}else(r.isFocused||"single"===r.settings.mode)&&r.items.length&&(l<0&&0===a.start&&0===a.length?u.push(r.items[r.caretPos-1]):0<l&&a.start===r.inputValue().length&&u.push(r.items[r.caretPos]));if(!u.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.apply(r,[u,t]))return!1;for(void 0!==n&&r.setCaret(n);u.length;)r.removeItem(u.pop());return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0},advanceSelection:function(t,e){var i,n,o;0!==t&&(this.rtl&&(t*=-1),this.isKeyDown(f,e)||this.isKeyDown(16,e)?(n=this.getLastActive(t),(o=this.getAdjacent(n,t,"item"))&&(o.classList.contains("active")&&this.removeActiveItem(n),this.setActiveItemClass(o))):this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+t):(n=this.getLastActive(t))&&(i=d(n),this.setCaret(0<t?i+1:i),this.setActiveItem(null)))},getLastActive:function(t){var e=this.control.querySelector(".last-active");return e||function(t,e,i){var n=t.querySelectorAll(e);if(n)return b(n,i)}(this.control,".active",t)},setCaret:function(t){var e=this;if(t="single"===e.settings.mode||e.settings.controlInput?e.items.length:Math.max(0,Math.min(e.items.length,t)),!e.settings.controlInput&&!e.isPending)for(var i,n=this.controlChildren(),o=n.length,s=0;s<o;s++)i=n[s],s<t?e.control_input.insertAdjacentElement("beforebegin",i):e.control.appendChild(i);e.caretPos=t},controlChildren:function(){return Array.prototype.filter.call(this.control.children,function(t){return"INPUT"!==t.nodeName})},lock:function(){this.close(),this.isLocked=!0,this.refreshState()},unlock:function(){this.isLocked=!1,this.refreshState()},disable:function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()},enable:function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()},destroy:function(){var t=this.revertSettings;this.trigger("destroy"),this.off(),this.wrapper.remove(),this.dropdown.remove(),this.input.innerHTML="",t.tabindex?this.input.setAttribute("tabindex",t.tabindex):this.input.removeAttribute("tabindex"),F(this.input,"tomselected"),this.input.removeAttribute("hidden");for(var e=0;e<t.children.length;e++)this.input.appendChild(t.children[e]);this._destroy(),delete this.input.tomselect},render:function(t,e){var i,n,o="",s=this;return"option"!==t&&"item"!==t||(i=k(e[s.settings.valueField]),!s.renderCache[t].hasOwnProperty(i))?(o=O(s.settings.render[t].apply(this,[e,a])),"option"===t||"option_create"===t?e[s.settings.disabledField]||o.setAttribute("data-selectable",""):"optgroup"===t&&(n=e[s.settings.optgroupValueField],o.setAttribute("data-group",n),e[s.settings.disabledField]&&o.setAttribute("data-disabled","")),"option"!==t&&"item"!==t||(o.setAttribute("data-value",i),x(o,"item"===t?s.settings.itemClass:s.settings.optionClass),s.renderCache[t][i]=o),o):s.renderCache[t][i]},clearCache:function(t){void 0===t?this.renderCache={item:{},option:{}}:this.renderCache[t]={}},canCreate:function(t){if(!this.settings.create)return!1;var e=this.settings.createFilter;return t.length&&("function"!=typeof e||e.apply(this,[t]))&&(!(e instanceof RegExp)||e.test(t))},isKeyDown:function(t,e){if(e){if(t==f&&e[m])return!0;if(t==p&&e[v])return!0;if(16==t&&e.shiftKey)return!0}return!1},hook:function(i,t,n){var o=this,s=o[t];o[t]=function(){var t,e;return"after"===i&&(t=s.apply(o,arguments)),e=n.apply(o,arguments),"instead"===i?e:("before"===i&&(t=s.apply(o,arguments)),t)}}}),E.count=0,E.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,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"tomselect-control",inputClass:"tomselect-input",dropdownClass:"tomselect-dropdown",dropdownContentClass:"tomselect-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}},E.define("drag_drop",function(t){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');var e,i,n;"multi"===this.settings.mode&&(i=(e=this).lock,n=e.unlock,e.hook("instead","lock",function(){var t=e.control.dataset.sortable;return t&&t.disable(),i.apply(e,arguments)}),e.hook("instead","unlock",function(){var t=e.control.dataset.sortable;return t&&t.enable(),n.apply(e,arguments)}),e.hook("after","setup",function(){var i=$(e.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:e.isLocked,start:function(t,e){e.placeholder.css("width",e.helper.css("width")),i.css({overflow:"visible"})},stop:function(){i.css({overflow:"hidden"});var t=[];i.children("[data-value]").each(function(){t.push($(this).attr("data-value"))}),e.setValue(t)}})}))}),E.define("dropdown_header",function(e){var i=this;e=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:function(t){return'<div class="'+t.headerClass+'"><div class="'+t.titleRowClass+'"><span class="'+t.labelClass+'">'+t.title+'</span><a href="javascript:void(0)" class="'+t.closeClass+'">&times;</a></div></div>'}},e),i.hook("after","setup",function(){var t=O(e.html(e));i.dropdown.insertBefore(t,i.dropdown.firstChild)})}),E.define("input_autogrow",function(t){var l=this;l.hook("after","setup",function(){var t=document.createElement("span"),e=this.control_input;t.style.position="absolute",t.style.top="-99999px",t.style.left="-99999px",t.style.width="auto",t.style.padding=0,t.style.whiteSpace="pre",l.wrapper.appendChild(t);for(var i=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"],n=0,o=i.length;n<o;n++){var s=i[n];t.style[s]=e.style[s]}function r(){t.textContent=e.value,e.style.width=t.clientWidth+"px"}e.addEventListener("input",r),e.addEventListener("keyup",r),e.addEventListener("blur",r),e.addEventListener("update",r)})}),E.define("no_backspace_delete",function(t){this.hook("instead","setActiveItem",function(){}),this.hook("instead","selectAll",function(){}),this.settings.onDelete=function(t,e){if(0<t.length&&e&&(8==e.keyCode||46==e.keyCode))return!1}}),E.define("optgroup_columns",function(l){var a=this;l=Object.assign({equalizeWidth:!0,equalizeHeight:!0},l);var s=a.onKeyDown;a.hook("instead","onKeyDown",function(t){var e,i,n,o;return!a.isOpen||37!==t.keyCode&&39!==t.keyCode?s.apply(a,arguments):(a.ignoreHover=!0,o=A(a.activeOption,"[data-group]"),e=d(a.activeOption,"[data-selectable]"),void((o=37===t.keyCode?o.previousSibling:o.nextSibling)&&(i=(n=o.querySelectorAll("[data-selectable]"))[Math.min(n.length-1,e)])&&a.setActiveOption(i)))});function t(){var t,e,i,n,o,s=a.dropdown_content.querySelectorAll("[data-group]"),r=s.length;if(r&&a.dropdown_content.clientWidth){if(l.equalizeHeight){for(t=e=0;t<r;t++)e=Math.max(e,s[t].clientHeight);for(t=0;t<r;t++)s[t].style.height=e+"px"}if(r&&a.dropdown_content.clientWidth&&l.equalizeWidth){for(o=a.dropdown_content.clientWidth-function t(){var e,i=t.width,n=document;return void 0===i&&((e=n.createElement("div")).innerHTML='<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>',e=e.firstChild,n.body.appendChild(e),i=t.width=e.offsetWidth-e.clientWidth,n.body.removeChild(e)),i}(),i=Math.round(o/r),t=0;t<r;t++)s[t].style.width=i+"px";1<r&&(n=o-i*(r-1),s[r-1].style.width=n+"px")}}}(l.equalizeHeight||l.equalizeWidth)&&(a.hook("after","positionDropdown",t),a.hook("after","refreshOptions",t))}),E.define("remove_button",function(t){t=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},t);var o,s,r=this;t.append&&(o='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+a(t.title)+'">'+t.label+"</a>",s=r.render,r.hook("instead","render",function(t,e){var i,n=s.apply(r,arguments);return"item"==t&&(i=O(o),n.appendChild(i),i.addEventListener("click",function(t){var e;t.preventDefault(),"single"!==r.settings.mode&&t.stopPropagation(),r.isLocked||(e=n.dataset.value,r.removeItem(e))})),n}))}),E.define("restore_on_backspace",function(n){var o=this;n.text=n.text||function(t){return t[o.settings.labelField]};var s=o.onKeyDown;o.hook("instead","onKeyDown",function(t){var e,i;return 8===t.keyCode&&""===o.control_input.value&&!o.activeItems.length&&0<=(e=o.caretPos-1)&&e<o.items.length?(i=o.options[o.items[e]],o.deleteSelection(t)&&(o.setTextboxValue(n.text.apply(o,[i])),o.refreshOptions(!0)),void t.preventDefault()):s.apply(o,arguments)})}),E});var tomSelect=function(t,e){return new TomSelect(t,e)};
!function(e,t){"function"==typeof define&&define.amd?define(["sifter","microplugin"],t):"object"==typeof exports?module.exports=t(require("sifter"),require("microplugin")):e.TomSelect=t(e.Sifter,e.MicroPlugin)}(this,function(a,e){"use strict";function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(s){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t,i,n,o=p(s);return t=r?(e=p(this).constructor,Reflect.construct(o,arguments,e)):o.apply(this,arguments),i=this,!(n=t)||"object"!==l(n)&&"function"!=typeof n?c(i):n}}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function d(){}d.prototype={on:function(e,t){this._events=this._events||{},this._events[e]=this._events[e]||[],this._events[e].push(t)},off:function(e,t){var i=arguments.length;return 0===i?delete this._events:1===i?delete this._events[e]:(this._events=this._events||{},void(e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(t),1)))},trigger:function(e){if(this._events=this._events||{},e in this._events!=!1)for(var t=0;t<this._events[e].length;t++)this._events[e][t].apply(this,Array.prototype.slice.call(arguments,1))}};function h(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function g(t,i,e){var n,o=t.trigger,s={};for(n in t.trigger=function(){var e=arguments[0];if(-1===i.indexOf(e))return o.apply(t,arguments);s[e]=arguments},e.apply(t,[]),t.trigger=o,s)s.hasOwnProperty(n)&&o.apply(t,s[n])}function f(e,t){var i=document.createEvent("HTMLEvents");i.initEvent(t,!0,!1),e.dispatchEvent(i)}function v(t,i){Object.keys(i).forEach(function(e){t.style[e]=i[e]})}function x(e){var t=C.apply(null,arguments);e=I(e);for(var i,n=0;n<e.length;n++){(i=e[n].classList).add.apply(i,s(t))}}function F(e){var t=C.apply(null,arguments);e=I(e);for(var i,n=0;n<e.length;n++){(i=e[n].classList).remove.apply(i,s(t))}}function O(i,e,n,o){for(var t=e.split(/\s/),s=function(e){var t=A(e.target,n,i);t&&(e.delegateTarget=t,o.call(t,e))},r=0;r<t.length;r++)i.addEventListener(t[r],s,!0)}function m(e,t){if(!e)return-1;t=t||e.nodeName;for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++;return i}var t=/Mac/.test(navigator.userAgent),y=t?18:17,b=t?"metaKey":"ctrlKey",w=function(u,e){var t,c=Object.assign({},S.defaults,e),p=c.dataAttr,d=c.labelField,h=c.valueField,g=c.disabledField,f=c.optgroupField,v=c.optgroupLabelField,m=c.optgroupValueField,i=u.tagName.toLowerCase(),n=u.getAttribute("placeholder")||u.getAttribute("data-placeholder");n||c.allowEmptyOption||(t=u.querySelector('option[value=""]'))&&(n=t.textContent);var y={placeholder:n,options:[],optgroups:[],items:[]};return("select"===i?function(){function r(e){var t=Object.assign({},e.dataset),i=p&&t[p];return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t}function a(e,t){var i,n,o=D(e.value);(o||c.allowEmptyOption)&&(l.hasOwnProperty(o)?t&&((i=l[o][f])?Array.isArray(i)?i.push(t):l[o][f]=[i,t]:l[o][f]=t):((n=r(e))[d]=n[d]||e.textContent,n[h]=n[h]||o,n[g]=n[g]||e.disabled,n[f]=n[f]||t,l[o]=n,s.push(n),e.selected&&y.items.push(o)))}var e,t,i,n,s=y.options,l={};for(y.maxItems=u.hasAttribute("multiple")?null:1,e=0,t=(n=u.children).length;e<t;e++)"optgroup"===(i=n[e].tagName.toLowerCase())?function(e){var t,i=e.getAttribute("label");i&&((t=r(e))[v]=i,t[m]=i,t[g]=e.disabled,y.optgroups.push(t));for(var n,o=0,s=(n=e.children).length;o<s;o++)a(n[o],i)}(n[e]):"option"===i&&a(n[e])}:function(){var e,t,i,n,o=u.getAttribute(p);if(o)for(y.options=JSON.parse(o),e=0,t=y.options.length;e<t;e++)y.items.push(y.options[e][h]);else{var s=u.value.trim()||"";if(!c.allowEmptyOption&&!s.length)return;for(e=0,t=(i=s.split(c.delimiter)).length;e<t;e++)(n={})[d]=i[e],n[h]=i[e],y.options.push(n);y.items=i}})(),Object.assign({},S.defaults,y,e)},D=function(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""},k=function(e){if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(-1<e.indexOf("<")){var t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)},C=function(){for(var e=[],t=1;t<arguments.length;t++){var i=arguments[t];"string"==typeof i&&(i=i.trim().split(/[\11\12\14\15\40]/)),Array.isArray(i)&&(e=e.concat(i))}return e.filter(Boolean)},I=function(e){return Array.isArray(e)||(e=[e]),e},A=function(e,t,i){for(;e&&e.matches;){if(e.matches(t))return e;if(e==i)break;e=e.parentNode}},_=function(e,t){return 0<t?e[e.length-1]:e[0]},S=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(r,d);var e,t,i,s=u(r);function r(e,t){var i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r);var n=c(i=s.call(this));if((e=k(e)).tomselect)throw new Error("Tom Select already initialized on this element");e.tomselect=n,t=w(e,t);var o=(window.getComputedStyle&&window.getComputedStyle(e,null)).getPropertyValue("direction");return Object.assign(n,{order:0,settings:t,input:e,tabIndex:e.getAttribute("tabindex")||"",is_select_tag:"select"===e.tagName.toLowerCase(),rtl:/rtl/i.test(o),highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:e.required,isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!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:{item:{},option:{}}}),n.settings.load&&n.settings.loadThrottle&&(n.settings.load=n.loadDebounce(n.settings.load,n.settings.loadThrottle)),n.sifter=new a(i.options,{diacritics:t.diacritics}),n.setupOptions(n.settings.options,n.settings.optgroups),delete n.settings.optgroups,delete n.settings.options,n.settings.mode=n.settings.mode||(1===n.settings.maxItems?"single":"multi"),"boolean"!=typeof n.settings.hideSelected&&(n.settings.hideSelected="multi"===n.settings.mode),"string"==typeof n.settings.createFilter&&(n.settings.createFilter=new RegExp(n.settings.createFilter)),n.initializePlugins(n.settings.plugins),n.setupCallbacks(),n.setupTemplates(),n.setup(),i}return e=r,(t=[{key:"setup",value:function(){var i,e,t,n,o,s,r,a,l=this,u=l.settings,c=l.input,p=l.settings.mode,d=c.getAttribute("class")||"",h=k("<div>");if(x(h,u.wrapperClass,d,p),i=k('<div class="items">'),x(i,u.inputClass),h.append(i),t=k('<div style="display:none">'),x(t,u.dropdownClass,p),n=k('<div style="scroll-behavior: smooth;">'),x(n,u.dropdownContentClass),t.append(n),k(u.dropdownParent||h).appendChild(t),u.controlInput)e=k(u.controlInput);else{e=k('<input type="text" autocomplete="off" />');for(var g=["autocorrect","autocapitalize","autocomplete"],f=0;f<g.length;f++){var v=g[f];c.getAttribute(v)&&e.setAttribute(v,c.getAttribute(v))}}u.controlInput||(e.setAttribute("tabindex",c.disabled?"-1":l.tabIndex),i.appendChild(e)),(s=c.getAttribute("id"))&&(e.setAttribute("id",s+"-tomselected"),(r=document.querySelector("label[for='"+s+"']"))&&r.setAttribute("for",s+"-tomselected")),l.settings.copyClassesToDropdown&&x(t,d),h.style.width=c.style.width,l.plugins.names.length&&(o="plugin-"+l.plugins.names.join(" plugin-"),x([h,t],o)),(null===u.maxItems||1<u.maxItems)&&l.is_select_tag&&c.setAttribute("multiple","multiple"),l.settings.placeholder&&e.setAttribute("placeholder",u.placeholder),!l.settings.splitOn&&l.settings.delimiter&&(a=l.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),l.settings.splitOn=new RegExp("\\s*"+a+"+\\s*")),e.type=c.type,l.control=i,l.control_input=e,l.wrapper=h,l.dropdown=t,l.dropdown_content=n,O(t,"mouseenter","[data-selectable]",function(){return l.onOptionHover.apply(l,arguments)}),O(t,"mousedown","[data-selectable]",function(){return l.onOptionSelect.apply(l,arguments)}),i.addEventListener("mousedown",function(e){var t=A(e.target,"."+l.settings.itemClass,i);return t?(e.delegateTarget=t,l.onItemSelect.call(l,e)):l.onMouseDown.call(l,e)}),i.addEventListener("click",function(){return l.onClick.apply(l,arguments)}),e.addEventListener("mousedown",function(e){e.stopPropagation()}),e.addEventListener("keydown",function(){return l.onKeyDown.apply(l,arguments)}),e.addEventListener("keyup",function(){return l.onKeyUp.apply(l,arguments)}),e.addEventListener("keypress",function(){return l.onKeyPress.apply(l,arguments)}),e.addEventListener("resize",function(){l.positionDropdown.apply(l,[])}),e.addEventListener("blur",function(){return l.onBlur.apply(l,arguments)}),e.addEventListener("focus",function(){return l.ignoreBlur=!1,l.onFocus.apply(l,arguments)}),e.addEventListener("paste",function(){return l.onPaste.apply(l,arguments)});function m(e){if(l.isFocused){if(A(e.target,"."+l.settings.wrapperClass,l.wrapper))return!1;l.blur(e.target)}}function y(){l.isOpen&&l.positionDropdown.apply(l,arguments)}function b(){l.ignoreHover=!1}document.addEventListener("mousedown",m),window.addEventListener("sroll",y),window.addEventListener("resize",y),window.addEventListener("mousemove",b),l._destroy=function(){document.removeEventListener("mousedown",m),window.removeEventListener("mousemove",b),window.removeEventListener("sroll",y),window.removeEventListener("resize",y)};for(var w=[];0<c.children.length;)w.push(c.children[0]),c.children[0].remove();this.revertSettings={children:w,tabindex:c.getAttribute("tabindex")},c.setAttribute("tabindex",-1),c.setAttribute("hidden","hidden"),c.insertAdjacentElement("afterend",l.wrapper),l.setValue(u.items),delete u.items,l.supportsValidity()&&c.addEventListener("invalid",function(e){e.preventDefault(),l.isInvalid=!0,l.refreshState()}),l.updateOriginalInput(),l.refreshItems(),l.refreshState(),l.isSetup=!0,c.disabled&&l.disable(),l.on("change",this.onChange),x(c,"tomselected"),l.trigger("initialize"),!0===u.preload&&l.onSearchChange("")}},{key:"supportsValidity",value:function(){return!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity}},{key:"setupOptions",value:function(e,t){var i,n;for(t=t||[],i=0,n=(e=e||[]).length;i<n;i++)this.registerOption(e[i]);for(i=0,n=t.length;i<n;i++)this.registerOptionGroup(t[i])}},{key:"setupTemplates",value:function(){var i=this.settings.labelField,n=this.settings.optgroupLabelField,e={optgroup:function(e,t){var i=document.createElement("div");return i.className="optgroup",i.appendChild(e.options),i},optgroup_header:function(e,t){return'<div class="optgroup-header">'+t(e[n])+"</div>"},option:function(e,t){return"<div>"+t(e[i])+"</div>"},item:function(e,t){return"<div>"+t(e[i])+"</div>"},option_create:function(e,t){return'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>"},no_results:function(){return'<div class="no-results">No results found</div>'}};this.settings.render=Object.assign({},e,this.settings.render)}},{key:"setupCallbacks",value:function(){var e,t,i={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(e in i)(t=this.settings[i[e]])&&this.on(e,t)}},{key:"onClick",value:function(e){this.isFocused&&this.isOpen||(this.focus(),e.preventDefault())}},{key:"onMouseDown",value:function(e){var t=this;if(t.isFocused){if(e.target!==t.control_input)return"single"===t.settings.mode?t.isOpen?t.close():t.open():t.setActiveItem(null),!1}else window.setTimeout(function(){t.focus()},0)}},{key:"onChange",value:function(){f(this.input,"change")}},{key:"onPaste",value:function(e){var o=this;o.isFull()||o.isInputHidden||o.isLocked?e.preventDefault():o.settings.splitOn&&setTimeout(function(){var e=o.inputValue();if(e.match(o.settings.splitOn))for(var t=e.trim().split(o.settings.splitOn),i=0,n=t.length;i<n;i++)o.createItem(t[i])},0)}},{key:"onKeyPress",value:function(e){if(this.isLocked)return e&&e.preventDefault();var t=String.fromCharCode(e.keyCode||e.which);return this.settings.create&&"multi"===this.settings.mode&&t===this.settings.delimiter?(this.createItem(),e.preventDefault(),!1):void 0}},{key:"onKeyDown",value:function(e){e.target,this.control_input;var t,i,n=this;if(n.isLocked)9!==e.keyCode&&e.preventDefault();else{switch(e.keyCode){case 65:if(n.isKeyDown(y,e))return void n.selectAll();break;case 27:return void(n.isOpen&&(e.preventDefault(),e.stopPropagation(),n.close()));case 40:return!n.isOpen&&n.hasOptions?n.open():n.activeOption&&(n.ignoreHover=!0,(t=n.getAdjacent(n.activeOption,1))&&n.setActiveOption(t,!0)),void e.preventDefault();case 38:return n.activeOption&&(n.ignoreHover=!0,(i=n.getAdjacent(n.activeOption,-1))&&n.setActiveOption(i,!0)),void e.preventDefault();case 13:return void(n.isOpen&&n.activeOption&&(n.onOptionSelect({delegateTarget:n.activeOption}),e.preventDefault()));case 37:return void n.advanceSelection(-1,e);case 39:return void n.advanceSelection(1,e);case 9:return n.settings.selectOnTab&&n.isOpen&&n.activeOption&&(n.onOptionSelect({delegateTarget:n.activeOption}),e.preventDefault()),void(n.settings.create&&n.createItem()&&e.preventDefault());case 8:case 46:return void n.deleteSelection(e)}!n.isInputHidden||n.isKeyDown(y,e)||e.preventDefault()}}},{key:"onKeyUp",value:function(e){var t=this;if(t.isLocked)return e&&e.preventDefault();var i=t.inputValue();t.lastValue!==i&&(t.lastValue=i,t.onSearchChange(i),t.refreshOptions(),t.trigger("type",i))}},{key:"onSearchChange",value:function(t){var i=this,n=i.settings.load;n&&(i.loadedSearches.hasOwnProperty(t)||(i.loadedSearches[t]=!0,i.load(function(e){n.apply(i,[t,e])})))}},{key:"onFocus",value:function(e){var t=this,i=t.isFocused;if(t.isDisabled)return t.blur(),e&&e.preventDefault(),!1;t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.onSearchChange(""),i||t.trigger("focus"),t.activeItems.length||(t.showInput(),t.setActiveItem(null),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}},{key:"onBlur",value:function(e,t){var i=this;if(i.isFocused){if(i.isFocused=!1,i.ignoreFocus=!1,!i.ignoreBlur&&document.activeElement===i.dropdown_content)return i.ignoreBlur=!0,void i.onFocus(e);var n=function(){i.close(),i.setActiveItem(null),i.setActiveOption(null),i.setCaret(i.items.length),i.refreshState(),t&&t.focus&&t.focus(),i.isBlurring=!1,i.trigger("blur")};i.isBlurring=!0,i.settings.create&&i.settings.createOnBlur?i.createItem(null,!1,n):n()}}},{key:"onOptionHover",value:function(e){this.ignoreHover||this.setActiveOption(e.delegateTarget,!1)}},{key:"onOptionSelect",value:function(e){var t,i=this;e.preventDefault&&(e.preventDefault(),e.stopPropagation());var n=e.delegateTarget;n&&(n.parentNode&&n.parentNode.matches("[data-disabled]")||(n.classList.contains("create")?i.createItem(null,function(){i.settings.closeAfterSelect&&i.close()}):void 0!==(t=n.dataset.value)&&(i.lastQuery=null,i.addItem(t),i.settings.closeAfterSelect?i.close():!i.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&i.setActiveOption(i.getOption(t)))))}},{key:"onItemSelect",value:function(e){this.isLocked||"multi"===this.settings.mode&&(e.preventDefault(),this.setActiveItem(e.delegateTarget,e))}},{key:"load",value:function(e){var i=this;x(i.wrapper,i.settings.loadingClass),i.loading++,e.apply(i,[function(e,t){i.loading=Math.max(i.loading-1,0),i.setupOptions(e,t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||F(i.wrapper,i.settings.loadingClass),i.trigger("load",e)}])}},{key:"loadDebounce",value:function(i,n){var o;return function(){var e=this,t=arguments;o&&(e.loading=Math.max(e.loading-1,0)),window.clearTimeout(o),o=window.setTimeout(function(){o=null,i.apply(e,t)},n)}}},{key:"setTextboxValue",value:function(e){var t=this.control_input;t.value!==e&&(t.value=e,f(t,"update"),this.lastValue=e)}},{key:"getValue",value:function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}},{key:"setValue",value:function(e,t){g(this,t?[]:["change"],function(){this.clear(t),this.addItems(e,t)})}},{key:"setActiveItem",value:function(e,t){var i,n,o,s,r,a;if("single"!==this.settings.mode){if(!e)return F(this.activeItems,"active"),this.activeItems=[],void(this.isFocused&&this.showInput());if("mousedown"===(i=t&&t.type.toLowerCase())&&this.isKeyDown(16,t)&&this.activeItems.length){for(a=this.getLastActive(),o=Array.prototype.indexOf.apply(this.control.children,[a]),(s=Array.prototype.indexOf.apply(this.control.children,[e]))<o&&(r=o,o=s,s=r),n=o;n<=s;n++)e=this.control.children[n],-1===this.activeItems.indexOf(e)&&this.setActiveItemClass(e);t.preventDefault()}else"mousedown"===i&&this.isKeyDown(y,t)||"keydown"===i&&this.isKeyDown(16,t)?e.classList.contains("active")?this.removeActiveItem(e):this.setActiveItemClass(e):(F(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(e));this.hideInput(),this.isFocused||this.focus()}}},{key:"setActiveItemClass",value:function(e){var t=this.control.querySelector(".last-active");t&&F(t,"last-active"),x(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}},{key:"removeActiveItem",value:function(e){var t=this.activeItems.indexOf(e);this.activeItems.splice(t,1),F(e,"active")}},{key:"setActiveOption",value:function(e,t){var i,n,o;e!==this.activeOption&&(this.activeOption&&F(this.activeOption,"active"),this.activeOption=null,e&&(this.activeOption=e,x(e,"active"),!t&&void 0!==t||(i=this.dropdown_content.clientHeight,t=this.dropdown_content.scrollTop||0,n=this.activeOption.offsetHeight,i+t<(o=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+t)+n?this.dropdown_content.scrollTop=o-i+n:o<t&&(this.dropdown_content.scrollTop=o))))}},{key:"selectAll",value:function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(x(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}},{key:"hideInput",value:function(){this.settings.controlInput||(this.setTextboxValue(""),v(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)}},{key:"showInput",value:function(){this.settings.controlInput||(v(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)}},{key:"inputValue",value:function(){return this.control_input.value.trim()}},{key:"focus",value:function(){var e=this;e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),window.setTimeout(function(){e.ignoreFocus=!1,e.onFocus()},0))}},{key:"blur",value:function(e){this.control_input.blur(),this.onBlur(null,e)}},{key:"getScoreFunction",value:function(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}},{key:"getSearchOptions",value:function(){var e=this.settings,t=e.sortField;return"string"==typeof t&&(t=[{field:t}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}},{key:"search",value:function(e){var t,i,n,o=this,s=o.settings,r=this.getSearchOptions();if(s.score&&"function"!=typeof(n=o.settings.score.apply(this,[e])))throw new Error('Tom Select "score" setting must be a function that returns a function');if(e!==o.lastQuery?(o.lastQuery=e,i=o.sifter.search(e,Object.assign(r,{score:n})),o.currentResults=i):i=Object.assign({},o.currentResults),s.hideSelected)for(t=i.items.length-1;0<=t;t--)-1!==o.items.indexOf(D(i.items[t].id))&&i.items.splice(t,1);return i}},{key:"refreshOptions",value:function(e){var t,i,n,o,s,r;void 0===e&&(e=!0);var a,l,u,c,p,d,h,g=this,f=g.inputValue(),v=g.search(f),m=g.activeOption&&D(g.activeOption.dataset.value),y=!1,b=v.items.length;for("number"==typeof g.settings.maxOptions&&(b=Math.min(b,g.settings.maxOptions)),0<b&&(y=!0),i={},n=[],t=0;t<b;t++)for(var w,O=g.options[v.items[t].id],k=D(O[g.settings.valueField]),C=(C=g.getOption(k))||g.render("option",O),I=O[g.settings.optgroupField]||"",A=0,_=(w=Array.isArray(I)?I:[I])&&w.length;A<_;A++)I=w[A],g.optgroups.hasOwnProperty(I)||(I=""),i.hasOwnProperty(I)||(i[I]=document.createDocumentFragment(),n.push(I)),0<A&&(C=C.cloneNode(!0),F(C,"active")),i[I].appendChild(C);for(this.settings.lockOptgroupOrder&&n.sort(function(e,t){return(g.optgroups[e].$order||0)-(g.optgroups[t].$order||0)}),o=document.createDocumentFragment(),t=0,b=n.length;t<b;t++){I=n[t],g.optgroups.hasOwnProperty(I)&&i[I].children.length?((a=document.createDocumentFragment()).appendChild(g.render("optgroup_header",g.optgroups[I])),a.appendChild(i[I]),l=g.render("optgroup",{group:g.optgroups[I],options:a}),o.appendChild(l)):o.appendChild(i[I])}if(g.dropdown_content.innerHTML="",g.dropdown_content.appendChild(o),g.settings.highlight&&(g.dropdown_content,u=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(u,function(e,t){var i=e.parentNode;i.replaceChild(e.firstChild,e),i.normalize()}),v.query.length&&v.tokens.length))for(t=0,b=v.tokens.length;t<b;t++)!function(e,t){var u,i;"string"==typeof t&&!t.length||(u="string"==typeof t?new RegExp(t,"i"):t,i=function e(t){var i=0;if(3===t.nodeType){var n,o,s,r,a=t.data.search(u);0<=a&&0<t.data.length&&(n=t.data.match(u),(o=document.createElement("span")).className="highlight",(s=t.splitText(a)).splitText(n[0].length),r=s.cloneNode(!0),o.appendChild(r),s.parentNode.replaceChild(o,s),i=1)}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var l=0;l<t.childNodes.length;++l)l+=e(t.childNodes[l]);return i},i(e))}(g.dropdown_content,v.tokens[t].regex);if(!g.settings.hideSelected)for(t=0,b=g.items.length;t<b;t++){var S=g.getOption(g.items[t]);S&&x(S,"selected")}0===v.items.length&&g.settings.render.no_results&&!g.loading&&f.length&&(c=g.render("no_results",{input:f}),y=!0,g.dropdown_content.insertBefore(c,g.dropdown_content.firstChild)),(s=g.canCreate(f))&&(y=!0,r=g.render("option_create",{input:f}),g.dropdown_content.insertBefore(r,g.dropdown_content.firstChild)),g.hasOptions=0<v.items.length||s,y?(h=0<v.items.length?(d=m&&g.getOption(m))&&g.dropdown_content.contains(d)?d:"single"===g.settings.mode&&g.items.length?g.getOption(g.items[0]):(p=0,r&&!g.settings.addPrecedence&&(p=1),g.selectable()[p]):r,g.setActiveOption(h),e&&!g.isOpen&&g.open()):(g.setActiveOption(null),e&&g.isOpen&&g.close())}},{key:"selectable",value:function(){return this.dropdown_content.querySelectorAll("[data-selectable]")}},{key:"addOption",value:function(e){var t,i,n,o=this;if(Array.isArray(e))for(t=0,i=e.length;t<i;t++)o.addOption(e[t]);else(n=o.registerOption(e))&&(o.userOptions[n]=!0,o.lastQuery=null,o.trigger("option_add",n,e))}},{key:"registerOption",value:function(e){var t=D(e[this.settings.valueField]);return null!=t&&!this.options.hasOwnProperty(t)&&(e.$order=e.$order||++this.order,this.options[t]=e,t)}},{key:"registerOptionGroup",value:function(e){var t=D(e[this.settings.optgroupValueField]);return!!t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}},{key:"addOptionGroup",value:function(e,t){t[this.settings.optgroupValueField]=e,(e=this.registerOptionGroup(t))&&this.trigger("optgroup_add",e,t)}},{key:"removeOptionGroup",value:function(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}},{key:"clearOptionGroups",value:function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}},{key:"updateOption",value:function(e,t){var i,n,o,s,r,a,l,u=this;if(e=D(e),o=D(t[u.settings.valueField]),null!==e&&u.options.hasOwnProperty(e)){if("string"!=typeof o)throw new Error("Value must be set in option data");l=u.options[e].$order,o!==e&&(delete u.options[e],-1!==(s=u.items.indexOf(e))&&u.items.splice(s,1,o)),t.$order=t.$order||l,u.options[o]=t,r=u.renderCache.item,a=u.renderCache.option,r&&(delete r[e],delete r[o]),a&&(delete a[e],delete a[o]),-1!==u.items.indexOf(o)&&(i=u.getItem(e),n=u.render("item",t),i.classList.contains("active")&&x(n,"active"),i.parentNode.insertBefore(n,i),i.remove()),u.lastQuery=null,u.isOpen&&u.refreshOptions(!1)}}},{key:"removeOption",value:function(e,t){var i=this;e=D(e);var n=i.renderCache.item,o=i.renderCache.option;n&&delete n[e],o&&delete o[e],delete i.userOptions[e],delete i.options[e],i.lastQuery=null,i.trigger("option_remove",e),i.removeItem(e,t)}},{key:"clearOptions",value:function(){this.loadedSearches={},this.userOptions={},this.clearCache();var e={};for(var t in this.options)this.options.hasOwnProperty(t)&&0<=this.items.indexOf(t)&&(e[t]=this.options[t]);this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}},{key:"getOption",value:function(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}},{key:"getAdjacent",value:function(e,t,i){var n=2<arguments.length&&void 0!==i?i:"option";if(e){var o=this.settings.optionClass,s=this.dropdown;"item"==n&&(s=this.control,o=this.settings.itemClass);for(var r=s.querySelectorAll("."+o),a=0;a<r.length;a++)if(r[a]==e)return 0<t?r[a+1]:r[a-1]}}},{key:"getElementWithValue",value:function(e,t){if(null!=(e=D(e)))for(var i=0,n=t.length;i<n;i++)if(t[i].getAttribute("data-value")===e)return t[i]}},{key:"getItem",value:function(e){return this.getElementWithValue(e,this.control.children)}},{key:"addItems",value:function(e,t){this.buffer=document.createDocumentFragment();for(var i=this.control.children,n=0;n<i.length;n++)this.buffer.appendChild(i[n]);for(var o=Array.isArray(e)?e:[e],n=0,s=o.length;n<s;n++)this.isPending=n<s-1,this.addItem(o[n],t);var r=this.control;r.insertBefore(this.buffer,r.firstChild),this.buffer=null}},{key:"addItem",value:function(a,l){g(this,l?[]:["change"],function(){var e,t,i,n,o,s=this,r=s.settings.mode;a=D(a),(-1===s.items.indexOf(a)||("single"===r&&s.close(),"single"!==r&&s.settings.duplicates))&&s.options.hasOwnProperty(a)&&("single"===r&&s.clear(l),"multi"===r&&s.isFull()||(o=s.render("item",s.options[a]),this.control.contains(o)&&(o=o.cloneNode(!0)),e=s.isFull(),s.items.splice(s.caretPos,0,a),s.insertAtCaret(o),s.isPending&&(e||!s.isFull())||s.refreshState(),s.isSetup&&(t=s.selectable(),s.isPending||(i=s.getOption(a),n=s.getAdjacent(i,1),s.refreshOptions(s.isFocused&&"single"!==r),n&&s.setActiveOption(n)),!t.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.trigger("item_add",a,o),s.isPending||s.updateOriginalInput({silent:l}))))})}},{key:"removeItem",value:function(e,t){var i,n,o=this.getItem(e);o&&(e=D(o.dataset.value),-1!==(i=this.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(n=this.activeItems.indexOf(o),this.activeItems.splice(n,1),F(o,"active")),this.items.splice(i,1),this.lastQuery=null,!this.settings.persist&&this.userOptions.hasOwnProperty(e)&&this.removeOption(e,t),i<this.caretPos&&this.setCaret(this.caretPos-1),this.refreshState(),this.updateOriginalInput({silent:t}),this.positionDropdown(),this.trigger("item_remove",e,o)))}},{key:"createItem",value:function(e,i){var t,n=this,o=n.caretPos;e=e||n.inputValue();var s=arguments[arguments.length-1];if("function"!=typeof s&&(s=function(){}),"boolean"!=typeof i&&(i=!0),!n.canCreate(e))return s(),!1;n.lock();function r(e){if(n.unlock(),!e||"object"!==l(e))return s();var t=D(e[n.settings.valueField]);if("string"!=typeof t)return s();n.setTextboxValue(""),n.addOption(e),n.setCaret(o),n.addItem(t),n.refreshOptions(i&&"single"!==n.settings.mode),s(e),a=!0}var a=!1;return"function"==typeof n.settings.create?t=n.settings.create.apply(this,[e,r]):((t={})[n.settings.labelField]=e,t[n.settings.valueField]=e),a||r(t),!0}},{key:"refreshItems",value:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()}},{key:"refreshState",value:function(){var e=this;e.refreshValidityState();var t=e.isFull(),i=e.isLocked;e.wrapper.classList.toggle("rtl",e.rtl);var n,o=e.control.classList;o.toggle("focus",e.isFocused),o.toggle("disabled",e.isDisabled),o.toggle("required",e.isRequired),o.toggle("invalid",e.isInvalid),o.toggle("locked",i),o.toggle("full",t),o.toggle("not-full",!t),o.toggle("input-active",e.isFocused&&!e.isInputHidden),o.toggle("dropdown-active",e.isOpen),o.toggle("has-options",(n=e.options,0===Object.keys(n).length)),o.toggle("has-items",0<e.items.length)}},{key:"refreshValidityState",value:function(){if(!this.isRequired)return!1;var e=!this.items.length;this.isInvalid=e,this.control_input.required=e,this.input.required=!e}},{key:"isFull",value:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}},{key:"updateOriginalInput",value:function(e){var t,i,n,o,s=this;if(e=e||{},s.is_select_tag){for(n=[],t=0,i=s.items.length;t<i;t++)o=s.options[s.items[t]][s.settings.labelField]||"",n.push('<option value="'+h(s.items[t])+'" selected="selected">'+h(o)+"</option>");n.length||this.input.hasAttribute("multiple")||n.push('<option value="" selected="selected"></option>'),s.input.innerHTML=n.join("")}else s.input.value=s.getValue(),s.input.setAttribute("value",s.input.value);s.isSetup&&(e.silent||s.trigger("change",s.input.value))}},{key:"open",value:function(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.focus(),e.isOpen=!0,e.refreshState(),v(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),v(e.dropdown,{visibility:"visible",display:"block"}),e.trigger("dropdown_open",e.dropdown))}},{key:"close",value:function(){var e=this,t=e.isOpen;"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.isBlurring||e.blur()),e.isOpen=!1,v(e.dropdown,{display:"none"}),e.setActiveOption(null),e.refreshState(),t&&e.trigger("dropdown_close",e.dropdown)}},{key:"positionDropdown",value:function(){var e,t=0,i=this.control,n=i.offsetHeight;"body"===this.settings.dropdownParent?(n+=(e=i.getBoundingClientRect()).top+window.scrollY,t=e.left+window.scrollX):this.settings.dropdownParent?n=(i=k(this.settings.dropdownParent)).offsetHeight:(n+=i.offsetTop,t=i.offsetLeft),v(this.dropdown,{width:i.getBoundingClientRect().width+"px",top:n+"px",left:t+"px"})}},{key:"clear",value:function(e){if(this.items.length){for(var t=this.controlChildren(),i=0;i<t.length;i++)t[i].remove();this.items=[],this.lastQuery=null,this.setCaret(0),this.setActiveItem(null),this.updateOriginalInput({silent:e}),this.refreshState(),this.showInput(),this.trigger("clear")}}},{key:"insertAtCaret",value:function(e){var t=Math.min(this.caretPos,this.items.length),i=this.buffer||this.control;0===t?i.insertBefore(e,i.firstChild):i.insertBefore(e,i.children[t]),this.setCaret(t+1)}},{key:"deleteSelection",value:function(e){var t,i,n,o,s,r=this,a=e&&8===e.keyCode?-1:1,l={start:(s=r.control_input).selectionStart,length:s.selectionEnd-s.selectionStart},u=[];if(r.activeItems.length){for(o=_(r.activeItems,a),n=m(o),0<a&&n++,t=0,i=r.activeItems.length;t<i;t++)u.push(r.activeItems[t].dataset.value);e&&(e.preventDefault(),e.stopPropagation())}else(r.isFocused||"single"===r.settings.mode)&&r.items.length&&(a<0&&0===l.start&&0===l.length?u.push(r.items[r.caretPos-1]):0<a&&l.start===r.inputValue().length&&u.push(r.items[r.caretPos]));if(!u.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.apply(r,[u,e]))return!1;for(void 0!==n&&r.setCaret(n);u.length;)r.removeItem(u.pop());return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}},{key:"advanceSelection",value:function(e,t){var i,n,o;0!==e&&(this.rtl&&(e*=-1),this.isKeyDown(y,t)||this.isKeyDown(16,t)?(n=this.getLastActive(e),(o=this.getAdjacent(n,e,"item"))&&(o.classList.contains("active")&&this.removeActiveItem(n),this.setActiveItemClass(o))):this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+e):(n=this.getLastActive(e))&&(i=m(n),this.setCaret(0<e?i+1:i),this.setActiveItem(null)))}},{key:"getLastActive",value:function(e){var t=this.control.querySelector(".last-active");return t||function(e,t,i){var n=e.querySelectorAll(t);if(n)return _(n,i)}(this.control,".active",e)}},{key:"setCaret",value:function(e){var t=this;if(e="single"===t.settings.mode||t.settings.controlInput?t.items.length:Math.max(0,Math.min(t.items.length,e)),!t.settings.controlInput&&!t.isPending)for(var i,n=this.controlChildren(),o=n.length,s=0;s<o;s++)i=n[s],s<e?t.control_input.insertAdjacentElement("beforebegin",i):t.control.appendChild(i);t.caretPos=e}},{key:"controlChildren",value:function(){return Array.prototype.filter.call(this.control.children,function(e){return"INPUT"!==e.nodeName})}},{key:"lock",value:function(){this.close(),this.isLocked=!0,this.refreshState()}},{key:"unlock",value:function(){this.isLocked=!1,this.refreshState()}},{key:"disable",value:function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()}},{key:"enable",value:function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()}},{key:"destroy",value:function(){var e=this.revertSettings;this.trigger("destroy"),this.off(),this.wrapper.remove(),this.dropdown.remove(),this.input.innerHTML="",e.tabindex?this.input.setAttribute("tabindex",e.tabindex):this.input.removeAttribute("tabindex"),F(this.input,"tomselected"),this.input.removeAttribute("hidden");for(var t=0;t<e.children.length;t++)this.input.appendChild(e.children[t]);this._destroy(),delete this.input.tomselect}},{key:"render",value:function(e,t){var i,n,o="",s=this;return"option"!==e&&"item"!==e||(i=D(t[s.settings.valueField]),!s.renderCache[e].hasOwnProperty(i))?(o=k(s.settings.render[e].apply(this,[t,h])),"option"===e||"option_create"===e?t[s.settings.disabledField]||o.setAttribute("data-selectable",""):"optgroup"===e&&(n=t.group[s.settings.optgroupValueField],o.setAttribute("data-group",n),t.group[s.settings.disabledField]&&o.setAttribute("data-disabled","")),"option"!==e&&"item"!==e||(o.setAttribute("data-value",i),x(o,"item"===e?s.settings.itemClass:s.settings.optionClass),s.renderCache[e][i]=o),o):s.renderCache[e][i]}},{key:"clearCache",value:function(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}},{key:"canCreate",value:function(e){if(!this.settings.create)return!1;var t=this.settings.createFilter;return e.length&&("function"!=typeof t||t.apply(this,[e]))&&(!(t instanceof RegExp)||t.test(e))}},{key:"isKeyDown",value:function(e,t){return!!t&&(!t.altKey&&((!t[b]||!t.shiftKey)&&(!(e!=y||!t[b])||!(16!=e||!t.shiftKey))))}},{key:"hook",value:function(i,e,n){var o=this,s=o[e];o[e]=function(){var e,t;return"after"===i&&(e=s.apply(o,arguments)),t=n.apply(o,arguments),"instead"===i?t:("before"===i&&(e=s.apply(o,arguments)),e)}}}])&&n(e.prototype,t),i&&n(e,i),r}();if(void 0===e)throw'Dependency MicroPlugin is missing. Make sure you either: (1) are using the "complete" version of Tom Select, or (2) require MicroPlugin before you load Tom Select.';return e.mixin(S),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,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"tomselect-control",inputClass:"tomselect-input",dropdownClass:"tomselect-dropdown",dropdownContentClass:"tomselect-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}},S.define("change_listener",function(e){var t=this,i=!1;t.input.addEventListener("change",function(){var e;i?i=!1:(i=!0,e=w(t.input,{}),t.setupOptions(e.options,e.optgroups),t.setValue(e.items))})}),S.define("drag_drop",function(e){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');var t,i,n;"multi"===this.settings.mode&&(i=(t=this).lock,n=t.unlock,t.hook("instead","lock",function(){var e=t.control.dataset.sortable;return e&&e.disable(),i.apply(t,arguments)}),t.hook("instead","unlock",function(){var e=t.control.dataset.sortable;return e&&e.enable(),n.apply(t,arguments)}),t.hook("after","setup",function(){var i=$(t.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:t.isLocked,start:function(e,t){t.placeholder.css("width",t.helper.css("width")),i.css({overflow:"visible"})},stop:function(){i.css({overflow:"hidden"});var e=[];i.children("[data-value]").each(function(){e.push($(this).attr("data-value"))}),t.setValue(e)}})}))}),S.define("dropdown_header",function(t){var i=this;t=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:function(e){return'<div class="'+e.headerClass+'"><div class="'+e.titleRowClass+'"><span class="'+e.labelClass+'">'+e.title+'</span><a href="javascript:void(0)" class="'+e.closeClass+'">&times;</a></div></div>'}},t),i.hook("after","setup",function(){var e=k(t.html(t));i.dropdown.insertBefore(e,i.dropdown.firstChild)})}),S.define("input_autogrow",function(e){var a=this;a.hook("after","setup",function(){var e=document.createElement("span"),t=this.control_input;e.style.position="absolute",e.style.top="-99999px",e.style.left="-99999px",e.style.width="auto",e.style.padding=0,e.style.whiteSpace="pre",a.wrapper.appendChild(e);for(var i=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"],n=0,o=i.length;n<o;n++){var s=i[n];e.style[s]=t.style[s]}function r(){e.textContent=t.value,t.style.width=e.clientWidth+"px"}t.addEventListener("input",r),t.addEventListener("keyup",r),t.addEventListener("blur",r),t.addEventListener("update",r)})}),S.define("no_backspace_delete",function(e){this.hook("instead","setActiveItem",function(){}),this.hook("instead","selectAll",function(){}),this.hook("instead","deleteSelection",function(){})}),S.define("optgroup_columns",function(e){var s=this,r=s.onKeyDown;s.hook("instead","onKeyDown",function(e){var t,i,n,o;return!s.isOpen||37!==e.keyCode&&39!==e.keyCode?r.apply(s,arguments):(s.ignoreHover=!0,o=A(s.activeOption,"[data-group]"),t=m(s.activeOption,"[data-selectable]"),void((o=37===e.keyCode?o.previousSibling:o.nextSibling)&&(i=(n=o.querySelectorAll("[data-selectable]"))[Math.min(n.length-1,t)])&&s.setActiveOption(i)))})}),S.define("remove_button",function(e){e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e);var n,o=this;e.append&&(n='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+h(e.title)+'">'+e.label+"</a>",o.hook("after","setupTemplates",function(){var t=o.settings.render.item;o.settings.render.item=function(){var i=k(t.apply(o,arguments)),e=k(n);return i.appendChild(e),e.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation()}),e.addEventListener("click",function(e){var t;e.preventDefault(),e.stopPropagation(),"single"!==o.settings.mode&&e.stopPropagation(),o.isLocked||(t=i.dataset.value,o.removeItem(t),o.refreshOptions(!1))}),i}}))}),S.define("restore_on_backspace",function(n){var o=this;n.text=n.text||function(e){return e[o.settings.labelField]};var s=o.onKeyDown;o.hook("instead","onKeyDown",function(e){var t,i;return 8===e.keyCode&&""===o.control_input.value&&!o.activeItems.length&&0<=(t=o.caretPos-1)&&t<o.items.length?(i=o.options[o.items[t]],o.deleteSelection(e)&&(o.setTextboxValue(n.text.apply(o,[i])),o.refreshOptions(!0)),void e.preventDefault()):s.apply(o,arguments)})}),S});var tomSelect=function(e,t){return new TomSelect(e,t)};

@@ -211,3 +211,3 @@ ---

<td><code>getValue()</code></td>
<td>Returns the value of the control. If multiple items can be selected with a "select" input tag (e.g. <a href="usage.md#maxItems">&lt;select multiple&gt;</a>), this returns an array. Otherwise, returns a string (separated by <code>delimiter</code> if "multiple").</td>
<td>Returns the value of the control. If multiple items can be selected with a "select" input tag (e.g. <a href="/docs#maxItems">&lt;select multiple&gt;</a>), this returns an array. Otherwise, returns a string (separated by <code>delimiter</code> if "multiple").</td>
</tr>

@@ -214,0 +214,0 @@ <tr>

@@ -8,20 +8,9 @@ ---

### Pull Requests
1) **Include tests**
2) Add an entry to the top of the CHANGELOG, and update the documentation
in `docs/` as needed. (Refactors and documentation changes don't need a
changelog entry.)
That's it. If you're motivated to fix a bug you've found or develop a new feature, we'd love to see it.
Including tests helps to demonstrate the functionality you're adding and are required before we'll merge your changes.
3) Squash your commits together in one or a few complete, logical commits,
with a concise and descriptive message. One commit means one
feature/bugfix/thing that has changed, or a diff bringing the code one
step forward to a better, working state.
4) Once your commit is nice and clean, and you want to *discard the other
changes*, you can use `git checkout .` (that will erase changes to
tracked files) and `git clean [-i/--interactive]` (to erase untracked
files). **However, be careful with those commands, as their function
is to erase things/changes.**
### Tests

@@ -31,10 +20,7 @@ Please ensure all the tests pass:

```shell
$ yarn test # headless Firefox
$ BROWSERS=Firefox yarn test
$ BROWSERS=Firefox,Chrome yarn test
$ BROWSERS=Firefox,Chrome,Safari yarn test
$ yarn test
```
### Local environment
To run locally:
Runing ```yarn start``` on your repo will start a web server allowing you to view a local copy of tom-select.js.org.

@@ -45,6 +31,2 @@ ```shell

You can then run the examples in `http://localhost:8000/examples/`.
However, be careful not to add the `dist/` files in your commit, as
Grunt automatically regenerates the files in `dist/` as the source is
changed.
Once started, you can run all the examples at `http://localhost:8000/`.

@@ -77,3 +77,3 @@ ---

create: function(input){
return: {value:input,text:input}
return {value:input,text:input}
}

@@ -469,3 +469,6 @@ ```

'optgroup': function(data) {
return '<div class="optgroup"></div>';
let optgroup = document.createElement('div');
optgroup.className = 'optgroup';
optgroup.appendChild(data.options);
return optgroup;
},

@@ -472,0 +475,0 @@ 'optgroup_header': function(data, escape) {

@@ -14,2 +14,3 @@ ---

## Performance and Usability

@@ -24,2 +25,3 @@ - framework agnostic (doesn't require jQuery, Vue or any other JavaScript framework)

## Breaking Changes

@@ -35,2 +37,3 @@ - removed support for older browsers ES5

## Issues / Pull requests

@@ -46,8 +49,10 @@ - [#1363](https://github.com/selectize/selectize.js/issues/1363) Autofill disable possibility

- [#999](https://github.com/selectize/selectize.js/issues/999) Don't clear the text box value on blur
- [#1104](https://github.com/selectize/selectize.js/issues/1104) Replace values in single-item selection #
- [#1104](https://github.com/selectize/selectize.js/issues/1104) Replace values in single-item selection
- [#1132](https://github.com/selectize/selectize.js/issues/1132) Can't enter 'ą' character in tags mode
- [#102](https://github.com/selectize/selectize.js/issues/102) Listen to original select changes (via 'change_listener' plugin)
- [#905](https://github.com/selectize/selectize.js/issues/905) Support for Bootstrap 4
## Development
- examples and documentation generated using 11ty
- babel compiler
<h1 class="display-3 mt-0">Tom Select</h1>
<div class="text-center">
<h1 class="display-2 mt-5">Tom Select</h1>
<a href="https://github.com/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="GitHub forks" src="https://img.shields.io/github/forks/orchidjs/tom-select?label=Github%20forks&style=for-the-badge&color=007ec6"></a>
<a href="https://www.npmjs.com/package/tom-select" class="m-1 d-inline-block"><img alt="npmjs.org" style="height:28px" src="https://img.shields.io/npm/v/tom-select.svg?style=for-the-badge&color=007ec6"></a>
<a href="https://travis-ci.org/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="Travis.org" style="height:28px" src="https://img.shields.io/travis/orchidjs/tom-select?style=for-the-badge"></a>
<a href="https://coveralls.io/github/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="Coveralls Coverage" style="height:28px" src="https://img.shields.io/coveralls/github/orchidjs/tom-select?color=4c1&style=for-the-badge"></a>
<a href="https://github.com/orchidjs/tom-select/issues" class="m-1 d-inline-block"><img alt="GitHub Issues" style="height:28px" src="https://img.shields.io/github/issues/orchidjs/tom-select?style=for-the-badge"></a>
</div>
<!-- [![NPM version](http://img.shields.io/npm/v/selectize.svg?style=flat)](https://www.npmjs.org/package/selectize)
[![CDNJS version](http://img.shields.io/cdnjs/v/selectize.js.svg?style=flat)](https://cdnjs.com/libraries/selectize.js)
-->
[![Build Status](https://travis-ci.org/orchidjs/tom-select.svg?branch=master)](https://travis-ci.org/orchidjs/tom-select)
[![Coverage Status](https://coveralls.io/repos/github/orchidjs/tom-select/badge.svg?branch=master)](https://coveralls.io/github/orchidjs/tom-select?branch=master)
<div class="lead my-4">
Tom Select is a versatile and dynamic &lt;select&gt; UI control.
With autocomplete and native-feeling keyboard navigation, it's useful for tagging, contact lists, country selectors, and so on.
Tom Select was forked from <a href="/docs/selectize.js/">selectize.js</a> to provide the same powerful UI and API but with a framework agnostic design.
</div>
<div class="w-50 mx-auto">
<h3>Example</h3>
<div class="row py-5">
<div class="col-lg-6 offset-lg-3 col-md-8 offset-md-2 mx-auto">
<h5 class="mt-3">Example</h5>
<link rel="stylesheet" href="/css/tom-select.bootstrap4.css">

@@ -29,8 +26,18 @@ <select id="select-tags" multiple placeholder="Best movies and TV shows">

tomSelect("#select-tags",{
create: true
plugins: ['remove_button'],
create: true,
});
</script>
</div>
</div>
<div class="lead my-5">
Tom Select is a versatile and dynamic &lt;select&gt; UI control.
With autocomplete and native-feeling keyboard navigation, it's useful for tagging, contact lists, country selectors, and so on.
Tom Select was forked from <a href="/docs/selectize.js/">selectize.js</a> to provide the same powerful UI and API but with a framework agnostic design.
</div>
## Features

@@ -56,7 +63,7 @@

var options = {};
tomSelect('#tom-select-it',{});
tomSelect('#tom-select-it',options);
</script>
```
The available options are [documented here](usage.md).
The available options are [documented here](docs).

@@ -81,3 +88,3 @@

By default, all [plugins](plugins) are included. To hand-pick what plugins (if any) to include, run [`grunt`](http://gruntjs.com/) with the "--plugins" flag. After this completes, grab the files you need from the "build" folder.
By default, all [plugins](/docs/plugins.md) are included. To hand-pick what plugins (if any) to include, run [`grunt`](http://gruntjs.com/) with the "--plugins" flag. After this completes, grab the files you need from the "build" folder.

@@ -84,0 +91,0 @@ ```shell

@@ -44,2 +44,3 @@ var fs = require('fs');

'connect',
'check_doc_links',
'watch'

@@ -78,2 +79,61 @@ ])

/**
* Check generated docs for broken links
* https://www.npmjs.com/package/broken-link-checker
*/
grunt.registerTask('check_doc_links','',function(){
var done = this.async();
const {SiteChecker} = require('broken-link-checker');
const options = {
excludeExternalLinks: true,
cacheMaxAge:60,
};
var urls_checked = 0;
var links_checked = 0;
var failures = 0;
const handlers = {
error:function(error){
failures++;
console.log('error',error);
},
page:function(error, page_url, customData){
if( error ){
failures++;
console.log('error!',page_url);
}
urls_checked++;
},
junk:function( result, data ){
links_checked++;
if( result.broken ){
failures++;
console.log('broken junk found',result);
}
},
link:function(link){
if( link.broken ){
failures++;
console.log('broken link',link);
}
},
end:function(){
console.log('urls checked',urls_checked);
console.log('links checked',links_checked);
console.log('failures',failures);
done(failures==0);
}
};
const checker = new SiteChecker(options,handlers)
checker.enqueue('http://localhost:8000/', {});
});
var files_js = [

@@ -321,2 +381,3 @@ 'src/contrib/*.js',

'builddocs',
'check_doc_links',
]

@@ -331,2 +392,3 @@ },

'builddocs',
'check_doc_links',
]

@@ -333,0 +395,0 @@ }

@@ -107,2 +107,3 @@ module.exports = function(config) {

'src/plugins/no_backspace_delete/plugin.js',
'src/plugins/change_listener/plugin.js',
'test/*.js'

@@ -109,0 +110,0 @@ ],

@@ -14,4 +14,5 @@ {

"main": "dist/js/tom-select.complete.js",
"description": "Tom Select is a framework agnostic custom <select> UI control. Useful for tagging, contact lists, country selectors, etc.",
"version": "1.0.0-b.1",
"description": "Tom Select is a versatile and dynamic <select> UI control. Framework agnostic with autocomplete and native-feeling keyboard navigation, it's useful for tagging, contact lists, country selectors, etc.",
"homepage": "https://tom-select.js.org",
"version": "1.0.0-b.2",
"author": "Josh Schmidt (https://github.com/oyejorge)",

@@ -38,2 +39,3 @@ "contributors": [

"bootstrap-sass": "^3.4.1",
"broken-link-checker": "^0.7.8",
"chai": "^4.2.0",

@@ -40,0 +42,0 @@ "cssnano": "^4.1.10",

@@ -1,7 +0,10 @@

# Tom Select
<h1 align="center">Tom Select</h1>
<!-- [![NPM version](http://img.shields.io/npm/v/selectize.svg?style=flat)](https://www.npmjs.org/package/selectize)
[![CDNJS version](http://img.shields.io/cdnjs/v/selectize.js.svg?style=flat)](https://cdnjs.com/libraries/selectize.js) -->
[![Build Status](https://travis-ci.org/orchidjs/tom-select.svg?branch=master)](https://travis-ci.org/orchidjs/tom-select)
[![Coverage Status](https://coveralls.io/repos/github/orchidjs/tom-select/badge.svg?branch=master)](https://coveralls.io/github/orchidjs/tom-select?branch=master)
<p align="center">
<a href="https://github.com/orchidjs/tom-select"><img alt="GitHub forks" src="https://img.shields.io/github/forks/orchidjs/tom-select?label=Github%20forks&style=for-the-badge&color=007ec6"></a>
<a href="https://www.npmjs.com/package/tom-select"><img alt="npmjs.org" style="height:28px" src="https://img.shields.io/npm/v/tom-select.svg?style=for-the-badge&color=007ec6"></a>
<a href="https://travis-ci.org/orchidjs/tom-select"><img alt="Travis.org" style="height:28px" src="https://img.shields.io/travis/orchidjs/tom-select?style=for-the-badge"></a>
<a href="https://coveralls.io/github/orchidjs/tom-select"><img alt="Coveralls Coverage" style="height:28px" src="https://img.shields.io/coveralls/github/orchidjs/tom-select?color=4c1&style=for-the-badge"></a>
<a href="https://github.com/orchidjs/tom-select/issues"><img alt="GitHub Issues" style="height:28px" src="https://img.shields.io/github/issues/orchidjs/tom-select?style=for-the-badge"></a>
</p>

@@ -8,0 +11,0 @@

@@ -14,7 +14,5 @@ const IS_MAC = /Mac/.test(navigator.userAgent);

const KEY_SHIFT = 16;
const KEY_CMD = IS_MAC ? 91 : 17;
const KEY_CTRL = IS_MAC ? 18 : 17;
const KEY_TAB = 9;
const KEY_CMD_NAME = IS_MAC ? 'metaKey' : 'ctrlKey';
const KEY_CTRL_NAME = IS_MAC ? 'altKey' : 'ctrlKey';
const KEY_CTRL_NAME = IS_MAC ? 'metaKey' : 'ctrlKey';

@@ -35,15 +35,1 @@ /**

};
/**
* Mixin will delegate all MicroEvent.js function in the destination object.
*
* - MicroEvent.mixin(Foobar) will make Foobar able to use MicroEvent
*
* @param {object} the object which will support MicroEvent
*/
MicroEvent.mixin = function(destObject){
var props = ['on', 'off', 'trigger'];
for (var i = 0; i < props.length; i++){
destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
}
};

@@ -19,9 +19,4 @@ /**

this.hook('instead','selectAll',function(){});
this.hook('instead','deleteSelection',function(){});
this.settings.onDelete = function(values,evt){
if( values.length > 0 && evt && (evt.keyCode == 8 || evt.keyCode == 46) ){
return false;
}
};
});

@@ -19,7 +19,2 @@ /**

options = Object.assign({
equalizeWidth : true,
equalizeHeight : true
}, options);
var orig_keydown = self.onKeyDown;

@@ -57,60 +52,2 @@

var getScrollbarWidth = function() {
var div;
var width = getScrollbarWidth.width;
var doc = document;
if (typeof width === 'undefined') {
div = doc.createElement('div');
div.innerHTML = '<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>';
div = div.firstChild;
doc.body.appendChild(div);
width = getScrollbarWidth.width = div.offsetWidth - div.clientWidth;
doc.body.removeChild(div);
}
return width;
};
var equalizeSizes = function() {
var i, n, height_max, width, width_last, width_parent, optgroups;
optgroups = self.dropdown_content.querySelectorAll('[data-group]');
n = optgroups.length;
if (!n || !self.dropdown_content.clientWidth ) return;
if (options.equalizeHeight) {
height_max = 0;
for (i = 0; i < n; i++) {
height_max = Math.max(height_max, optgroups[i].clientHeight );
}
for( i = 0; i < n; i++){
optgroups[i].style.height = height_max + 'px';
}
}
if (!n || !self.dropdown_content.clientWidth ) return;
if (options.equalizeWidth) {
width_parent = self.dropdown_content.clientWidth - getScrollbarWidth();
width = Math.round(width_parent / n);
for( i = 0; i < n; i++ ){
optgroups[i].style.width = width + 'px';
}
if (n > 1) {
width_last = width_parent - width * (n - 1);
optgroups[n-1].style.width = width_last+'px';
}
}
};
if (options.equalizeHeight || options.equalizeWidth) {
self.hook('after','positionDropdown',equalizeSizes);
self.hook('after','refreshOptions',equalizeSizes);
}
});

@@ -36,13 +36,21 @@ /**

var orig_render = self.render;
self.hook('after','setupTemplates',function(){
self.hook('instead','render',function( templateName, data){
var rendered = orig_render.apply(self,arguments);
var orig_render_item = self.settings.render.item;
if( templateName == 'item' ){
self.settings.render.item = function(){
var rendered = getDom(orig_render_item.apply(self, arguments));
var close_button = getDom(html);
rendered.appendChild(close_button);
close_button.addEventListener('mousedown',function(evt){
evt.preventDefault();
evt.stopPropagation();
});
close_button.addEventListener('click',function(evt){
evt.preventDefault();
evt.stopPropagation();

@@ -58,8 +66,11 @@ // propagating will trigger the dropdown to show for single mode

self.removeItem(value);
self.refreshOptions(false);
});
}
return rendered;
return rendered;
};
});
});

@@ -158,3 +158,4 @@

return extend( true, {}, TomSelect.defaults, settings_element, settings_user);
return Object.assign( {}, TomSelect.defaults, settings_element, settings_user);
//return extend( true, {}, TomSelect.defaults, settings_element, settings_user);
};

@@ -1,112 +0,97 @@

var TomSelect = function( input, settings ){
var i, n, dir, self = this;
input = getDom( input );
class TomSelect extends MicroEvent{
if( input.tomselect ){
throw new Error('Tom Select already initialized on this element');
}
constructor( input, settings ){
super();
input.tomselect = self;
settings = getSettings( input, settings );
var i, n, dir, self = this;
input = getDom( input );
// detect rtl environment
var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
dir = computedStyle.getPropertyValue('direction');
if( input.tomselect ){
throw new Error('Tom Select already initialized on this element');
}
// setup default state
Object.assign(self, {
order : 0,
settings : settings,
input : input,
tabIndex : input.getAttribute('tabindex') || '',
is_select_tag : input.tagName.toLowerCase() === 'select',
rtl : /rtl/i.test(dir),
input.tomselect = self;
settings = getSettings( input, settings );
highlightedValue : null,
isBlurring : false,
isOpen : false,
isDisabled : false,
isRequired : input.required,
isInvalid : false,
isLocked : false,
isFocused : false,
isInputHidden : false,
isSetup : false,
ignoreFocus : false,
ignoreBlur : false,
ignoreHover : false,
hasOptions : false,
currentResults : null,
lastValue : '',
caretPos : 0,
loading : 0,
loadedSearches : {},
activeOption : null,
activeItems : [],
// detect rtl environment
var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
dir = computedStyle.getPropertyValue('direction');
optgroups : {},
options : {},
userOptions : {},
items : [],
renderCache : {'item':{},'option':{}},
});
// setup default state
Object.assign(self, {
order : 0,
settings : settings,
input : input,
tabIndex : input.getAttribute('tabindex') || '',
is_select_tag : input.tagName.toLowerCase() === 'select',
rtl : /rtl/i.test(dir),
// debounce user defined load() if loadThrottle > 0
if( self.settings.load && self.settings.loadThrottle ){
self.settings.load = self.loadDebounce(self.settings.load,self.settings.loadThrottle)
}
highlightedValue : null,
isBlurring : false,
isOpen : false,
isDisabled : false,
isRequired : input.required,
isInvalid : false,
isLocked : false,
isFocused : false,
isInputHidden : false,
isSetup : false,
ignoreFocus : false,
ignoreBlur : false,
ignoreHover : false,
hasOptions : false,
currentResults : null,
lastValue : '',
caretPos : 0,
loading : 0,
loadedSearches : {},
// search system
self.sifter = new Sifter(this.options, {diacritics: settings.diacritics});
activeOption : null,
activeItems : [],
// build options table
for (i = 0, n = self.settings.options.length; i < n; i++) {
self.registerOption(self.settings.options[i]);
}
delete self.settings.options;
optgroups : {},
options : {},
userOptions : {},
items : [],
renderCache : {'item':{},'option':{}},
});
// debounce user defined load() if loadThrottle > 0
if( self.settings.load && self.settings.loadThrottle ){
self.settings.load = self.loadDebounce(self.settings.load,self.settings.loadThrottle)
}
// build optgroup table
for (i = 0, n = self.settings.optgroups.length; i < n; i++) {
self.registerOptionGroup(self.settings.optgroups[i]);
}
delete self.settings.optgroups;
// search system
self.sifter = new Sifter(this.options, {diacritics: settings.diacritics});
self.setupOptions(self.settings.options,self.settings.optgroups);
delete self.settings.optgroups;
delete self.settings.options;
// option-dependent defaults
self.settings.mode = self.settings.mode || (self.settings.maxItems === 1 ? 'single' : 'multi');
if (typeof self.settings.hideSelected !== 'boolean') {
self.settings.hideSelected = self.settings.mode === 'multi';
}
// create filter regex
if( typeof self.settings.createFilter === 'string' ){
self.settings.createFilter = new RegExp(self.settings.createFilter);
}
// option-dependent defaults
self.settings.mode = self.settings.mode || (self.settings.maxItems === 1 ? 'single' : 'multi');
if (typeof self.settings.hideSelected !== 'boolean') {
self.settings.hideSelected = self.settings.mode === 'multi';
}
self.initializePlugins(self.settings.plugins);
self.setupCallbacks();
self.setupTemplates();
self.setup();
};
// create filter regex
if( typeof self.settings.createFilter === 'string' ){
self.settings.createFilter = new RegExp(self.settings.createFilter);
}
// mixins
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
self.initializePlugins(self.settings.plugins);
self.setupCallbacks();
self.setupTemplates();
self.setup();
}
if( typeof MicroPlugin === "undefined"){
throw 'Dependency MicroPlugin is missing. Make sure you either: (1) are using the "complete" version of Tom Select, or (2) require MicroPlugin before you load Tom Select.';
}
MicroEvent.mixin(TomSelect);
MicroPlugin.mixin(TomSelect);
// methods
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// methods
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Object.assign(TomSelect.prototype, {
/**

@@ -116,3 +101,3 @@ * Creates all elements and sets up event bindings.

*/
setup: function() {
setup(){
var self = this;

@@ -328,12 +313,35 @@ var settings = self.settings;

},
}
supportsValidity: function(){
supportsValidity(){
return !/android/i.test(window.navigator.userAgent) && !!document.createElement('input').validity;
},
}
/**
* Register options and optgroups
*
*/
setupOptions(options, optgroups){
var i, n;
options = options || [];
optgroups = optgroups || [];
// build options table
for( i = 0, n = options.length; i < n; i++ ){
this.registerOption(options[i]);
}
// build optgroup table
for( i = 0, n = optgroups.length; i < n; i++ ){
this.registerOptionGroup(optgroups[i]);
}
}
/**
* Sets up default rendering functions.
*/
setupTemplates: function() {
setupTemplates() {
var self = this;

@@ -344,4 +352,8 @@ var field_label = self.settings.labelField;

var templates = {
'optgroup': function(data) {
return '<div class="optgroup"></div>';
'optgroup': function(data, escape) {
let optgroup = document.createElement('div');
optgroup.className = 'optgroup';
optgroup.appendChild(data.options);
return optgroup;
},

@@ -368,3 +380,3 @@ 'optgroup_header': function(data, escape) {

self.settings.render = Object.assign({}, templates, self.settings.render);
},
}

@@ -375,3 +387,3 @@ /**

*/
setupCallbacks: function() {
setupCallbacks() {
var key, fn, callbacks = {

@@ -403,3 +415,3 @@ 'initialize' : 'onInitialize',

}
},
}

@@ -413,3 +425,3 @@ /**

*/
onClick: function(e) {
onClick(e) {
var self = this;

@@ -425,3 +437,3 @@

}
},
}

@@ -435,3 +447,3 @@ /**

*/
onMouseDown: function(e) {
onMouseDown(e) {
var self = this;

@@ -459,3 +471,3 @@

}
},
}

@@ -467,5 +479,5 @@ /**

*/
onChange: function() {
onChange() {
triggerEvent(this.input, 'change');
},
}

@@ -478,3 +490,3 @@ /**

*/
onPaste: function(e) {
onPaste(e) {
var self = this;

@@ -502,3 +514,3 @@

}
},
}

@@ -511,3 +523,3 @@ /**

*/
onKeyPress: function(e) {
onKeyPress(e) {
if (this.isLocked) return e && e.preventDefault();

@@ -520,3 +532,3 @@ var character = String.fromCharCode(e.keyCode || e.which);

}
},
}

@@ -529,3 +541,3 @@ /**

*/
onKeyDown: function(e) {
onKeyDown(e) {
var isInput = e.target === this.control_input;

@@ -545,3 +557,3 @@ var self = this;

case KEY_A:
if (self.isKeyDown(KEY_CMD,e) ) {
if( self.isKeyDown(KEY_CTRL,e) ){
self.selectAll();

@@ -583,3 +595,3 @@ return;

// return: select active option
// doc_src select active option
case KEY_RETURN:

@@ -623,7 +635,7 @@ if (self.isOpen && self.activeOption) {

if( self.isInputHidden && !self.isKeyDown(KEY_CMD,e) ){
if( self.isInputHidden && !self.isKeyDown(KEY_CTRL,e) ){
e.preventDefault();
return;
}
},
}

@@ -636,3 +648,3 @@ /**

*/
onKeyUp: function(e) {
onKeyUp(e) {
var self = this;

@@ -648,3 +660,3 @@

}
},
}

@@ -656,3 +668,3 @@ /**

*/
onSearchChange: function(value) {
onSearchChange(value) {
var self = this;

@@ -666,3 +678,3 @@ var fn = self.settings.load;

});
},
}

@@ -675,3 +687,3 @@ /**

*/
onFocus: function(e) {
onFocus(e) {
var self = this;

@@ -699,3 +711,3 @@ var wasFocused = self.isFocused;

self.refreshState();
},
}

@@ -708,3 +720,3 @@ /**

*/
onBlur: function(e, dest) {
onBlur(e, dest) {
var self = this;

@@ -743,3 +755,3 @@ if (!self.isFocused) return;

}
},
}

@@ -753,6 +765,6 @@ /**

*/
onOptionHover: function(e) {
onOptionHover(e) {
if (this.ignoreHover) return;
this.setActiveOption(e.delegateTarget, false);
},
}

@@ -766,3 +778,3 @@ /**

*/
onOptionSelect: function(e) {
onOptionSelect(e) {
var value, self = this;

@@ -806,3 +818,3 @@

}
},
}

@@ -816,3 +828,3 @@ /**

*/
onItemSelect: function(e) {
onItemSelect(e) {
var self = this;

@@ -825,3 +837,3 @@

}
},
}

@@ -835,3 +847,3 @@ /**

*/
load: function(fn) {
load(fn) {
var self = this;

@@ -841,17 +853,7 @@ addClasses(self.wrapper,self.settings.loadingClass);

self.loading++;
fn.apply(self, [function(options, groups) {
fn.apply(self, [function(options, optgroups) {
self.loading = Math.max(self.loading - 1, 0);
// load groups before options
if (groups && groups.length) {
groups.forEach(function (group) {
self.addOptionGroup(group[self.settings.optgroupValueField], group);
});
}
self.setupOptions(options,optgroups);
if (options && options.length) {
self.addOption(options);
}
// refresh even if no options so that we can show no_results message
self.refreshOptions(self.isFocused && !self.isInputHidden);

@@ -865,3 +867,3 @@

}]);
},
}

@@ -873,3 +875,3 @@

*/
loadDebounce: function(fn,delay){
loadDebounce(fn,delay){
var timeout;

@@ -888,3 +890,3 @@ return function() {

};
},
}

@@ -896,3 +898,3 @@ /**

*/
setTextboxValue: function(value) {
setTextboxValue(value) {
var input = this.control_input;

@@ -905,3 +907,3 @@ var changed = input.value !== value;

}
},
}

@@ -916,3 +918,3 @@ /**

*/
getValue: function() {
getValue() {
if( this.is_select_tag && this.input.hasAttribute('multiple')) {

@@ -923,3 +925,3 @@ return this.items;

}
},
}

@@ -931,3 +933,3 @@ /**

*/
setValue: function(value, silent) {
setValue(value, silent) {
var events = silent ? [] : ['change'];

@@ -939,3 +941,3 @@

});
},
}

@@ -948,3 +950,3 @@ /**

*/
setActiveItem: function( item, e) {
setActiveItem( item, e) {

@@ -1006,3 +1008,3 @@

}
},
}

@@ -1013,3 +1015,3 @@ /**

*/
setActiveItemClass: function( item ){
setActiveItemClass( item ){

@@ -1023,3 +1025,3 @@ var last_active = this.control.querySelector('.last-active');

}
},
}

@@ -1030,7 +1032,7 @@ /**

*/
removeActiveItem: function( item ){
removeActiveItem( item ){
var idx = this.activeItems.indexOf(item);
this.activeItems.splice(idx, 1);
removeClasses(item,'active');
},
}

@@ -1045,3 +1047,3 @@

*/
setActiveOption: function(option, scroll ) {
setActiveOption(option, scroll ) {
var height_menu, height_item, y;

@@ -1078,3 +1080,3 @@

}
},
}

@@ -1084,4 +1086,3 @@ /**

*/
selectAll: function() {
var i,n;
selectAll() {

@@ -1091,5 +1092,4 @@ if (this.settings.mode === 'single') return;

this.activeItems = this.controlChildren();
n = this.activeItems.length;
if( n ){
if( this.activeItems.length ){
addClasses( this.activeItems, 'active' );

@@ -1101,3 +1101,3 @@

this.focus();
},
}

@@ -1108,3 +1108,3 @@ /**

*/
hideInput: function() {
hideInput() {

@@ -1116,3 +1116,3 @@ if( this.settings.controlInput ) return;

this.isInputHidden = true;
},
}

@@ -1122,3 +1122,3 @@ /**

*/
showInput: function() {
showInput() {

@@ -1129,3 +1129,3 @@ if( this.settings.controlInput ) return;

this.isInputHidden = false;
},
}

@@ -1135,5 +1135,5 @@ /**

*/
inputValue: function(){
inputValue(){
return this.control_input.value.trim();
},
}

@@ -1143,3 +1143,3 @@ /**

*/
focus: function() {
focus() {
var self = this;

@@ -1154,3 +1154,3 @@ if (self.isDisabled) return;

}, 0);
},
}

@@ -1162,6 +1162,6 @@ /**

*/
blur: function(dest) {
blur(dest) {
this.control_input.blur();
this.onBlur(null, dest);
},
}

@@ -1177,5 +1177,5 @@ /**

*/
getScoreFunction: function(query) {
getScoreFunction(query) {
return this.sifter.getScoreFunction(query, this.getSearchOptions());
},
}

@@ -1189,3 +1189,3 @@ /**

*/
getSearchOptions: function() {
getSearchOptions() {
var settings = this.settings;

@@ -1203,3 +1203,3 @@ var sort = settings.sortField;

};
},
}

@@ -1220,3 +1220,3 @@ /**

*/
search: function(query) {
search(query) {
var i, value, score, result, calculateScore;

@@ -1241,3 +1241,3 @@ var self = this;

} else {
result = extend( {}, self.currentResults);
result = Object.assign( {}, self.currentResults);
}

@@ -1255,3 +1255,3 @@

return result;
},
}

@@ -1264,3 +1264,3 @@ /**

*/
refreshOptions: function(triggerDropdown) {
refreshOptions(triggerDropdown) {
var i, j, k, n, groups, groups_order, optgroup, optgroups, html, has_create_option;

@@ -1345,6 +1345,8 @@ var active, active_before, create;

let group_html = self.render('optgroup', self.optgroups[optgroup] );
group_html.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
group_html.appendChild(groups[optgroup]);
let group_options = document.createDocumentFragment();
group_options.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
group_options.appendChild(groups[optgroup]);
let group_html = self.render('optgroup', {group:self.optgroups[optgroup],options:group_options} );
html.appendChild(group_html);

@@ -1430,3 +1432,3 @@

}
},
}

@@ -1437,5 +1439,5 @@ /**

*/
selectable: function(){
selectable(){
return this.dropdown_content.querySelectorAll('[data-selectable]');
},
}

@@ -1456,3 +1458,3 @@

*/
addOption: function(data) {
addOption(data) {
var i, n, value, self = this;

@@ -1472,3 +1474,3 @@

}
},
}

@@ -1481,3 +1483,3 @@ /**

*/
registerOption: function(data) {
registerOption(data) {
var key = hash_key(data[this.settings.valueField]);

@@ -1488,3 +1490,3 @@ if (typeof key === 'undefined' || key === null || this.options.hasOwnProperty(key)) return false;

return key;
},
}

@@ -1497,3 +1499,3 @@ /**

*/
registerOptionGroup: function(data) {
registerOptionGroup(data) {
var key = hash_key(data[this.settings.optgroupValueField]);

@@ -1505,3 +1507,3 @@ if (!key) return false;

return key;
},
}

@@ -1515,3 +1517,3 @@ /**

*/
addOptionGroup: function(id, data) {
addOptionGroup(id, data) {
data[this.settings.optgroupValueField] = id;

@@ -1521,3 +1523,3 @@ if (id = this.registerOptionGroup(data)) {

}
},
}

@@ -1529,3 +1531,3 @@ /**

*/
removeOptionGroup: function(id) {
removeOptionGroup(id) {
if (this.optgroups.hasOwnProperty(id)) {

@@ -1536,3 +1538,3 @@ delete this.optgroups[id];

}
},
}

@@ -1542,7 +1544,7 @@ /**

*/
clearOptionGroups: function() {
clearOptionGroups() {
this.optgroups = {};
this.clearCache();
this.trigger('optgroup_clear');
},
}

@@ -1557,3 +1559,3 @@ /**

*/
updateOption: function(value, data) {
updateOption(value, data) {
var self = this;

@@ -1615,3 +1617,3 @@ var item, item_new;

}
},
}

@@ -1624,3 +1626,3 @@ /**

*/
removeOption: function(value, silent) {
removeOption(value, silent) {
var self = this;

@@ -1639,3 +1641,3 @@ value = hash_key(value);

self.removeItem(value, silent);
},
}

@@ -1645,3 +1647,3 @@ /**

*/
clearOptions: function() {
clearOptions() {

@@ -1652,3 +1654,3 @@ this.loadedSearches = {};

var selected = {};
for( key in this.options){
for( let key in this.options){
if( this.options.hasOwnProperty(key) && this.items.indexOf(key) >= 0 ){

@@ -1662,3 +1664,3 @@ selected[key] = this.options[key];

this.trigger('option_clear');
},
}

@@ -1672,3 +1674,3 @@ /**

*/
getOption: function(value) {
getOption(value) {

@@ -1682,3 +1684,3 @@ // cached ?

return this.getElementWithValue(value, this.selectable());
},
}

@@ -1693,3 +1695,3 @@ /**

*/
getAdjacent: function( option, direction, type = 'option' ){
getAdjacent( option, direction, type = 'option' ){

@@ -1721,3 +1723,3 @@ if( !option ){

}
},
}

@@ -1732,3 +1734,3 @@ /**

*/
getElementWithValue: function(value, els) {
getElementWithValue(value, els) {
value = hash_key(value);

@@ -1743,3 +1745,3 @@

}
},
}

@@ -1753,5 +1755,5 @@ /**

*/
getItem: function(value) {
getItem(value) {
return this.getElementWithValue(value, this.control.children);
},
}

@@ -1765,3 +1767,3 @@ /**

*/
addItems: function(values, silent) {
addItems(values, silent) {
this.buffer = document.createDocumentFragment();

@@ -1784,3 +1786,3 @@

this.buffer = null;
},
}

@@ -1794,3 +1796,3 @@ /**

*/
addItem: function(value, silent) {
addItem(value, silent) {
var events = silent ? [] : ['change'];

@@ -1860,3 +1862,3 @@

});
},
}

@@ -1869,3 +1871,3 @@ /**

*/
removeItem: function(value, silent) {
removeItem(value, silent) {
var i, idx;

@@ -1903,3 +1905,3 @@

}
},
}

@@ -1919,5 +1921,6 @@ /**

*/
createItem: function(input, triggerDropdown) {
createItem(input, triggerDropdown) {
var self = this;
var caret = self.caretPos;
var output;
input = input || self.inputValue();

@@ -1939,10 +1942,4 @@

var setup = (typeof self.settings.create === 'function') ? this.settings.create : function(input) {
var data = {};
data[self.settings.labelField] = input;
data[self.settings.valueField] = input;
return data;
};
var create = once(function(data) {
var created = false;
var create = function(data) {
self.unlock();

@@ -1962,6 +1959,14 @@

callback(data);
});
created = true;
};
var output = setup.apply(this, [input, create]);
if (typeof output !== 'undefined') {
if( typeof self.settings.create === 'function' ){
output = self.settings.create.apply(this, [input, create]);
}else{
output = {};
output[self.settings.labelField] = input;
output[self.settings.valueField] = input;
}
if( !created ){
create(output);

@@ -1971,3 +1976,3 @@ }

return true;
},
}

@@ -1977,3 +1982,3 @@ /**

*/
refreshItems: function() {
refreshItems() {
this.lastQuery = null;

@@ -1987,3 +1992,3 @@

this.updateOriginalInput();
},
}

@@ -1994,3 +1999,3 @@ /**

*/
refreshState: function() {
refreshState() {
var self = this;

@@ -2020,3 +2025,3 @@

},
}

@@ -2032,3 +2037,3 @@

*/
refreshValidityState: function() {
refreshValidityState() {
if (!this.isRequired) return false;

@@ -2041,3 +2046,3 @@

this.input.required = !invalid;
},
}

@@ -2050,5 +2055,5 @@ /**

*/
isFull: function() {
isFull() {
return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
},
}

@@ -2059,3 +2064,3 @@ /**

*/
updateOriginalInput: function(opts) {
updateOriginalInput(opts) {
var i, n, options, label, self = this;

@@ -2084,3 +2089,3 @@ opts = opts || {};

}
},
}

@@ -2091,3 +2096,3 @@ /**

*/
open: function() {
open() {
var self = this;

@@ -2103,3 +2108,3 @@

self.trigger('dropdown_open', self.dropdown);
},
}

@@ -2109,3 +2114,3 @@ /**

*/
close: function() {
close() {
var self = this;

@@ -2131,3 +2136,3 @@ var trigger = self.isOpen;

if (trigger) self.trigger('dropdown_close', self.dropdown);
},
}

@@ -2138,3 +2143,3 @@ /**

*/
positionDropdown: function() {
positionDropdown() {
var left = 0;

@@ -2166,3 +2171,3 @@ var context = this.control;

},
}

@@ -2175,3 +2180,3 @@ /**

*/
clear: function(silent) {
clear(silent) {

@@ -2193,3 +2198,3 @@ if (!this.items.length) return;

this.trigger('clear');
},
}

@@ -2202,3 +2207,3 @@ /**

*/
insertAtCaret: function(el) {
insertAtCaret(el) {
var caret = Math.min(this.caretPos, this.items.length);

@@ -2214,3 +2219,3 @@ var target = this.buffer || this.control;

this.setCaret(caret + 1);
},
}

@@ -2223,3 +2228,3 @@ /**

*/
deleteSelection: function(e) {
deleteSelection(e) {
var i, n, direction, selection, values, caret, tail;

@@ -2275,3 +2280,3 @@ var self = this;

return true;
},
}

@@ -2287,3 +2292,3 @@ /**

*/
advanceSelection: function(direction, e) {
advanceSelection(direction, e) {
var selection, idx, last_active;

@@ -2324,3 +2329,3 @@

}
},
}

@@ -2331,3 +2336,3 @@ /**

*/
getLastActive: function(direction){
getLastActive(direction){

@@ -2340,3 +2345,3 @@ let last_active = this.control.querySelector('.last-active');

return querySelectorEnd(this.control,'.active',direction);
},
}

@@ -2349,3 +2354,3 @@

*/
setCaret: function(i) {
setCaret(i) {
var self = this;

@@ -2379,3 +2384,3 @@

self.caretPos = i;
},
}

@@ -2386,5 +2391,5 @@ /**

*/
controlChildren: function(){
controlChildren(){
return Array.prototype.filter.call( this.control.children, node => node.nodeName !== 'INPUT' );
},
}

@@ -2395,7 +2400,7 @@ /**

*/
lock: function() {
lock() {
this.close();
this.isLocked = true;
this.refreshState();
},
}

@@ -2405,6 +2410,6 @@ /**

*/
unlock: function() {
unlock() {
this.isLocked = false;
this.refreshState();
},
}

@@ -2415,3 +2420,3 @@ /**

*/
disable: function() {
disable() {
this.input.disabled = true;

@@ -2422,3 +2427,3 @@ this.control_input.disabled = true;

this.lock();
},
}

@@ -2429,3 +2434,3 @@ /**

*/
enable: function() {
enable() {
this.input.disabled = false;

@@ -2436,3 +2441,3 @@ this.control_input.disabled = false;

this.unlock();
},
}

@@ -2444,3 +2449,3 @@ /**

*/
destroy: function() {
destroy() {
var revertSettings = this.revertSettings;

@@ -2470,3 +2475,3 @@

delete this.input.tomselect;
},
}

@@ -2481,3 +2486,3 @@ /**

*/
render: function(templateName, data) {
render(templateName, data) {
var value, id, label;

@@ -2509,5 +2514,5 @@ var html = '';

}else if (templateName === 'optgroup') {
id = data[self.settings.optgroupValueField];
id = data.group[self.settings.optgroupValueField];
html.setAttribute('data-group', id);
if(data[self.settings.disabledField]) {
if(data.group[self.settings.disabledField]) {
html.setAttribute('data-disabled', '');

@@ -2533,3 +2538,3 @@ }

return html;
},
}

@@ -2543,3 +2548,3 @@ /**

*/
clearCache: function(templateName) {
clearCache(templateName) {
var self = this;

@@ -2551,3 +2556,3 @@ if (typeof templateName === 'undefined') {

}
},
}

@@ -2561,3 +2566,3 @@ /**

*/
canCreate: function(input) {
canCreate(input) {
if (!this.settings.create) return false;

@@ -2569,3 +2574,3 @@ var filter = this.settings.createFilter;

&& (!(filter instanceof RegExp) || filter.test(input));
},
}

@@ -2575,23 +2580,31 @@

* Return true if the requested key is down
* Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
* The current evt may not always set ( eg calling advanceSelection() )
*
*/
isKeyDown: function( key_code, evt ){
isKeyDown( key_code, evt ){
if( evt ){
if( key_code == KEY_CTRL && evt[KEY_CTRL_NAME] ){
return true;
}
if( !evt ){
return false;
}
if( key_code == KEY_CMD && evt[KEY_CMD_NAME] ){
return true;
}
if( evt.altKey ){
return false;
}
if( key_code == KEY_SHIFT && evt.shiftKey ){
return true;
}
// if [ctrl+shift], return false
if( evt[KEY_CTRL_NAME] && evt.shiftKey ){
return false;
}
if( key_code == KEY_CTRL && evt[KEY_CTRL_NAME] ){
return true;
}
if( key_code == KEY_SHIFT && evt.shiftKey ){
return true;
}
return false;
},
}

@@ -2609,3 +2622,3 @@ /**

*/
hook: function( when, method, new_fn ){
hook( when, method, new_fn ){
var self = this;

@@ -2635,5 +2648,13 @@ var orig_method = self[method];

}
},
};
});
// mixins
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if( typeof MicroPlugin === "undefined"){
throw 'Dependency MicroPlugin is missing. Make sure you either: (1) are using the "complete" version of Tom Select, or (2) require MicroPlugin before you load Tom Select.';
}
MicroPlugin.mixin(TomSelect);

@@ -57,18 +57,3 @@ /**

/**
* Wraps `fn` so that it can only be invoked once.
*
* @param {function} fn
* @returns {function}
*/
var once = function(fn) {
var called = false;
return function() {
if (called) return;
called = true;
fn.apply(this, arguments);
};
};
/**

@@ -75,0 +60,0 @@ * Debounce all fired events types listed in `types`

@@ -206,115 +206,1 @@

}
/**
* Copied from jQuery source
*
*/
var hasOwn = ( {} ).hasOwnProperty;
var fnToString = hasOwn.toString;
var getProto = Object.getPrototypeOf;
var ObjectFunctionString = fnToString.call( Object );
var isPlainObject = function( obj ) {
var proto, Ctor;
// Detect obvious negatives
// Use toString instead of jQuery.type to catch host objects
if ( !obj || toString.call( obj ) !== "[object Object]" ) {
return false;
}
proto = getProto( obj );
// Objects with no prototype (e.g., `Object.create( null )`) are plain
if ( !proto ) {
return true;
}
// Objects with prototype are plain iff they were constructed by a global Object function
Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
};
var isFunction = function( obj ) {
// Support: Chrome <=57, Firefox <=52
// In some browsers, typeof returns "function" for HTML <object> elements
// (i.e., `typeof document.createElement( "object" ) === "function"`).
// We don't want to classify *any* DOM node as a function.
return typeof obj === "function" && typeof obj.nodeType !== "number";
};
var extend = function() {
var options, name, src, copy, copyIsArray, clone,
target = arguments[ 0 ] || {},
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
deep = target;
// Skip the boolean and the target
target = arguments[ i ] || {};
i++;
}
// Handle case when target is a string or something (possible in deep copy)
if ( typeof target !== "object" && !isFunction( target ) ) {
target = {};
}
// Extend jQuery itself if only one argument is passed
if ( i === length ) {
target = this;
i--;
}
for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values
if ( ( options = arguments[ i ] ) != null ) {
// Extend the base object
for ( name in options ) {
copy = options[ name ];
// Prevent Object.prototype pollution
// Prevent never-ending loop
if ( name === "__proto__" || target === copy ) {
continue;
}
// Recurse if we're merging plain objects or arrays
if ( deep && copy && ( isPlainObject( copy ) ||
( copyIsArray = Array.isArray( copy ) ) ) ) {
src = target[ name ];
// Ensure proper type for the source value
if ( copyIsArray && !Array.isArray( src ) ) {
clone = [];
} else if ( !copyIsArray && !isPlainObject( src ) ) {
clone = {};
} else {
clone = src;
}
copyIsArray = false;
// Never move original objects, clone them
target[ name ] = extend( deep, clone, copy );
// Don't bring in undefined values
} else if ( copy !== undefined ) {
target[ name ] = copy;
}
}
}
}
// Return the modified object
return target;
};

@@ -145,2 +145,3 @@

});
it_n('should add option upon completion (asynchronous)', function(done) {

@@ -162,2 +163,17 @@ var test = setup_test('<select>', {

});
it_n('should not create two items', function(){
var test = setup_test('<select multiple>', {
valueField: 'value',
labelField: 'value',
create: function(input, callback) {
callback({value: 'test'});
return {value:'test2'};
}
});
test.instance.createItem('test');
assert.equal(test.instance.items.length,1);
});
});

@@ -845,2 +861,52 @@

describe('isKeyDown()', function() {
var test = setup_test('<select>');
var instance = test.instance;
var last_keydown;
test.instance.control_input.addEventListener('keydown',function(evt){
last_keydown = evt;
});
it_n('should return false if [alt] is pressed', function() {
syn.type('[alt]', test.instance.control_input, function(evt) {
assert.equal( instance.isKeyDown(KEY_SHIFT,last_keydown), false);
syn.type('[alt-up]', test.instance.control_input);
});
});
it_n('should return false if [alt][shift] is pressed', function() {
syn.type('[alt][shift]', test.instance.control_input, function() {
assert.equal( instance.isKeyDown(KEY_SHIFT,last_keydown), false);
syn.type('[alt-up][shift-up]', test.instance.control_input);
});
});
it_n('should return false if [ctrl][shift] is pressed', function() {
syn.type('[ctrl][shift]', test.instance.control_input, function() {
assert.equal( instance.isKeyDown(KEY_SHIFT,last_keydown), false);
assert.equal( instance.isKeyDown(KEY_CTRL,last_keydown), false);
syn.type('[ctrl-up][shift-up]', test.instance.control_input);
});
});
it_n('should return true if [shift] is pressed', function() {
syn.type('[shift]', test.instance.control_input, function() {
assert.equal( instance.isKeyDown(KEY_SHIFT,last_keydown), true);
syn.type('[shift-up]', test.instance.control_input);
});
});
it_n('should return true if [ctrl] is pressed', function() {
syn.type('[ctrl]', test.instance.control_input, function() {
assert.equal( instance.isKeyDown(KEY_CTRL,last_keydown), true);
syn.type('[ctrl-up]', test.instance.control_input);
});
});
});
});

@@ -48,5 +48,4 @@

var test = setup_test('<input>',{
optgroupField: 'class',
labelField: 'name',
searchField: ['name'],
labelField: 'value',
searchField: ['value'],
preload: true,

@@ -56,8 +55,8 @@ load: function(query, loadcb) {

var options = [
{class: 'mammal', value: "dog" },
{class: 'mammal', value: "cat" },
{class: 'bird', value: 'duck'},
{class: 'bird', value: 'chicken'},
{class: 'reptile', value: 'snake'},
{class: 'reptile', value: 'lizard'},
{optgroup: 'mammal', value: "dog" },
{optgroup: 'mammal', value: "cat" },
{optgroup: 'bird', value: 'duck'},
{optgroup: 'bird', value: 'chicken'},
{optgroup: 'reptile', value: 'snake'},
{optgroup: 'reptile', value: 'lizard'},
];

@@ -68,4 +67,5 @@

{value: 'reptile', label: 'Reptile'}];
loadcb(options,groups);
assert.equal(Object.keys(test.instance.options).length, 6);

@@ -72,0 +72,0 @@ assert.equal(Object.keys(test.instance.optgroups).length, 3);

@@ -497,2 +497,23 @@

it_n('should not close dropdown when [ctrl-a] pressed no items', function(done) {
var test = setup_test('AB_Multi');
click(test.instance.control, function() {
assert.equal( test.instance.items.length, 0 );
assert.equal( test.instance.isOpen, true );
syn.type('[ctrl]a[ctrl-up]', test.instance.control_input, function() {
assert.equal( test.instance.items.length, 0 );
assert.equal( test.instance.isOpen, true );
done();
});
});
});
var ShiftMousedown = function(first_item,last_item){

@@ -703,3 +724,16 @@

it_n('create item should be focused when addPrecedence=false (default)', function(done) {
var test = setup_test('AB_Multi', {create: true});
click(test.instance.control, function() {
syn.type('b', test.instance.control_input, function() {
assert.equal( test.instance.activeOption.classList.contains('create'), false);
done();
});
});
});
describe('filtering created items', function() {

@@ -706,0 +740,0 @@

@@ -1,171 +0,200 @@

(function() {
describe('plugins', function() {
describe('remove_button', function() {
it_n('should remove item when remove button is clicked', function(done) {
describe('plugin: remove_button', function() {
let test = setup_test('AB_Multi', {plugins: ['remove_button']});
it_n('should remove item when remove button is clicked', function(done) {
test.instance.addItem('a');
test.instance.addItem('b');
assert.equal( test.instance.items.length, 2 );
let test = setup_test('AB_Multi', {plugins: ['remove_button']});
var itema = test.instance.getItem('b');
var remove_button = itema.querySelector('.remove');
test.instance.addItem('a');
test.instance.addItem('b');
assert.equal( test.instance.items.length, 2 );
expect(remove_button.classList.contains('remove')).to.be.equal(true);
var itema = test.instance.getItem('b');
var remove_button = itema.querySelector('.remove');
syn.click( remove_button, function() {
assert.equal( test.instance.items.length, 1 );
assert.equal( test.instance.items[0], 'a' );
done();
syn.click( remove_button, function() {
assert.equal( test.instance.items.length, 1 );
assert.equal( test.instance.items[0], 'a' );
done();
});
});
});
it_n('option should reappear in dropdown when removed', function(done) {
let test = setup_test('AB_Multi', {plugins: ['remove_button']});
test.instance.addItem('a');
test.instance.addItem('b');
assert.equal( test.instance.items.length, 2 );
syn.click(test.instance.control_input,function(){
assert.equal( test.instance.dropdown_content.querySelectorAll('.option').length, 1);
var itema = test.instance.getItem('b');
var remove_button = itema.querySelector('.remove');
syn.click( remove_button, function() {
assert.equal( test.instance.dropdown_content.querySelectorAll('.option').length, 2);
done();
});
});
describe('no_backspace_delete', function() {
});
it_n('should not delete item on backspace', function(done) {
let test = setup_test('AB_Multi', {plugins: ['no_backspace_delete']});
it_n('rendering item a second time should not add a remove button a second time', function() {
test.instance.addItem('a');
test.instance.addItem('b');
test.instance.setActiveItem(test.instance.getItem('b'));
let test = setup_test('AB_Multi', {plugins: ['remove_button']});
assert.equal( test.instance.items.length, 2 );
assert.equal( test.instance.activeItems.length, 0 );
syn.click(test.instance.control_input,function(){
syn.type('\b', test.instance.control_input, function() {
var item = test.instance.render('item', test.instance.options['a']);
item = test.instance.render('item', test.instance.options['a']);
assert.equal( test.instance.items.length, 2 );
done();
assert.equal( item.querySelectorAll('.remove').length, 1);
});
});
});
});
});
describe('plugin: no_backspace_delete', function() {
});
it_n('should not delete item on backspace', function(done) {
let test = setup_test('AB_Multi', {plugins: ['no_backspace_delete']});
describe('restore_on_backspace', function() {
test.instance.addItem('a');
test.instance.addItem('b');
test.instance.setActiveItem(test.instance.getItem('b'));
it_n('should fill control_input.value when item deleted', function(done) {
assert.equal( test.instance.items.length, 2 );
assert.equal( test.instance.activeItems.length, 0 );
var test = setup_test('AB_Multi',{plugins:['restore_on_backspace']});
syn.click(test.instance.control_input,function(){
syn.type('\b', test.instance.control_input, function() {
test.instance.addItem('a');
test.instance.addItem('b');
assert.equal( test.instance.items.length, 2 );
done();
syn.click(test.instance.control_input,function(){
syn.type('\b', test.instance.control_input, function() {
assert.equal( test.instance.items.length, 1 );
assert.equal( test.instance.items[0], 'a' );
assert.equal( test.instance.control_input.value, 'b' );
done();
});
});
});
});
});
});
});
});
describe('dropdown_header', function() {
describe('plugin: restore_on_backspace', function() {
it_n('header should be added to dropdown menu', function() {
it_n('should fill control_input.value when item deleted', function(done) {
var test = setup_test('AB_Multi',{plugins:['dropdown_header']});
var header = test.instance.dropdown.querySelectorAll('.dropdown-header');
var test = setup_test('AB_Multi',{plugins:['restore_on_backspace']});
expect(header.length).to.be.equal(1);
test.instance.addItem('a');
test.instance.addItem('b');
assert.equal( test.instance.items.length, 2 );
syn.click(test.instance.control_input,function(){
syn.type('a\b\b', test.instance.control_input, function() {
assert.equal( test.instance.items.length, 1 );
assert.equal( test.instance.items[0], 'a' );
assert.equal( test.instance.control_input.value, 'b' );
done();
});
});
});
describe('optgroup_columns', function() {
});
var optgroup_test = function(){
return setup_test('<input>',{
options: [
{id: 'avenger', make: 'dodge', model: 'Avenger'},
{id: 'caliber', make: 'dodge', model: 'Caliber'},
{id: 'caravan-grand-passenger', make: 'dodge', model: 'Caravan Grand Passenger'},
{id: 'challenger', make: 'dodge', model: 'Challenger'},
{id: 'ram-1500', make: 'dodge', model: 'Ram 1500'},
{id: 'viper', make: 'dodge', model: 'Viper'},
{id: 'a3', make: 'audi', model: 'A3'},
{id: 'a6', make: 'audi', model: 'A6'},
{id: 'r8', make: 'audi', model: 'R8'},
{id: 'rs-4', make: 'audi', model: 'RS 4'},
{id: 's4', make: 'audi', model: 'S4'},
{id: 's8', make: 'audi', model: 'S8'},
{id: 'tt', make: 'audi', model: 'TT'},
{id: 'avalanche', make: 'chevrolet', model: 'Avalanche'},
{id: 'aveo', make: 'chevrolet', model: 'Aveo'},
{id: 'cobalt', make: 'chevrolet', model: 'Cobalt'},
{id: 'silverado', make: 'chevrolet', model: 'Silverado'},
{id: 'suburban', make: 'chevrolet', model: 'Suburban'},
{id: 'tahoe', make: 'chevrolet', model: 'Tahoe'},
{id: 'trail-blazer', make: 'chevrolet', model: 'TrailBlazer'},
],
optgroups: [
{$order: 3, id: 'dodge', name: 'Dodge'},
{$order: 2, id: 'audi', name: 'Audi'},
{$order: 1, id: 'chevrolet', name: 'Chevrolet'}
],
labelField: 'model',
valueField: 'id',
optgroupField: 'make',
optgroupLabelField: 'name',
optgroupValueField: 'id',
lockOptgroupOrder: true,
searchField: ['model'],
plugins: ['optgroup_columns'],
openOnFocus: false
});
};
describe('plugin: dropdown_header', function() {
it_n('three optgroups should be displayed', function() {
it_n('header should be added to dropdown menu', function() {
var test = optgroup_test();
syn.type('a', test.instance.control_input, function() {
var optgroups = test.instance.dropdown_content.querySelectorAll('.optgroup');
expect(optgroups.length).to.be.equal(3);
});
var test = setup_test('AB_Multi',{plugins:['dropdown_header']});
var header = test.instance.dropdown.querySelectorAll('.dropdown-header');
});
expect(header.length).to.be.equal(1);
});
it_n('[right] keypress should move focus to second optgroup', function() {
var test = optgroup_test();
});
// 1) move right to audi
syn.type('a[right]', test.instance.control_input, function() {
var optgroup = parentMatch(test.instance.activeOption,'[data-group]');
expect(optgroup.dataset.group).to.be.equal('audi');
describe('plugin: optgroup_columns', function() {
// 2) move left to chevy
syn.type('[left]', test.instance.control_input, function() {
var optgroup_test = function(){
return setup_test('<input>',{
options: [
{id: 'avenger', make: 'dodge', model: 'Avenger'},
{id: 'caliber', make: 'dodge', model: 'Caliber'},
{id: 'caravan-grand-passenger', make: 'dodge', model: 'Caravan Grand Passenger'},
{id: 'challenger', make: 'dodge', model: 'Challenger'},
{id: 'ram-1500', make: 'dodge', model: 'Ram 1500'},
{id: 'viper', make: 'dodge', model: 'Viper'},
{id: 'a3', make: 'audi', model: 'A3'},
{id: 'a6', make: 'audi', model: 'A6'},
{id: 'r8', make: 'audi', model: 'R8'},
{id: 'rs-4', make: 'audi', model: 'RS 4'},
{id: 's4', make: 'audi', model: 'S4'},
{id: 's8', make: 'audi', model: 'S8'},
{id: 'tt', make: 'audi', model: 'TT'},
{id: 'avalanche', make: 'chevrolet', model: 'Avalanche'},
{id: 'aveo', make: 'chevrolet', model: 'Aveo'},
{id: 'cobalt', make: 'chevrolet', model: 'Cobalt'},
{id: 'silverado', make: 'chevrolet', model: 'Silverado'},
{id: 'suburban', make: 'chevrolet', model: 'Suburban'},
{id: 'tahoe', make: 'chevrolet', model: 'Tahoe'},
{id: 'trail-blazer', make: 'chevrolet', model: 'TrailBlazer'},
],
optgroups: [
{$order: 3, id: 'dodge', name: 'Dodge'},
{$order: 2, id: 'audi', name: 'Audi'},
{$order: 1, id: 'chevrolet', name: 'Chevrolet'}
],
labelField: 'model',
valueField: 'id',
optgroupField: 'make',
optgroupLabelField: 'name',
optgroupValueField: 'id',
lockOptgroupOrder: true,
searchField: ['model'],
plugins: ['optgroup_columns'],
openOnFocus: false
});
};
var optgroup = parentMatch(test.instance.activeOption,'[data-group]');
expect(optgroup.dataset.group).to.be.equal('chevrolet');
});
it_n('three optgroups should be displayed', function() {
});
var test = optgroup_test();
syn.type('a', test.instance.control_input, function() {
var optgroups = test.instance.dropdown_content.querySelectorAll('.optgroup');
expect(optgroups.length).to.be.equal(3);
});
});
it_n('[right] keypress should move focus to second optgroup', function() {
var test = optgroup_test();
// 1) move right to audi
syn.type('a[right]', test.instance.control_input, function() {
var optgroup = parentMatch(test.instance.activeOption,'[data-group]');
expect(optgroup.dataset.group).to.be.equal('audi');
// 2) move left to chevy
syn.type('[left]', test.instance.control_input, function() {
var optgroup = parentMatch(test.instance.activeOption,'[data-group]');
expect(optgroup.dataset.group).to.be.equal('chevrolet');
});

@@ -175,5 +204,28 @@

});
});
describe('plugin: change_listener', function() {
it_n('Tom Select should update when original input is changed', function() {
let test = setup_test('<input value="original">', {plugins: ['change_listener']});
assert.equal( Object.keys(test.instance.options).length, 1);
var input = test.$select[0];
input.value = 'new value';
var evt = document.createEvent('HTMLEvents');
evt.initEvent('change', false, true);
input.dispatchEvent(evt);
assert.equal( Object.keys(test.instance.options).length, 2);
assert.equal( test.instance.items.length, 1);
assert.equal( test.instance.items[0], 'new value');
});
})();
});

@@ -46,3 +46,3 @@ (function() {

assert.deepEqual(test.instance.options, {
'a': {value: 'a', test: 'b', text: 'c', disabled:false, $order: 1},
'a': {value: 'a', test: 'b', text: 'c', disabled:false, optgroup: undefined, $order: 1},
});

@@ -49,0 +49,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc