tom-select
Advanced tools
Comparing version 1.0.0-rc.2 to 1.0.0-rc.3
@@ -19,3 +19,17 @@ import resolve from '@rollup/plugin-node-resolve'; // so Rollup can find `node_modules` | ||
var terser_config = terser({ | ||
mangle: true, | ||
format: { | ||
comments: function (node, comment) { | ||
var text = comment.value; | ||
var type = comment.type; | ||
if (type == "comment2") { | ||
// multiline comment | ||
return /\* Tom Select/i.test(text); | ||
} | ||
}, | ||
}, | ||
}); | ||
function createConfig( input, output, plugins ){ | ||
@@ -98,3 +112,3 @@ | ||
configCore(custom_file,'tom-select.custom.js'); | ||
configCore(custom_file,'tom-select.custom.min.js',[terser({mangle:true})]); | ||
configCore(custom_file,'tom-select.custom.min.js',[terser_config]); | ||
} | ||
@@ -104,7 +118,7 @@ | ||
configCore('src/tom-select.js','tom-select.base.js') | ||
configCore('src/tom-select.js','tom-select.base.min.js',[terser({mangle:true})]); | ||
configCore('src/tom-select.js','tom-select.base.min.js',[terser_config]); | ||
// tom-select.complete | ||
configCore('src/tom-select.complete.js','tom-select.complete.js'); | ||
configCore('src/tom-select.complete.js','tom-select.complete.min.js',[terser({mangle:true})]); | ||
configCore('src/tom-select.complete.js','tom-select.complete.min.js',[terser_config]); | ||
@@ -111,0 +125,0 @@ |
/** | ||
* Tom Select v1.0.0-rc.2 | ||
* Tom Select v1.0.0-rc.3 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
@@ -96,8 +96,2 @@ */ | ||
/** | ||
* Determines if the provided value has been defined. | ||
* | ||
* @param {mixed} object | ||
* @returns {boolean} | ||
*/ | ||
/** | ||
* Converts a scalar to its best string representation | ||
@@ -118,3 +112,2 @@ * for hash keys and HTML attribute values. | ||
*/ | ||
function hash_key(value) { | ||
@@ -121,0 +114,0 @@ if (typeof value === 'undefined' || value === null) return null; |
/** | ||
* Tom Select v1.0.0-rc.2 | ||
* Tom Select v1.0.0-rc.3 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* Tom Select v1.0.0-rc.2 | ||
* Tom Select v1.0.0-rc.3 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
@@ -20,4 +20,4 @@ */ | ||
* | ||
* @param {mixed} query | ||
* @return {Element} | ||
* @param {any} query .. should be {HTMLElement|string|JQuery} | ||
* @return {HTMLElement} | ||
*/ | ||
@@ -37,3 +37,3 @@ function getDom(query) { | ||
return div.firstChild; | ||
return div.querySelector(':first-child'); | ||
} | ||
@@ -40,0 +40,0 @@ |
/** | ||
* Tom Select v1.0.0-rc.2 | ||
* Tom Select v1.0.0-rc.3 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
@@ -38,3 +38,3 @@ */ | ||
test_input.style.width = 'auto'; | ||
test_input.style.padding = 0; | ||
test_input.style.padding = '0'; | ||
test_input.style.whiteSpace = 'pre'; | ||
@@ -51,3 +51,2 @@ self.wrapper.appendChild(test_input); | ||
* | ||
* @param {string} str | ||
*/ | ||
@@ -54,0 +53,0 @@ |
/** | ||
* Tom Select v1.0.0-rc.2 | ||
* Tom Select v1.0.0-rc.3 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* Tom Select v1.0.0-rc.2 | ||
* Tom Select v1.0.0-rc.3 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
@@ -23,4 +23,4 @@ */ | ||
* | ||
* @param {mixed} query | ||
* @return {Element} | ||
* @param {any} query .. should be {HTMLElement|string|JQuery} | ||
* @return {HTMLElement} | ||
*/ | ||
@@ -27,0 +27,0 @@ /** |
/** | ||
* Tom Select v1.0.0-rc.2 | ||
* Tom Select v1.0.0-rc.3 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
@@ -20,4 +20,4 @@ */ | ||
* | ||
* @param {mixed} query | ||
* @return {Element} | ||
* @param {any} query .. should be {HTMLElement|string|JQuery} | ||
* @return {HTMLElement} | ||
*/ | ||
@@ -37,3 +37,3 @@ function getDom(query) { | ||
return div.firstChild; | ||
return div.querySelector(':first-child'); | ||
} | ||
@@ -45,6 +45,16 @@ | ||
/** | ||
* Determines if the provided value has been defined. | ||
* Converts a scalar to its best string representation | ||
* for hash keys and HTML attribute values. | ||
* | ||
* @param {mixed} object | ||
* @returns {boolean} | ||
* Transformations: | ||
* 'str' -> 'str' | ||
* null -> '' | ||
* undefined -> '' | ||
* true -> '1' | ||
* false -> '0' | ||
* 0 -> '0' | ||
* 1 -> '1' | ||
* | ||
* @param {string} value | ||
* @returns {string|null} | ||
*/ | ||
@@ -51,0 +61,0 @@ /** |
/** | ||
* Tom Select v1.0.0-rc.2 | ||
* Tom Select v1.0.0-rc.3 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
@@ -4,0 +4,0 @@ */ |
@@ -1,2 +0,6 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TomSelect=e()}(this,(function(){"use strict";var t=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){this._events[t]=this._events[t]||[],this._events[t].push(e)},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)))},e.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))},t}();var e=function(t,e){return"number"==typeof t&&"number"==typeof e?t>e?1:t<e?-1:0:(t=s(String(t||"")))>(e=s(String(e||"")))?1:e>t?-1:0},i=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}},n={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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},s=function(){var t,e,i,s,o="",r={};for(i in n)if(n.hasOwnProperty(i))for(o+=s=n[i].substring(2,n[i].length-1),t=0,e=s.length;t<e;t++)r[s.charAt(t)]=i;var a=new RegExp("["+o+"]","g");return function(t){return t.replace(a,(function(t){return r[t]})).toLowerCase()}}(),o=function(){function t(t,e){this.items=t,this.settings=e||{diacritics:!0}}var s=t.prototype;return s.tokenize=function(t,e){if(!(t=String(t||"").toLowerCase().trim())||!t.length)return[];var i,s,o,r,a=[],l=t.split(/ +/);for(i=0,s=l.length;i<s;i++){if(o=(l[i]+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),this.settings.diacritics)for(r in n)n.hasOwnProperty(r)&&(o=o.replace(new RegExp(r,"g"),n[r]));e&&(o="\\b"+o),a.push({string:l[i],regex:new RegExp(o,"i")})}return a},s.iterator=function(t,e){var i;i=Array.isArray(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])},s.getScoreFunction=function(t,e){var n,s,o,r;t=this.prepareSearch(t,e),s=t.tokens,n=t.options.fields,o=s.length,r=t.options.nesting;var a,l=function(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):0},u=(a=n.length)?1===a?function(t,e){return l(i(e,n[0],r),t)}:function(t,e){for(var s=0,o=0;s<a;s++)o+=l(i(e,n[s],r),t);return o/a}:function(){return 0};return o?1===o?function(t){return u(s[0],t)}:"and"===t.options.conjunction?function(t){for(var e,i=0,n=0;i<o;i++){if((e=u(s[i],t))<=0)return 0;n+=e}return n/o}:function(t){for(var e=0,i=0;e<o;e++)i+=u(s[e],t);return i/o}:function(){return 0}},s.getSortFunction=function(t,n){var s,o,r,a,l,u,c,p,d,h,g;if(g=!(t=(r=this).prepareSearch(t,n)).query&&n.sort_empty||n.sort,d=function(t,e){return"$score"===t?e.score:i(r.items[e.id],t,n.nesting)},l=[],g)for(s=0,o=g.length;s<o;s++)(t.query||"$score"!==g[s].field)&&l.push(g[s]);if(t.query){for(h=!0,s=0,o=l.length;s<o;s++)if("$score"===l[s].field){h=!1;break}h&&l.unshift({field:"$score",direction:"desc"})}else for(s=0,o=l.length;s<o;s++)if("$score"===l[s].field){l.splice(s,1);break}for(p=[],s=0,o=l.length;s<o;s++)p.push("desc"===l[s].direction?-1:1);return(u=l.length)?1===u?(a=l[0].field,c=p[0],function(t,i){return c*e(d(a,t),d(a,i))}):function(t,i){var n,s,o;for(n=0;n<u;n++)if(o=l[n].field,s=p[n]*e(d(o,t),d(o,i)))return s;return 0}:null},s.prepareSearch=function(t,e){if("object"==typeof t)return t;var i=(e=Object.assign({},e)).fields,n=e.sort,s=e.sort_empty;return i&&!Array.isArray(i)&&(e.fields=[i]),n&&!Array.isArray(n)&&(e.sort=[n]),s&&!Array.isArray(s)&&(e.sort_empty=[s]),{options:e,query:String(t||"").toLowerCase(),tokens:this.tokenize(t,e.respect_word_boundaries),total:0,items:[]}},s.search=function(t,e){var i,n,s,o,r=this;return n=this.prepareSearch(t,e),e=n.options,t=n.query,o=e.score||r.getScoreFunction(n),t.length?r.iterator(r.items,(function(t,s){i=o(t),(!1===e.filter||i>0)&&n.items.push({score:i,id:s})})):r.iterator(r.items,(function(t,e){n.items.push({score:1,id:e})})),(s=r.getSortFunction(n,e))&&n.items.sort(s),n.total=n.items.length,"number"==typeof e.limit&&(n.items=n.items.slice(0,e.limit)),n},t}();function r(t,e){if("string"!=typeof e||e.length){var i="string"==typeof e?new RegExp(e,"i"):e;!function t(e){var n=0;if(3===e.nodeType){var s=e.data.search(i);if(s>=0&&e.data.length>0){var o=e.data.match(i),r=document.createElement("span");r.className="highlight";var a=e.splitText(s),l=(a.splitText(o[0].length),a.cloneNode(!0));r.appendChild(l),a.parentNode.replaceChild(r,a),n=1}}else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&("highlight"!==e.className||"SPAN"!==e.tagName))for(var u=0;u<e.childNodes.length;++u)u+=t(e.childNodes[u]);return n}(t)}}var a={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:50,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:"ts-control",inputClass:"ts-input",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}};function l(t){return null==t?null:"boolean"==typeof t?t?"1":"0":t+""}function u(t){return(t+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t,e,i){var n,s=t.trigger,o={};for(n in t.trigger=function(){var i=arguments[0];if(-1===e.indexOf(i))return s.apply(t,arguments);o[i]=arguments},i.apply(t,[]),t.trigger=s,o)o.hasOwnProperty(n)&&s.apply(t,o[n])}function p(t){if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(t.indexOf("<")>-1){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild}return document.querySelector(t)}function d(t,e){var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!1),t.dispatchEvent(i)}function h(t,e){Object.keys(e).forEach((function(i){t.style[i]=e[i]}))}function g(t){var e=v.apply(null,arguments);(t=m(t)).map((function(t){e.map((function(e){t.classList.add(e)}))}))}function f(t){var e=v.apply(null,arguments);(t=m(t)).map((function(t){e.map((function(e){t.classList.remove(e)}))}))}function v(){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)}function m(t){return Array.isArray(t)||(t=[t]),t}function y(t,e,i){if(!i||i.contains(t))for(;t&&t.matches;){if(t.matches(e))return t;t=t.parentNode}}function O(t,e){return e>0?t[t.length-1]:t[0]}function w(t,e){if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i}var b,C=function(t){var e,i;function n(e,i){var n,s,r=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n=t.call(this)||this);if((e=p(e)).tomselect)throw new Error("Tom Select already initialized on this element");return e.tomselect=r,i=function(t,e){var i=Object.assign({},a,e),n=i.dataAttr,s=i.labelField,o=i.valueField,r=i.disabledField,u=i.optgroupField,c=i.optgroupLabelField,p=i.optgroupValueField,d=t.tagName.toLowerCase(),h=t.getAttribute("placeholder")||t.getAttribute("data-placeholder");if(!h&&!i.allowEmptyOption){var g=t.querySelector('option[value=""]');g&&(h=g.textContent)}var f={placeholder:h,options:[],optgroups:[],items:[]};return"select"===d?function(){var e,a,d,h,g=f.options,v={},m=function(t){var e=Object.assign({},t.dataset),i=n&&e[n];return"string"==typeof i&&i.length&&(e=Object.assign(e,JSON.parse(i))),e},y=function(t,e){var n=l(t.value);if(n||i.allowEmptyOption)if(v.hasOwnProperty(n)){if(e){var a=v[n][u];a?Array.isArray(a)?a.push(e):v[n][u]=[a,e]:v[n][u]=e}}else{var c=m(t);c[s]=c[s]||t.textContent,c[o]=c[o]||n,c[r]=c[r]||t.disabled,c[u]=c[u]||e,v[n]=c,g.push(c),t.selected&&f.items.push(n)}},O=function(t){var e,i,n,s,o;for((n=t.getAttribute("label"))&&((s=m(t))[c]=n,s[p]=n,s[r]=t.disabled,f.optgroups.push(s)),e=0,i=(o=t.children).length;e<i;e++)y(o[e],n)};for(f.maxItems=t.hasAttribute("multiple")?null:1,e=0,a=(h=t.children).length;e<a;e++)"optgroup"===(d=h[e].tagName.toLowerCase())?O(h[e]):"option"===d&&y(h[e])}():function(){var e,r,a,l,u=t.getAttribute(n);if(u)for(f.options=JSON.parse(u),e=0,r=f.options.length;e<r;e++)f.items.push(f.options[e][o]);else{var c=t.value.trim()||"";if(!i.allowEmptyOption&&!c.length)return;for(e=0,r=(a=c.split(i.delimiter)).length;e<r;e++)(l={})[s]=a[e],l[o]=a[e],f.options.push(l);f.items=a}}(),Object.assign({},a,f,e)}(e,i),s=(window.getComputedStyle&&window.getComputedStyle(e,null)).getPropertyValue("direction"),Object.assign(r,{order:0,settings:i,input:e,tabIndex:e.getAttribute("tabindex")||"",is_select_tag:"select"===e.tagName.toLowerCase(),rtl:/rtl/i.test(s),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:{}}}),r.settings.load&&r.settings.loadThrottle&&(r.settings.load=r.loadDebounce(r.settings.load,r.settings.loadThrottle)),r.sifter=new o(n.options,{diacritics:i.diacritics}),r.setupOptions(r.settings.options,r.settings.optgroups),delete r.settings.optgroups,delete r.settings.options,r.settings.mode=r.settings.mode||(1===r.settings.maxItems?"single":"multi"),"boolean"!=typeof r.settings.hideSelected&&(r.settings.hideSelected="multi"===r.settings.mode),"string"==typeof r.settings.createFilter&&(r.settings.createFilter=new RegExp(r.settings.createFilter)),r.initializePlugins(r.settings.plugins),r.setupCallbacks(),r.setupTemplates(),r.setup(),n}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,e.__proto__=i;var s=n.prototype;return s.setup=function(){var t,e,i,n,s,o,r,a,l=this,u=l.settings,c=l.input;if(o=l.settings.mode,r=c.getAttribute("class")||"",g(t=p("<div>"),u.wrapperClass,r,o),g(e=p('<div class="items">'),u.inputClass),t.append(e),g(n=l.render("dropdown"),u.dropdownClass,o),g(s=p('<div style="scroll-behavior: smooth;">'),u.dropdownContentClass),n.append(s),p(u.dropdownParent||t).appendChild(n),u.controlInput)i=p(u.controlInput);else{i=p('<input type="text" autocomplete="off" />');for(var d=["autocorrect","autocapitalize","autocomplete"],h=0;h<d.length;h++){var f=d[h];c.getAttribute(f)&&i.setAttribute(f,c.getAttribute(f))}}if(u.controlInput||(i.setAttribute("tabindex",c.disabled?"-1":l.tabIndex),e.appendChild(i)),a=c.getAttribute("id")){i.setAttribute("id",a+"-tomselected");var v=document.querySelector("label[for='"+a+"']");v&&v.setAttribute("for",a+"-tomselected")}if(l.settings.copyClassesToDropdown&&g(n,r),t.style.width=c.style.width,l.plugins.names.length&&g([t,n],"plugin-"+l.plugins.names.join(" plugin-")),(null===u.maxItems||u.maxItems>1)&&l.is_select_tag&&c.setAttribute("multiple","multiple"),l.settings.placeholder&&i.setAttribute("placeholder",u.placeholder),!l.settings.splitOn&&l.settings.delimiter){var m=l.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");l.settings.splitOn=new RegExp("\\s*"+m+"+\\s*")}i.type=c.type,l.control=e,l.control_input=i,l.wrapper=t,l.dropdown=n,l.dropdown_content=s,function(t,e,i,n){for(var s=e.split(/\s/),o=function(e){var s=y(e.target,i,t);s&&(e.delegateTarget=s,n.call(s,e))},r=0;r<s.length;r++)t.addEventListener(s[r],o,!0)}(n,"mouseenter","[data-selectable]",(function(){return l.onOptionHover.apply(l,arguments)})),e.addEventListener("mousedown",(function(t){var i=y(t.target,"."+l.settings.itemClass,e);return i?(t.delegateTarget=i,l.onItemSelect.call(l,t)):l.onMouseDown.call(l,t)})),e.addEventListener("click",(function(){return l.onClick.apply(l,arguments)})),i.addEventListener("mousedown",(function(t){t.stopPropagation()})),i.addEventListener("keydown",(function(){return l.onKeyDown.apply(l,arguments)})),i.addEventListener("keyup",(function(){return l.onKeyUp.apply(l,arguments)})),i.addEventListener("keypress",(function(){return l.onKeyPress.apply(l,arguments)})),i.addEventListener("resize",(function(){l.positionDropdown.apply(l,[])})),i.addEventListener("blur",(function(){return l.onBlur.apply(l,arguments)})),i.addEventListener("focus",(function(){return l.ignoreBlur=!1,l.onFocus.apply(l,arguments)})),i.addEventListener("paste",(function(){return l.onPaste.apply(l,arguments)}));var O=function(t){if(l.wrapper.contains(t.target)){t.preventDefault(),t.stopPropagation();var e=y(t.target,"[data-selectable]",l.wrapper);e&&l.onOptionSelect(e,!0)}else l.isFocused&&l.blur(t.target)},w=function(){l.isOpen&&l.positionDropdown.apply(l,arguments)},b=function(){l.ignoreHover=!1};document.addEventListener("mousedown",O),window.addEventListener("sroll",w),window.addEventListener("resize",w),window.addEventListener("mousemove",b),l._destroy=function(){document.removeEventListener("mousedown",O),window.removeEventListener("mousemove",b),window.removeEventListener("sroll",w),window.removeEventListener("resize",w)};for(var C=[];c.children.length>0;)C.push(c.children[0]),c.children[0].remove();this.revertSettings={children:C,tabindex:c.getAttribute("tabindex")},c.setAttribute("tabindex",-1),c.setAttribute("hidden","hidden"),c.insertAdjacentElement("afterend",l.wrapper),l.setValue(u.items),delete u.items,c.addEventListener("invalid",(function(t){t.preventDefault(),l.isInvalid||(l.isInvalid=!0,l.refreshState())})),l.updateOriginalInput(),l.refreshItems(),l.refreshState(),l.isSetup=!0,c.disabled&&l.disable(),l.on("change",this.onChange),g(c,"tomselected"),l.trigger("initialize"),!0===u.preload&&l.onSearchChange("")},s.setupOptions=function(t,e){var i,n;for(e=e||[],i=0,n=(t=t||[]).length;i<n;i++)this.registerOption(t[i]);for(i=0,n=e.length;i<n;i++)this.registerOptionGroup(e[i])},s.setupTemplates=function(){var t=this,e=t.settings.labelField,i=t.settings.optgroupLabelField,n={optgroup:function(t,e){var i=document.createElement("div");return i.className="optgroup",i.appendChild(t.options),i},optgroup_header:function(t,e){return'<div class="optgroup-header">'+e(t[i])+"</div>"},option:function(t,i){return"<div>"+i(t[e])+"</div>"},item:function(t,i){return"<div>"+i(t[e])+"</div>"},option_create:function(t,e){return'<div class="create">Add <strong>'+e(t.input)+"</strong>…</div>"},no_results:function(t,e){return'<div class="no-results">No results found</div>'},loading:function(t,e){return'<div class="spinner"></div>'},dropdown:function(){return'<div style="display:none"></div>'}};t.settings.render=Object.assign({},n,t.settings.render)},s.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)},s.onClick=function(t){var e=this;e.isFocused&&e.isOpen||(e.focus(),t.preventDefault())},s.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)},s.onChange=function(){d(this.input,"change")},s.onPaste=function(t){var e=this;e.isFull()||e.isInputHidden||e.isLocked?t.preventDefault():e.settings.splitOn&&setTimeout((function(){var t=e.inputValue();if(t.match(e.settings.splitOn))for(var i=t.trim().split(e.settings.splitOn),n=0,s=i.length;n<s;n++)e.createItem(i[n])}),0)},s.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},s.onKeyDown=function(t){var e=this;t.target,e.control_input;if(e.ignoreHover=!0,e.isLocked)9!==t.keyCode&&t.preventDefault();else{switch(t.keyCode){case 65:if(e.isKeyDown(17,t))return void e.selectAll();break;case 27:return void(e.isOpen&&(t.preventDefault(),t.stopPropagation(),e.close()));case 40:if(!e.isOpen&&e.hasOptions)e.open();else if(e.activeOption){var i=e.getAdjacent(e.activeOption,1);i&&e.setActiveOption(i,!0)}return void t.preventDefault();case 38:if(e.activeOption){var n=e.getAdjacent(e.activeOption,-1);n&&e.setActiveOption(n,!0)}return void t.preventDefault();case 13:return void(e.isOpen&&e.activeOption&&(e.onOptionSelect(e.activeOption),t.preventDefault()));case 37:return void e.advanceSelection(-1,t);case 39:return void e.advanceSelection(1,t);case 9:return e.settings.selectOnTab&&e.isOpen&&e.activeOption&&(e.onOptionSelect(e.activeOption),t.preventDefault()),void(e.settings.create&&e.createItem()&&t.preventDefault());case 8:case 46:return void e.deleteSelection(t)}!e.isInputHidden||e.isKeyDown(17,t)||t.preventDefault()}},s.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))},s.onSearchChange=function(t){var e=this,i=e.settings.load;i&&(e.loadedSearches.hasOwnProperty(t)||(e.loadedSearches[t]=!0,e.load((function(n){i.apply(e,[t,n])}))))},s.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())},s.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()}},s.onOptionHover=function(t){this.ignoreHover||this.setActiveOption(t.delegateTarget,!1)},s.onOptionSelect=function(t,e){var i,n=this;t&&(t.parentNode&&t.parentNode.matches("[data-disabled]")||(t.classList.contains("create")?n.createItem(null,(function(){n.settings.closeAfterSelect&&n.close()})):void 0!==(i=t.dataset.value)&&(n.lastQuery=null,n.addItem(i),n.settings.closeAfterSelect?n.close():!n.settings.hideSelected&&e&&n.setActiveOption(n.getOption(i)))))},s.onItemSelect=function(t){var e=this;e.isLocked||"multi"===e.settings.mode&&(t.preventDefault(),e.setActiveItem(t.delegateTarget,t))},s.load=function(t){var e=this;g(e.wrapper,e.settings.loadingClass),e.loading++,t.call(e,(function(t,i){e.loading=Math.max(e.loading-1,0),e.lastQuery=null,e.setupOptions(t,i),e.refreshOptions(e.isFocused&&!e.isInputHidden),e.loading||f(e.wrapper,e.settings.loadingClass),e.trigger("load",t)}))},s.loadDebounce=function(t,e){var i;return function(){var n=this,s=arguments;i&&(n.loading=Math.max(n.loading-1,0)),window.clearTimeout(i),i=window.setTimeout((function(){i=null,t.apply(n,s)}),e)}},s.setTextboxValue=function(t){var e=this.control_input;e.value!==t&&(e.value=t,d(e,"update"),this.lastValue=t)},s.getValue=function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)},s.setValue=function(t,e){c(this,e?[]:["change"],(function(){this.clear(e),this.addItems(t,e)}))},s.setActiveItem=function(t,e){var i,n,s,o,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(),(s=Array.prototype.indexOf.call(this.control.children,a))>(o=Array.prototype.indexOf.call(this.control.children,t))&&(r=s,s=o,o=r),n=s;n<=o;n++)t=this.control.children[n],-1===this.activeItems.indexOf(t)&&this.setActiveItemClass(t);e.preventDefault()}else"mousedown"===i&&this.isKeyDown(17,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()}},s.setActiveItemClass=function(t){var e=this.control.querySelector(".last-active");e&&f(e,"last-active"),g(t,"active last-active"),-1==this.activeItems.indexOf(t)&&this.activeItems.push(t)},s.removeActiveItem=function(t){var e=this.activeItems.indexOf(t);this.activeItems.splice(e,1),f(t,"active")},s.setActiveOption=function(t,e){var i,n,s;t!==this.activeOption&&(this.activeOption&&f(this.activeOption,"active"),this.activeOption=null,t&&(this.activeOption=t,g(t,"active"),(e||void 0===e)&&(i=this.dropdown_content.clientHeight,e=this.dropdown_content.scrollTop||0,n=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+e)+n>i+e?this.dropdown_content.scrollTop=s-i+n:s<e&&(this.dropdown_content.scrollTop=s))))},s.selectAll=function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(g(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())},s.hideInput=function(){this.settings.controlInput||(this.setTextboxValue(""),h(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)},s.showInput=function(){this.settings.controlInput||(h(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)},s.inputValue=function(){return this.control_input.value.trim()},s.focus=function(){var t=this;t.isDisabled||(t.ignoreFocus=!0,t.control_input.focus(),window.setTimeout((function(){t.ignoreFocus=!1,t.onFocus()}),0))},s.blur=function(t){this.control_input.blur(),this.onBlur(null,t)},s.getScoreFunction=function(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())},s.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}},s.search=function(t){var e,i,n,s=this,o=s.settings,r=this.getSearchOptions();if(o.score&&"function"!=typeof(n=s.settings.score.call(this,t)))throw new Error('Tom Select "score" setting must be a function that returns a function');if(t!==s.lastQuery?(s.lastQuery=t,i=s.sifter.search(t,Object.assign(r,{score:n})),s.currentResults=i):i=Object.assign({},s.currentResults),o.hideSelected)for(e=i.items.length-1;e>=0;e--)-1!==s.items.indexOf(l(i.items[e].id))&&i.items.splice(e,1);return i},s.refreshOptions=function(t){var e,i,n,s,o,a,u,c,p,d,h,v,m;void 0===t&&(t=!0);var y,O=this,w=O.inputValue(),b=O.search(w),C=O.activeOption&&l(O.activeOption.dataset.value),A=!1;for(s=b.items.length,"number"==typeof O.settings.maxOptions&&(s=Math.min(s,O.settings.maxOptions)),s>0&&(A=!0),o={},a=[],e=0;e<s;e++){var I=O.options[b.items[e].id],_=l(I[O.settings.valueField]),S=O.getOption(_);for(S||(S=O.render("option",I)),u=I[O.settings.optgroupField]||"",i=0,n=(c=Array.isArray(u)?u:[u])&&c.length;i<n;i++)u=c[i],O.optgroups.hasOwnProperty(u)||(u=""),o.hasOwnProperty(u)||(o[u]=document.createDocumentFragment(),a.push(u)),i>0&&f(S=S.cloneNode(!0),"active"),o[u].appendChild(S)}for(this.settings.lockOptgroupOrder&&a.sort((function(t,e){return(O.optgroups[t].$order||0)-(O.optgroups[e].$order||0)})),p=document.createDocumentFragment(),e=0,s=a.length;e<s;e++)if(u=a[e],O.optgroups.hasOwnProperty(u)&&o[u].children.length){var F=document.createDocumentFragment();F.appendChild(O.render("optgroup_header",O.optgroups[u])),F.appendChild(o[u]);var x=O.render("optgroup",{group:O.optgroups[u],options:F});p.appendChild(x)}else p.appendChild(o[u]);if(O.dropdown_content.innerHTML="",O.dropdown_content.appendChild(p),O.settings.highlight&&(O.dropdown_content,y=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(y,(function(t,e){var i=t.parentNode;i.replaceChild(t.firstChild,t),i.normalize()})),b.query.length&&b.tokens.length))for(e=0,s=b.tokens.length;e<s;e++)r(O.dropdown_content,b.tokens[e].regex);if(!O.settings.hideSelected)for(e=0,s=O.items.length;e<s;e++){var L=O.getOption(O.items[e]);L&&g(L,"selected")}var D=function(t){A=!0;var e=O.render(t,{input:w});return O.dropdown_content.insertBefore(e,O.dropdown_content.firstChild),e};if(O.loading?D("loading"):0===b.items.length&&O.settings.render.no_results&&w.length&&D("no_results"),(d=O.canCreate(w))&&(m=D("option_create")),O.hasOptions=b.items.length>0||d,A){if(b.items.length>0)if((v=C&&O.getOption(C))&&O.dropdown_content.contains(v))h=v;else if("single"===O.settings.mode&&O.items.length)h=O.getOption(O.items[0]);else{var P=0;m&&!O.settings.addPrecedence&&(P=1),h=O.selectable()[P]}else h=m;O.setActiveOption(h),t&&!O.isOpen&&O.open()}else O.setActiveOption(null),t&&O.isOpen&&O.close()},s.selectable=function(){return this.dropdown_content.querySelectorAll("[data-selectable]")},s.addOption=function(t){var e,i,n,s=this;if(Array.isArray(t))for(e=0,i=t.length;e<i;e++)s.addOption(t[e]);else(n=s.registerOption(t))&&(s.userOptions[n]=!0,s.lastQuery=null,s.trigger("option_add",n,t))},s.registerOption=function(t){var e=l(t[this.settings.valueField]);return null!=e&&!this.options.hasOwnProperty(e)&&(t.$order=t.$order||++this.order,this.options[e]=t,e)},s.registerOptionGroup=function(t){var e=l(t[this.settings.optgroupValueField]);return!!e&&(t.$order=t.$order||++this.order,this.optgroups[e]=t,e)},s.addOptionGroup=function(t,e){e[this.settings.optgroupValueField]=t,(t=this.registerOptionGroup(e))&&this.trigger("optgroup_add",t,e)},s.removeOptionGroup=function(t){this.optgroups.hasOwnProperty(t)&&(delete this.optgroups[t],this.clearCache(),this.trigger("optgroup_remove",t))},s.clearOptionGroups=function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")},s.updateOption=function(t,e){var i,n,s,o,r,a,u,c=this;if(t=l(t),s=l(e[c.settings.valueField]),null!==t&&c.options.hasOwnProperty(t)){if("string"!=typeof s)throw new Error("Value must be set in option data");u=c.options[t].$order,s!==t&&(delete c.options[t],-1!==(o=c.items.indexOf(t))&&c.items.splice(o,1,s)),e.$order=e.$order||u,c.options[s]=e,r=c.renderCache.item,a=c.renderCache.option,r&&(delete r[t],delete r[s]),a&&(delete a[t],delete a[s]),-1!==c.items.indexOf(s)&&(i=c.getItem(t),n=c.render("item",e),i.classList.contains("active")&&g(n,"active"),i.parentNode.insertBefore(n,i),i.remove()),c.lastQuery=null,c.isOpen&&c.refreshOptions(!1)}},s.removeOption=function(t,e){var i=this;t=l(t);var n=i.renderCache.item,s=i.renderCache.option;n&&delete n[t],s&&delete s[t],delete i.userOptions[t],delete i.options[t],i.lastQuery=null,i.trigger("option_remove",t),i.removeItem(t,e)},s.clearOptions=function(){this.loadedSearches={},this.userOptions={},this.clearCache();var t={};for(var e in this.options)this.options.hasOwnProperty(e)&&this.items.indexOf(e)>=0&&(t[e]=this.options[e]);this.options=this.sifter.items=t,this.lastQuery=null,this.trigger("option_clear")},s.getOption=function(t){return this.renderCache.option.hasOwnProperty(t)?this.renderCache.option[t]:this.getElementWithValue(t,this.selectable())},s.getAdjacent=function(t,e,i){if(void 0===i&&(i="option"),t){var n=this,s=n.settings.optionClass,o=n.dropdown;"item"==i&&(o=n.control,s=n.settings.itemClass);for(var r=o.querySelectorAll("."+s),a=0;a<r.length;a++)if(r[a]==t)return e>0?r[a+1]:r[a-1]}},s.getElementWithValue=function(t,e){if(null!=(t=l(t)))for(var i=0,n=e.length;i<n;i++)if(e[i].getAttribute("data-value")===t)return e[i]},s.getItem=function(t){return this.getElementWithValue(t,this.control.children)},s.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 s=Array.isArray(t)?t:[t],o=(n=0,s.length);n<o;n++)this.isPending=n<o-1,this.addItem(s[n],e);var r=this.control;r.insertBefore(this.buffer,r.firstChild),this.buffer=null},s.addItem=function(t,e){c(this,e?[]:["change"],(function(){var i,n,s=this,o=s.settings.mode;if(t=l(t),(-1===s.items.indexOf(t)||("single"===o&&s.close(),"single"!==o&&s.settings.duplicates))&&s.options.hasOwnProperty(t)&&("single"===o&&s.clear(e),("multi"!==o||!s.isFull())&&(i=s.render("item",s.options[t]),this.control.contains(i)&&(i=i.cloneNode(!0)),n=s.isFull(),s.items.splice(s.caretPos,0,t),s.insertAtCaret(i),(!s.isPending||!n&&s.isFull())&&s.refreshState(),s.isSetup))){var r=s.selectable();if(!s.isPending){var a=s.getOption(t),u=s.getAdjacent(a,1);s.refreshOptions(s.isFocused&&"single"!==o),u&&s.setActiveOption(u)}!r.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.trigger("item_add",t,i),s.isPending||s.updateOriginalInput({silent:e})}}))},s.removeItem=function(t,e){var i,n,s=this.getItem(t);s&&(t=l(s.dataset.value),-1!==(i=this.items.indexOf(t))&&(s.remove(),s.classList.contains("active")&&(n=this.activeItems.indexOf(s),this.activeItems.splice(n,1),f(s,"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,s)))},s.createItem=function(t,e){var i,n=this,s=n.caretPos;t=t||n.inputValue();var o=arguments[arguments.length-1];if("function"!=typeof o&&(o=function(){}),"boolean"!=typeof e&&(e=!0),!n.canCreate(t))return o(),!1;n.lock();var r=!1,a=function(t){if(n.unlock(),!t||"object"!=typeof t)return o();var i=l(t[n.settings.valueField]);if("string"!=typeof i)return o();n.setTextboxValue(""),n.addOption(t),n.setCaret(s),n.addItem(i),n.refreshOptions(e&&"single"!==n.settings.mode),o(t),r=!0};return"function"==typeof n.settings.create?i=n.settings.create.apply(this,[t,a]):((i={})[n.settings.labelField]=t,i[n.settings.valueField]=t),r||a(i),!0},s.refreshItems=function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()},s.refreshState=function(){var t=this;t.refreshValidityState();var e=t.isFull(),i=t.isLocked;t.wrapper.classList.toggle("rtl",t.rtl);var n,s=t.control.classList;s.toggle("focus",t.isFocused),s.toggle("disabled",t.isDisabled),s.toggle("required",t.isRequired),s.toggle("invalid",t.isInvalid),s.toggle("locked",i),s.toggle("full",e),s.toggle("not-full",!e),s.toggle("input-active",t.isFocused&&!t.isInputHidden),s.toggle("dropdown-active",t.isOpen),s.toggle("has-options",(n=t.options,0===Object.keys(n).length)),s.toggle("has-items",t.items.length>0)},s.refreshValidityState=function(){if(this.input.checkValidity){var t=!this.input.checkValidity();this.isInvalid=t,this.control_input.required=t,this.input.required=!t}},s.isFull=function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},s.updateOriginalInput=function(t){var e,i,n,s,o=this;if(t=t||{},o.is_select_tag){for(n=[],e=0,i=o.items.length;e<i;e++)s=o.options[o.items[e]][o.settings.labelField]||"",n.push('<option value="'+u(o.items[e])+'" selected="selected">'+u(s)+"</option>");n.length||this.input.hasAttribute("multiple")||n.push('<option value="" selected="selected"></option>'),o.input.innerHTML=n.join("")}else o.input.value=o.getValue(),o.input.setAttribute("value",o.input.value);o.isSetup&&(t.silent||o.trigger("change",o.input.value))},s.open=function(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.focus(),t.isOpen=!0,t.refreshState(),h(t.dropdown,{visibility:"hidden",display:"block"}),t.positionDropdown(),h(t.dropdown,{visibility:"visible",display:"block"}),t.trigger("dropdown_open",t.dropdown))},s.close=function(){var t=this,e=t.isOpen;"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.isBlurring||t.blur()),t.isOpen=!1,h(t.dropdown,{display:"none"}),t.setActiveOption(null),t.refreshState(),e&&t.trigger("dropdown_close",t.dropdown)},s.positionDropdown=function(){if("body"===this.settings.dropdownParent){var t=this.control,e=t.getBoundingClientRect(),i=t.offsetHeight+e.top+window.scrollY,n=e.left+window.scrollX;h(this.dropdown,{width:e.width+"px",top:i+"px",left:n+"px"})}},s.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")}},s.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)},s.deleteSelection=function(t){var e,i,n,s,o,r,a,l=this;if(n=t&&8===t.keyCode?-1:1,s={start:(a=l.control_input).selectionStart,length:a.selectionEnd-a.selectionStart},o=[],l.activeItems.length){for(r=w(O(l.activeItems,n)),n>0&&r++,e=0,i=l.activeItems.length;e<i;e++)o.push(l.activeItems[e].dataset.value);t&&(t.preventDefault(),t.stopPropagation())}else(l.isFocused||"single"===l.settings.mode)&&l.items.length&&(n<0&&0===s.start&&0===s.length?o.push(l.items[l.caretPos-1]):n>0&&s.start===l.inputValue().length&&o.push(l.items[l.caretPos]));if(!o.length||"function"==typeof l.settings.onDelete&&!1===l.settings.onDelete.apply(l,[o,t]))return!1;for(void 0!==r&&l.setCaret(r);o.length;)l.removeItem(o.pop());return l.showInput(),l.positionDropdown(),l.refreshOptions(!1),!0},s.advanceSelection=function(t,e){var i,n;if(0!==t)if(this.rtl&&(t*=-1),this.isKeyDown(17,e)||this.isKeyDown(16,e)){n=this.getLastActive(t);var s=this.getAdjacent(n,t,"item");s&&(s.classList.contains("active")&&this.removeActiveItem(n),this.setActiveItemClass(s))}else this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+t):(n=this.getLastActive(t))&&(i=w(n),this.setCaret(t>0?i+1:i),this.setActiveItem(null))},s.getLastActive=function(t){var e=this.control.querySelector(".last-active");return e||function(t,e,i){var n=t.querySelectorAll(e);if(n)return O(n,i)}(this.control,".active",t)},s.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){var i,n,s=this.controlChildren(),o=s.length;for(i=0;i<o;i++)n=s[i],i<t?e.control_input.insertAdjacentElement("beforebegin",n):e.control.appendChild(n)}e.caretPos=t},s.controlChildren=function(){return Array.prototype.filter.call(this.control.children,(function(t){return"INPUT"!==t.nodeName}))},s.lock=function(){this.close(),this.isLocked=!0,this.refreshState()},s.unlock=function(){this.isLocked=!1,this.refreshState()},s.disable=function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()},s.enable=function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()},s.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},s.render=function(t,e){var i,n,s="",o=this;return"option"!==t&&"item"!==t||(i=l(e[o.settings.valueField]),!o.renderCache[t].hasOwnProperty(i))?(s=p(o.settings.render[t].apply(this,[e,u])),"option"===t||"option_create"===t?e[o.settings.disabledField]||s.setAttribute("data-selectable",""):"optgroup"===t&&(n=e.group[o.settings.optgroupValueField],s.setAttribute("data-group",n),e.group[o.settings.disabledField]&&s.setAttribute("data-disabled","")),"option"!==t&&"item"!==t||(s.setAttribute("data-value",i),g(s,"item"===t?o.settings.itemClass:o.settings.optionClass),o.renderCache[t][i]=s),s):o.renderCache[t][i]},s.clearCache=function(t){void 0===t?this.renderCache={item:{},option:{}}:this.renderCache[t]={}},s.canCreate=function(t){if(!this.settings.create)return!1;var e=this.settings.createFilter;return t.length&&("function"!=typeof e||e.call(this,t))&&(!(e instanceof RegExp)||e.test(t))},s.isKeyDown=function(t,e){return!!e&&(!e.altKey&&((!e.ctrlKey||!e.shiftKey)&&(!(17!=t||!e.ctrlKey)||!(16!=t||!e.shiftKey))))},s.hook=function(t,e,i){var n=this,s=n[e];n[e]=function(){var e,o;return"after"===t&&(e=s.apply(n,arguments)),o=i.apply(n,arguments),"instead"===t?o:("before"===t&&(e=s.apply(n,arguments)),e)}},n}(t);return(b=C).plugins={},b.prototype.initializePlugins=function(t){var e,i,n,s=this,o=[];if(s.plugins={names:[],settings:{},requested:{},loaded:{}},Array.isArray(t))for(e=0,i=t.length;e<i;e++)"string"==typeof t[e]?o.push(t[e]):(s.plugins.settings[t[e].name]=t[e].options,o.push(t[e].name));else if(t)for(n in t)t.hasOwnProperty(n)&&(s.plugins.settings[n]=t[n],o.push(n));for(;o.length;)s.require(o.shift())},b.prototype.loadPlugin=function(t){var e=this,i=e.plugins,n=b.plugins[t];if(!b.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');i.requested[t]=!0,i.loaded[t]=n.fn.apply(e,[e.plugins.settings[t]||{}]),i.names.push(t)},b.prototype.require=function(t){var e=this,i=e.plugins;if(!e.plugins.loaded.hasOwnProperty(t)){if(i.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")');e.loadPlugin(t)}return i.loaded[t]},b.define=function(t,e){b.plugins[t]={name:t,fn:e}},C}));var tomSelect=function(t,e){return new TomSelect(t,e)}; | ||
/** | ||
* Tom Select v1.0.0-rc.3 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TomSelect=e()}(this,(function(){"use strict";function t(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var e=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){this._events[t]=this._events[t]||[],this._events[t].push(e)},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)))},e.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))},t}();var i=function(t,e){return"number"==typeof t&&"number"==typeof e?t>e?1:t<e?-1:0:(t=o(String(t||"")))>(e=o(String(e||"")))?1:e>t?-1:0},n=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}},s={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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},o=function(){var t,e,i,n,o="",r={};for(i in s)if(s.hasOwnProperty(i))for(o+=n=s[i].substring(2,s[i].length-1),t=0,e=n.length;t<e;t++)r[n.charAt(t)]=i;var l=new RegExp("["+o+"]","g");return function(t){return t.replace(l,(function(t){return r[t]})).toLowerCase()}}(),r=function(){function t(t,e){this.items=t,this.settings=e||{diacritics:!0}}var e=t.prototype;return e.tokenize=function(t,e){if(!(t=String(t||"").toLowerCase().trim())||!t.length)return[];var i,n,o,r,l=[],a=t.split(/ +/);for(i=0,n=a.length;i<n;i++){if(o=(a[i]+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),this.settings.diacritics)for(r in s)s.hasOwnProperty(r)&&(o=o.replace(new RegExp(r,"g"),s[r]));e&&(o="\\b"+o),l.push({string:a[i],regex:new RegExp(o,"i")})}return l},e.iterator=function(t,e){var i;i=Array.isArray(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])},e.getScoreFunction=function(t,e){var i,s,o,r;void 0===e&&(e=null),t=this.prepareSearch(t,e),s=t.tokens,i=t.options.fields,o=s.length,r=t.options.nesting;var l,a=function(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):0},u=(l=i.length)?1===l?function(t,e){return a(n(e,i[0],r),t)}:function(t,e){for(var s=0,o=0;s<l;s++)o+=a(n(e,i[s],r),t);return o/l}:function(){return 0};return o?1===o?function(t){return u(s[0],t)}:"and"===t.options.conjunction?function(t){for(var e,i=0,n=0;i<o;i++){if((e=u(s[i],t))<=0)return 0;n+=e}return n/o}:function(t){for(var e=0,i=0;e<o;e++)i+=u(s[e],t);return i/o}:function(){return 0}},e.getSortFunction=function(t,e){var s,o,r,l,a,u,c,p,d,h,g;if(g=!(t=(r=this).prepareSearch(t,e)).query&&e.sort_empty||e.sort,d=function(t,i){return"$score"===t?i.score:n(r.items[i.id],t,e.nesting)},a=[],g)for(s=0,o=g.length;s<o;s++)(t.query||"$score"!==g[s].field)&&a.push(g[s]);if(t.query){for(h=!0,s=0,o=a.length;s<o;s++)if("$score"===a[s].field){h=!1;break}h&&a.unshift({field:"$score",direction:"desc"})}else for(s=0,o=a.length;s<o;s++)if("$score"===a[s].field){a.splice(s,1);break}for(p=[],s=0,o=a.length;s<o;s++)p.push("desc"===a[s].direction?-1:1);return(u=a.length)?1===u?(l=a[0].field,c=p[0],function(t,e){return c*i(d(l,t),d(l,e))}):function(t,e){var n,s,o;for(n=0;n<u;n++)if(o=a[n].field,s=p[n]*i(d(o,t),d(o,e)))return s;return 0}:null},e.prepareSearch=function(t,e){if("object"==typeof t)return t;var i=(e=Object.assign({},e)).fields,n=e.sort,s=e.sort_empty;return i&&!Array.isArray(i)&&(e.fields=[i]),n&&!Array.isArray(n)&&(e.sort=[n]),s&&!Array.isArray(s)&&(e.sort_empty=[s]),{options:e,query:String(t||"").toLowerCase(),tokens:this.tokenize(t,e.respect_word_boundaries),total:0,items:[]}},e.search=function(t,e){var i,n,s,o,r=this;return n=this.prepareSearch(t,e),e=n.options,t=n.query,o=e.score||r.getScoreFunction(n),t.length?r.iterator(r.items,(function(t,s){i=o(t),(!1===e.filter||i>0)&&n.items.push({score:i,id:s})})):r.iterator(r.items,(function(t,e){n.items.push({score:1,id:e})})),(s=r.getSortFunction(n,e))&&n.items.sort(s),n.total=n.items.length,"number"==typeof e.limit&&(n.items=n.items.slice(0,e.limit)),n},t}();function l(t,e){if("string"!=typeof e||e.length){var i="string"==typeof e?new RegExp(e,"i"):e;!function t(e){var n=0;if(3===e.nodeType){var s=e.data.search(i);if(s>=0&&e.data.length>0){var o=e.data.match(i),r=document.createElement("span");r.className="highlight";var l=e.splitText(s),a=(l.splitText(o[0].length),l.cloneNode(!0));r.appendChild(a),l.parentNode.replaceChild(r,l),n=1}}else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&("highlight"!==e.className||"SPAN"!==e.tagName))for(var u=0;u<e.childNodes.length;++u)u+=t(e.childNodes[u]);return n}(t)}}var a,u={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:50,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:"ts-control",inputClass:"ts-input",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}};function c(t){return null==t?null:"boolean"==typeof t?t?"1":"0":t+""}function p(t){return(t+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function d(t,e,i){var n,s=t.trigger,o={};for(n in t.trigger=function(){var i=arguments[0];if(-1===e.indexOf(i))return s.apply(t,arguments);o[i]=arguments},i.apply(t,[]),t.trigger=s,o)o.hasOwnProperty(n)&&s.apply(t,o[n])}function h(t){if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(t.indexOf("<")>-1){var e=document.createElement("div");return e.innerHTML=t.trim(),e.querySelector(":first-child")}return document.querySelector(t)}function g(t,e){var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!1),t.dispatchEvent(i)}function f(t,e){Object.keys(e).forEach((function(i){t.style[i]=e[i]}))}function v(t){var e=y.apply(null,arguments);(t=O(t)).map((function(t){e.map((function(e){t.classList.add(e)}))}))}function m(t){var e=y.apply(null,arguments);(t=O(t)).map((function(t){e.map((function(e){t.classList.remove(e)}))}))}function y(){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)}function O(t){return Array.isArray(t)||(t=[t]),t}function w(t,e,i){if(!i||i.contains(t))for(;t&&t.matches;){if(t.matches(e))return t;t=t.parentNode}}function b(t,e){return e>0?t[t.length-1]:t[0]}function C(t,e){if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i}return function(e){function i(t,i){var n,s,o=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n=e.call(this)||this);if((t=h(t)).tomselect)throw new Error("Tom Select already initialized on this element");return t.tomselect=o,n.control_input=null,n.wrapper=null,n.dropdown=null,n._destroy=null,n.control=null,n.sifter=null,n.dropdown_content=null,s=(window.getComputedStyle&&window.getComputedStyle(t,null)).getPropertyValue("direction"),n.order=0,n.settings=function(t,e){var i=Object.assign({},u,e),n=i.dataAttr,s=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,a=i.optgroupLabelField,p=i.optgroupValueField,d=t.tagName.toLowerCase(),h=t.getAttribute("placeholder")||t.getAttribute("data-placeholder");if(!h&&!i.allowEmptyOption){var g=t.querySelector('option[value=""]');g&&(h=g.textContent)}var f={placeholder:h,options:[],optgroups:[],items:[]};return"select"===d?function(){var e,u,d,h,g=f.options,v={},m=function(t){var e=Object.assign({},t.dataset),i=n&&e[n];return"string"==typeof i&&i.length&&(e=Object.assign(e,JSON.parse(i))),e},y=function(t,e){var n=c(t.value);if(n||i.allowEmptyOption)if(v.hasOwnProperty(n)){if(e){var a=v[n][l];a?Array.isArray(a)?a.push(e):v[n][l]=[a,e]:v[n][l]=e}}else{var u=m(t);u[s]=u[s]||t.textContent,u[o]=u[o]||n,u[r]=u[r]||t.disabled,u[l]=u[l]||e,v[n]=u,g.push(u),t.selected&&f.items.push(n)}},O=function(t){var e,i,n,s,o;for((n=t.getAttribute("label"))&&((s=m(t))[a]=n,s[p]=n,s[r]=t.disabled,f.optgroups.push(s)),e=0,i=(o=t.children).length;e<i;e++)y(o[e],n)};for(f.maxItems=t.hasAttribute("multiple")?null:1,e=0,u=(h=t.children).length;e<u;e++)"optgroup"===(d=h[e].tagName.toLowerCase())?O(h[e]):"option"===d&&y(h[e])}():function(){var e,r,l,a,u=t.getAttribute(n);if(u)for(f.options=JSON.parse(u),e=0,r=f.options.length;e<r;e++)f.items.push(f.options[e][o]);else{var c=t.value.trim()||"";if(!i.allowEmptyOption&&!c.length)return;for(e=0,r=(l=c.split(i.delimiter)).length;e<r;e++)(a={})[s]=l[e],a[o]=l[e],f.options.push(a);f.items=l}}(),Object.assign({},u,f,e)}(t,i),n.input=t,n.tabIndex=t.getAttribute("tabindex")||"",n.is_select_tag="select"===t.tagName.toLowerCase(),n.rtl=/rtl/i.test(s),n.highlightedValue=null,n.isBlurring=!1,n.isOpen=!1,n.isDisabled=!1,n.isRequired=t.required,n.isInvalid=!1,n.isLocked=!1,n.isFocused=!1,n.isInputHidden=!1,n.isSetup=!1,n.ignoreFocus=!1,n.ignoreBlur=!1,n.ignoreHover=!1,n.hasOptions=!1,n.currentResults=null,n.lastValue="",n.caretPos=0,n.loading=0,n.loadedSearches={},n.activeOption=null,n.activeItems=[],n.optgroups={},n.options={},n.userOptions={},n.items=[],n.renderCache={item:{},option:{}},o.settings.load&&o.settings.loadThrottle&&(o.settings.load=o.loadDebounce(o.settings.load,o.settings.loadThrottle)),o.sifter=new r(n.options,{diacritics:o.settings.diacritics}),o.setupOptions(o.settings.options,o.settings.optgroups),delete o.settings.optgroups,delete o.settings.options,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(),n}t(i,e);var n=i.prototype;return n.setup=function(){var t,e,i,n,s,o,r,l,a,u=this,c=u.settings,p=u.input;if(o=u.settings.mode,r=p.getAttribute("class")||"",v(t=h("<div>"),c.wrapperClass,r,o),v(e=h('<div class="items">'),c.inputClass),t.append(e),v(n=u.render("dropdown"),c.dropdownClass,o),v(s=h('<div style="scroll-behavior: smooth;">'),c.dropdownContentClass),n.append(s),h(c.dropdownParent||t).appendChild(n),c.controlInput)i=h(c.controlInput);else{i=h('<input type="text" autocomplete="off" />');for(var d=["autocorrect","autocapitalize","autocomplete"],g=0;g<d.length;g++){var f=d[g];p.getAttribute(f)&&i.setAttribute(f,p.getAttribute(f))}}if(c.controlInput||(i.setAttribute("tabindex",p.disabled?"-1":u.tabIndex),e.appendChild(i)),a=p.getAttribute("id")){i.setAttribute("id",a+"-tomselected");var m=document.querySelector("label[for='"+a+"']");m&&m.setAttribute("for",a+"-tomselected")}if(u.settings.copyClassesToDropdown&&v(n,r),t.style.width=p.style.width,u.plugins.names.length&&(l="plugin-"+u.plugins.names.join(" plugin-"),v([t,n],l)),(null===c.maxItems||c.maxItems>1)&&u.is_select_tag&&p.setAttribute("multiple","multiple"),u.settings.placeholder&&i.setAttribute("placeholder",c.placeholder),!u.settings.splitOn&&u.settings.delimiter){var y=u.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");u.settings.splitOn=new RegExp("\\s*"+y+"+\\s*")}u.control=e,u.control_input=i,u.wrapper=t,u.dropdown=n,u.dropdown_content=s,u.control_input.type=p.type,n.addEventListener("mouseenter",(function(t){var e=w(t.target,"[data-selectable]",n);if(e)return u.onOptionHover.call(u,t,e)}),!0),e.addEventListener("mousedown",(function(t){var i=w(t.target,"."+u.settings.itemClass,e);return i?u.onItemSelect.call(u,t,i):u.onMouseDown.call(u,t)})),e.addEventListener("click",(function(){u.onClick.apply(u,arguments)})),i.addEventListener("mousedown",(function(t){t.stopPropagation()})),i.addEventListener("keydown",(function(){return u.onKeyDown.apply(u,arguments)})),i.addEventListener("keyup",(function(){return u.onKeyUp.apply(u,arguments)})),i.addEventListener("keypress",(function(){return u.onKeyPress.apply(u,arguments)})),i.addEventListener("resize",(function(){u.positionDropdown.apply(u,[])})),i.addEventListener("blur",(function(){return u.onBlur.apply(u,arguments)})),i.addEventListener("focus",(function(){return u.ignoreBlur=!1,u.onFocus.apply(u,arguments)})),i.addEventListener("paste",(function(){return u.onPaste.apply(u,arguments)}));var O=function(t){var e=w(t.target,"[data-selectable]",u.dropdown);e||u.wrapper.contains(t.target)?(t.preventDefault(),t.stopPropagation(),e&&u.onOptionSelect(t,e)):u.isFocused&&u.blur(t.target)},b=function(){u.isOpen&&u.positionDropdown.apply(u,arguments)},C=function(){u.ignoreHover=!1};document.addEventListener("mousedown",O),window.addEventListener("sroll",b),window.addEventListener("resize",b),window.addEventListener("mousemove",C),u._destroy=function(){document.removeEventListener("mousedown",O),window.removeEventListener("mousemove",C),window.removeEventListener("sroll",b),window.removeEventListener("resize",b)};for(var A=[];p.children.length>0;)A.push(p.children[0]),p.children[0].remove();this.revertSettings={children:A,tabindex:p.getAttribute("tabindex")},p.setAttribute("tabindex",-1),p.setAttribute("hidden","hidden"),p.insertAdjacentElement("afterend",u.wrapper),u.setValue(c.items),delete c.items,p.addEventListener("invalid",(function(t){t.preventDefault(),u.isInvalid||(u.isInvalid=!0,u.refreshState())})),u.updateOriginalInput(),u.refreshItems(),u.refreshState(),u.isSetup=!0,p.disabled&&u.disable(),u.on("change",this.onChange),v(p,"tomselected"),u.trigger("initialize"),!0===c.preload&&u.onSearchChange("")},n.setupOptions=function(t,e){var i,n;for(e=e||[],i=0,n=(t=t||[]).length;i<n;i++)this.registerOption(t[i]);for(i=0,n=e.length;i<n;i++)this.registerOptionGroup(e[i])},n.setupTemplates=function(){var t=this,e=t.settings.labelField,i=t.settings.optgroupLabelField,n={optgroup:function(t,e){var i=document.createElement("div");return i.className="optgroup",i.appendChild(t.options),i},optgroup_header:function(t,e){return'<div class="optgroup-header">'+e(t[i])+"</div>"},option:function(t,i){return"<div>"+i(t[e])+"</div>"},item:function(t,i){return"<div>"+i(t[e])+"</div>"},option_create:function(t,e){return'<div class="create">Add <strong>'+e(t.input)+"</strong>…</div>"},no_results:function(t,e){return'<div class="no-results">No results found</div>'},loading:function(t,e){return'<div class="spinner"></div>'},dropdown:function(){return'<div style="display:none"></div>'}};t.settings.render=Object.assign({},n,t.settings.render)},n.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)},n.onClick=function(t){var e=this;e.isFocused&&e.isOpen||(e.focus(),t.preventDefault())},n.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(),!1}else window.setTimeout((function(){e.focus()}),0)},n.onChange=function(){g(this.input,"change")},n.onPaste=function(t){var e=this;e.isFull()||e.isInputHidden||e.isLocked?t.preventDefault():e.settings.splitOn&&setTimeout((function(){var t=e.inputValue();if(t.match(e.settings.splitOn))for(var i=t.trim().split(e.settings.splitOn),n=0,s=i.length;n<s;n++)e.createItem(i[n])}),0)},n.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},n.onKeyDown=function(t){var e=this;t.target,e.control_input;if(e.ignoreHover=!0,e.isLocked)9!==t.keyCode&&t.preventDefault();else{switch(t.keyCode){case 65:if(e.isKeyDown(17,t))return void e.selectAll();break;case 27:return void(e.isOpen&&(t.preventDefault(),t.stopPropagation(),e.close()));case 40:if(!e.isOpen&&e.hasOptions)e.open();else if(e.activeOption){var i=e.getAdjacent(e.activeOption,1);i&&e.setActiveOption(i,!0)}return void t.preventDefault();case 38:if(e.activeOption){var n=e.getAdjacent(e.activeOption,-1);n&&e.setActiveOption(n,!0)}return void t.preventDefault();case 13:return void(e.isOpen&&e.activeOption&&(e.onOptionSelect(t,e.activeOption),t.preventDefault()));case 37:return void e.advanceSelection(-1,t);case 39:return void e.advanceSelection(1,t);case 9:return e.settings.selectOnTab&&e.isOpen&&e.activeOption&&(e.onOptionSelect(t,e.activeOption),t.preventDefault()),void(e.settings.create&&e.createItem()&&t.preventDefault());case 8:case 46:return void e.deleteSelection(t)}!e.isInputHidden||e.isKeyDown(17,t)||t.preventDefault()}},n.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))},n.onSearchChange=function(t){var e=this,i=e.settings.load;i&&(e.loadedSearches.hasOwnProperty(t)||(e.loadedSearches[t]=!0,e.load((function(n){i.apply(e,[t,n])}))))},n.onFocus=function(t){void 0===t&&(t=null);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(),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())},n.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(),i.setActiveOption(),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()}},n.onOptionHover=function(t,e){this.ignoreHover||this.setActiveOption(e,!1)},n.onOptionSelect=function(t,e){var i,n=this;e&&(e.parentElement&&e.parentElement.matches("[data-disabled]")||(e.classList.contains("create")?n.createItem(null,!0,(function(){n.settings.closeAfterSelect&&n.close()})):void 0!==(i=e.dataset.value)&&(n.lastQuery=null,n.addItem(i),n.settings.closeAfterSelect?n.close():!n.settings.hideSelected&&t.type&&/mouse/.test(t.type)&&n.setActiveOption(n.getOption(i)))))},n.onItemSelect=function(t,e){var i=this;i.isLocked||"multi"===i.settings.mode&&(t.preventDefault(),i.setActiveItem(e,t))},n.load=function(t){var e=this;v(e.wrapper,e.settings.loadingClass),e.loading++,t.call(e,(function(t,i){e.loading=Math.max(e.loading-1,0),e.lastQuery=null,e.setupOptions(t,i),e.refreshOptions(e.isFocused&&!e.isInputHidden),e.loading||m(e.wrapper,e.settings.loadingClass),e.trigger("load",t)}))},n.loadDebounce=function(t,e){var i;return function(){var n=this,s=arguments;i&&(n.loading=Math.max(n.loading-1,0)),window.clearTimeout(i),i=window.setTimeout((function(){i=null,t.apply(n,s)}),e)}},n.setTextboxValue=function(t){var e=this.control_input;e.value!==t&&(e.value=t,g(e,"update"),this.lastValue=t)},n.getValue=function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)},n.setValue=function(t,e){void 0===e&&(e=!1),d(this,e?[]:["change"],(function(){this.clear(e),this.addItems(t,e)}))},n.setActiveItem=function(t,e){var i,n,s,o,r,l;if(void 0===t&&(t=null),void 0===e&&(e=null),"single"!==this.settings.mode){if(!t)return m(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(),(s=Array.prototype.indexOf.call(this.control.children,l))>(o=Array.prototype.indexOf.call(this.control.children,t))&&(r=s,s=o,o=r),n=s;n<=o;n++)t=this.control.children[n],-1===this.activeItems.indexOf(t)&&this.setActiveItemClass(t);e.preventDefault()}else"mousedown"===i&&this.isKeyDown(17,e)||"keydown"===i&&this.isKeyDown(16,e)?t.classList.contains("active")?this.removeActiveItem(t):this.setActiveItemClass(t):(m(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(t));this.hideInput(),this.isFocused||this.focus()}},n.setActiveItemClass=function(t){var e=this.control.querySelector(".last-active");e&&m(e,"last-active"),v(t,"active last-active"),-1==this.activeItems.indexOf(t)&&this.activeItems.push(t)},n.removeActiveItem=function(t){var e=this.activeItems.indexOf(t);this.activeItems.splice(e,1),m(t,"active")},n.setActiveOption=function(t,e){var i,n,s;if(void 0===t&&(t=null),void 0===e&&(e=!1),t!==this.activeOption&&(this.activeOption&&m(this.activeOption,"active"),this.activeOption=null,t&&(this.activeOption=t,v(t,"active"),e))){i=this.dropdown_content.clientHeight;var o=this.dropdown_content.scrollTop||0;n=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+o)+n>i+o?this.dropdown_content.scrollTop=s-i+n:s<o&&(this.dropdown_content.scrollTop=s)}},n.selectAll=function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(v(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())},n.hideInput=function(){this.settings.controlInput||(this.setTextboxValue(""),f(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)},n.showInput=function(){this.settings.controlInput||(f(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)},n.inputValue=function(){return this.control_input.value.trim()},n.focus=function(){var t=this;t.isDisabled||(t.ignoreFocus=!0,t.control_input.focus(),window.setTimeout((function(){t.ignoreFocus=!1,t.onFocus()}),0))},n.blur=function(t){void 0===t&&(t=null),this.control_input.blur(),this.onBlur(null,t)},n.getScoreFunction=function(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())},n.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}},n.search=function(t){var e,i,n,s=this,o=s.settings,r=this.getSearchOptions();if(o.score&&"function"!=typeof(n=s.settings.score.call(this,t)))throw new Error('Tom Select "score" setting must be a function that returns a function');if(t!==s.lastQuery?(s.lastQuery=t,i=s.sifter.search(t,Object.assign(r,{score:n})),s.currentResults=i):i=Object.assign({},s.currentResults),o.hideSelected)for(e=i.items.length-1;e>=0;e--)-1!==s.items.indexOf(c(i.items[e].id))&&i.items.splice(e,1);return i},n.refreshOptions=function(t){var e,i,n,s,o,r,a,u,p,d,h,g,f;void 0===t&&(t=!0);var y,O=this,w=O.inputValue(),b=O.search(w),C=O.activeOption&&c(O.activeOption.dataset.value),A=!1;for(s=b.items.length,"number"==typeof O.settings.maxOptions&&(s=Math.min(s,O.settings.maxOptions)),s>0&&(A=!0),o={},r=[],e=0;e<s;e++){var I=O.options[b.items[e].id],_=c(I[O.settings.valueField]),S=O.getOption(_);for(S||(S=O.render("option",I)),a=I[O.settings.optgroupField]||"",i=0,n=(u=Array.isArray(a)?a:[a])&&u.length;i<n;i++)a=u[i],O.optgroups.hasOwnProperty(a)||(a=""),o.hasOwnProperty(a)||(o[a]=document.createDocumentFragment(),r.push(a)),i>0&&m(S=S.cloneNode(!0),"active"),o[a].appendChild(S)}for(this.settings.lockOptgroupOrder&&r.sort((function(t,e){return(O.optgroups[t].$order||0)-(O.optgroups[e].$order||0)})),p=document.createDocumentFragment(),e=0,s=r.length;e<s;e++)if(a=r[e],O.optgroups.hasOwnProperty(a)&&o[a].children.length){var F=document.createDocumentFragment();F.appendChild(O.render("optgroup_header",O.optgroups[a])),F.appendChild(o[a]);var x=O.render("optgroup",{group:O.optgroups[a],options:F});p.appendChild(x)}else p.appendChild(o[a]);if(O.dropdown_content.innerHTML="",O.dropdown_content.appendChild(p),O.settings.highlight&&(O.dropdown_content,y=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(y,(function(t,e){var i=t.parentNode;i.replaceChild(t.firstChild,t),i.normalize()})),b.query.length&&b.tokens.length))for(e=0,s=b.tokens.length;e<s;e++)l(O.dropdown_content,b.tokens[e].regex);if(!O.settings.hideSelected)for(e=0,s=O.items.length;e<s;e++){var L=O.getOption(O.items[e]);L&&v(L,"selected")}var D=function(t){A=!0;var e=O.render(t,{input:w});return O.dropdown_content.insertBefore(e,O.dropdown_content.firstChild),e};if(O.loading?D("loading"):0===b.items.length&&O.settings.render.no_results&&w.length&&D("no_results"),(d=O.canCreate(w))&&(f=D("option_create")),O.hasOptions=b.items.length>0||d,A){if(b.items.length>0)if((g=C&&O.getOption(C))&&O.dropdown_content.contains(g))h=g;else if("single"===O.settings.mode&&O.items.length)h=O.getOption(O.items[0]);else{var E=0;f&&!O.settings.addPrecedence&&(E=1),h=O.selectable()[E]}else h=f;O.setActiveOption(h),t&&!O.isOpen&&O.open()}else O.setActiveOption(),t&&O.isOpen&&O.close()},n.selectable=function(){return this.dropdown_content.querySelectorAll("[data-selectable]")},n.addOption=function(t){var e,i,n,s=this;if(Array.isArray(t))for(e=0,i=t.length;e<i;e++)s.addOption(t[e]);else(n=s.registerOption(t))&&(s.userOptions[n]=!0,s.lastQuery=null,s.trigger("option_add",n,t))},n.registerOption=function(t){var e=c(t[this.settings.valueField]);return null!=e&&!this.options.hasOwnProperty(e)&&(t.$order=t.$order||++this.order,this.options[e]=t,e)},n.registerOptionGroup=function(t){var e=c(t[this.settings.optgroupValueField]);return!!e&&(t.$order=t.$order||++this.order,this.optgroups[e]=t,e)},n.addOptionGroup=function(t,e){var i;e[this.settings.optgroupValueField]=t,(i=this.registerOptionGroup(e))&&this.trigger("optgroup_add",i,e)},n.removeOptionGroup=function(t){this.optgroups.hasOwnProperty(t)&&(delete this.optgroups[t],this.clearCache(),this.trigger("optgroup_remove",t))},n.clearOptionGroups=function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")},n.updateOption=function(t,e){var i,n,s,o,r,l,a,u=this;if(t=c(t),s=c(e[u.settings.valueField]),null!==t&&u.options.hasOwnProperty(t)){if("string"!=typeof s)throw new Error("Value must be set in option data");a=u.options[t].$order,s!==t&&(delete u.options[t],-1!==(o=u.items.indexOf(t))&&u.items.splice(o,1,s)),e.$order=e.$order||a,u.options[s]=e,r=u.renderCache.item,l=u.renderCache.option,r&&(delete r[t],delete r[s]),l&&(delete l[t],delete l[s]),-1!==u.items.indexOf(s)&&(i=u.getItem(t),n=u.render("item",e),i.classList.contains("active")&&v(n,"active"),i.parentNode.insertBefore(n,i),i.remove()),u.lastQuery=null,u.isOpen&&u.refreshOptions(!1)}},n.removeOption=function(t,e){var i=this;t=c(t);var n=i.renderCache.item,s=i.renderCache.option;n&&delete n[t],s&&delete s[t],delete i.userOptions[t],delete i.options[t],i.lastQuery=null,i.trigger("option_remove",t),i.removeItem(t,e)},n.clearOptions=function(){this.loadedSearches={},this.userOptions={},this.clearCache();var t={};for(var e in this.options)this.options.hasOwnProperty(e)&&this.items.indexOf(e)>=0&&(t[e]=this.options[e]);this.options=this.sifter.items=t,this.lastQuery=null,this.trigger("option_clear")},n.getOption=function(t){return this.renderCache.option.hasOwnProperty(t)?this.renderCache.option[t]:this.getElementWithValue(t,this.selectable())},n.getAdjacent=function(t,e,i){if(void 0===i&&(i="option"),t){var n=this,s=n.settings.optionClass,o=n.dropdown;"item"==i&&(o=n.control,s=n.settings.itemClass);for(var r=o.querySelectorAll("."+s),l=0;l<r.length;l++)if(r[l]==t)return e>0?r[l+1]:r[l-1]}},n.getElementWithValue=function(t,e){if(null!=(t=c(t)))for(var i=0,n=e.length;i<n;i++)if(e[i].getAttribute("data-value")===t)return e[i]},n.getItem=function(t){return this.getElementWithValue(t,this.control.children)},n.addItems=function(t,e){void 0===e&&(e=!1),this.buffer=document.createDocumentFragment();for(var i=this.control.children,n=0;n<i.length;n++)this.buffer.appendChild(i[n]);for(var s=Array.isArray(t)?t:[t],o=0,r=s.length;o<r;o++)this.isPending=o<r-1,this.addItem(s[o],e);var l=this.control;l.insertBefore(this.buffer,l.firstChild),this.buffer=null},n.addItem=function(t,e){void 0===e&&(e=!1),d(this,e?[]:["change"],(function(){var i,n,s=this,o=s.settings.mode;if(t=c(t),(-1===s.items.indexOf(t)||("single"===o&&s.close(),"single"!==o&&s.settings.duplicates))&&s.options.hasOwnProperty(t)&&("single"===o&&s.clear(e),("multi"!==o||!s.isFull())&&(i=s.render("item",s.options[t]),this.control.contains(i)&&(i=i.cloneNode(!0)),n=s.isFull(),s.items.splice(s.caretPos,0,t),s.insertAtCaret(i),(!s.isPending||!n&&s.isFull())&&s.refreshState(),s.isSetup))){var r=s.selectable();if(!s.isPending){var l=s.getOption(t),a=s.getAdjacent(l,1);s.refreshOptions(s.isFocused&&"single"!==o),a&&s.setActiveOption(a)}!r.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.trigger("item_add",t,i),s.isPending||s.updateOriginalInput({silent:e})}}))},n.removeItem=function(t,e){var i,n;void 0===e&&(e=!1);var s=this.getItem(t);s&&(t=c(s.dataset.value),-1!==(i=this.items.indexOf(t))&&(s.remove(),s.classList.contains("active")&&(n=this.activeItems.indexOf(s),this.activeItems.splice(n,1),m(s,"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,s)))},n.createItem=function(t,e,i){void 0===t&&(t=null),void 0===e&&(e=!0),void 0===i&&(i=null);var n,s=this,o=s.caretPos;if(t=t||s.inputValue(),"function"!=typeof i&&(i=function(){}),!s.canCreate(t))return i(),!1;s.lock();var r=!1,l=function(t){if(s.unlock(),!t||"object"!=typeof t)return i();var n=c(t[s.settings.valueField]);if("string"!=typeof n)return i();s.setTextboxValue(""),s.addOption(t),s.setCaret(o),s.addItem(n),s.refreshOptions(e&&"single"!==s.settings.mode),i(t),r=!0};return"function"==typeof s.settings.create?n=s.settings.create.apply(this,[t,l]):((n={})[s.settings.labelField]=t,n[s.settings.valueField]=t),r||l(n),!0},n.refreshItems=function(){this.lastQuery=null,this.isSetup&&this.addItems(this.items),this.refreshState(),this.updateOriginalInput()},n.refreshState=function(){var t=this;t.refreshValidityState();var e=t.isFull(),i=t.isLocked;t.wrapper.classList.toggle("rtl",t.rtl);var n,s=t.control.classList;s.toggle("focus",t.isFocused),s.toggle("disabled",t.isDisabled),s.toggle("required",t.isRequired),s.toggle("invalid",t.isInvalid),s.toggle("locked",i),s.toggle("full",e),s.toggle("not-full",!e),s.toggle("input-active",t.isFocused&&!t.isInputHidden),s.toggle("dropdown-active",t.isOpen),s.toggle("has-options",(n=t.options,0===Object.keys(n).length)),s.toggle("has-items",t.items.length>0)},n.refreshValidityState=function(){if(this.input.checkValidity){var t=!this.input.checkValidity();this.isInvalid=t,this.control_input.required=t,this.input.required=!t}},n.isFull=function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},n.updateOriginalInput=function(t){var e,i,n,s,o=this;if(t=t||{},o.is_select_tag){for(n=[],e=0,i=o.items.length;e<i;e++)s=o.options[o.items[e]][o.settings.labelField]||"",n.push('<option value="'+p(o.items[e])+'" selected="selected">'+p(s)+"</option>");n.length||this.input.hasAttribute("multiple")||n.push('<option value="" selected="selected"></option>'),o.input.innerHTML=n.join("")}else o.input.value=o.getValue(),o.input.setAttribute("value",o.input.value);o.isSetup&&(t.silent||o.trigger("change",o.input.value))},n.open=function(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.focus(),t.isOpen=!0,t.refreshState(),f(t.dropdown,{visibility:"hidden",display:"block"}),t.positionDropdown(),f(t.dropdown,{visibility:"visible",display:"block"}),t.trigger("dropdown_open",t.dropdown))},n.close=function(){var t=this,e=t.isOpen;"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.isBlurring||t.blur()),t.isOpen=!1,f(t.dropdown,{display:"none"}),t.setActiveOption(),t.refreshState(),e&&t.trigger("dropdown_close",t.dropdown)},n.positionDropdown=function(){if("body"===this.settings.dropdownParent){var t=this.control,e=t.getBoundingClientRect(),i=t.offsetHeight+e.top+window.scrollY,n=e.left+window.scrollX;f(this.dropdown,{width:e.width+"px",top:i+"px",left:n+"px"})}},n.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(),this.updateOriginalInput({silent:t}),this.refreshState(),this.showInput(),this.trigger("clear")}},n.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)},n.deleteSelection=function(t){var e,i,n,s,o,r,l,a=this;if(n=t&&8===t.keyCode?-1:1,s={start:(l=a.control_input).selectionStart,length:l.selectionEnd-l.selectionStart},o=[],a.activeItems.length){for(r=C(b(a.activeItems,n)),n>0&&r++,e=0,i=a.activeItems.length;e<i;e++)o.push(a.activeItems[e].dataset.value);t&&(t.preventDefault(),t.stopPropagation())}else(a.isFocused||"single"===a.settings.mode)&&a.items.length&&(n<0&&0===s.start&&0===s.length?o.push(a.items[a.caretPos-1]):n>0&&s.start===a.inputValue().length&&o.push(a.items[a.caretPos]));if(!o.length||"function"==typeof a.settings.onDelete&&!1===a.settings.onDelete.apply(a,[o,t]))return!1;for(void 0!==r&&a.setCaret(r);o.length;)a.removeItem(o.pop());return a.showInput(),a.positionDropdown(),a.refreshOptions(!1),!0},n.advanceSelection=function(t,e){var i,n;if(0!==t)if(this.rtl&&(t*=-1),this.isKeyDown(17,e)||this.isKeyDown(16,e)){n=this.getLastActive(t);var s=this.getAdjacent(n,t,"item");s&&(s.classList.contains("active")&&this.removeActiveItem(n),this.setActiveItemClass(s))}else this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+t):(n=this.getLastActive(t))&&(i=C(n),this.setCaret(t>0?i+1:i),this.setActiveItem())},n.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)},n.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){var i,n,s=this.controlChildren(),o=s.length;for(i=0;i<o;i++)n=s[i],i<t?e.control_input.insertAdjacentElement("beforebegin",n):e.control.appendChild(n)}e.caretPos=t},n.controlChildren=function(){return Array.prototype.filter.call(this.control.children,(function(t){return"INPUT"!==t.nodeName}))},n.lock=function(){this.close(),this.isLocked=!0,this.refreshState()},n.unlock=function(){this.isLocked=!1,this.refreshState()},n.disable=function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()},n.enable=function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()},n.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"),m(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},n.render=function(t,e){var i,n,s;void 0===e&&(e=null);var o=this;return"option"!==t&&"item"!==t||(i=c(e[o.settings.valueField]),!o.renderCache[t].hasOwnProperty(i))?(s=h(o.settings.render[t].apply(this,[e,p])),"option"===t||"option_create"===t?e[o.settings.disabledField]||s.setAttribute("data-selectable",""):"optgroup"===t&&(n=e.group[o.settings.optgroupValueField],s.setAttribute("data-group",n),e.group[o.settings.disabledField]&&s.setAttribute("data-disabled","")),"option"!==t&&"item"!==t||(s.setAttribute("data-value",i),v(s,"item"===t?o.settings.itemClass:o.settings.optionClass),o.renderCache[t][i]=s),s):o.renderCache[t][i]},n.clearCache=function(t){void 0===t&&(t=null);null===t?this.renderCache={item:{},option:{}}:this.renderCache[t]={}},n.canCreate=function(t){if(!this.settings.create)return!1;var e=this.settings.createFilter;return t.length&&("function"!=typeof e||e.call(this,t))&&(!(e instanceof RegExp)||e.test(t))},n.isKeyDown=function(t,e){return!!e&&(!e.altKey&&((!e.ctrlKey||!e.shiftKey)&&(!(17!=t||!e.ctrlKey)||!(16!=t||!e.shiftKey))))},n.hook=function(t,e,i){var n=this,s=n[e];n[e]=function(){var e,o;return"after"===t&&(e=s.apply(n,arguments)),o=i.apply(n,arguments),"instead"===t?o:("before"===t&&(e=s.apply(n,arguments)),e)}},i}(((a=e).plugins={},function(e){function i(){return e.apply(this,arguments)||this}t(i,e),i.define=function(t,e){a.plugins[t]={name:t,fn:e}};var n=i.prototype;return n.initializePlugins=function(t){var e,i,n,s=this,o=[];if(s.plugins={names:[],settings:{},requested:{},loaded:{}},Array.isArray(t))for(e=0,i=t.length;e<i;e++)"string"==typeof t[e]?o.push(t[e]):(s.plugins.settings[t[e].name]=t[e].options,o.push(t[e].name));else if(t)for(n in t)t.hasOwnProperty(n)&&(s.plugins.settings[n]=t[n],o.push(n));for(;o.length;)s.require(o.shift())},n.loadPlugin=function(t){var e=this,i=e.plugins,n=a.plugins[t];if(!a.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');i.requested[t]=!0,i.loaded[t]=n.fn.apply(e,[e.plugins.settings[t]||{}]),i.names.push(t)},n.require=function(t){var e=this,i=e.plugins;if(!e.plugins.loaded.hasOwnProperty(t)){if(i.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")');e.loadPlugin(t)}return i.loaded[t]},i}(a)))}));var tomSelect=function(t,e){return new TomSelect(t,e)}; | ||
//# sourceMappingURL=tom-select.base.min.js.map |
@@ -1,2 +0,6 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TomSelect=e()}(this,(function(){"use strict";var t=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){this._events[t]=this._events[t]||[],this._events[t].push(e)},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)))},e.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))},t}();var e=function(t,e){return"number"==typeof t&&"number"==typeof e?t>e?1:t<e?-1:0:(t=s(String(t||"")))>(e=s(String(e||"")))?1:e>t?-1:0},i=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}},n={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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},s=function(){var t,e,i,s,o="",r={};for(i in n)if(n.hasOwnProperty(i))for(o+=s=n[i].substring(2,n[i].length-1),t=0,e=s.length;t<e;t++)r[s.charAt(t)]=i;var a=new RegExp("["+o+"]","g");return function(t){return t.replace(a,(function(t){return r[t]})).toLowerCase()}}(),o=function(){function t(t,e){this.items=t,this.settings=e||{diacritics:!0}}var s=t.prototype;return s.tokenize=function(t,e){if(!(t=String(t||"").toLowerCase().trim())||!t.length)return[];var i,s,o,r,a=[],l=t.split(/ +/);for(i=0,s=l.length;i<s;i++){if(o=(l[i]+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),this.settings.diacritics)for(r in n)n.hasOwnProperty(r)&&(o=o.replace(new RegExp(r,"g"),n[r]));e&&(o="\\b"+o),a.push({string:l[i],regex:new RegExp(o,"i")})}return a},s.iterator=function(t,e){var i;i=Array.isArray(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])},s.getScoreFunction=function(t,e){var n,s,o,r;t=this.prepareSearch(t,e),s=t.tokens,n=t.options.fields,o=s.length,r=t.options.nesting;var a,l=function(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):0},u=(a=n.length)?1===a?function(t,e){return l(i(e,n[0],r),t)}:function(t,e){for(var s=0,o=0;s<a;s++)o+=l(i(e,n[s],r),t);return o/a}:function(){return 0};return o?1===o?function(t){return u(s[0],t)}:"and"===t.options.conjunction?function(t){for(var e,i=0,n=0;i<o;i++){if((e=u(s[i],t))<=0)return 0;n+=e}return n/o}:function(t){for(var e=0,i=0;e<o;e++)i+=u(s[e],t);return i/o}:function(){return 0}},s.getSortFunction=function(t,n){var s,o,r,a,l,u,c,p,d,h,g;if(g=!(t=(r=this).prepareSearch(t,n)).query&&n.sort_empty||n.sort,d=function(t,e){return"$score"===t?e.score:i(r.items[e.id],t,n.nesting)},l=[],g)for(s=0,o=g.length;s<o;s++)(t.query||"$score"!==g[s].field)&&l.push(g[s]);if(t.query){for(h=!0,s=0,o=l.length;s<o;s++)if("$score"===l[s].field){h=!1;break}h&&l.unshift({field:"$score",direction:"desc"})}else for(s=0,o=l.length;s<o;s++)if("$score"===l[s].field){l.splice(s,1);break}for(p=[],s=0,o=l.length;s<o;s++)p.push("desc"===l[s].direction?-1:1);return(u=l.length)?1===u?(a=l[0].field,c=p[0],function(t,i){return c*e(d(a,t),d(a,i))}):function(t,i){var n,s,o;for(n=0;n<u;n++)if(o=l[n].field,s=p[n]*e(d(o,t),d(o,i)))return s;return 0}:null},s.prepareSearch=function(t,e){if("object"==typeof t)return t;var i=(e=Object.assign({},e)).fields,n=e.sort,s=e.sort_empty;return i&&!Array.isArray(i)&&(e.fields=[i]),n&&!Array.isArray(n)&&(e.sort=[n]),s&&!Array.isArray(s)&&(e.sort_empty=[s]),{options:e,query:String(t||"").toLowerCase(),tokens:this.tokenize(t,e.respect_word_boundaries),total:0,items:[]}},s.search=function(t,e){var i,n,s,o,r=this;return n=this.prepareSearch(t,e),e=n.options,t=n.query,o=e.score||r.getScoreFunction(n),t.length?r.iterator(r.items,(function(t,s){i=o(t),(!1===e.filter||i>0)&&n.items.push({score:i,id:s})})):r.iterator(r.items,(function(t,e){n.items.push({score:1,id:e})})),(s=r.getSortFunction(n,e))&&n.items.sort(s),n.total=n.items.length,"number"==typeof e.limit&&(n.items=n.items.slice(0,e.limit)),n},t}();function r(t,e){if("string"!=typeof e||e.length){var i="string"==typeof e?new RegExp(e,"i"):e;!function t(e){var n=0;if(3===e.nodeType){var s=e.data.search(i);if(s>=0&&e.data.length>0){var o=e.data.match(i),r=document.createElement("span");r.className="highlight";var a=e.splitText(s),l=(a.splitText(o[0].length),a.cloneNode(!0));r.appendChild(l),a.parentNode.replaceChild(r,a),n=1}}else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&("highlight"!==e.className||"SPAN"!==e.tagName))for(var u=0;u<e.childNodes.length;++u)u+=t(e.childNodes[u]);return n}(t)}}var a={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:50,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:"ts-control",inputClass:"ts-input",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}};function l(t){return null==t?null:"boolean"==typeof t?t?"1":"0":t+""}function u(t){return(t+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t,e,i){var n,s=t.trigger,o={};for(n in t.trigger=function(){var i=arguments[0];if(-1===e.indexOf(i))return s.apply(t,arguments);o[i]=arguments},i.apply(t,[]),t.trigger=s,o)o.hasOwnProperty(n)&&s.apply(t,o[n])}function p(t,e){var i=Object.assign({},a,e),n=i.dataAttr,s=i.labelField,o=i.valueField,r=i.disabledField,u=i.optgroupField,c=i.optgroupLabelField,p=i.optgroupValueField,d=t.tagName.toLowerCase(),h=t.getAttribute("placeholder")||t.getAttribute("data-placeholder");if(!h&&!i.allowEmptyOption){var g=t.querySelector('option[value=""]');g&&(h=g.textContent)}var f={placeholder:h,options:[],optgroups:[],items:[]};return"select"===d?function(){var e,a,d,h,g=f.options,v={},m=function(t){var e=Object.assign({},t.dataset),i=n&&e[n];return"string"==typeof i&&i.length&&(e=Object.assign(e,JSON.parse(i))),e},y=function(t,e){var n=l(t.value);if(n||i.allowEmptyOption)if(v.hasOwnProperty(n)){if(e){var a=v[n][u];a?Array.isArray(a)?a.push(e):v[n][u]=[a,e]:v[n][u]=e}}else{var c=m(t);c[s]=c[s]||t.textContent,c[o]=c[o]||n,c[r]=c[r]||t.disabled,c[u]=c[u]||e,v[n]=c,g.push(c),t.selected&&f.items.push(n)}},w=function(t){var e,i,n,s,o;for((n=t.getAttribute("label"))&&((s=m(t))[c]=n,s[p]=n,s[r]=t.disabled,f.optgroups.push(s)),e=0,i=(o=t.children).length;e<i;e++)y(o[e],n)};for(f.maxItems=t.hasAttribute("multiple")?null:1,e=0,a=(h=t.children).length;e<a;e++)"optgroup"===(d=h[e].tagName.toLowerCase())?w(h[e]):"option"===d&&y(h[e])}():function(){var e,r,a,l,u=t.getAttribute(n);if(u)for(f.options=JSON.parse(u),e=0,r=f.options.length;e<r;e++)f.items.push(f.options[e][o]);else{var c=t.value.trim()||"";if(!i.allowEmptyOption&&!c.length)return;for(e=0,r=(a=c.split(i.delimiter)).length;e<r;e++)(l={})[s]=a[e],l[o]=a[e],f.options.push(l);f.items=a}}(),Object.assign({},a,f,e)}function d(t){if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(t.indexOf("<")>-1){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild}return document.querySelector(t)}function h(t,e){var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!1),t.dispatchEvent(i)}function g(t,e){Object.keys(e).forEach((function(i){t.style[i]=e[i]}))}function f(t){var e=m.apply(null,arguments);(t=y(t)).map((function(t){e.map((function(e){t.classList.add(e)}))}))}function v(t){var e=m.apply(null,arguments);(t=y(t)).map((function(t){e.map((function(e){t.classList.remove(e)}))}))}function m(){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)}function y(t){return Array.isArray(t)||(t=[t]),t}function w(t,e,i){if(!i||i.contains(t))for(;t&&t.matches;){if(t.matches(e))return t;t=t.parentNode}}function O(t,e){return e>0?t[t.length-1]:t[0]}function b(t,e){if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i}var C,A=function(t){var e,i;function n(e,i){var n,s,r=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n=t.call(this)||this);if((e=d(e)).tomselect)throw new Error("Tom Select already initialized on this element");return e.tomselect=r,i=p(e,i),s=(window.getComputedStyle&&window.getComputedStyle(e,null)).getPropertyValue("direction"),Object.assign(r,{order:0,settings:i,input:e,tabIndex:e.getAttribute("tabindex")||"",is_select_tag:"select"===e.tagName.toLowerCase(),rtl:/rtl/i.test(s),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:{}}}),r.settings.load&&r.settings.loadThrottle&&(r.settings.load=r.loadDebounce(r.settings.load,r.settings.loadThrottle)),r.sifter=new o(n.options,{diacritics:i.diacritics}),r.setupOptions(r.settings.options,r.settings.optgroups),delete r.settings.optgroups,delete r.settings.options,r.settings.mode=r.settings.mode||(1===r.settings.maxItems?"single":"multi"),"boolean"!=typeof r.settings.hideSelected&&(r.settings.hideSelected="multi"===r.settings.mode),"string"==typeof r.settings.createFilter&&(r.settings.createFilter=new RegExp(r.settings.createFilter)),r.initializePlugins(r.settings.plugins),r.setupCallbacks(),r.setupTemplates(),r.setup(),n}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,e.__proto__=i;var s=n.prototype;return s.setup=function(){var t,e,i,n,s,o,r,a,l=this,u=l.settings,c=l.input;if(o=l.settings.mode,r=c.getAttribute("class")||"",f(t=d("<div>"),u.wrapperClass,r,o),f(e=d('<div class="items">'),u.inputClass),t.append(e),f(n=l.render("dropdown"),u.dropdownClass,o),f(s=d('<div style="scroll-behavior: smooth;">'),u.dropdownContentClass),n.append(s),d(u.dropdownParent||t).appendChild(n),u.controlInput)i=d(u.controlInput);else{i=d('<input type="text" autocomplete="off" />');for(var p=["autocorrect","autocapitalize","autocomplete"],h=0;h<p.length;h++){var g=p[h];c.getAttribute(g)&&i.setAttribute(g,c.getAttribute(g))}}if(u.controlInput||(i.setAttribute("tabindex",c.disabled?"-1":l.tabIndex),e.appendChild(i)),a=c.getAttribute("id")){i.setAttribute("id",a+"-tomselected");var v=document.querySelector("label[for='"+a+"']");v&&v.setAttribute("for",a+"-tomselected")}if(l.settings.copyClassesToDropdown&&f(n,r),t.style.width=c.style.width,l.plugins.names.length&&f([t,n],"plugin-"+l.plugins.names.join(" plugin-")),(null===u.maxItems||u.maxItems>1)&&l.is_select_tag&&c.setAttribute("multiple","multiple"),l.settings.placeholder&&i.setAttribute("placeholder",u.placeholder),!l.settings.splitOn&&l.settings.delimiter){var m=l.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");l.settings.splitOn=new RegExp("\\s*"+m+"+\\s*")}i.type=c.type,l.control=e,l.control_input=i,l.wrapper=t,l.dropdown=n,l.dropdown_content=s,function(t,e,i,n){for(var s=e.split(/\s/),o=function(e){var s=w(e.target,i,t);s&&(e.delegateTarget=s,n.call(s,e))},r=0;r<s.length;r++)t.addEventListener(s[r],o,!0)}(n,"mouseenter","[data-selectable]",(function(){return l.onOptionHover.apply(l,arguments)})),e.addEventListener("mousedown",(function(t){var i=w(t.target,"."+l.settings.itemClass,e);return i?(t.delegateTarget=i,l.onItemSelect.call(l,t)):l.onMouseDown.call(l,t)})),e.addEventListener("click",(function(){return l.onClick.apply(l,arguments)})),i.addEventListener("mousedown",(function(t){t.stopPropagation()})),i.addEventListener("keydown",(function(){return l.onKeyDown.apply(l,arguments)})),i.addEventListener("keyup",(function(){return l.onKeyUp.apply(l,arguments)})),i.addEventListener("keypress",(function(){return l.onKeyPress.apply(l,arguments)})),i.addEventListener("resize",(function(){l.positionDropdown.apply(l,[])})),i.addEventListener("blur",(function(){return l.onBlur.apply(l,arguments)})),i.addEventListener("focus",(function(){return l.ignoreBlur=!1,l.onFocus.apply(l,arguments)})),i.addEventListener("paste",(function(){return l.onPaste.apply(l,arguments)}));var y=function(t){if(l.wrapper.contains(t.target)){t.preventDefault(),t.stopPropagation();var e=w(t.target,"[data-selectable]",l.wrapper);e&&l.onOptionSelect(e,!0)}else l.isFocused&&l.blur(t.target)},O=function(){l.isOpen&&l.positionDropdown.apply(l,arguments)},b=function(){l.ignoreHover=!1};document.addEventListener("mousedown",y),window.addEventListener("sroll",O),window.addEventListener("resize",O),window.addEventListener("mousemove",b),l._destroy=function(){document.removeEventListener("mousedown",y),window.removeEventListener("mousemove",b),window.removeEventListener("sroll",O),window.removeEventListener("resize",O)};for(var C=[];c.children.length>0;)C.push(c.children[0]),c.children[0].remove();this.revertSettings={children:C,tabindex:c.getAttribute("tabindex")},c.setAttribute("tabindex",-1),c.setAttribute("hidden","hidden"),c.insertAdjacentElement("afterend",l.wrapper),l.setValue(u.items),delete u.items,c.addEventListener("invalid",(function(t){t.preventDefault(),l.isInvalid||(l.isInvalid=!0,l.refreshState())})),l.updateOriginalInput(),l.refreshItems(),l.refreshState(),l.isSetup=!0,c.disabled&&l.disable(),l.on("change",this.onChange),f(c,"tomselected"),l.trigger("initialize"),!0===u.preload&&l.onSearchChange("")},s.setupOptions=function(t,e){var i,n;for(e=e||[],i=0,n=(t=t||[]).length;i<n;i++)this.registerOption(t[i]);for(i=0,n=e.length;i<n;i++)this.registerOptionGroup(e[i])},s.setupTemplates=function(){var t=this,e=t.settings.labelField,i=t.settings.optgroupLabelField,n={optgroup:function(t,e){var i=document.createElement("div");return i.className="optgroup",i.appendChild(t.options),i},optgroup_header:function(t,e){return'<div class="optgroup-header">'+e(t[i])+"</div>"},option:function(t,i){return"<div>"+i(t[e])+"</div>"},item:function(t,i){return"<div>"+i(t[e])+"</div>"},option_create:function(t,e){return'<div class="create">Add <strong>'+e(t.input)+"</strong>…</div>"},no_results:function(t,e){return'<div class="no-results">No results found</div>'},loading:function(t,e){return'<div class="spinner"></div>'},dropdown:function(){return'<div style="display:none"></div>'}};t.settings.render=Object.assign({},n,t.settings.render)},s.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)},s.onClick=function(t){var e=this;e.isFocused&&e.isOpen||(e.focus(),t.preventDefault())},s.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)},s.onChange=function(){h(this.input,"change")},s.onPaste=function(t){var e=this;e.isFull()||e.isInputHidden||e.isLocked?t.preventDefault():e.settings.splitOn&&setTimeout((function(){var t=e.inputValue();if(t.match(e.settings.splitOn))for(var i=t.trim().split(e.settings.splitOn),n=0,s=i.length;n<s;n++)e.createItem(i[n])}),0)},s.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},s.onKeyDown=function(t){var e=this;t.target,e.control_input;if(e.ignoreHover=!0,e.isLocked)9!==t.keyCode&&t.preventDefault();else{switch(t.keyCode){case 65:if(e.isKeyDown(17,t))return void e.selectAll();break;case 27:return void(e.isOpen&&(t.preventDefault(),t.stopPropagation(),e.close()));case 40:if(!e.isOpen&&e.hasOptions)e.open();else if(e.activeOption){var i=e.getAdjacent(e.activeOption,1);i&&e.setActiveOption(i,!0)}return void t.preventDefault();case 38:if(e.activeOption){var n=e.getAdjacent(e.activeOption,-1);n&&e.setActiveOption(n,!0)}return void t.preventDefault();case 13:return void(e.isOpen&&e.activeOption&&(e.onOptionSelect(e.activeOption),t.preventDefault()));case 37:return void e.advanceSelection(-1,t);case 39:return void e.advanceSelection(1,t);case 9:return e.settings.selectOnTab&&e.isOpen&&e.activeOption&&(e.onOptionSelect(e.activeOption),t.preventDefault()),void(e.settings.create&&e.createItem()&&t.preventDefault());case 8:case 46:return void e.deleteSelection(t)}!e.isInputHidden||e.isKeyDown(17,t)||t.preventDefault()}},s.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))},s.onSearchChange=function(t){var e=this,i=e.settings.load;i&&(e.loadedSearches.hasOwnProperty(t)||(e.loadedSearches[t]=!0,e.load((function(n){i.apply(e,[t,n])}))))},s.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())},s.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()}},s.onOptionHover=function(t){this.ignoreHover||this.setActiveOption(t.delegateTarget,!1)},s.onOptionSelect=function(t,e){var i,n=this;t&&(t.parentNode&&t.parentNode.matches("[data-disabled]")||(t.classList.contains("create")?n.createItem(null,(function(){n.settings.closeAfterSelect&&n.close()})):void 0!==(i=t.dataset.value)&&(n.lastQuery=null,n.addItem(i),n.settings.closeAfterSelect?n.close():!n.settings.hideSelected&&e&&n.setActiveOption(n.getOption(i)))))},s.onItemSelect=function(t){var e=this;e.isLocked||"multi"===e.settings.mode&&(t.preventDefault(),e.setActiveItem(t.delegateTarget,t))},s.load=function(t){var e=this;f(e.wrapper,e.settings.loadingClass),e.loading++,t.call(e,(function(t,i){e.loading=Math.max(e.loading-1,0),e.lastQuery=null,e.setupOptions(t,i),e.refreshOptions(e.isFocused&&!e.isInputHidden),e.loading||v(e.wrapper,e.settings.loadingClass),e.trigger("load",t)}))},s.loadDebounce=function(t,e){var i;return function(){var n=this,s=arguments;i&&(n.loading=Math.max(n.loading-1,0)),window.clearTimeout(i),i=window.setTimeout((function(){i=null,t.apply(n,s)}),e)}},s.setTextboxValue=function(t){var e=this.control_input;e.value!==t&&(e.value=t,h(e,"update"),this.lastValue=t)},s.getValue=function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)},s.setValue=function(t,e){c(this,e?[]:["change"],(function(){this.clear(e),this.addItems(t,e)}))},s.setActiveItem=function(t,e){var i,n,s,o,r,a;if("single"!==this.settings.mode){if(!t)return v(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(),(s=Array.prototype.indexOf.call(this.control.children,a))>(o=Array.prototype.indexOf.call(this.control.children,t))&&(r=s,s=o,o=r),n=s;n<=o;n++)t=this.control.children[n],-1===this.activeItems.indexOf(t)&&this.setActiveItemClass(t);e.preventDefault()}else"mousedown"===i&&this.isKeyDown(17,e)||"keydown"===i&&this.isKeyDown(16,e)?t.classList.contains("active")?this.removeActiveItem(t):this.setActiveItemClass(t):(v(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(t));this.hideInput(),this.isFocused||this.focus()}},s.setActiveItemClass=function(t){var e=this.control.querySelector(".last-active");e&&v(e,"last-active"),f(t,"active last-active"),-1==this.activeItems.indexOf(t)&&this.activeItems.push(t)},s.removeActiveItem=function(t){var e=this.activeItems.indexOf(t);this.activeItems.splice(e,1),v(t,"active")},s.setActiveOption=function(t,e){var i,n,s;t!==this.activeOption&&(this.activeOption&&v(this.activeOption,"active"),this.activeOption=null,t&&(this.activeOption=t,f(t,"active"),(e||void 0===e)&&(i=this.dropdown_content.clientHeight,e=this.dropdown_content.scrollTop||0,n=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+e)+n>i+e?this.dropdown_content.scrollTop=s-i+n:s<e&&(this.dropdown_content.scrollTop=s))))},s.selectAll=function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(f(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())},s.hideInput=function(){this.settings.controlInput||(this.setTextboxValue(""),g(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)},s.showInput=function(){this.settings.controlInput||(g(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)},s.inputValue=function(){return this.control_input.value.trim()},s.focus=function(){var t=this;t.isDisabled||(t.ignoreFocus=!0,t.control_input.focus(),window.setTimeout((function(){t.ignoreFocus=!1,t.onFocus()}),0))},s.blur=function(t){this.control_input.blur(),this.onBlur(null,t)},s.getScoreFunction=function(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())},s.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}},s.search=function(t){var e,i,n,s=this,o=s.settings,r=this.getSearchOptions();if(o.score&&"function"!=typeof(n=s.settings.score.call(this,t)))throw new Error('Tom Select "score" setting must be a function that returns a function');if(t!==s.lastQuery?(s.lastQuery=t,i=s.sifter.search(t,Object.assign(r,{score:n})),s.currentResults=i):i=Object.assign({},s.currentResults),o.hideSelected)for(e=i.items.length-1;e>=0;e--)-1!==s.items.indexOf(l(i.items[e].id))&&i.items.splice(e,1);return i},s.refreshOptions=function(t){var e,i,n,s,o,a,u,c,p,d,h,g,m;void 0===t&&(t=!0);var y,w=this,O=w.inputValue(),b=w.search(O),C=w.activeOption&&l(w.activeOption.dataset.value),A=!1;for(s=b.items.length,"number"==typeof w.settings.maxOptions&&(s=Math.min(s,w.settings.maxOptions)),s>0&&(A=!0),o={},a=[],e=0;e<s;e++){var I=w.options[b.items[e].id],_=l(I[w.settings.valueField]),S=w.getOption(_);for(S||(S=w.render("option",I)),u=I[w.settings.optgroupField]||"",i=0,n=(c=Array.isArray(u)?u:[u])&&c.length;i<n;i++)u=c[i],w.optgroups.hasOwnProperty(u)||(u=""),o.hasOwnProperty(u)||(o[u]=document.createDocumentFragment(),a.push(u)),i>0&&v(S=S.cloneNode(!0),"active"),o[u].appendChild(S)}for(this.settings.lockOptgroupOrder&&a.sort((function(t,e){return(w.optgroups[t].$order||0)-(w.optgroups[e].$order||0)})),p=document.createDocumentFragment(),e=0,s=a.length;e<s;e++)if(u=a[e],w.optgroups.hasOwnProperty(u)&&o[u].children.length){var x=document.createDocumentFragment();x.appendChild(w.render("optgroup_header",w.optgroups[u])),x.appendChild(o[u]);var F=w.render("optgroup",{group:w.optgroups[u],options:x});p.appendChild(F)}else p.appendChild(o[u]);if(w.dropdown_content.innerHTML="",w.dropdown_content.appendChild(p),w.settings.highlight&&(w.dropdown_content,y=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(y,(function(t,e){var i=t.parentNode;i.replaceChild(t.firstChild,t),i.normalize()})),b.query.length&&b.tokens.length))for(e=0,s=b.tokens.length;e<s;e++)r(w.dropdown_content,b.tokens[e].regex);if(!w.settings.hideSelected)for(e=0,s=w.items.length;e<s;e++){var k=w.getOption(w.items[e]);k&&f(k,"selected")}var L=function(t){A=!0;var e=w.render(t,{input:O});return w.dropdown_content.insertBefore(e,w.dropdown_content.firstChild),e};if(w.loading?L("loading"):0===b.items.length&&w.settings.render.no_results&&O.length&&L("no_results"),(d=w.canCreate(O))&&(m=L("option_create")),w.hasOptions=b.items.length>0||d,A){if(b.items.length>0)if((g=C&&w.getOption(C))&&w.dropdown_content.contains(g))h=g;else if("single"===w.settings.mode&&w.items.length)h=w.getOption(w.items[0]);else{var D=0;m&&!w.settings.addPrecedence&&(D=1),h=w.selectable()[D]}else h=m;w.setActiveOption(h),t&&!w.isOpen&&w.open()}else w.setActiveOption(null),t&&w.isOpen&&w.close()},s.selectable=function(){return this.dropdown_content.querySelectorAll("[data-selectable]")},s.addOption=function(t){var e,i,n,s=this;if(Array.isArray(t))for(e=0,i=t.length;e<i;e++)s.addOption(t[e]);else(n=s.registerOption(t))&&(s.userOptions[n]=!0,s.lastQuery=null,s.trigger("option_add",n,t))},s.registerOption=function(t){var e=l(t[this.settings.valueField]);return null!=e&&!this.options.hasOwnProperty(e)&&(t.$order=t.$order||++this.order,this.options[e]=t,e)},s.registerOptionGroup=function(t){var e=l(t[this.settings.optgroupValueField]);return!!e&&(t.$order=t.$order||++this.order,this.optgroups[e]=t,e)},s.addOptionGroup=function(t,e){e[this.settings.optgroupValueField]=t,(t=this.registerOptionGroup(e))&&this.trigger("optgroup_add",t,e)},s.removeOptionGroup=function(t){this.optgroups.hasOwnProperty(t)&&(delete this.optgroups[t],this.clearCache(),this.trigger("optgroup_remove",t))},s.clearOptionGroups=function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")},s.updateOption=function(t,e){var i,n,s,o,r,a,u,c=this;if(t=l(t),s=l(e[c.settings.valueField]),null!==t&&c.options.hasOwnProperty(t)){if("string"!=typeof s)throw new Error("Value must be set in option data");u=c.options[t].$order,s!==t&&(delete c.options[t],-1!==(o=c.items.indexOf(t))&&c.items.splice(o,1,s)),e.$order=e.$order||u,c.options[s]=e,r=c.renderCache.item,a=c.renderCache.option,r&&(delete r[t],delete r[s]),a&&(delete a[t],delete a[s]),-1!==c.items.indexOf(s)&&(i=c.getItem(t),n=c.render("item",e),i.classList.contains("active")&&f(n,"active"),i.parentNode.insertBefore(n,i),i.remove()),c.lastQuery=null,c.isOpen&&c.refreshOptions(!1)}},s.removeOption=function(t,e){var i=this;t=l(t);var n=i.renderCache.item,s=i.renderCache.option;n&&delete n[t],s&&delete s[t],delete i.userOptions[t],delete i.options[t],i.lastQuery=null,i.trigger("option_remove",t),i.removeItem(t,e)},s.clearOptions=function(){this.loadedSearches={},this.userOptions={},this.clearCache();var t={};for(var e in this.options)this.options.hasOwnProperty(e)&&this.items.indexOf(e)>=0&&(t[e]=this.options[e]);this.options=this.sifter.items=t,this.lastQuery=null,this.trigger("option_clear")},s.getOption=function(t){return this.renderCache.option.hasOwnProperty(t)?this.renderCache.option[t]:this.getElementWithValue(t,this.selectable())},s.getAdjacent=function(t,e,i){if(void 0===i&&(i="option"),t){var n=this,s=n.settings.optionClass,o=n.dropdown;"item"==i&&(o=n.control,s=n.settings.itemClass);for(var r=o.querySelectorAll("."+s),a=0;a<r.length;a++)if(r[a]==t)return e>0?r[a+1]:r[a-1]}},s.getElementWithValue=function(t,e){if(null!=(t=l(t)))for(var i=0,n=e.length;i<n;i++)if(e[i].getAttribute("data-value")===t)return e[i]},s.getItem=function(t){return this.getElementWithValue(t,this.control.children)},s.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 s=Array.isArray(t)?t:[t],o=(n=0,s.length);n<o;n++)this.isPending=n<o-1,this.addItem(s[n],e);var r=this.control;r.insertBefore(this.buffer,r.firstChild),this.buffer=null},s.addItem=function(t,e){c(this,e?[]:["change"],(function(){var i,n,s=this,o=s.settings.mode;if(t=l(t),(-1===s.items.indexOf(t)||("single"===o&&s.close(),"single"!==o&&s.settings.duplicates))&&s.options.hasOwnProperty(t)&&("single"===o&&s.clear(e),("multi"!==o||!s.isFull())&&(i=s.render("item",s.options[t]),this.control.contains(i)&&(i=i.cloneNode(!0)),n=s.isFull(),s.items.splice(s.caretPos,0,t),s.insertAtCaret(i),(!s.isPending||!n&&s.isFull())&&s.refreshState(),s.isSetup))){var r=s.selectable();if(!s.isPending){var a=s.getOption(t),u=s.getAdjacent(a,1);s.refreshOptions(s.isFocused&&"single"!==o),u&&s.setActiveOption(u)}!r.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.trigger("item_add",t,i),s.isPending||s.updateOriginalInput({silent:e})}}))},s.removeItem=function(t,e){var i,n,s=this.getItem(t);s&&(t=l(s.dataset.value),-1!==(i=this.items.indexOf(t))&&(s.remove(),s.classList.contains("active")&&(n=this.activeItems.indexOf(s),this.activeItems.splice(n,1),v(s,"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,s)))},s.createItem=function(t,e){var i,n=this,s=n.caretPos;t=t||n.inputValue();var o=arguments[arguments.length-1];if("function"!=typeof o&&(o=function(){}),"boolean"!=typeof e&&(e=!0),!n.canCreate(t))return o(),!1;n.lock();var r=!1,a=function(t){if(n.unlock(),!t||"object"!=typeof t)return o();var i=l(t[n.settings.valueField]);if("string"!=typeof i)return o();n.setTextboxValue(""),n.addOption(t),n.setCaret(s),n.addItem(i),n.refreshOptions(e&&"single"!==n.settings.mode),o(t),r=!0};return"function"==typeof n.settings.create?i=n.settings.create.apply(this,[t,a]):((i={})[n.settings.labelField]=t,i[n.settings.valueField]=t),r||a(i),!0},s.refreshItems=function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()},s.refreshState=function(){var t=this;t.refreshValidityState();var e=t.isFull(),i=t.isLocked;t.wrapper.classList.toggle("rtl",t.rtl);var n,s=t.control.classList;s.toggle("focus",t.isFocused),s.toggle("disabled",t.isDisabled),s.toggle("required",t.isRequired),s.toggle("invalid",t.isInvalid),s.toggle("locked",i),s.toggle("full",e),s.toggle("not-full",!e),s.toggle("input-active",t.isFocused&&!t.isInputHidden),s.toggle("dropdown-active",t.isOpen),s.toggle("has-options",(n=t.options,0===Object.keys(n).length)),s.toggle("has-items",t.items.length>0)},s.refreshValidityState=function(){if(this.input.checkValidity){var t=!this.input.checkValidity();this.isInvalid=t,this.control_input.required=t,this.input.required=!t}},s.isFull=function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},s.updateOriginalInput=function(t){var e,i,n,s,o=this;if(t=t||{},o.is_select_tag){for(n=[],e=0,i=o.items.length;e<i;e++)s=o.options[o.items[e]][o.settings.labelField]||"",n.push('<option value="'+u(o.items[e])+'" selected="selected">'+u(s)+"</option>");n.length||this.input.hasAttribute("multiple")||n.push('<option value="" selected="selected"></option>'),o.input.innerHTML=n.join("")}else o.input.value=o.getValue(),o.input.setAttribute("value",o.input.value);o.isSetup&&(t.silent||o.trigger("change",o.input.value))},s.open=function(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.focus(),t.isOpen=!0,t.refreshState(),g(t.dropdown,{visibility:"hidden",display:"block"}),t.positionDropdown(),g(t.dropdown,{visibility:"visible",display:"block"}),t.trigger("dropdown_open",t.dropdown))},s.close=function(){var t=this,e=t.isOpen;"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.isBlurring||t.blur()),t.isOpen=!1,g(t.dropdown,{display:"none"}),t.setActiveOption(null),t.refreshState(),e&&t.trigger("dropdown_close",t.dropdown)},s.positionDropdown=function(){if("body"===this.settings.dropdownParent){var t=this.control,e=t.getBoundingClientRect(),i=t.offsetHeight+e.top+window.scrollY,n=e.left+window.scrollX;g(this.dropdown,{width:e.width+"px",top:i+"px",left:n+"px"})}},s.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")}},s.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)},s.deleteSelection=function(t){var e,i,n,s,o,r,a,l=this;if(n=t&&8===t.keyCode?-1:1,s={start:(a=l.control_input).selectionStart,length:a.selectionEnd-a.selectionStart},o=[],l.activeItems.length){for(r=b(O(l.activeItems,n)),n>0&&r++,e=0,i=l.activeItems.length;e<i;e++)o.push(l.activeItems[e].dataset.value);t&&(t.preventDefault(),t.stopPropagation())}else(l.isFocused||"single"===l.settings.mode)&&l.items.length&&(n<0&&0===s.start&&0===s.length?o.push(l.items[l.caretPos-1]):n>0&&s.start===l.inputValue().length&&o.push(l.items[l.caretPos]));if(!o.length||"function"==typeof l.settings.onDelete&&!1===l.settings.onDelete.apply(l,[o,t]))return!1;for(void 0!==r&&l.setCaret(r);o.length;)l.removeItem(o.pop());return l.showInput(),l.positionDropdown(),l.refreshOptions(!1),!0},s.advanceSelection=function(t,e){var i,n;if(0!==t)if(this.rtl&&(t*=-1),this.isKeyDown(17,e)||this.isKeyDown(16,e)){n=this.getLastActive(t);var s=this.getAdjacent(n,t,"item");s&&(s.classList.contains("active")&&this.removeActiveItem(n),this.setActiveItemClass(s))}else this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+t):(n=this.getLastActive(t))&&(i=b(n),this.setCaret(t>0?i+1:i),this.setActiveItem(null))},s.getLastActive=function(t){var e=this.control.querySelector(".last-active");return e||function(t,e,i){var n=t.querySelectorAll(e);if(n)return O(n,i)}(this.control,".active",t)},s.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){var i,n,s=this.controlChildren(),o=s.length;for(i=0;i<o;i++)n=s[i],i<t?e.control_input.insertAdjacentElement("beforebegin",n):e.control.appendChild(n)}e.caretPos=t},s.controlChildren=function(){return Array.prototype.filter.call(this.control.children,(function(t){return"INPUT"!==t.nodeName}))},s.lock=function(){this.close(),this.isLocked=!0,this.refreshState()},s.unlock=function(){this.isLocked=!1,this.refreshState()},s.disable=function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()},s.enable=function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()},s.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"),v(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},s.render=function(t,e){var i,n,s="",o=this;return"option"!==t&&"item"!==t||(i=l(e[o.settings.valueField]),!o.renderCache[t].hasOwnProperty(i))?(s=d(o.settings.render[t].apply(this,[e,u])),"option"===t||"option_create"===t?e[o.settings.disabledField]||s.setAttribute("data-selectable",""):"optgroup"===t&&(n=e.group[o.settings.optgroupValueField],s.setAttribute("data-group",n),e.group[o.settings.disabledField]&&s.setAttribute("data-disabled","")),"option"!==t&&"item"!==t||(s.setAttribute("data-value",i),f(s,"item"===t?o.settings.itemClass:o.settings.optionClass),o.renderCache[t][i]=s),s):o.renderCache[t][i]},s.clearCache=function(t){void 0===t?this.renderCache={item:{},option:{}}:this.renderCache[t]={}},s.canCreate=function(t){if(!this.settings.create)return!1;var e=this.settings.createFilter;return t.length&&("function"!=typeof e||e.call(this,t))&&(!(e instanceof RegExp)||e.test(t))},s.isKeyDown=function(t,e){return!!e&&(!e.altKey&&((!e.ctrlKey||!e.shiftKey)&&(!(17!=t||!e.ctrlKey)||!(16!=t||!e.shiftKey))))},s.hook=function(t,e,i){var n=this,s=n[e];n[e]=function(){var e,o;return"after"===t&&(e=s.apply(n,arguments)),o=i.apply(n,arguments),"instead"===t?o:("before"===t&&(e=s.apply(n,arguments)),e)}},n}(t);return(C=A).plugins={},C.prototype.initializePlugins=function(t){var e,i,n,s=this,o=[];if(s.plugins={names:[],settings:{},requested:{},loaded:{}},Array.isArray(t))for(e=0,i=t.length;e<i;e++)"string"==typeof t[e]?o.push(t[e]):(s.plugins.settings[t[e].name]=t[e].options,o.push(t[e].name));else if(t)for(n in t)t.hasOwnProperty(n)&&(s.plugins.settings[n]=t[n],o.push(n));for(;o.length;)s.require(o.shift())},C.prototype.loadPlugin=function(t){var e=this,i=e.plugins,n=C.plugins[t];if(!C.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');i.requested[t]=!0,i.loaded[t]=n.fn.apply(e,[e.plugins.settings[t]||{}]),i.names.push(t)},C.prototype.require=function(t){var e=this,i=e.plugins;if(!e.plugins.loaded.hasOwnProperty(t)){if(i.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")');e.loadPlugin(t)}return i.loaded[t]},C.define=function(t,e){C.plugins[t]={name:t,fn:e}},A.define("change_listener",(function(t){var e=this,i=!1;e.input.addEventListener("change",(function(){if(i)i=!1;else{i=!0;var t=p(e.input,{});e.setupOptions(t.options,t.optgroups),e.setValue(t.items)}}))})),A.define("drag_drop",(function(t){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');if("multi"===this.settings.mode){var e=this,i=e.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 t=$(e.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:e.isLocked,start:function(e,i){i.placeholder.css("width",i.helper.css("width")),t.css({overflow:"visible"})},stop:function(){t.css({overflow:"hidden"});var i=[];t.children("[data-value]").each((function(){i.push($(this).attr("data-value"))})),e.setValue(i)}})}))}})),A.define("dropdown_header",(function(t){var e=this;t=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+'">×</a></div></div>'}},t),e.hook("after","setup",(function(){var i=d(t.html(t));e.dropdown.insertBefore(i,e.dropdown.firstChild)}))})),A.define("input_autogrow",(function(t){var e=this;e.hook("after","setup",(function(){var t=document.createElement("span"),i=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",e.wrapper.appendChild(t);for(var n=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"],s=0,o=n.length;s<o;s++){var r=n[s];t.style[r]=i.style[r]}var a=function(){t.textContent=i.value,i.style.width=t.clientWidth+"px"};i.addEventListener("input",a),i.addEventListener("keyup",a),i.addEventListener("blur",a),i.addEventListener("update",a)}))})),A.define("no_backspace_delete",(function(t){this.hook("instead","setActiveItem",(function(){})),this.hook("instead","selectAll",(function(){})),this.hook("instead","deleteSelection",(function(){}))})),A.define("optgroup_columns",(function(t){var e=this,i=e.onKeyDown;e.hook("instead","onKeyDown",(function(t){var n,s,o,r;if(!e.isOpen||37!==t.keyCode&&39!==t.keyCode)return i.apply(e,arguments);e.ignoreHover=!0,r=w(e.activeOption,"[data-group]"),n=b(e.activeOption,"[data-selectable]"),(r=37===t.keyCode?r.previousSibling:r.nextSibling)&&(s=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,n)])&&e.setActiveOption(s)}))})),A.define("remove_button",(function(t){t=Object.assign({label:"×",title:"Remove",className:"remove",append:!0},t);var e=this;if(t.append){var i='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+u(t.title)+'">'+t.label+"</a>";e.hook("after","setupTemplates",(function(){var t=e.settings.render.item;e.settings.render.item=function(){var n=d(t.apply(e,arguments)),s=d(i);return n.appendChild(s),s.addEventListener("mousedown",(function(t){t.preventDefault(),t.stopPropagation()})),s.addEventListener("click",(function(t){if(t.preventDefault(),t.stopPropagation(),"single"!==e.settings.mode&&t.stopPropagation(),!e.isLocked){var i=n.dataset.value;e.removeItem(i),e.refreshOptions(!1)}})),n}}))}})),A.define("restore_on_backspace",(function(t){var e=this;t.text=t.text||function(t){return t[e.settings.labelField]};var i=e.onKeyDown;e.hook("instead","onKeyDown",(function(n){var s,o;return 8===n.keyCode&&""===e.control_input.value&&!e.activeItems.length&&(s=e.caretPos-1)>=0&&s<e.items.length?(o=e.options[e.items[s]],e.deleteSelection(n)&&(e.setTextboxValue(t.text.call(e,o)),e.refreshOptions(!0)),void n.preventDefault()):i.apply(e,arguments)}))})),A}));var tomSelect=function(t,e){return new TomSelect(t,e)}; | ||
/** | ||
* Tom Select v1.0.0-rc.3 | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TomSelect=e()}(this,(function(){"use strict";function t(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var e=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){this._events[t]=this._events[t]||[],this._events[t].push(e)},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)))},e.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))},t}();var i=function(t,e){return"number"==typeof t&&"number"==typeof e?t>e?1:t<e?-1:0:(t=o(String(t||"")))>(e=o(String(e||"")))?1:e>t?-1:0},n=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}},s={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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},o=function(){var t,e,i,n,o="",r={};for(i in s)if(s.hasOwnProperty(i))for(o+=n=s[i].substring(2,s[i].length-1),t=0,e=n.length;t<e;t++)r[n.charAt(t)]=i;var a=new RegExp("["+o+"]","g");return function(t){return t.replace(a,(function(t){return r[t]})).toLowerCase()}}(),r=function(){function t(t,e){this.items=t,this.settings=e||{diacritics:!0}}var e=t.prototype;return e.tokenize=function(t,e){if(!(t=String(t||"").toLowerCase().trim())||!t.length)return[];var i,n,o,r,a=[],l=t.split(/ +/);for(i=0,n=l.length;i<n;i++){if(o=(l[i]+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),this.settings.diacritics)for(r in s)s.hasOwnProperty(r)&&(o=o.replace(new RegExp(r,"g"),s[r]));e&&(o="\\b"+o),a.push({string:l[i],regex:new RegExp(o,"i")})}return a},e.iterator=function(t,e){var i;i=Array.isArray(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])},e.getScoreFunction=function(t,e){var i,s,o,r;void 0===e&&(e=null),t=this.prepareSearch(t,e),s=t.tokens,i=t.options.fields,o=s.length,r=t.options.nesting;var a,l=function(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):0},u=(a=i.length)?1===a?function(t,e){return l(n(e,i[0],r),t)}:function(t,e){for(var s=0,o=0;s<a;s++)o+=l(n(e,i[s],r),t);return o/a}:function(){return 0};return o?1===o?function(t){return u(s[0],t)}:"and"===t.options.conjunction?function(t){for(var e,i=0,n=0;i<o;i++){if((e=u(s[i],t))<=0)return 0;n+=e}return n/o}:function(t){for(var e=0,i=0;e<o;e++)i+=u(s[e],t);return i/o}:function(){return 0}},e.getSortFunction=function(t,e){var s,o,r,a,l,u,c,p,d,h,f;if(f=!(t=(r=this).prepareSearch(t,e)).query&&e.sort_empty||e.sort,d=function(t,i){return"$score"===t?i.score:n(r.items[i.id],t,e.nesting)},l=[],f)for(s=0,o=f.length;s<o;s++)(t.query||"$score"!==f[s].field)&&l.push(f[s]);if(t.query){for(h=!0,s=0,o=l.length;s<o;s++)if("$score"===l[s].field){h=!1;break}h&&l.unshift({field:"$score",direction:"desc"})}else for(s=0,o=l.length;s<o;s++)if("$score"===l[s].field){l.splice(s,1);break}for(p=[],s=0,o=l.length;s<o;s++)p.push("desc"===l[s].direction?-1:1);return(u=l.length)?1===u?(a=l[0].field,c=p[0],function(t,e){return c*i(d(a,t),d(a,e))}):function(t,e){var n,s,o;for(n=0;n<u;n++)if(o=l[n].field,s=p[n]*i(d(o,t),d(o,e)))return s;return 0}:null},e.prepareSearch=function(t,e){if("object"==typeof t)return t;var i=(e=Object.assign({},e)).fields,n=e.sort,s=e.sort_empty;return i&&!Array.isArray(i)&&(e.fields=[i]),n&&!Array.isArray(n)&&(e.sort=[n]),s&&!Array.isArray(s)&&(e.sort_empty=[s]),{options:e,query:String(t||"").toLowerCase(),tokens:this.tokenize(t,e.respect_word_boundaries),total:0,items:[]}},e.search=function(t,e){var i,n,s,o,r=this;return n=this.prepareSearch(t,e),e=n.options,t=n.query,o=e.score||r.getScoreFunction(n),t.length?r.iterator(r.items,(function(t,s){i=o(t),(!1===e.filter||i>0)&&n.items.push({score:i,id:s})})):r.iterator(r.items,(function(t,e){n.items.push({score:1,id:e})})),(s=r.getSortFunction(n,e))&&n.items.sort(s),n.total=n.items.length,"number"==typeof e.limit&&(n.items=n.items.slice(0,e.limit)),n},t}();function a(t,e){if("string"!=typeof e||e.length){var i="string"==typeof e?new RegExp(e,"i"):e;!function t(e){var n=0;if(3===e.nodeType){var s=e.data.search(i);if(s>=0&&e.data.length>0){var o=e.data.match(i),r=document.createElement("span");r.className="highlight";var a=e.splitText(s),l=(a.splitText(o[0].length),a.cloneNode(!0));r.appendChild(l),a.parentNode.replaceChild(r,a),n=1}}else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&("highlight"!==e.className||"SPAN"!==e.tagName))for(var u=0;u<e.childNodes.length;++u)u+=t(e.childNodes[u]);return n}(t)}}var l={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:50,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:"ts-control",inputClass:"ts-input",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:null,copyClassesToDropdown:!0,render:{}};function u(t){return null==t?null:"boolean"==typeof t?t?"1":"0":t+""}function c(t){return(t+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function p(t,e,i){var n,s=t.trigger,o={};for(n in t.trigger=function(){var i=arguments[0];if(-1===e.indexOf(i))return s.apply(t,arguments);o[i]=arguments},i.apply(t,[]),t.trigger=s,o)o.hasOwnProperty(n)&&s.apply(t,o[n])}function d(t,e){var i=Object.assign({},l,e),n=i.dataAttr,s=i.labelField,o=i.valueField,r=i.disabledField,a=i.optgroupField,c=i.optgroupLabelField,p=i.optgroupValueField,d=t.tagName.toLowerCase(),h=t.getAttribute("placeholder")||t.getAttribute("data-placeholder");if(!h&&!i.allowEmptyOption){var f=t.querySelector('option[value=""]');f&&(h=f.textContent)}var g={placeholder:h,options:[],optgroups:[],items:[]};return"select"===d?function(){var e,l,d,h,f=g.options,v={},m=function(t){var e=Object.assign({},t.dataset),i=n&&e[n];return"string"==typeof i&&i.length&&(e=Object.assign(e,JSON.parse(i))),e},y=function(t,e){var n=u(t.value);if(n||i.allowEmptyOption)if(v.hasOwnProperty(n)){if(e){var l=v[n][a];l?Array.isArray(l)?l.push(e):v[n][a]=[l,e]:v[n][a]=e}}else{var c=m(t);c[s]=c[s]||t.textContent,c[o]=c[o]||n,c[r]=c[r]||t.disabled,c[a]=c[a]||e,v[n]=c,f.push(c),t.selected&&g.items.push(n)}},w=function(t){var e,i,n,s,o;for((n=t.getAttribute("label"))&&((s=m(t))[c]=n,s[p]=n,s[r]=t.disabled,g.optgroups.push(s)),e=0,i=(o=t.children).length;e<i;e++)y(o[e],n)};for(g.maxItems=t.hasAttribute("multiple")?null:1,e=0,l=(h=t.children).length;e<l;e++)"optgroup"===(d=h[e].tagName.toLowerCase())?w(h[e]):"option"===d&&y(h[e])}():function(){var e,r,a,l,u=t.getAttribute(n);if(u)for(g.options=JSON.parse(u),e=0,r=g.options.length;e<r;e++)g.items.push(g.options[e][o]);else{var c=t.value.trim()||"";if(!i.allowEmptyOption&&!c.length)return;for(e=0,r=(a=c.split(i.delimiter)).length;e<r;e++)(l={})[s]=a[e],l[o]=a[e],g.options.push(l);g.items=a}}(),Object.assign({},l,g,e)}function h(t){if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(t.indexOf("<")>-1){var e=document.createElement("div");return e.innerHTML=t.trim(),e.querySelector(":first-child")}return document.querySelector(t)}function f(t,e){var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!1),t.dispatchEvent(i)}function g(t,e){Object.keys(e).forEach((function(i){t.style[i]=e[i]}))}function v(t){var e=y.apply(null,arguments);(t=w(t)).map((function(t){e.map((function(e){t.classList.add(e)}))}))}function m(t){var e=y.apply(null,arguments);(t=w(t)).map((function(t){e.map((function(e){t.classList.remove(e)}))}))}function y(){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)}function w(t){return Array.isArray(t)||(t=[t]),t}function O(t,e,i){if(!i||i.contains(t))for(;t&&t.matches;){if(t.matches(e))return t;t=t.parentNode}}function b(t,e){return e>0?t[t.length-1]:t[0]}function C(t,e){if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i}var A,I=function(e){function i(t,i){var n,s,o=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n=e.call(this)||this);if((t=h(t)).tomselect)throw new Error("Tom Select already initialized on this element");return t.tomselect=o,n.control_input=null,n.wrapper=null,n.dropdown=null,n._destroy=null,n.control=null,n.sifter=null,n.dropdown_content=null,s=(window.getComputedStyle&&window.getComputedStyle(t,null)).getPropertyValue("direction"),n.order=0,n.settings=d(t,i),n.input=t,n.tabIndex=t.getAttribute("tabindex")||"",n.is_select_tag="select"===t.tagName.toLowerCase(),n.rtl=/rtl/i.test(s),n.highlightedValue=null,n.isBlurring=!1,n.isOpen=!1,n.isDisabled=!1,n.isRequired=t.required,n.isInvalid=!1,n.isLocked=!1,n.isFocused=!1,n.isInputHidden=!1,n.isSetup=!1,n.ignoreFocus=!1,n.ignoreBlur=!1,n.ignoreHover=!1,n.hasOptions=!1,n.currentResults=null,n.lastValue="",n.caretPos=0,n.loading=0,n.loadedSearches={},n.activeOption=null,n.activeItems=[],n.optgroups={},n.options={},n.userOptions={},n.items=[],n.renderCache={item:{},option:{}},o.settings.load&&o.settings.loadThrottle&&(o.settings.load=o.loadDebounce(o.settings.load,o.settings.loadThrottle)),o.sifter=new r(n.options,{diacritics:o.settings.diacritics}),o.setupOptions(o.settings.options,o.settings.optgroups),delete o.settings.optgroups,delete o.settings.options,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(),n}t(i,e);var n=i.prototype;return n.setup=function(){var t,e,i,n,s,o,r,a,l,u=this,c=u.settings,p=u.input;if(o=u.settings.mode,r=p.getAttribute("class")||"",v(t=h("<div>"),c.wrapperClass,r,o),v(e=h('<div class="items">'),c.inputClass),t.append(e),v(n=u.render("dropdown"),c.dropdownClass,o),v(s=h('<div style="scroll-behavior: smooth;">'),c.dropdownContentClass),n.append(s),h(c.dropdownParent||t).appendChild(n),c.controlInput)i=h(c.controlInput);else{i=h('<input type="text" autocomplete="off" />');for(var d=["autocorrect","autocapitalize","autocomplete"],f=0;f<d.length;f++){var g=d[f];p.getAttribute(g)&&i.setAttribute(g,p.getAttribute(g))}}if(c.controlInput||(i.setAttribute("tabindex",p.disabled?"-1":u.tabIndex),e.appendChild(i)),l=p.getAttribute("id")){i.setAttribute("id",l+"-tomselected");var m=document.querySelector("label[for='"+l+"']");m&&m.setAttribute("for",l+"-tomselected")}if(u.settings.copyClassesToDropdown&&v(n,r),t.style.width=p.style.width,u.plugins.names.length&&(a="plugin-"+u.plugins.names.join(" plugin-"),v([t,n],a)),(null===c.maxItems||c.maxItems>1)&&u.is_select_tag&&p.setAttribute("multiple","multiple"),u.settings.placeholder&&i.setAttribute("placeholder",c.placeholder),!u.settings.splitOn&&u.settings.delimiter){var y=u.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");u.settings.splitOn=new RegExp("\\s*"+y+"+\\s*")}u.control=e,u.control_input=i,u.wrapper=t,u.dropdown=n,u.dropdown_content=s,u.control_input.type=p.type,n.addEventListener("mouseenter",(function(t){var e=O(t.target,"[data-selectable]",n);if(e)return u.onOptionHover.call(u,t,e)}),!0),e.addEventListener("mousedown",(function(t){var i=O(t.target,"."+u.settings.itemClass,e);return i?u.onItemSelect.call(u,t,i):u.onMouseDown.call(u,t)})),e.addEventListener("click",(function(){u.onClick.apply(u,arguments)})),i.addEventListener("mousedown",(function(t){t.stopPropagation()})),i.addEventListener("keydown",(function(){return u.onKeyDown.apply(u,arguments)})),i.addEventListener("keyup",(function(){return u.onKeyUp.apply(u,arguments)})),i.addEventListener("keypress",(function(){return u.onKeyPress.apply(u,arguments)})),i.addEventListener("resize",(function(){u.positionDropdown.apply(u,[])})),i.addEventListener("blur",(function(){return u.onBlur.apply(u,arguments)})),i.addEventListener("focus",(function(){return u.ignoreBlur=!1,u.onFocus.apply(u,arguments)})),i.addEventListener("paste",(function(){return u.onPaste.apply(u,arguments)}));var w=function(t){var e=O(t.target,"[data-selectable]",u.dropdown);e||u.wrapper.contains(t.target)?(t.preventDefault(),t.stopPropagation(),e&&u.onOptionSelect(t,e)):u.isFocused&&u.blur(t.target)},b=function(){u.isOpen&&u.positionDropdown.apply(u,arguments)},C=function(){u.ignoreHover=!1};document.addEventListener("mousedown",w),window.addEventListener("sroll",b),window.addEventListener("resize",b),window.addEventListener("mousemove",C),u._destroy=function(){document.removeEventListener("mousedown",w),window.removeEventListener("mousemove",C),window.removeEventListener("sroll",b),window.removeEventListener("resize",b)};for(var A=[];p.children.length>0;)A.push(p.children[0]),p.children[0].remove();this.revertSettings={children:A,tabindex:p.getAttribute("tabindex")},p.setAttribute("tabindex",-1),p.setAttribute("hidden","hidden"),p.insertAdjacentElement("afterend",u.wrapper),u.setValue(c.items),delete c.items,p.addEventListener("invalid",(function(t){t.preventDefault(),u.isInvalid||(u.isInvalid=!0,u.refreshState())})),u.updateOriginalInput(),u.refreshItems(),u.refreshState(),u.isSetup=!0,p.disabled&&u.disable(),u.on("change",this.onChange),v(p,"tomselected"),u.trigger("initialize"),!0===c.preload&&u.onSearchChange("")},n.setupOptions=function(t,e){var i,n;for(e=e||[],i=0,n=(t=t||[]).length;i<n;i++)this.registerOption(t[i]);for(i=0,n=e.length;i<n;i++)this.registerOptionGroup(e[i])},n.setupTemplates=function(){var t=this,e=t.settings.labelField,i=t.settings.optgroupLabelField,n={optgroup:function(t,e){var i=document.createElement("div");return i.className="optgroup",i.appendChild(t.options),i},optgroup_header:function(t,e){return'<div class="optgroup-header">'+e(t[i])+"</div>"},option:function(t,i){return"<div>"+i(t[e])+"</div>"},item:function(t,i){return"<div>"+i(t[e])+"</div>"},option_create:function(t,e){return'<div class="create">Add <strong>'+e(t.input)+"</strong>…</div>"},no_results:function(t,e){return'<div class="no-results">No results found</div>'},loading:function(t,e){return'<div class="spinner"></div>'},dropdown:function(){return'<div style="display:none"></div>'}};t.settings.render=Object.assign({},n,t.settings.render)},n.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)},n.onClick=function(t){var e=this;e.isFocused&&e.isOpen||(e.focus(),t.preventDefault())},n.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(),!1}else window.setTimeout((function(){e.focus()}),0)},n.onChange=function(){f(this.input,"change")},n.onPaste=function(t){var e=this;e.isFull()||e.isInputHidden||e.isLocked?t.preventDefault():e.settings.splitOn&&setTimeout((function(){var t=e.inputValue();if(t.match(e.settings.splitOn))for(var i=t.trim().split(e.settings.splitOn),n=0,s=i.length;n<s;n++)e.createItem(i[n])}),0)},n.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},n.onKeyDown=function(t){var e=this;t.target,e.control_input;if(e.ignoreHover=!0,e.isLocked)9!==t.keyCode&&t.preventDefault();else{switch(t.keyCode){case 65:if(e.isKeyDown(17,t))return void e.selectAll();break;case 27:return void(e.isOpen&&(t.preventDefault(),t.stopPropagation(),e.close()));case 40:if(!e.isOpen&&e.hasOptions)e.open();else if(e.activeOption){var i=e.getAdjacent(e.activeOption,1);i&&e.setActiveOption(i,!0)}return void t.preventDefault();case 38:if(e.activeOption){var n=e.getAdjacent(e.activeOption,-1);n&&e.setActiveOption(n,!0)}return void t.preventDefault();case 13:return void(e.isOpen&&e.activeOption&&(e.onOptionSelect(t,e.activeOption),t.preventDefault()));case 37:return void e.advanceSelection(-1,t);case 39:return void e.advanceSelection(1,t);case 9:return e.settings.selectOnTab&&e.isOpen&&e.activeOption&&(e.onOptionSelect(t,e.activeOption),t.preventDefault()),void(e.settings.create&&e.createItem()&&t.preventDefault());case 8:case 46:return void e.deleteSelection(t)}!e.isInputHidden||e.isKeyDown(17,t)||t.preventDefault()}},n.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))},n.onSearchChange=function(t){var e=this,i=e.settings.load;i&&(e.loadedSearches.hasOwnProperty(t)||(e.loadedSearches[t]=!0,e.load((function(n){i.apply(e,[t,n])}))))},n.onFocus=function(t){void 0===t&&(t=null);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(),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())},n.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(),i.setActiveOption(),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()}},n.onOptionHover=function(t,e){this.ignoreHover||this.setActiveOption(e,!1)},n.onOptionSelect=function(t,e){var i,n=this;e&&(e.parentElement&&e.parentElement.matches("[data-disabled]")||(e.classList.contains("create")?n.createItem(null,!0,(function(){n.settings.closeAfterSelect&&n.close()})):void 0!==(i=e.dataset.value)&&(n.lastQuery=null,n.addItem(i),n.settings.closeAfterSelect?n.close():!n.settings.hideSelected&&t.type&&/mouse/.test(t.type)&&n.setActiveOption(n.getOption(i)))))},n.onItemSelect=function(t,e){var i=this;i.isLocked||"multi"===i.settings.mode&&(t.preventDefault(),i.setActiveItem(e,t))},n.load=function(t){var e=this;v(e.wrapper,e.settings.loadingClass),e.loading++,t.call(e,(function(t,i){e.loading=Math.max(e.loading-1,0),e.lastQuery=null,e.setupOptions(t,i),e.refreshOptions(e.isFocused&&!e.isInputHidden),e.loading||m(e.wrapper,e.settings.loadingClass),e.trigger("load",t)}))},n.loadDebounce=function(t,e){var i;return function(){var n=this,s=arguments;i&&(n.loading=Math.max(n.loading-1,0)),window.clearTimeout(i),i=window.setTimeout((function(){i=null,t.apply(n,s)}),e)}},n.setTextboxValue=function(t){var e=this.control_input;e.value!==t&&(e.value=t,f(e,"update"),this.lastValue=t)},n.getValue=function(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)},n.setValue=function(t,e){void 0===e&&(e=!1),p(this,e?[]:["change"],(function(){this.clear(e),this.addItems(t,e)}))},n.setActiveItem=function(t,e){var i,n,s,o,r,a;if(void 0===t&&(t=null),void 0===e&&(e=null),"single"!==this.settings.mode){if(!t)return m(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(),(s=Array.prototype.indexOf.call(this.control.children,a))>(o=Array.prototype.indexOf.call(this.control.children,t))&&(r=s,s=o,o=r),n=s;n<=o;n++)t=this.control.children[n],-1===this.activeItems.indexOf(t)&&this.setActiveItemClass(t);e.preventDefault()}else"mousedown"===i&&this.isKeyDown(17,e)||"keydown"===i&&this.isKeyDown(16,e)?t.classList.contains("active")?this.removeActiveItem(t):this.setActiveItemClass(t):(m(this.activeItems,"active"),this.activeItems=[],this.setActiveItemClass(t));this.hideInput(),this.isFocused||this.focus()}},n.setActiveItemClass=function(t){var e=this.control.querySelector(".last-active");e&&m(e,"last-active"),v(t,"active last-active"),-1==this.activeItems.indexOf(t)&&this.activeItems.push(t)},n.removeActiveItem=function(t){var e=this.activeItems.indexOf(t);this.activeItems.splice(e,1),m(t,"active")},n.setActiveOption=function(t,e){var i,n,s;if(void 0===t&&(t=null),void 0===e&&(e=!1),t!==this.activeOption&&(this.activeOption&&m(this.activeOption,"active"),this.activeOption=null,t&&(this.activeOption=t,v(t,"active"),e))){i=this.dropdown_content.clientHeight;var o=this.dropdown_content.scrollTop||0;n=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+o)+n>i+o?this.dropdown_content.scrollTop=s-i+n:s<o&&(this.dropdown_content.scrollTop=s)}},n.selectAll=function(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(v(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())},n.hideInput=function(){this.settings.controlInput||(this.setTextboxValue(""),g(this.control_input,{opacity:0,position:"absolute",left:(this.rtl?1e4:-1e4)+"px"}),this.isInputHidden=!0)},n.showInput=function(){this.settings.controlInput||(g(this.control_input,{opacity:1,position:"relative",left:0}),this.isInputHidden=!1)},n.inputValue=function(){return this.control_input.value.trim()},n.focus=function(){var t=this;t.isDisabled||(t.ignoreFocus=!0,t.control_input.focus(),window.setTimeout((function(){t.ignoreFocus=!1,t.onFocus()}),0))},n.blur=function(t){void 0===t&&(t=null),this.control_input.blur(),this.onBlur(null,t)},n.getScoreFunction=function(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())},n.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}},n.search=function(t){var e,i,n,s=this,o=s.settings,r=this.getSearchOptions();if(o.score&&"function"!=typeof(n=s.settings.score.call(this,t)))throw new Error('Tom Select "score" setting must be a function that returns a function');if(t!==s.lastQuery?(s.lastQuery=t,i=s.sifter.search(t,Object.assign(r,{score:n})),s.currentResults=i):i=Object.assign({},s.currentResults),o.hideSelected)for(e=i.items.length-1;e>=0;e--)-1!==s.items.indexOf(u(i.items[e].id))&&i.items.splice(e,1);return i},n.refreshOptions=function(t){var e,i,n,s,o,r,l,c,p,d,h,f,g;void 0===t&&(t=!0);var y,w=this,O=w.inputValue(),b=w.search(O),C=w.activeOption&&u(w.activeOption.dataset.value),A=!1;for(s=b.items.length,"number"==typeof w.settings.maxOptions&&(s=Math.min(s,w.settings.maxOptions)),s>0&&(A=!0),o={},r=[],e=0;e<s;e++){var I=w.options[b.items[e].id],_=u(I[w.settings.valueField]),S=w.getOption(_);for(S||(S=w.render("option",I)),l=I[w.settings.optgroupField]||"",i=0,n=(c=Array.isArray(l)?l:[l])&&c.length;i<n;i++)l=c[i],w.optgroups.hasOwnProperty(l)||(l=""),o.hasOwnProperty(l)||(o[l]=document.createDocumentFragment(),r.push(l)),i>0&&m(S=S.cloneNode(!0),"active"),o[l].appendChild(S)}for(this.settings.lockOptgroupOrder&&r.sort((function(t,e){return(w.optgroups[t].$order||0)-(w.optgroups[e].$order||0)})),p=document.createDocumentFragment(),e=0,s=r.length;e<s;e++)if(l=r[e],w.optgroups.hasOwnProperty(l)&&o[l].children.length){var x=document.createDocumentFragment();x.appendChild(w.render("optgroup_header",w.optgroups[l])),x.appendChild(o[l]);var F=w.render("optgroup",{group:w.optgroups[l],options:x});p.appendChild(F)}else p.appendChild(o[l]);if(w.dropdown_content.innerHTML="",w.dropdown_content.appendChild(p),w.settings.highlight&&(w.dropdown_content,y=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(y,(function(t,e){var i=t.parentNode;i.replaceChild(t.firstChild,t),i.normalize()})),b.query.length&&b.tokens.length))for(e=0,s=b.tokens.length;e<s;e++)a(w.dropdown_content,b.tokens[e].regex);if(!w.settings.hideSelected)for(e=0,s=w.items.length;e<s;e++){var k=w.getOption(w.items[e]);k&&v(k,"selected")}var L=function(t){A=!0;var e=w.render(t,{input:O});return w.dropdown_content.insertBefore(e,w.dropdown_content.firstChild),e};if(w.loading?L("loading"):0===b.items.length&&w.settings.render.no_results&&O.length&&L("no_results"),(d=w.canCreate(O))&&(g=L("option_create")),w.hasOptions=b.items.length>0||d,A){if(b.items.length>0)if((f=C&&w.getOption(C))&&w.dropdown_content.contains(f))h=f;else if("single"===w.settings.mode&&w.items.length)h=w.getOption(w.items[0]);else{var E=0;g&&!w.settings.addPrecedence&&(E=1),h=w.selectable()[E]}else h=g;w.setActiveOption(h),t&&!w.isOpen&&w.open()}else w.setActiveOption(),t&&w.isOpen&&w.close()},n.selectable=function(){return this.dropdown_content.querySelectorAll("[data-selectable]")},n.addOption=function(t){var e,i,n,s=this;if(Array.isArray(t))for(e=0,i=t.length;e<i;e++)s.addOption(t[e]);else(n=s.registerOption(t))&&(s.userOptions[n]=!0,s.lastQuery=null,s.trigger("option_add",n,t))},n.registerOption=function(t){var e=u(t[this.settings.valueField]);return null!=e&&!this.options.hasOwnProperty(e)&&(t.$order=t.$order||++this.order,this.options[e]=t,e)},n.registerOptionGroup=function(t){var e=u(t[this.settings.optgroupValueField]);return!!e&&(t.$order=t.$order||++this.order,this.optgroups[e]=t,e)},n.addOptionGroup=function(t,e){var i;e[this.settings.optgroupValueField]=t,(i=this.registerOptionGroup(e))&&this.trigger("optgroup_add",i,e)},n.removeOptionGroup=function(t){this.optgroups.hasOwnProperty(t)&&(delete this.optgroups[t],this.clearCache(),this.trigger("optgroup_remove",t))},n.clearOptionGroups=function(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")},n.updateOption=function(t,e){var i,n,s,o,r,a,l,c=this;if(t=u(t),s=u(e[c.settings.valueField]),null!==t&&c.options.hasOwnProperty(t)){if("string"!=typeof s)throw new Error("Value must be set in option data");l=c.options[t].$order,s!==t&&(delete c.options[t],-1!==(o=c.items.indexOf(t))&&c.items.splice(o,1,s)),e.$order=e.$order||l,c.options[s]=e,r=c.renderCache.item,a=c.renderCache.option,r&&(delete r[t],delete r[s]),a&&(delete a[t],delete a[s]),-1!==c.items.indexOf(s)&&(i=c.getItem(t),n=c.render("item",e),i.classList.contains("active")&&v(n,"active"),i.parentNode.insertBefore(n,i),i.remove()),c.lastQuery=null,c.isOpen&&c.refreshOptions(!1)}},n.removeOption=function(t,e){var i=this;t=u(t);var n=i.renderCache.item,s=i.renderCache.option;n&&delete n[t],s&&delete s[t],delete i.userOptions[t],delete i.options[t],i.lastQuery=null,i.trigger("option_remove",t),i.removeItem(t,e)},n.clearOptions=function(){this.loadedSearches={},this.userOptions={},this.clearCache();var t={};for(var e in this.options)this.options.hasOwnProperty(e)&&this.items.indexOf(e)>=0&&(t[e]=this.options[e]);this.options=this.sifter.items=t,this.lastQuery=null,this.trigger("option_clear")},n.getOption=function(t){return this.renderCache.option.hasOwnProperty(t)?this.renderCache.option[t]:this.getElementWithValue(t,this.selectable())},n.getAdjacent=function(t,e,i){if(void 0===i&&(i="option"),t){var n=this,s=n.settings.optionClass,o=n.dropdown;"item"==i&&(o=n.control,s=n.settings.itemClass);for(var r=o.querySelectorAll("."+s),a=0;a<r.length;a++)if(r[a]==t)return e>0?r[a+1]:r[a-1]}},n.getElementWithValue=function(t,e){if(null!=(t=u(t)))for(var i=0,n=e.length;i<n;i++)if(e[i].getAttribute("data-value")===t)return e[i]},n.getItem=function(t){return this.getElementWithValue(t,this.control.children)},n.addItems=function(t,e){void 0===e&&(e=!1),this.buffer=document.createDocumentFragment();for(var i=this.control.children,n=0;n<i.length;n++)this.buffer.appendChild(i[n]);for(var s=Array.isArray(t)?t:[t],o=0,r=s.length;o<r;o++)this.isPending=o<r-1,this.addItem(s[o],e);var a=this.control;a.insertBefore(this.buffer,a.firstChild),this.buffer=null},n.addItem=function(t,e){void 0===e&&(e=!1),p(this,e?[]:["change"],(function(){var i,n,s=this,o=s.settings.mode;if(t=u(t),(-1===s.items.indexOf(t)||("single"===o&&s.close(),"single"!==o&&s.settings.duplicates))&&s.options.hasOwnProperty(t)&&("single"===o&&s.clear(e),("multi"!==o||!s.isFull())&&(i=s.render("item",s.options[t]),this.control.contains(i)&&(i=i.cloneNode(!0)),n=s.isFull(),s.items.splice(s.caretPos,0,t),s.insertAtCaret(i),(!s.isPending||!n&&s.isFull())&&s.refreshState(),s.isSetup))){var r=s.selectable();if(!s.isPending){var a=s.getOption(t),l=s.getAdjacent(a,1);s.refreshOptions(s.isFocused&&"single"!==o),l&&s.setActiveOption(l)}!r.length||s.isFull()?s.close():s.isPending||s.positionDropdown(),s.trigger("item_add",t,i),s.isPending||s.updateOriginalInput({silent:e})}}))},n.removeItem=function(t,e){var i,n;void 0===e&&(e=!1);var s=this.getItem(t);s&&(t=u(s.dataset.value),-1!==(i=this.items.indexOf(t))&&(s.remove(),s.classList.contains("active")&&(n=this.activeItems.indexOf(s),this.activeItems.splice(n,1),m(s,"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,s)))},n.createItem=function(t,e,i){void 0===t&&(t=null),void 0===e&&(e=!0),void 0===i&&(i=null);var n,s=this,o=s.caretPos;if(t=t||s.inputValue(),"function"!=typeof i&&(i=function(){}),!s.canCreate(t))return i(),!1;s.lock();var r=!1,a=function(t){if(s.unlock(),!t||"object"!=typeof t)return i();var n=u(t[s.settings.valueField]);if("string"!=typeof n)return i();s.setTextboxValue(""),s.addOption(t),s.setCaret(o),s.addItem(n),s.refreshOptions(e&&"single"!==s.settings.mode),i(t),r=!0};return"function"==typeof s.settings.create?n=s.settings.create.apply(this,[t,a]):((n={})[s.settings.labelField]=t,n[s.settings.valueField]=t),r||a(n),!0},n.refreshItems=function(){this.lastQuery=null,this.isSetup&&this.addItems(this.items),this.refreshState(),this.updateOriginalInput()},n.refreshState=function(){var t=this;t.refreshValidityState();var e=t.isFull(),i=t.isLocked;t.wrapper.classList.toggle("rtl",t.rtl);var n,s=t.control.classList;s.toggle("focus",t.isFocused),s.toggle("disabled",t.isDisabled),s.toggle("required",t.isRequired),s.toggle("invalid",t.isInvalid),s.toggle("locked",i),s.toggle("full",e),s.toggle("not-full",!e),s.toggle("input-active",t.isFocused&&!t.isInputHidden),s.toggle("dropdown-active",t.isOpen),s.toggle("has-options",(n=t.options,0===Object.keys(n).length)),s.toggle("has-items",t.items.length>0)},n.refreshValidityState=function(){if(this.input.checkValidity){var t=!this.input.checkValidity();this.isInvalid=t,this.control_input.required=t,this.input.required=!t}},n.isFull=function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},n.updateOriginalInput=function(t){var e,i,n,s,o=this;if(t=t||{},o.is_select_tag){for(n=[],e=0,i=o.items.length;e<i;e++)s=o.options[o.items[e]][o.settings.labelField]||"",n.push('<option value="'+c(o.items[e])+'" selected="selected">'+c(s)+"</option>");n.length||this.input.hasAttribute("multiple")||n.push('<option value="" selected="selected"></option>'),o.input.innerHTML=n.join("")}else o.input.value=o.getValue(),o.input.setAttribute("value",o.input.value);o.isSetup&&(t.silent||o.trigger("change",o.input.value))},n.open=function(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.focus(),t.isOpen=!0,t.refreshState(),g(t.dropdown,{visibility:"hidden",display:"block"}),t.positionDropdown(),g(t.dropdown,{visibility:"visible",display:"block"}),t.trigger("dropdown_open",t.dropdown))},n.close=function(){var t=this,e=t.isOpen;"single"===t.settings.mode&&t.items.length&&(t.hideInput(),t.isBlurring||t.blur()),t.isOpen=!1,g(t.dropdown,{display:"none"}),t.setActiveOption(),t.refreshState(),e&&t.trigger("dropdown_close",t.dropdown)},n.positionDropdown=function(){if("body"===this.settings.dropdownParent){var t=this.control,e=t.getBoundingClientRect(),i=t.offsetHeight+e.top+window.scrollY,n=e.left+window.scrollX;g(this.dropdown,{width:e.width+"px",top:i+"px",left:n+"px"})}},n.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(),this.updateOriginalInput({silent:t}),this.refreshState(),this.showInput(),this.trigger("clear")}},n.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)},n.deleteSelection=function(t){var e,i,n,s,o,r,a,l=this;if(n=t&&8===t.keyCode?-1:1,s={start:(a=l.control_input).selectionStart,length:a.selectionEnd-a.selectionStart},o=[],l.activeItems.length){for(r=C(b(l.activeItems,n)),n>0&&r++,e=0,i=l.activeItems.length;e<i;e++)o.push(l.activeItems[e].dataset.value);t&&(t.preventDefault(),t.stopPropagation())}else(l.isFocused||"single"===l.settings.mode)&&l.items.length&&(n<0&&0===s.start&&0===s.length?o.push(l.items[l.caretPos-1]):n>0&&s.start===l.inputValue().length&&o.push(l.items[l.caretPos]));if(!o.length||"function"==typeof l.settings.onDelete&&!1===l.settings.onDelete.apply(l,[o,t]))return!1;for(void 0!==r&&l.setCaret(r);o.length;)l.removeItem(o.pop());return l.showInput(),l.positionDropdown(),l.refreshOptions(!1),!0},n.advanceSelection=function(t,e){var i,n;if(0!==t)if(this.rtl&&(t*=-1),this.isKeyDown(17,e)||this.isKeyDown(16,e)){n=this.getLastActive(t);var s=this.getAdjacent(n,t,"item");s&&(s.classList.contains("active")&&this.removeActiveItem(n),this.setActiveItemClass(s))}else this.isFocused&&!this.isInputHidden?this.inputValue().length||this.setCaret(this.caretPos+t):(n=this.getLastActive(t))&&(i=C(n),this.setCaret(t>0?i+1:i),this.setActiveItem())},n.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)},n.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){var i,n,s=this.controlChildren(),o=s.length;for(i=0;i<o;i++)n=s[i],i<t?e.control_input.insertAdjacentElement("beforebegin",n):e.control.appendChild(n)}e.caretPos=t},n.controlChildren=function(){return Array.prototype.filter.call(this.control.children,(function(t){return"INPUT"!==t.nodeName}))},n.lock=function(){this.close(),this.isLocked=!0,this.refreshState()},n.unlock=function(){this.isLocked=!1,this.refreshState()},n.disable=function(){this.input.disabled=!0,this.control_input.disabled=!0,this.control_input.tabIndex=-1,this.isDisabled=!0,this.lock()},n.enable=function(){this.input.disabled=!1,this.control_input.disabled=!1,this.control_input.tabIndex=this.tabIndex,this.isDisabled=!1,this.unlock()},n.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"),m(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},n.render=function(t,e){var i,n,s;void 0===e&&(e=null);var o=this;return"option"!==t&&"item"!==t||(i=u(e[o.settings.valueField]),!o.renderCache[t].hasOwnProperty(i))?(s=h(o.settings.render[t].apply(this,[e,c])),"option"===t||"option_create"===t?e[o.settings.disabledField]||s.setAttribute("data-selectable",""):"optgroup"===t&&(n=e.group[o.settings.optgroupValueField],s.setAttribute("data-group",n),e.group[o.settings.disabledField]&&s.setAttribute("data-disabled","")),"option"!==t&&"item"!==t||(s.setAttribute("data-value",i),v(s,"item"===t?o.settings.itemClass:o.settings.optionClass),o.renderCache[t][i]=s),s):o.renderCache[t][i]},n.clearCache=function(t){void 0===t&&(t=null);null===t?this.renderCache={item:{},option:{}}:this.renderCache[t]={}},n.canCreate=function(t){if(!this.settings.create)return!1;var e=this.settings.createFilter;return t.length&&("function"!=typeof e||e.call(this,t))&&(!(e instanceof RegExp)||e.test(t))},n.isKeyDown=function(t,e){return!!e&&(!e.altKey&&((!e.ctrlKey||!e.shiftKey)&&(!(17!=t||!e.ctrlKey)||!(16!=t||!e.shiftKey))))},n.hook=function(t,e,i){var n=this,s=n[e];n[e]=function(){var e,o;return"after"===t&&(e=s.apply(n,arguments)),o=i.apply(n,arguments),"instead"===t?o:("before"===t&&(e=s.apply(n,arguments)),e)}},i}(((A=e).plugins={},function(e){function i(){return e.apply(this,arguments)||this}t(i,e),i.define=function(t,e){A.plugins[t]={name:t,fn:e}};var n=i.prototype;return n.initializePlugins=function(t){var e,i,n,s=this,o=[];if(s.plugins={names:[],settings:{},requested:{},loaded:{}},Array.isArray(t))for(e=0,i=t.length;e<i;e++)"string"==typeof t[e]?o.push(t[e]):(s.plugins.settings[t[e].name]=t[e].options,o.push(t[e].name));else if(t)for(n in t)t.hasOwnProperty(n)&&(s.plugins.settings[n]=t[n],o.push(n));for(;o.length;)s.require(o.shift())},n.loadPlugin=function(t){var e=this,i=e.plugins,n=A.plugins[t];if(!A.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');i.requested[t]=!0,i.loaded[t]=n.fn.apply(e,[e.plugins.settings[t]||{}]),i.names.push(t)},n.require=function(t){var e=this,i=e.plugins;if(!e.plugins.loaded.hasOwnProperty(t)){if(i.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")');e.loadPlugin(t)}return i.loaded[t]},i}(A)));return I.define("change_listener",(function(t){var e=this,i=!1;e.input.addEventListener("change",(function(){if(i)i=!1;else{i=!0;var t=d(e.input,{});e.setupOptions(t.options,t.optgroups),e.setValue(t.items)}}))})),I.define("drag_drop",(function(t){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');if("multi"===this.settings.mode){var e=this,i=e.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 t=$(e.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:e.isLocked,start:function(e,i){i.placeholder.css("width",i.helper.css("width")),t.css({overflow:"visible"})},stop:function(){t.css({overflow:"hidden"});var i=[];t.children("[data-value]").each((function(){i.push($(this).attr("data-value"))})),e.setValue(i)}})}))}})),I.define("dropdown_header",(function(t){var e=this;t=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+'">×</a></div></div>'}},t),e.hook("after","setup",(function(){var i=h(t.html(t));e.dropdown.insertBefore(i,e.dropdown.firstChild)}))})),I.define("input_autogrow",(function(t){var e=this;e.hook("after","setup",(function(){var t=document.createElement("span"),i=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",e.wrapper.appendChild(t);for(var n=["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"],s=0,o=n.length;s<o;s++){var r=n[s];t.style[r]=i.style[r]}var a=function(){t.textContent=i.value,i.style.width=t.clientWidth+"px"};i.addEventListener("input",a),i.addEventListener("keyup",a),i.addEventListener("blur",a),i.addEventListener("update",a)}))})),I.define("no_backspace_delete",(function(t){this.hook("instead","setActiveItem",(function(){})),this.hook("instead","selectAll",(function(){})),this.hook("instead","deleteSelection",(function(){}))})),I.define("optgroup_columns",(function(t){var e=this,i=e.onKeyDown;e.hook("instead","onKeyDown",(function(t){var n,s,o,r;if(!e.isOpen||37!==t.keyCode&&39!==t.keyCode)return i.apply(e,arguments);e.ignoreHover=!0,r=O(e.activeOption,"[data-group]"),n=C(e.activeOption,"[data-selectable]"),(r=37===t.keyCode?r.previousSibling:r.nextSibling)&&(s=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,n)])&&e.setActiveOption(s)}))})),I.define("remove_button",(function(t){t=Object.assign({label:"×",title:"Remove",className:"remove",append:!0},t);var e=this;if(t.append){var i='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+c(t.title)+'">'+t.label+"</a>";e.hook("after","setupTemplates",(function(){var t=e.settings.render.item;e.settings.render.item=function(){var n=h(t.apply(e,arguments)),s=h(i);return n.appendChild(s),s.addEventListener("mousedown",(function(t){t.preventDefault(),t.stopPropagation()})),s.addEventListener("click",(function(t){if(t.preventDefault(),t.stopPropagation(),"single"!==e.settings.mode&&t.stopPropagation(),!e.isLocked){var i=n.dataset.value;e.removeItem(i),e.refreshOptions(!1)}})),n}}))}})),I.define("restore_on_backspace",(function(t){var e=this;t.text=t.text||function(t){return t[e.settings.labelField]};var i=e.onKeyDown;e.hook("instead","onKeyDown",(function(n){var s,o;return 8===n.keyCode&&""===e.control_input.value&&!e.activeItems.length&&(s=e.caretPos-1)>=0&&s<e.items.length?(o=e.options[e.items[s]],e.deleteSelection(n)&&(e.setTextboxValue(t.text.call(e,o)),e.refreshOptions(!0)),void n.preventDefault()):i.apply(e,arguments)}))})),I}));var tomSelect=function(t,e){return new TomSelect(t,e)}; | ||
//# sourceMappingURL=tom-select.complete.min.js.map |
@@ -82,3 +82,3 @@ | ||
- [tom-select.complete.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.complete.js) — Includes dependencies and plugins | ||
- [tom-select.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.base.js) — Does not include any plugins | ||
- [tom-select.base.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.base.js) — Does not include any plugins | ||
- [CSS](https://github.com/orchidjs/tom-select/tree/master/dist/css) — Compiled themes | ||
@@ -85,0 +85,0 @@ - [SCSS](https://github.com/orchidjs/tom-select/tree/master/dist/scss) — Uncompiled theme sources |
@@ -24,2 +24,5 @@ var fs = require('fs'); | ||
'clean:pre', | ||
'shell:buildjs', | ||
'copy:scss', | ||
@@ -31,4 +34,2 @@ 'copy:scss_plugins', | ||
'replace:css_post', | ||
'shell:buildjs', | ||
]); | ||
@@ -35,0 +36,0 @@ |
@@ -17,3 +17,3 @@ { | ||
"homepage": "https://tom-select.js.org", | ||
"version": "1.0.0-rc.2", | ||
"version": "1.0.0-rc.3", | ||
"author": "Josh Schmidt (https://github.com/oyejorge)", | ||
@@ -37,2 +37,4 @@ "contributors": [ | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"@types/jquery": "^3.5.4", | ||
"@types/jqueryui": "^1.12.13", | ||
"autoprefixer": "^9.8.6", | ||
@@ -75,2 +77,4 @@ "bootstrap": "4.5.2", | ||
"syn": "^0.15.0", | ||
"tslib": "^2.0.3", | ||
"typescript": "^4.0.5", | ||
"yargs": "^16.1.0" | ||
@@ -81,2 +85,3 @@ }, | ||
"test": "karma start", | ||
"test:typescript": "tsc -p .config", | ||
"start": "grunt serve", | ||
@@ -99,3 +104,4 @@ "pretest": "grunt build" | ||
"not Explorer <= 11" | ||
] | ||
], | ||
"dependencies": {} | ||
} |
@@ -59,3 +59,3 @@ <p align="center"> | ||
- [tom-select.complete.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.complete.js) — Includes dependencies and plugins | ||
- [tom-select.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.base.js) — Does not include any plugins | ||
- [tom-select.base.js](https://github.com/orchidjs/tom-select/tree/master/dist/js/tom-select.base.js) — Does not include any plugins | ||
- [CSS](https://github.com/orchidjs/tom-select/tree/master/dist/css) — Compiled themes | ||
@@ -62,0 +62,0 @@ - [SCSS](https://github.com/orchidjs/tom-select/tree/master/dist/scss) — Uncompiled theme sources |
@@ -21,98 +21,103 @@ /** | ||
/** | ||
* Initializes the listed plugins (with options). | ||
* Acceptable formats: | ||
* | ||
* List (without options): | ||
* ['a', 'b', 'c'] | ||
* | ||
* List (with options): | ||
* [{'name': 'a', options: {}}, {'name': 'b', options: {}}] | ||
* | ||
* Hash (with options): | ||
* {'a': { ... }, 'b': { ... }, 'c': { ... }} | ||
* | ||
* @param {mixed} plugins | ||
*/ | ||
Interface.prototype.initializePlugins = function(plugins) { | ||
var i, n, key; | ||
var self = this; | ||
var queue = []; | ||
self.plugins = { | ||
names : [], | ||
settings : {}, | ||
requested : {}, | ||
loaded : {} | ||
}; | ||
return class mixin extends Interface{ | ||
if (Array.isArray(plugins)) { | ||
for (i = 0, n = plugins.length; i < n; i++) { | ||
if (typeof plugins[i] === 'string') { | ||
queue.push(plugins[i]); | ||
} else { | ||
self.plugins.settings[plugins[i].name] = plugins[i].options; | ||
queue.push(plugins[i].name); | ||
/** | ||
* Registers a plugin. | ||
* | ||
* @param {string} name | ||
* @param {function} fn | ||
*/ | ||
static define(name, fn){ | ||
Interface.plugins[name] = { | ||
'name' : name, | ||
'fn' : fn | ||
}; | ||
} | ||
/** | ||
* Initializes the listed plugins (with options). | ||
* Acceptable formats: | ||
* | ||
* List (without options): | ||
* ['a', 'b', 'c'] | ||
* | ||
* List (with options): | ||
* [{'name': 'a', options: {}}, {'name': 'b', options: {}}] | ||
* | ||
* Hash (with options): | ||
* {'a': { ... }, 'b': { ... }, 'c': { ... }} | ||
* | ||
* @param {array|object} plugins | ||
*/ | ||
initializePlugins(plugins) { | ||
var i, n, key; | ||
var self = this; | ||
var queue = []; | ||
self.plugins = { | ||
names : [], | ||
settings : {}, | ||
requested : {}, | ||
loaded : {} | ||
}; | ||
if (Array.isArray(plugins)) { | ||
for (i = 0, n = plugins.length; i < n; i++) { | ||
if (typeof plugins[i] === 'string') { | ||
queue.push(plugins[i]); | ||
} else { | ||
self.plugins.settings[plugins[i].name] = plugins[i].options; | ||
queue.push(plugins[i].name); | ||
} | ||
} | ||
} | ||
} else if (plugins) { | ||
for (key in plugins) { | ||
if (plugins.hasOwnProperty(key)) { | ||
self.plugins.settings[key] = plugins[key]; | ||
queue.push(key); | ||
} else if (plugins) { | ||
for (key in plugins) { | ||
if (plugins.hasOwnProperty(key)) { | ||
self.plugins.settings[key] = plugins[key]; | ||
queue.push(key); | ||
} | ||
} | ||
} | ||
} | ||
while (queue.length) { | ||
self.require(queue.shift()); | ||
while (queue.length) { | ||
self.require(queue.shift()); | ||
} | ||
} | ||
}; | ||
Interface.prototype.loadPlugin = function(name) { | ||
var self = this; | ||
var plugins = self.plugins; | ||
var plugin = Interface.plugins[name]; | ||
loadPlugin(name) { | ||
var self = this; | ||
var plugins = self.plugins; | ||
var plugin = Interface.plugins[name]; | ||
if (!Interface.plugins.hasOwnProperty(name)) { | ||
throw new Error('Unable to find "' + name + '" plugin'); | ||
if (!Interface.plugins.hasOwnProperty(name)) { | ||
throw new Error('Unable to find "' + name + '" plugin'); | ||
} | ||
plugins.requested[name] = true; | ||
plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]); | ||
plugins.names.push(name); | ||
} | ||
plugins.requested[name] = true; | ||
plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]); | ||
plugins.names.push(name); | ||
}; | ||
/** | ||
* Initializes a plugin. | ||
* | ||
* @param {string} name | ||
*/ | ||
require(name) { | ||
var self = this; | ||
var plugins = self.plugins; | ||
/** | ||
* Initializes a plugin. | ||
* | ||
* @param {string} name | ||
*/ | ||
Interface.prototype.require = function(name) { | ||
var self = this; | ||
var plugins = self.plugins; | ||
if (!self.plugins.loaded.hasOwnProperty(name)) { | ||
if (plugins.requested[name]) { | ||
throw new Error('Plugin has circular dependency ("' + name + '")'); | ||
} | ||
self.loadPlugin(name); | ||
} | ||
if (!self.plugins.loaded.hasOwnProperty(name)) { | ||
if (plugins.requested[name]) { | ||
throw new Error('Plugin has circular dependency ("' + name + '")'); | ||
} | ||
self.loadPlugin(name); | ||
return plugins.loaded[name]; | ||
} | ||
return plugins.loaded[name]; | ||
}; | ||
/** | ||
* Registers a plugin. | ||
* | ||
* @param {string} name | ||
* @param {function} fn | ||
*/ | ||
Interface.define = function(name, fn) { | ||
Interface.plugins[name] = { | ||
'name' : name, | ||
'fn' : fn | ||
}; | ||
}; | ||
} |
@@ -190,6 +190,6 @@ /** | ||
* @param {object|string} search | ||
* @param {object} options (optional) | ||
* @param {object} options | ||
* @returns {function} | ||
*/ | ||
getScoreFunction(search, options) { | ||
getScoreFunction(search, options=null ){ | ||
var self, fields, tokens, token_count, nesting; | ||
@@ -208,3 +208,3 @@ | ||
* | ||
* @param {mixed} value | ||
* @param {string} value | ||
* @param {object} token | ||
@@ -302,3 +302,3 @@ * @return {number} | ||
* @param {object} result | ||
* @return {mixed} | ||
* @return {string} | ||
*/ | ||
@@ -305,0 +305,0 @@ get_field = function(name, result) { |
@@ -29,3 +29,3 @@ /** | ||
test_input.style.width = 'auto'; | ||
test_input.style.padding = 0; | ||
test_input.style.padding = '0'; | ||
test_input.style.whiteSpace = 'pre'; | ||
@@ -47,3 +47,2 @@ | ||
* | ||
* @param {string} str | ||
*/ | ||
@@ -50,0 +49,0 @@ var resize = function(){ |
@@ -8,3 +8,3 @@ | ||
import getSettings from './settings.js'; | ||
import { isset, hash_key, escape_html, debounce_events, getSelection} from './utils.js'; | ||
import { hash_key, escape_html, debounce_events, getSelection} from './utils.js'; | ||
import { | ||
@@ -17,3 +17,2 @@ getDom, | ||
castAsArray, | ||
onEvent, | ||
parentMatch, | ||
@@ -26,3 +25,3 @@ querySelectorEnd, | ||
export default class TomSelect extends MicroEvent{ | ||
export default class TomSelect extends MicroPlugin(MicroEvent){ | ||
@@ -40,49 +39,58 @@ constructor( input, settings ){ | ||
input.tomselect = self; | ||
settings = getSettings( input, settings ); | ||
input.tomselect = self; | ||
/** | ||
* @param {HTMLInputElement} control_input | ||
*/ | ||
this.control_input = null; | ||
this.wrapper = null; | ||
this.dropdown = null; | ||
this._destroy = null; | ||
this.control = null; | ||
this.sifter = null; | ||
this.dropdown_content = null; | ||
// detect rtl environment | ||
var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null); | ||
dir = computedStyle.getPropertyValue('direction'); | ||
var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null); | ||
dir = computedStyle.getPropertyValue('direction'); | ||
// 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), | ||
this.order = 0; | ||
this.settings = getSettings( input, settings ); | ||
this.input = input; | ||
this.tabIndex = input.getAttribute('tabindex') || ''; | ||
this.is_select_tag = input.tagName.toLowerCase() === 'select'; | ||
this.rtl = /rtl/i.test(dir); | ||
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 : {}, | ||
this.highlightedValue = null; | ||
this.isBlurring = false; | ||
this.isOpen = false; | ||
this.isDisabled = false; | ||
this.isRequired = input.required; | ||
this.isInvalid = false; | ||
this.isLocked = false; | ||
this.isFocused = false; | ||
this.isInputHidden = false; | ||
this.isSetup = false; | ||
this.ignoreFocus = false; | ||
this.ignoreBlur = false; | ||
this.ignoreHover = false; | ||
this.hasOptions = false; | ||
this.currentResults = null; | ||
this.lastValue = ''; | ||
this.caretPos = 0; | ||
this.loading = 0; | ||
this.loadedSearches = {}; | ||
activeOption : null, | ||
activeItems : [], | ||
this.activeOption = null; | ||
this.activeItems = []; | ||
optgroups : {}, | ||
options : {}, | ||
userOptions : {}, | ||
items : [], | ||
renderCache : {'item':{},'option':{}}, | ||
}); | ||
this.optgroups = {}; | ||
this.options = {}; | ||
this.userOptions = {}; | ||
this.items = []; | ||
this.renderCache = {'item':{},'option':{}}; | ||
// debounce user defined load() if loadThrottle > 0 | ||
@@ -94,3 +102,3 @@ if( self.settings.load && self.settings.loadThrottle ){ | ||
// search system | ||
self.sifter = new Sifter(this.options, {diacritics: settings.diacritics}); | ||
self.sifter = new Sifter(this.options, {diacritics: self.settings.diacritics}); | ||
@@ -129,6 +137,6 @@ self.setupOptions(self.settings.options,self.settings.optgroups); | ||
setup(){ | ||
var self = this; | ||
var settings = self.settings; | ||
var wrapper; | ||
@@ -223,3 +231,2 @@ var control; | ||
control_input.type = input.type; | ||
@@ -232,5 +239,12 @@ self.control = control; | ||
self.control_input.type = input.type; | ||
onEvent(dropdown, 'mouseenter', '[data-selectable]', function() { return self.onOptionHover.apply(self, arguments); }); | ||
dropdown.addEventListener('mouseenter', function(e) { | ||
var target_match = parentMatch(e.target, '[data-selectable]', dropdown); | ||
if( target_match ){ | ||
return self.onOptionHover.call(self, e, target_match ); | ||
} | ||
}, true); | ||
control.addEventListener('mousedown', function(evt){ | ||
@@ -240,4 +254,3 @@ | ||
if( target_match ){ | ||
evt.delegateTarget = target_match; | ||
return self.onItemSelect.call(self, evt); | ||
return self.onItemSelect.call(self, evt, target_match); | ||
} | ||
@@ -247,3 +260,3 @@ return self.onMouseDown.call(self, evt); | ||
control.addEventListener('click', function() { return self.onClick.apply(self, arguments); }); | ||
control.addEventListener('click', function() { self.onClick.apply(self, arguments); }); | ||
@@ -265,4 +278,7 @@ | ||
// if dropdownParent is set, options may not be within self.wrapper | ||
var option = parentMatch(e.target, '[data-selectable]',self.dropdown); | ||
// outside of this instance | ||
if( !self.wrapper.contains(e.target) ){ | ||
if( !option && !self.wrapper.contains(e.target) ){ | ||
if (self.isFocused) { | ||
@@ -277,6 +293,4 @@ self.blur(e.target); | ||
// option | ||
var option = parentMatch(e.target, '[data-selectable]', self.wrapper); | ||
if( option ){ | ||
self.onOptionSelect(option,true); | ||
self.onOptionSelect( e, option ); | ||
} | ||
@@ -459,3 +473,2 @@ }; | ||
* @param {object} e | ||
* @return {boolean} | ||
*/ | ||
@@ -467,4 +480,4 @@ onClick(e) { | ||
// is ignored unless invoked within a click event) | ||
// also necessary to reopen a dropdown that has been closed by | ||
// closeAfterSelect | ||
// also necessary to reopen a dropdown that has been closed by | ||
// closeAfterSelect | ||
if (!self.isFocused || !self.isOpen) { | ||
@@ -496,3 +509,3 @@ self.focus(); | ||
} else { | ||
self.setActiveItem(null); | ||
self.setActiveItem(); | ||
} | ||
@@ -625,3 +638,3 @@ return false; | ||
if (self.isOpen && self.activeOption) { | ||
self.onOptionSelect(self.activeOption); | ||
self.onOptionSelect(e,self.activeOption); | ||
e.preventDefault(); | ||
@@ -644,3 +657,3 @@ } | ||
if (self.settings.selectOnTab && self.isOpen && self.activeOption) { | ||
self.onOptionSelect(self.activeOption); | ||
self.onOptionSelect(e,self.activeOption); | ||
@@ -707,6 +720,6 @@ // prevent default [tab] behaviour of jump to the next field | ||
* | ||
* @param {object} e (optional) | ||
* @param {object} e | ||
* @returns {boolean} | ||
*/ | ||
onFocus(e) { | ||
onFocus( e = null ){ | ||
var self = this; | ||
@@ -729,3 +742,3 @@ var wasFocused = self.isFocused; | ||
self.showInput(); | ||
self.setActiveItem(null); | ||
self.setActiveItem(); | ||
self.refreshOptions(!!self.settings.openOnFocus); | ||
@@ -741,3 +754,3 @@ } | ||
* @param {object} e | ||
* @param {Element} dest | ||
* @param {HTMLElement} dest | ||
*/ | ||
@@ -760,4 +773,4 @@ onBlur(e, dest) { | ||
self.close(); | ||
self.setActiveItem(null); | ||
self.setActiveOption(null); | ||
self.setActiveItem(); | ||
self.setActiveOption(); | ||
self.setCaret(self.items.length); | ||
@@ -785,8 +798,9 @@ self.refreshState(); | ||
* | ||
* @param {object} e | ||
* @param {object} evt | ||
* @param {HTMLElement} option | ||
* @returns {boolean} | ||
*/ | ||
onOptionHover(e) { | ||
onOptionHover( evt, option ){ | ||
if (this.ignoreHover) return; | ||
this.setActiveOption(e.delegateTarget, false); | ||
this.setActiveOption(option, false); | ||
} | ||
@@ -798,10 +812,10 @@ | ||
* | ||
* @param {Element} target | ||
* @param {boolean} is_mouse_event | ||
* @param {object} evt | ||
* @param {HTMLElement} option | ||
* @returns {boolean} | ||
*/ | ||
onOptionSelect(target, is_mouse_event){ | ||
onOptionSelect( evt, option ){ | ||
var value, self = this; | ||
if( !target ){ | ||
if( !option ){ | ||
return; | ||
@@ -811,3 +825,3 @@ } | ||
// should not be possible to trigger a option under a disabled optgroup | ||
if( target.parentNode && target.parentNode.matches('[data-disabled]') ){ | ||
if( option.parentElement && option.parentElement.matches('[data-disabled]') ){ | ||
return; | ||
@@ -817,4 +831,4 @@ } | ||
if( target.classList.contains('create') ){ | ||
self.createItem(null, function() { | ||
if( option.classList.contains('create') ){ | ||
self.createItem(null, true, function() { | ||
if (self.settings.closeAfterSelect) { | ||
@@ -825,3 +839,3 @@ self.close(); | ||
} else { | ||
value = target.dataset.value; | ||
value = option.dataset.value; | ||
if (typeof value !== 'undefined') { | ||
@@ -832,3 +846,3 @@ self.lastQuery = null; | ||
self.close(); | ||
} else if (!self.settings.hideSelected && is_mouse_event ) { | ||
} else if (!self.settings.hideSelected && evt.type && /mouse/.test(evt.type)) { | ||
self.setActiveOption(self.getOption(value)); | ||
@@ -845,6 +859,7 @@ } | ||
* | ||
* @param {object} e | ||
* @param {object} evt | ||
* @param {HTMLElement} item | ||
* @returns {boolean} | ||
*/ | ||
onItemSelect(e) { | ||
onItemSelect( evt, item ){ | ||
var self = this; | ||
@@ -854,4 +869,4 @@ | ||
if (self.settings.mode === 'multi') { | ||
e.preventDefault(); | ||
self.setActiveItem(e.delegateTarget, e); | ||
evt.preventDefault(); | ||
self.setActiveItem(item, evt); | ||
} | ||
@@ -931,3 +946,3 @@ } | ||
* | ||
* @returns {mixed} | ||
* @returns {string|array} | ||
*/ | ||
@@ -945,5 +960,6 @@ getValue() { | ||
* | ||
* @param {mixed} value | ||
* @param {string|array} value | ||
* @param {boolean} silent | ||
*/ | ||
setValue(value, silent) { | ||
setValue( value, silent=false ){ | ||
var events = silent ? [] : ['change']; | ||
@@ -960,11 +976,9 @@ | ||
* | ||
* @param {object} item | ||
* @param {object} e (optional) | ||
* @param {HTMLElement} item | ||
* @param {object} e | ||
*/ | ||
setActiveItem( item, e) { | ||
setActiveItem( item=null, e=null ){ | ||
var self = this; | ||
var eventName; | ||
var i, begin, end, item, swap; | ||
var i, begin, end, swap; | ||
var last; | ||
@@ -1056,3 +1070,3 @@ | ||
*/ | ||
setActiveOption(option, scroll ) { | ||
setActiveOption( option=null, scroll=false ){ | ||
var height_menu, height_item, y; | ||
@@ -1072,14 +1086,14 @@ | ||
if (scroll || !isset(scroll)) { | ||
if( scroll ){ | ||
height_menu = this.dropdown_content.clientHeight; | ||
scroll = this.dropdown_content.scrollTop || 0; | ||
let scrollTop = this.dropdown_content.scrollTop || 0; | ||
height_item = this.activeOption.offsetHeight; | ||
y = this.activeOption.getBoundingClientRect().top - this.dropdown_content.getBoundingClientRect().top + scroll; | ||
y = this.activeOption.getBoundingClientRect().top - this.dropdown_content.getBoundingClientRect().top + scrollTop; | ||
if (y + height_item > height_menu + scroll) { | ||
if (y + height_item > height_menu + scrollTop) { | ||
this.dropdown_content.scrollTop = y - height_menu + height_item; | ||
} else if (y < scroll) { | ||
} else if (y < scrollTop) { | ||
this.dropdown_content.scrollTop = y; | ||
@@ -1159,5 +1173,5 @@ } | ||
* | ||
* @param {Element} dest | ||
* @param {HTMLElement} dest | ||
*/ | ||
blur(dest) { | ||
blur(dest = null) { | ||
this.control_input.blur(); | ||
@@ -1174,3 +1188,2 @@ | ||
* @param {string} query | ||
* @param {object} options | ||
* @return {function} | ||
@@ -1259,12 +1272,6 @@ */ | ||
*/ | ||
refreshOptions(triggerDropdown) { | ||
refreshOptions( triggerDropdown = true ){ | ||
var i, j, k, n, groups, groups_order, optgroup, optgroups, html, has_create_option; | ||
var active, active_before, create; | ||
if (typeof triggerDropdown === 'undefined') { | ||
triggerDropdown = true; | ||
} | ||
var self = this; | ||
@@ -1432,3 +1439,3 @@ var query = self.inputValue(); | ||
}else{ | ||
self.setActiveOption(null); | ||
self.setActiveOption(); | ||
if( triggerDropdown && self.isOpen ){ self.close(); } | ||
@@ -1514,5 +1521,7 @@ } | ||
addOptionGroup(id, data) { | ||
var hashed_id; | ||
data[this.settings.optgroupValueField] = id; | ||
if (id = this.registerOptionGroup(data)) { | ||
this.trigger('optgroup_add', id, data); | ||
if( hashed_id = this.registerOptionGroup(data) ){ | ||
this.trigger('optgroup_add', hashed_id, data); | ||
} | ||
@@ -1674,3 +1683,3 @@ } | ||
* @param {object} option | ||
* @param {int} direction can be 1 for next or -1 for previous | ||
* @param {number} direction can be 1 for next or -1 for previous | ||
* @param {string} type | ||
@@ -1712,3 +1721,3 @@ * @return {object|undefined} | ||
* | ||
* @param {mixed} value | ||
* @param {string} value | ||
* @param {object} els | ||
@@ -1744,10 +1753,10 @@ * @return {object} | ||
* | ||
* @param {string} value | ||
* @param {string|array} values | ||
* @param {boolean} silent | ||
*/ | ||
addItems(values, silent) { | ||
addItems( values, silent = false ){ | ||
this.buffer = document.createDocumentFragment(); | ||
var children = this.control.children; | ||
for (var i = 0; i < children.length; i++) { | ||
for (let i = 0; i < children.length; i++) { | ||
this.buffer.appendChild(children[i]); | ||
@@ -1757,3 +1766,3 @@ } | ||
var items = Array.isArray(values) ? values : [values]; | ||
for (var i = 0, n = items.length; i < n; i++) { | ||
for (let i = 0, n = items.length; i < n; i++) { | ||
this.isPending = (i < n - 1); | ||
@@ -1776,3 +1785,3 @@ this.addItem(items[i], silent); | ||
*/ | ||
addItem(value, silent) { | ||
addItem( value, silent = false ){ | ||
var events = silent ? [] : ['change']; | ||
@@ -1849,4 +1858,5 @@ | ||
* @param {string} value | ||
* @param {boolean} silent | ||
*/ | ||
removeItem(value, silent) { | ||
removeItem( value, silent = false ){ | ||
var i, idx; | ||
@@ -1894,8 +1904,8 @@ | ||
* | ||
* @param {string} value | ||
* @param {boolean} [triggerDropdown] | ||
* @param {function} [callback] | ||
* @param {string} input | ||
* @param {boolean} triggerDropdown | ||
* @param {function} callback | ||
* @return {boolean} | ||
*/ | ||
createItem(input, triggerDropdown) { | ||
createItem( input=null, triggerDropdown=true, callback=null ){ | ||
var self = this; | ||
@@ -1906,9 +1916,4 @@ var caret = self.caretPos; | ||
var callback = arguments[arguments.length - 1]; | ||
if (typeof callback !== 'function') callback = function() {}; | ||
if (typeof triggerDropdown !== 'boolean') { | ||
triggerDropdown = true; | ||
} | ||
if (!self.canCreate(input)) { | ||
@@ -1962,3 +1967,3 @@ callback(); | ||
if (this.isSetup) { | ||
this.addItem(this.items); | ||
this.addItems(this.items); | ||
} | ||
@@ -2100,3 +2105,3 @@ | ||
applyCSS(self.dropdown,{display: 'none'}); | ||
self.setActiveOption(null); | ||
self.setActiveOption(); | ||
self.refreshState(); | ||
@@ -2150,3 +2155,3 @@ | ||
this.setCaret(0); | ||
this.setActiveItem(null); | ||
this.setActiveItem(); | ||
this.updateOriginalInput({silent: silent}); | ||
@@ -2242,3 +2247,3 @@ this.refreshState(); | ||
* | ||
* @param {int} direction | ||
* @param {number} direction | ||
* @param {object} e (optional) | ||
@@ -2279,3 +2284,3 @@ */ | ||
this.setCaret(direction > 0 ? idx + 1: idx); | ||
this.setActiveItem(null); | ||
this.setActiveItem(); | ||
} | ||
@@ -2303,3 +2308,3 @@ } | ||
* | ||
* @param {int} i | ||
* @param {number} i | ||
*/ | ||
@@ -2425,7 +2430,6 @@ setCaret(i) { | ||
* @param {object} data | ||
* @returns {Element} | ||
* @returns {HTMLElement} | ||
*/ | ||
render(templateName, data) { | ||
var value, id, label; | ||
var html = ''; | ||
render( templateName, data = null ){ | ||
var value, id, label, html; | ||
var self = this; | ||
@@ -2487,5 +2491,5 @@ var regex_tag = /^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i; | ||
*/ | ||
clearCache(templateName) { | ||
clearCache( templateName = null ){ | ||
var self = this; | ||
if (typeof templateName === 'undefined') { | ||
if( templateName === null ){ | ||
self.renderCache = {'item':{},'option':{}}; | ||
@@ -2585,3 +2589,1 @@ } else { | ||
}; | ||
MicroPlugin(TomSelect); |
@@ -1,11 +0,3 @@ | ||
/** | ||
* Determines if the provided value has been defined. | ||
* | ||
* @param {mixed} object | ||
* @returns {boolean} | ||
*/ | ||
export function isset(object) { | ||
return typeof object !== 'undefined'; | ||
}; | ||
/** | ||
@@ -12,0 +4,0 @@ * Converts a scalar to its best string representation |
@@ -6,4 +6,4 @@ | ||
* | ||
* @param {mixed} query | ||
* @return {Element} | ||
* @param {any} query .. should be {HTMLElement|string|JQuery} | ||
* @return {HTMLElement} | ||
*/ | ||
@@ -23,3 +23,3 @@ export function getDom( query ){ | ||
div.innerHTML = query.trim(); // Never return a text node of whitespace as the result | ||
return div.firstChild; | ||
return div.querySelector(':first-child'); | ||
} | ||
@@ -110,27 +110,3 @@ | ||
/** | ||
* Delegate Event | ||
* | ||
*/ | ||
export function onEvent( el, eventName, elementSelector, handler ){ | ||
let event_names = eventName.split(/\s/); | ||
// create intermediate handler that can be used for all event names | ||
// loop parent nodes from the target to the delegation node | ||
let _handler = function(e) { | ||
var target_match = parentMatch(e.target, elementSelector, el); | ||
if( target_match ){ | ||
e.delegateTarget = target_match; | ||
handler.call(target_match, e); | ||
} | ||
}; | ||
for( let i = 0; i<event_names.length; i++){ | ||
el.addEventListener(event_names[i], _handler, true); | ||
} | ||
}; | ||
/** | ||
@@ -137,0 +113,0 @@ * Get the closest node to the evt.target matching the selector |
@@ -9,5 +9,3 @@ | ||
// currently fails on IOS 10 + FFox 82 | ||
if( process.env.TRAVIS_CI && process.env.TARGET === 'browserstack' ){ | ||
this.skip(); | ||
} | ||
this.skip(); | ||
@@ -14,0 +12,0 @@ import('/base/src/tom-select.complete.js').then(function(SelectModule){ |
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 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 not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2303461
135
29945
50