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

tom-select

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tom-select - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

2

dist/esm/constants.js
/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -157,3 +157,3 @@ */

addClasses(dropdown, settings.dropdownClass, inputMode);
dropdown_content = getDom(`<div style="scroll-behavior: smooth;" role="listbox" id="${listboxId}">`);
dropdown_content = getDom(`<div style="scroll-behavior: smooth;" role="listbox" id="${listboxId}" tabindex="-1">`);
addClasses(dropdown_content, settings.dropdownContentClass);

@@ -737,5 +737,3 @@ dropdown.append(dropdown_content);

self.setActiveItem();
self.clearActiveOption();
self.setCaret(self.items.length);
self.refreshState();
self.trigger('blur');

@@ -858,3 +856,3 @@ };

setTextboxValue(value) {
setTextboxValue(value = '') {
var input = this.control_input;

@@ -1088,3 +1086,3 @@ var changed = input.value !== value;

if (self.activeItems.length > 0 || !self.isFocused && this.settings.hidePlaceholder && self.items.length > 0) {
self.setTextboxValue('');
self.setTextboxValue();
self.isInputHidden = true;

@@ -1636,2 +1634,6 @@ addClasses(self.wrapper, 'input-hidden');

getAdjacent(option, direction, type = 'option') {
var self = this,
class_type,
sibling = option;
if (!option) {

@@ -1641,24 +1643,19 @@ return;

var self = this;
var type_class = self.settings.optionClass;
var parent = self.dropdown;
if (type == 'item') {
parent = self.control;
type_class = self.settings.itemClass;
class_type = self.settings.itemClass;
} else {
class_type = self.settings.optionClass;
}
var all = parent.querySelectorAll('.' + type_class);
for (let i = 0; i < all.length; i++) {
if (all[i] != option) {
continue;
do {
if (direction > 0) {
sibling = sibling.nextSibling;
} else {
sibling = sibling.previousSibling;
}
if (direction > 0) {
return all[i + 1];
if (sibling && sibling.classList.contains(class_type)) {
return sibling;
}
return all[i - 1];
}
} while (sibling);
}

@@ -1873,3 +1870,3 @@ /**

self.setTextboxValue('');
self.setTextboxValue();
self.addOption(data);

@@ -2078,3 +2075,3 @@ self.setCaret(caret);

self.refreshState();
self.setTextboxValue('');
self.setTextboxValue();
if (trigger) self.trigger('dropdown_close', self.dropdown);

@@ -2279,2 +2276,6 @@ }

*
* The input must be moved by leaving it in place and moving the
* siblings, due to the fact that focus cannot be restored once lost
* on mobile webkit devices
*
*/

@@ -2290,20 +2291,13 @@

i = Math.max(0, Math.min(self.items.length, i));
}
if (!self.settings.controlInput && !self.isPending) {
// the input must be moved by leaving it in place and moving the
// siblings, due to the fact that focus cannot be restored once lost
// on mobile webkit devices
var j,
child,
children = self.controlChildren(),
n = children.length;
if (i != self.caretPos && !self.isPending) {
var j,
children = self.controlChildren();
for (j = 0; j < n; j++) {
child = children[j];
if (j < i) {
self.control_input.insertAdjacentElement('beforebegin', child);
} else {
self.control.appendChild(child);
for (j in children) {
if (j < i) {
self.control_input.insertAdjacentElement('beforebegin', children[j]);
} else {
self.control.appendChild(children[j]);
}
}

@@ -2322,3 +2316,3 @@ }

controlChildren() {
return Array.prototype.filter.call(this.control.children, node => node.nodeName !== 'INPUT');
return [...this.control.getElementsByClassName(this.settings.itemClass)];
}

@@ -2436,4 +2430,8 @@ /**

if (templateName === 'option' || templateName === 'option_create') {
if (!data[self.settings.disabledField]) {
if (data[self.settings.disabledField]) {
setAttr(html, {
'aria-disabled': 'true'
});
} else {
setAttr(html, {
'data-selectable': ''

@@ -2440,0 +2438,0 @@ });

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -4,0 +4,0 @@ */

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -8,41 +8,41 @@ */

return 0===i?delete this._events:1===i?delete this._events[e]:(this._events=this._events||{},void(e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(t),1)))}trigger(e){if(this._events=this._events||{},e in this._events!=!1)for(var t=0;t<this._events[e].length;t++)this._events[e][t].apply(this,Array.prototype.slice.call(arguments,1))}}var t=function(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=n(String(e||"")))>(t=n(String(t||"")))?1:t>e?-1:0},i=function(e,t,i){if(e&&t){if(!i)return e[t]
for(var s=t.split(".");s.length&&(e=e[s.shift()]););return e}},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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},n=function(){var e,t,i,n,r="",o={}
for(i in s)if(s.hasOwnProperty(i))for(r+=n=s[i].substring(2,s[i].length-1),e=0,t=n.length;e<t;e++)o[n.charAt(e)]=i
var l=new RegExp("["+r+"]","g")
return function(e){return e.replace(l,(function(e){return o[e]})).toLowerCase()}}()
class r{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t){if(!(e=String(e||"").toLowerCase().trim())||!e.length)return[]
var i,n,r,o,l=[],a=e.split(/ +/)
for(i=0,n=a.length;i<n;i++){if(r=(a[i]+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),this.settings.diacritics)for(o in s)s.hasOwnProperty(o)&&(r=r.replace(new RegExp(o,"g"),s[o]))
t&&(r="\\b"+r),l.push({string:a[i],regex:new RegExp(r,"i")})}return l}iterator(e,t){(Array.isArray(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;t<i;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)}).apply(e,[t])}getScoreFunction(e,t){var s,n,r,o,l
l=this.prepareSearch(e,t),n=l.tokens,s=l.options.fields,r=n.length,o=l.options.nesting
for(var s=t.split(".");s.length&&(e=e[s.shift()]););return e}},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ŹźẐẑŽžŻżẒẓẔẕƵƶ]"},n=function(){var e,t,i,n,o="",r={}
for(i in s)if(s.hasOwnProperty(i))for(o+=n=s[i].substring(2,s[i].length-1),e=0,t=n.length;e<t;e++)r[n.charAt(e)]=i
var l=new RegExp("["+o+"]","g")
return function(e){return e.replace(l,(function(e){return r[e]})).toLowerCase()}}()
class o{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t){if(!(e=String(e||"").toLowerCase().trim())||!e.length)return[]
var i,n,o,r,l=[],a=e.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]))
t&&(o="\\b"+o),l.push({string:a[i],regex:new RegExp(o,"i")})}return l}iterator(e,t){(Array.isArray(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;t<i;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)}).apply(e,[t])}getScoreFunction(e,t){var s,n,o,r,l
l=this.prepareSearch(e,t),n=l.tokens,s=l.options.fields,o=n.length,r=l.options.nesting
var a,d=function(e,t){var i,s
return e?-1===(s=(e=String(e||"")).search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i):0},p=(a=s.length)?1===a?function(e,t){return d(i(t,s[0],o),e)}:function(e,t){for(var n=0,r=0;n<a;n++)r+=d(i(t,s[n],o),e)
return r/a}:function(){return 0}
return r?1===r?function(e){return p(n[0],e)}:"and"===l.options.conjunction?function(e){for(var t,i=0,s=0;i<r;i++){if((t=p(n[i],e))<=0)return 0
s+=t}return s/r}:function(e){for(var t=0,i=0;t<r;t++)i+=p(n[t],e)
return i/r}:function(){return 0}}getSortFunction(e,s){var n,r,o,l,a,d,p,c,u,h,g
if(g=!(e=(o=this).prepareSearch(e,s)).query&&s.sort_empty||s.sort,u=function(e,t){return"$score"===e?t.score:i(o.items[t.id],e,s.nesting)},a=[],g)for(n=0,r=g.length;n<r;n++)(e.query||"$score"!==g[n].field)&&a.push(g[n])
if(e.query){for(h=!0,n=0,r=a.length;n<r;n++)if("$score"===a[n].field){h=!1
break}h&&a.unshift({field:"$score",direction:"desc"})}else for(n=0,r=a.length;n<r;n++)if("$score"===a[n].field){a.splice(n,1)
break}for(c=[],n=0,r=a.length;n<r;n++)c.push("desc"===a[n].direction?-1:1)
return(d=a.length)?1===d?(l=a[0].field,p=c[0],function(e,i){return p*t(u(l,e),u(l,i))}):function(e,i){var s,n,r
for(s=0;s<d;s++)if(r=a[s].field,n=c[s]*t(u(r,e),u(r,i)))return n
return e?-1===(s=(e=String(e||"")).search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i):0},p=(a=s.length)?1===a?function(e,t){return d(i(t,s[0],r),e)}:function(e,t){for(var n=0,o=0;n<a;n++)o+=d(i(t,s[n],r),e)
return o/a}:function(){return 0}
return o?1===o?function(e){return p(n[0],e)}:"and"===l.options.conjunction?function(e){for(var t,i=0,s=0;i<o;i++){if((t=p(n[i],e))<=0)return 0
s+=t}return s/o}:function(e){for(var t=0,i=0;t<o;t++)i+=p(n[t],e)
return i/o}:function(){return 0}}getSortFunction(e,s){var n,o,r,l,a,d,p,c,u,h,g
if(g=!(e=(r=this).prepareSearch(e,s)).query&&s.sort_empty||s.sort,u=function(e,t){return"$score"===e?t.score:i(r.items[t.id],e,s.nesting)},a=[],g)for(n=0,o=g.length;n<o;n++)(e.query||"$score"!==g[n].field)&&a.push(g[n])
if(e.query){for(h=!0,n=0,o=a.length;n<o;n++)if("$score"===a[n].field){h=!1
break}h&&a.unshift({field:"$score",direction:"desc"})}else for(n=0,o=a.length;n<o;n++)if("$score"===a[n].field){a.splice(n,1)
break}for(c=[],n=0,o=a.length;n<o;n++)c.push("desc"===a[n].direction?-1:1)
return(d=a.length)?1===d?(l=a[0].field,p=c[0],function(e,i){return p*t(u(l,e),u(l,i))}):function(e,i){var s,n,o
for(s=0;s<d;s++)if(o=a[s].field,n=c[s]*t(u(o,e),u(o,i)))return n
return 0}:null}prepareSearch(e,t){if("object"==typeof e)return e
var i=(t=Object.assign({},t)).fields,s=t.sort,n=t.sort_empty
return i&&!Array.isArray(i)&&(t.fields=[i]),s&&!Array.isArray(s)&&(t.sort=[s]),n&&!Array.isArray(n)&&(t.sort_empty=[n]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t.respect_word_boundaries),total:0,items:[]}}search(e,t){var i,s,n,r,o=this
return s=this.prepareSearch(e,t),t=s.options,e=s.query,r=t.score||o.getScoreFunction(s),e.length?o.iterator(o.items,(function(e,n){i=r(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):o.iterator(o.items,(function(e,t){s.items.push({score:1,id:t})})),(n=o.getSortFunction(s,t))&&s.items.sort(n),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}function o(e,t){if("string"!=typeof t||t.length){var i="string"==typeof t?new RegExp(t,"i"):t
return i&&!Array.isArray(i)&&(t.fields=[i]),s&&!Array.isArray(s)&&(t.sort=[s]),n&&!Array.isArray(n)&&(t.sort_empty=[n]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t.respect_word_boundaries),total:0,items:[]}}search(e,t){var i,s,n,o,r=this
return s=this.prepareSearch(e,t),t=s.options,e=s.query,o=t.score||r.getScoreFunction(s),e.length?r.iterator(r.items,(function(e,n){i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):r.iterator(r.items,(function(e,t){s.items.push({score:1,id:t})})),(n=r.getSortFunction(s,t))&&s.items.sort(n),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}function r(e,t){if("string"!=typeof t||t.length){var i="string"==typeof t?new RegExp(t,"i"):t
!function e(t){var s=0
if(3===t.nodeType){var n=t.data.search(i)
if(n>=0&&t.data.length>0){var r=t.data.match(i),o=document.createElement("span")
o.className="highlight"
if(n>=0&&t.data.length>0){var o=t.data.match(i),r=document.createElement("span")
r.className="highlight"
var l=t.splitText(n)
l.splitText(r[0].length)
l.splitText(o[0].length)
var a=l.cloneNode(!0)
o.appendChild(a),l.parentNode.replaceChild(o,l),s=1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var d=0;d<t.childNodes.length;++d)d+=e(t.childNodes[d])
r.appendChild(a),l.parentNode.replaceChild(r,l),s=1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var d=0;d<t.childNodes.length;++d)d+=e(t.childNodes[d])
return s}(e)}}const l="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
var a={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,closeAfterSelect:!1,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,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
function d(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""}function p(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(e,t,i){var s,n=e.trigger,r={}
function d(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""}function p(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(e,t,i){var s,n=e.trigger,o={}
for(s in e.trigger=function(){var i=arguments[0]
if(-1===t.indexOf(i))return n.apply(e,arguments)
r[i]=arguments},i.apply(e,[]),e.trigger=n,r)n.apply(e,r[s])}function u(e,t=!1){e&&(e.preventDefault(),t&&e.stopPropagation())}function h(e,t,i,s){e.addEventListener(t,i,s)}function g(e,t){return!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0))}function f(e,t){const i=e.getAttribute("id")
o[i]=arguments},i.apply(e,[]),e.trigger=n,o)n.apply(e,o[s])}function u(e,t=!1){e&&(e.preventDefault(),t&&e.stopPropagation())}function h(e,t,i,s){e.addEventListener(t,i,s)}function g(e,t){return!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0))}function f(e,t){const i=e.getAttribute("id")
return i||(e.setAttribute("id",t),t)}function v(e){if(e.jquery)return e[0]

@@ -52,3 +52,3 @@ if(e instanceof HTMLElement)return e

return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)}function m(e,t){var i=document.createEvent("HTMLEvents")
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function y(e,t){Object.assign(e.style,t)}function O(e,...t){var i=b(t);(e=I(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function w(e,...t){var i=b(t);(e=I(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function b(e){var t=[]
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function y(e,t){Object.assign(e.style,t)}function O(e,...t){var i=w(t);(e=I(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function b(e,...t){var i=w(t);(e=I(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function w(e){var t=[]
for(let i of e)"string"==typeof i&&(i=i.trim().split(/[\11\12\14\15\40]/)),Array.isArray(i)&&(t=t.concat(i))

@@ -60,6 +60,6 @@ return t.filter(Boolean)}function I(e){return Array.isArray(e)||(e=[e]),e}function C(e,t,i){if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e

return i}function S(e,t){for(const i in t)e.setAttribute(i,t[i])}var x=0
class F extends(function(e){return e.plugins={},class extends e{static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i,s,n=this,r=[]
if(n.plugins={names:[],settings:{},requested:{},loaded:{}},Array.isArray(e))for(t=0,i=e.length;t<i;t++)"string"==typeof e[t]?r.push(e[t]):(n.plugins.settings[e[t].name]=e[t].options,r.push(e[t].name))
else if(e)for(s in e)e.hasOwnProperty(s)&&(n.plugins.settings[s]=e[s],r.push(s))
for(;r.length;)n.require(r.shift())}loadPlugin(t){var i=this,s=i.plugins,n=e.plugins[t]
class F extends(function(e){return e.plugins={},class extends e{static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i,s,n=this,o=[]
if(n.plugins={names:[],settings:{},requested:{},loaded:{}},Array.isArray(e))for(t=0,i=e.length;t<i;t++)"string"==typeof e[t]?o.push(e[t]):(n.plugins.settings[e[t].name]=e[t].options,o.push(e[t].name))
else if(e)for(s in e)e.hasOwnProperty(s)&&(n.plugins.settings[s]=e[s],o.push(s))
for(;o.length;)n.require(o.shift())}loadPlugin(t){var i=this,s=i.plugins,n=e.plugins[t]
if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin')

@@ -70,5 +70,5 @@ s.requested[t]=!0,s.loaded[t]=n.fn.apply(i,[i.plugins.settings[t]||{}]),s.names.push(t)}require(e){var t=this,i=t.plugins

super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.tab_key=!1,this.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreBlur=!1,this.hasOptions=!1,this.currentResults=null,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],this.renderCache={item:{},option:{}},x++
var s,n,o,l=v(e)
var s,n,r,l=v(e)
if(l.tomselect)throw new Error("Tom Select already initialized on this element")
l.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(l,null)).getPropertyValue("direction"),this.settings=function(e,t){var i=Object.assign({},a,t),s=i.dataAttr,n=i.labelField,r=i.valueField,o=i.disabledField,l=i.optgroupField,p=i.optgroupLabelField,c=i.optgroupValueField,u=e.tagName.toLowerCase(),h=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
l.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(l,null)).getPropertyValue("direction"),this.settings=function(e,t){var i=Object.assign({},a,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,p=i.optgroupLabelField,c=i.optgroupValueField,u=e.tagName.toLowerCase(),h=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
if(!h&&!i.allowEmptyOption){let t=e.querySelector('option[value=""]')

@@ -80,22 +80,22 @@ t&&(h=t.textContent)}var g={placeholder:h,options:[],optgroups:[],items:[],maxItems:null}

p?Array.isArray(p)?p.push(t):u[s][l]=[p,t]:u[s][l]=t}}else{var c=f(e)
c[n]=c[n]||e.textContent,c[r]=c[r]||s,c[o]=c[o]||e.disabled,c[l]=c[l]||t,c.$option=e,u[s]=c,a.push(c),e.selected&&g.items.push(s)}},m=e=>{var t,i;(i=f(e))[p]=i[p]||e.getAttribute("label")||"",i[c]=i[c]||h++,i[o]=i[o]||e.disabled,g.optgroups.push(i),t=i[c]
c[n]=c[n]||e.textContent,c[o]=c[o]||s,c[r]=c[r]||e.disabled,c[l]=c[l]||t,c.$option=e,u[s]=c,a.push(c),e.selected&&g.items.push(s)}},m=e=>{var t,i;(i=f(e))[p]=i[p]||e.getAttribute("label")||"",i[c]=i[c]||h++,i[r]=i[r]||e.disabled,g.optgroups.push(i),t=i[c]
for(const i of e.children)v(i,t)}
g.maxItems=e.hasAttribute("multiple")?null:1
for(const i of e.children)"optgroup"===(t=i.tagName.toLowerCase())?m(i):"option"===t&&v(i)})():(()=>{var t,o,l=e.getAttribute(s)
for(const i of e.children)"optgroup"===(t=i.tagName.toLowerCase())?m(i):"option"===t&&v(i)})():(()=>{var t,r,l=e.getAttribute(s)
if(l){g.options=JSON.parse(l)
for(const e of g.options)g.items.push(e[r])}else{var a=e.value.trim()||""
for(const e of g.options)g.items.push(e[o])}else{var a=e.value.trim()||""
if(!i.allowEmptyOption&&!a.length)return
t=a.split(i.delimiter)
for(const e of t)(o={})[n]=e,o[r]=e,g.options.push(o)
for(const e of t)(r={})[n]=e,r[o]=e,g.options.push(r)
g.items=t}})(),Object.assign({},a,g,t)}(l,t),this.input=l,this.tabIndex=l.tabIndex||0,this.is_select_tag="select"===l.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=f(l,"tomselect-"+x),this.isRequired=l.required,this.settings.load&&this.settings.loadThrottle&&(this.settings.load=(s=this.settings.load,n=this.settings.loadThrottle,function(e,t){var i=this
o&&(i.loading=Math.max(i.loading-1,0)),clearTimeout(o),o=setTimeout((function(){o=null,i.loadedSearches[e]=!0,s.call(i,e,t)}),n)})),this.sifter=new r(this.options,{diacritics:this.settings.diacritics}),this.setupOptions(this.settings.options,this.settings.optgroups),delete this.settings.optgroups,delete this.settings.options,this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi"),"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode),"boolean"!=typeof this.settings.hidePlaceholder&&(this.settings.hidePlaceholder="multi"!==this.settings.mode)
r&&(i.loading=Math.max(i.loading-1,0)),clearTimeout(r),r=setTimeout((function(){r=null,i.loadedSearches[e]=!0,s.call(i,e,t)}),n)})),this.sifter=new o(this.options,{diacritics:this.settings.diacritics}),this.setupOptions(this.settings.options,this.settings.optgroups),delete this.settings.optgroups,delete this.settings.options,this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi"),"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode),"boolean"!=typeof this.settings.hidePlaceholder&&(this.settings.hidePlaceholder="multi"!==this.settings.mode)
var p=this.settings.createFilter
"function"!=typeof p&&("string"==typeof p&&(p=new RegExp(p)),p instanceof RegExp?this.settings.createFilter=e=>p.test(e):this.settings.createFilter=()=>!0),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()}setup(){var e,t,i,s,n,r,o,l,a,d=this,p=d.settings,c=d.input
"function"!=typeof p&&("string"==typeof p&&(p=new RegExp(p)),p instanceof RegExp?this.settings.createFilter=e=>p.test(e):this.settings.createFilter=()=>!0),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()}setup(){var e,t,i,s,n,o,r,l,a,d=this,p=d.settings,c=d.input
const g={passive:!0},m=d.inputId+"-ts-dropdown"
if(r=d.settings.mode,o=c.getAttribute("class")||"",O(e=v("<div>"),p.wrapperClass,o,r),O(t=v('<div class="items">'),p.inputClass),e.append(t),O(s=d.render("dropdown"),p.dropdownClass,r),O(n=v(`<div style="scroll-behavior: smooth;" role="listbox" id="${m}">`),p.dropdownContentClass),s.append(n),v(p.dropdownParent||e).appendChild(s),p.controlInput)i=v(p.controlInput)
if(o=d.settings.mode,r=c.getAttribute("class")||"",O(e=v("<div>"),p.wrapperClass,r,o),O(t=v('<div class="items">'),p.inputClass),e.append(t),O(s=d.render("dropdown"),p.dropdownClass,o),O(n=v(`<div style="scroll-behavior: smooth;" role="listbox" id="${m}" tabindex="-1">`),p.dropdownContentClass),s.append(n),v(p.dropdownParent||e).appendChild(s),p.controlInput)i=v(p.controlInput)
else{i=v('<input type="text" autocomplete="off" />')
for(const e of["autocorrect","autocapitalize","autocomplete"])c.getAttribute(e)&&S(i,{[e]:c.getAttribute(e)})}p.controlInput||(i.tabIndex=c.disabled?-1:d.tabIndex,t.appendChild(i)),S(i,{role:"combobox",haspopup:"listbox","aria-expanded":"false","aria-controls":m}),a=f(i,d.inputId+"-tomselected")
let y="label[for='"+function(e){return e.replace(/['"\\]/g,"\\$&")}(d.inputId)+"']",w=document.querySelector(y)
if(w){S(w,{for:a}),S(n,{"aria-labelledby":f(w,d.inputId+"-ts-label")})}if(d.settings.copyClassesToDropdown&&O(s,o),e.style.width=c.style.width,d.plugins.names.length&&(l="plugin-"+d.plugins.names.join(" plugin-"),O([e,s],l)),(null===p.maxItems||p.maxItems>1)&&d.is_select_tag&&S(c,{multiple:"multiple"}),d.settings.placeholder&&S(i,{placeholder:p.placeholder}),!d.settings.splitOn&&d.settings.delimiter){var b=d.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")
d.settings.splitOn=new RegExp("\\s*"+b+"+\\s*")}d.control=t,d.control_input=i,d.wrapper=e,d.dropdown=s,d.dropdown_content=n,d.control_input.type=c.type,h(s,"mouseenter",(e=>{var t=C(e.target,"[data-selectable]",s)
let y="label[for='"+function(e){return e.replace(/['"\\]/g,"\\$&")}(d.inputId)+"']",b=document.querySelector(y)
if(b){S(b,{for:a}),S(n,{"aria-labelledby":f(b,d.inputId+"-ts-label")})}if(d.settings.copyClassesToDropdown&&O(s,r),e.style.width=c.style.width,d.plugins.names.length&&(l="plugin-"+d.plugins.names.join(" plugin-"),O([e,s],l)),(null===p.maxItems||p.maxItems>1)&&d.is_select_tag&&S(c,{multiple:"multiple"}),d.settings.placeholder&&S(i,{placeholder:p.placeholder}),!d.settings.splitOn&&d.settings.delimiter){var w=d.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")
d.settings.splitOn=new RegExp("\\s*"+w+"+\\s*")}d.control=t,d.control_input=i,d.wrapper=e,d.dropdown=s,d.dropdown_content=n,d.control_input.type=c.type,h(s,"mouseenter",(e=>{var t=C(e.target,"[data-selectable]",s)
if(t)return d.onOptionHover(e,t)}),{capture:!0}),h(t,"mousedown",(e=>{if(e.target==i)return d.clearActiveItems(),e.stopPropagation(),void d.inputState()

@@ -140,14 +140,14 @@ var s=C(e.target,"."+d.settings.itemClass,t)

if(t.isFocused){if(t.isFocused=!1,t.ignoreFocus=!1,!t.ignoreBlur&&document.activeElement===t.dropdown_content)return t.ignoreBlur=!0,void t.onFocus(e)
var i=()=>{t.close(),t.setActiveItem(),t.clearActiveOption(),t.setCaret(t.items.length),t.refreshState(),t.trigger("blur")}
var i=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")}
t.settings.create&&t.settings.createOnBlur?t.createItem(null,!1,i):i()}}onOptionHover(e,t){}onOptionSelect(e,t){var i,s=this
t&&(t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,!0,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=t.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect?s.close():!s.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&s.setActiveOption(s.getOption(i)))))}onItemSelect(e,t){var i=this
i.isLocked||"multi"===i.settings.mode&&(u(e),i.setActiveItem(t,e))}load(e){var t=this,i=t.settings.load
i&&(t.loadedSearches.hasOwnProperty(e)||(O(t.wrapper,t.settings.loadingClass),t.loading++,i.call(t,e,(function(e,i){t.loading=Math.max(t.loading-1,0),t.lastQuery=null,t.clearActiveOption(),t.setupOptions(e,i),t.refreshOptions(t.isFocused&&!t.isInputHidden),t.loading||w(t.wrapper,t.settings.loadingClass),t.trigger("load",e,i)}))))}onSearchChange(e){this.load(e)}setTextboxValue(e){var t=this.control_input
t.value!==e&&(t.value=e,m(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){c(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,r,o,a,d=this
i&&(t.loadedSearches.hasOwnProperty(e)||(O(t.wrapper,t.settings.loadingClass),t.loading++,i.call(t,e,(function(e,i){t.loading=Math.max(t.loading-1,0),t.lastQuery=null,t.clearActiveOption(),t.setupOptions(e,i),t.refreshOptions(t.isFocused&&!t.isInputHidden),t.loading||b(t.wrapper,t.settings.loadingClass),t.trigger("load",e,i)}))))}onSearchChange(e){this.load(e)}setTextboxValue(e=""){var t=this.control_input
t.value!==e&&(t.value=e,m(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){c(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,a,d=this
if("single"!==d.settings.mode){if(!e)return d.clearActiveItems(),void(d.isFocused&&d.showInput())
if("mousedown"===(i=t&&t.type.toLowerCase())&&g("shiftKey",t)&&d.activeItems.length){for(a=d.getLastActive(),(n=Array.prototype.indexOf.call(d.control.children,a))>(r=Array.prototype.indexOf.call(d.control.children,e))&&(o=n,n=r,r=o),s=n;s<=r;s++)e=d.control.children[s],-1===d.activeItems.indexOf(e)&&d.setActiveItemClass(e)
if("mousedown"===(i=t&&t.type.toLowerCase())&&g("shiftKey",t)&&d.activeItems.length){for(a=d.getLastActive(),(n=Array.prototype.indexOf.call(d.control.children,a))>(o=Array.prototype.indexOf.call(d.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=d.control.children[s],-1===d.activeItems.indexOf(e)&&d.setActiveItemClass(e)
u(t)}else"mousedown"===i&&g(l,t)||"keydown"===i&&g("shiftKey",t)?e.classList.contains("active")?d.removeActiveItem(e):d.setActiveItemClass(e):(d.clearActiveItems(),d.setActiveItemClass(e))
d.hideInput(),d.isFocused||d.focus()}}setActiveItemClass(e){var t=this.control.querySelector(".last-active")
t&&w(t,"last-active"),O(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
this.activeItems.splice(t,1),w(e,"active")}clearActiveItems(){w(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){var t,i,s
t&&b(t,"last-active"),O(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
this.activeItems.splice(t,1),b(e,"active")}clearActiveItems(){b(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){var t,i,s
if(e===this.activeOption)return

@@ -157,11 +157,11 @@ if(this.clearActiveOption(),!e)return

let n=this.dropdown_content.scrollTop||0
i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(w(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(O(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(""),e.isInputHidden=!0,O(e.wrapper,"input-hidden")):(e.isInputHidden=!1,w(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(b(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(O(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0,O(e.wrapper,"input-hidden")):(e.isInputHidden=!1,b(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.control_input.blur(),this.onBlur(null)}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e,t=this.settings
return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(e){var t,i,s,n=this,r=n.settings,o=this.getSearchOptions()
if(r.score&&"function"!=typeof(s=n.settings.score.call(n,e)))throw new Error('Tom Select "score" setting must be a function that returns a function')
if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(o,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),r.hideSelected)for(t=i.items.length-1;t>=0;t--)-1!==n.items.indexOf(d(i.items[t].id))&&i.items.splice(t,1)
return i}refreshOptions(e=!0){var t,i,s,n,r,l,a,p,c,u,h,g,f,v=this,m=v.inputValue(),y=v.search(m),O=v.activeOption&&d(v.activeOption.dataset.value),b=v.settings.shouldOpen||!1
for(n=y.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(b=!0),g={},r=[],t=0;t<n;t++){let e=v.options[y.items[t].id],n=d(e[v.settings.valueField]),o=v.getOption(n)
for(o||(o=v.render("option",e)),v.settings.hideSelected||o.classList.toggle("selected",v.items.includes(n)),l=e[v.settings.optgroupField]||"",i=0,s=(a=Array.isArray(l)?l:[l])&&a.length;i<s;i++)l=a[i],v.optgroups.hasOwnProperty(l)||(l=""),g.hasOwnProperty(l)||(g[l]=document.createDocumentFragment(),r.push(l)),i>0&&(o=o.cloneNode(!0),w(o,"active"),o.removeAttribute("aria-selected")),g[l].appendChild(o)}for(l of(this.settings.lockOptgroupOrder&&r.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),p=document.createDocumentFragment(),r))if(v.optgroups.hasOwnProperty(l)&&g[l].children.length){let e=document.createDocumentFragment()
return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(e){var t,i,s,n=this,o=n.settings,r=this.getSearchOptions()
if(o.score&&"function"!=typeof(s=n.settings.score.call(n,e)))throw new Error('Tom Select "score" setting must be a function that returns a function')
if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(r,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),o.hideSelected)for(t=i.items.length-1;t>=0;t--)-1!==n.items.indexOf(d(i.items[t].id))&&i.items.splice(t,1)
return i}refreshOptions(e=!0){var t,i,s,n,o,l,a,p,c,u,h,g,f,v=this,m=v.inputValue(),y=v.search(m),O=v.activeOption&&d(v.activeOption.dataset.value),w=v.settings.shouldOpen||!1
for(n=y.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(w=!0),g={},o=[],t=0;t<n;t++){let e=v.options[y.items[t].id],n=d(e[v.settings.valueField]),r=v.getOption(n)
for(r||(r=v.render("option",e)),v.settings.hideSelected||r.classList.toggle("selected",v.items.includes(n)),l=e[v.settings.optgroupField]||"",i=0,s=(a=Array.isArray(l)?l:[l])&&a.length;i<s;i++)l=a[i],v.optgroups.hasOwnProperty(l)||(l=""),g.hasOwnProperty(l)||(g[l]=document.createDocumentFragment(),o.push(l)),i>0&&(r=r.cloneNode(!0),b(r,"active"),r.removeAttribute("aria-selected")),g[l].appendChild(r)}for(l of(this.settings.lockOptgroupOrder&&o.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),p=document.createDocumentFragment(),o))if(v.optgroups.hasOwnProperty(l)&&g[l].children.length){let e=document.createDocumentFragment()
e.appendChild(v.render("optgroup_header",v.optgroups[l])),e.appendChild(g[l])

@@ -171,6 +171,6 @@ let t=v.render("optgroup",{group:v.optgroups[l],options:e})

if(v.dropdown_content.innerHTML="",v.dropdown_content.appendChild(p),v.settings.highlight&&(v.dropdown_content,f=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(f,(function(e,t){var i=e.parentNode
i.replaceChild(e.firstChild,e),i.normalize()})),y.query.length&&y.tokens.length))for(const e of y.tokens)o(v.dropdown_content,e.regex)
i.replaceChild(e.firstChild,e),i.normalize()})),y.query.length&&y.tokens.length))for(const e of y.tokens)r(v.dropdown_content,e.regex)
var I=e=>{let t=v.render(e,{input:m})
return t&&(b=!0,v.dropdown_content.insertBefore(t,v.dropdown_content.firstChild)),t}
if(v.settings.shouldLoad.call(v,m)?v.loading?I("loading"):0===y.items.length&&I("no_results"):I("not_loading"),(c=v.canCreate(m))&&(h=I("option_create")),v.hasOptions=y.items.length>0||c,b){if(y.items.length>0){if(!(u=O&&v.getOption(O))||!v.dropdown_content.contains(u)){let e=0
return t&&(w=!0,v.dropdown_content.insertBefore(t,v.dropdown_content.firstChild)),t}
if(v.settings.shouldLoad.call(v,m)?v.loading?I("loading"):0===y.items.length&&I("no_results"):I("not_loading"),(c=v.canCreate(m))&&(h=I("option_create")),v.hasOptions=y.items.length>0||c,w){if(y.items.length>0){if(!(u=O&&v.getOption(O))||!v.dropdown_content.contains(u)){let e=0
h&&!v.settings.addPrecedence&&(e=1),u=v.selectable()[e]}}else u=h

@@ -182,5 +182,5 @@ v.setActiveOption(u),e&&!v.isOpen&&v.open()}else v.clearActiveOption(),e&&v.isOpen&&v.close()}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e){var t,i=this

return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var i
t[this.settings.optgroupValueField]=e,(i=this.registerOptionGroup(t))&&this.trigger("optgroup_add",i,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){var i,s,n,r,o,l,a,p=this
t[this.settings.optgroupValueField]=e,(i=this.registerOptionGroup(t))&&this.trigger("optgroup_add",i,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){var i,s,n,o,r,l,a,p=this
if(e=d(e),n=d(t[p.settings.valueField]),null!==e&&p.options.hasOwnProperty(e)){if("string"!=typeof n)throw new Error("Value must be set in option data")
a=p.options[e].$order,n!==e&&(delete p.options[e],-1!==(r=p.items.indexOf(e))&&p.items.splice(r,1,n)),t.$order=t.$order||a,p.options[n]=t,o=p.renderCache.item,l=p.renderCache.option,o&&(delete o[e],delete o[n]),l&&(delete l[e],delete l[n]),-1!==p.items.indexOf(n)&&(i=p.getItem(e),s=p.render("item",t),i.classList.contains("active")&&O(s,"active"),i.parentNode.insertBefore(s,i),i.remove()),p.lastQuery=null,p.isOpen&&p.refreshOptions(!1)}}removeOption(e,t){var i=this
a=p.options[e].$order,n!==e&&(delete p.options[e],-1!==(o=p.items.indexOf(e))&&p.items.splice(o,1,n)),t.$order=t.$order||a,p.options[n]=t,r=p.renderCache.item,l=p.renderCache.option,r&&(delete r[e],delete r[n]),l&&(delete l[e],delete l[n]),-1!==p.items.indexOf(n)&&(i=p.getItem(e),s=p.render("item",t),i.classList.contains("active")&&O(s,"active"),i.parentNode.insertBefore(s,i),i.remove()),p.lastQuery=null,p.isOpen&&p.refreshOptions(!1)}}removeOption(e,t){var i=this
e=d(e)

@@ -191,6 +191,5 @@ var s=i.renderCache.item,n=i.renderCache.option

for(let t in this.options)this.options.hasOwnProperty(t)&&this.items.indexOf(t)>=0&&(e[t]=this.options[t])
this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}getOption(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}getAdjacent(e,t,i="option"){if(e){var s=this,n=s.settings.optionClass,r=s.dropdown
"item"==i&&(r=s.control,n=s.settings.itemClass)
var o=r.querySelectorAll("."+n)
for(let i=0;i<o.length;i++)if(o[i]==e)return t>0?o[i+1]:o[i-1]}}getElementWithValue(e,t){if(null!==(e=d(e)))for(const i of t){let t=i
this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}getOption(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}getAdjacent(e,t,i="option"){var s,n=e
if(e){s="item"==i?this.settings.itemClass:this.settings.optionClass
do{if((n=t>0?n.nextSibling:n.previousSibling)&&n.classList.contains(s))return n}while(n)}}getElementWithValue(e,t){if(null!==(e=d(e)))for(const i of t){let t=i
if(t.getAttribute("data-value")===e)return t}}getItem(e){return this.getElementWithValue(e,this.control.children)}addItems(e,t){this.buffer=document.createDocumentFragment()

@@ -201,14 +200,14 @@ for(const e of this.control.children)this.buffer.appendChild(e)

var s=this.control
s.insertBefore(this.buffer,s.firstChild),this.buffer=null}addItem(e,t){c(this,t?[]:["change"],(()=>{var i,s,n=this,r=n.settings.mode
if(e=d(e),(-1===n.items.indexOf(e)||("single"===r&&n.close(),"single"!==r&&n.settings.duplicates))&&n.options.hasOwnProperty(e)&&("single"===r&&n.clear(t),"multi"!==r||!n.isFull())){if(i=n.render("item",n.options[e]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,e),n.insertAtCaret(i),n.isSetup){let s=n.selectable()
s.insertBefore(this.buffer,s.firstChild),this.buffer=null}addItem(e,t){c(this,t?[]:["change"],(()=>{var i,s,n=this,o=n.settings.mode
if(e=d(e),(-1===n.items.indexOf(e)||("single"===o&&n.close(),"single"!==o&&n.settings.duplicates))&&n.options.hasOwnProperty(e)&&("single"===o&&n.clear(t),"multi"!==o||!n.isFull())){if(i=n.render("item",n.options[e]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,e),n.insertAtCaret(i),n.isSetup){let s=n.selectable()
if(!n.isPending){let t=n.getOption(e),i=n.getAdjacent(t,1)
n.refreshOptions(n.isFocused&&"single"!==r),i&&n.setActiveOption(i)}!s.length||n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",e,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&n.refreshState()}}))}removeItem(e,t){var i,s,n=this,r=n.getItem(e)
r&&(e=d(r.dataset.value),-1!==(i=n.items.indexOf(e))&&(r.remove(),r.classList.contains("active")&&(s=n.activeItems.indexOf(r),n.activeItems.splice(s,1),w(r,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(e)&&n.removeOption(e,t),i<n.caretPos&&n.setCaret(n.caretPos-1),n.updateOriginalInput({silent:t}),n.refreshState(),n.positionDropdown(),n.trigger("item_remove",e,r)))}createItem(e,t=!0,i){var s,n=this,r=n.caretPos
n.refreshOptions(n.isFocused&&"single"!==o),i&&n.setActiveOption(i)}!s.length||n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",e,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&n.refreshState()}}))}removeItem(e,t){var i,s,n=this,o=n.getItem(e)
o&&(e=d(o.dataset.value),-1!==(i=n.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(s=n.activeItems.indexOf(o),n.activeItems.splice(s,1),b(o,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(e)&&n.removeOption(e,t),i<n.caretPos&&n.setCaret(n.caretPos-1),n.updateOriginalInput({silent:t}),n.refreshState(),n.positionDropdown(),n.trigger("item_remove",e,o)))}createItem(e,t=!0,i){var s,n=this,o=n.caretPos
if(e=e||n.inputValue(),"function"!=typeof i&&(i=()=>{}),!n.canCreate(e))return i(),!1
n.lock()
var o=!1,l=e=>{if(n.unlock(),!e||"object"!=typeof e)return i()
var r=!1,l=e=>{if(n.unlock(),!e||"object"!=typeof e)return i()
var s=d(e[n.settings.valueField])
if("string"!=typeof s)return i()
n.setTextboxValue(""),n.addOption(e),n.setCaret(r),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),o=!0}
return s="function"==typeof n.settings.create?n.settings.create.call(this,e,l):{[n.settings.labelField]:e,[n.settings.valueField]:e},o||l(s),!0}refreshItems(){var e=this
n.setTextboxValue(),n.addOption(e),n.setCaret(o),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),r=!0}
return s="function"==typeof n.settings.create?n.settings.create.call(this,e,l):{[n.settings.labelField]:e,[n.settings.valueField]:e},r||l(s),!0}refreshItems(){var e=this
e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){var e=this

@@ -225,3 +224,3 @@ e.refreshValidityState()

e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,S(e.control_input,{"aria-expanded":"true"}),e.refreshState(),y(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),y(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(){var e=this,t=e.isOpen
"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.tab_key||e.blur()),e.isOpen=!1,S(e.control_input,{"aria-expanded":"false"}),y(e.dropdown,{display:"none"}),e.clearActiveOption(),e.refreshState(),e.setTextboxValue(""),t&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.tab_key||e.blur()),e.isOpen=!1,S(e.control_input,{"aria-expanded":"false"}),y(e.dropdown,{display:"none"}),e.clearActiveOption(),e.refreshState(),e.setTextboxValue(),t&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
y(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this

@@ -231,25 +230,26 @@ if(t.items.length){var i=t.controlChildren()

t.items=[],t.lastQuery=null,t.setCaret(0),t.setActiveItem(),t.updateOriginalInput({silent:e}),t.refreshState(),t.showInput(),t.trigger("clear")}}insertAtCaret(e){var t=this,i=Math.min(t.caretPos,t.items.length),s=t.buffer||t.control
0===i?s.insertBefore(e,s.firstChild):s.insertBefore(e,s.children[i]),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,r,o=this
if(t=e&&8===e.keyCode?-1:1,i={start:(r=o.control_input).selectionStart,length:r.selectionEnd-r.selectionStart},s=[],o.activeItems.length){n=_(A(o.activeItems,t)),t>0&&n++
for(const e of o.activeItems)s.push(e.dataset.value)}else(o.isFocused||"single"===o.settings.mode)&&o.items.length&&(t<0&&0===i.start&&0===i.length?s.push(o.items[o.caretPos-1]):t>0&&i.start===o.inputValue().length&&s.push(o.items[o.caretPos]))
if(!s.length||"function"==typeof o.settings.onDelete&&!1===o.settings.onDelete.call(o,s,e))return!1
for(u(e,!0),void 0!==n&&o.setCaret(n);s.length;)o.removeItem(s.pop())
return o.showInput(),o.positionDropdown(),o.refreshOptions(!1),!0}advanceSelection(e,t){var i,s,n,r=this
r.rtl&&(e*=-1),r.inputValue().length||(g(l,t)||g("shiftKey",t)?(n=(s=r.getLastActive(e))?s.classList.contains("active")?r.getAdjacent(s,e,"item"):s:e>0?r.control_input.nextElementSibling:r.control_input.previousElementSibling)&&(n.classList.contains("active")&&r.removeActiveItem(s),r.setActiveItemClass(n)):r.isFocused&&!r.activeItems.length?r.setCaret(r.caretPos+e):(s=r.getLastActive(e))&&(i=_(s),r.setCaret(e>0?i+1:i),r.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
0===i?s.insertBefore(e,s.firstChild):s.insertBefore(e,s.children[i]),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,o,r=this
if(t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart,length:o.selectionEnd-o.selectionStart},s=[],r.activeItems.length){n=_(A(r.activeItems,t)),t>0&&n++
for(const e of r.activeItems)s.push(e.dataset.value)}else(r.isFocused||"single"===r.settings.mode)&&r.items.length&&(t<0&&0===i.start&&0===i.length?s.push(r.items[r.caretPos-1]):t>0&&i.start===r.inputValue().length&&s.push(r.items[r.caretPos]))
if(!s.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.call(r,s,e))return!1
for(u(e,!0),void 0!==n&&r.setCaret(n);s.length;)r.removeItem(s.pop())
return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}advanceSelection(e,t){var i,s,n,o=this
o.rtl&&(e*=-1),o.inputValue().length||(g(l,t)||g("shiftKey",t)?(n=(s=o.getLastActive(e))?s.classList.contains("active")?o.getAdjacent(s,e,"item"):s:e>0?o.control_input.nextElementSibling:o.control_input.previousElementSibling)&&(n.classList.contains("active")&&o.removeActiveItem(s),o.setActiveItemClass(n)):o.isFocused&&!o.activeItems.length?o.setCaret(o.caretPos+e):(s=o.getLastActive(e))&&(i=_(s),o.setCaret(e>0?i+1:i),o.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
if(t)return t
var i=this.control.querySelectorAll(".active")
return i?A(i,e):void 0}setCaret(e){var t=this
if(e="single"===t.settings.mode||t.settings.controlInput?t.items.length:Math.max(0,Math.min(t.items.length,e)),!t.settings.controlInput&&!t.isPending){var i,s,n=t.controlChildren(),r=n.length
for(i=0;i<r;i++)s=n[i],i<e?t.control_input.insertAdjacentElement("beforebegin",s):t.control.appendChild(s)}t.caretPos=e}controlChildren(){return Array.prototype.filter.call(this.control.children,(e=>"INPUT"!==e.nodeName))}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
if("single"===t.settings.mode||t.settings.controlInput)e=t.items.length
else if((e=Math.max(0,Math.min(t.items.length,e)))!=t.caretPos&&!t.isPending){var i,s=t.controlChildren()
for(i in s)i<e?t.control_input.insertAdjacentElement("beforebegin",s[i]):t.control.appendChild(s[i])}t.caretPos=e}controlChildren(){return[...this.control.getElementsByClassName(this.settings.itemClass)]}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
e.input.disabled=!0,e.control_input.disabled=!0,e.control_input.tabIndex=-1,e.isDisabled=!0,e.lock()}enable(){var e=this
e.input.disabled=!1,e.control_input.disabled=!1,e.control_input.tabIndex=e.tabIndex,e.isDisabled=!1,e.unlock()}destroy(){var e=this,t=e.revertSettings
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML="",e.input.tabIndex=t.tabIndex,w(e.input,"tomselected"),e.input.removeAttribute("hidden"),e.input.required=this.isRequired
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML="",e.input.tabIndex=t.tabIndex,b(e.input,"tomselected"),e.input.removeAttribute("hidden"),e.input.required=this.isRequired
for(const i of t.children)e.input.appendChild(i)
e._destroy(),delete e.input.tomselect}render(e,t){var i,s,n=this
if(("option"===e||"item"===e)&&(i=d(t[n.settings.valueField]),n.renderCache[e].hasOwnProperty(i)))return n.renderCache[e][i]
var r=n.settings.render[e]
return"function"!=typeof r?null:(s=r.call(this,t,p))?(s=v(s),"option"===e||"option_create"===e?t[n.settings.disabledField]||S(s,{"data-selectable":""}):"optgroup"===e&&(S(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&S(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(S(s,{"data-value":i}),"item"===e?O(s,n.settings.itemClass):(O(s,n.settings.optionClass),S(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
s[t]=function(){var t,r
return"after"===e&&(t=n.apply(s,arguments)),r=i.apply(s,arguments),"instead"===e?r:("before"===e&&(t=n.apply(s,arguments)),t)}}}return F}))
var o=n.settings.render[e]
return"function"!=typeof o?null:(s=o.call(this,t,p))?(s=v(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?S(s,{"aria-disabled":"true"}):S(s,{"data-selectable":""}):"optgroup"===e&&(S(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&S(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(S(s,{"data-value":i}),"item"===e?O(s,n.settings.itemClass):(O(s,n.settings.optionClass),S(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
s[t]=function(){var t,o
return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return F}))
var tomSelect=function(e,t){return new TomSelect(e,t)}
//# sourceMappingURL=tom-select.base.min.js.map
/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -67,6 +67,6 @@ */

return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)}function y(e,t){var i=document.createEvent("HTMLEvents")
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function O(e,t){Object.assign(e.style,t)}function b(e,...t){var i=I(t);(e=C(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function w(e,...t){var i=I(t);(e=C(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function I(e){var t=[]
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function O(e,t){Object.assign(e.style,t)}function b(e,...t){var i=C(t);(e=I(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function w(e,...t){var i=C(t);(e=I(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function C(e){var t=[]
for(let i of 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 C(e){return Array.isArray(e)||(e=[e]),e}function _(e,t,i){if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
e=e.parentNode}}function A(e,t){return t>0?e[e.length-1]:e[0]}function S(e,t){if(!e)return-1
return t.filter(Boolean)}function I(e){return Array.isArray(e)||(e=[e]),e}function _(e,t,i){if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
e=e.parentNode}}function S(e,t){return t>0?e[e.length-1]:e[0]}function A(e,t){if(!e)return-1
t=t||e.nodeName

@@ -91,3 +91,3 @@ for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++

const g={passive:!0},v=d.inputId+"-ts-dropdown"
if(o=d.settings.mode,r=c.getAttribute("class")||"",b(e=m("<div>"),p.wrapperClass,r,o),b(t=m('<div class="items">'),p.inputClass),e.append(t),b(s=d.render("dropdown"),p.dropdownClass,o),b(n=m(`<div style="scroll-behavior: smooth;" role="listbox" id="${v}">`),p.dropdownContentClass),s.append(n),m(p.dropdownParent||e).appendChild(s),p.controlInput)i=m(p.controlInput)
if(o=d.settings.mode,r=c.getAttribute("class")||"",b(e=m("<div>"),p.wrapperClass,r,o),b(t=m('<div class="items">'),p.inputClass),e.append(t),b(s=d.render("dropdown"),p.dropdownClass,o),b(n=m(`<div style="scroll-behavior: smooth;" role="listbox" id="${v}" tabindex="-1">`),p.dropdownContentClass),s.append(n),m(p.dropdownParent||e).appendChild(s),p.controlInput)i=m(p.controlInput)
else{i=m('<input type="text" autocomplete="off" />')

@@ -101,6 +101,6 @@ for(const e of["autocorrect","autocapitalize","autocomplete"])c.getAttribute(e)&&x(i,{[e]:c.getAttribute(e)})}p.controlInput||(i.tabIndex=c.disabled?-1:d.tabIndex,t.appendChild(i)),x(i,{role:"combobox",haspopup:"listbox","aria-expanded":"false","aria-controls":v}),l=f(i,d.inputId+"-tomselected")

return s?d.onItemSelect(e,s):d.onMouseDown(e)})),h(t,"click",(e=>d.onClick(e))),h(i,"keydown",(e=>d.onKeyDown(e))),h(i,"keyup",(e=>d.onKeyUp(e))),h(i,"keypress",(e=>d.onKeyPress(e))),h(i,"resize",(()=>d.positionDropdown()),g),h(i,"blur",(e=>d.onBlur(e))),h(i,"focus",(e=>{d.ignoreBlur=!1,d.onFocus(e)})),h(i,"paste",(e=>d.onPaste(e)))
var I=e=>{var t=_(e.target,"[data-selectable]",d.dropdown)
var C=e=>{var t=_(e.target,"[data-selectable]",d.dropdown)
if(!t&&!d.wrapper.contains(e.target))return d.isFocused&&d.blur(),void d.inputState()
u(e,!0),t&&d.onOptionSelect(e,t)},C=()=>{d.isOpen&&d.positionDropdown()}
h(document,"mousedown",I),h(window,"sroll",C,g),h(window,"resize",C,g),d._destroy=()=>{document.removeEventListener("mousedown",I),window.removeEventListener("sroll",C),window.removeEventListener("resize",C)},this.revertSettings={children:[...c.children],tabIndex:c.tabIndex},c.tabIndex=-1,x(c,{hidden:"hidden"}),c.insertAdjacentElement("afterend",d.wrapper),d.setValue(p.items),delete p.items,h(c,"invalid",(e=>{u(e),d.isInvalid||(d.isInvalid=!0,d.refreshState())})),d.updateOriginalInput(),d.refreshItems(),d.refreshState(),d.inputState(),d.isSetup=!0,c.disabled&&d.disable(),d.on("change",this.onChange),b(c,"tomselected"),d.trigger("initialize"),!0===p.preload&&d.load("")}setupOptions(e=[],t=[]){for(const t of e)this.registerOption(t)
u(e,!0),t&&d.onOptionSelect(e,t)},I=()=>{d.isOpen&&d.positionDropdown()}
h(document,"mousedown",C),h(window,"sroll",I,g),h(window,"resize",I,g),d._destroy=()=>{document.removeEventListener("mousedown",C),window.removeEventListener("sroll",I),window.removeEventListener("resize",I)},this.revertSettings={children:[...c.children],tabIndex:c.tabIndex},c.tabIndex=-1,x(c,{hidden:"hidden"}),c.insertAdjacentElement("afterend",d.wrapper),d.setValue(p.items),delete p.items,h(c,"invalid",(e=>{u(e),d.isInvalid||(d.isInvalid=!0,d.refreshState())})),d.updateOriginalInput(),d.refreshItems(),d.refreshState(),d.inputState(),d.isSetup=!0,c.disabled&&d.disable(),d.on("change",this.onChange),b(c,"tomselected"),d.trigger("initialize"),!0===p.preload&&d.load("")}setupOptions(e=[],t=[]){for(const t of e)this.registerOption(t)
for(const e of t)this.registerOptionGroup(e)}setupTemplates(){var e=this,t=e.settings.labelField,i=e.settings.optgroupLabelField,s={optgroup:(e,t)=>{let i=document.createElement("div")

@@ -138,7 +138,7 @@ return i.className="optgroup",i.appendChild(e.options),i},optgroup_header:(e,t)=>'<div class="optgroup-header">'+t(e[i])+"</div>",option:(e,i)=>"<div>"+i(e[t])+"</div>",item:(e,i)=>"<div>"+i(e[t])+"</div>",option_create:(e,t)=>'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>",no_results:(e,t)=>'<div class="no-results">No results found</div>',loading:(e,t)=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>'<div style="display:none"></div>'}

if(t.isFocused){if(t.isFocused=!1,t.ignoreFocus=!1,!t.ignoreBlur&&document.activeElement===t.dropdown_content)return t.ignoreBlur=!0,void t.onFocus(e)
var i=()=>{t.close(),t.setActiveItem(),t.clearActiveOption(),t.setCaret(t.items.length),t.refreshState(),t.trigger("blur")}
var i=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")}
t.settings.create&&t.settings.createOnBlur?t.createItem(null,!1,i):i()}}onOptionHover(e,t){}onOptionSelect(e,t){var i,s=this
t&&(t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,!0,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=t.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect?s.close():!s.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&s.setActiveOption(s.getOption(i)))))}onItemSelect(e,t){var i=this
i.isLocked||"multi"===i.settings.mode&&(u(e),i.setActiveItem(t,e))}load(e){var t=this,i=t.settings.load
i&&(t.loadedSearches.hasOwnProperty(e)||(b(t.wrapper,t.settings.loadingClass),t.loading++,i.call(t,e,(function(e,i){t.loading=Math.max(t.loading-1,0),t.lastQuery=null,t.clearActiveOption(),t.setupOptions(e,i),t.refreshOptions(t.isFocused&&!t.isInputHidden),t.loading||w(t.wrapper,t.settings.loadingClass),t.trigger("load",e,i)}))))}onSearchChange(e){this.load(e)}setTextboxValue(e){var t=this.control_input
i&&(t.loadedSearches.hasOwnProperty(e)||(b(t.wrapper,t.settings.loadingClass),t.loading++,i.call(t,e,(function(e,i){t.loading=Math.max(t.loading-1,0),t.lastQuery=null,t.clearActiveOption(),t.setupOptions(e,i),t.refreshOptions(t.isFocused&&!t.isInputHidden),t.loading||w(t.wrapper,t.settings.loadingClass),t.trigger("load",e,i)}))))}onSearchChange(e){this.load(e)}setTextboxValue(e=""){var t=this.control_input
t.value!==e&&(t.value=e,y(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){c(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,l,d=this

@@ -156,3 +156,3 @@ if("single"!==d.settings.mode){if(!e)return d.clearActiveItems(),void(d.isFocused&&d.showInput())

i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(w(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(b(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(""),e.isInputHidden=!0,b(e.wrapper,"input-hidden")):(e.isInputHidden=!1,w(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0,b(e.wrapper,"input-hidden")):(e.isInputHidden=!1,w(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.control_input.blur(),this.onBlur(null)}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e,t=this.settings

@@ -170,5 +170,5 @@ return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(e){var t,i,s,n=this,o=n.settings,r=this.getSearchOptions()

i.replaceChild(e.firstChild,e),i.normalize()})),y.query.length&&y.tokens.length))for(const e of y.tokens)r(v.dropdown_content,e.regex)
var I=e=>{let t=v.render(e,{input:m})
var C=e=>{let t=v.render(e,{input:m})
return t&&(b=!0,v.dropdown_content.insertBefore(t,v.dropdown_content.firstChild)),t}
if(v.settings.shouldLoad.call(v,m)?v.loading?I("loading"):0===y.items.length&&I("no_results"):I("not_loading"),(c=v.canCreate(m))&&(h=I("option_create")),v.hasOptions=y.items.length>0||c,b){if(y.items.length>0){if(!(u=O&&v.getOption(O))||!v.dropdown_content.contains(u)){let e=0
if(v.settings.shouldLoad.call(v,m)?v.loading?C("loading"):0===y.items.length&&C("no_results"):C("not_loading"),(c=v.canCreate(m))&&(h=C("option_create")),v.hasOptions=y.items.length>0||c,b){if(y.items.length>0){if(!(u=O&&v.getOption(O))||!v.dropdown_content.contains(u)){let e=0
h&&!v.settings.addPrecedence&&(e=1),u=v.selectable()[e]}}else u=h

@@ -188,6 +188,5 @@ v.setActiveOption(u),e&&!v.isOpen&&v.open()}else v.clearActiveOption(),e&&v.isOpen&&v.close()}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e){var t,i=this

for(let t in this.options)this.options.hasOwnProperty(t)&&this.items.indexOf(t)>=0&&(e[t]=this.options[t])
this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}getOption(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}getAdjacent(e,t,i="option"){if(e){var s=this,n=s.settings.optionClass,o=s.dropdown
"item"==i&&(o=s.control,n=s.settings.itemClass)
var r=o.querySelectorAll("."+n)
for(let i=0;i<r.length;i++)if(r[i]==e)return t>0?r[i+1]:r[i-1]}}getElementWithValue(e,t){if(null!==(e=d(e)))for(const i of t){let t=i
this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}getOption(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}getAdjacent(e,t,i="option"){var s,n=e
if(e){s="item"==i?this.settings.itemClass:this.settings.optionClass
do{if((n=t>0?n.nextSibling:n.previousSibling)&&n.classList.contains(s))return n}while(n)}}getElementWithValue(e,t){if(null!==(e=d(e)))for(const i of t){let t=i
if(t.getAttribute("data-value")===e)return t}}getItem(e){return this.getElementWithValue(e,this.control.children)}addItems(e,t){this.buffer=document.createDocumentFragment()

@@ -208,3 +207,3 @@ for(const e of this.control.children)this.buffer.appendChild(e)

if("string"!=typeof s)return i()
n.setTextboxValue(""),n.addOption(e),n.setCaret(o),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),r=!0}
n.setTextboxValue(),n.addOption(e),n.setCaret(o),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),r=!0}
return s="function"==typeof n.settings.create?n.settings.create.call(this,e,a):{[n.settings.labelField]:e,[n.settings.valueField]:e},r||a(s),!0}refreshItems(){var e=this

@@ -222,3 +221,3 @@ e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){var e=this

e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,x(e.control_input,{"aria-expanded":"true"}),e.refreshState(),O(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),O(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(){var e=this,t=e.isOpen
"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.tab_key||e.blur()),e.isOpen=!1,x(e.control_input,{"aria-expanded":"false"}),O(e.dropdown,{display:"none"}),e.clearActiveOption(),e.refreshState(),e.setTextboxValue(""),t&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.tab_key||e.blur()),e.isOpen=!1,x(e.control_input,{"aria-expanded":"false"}),O(e.dropdown,{display:"none"}),e.clearActiveOption(),e.refreshState(),e.setTextboxValue(),t&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
O(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this

@@ -229,3 +228,3 @@ if(t.items.length){var i=t.controlChildren()

0===i?s.insertBefore(e,s.firstChild):s.insertBefore(e,s.children[i]),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,o,r=this
if(t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart,length:o.selectionEnd-o.selectionStart},s=[],r.activeItems.length){n=S(A(r.activeItems,t)),t>0&&n++
if(t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart,length:o.selectionEnd-o.selectionStart},s=[],r.activeItems.length){n=A(S(r.activeItems,t)),t>0&&n++
for(const e of r.activeItems)s.push(e.dataset.value)}else(r.isFocused||"single"===r.settings.mode)&&r.items.length&&(t<0&&0===i.start&&0===i.length?s.push(r.items[r.caretPos-1]):t>0&&i.start===r.inputValue().length&&s.push(r.items[r.caretPos]))

@@ -235,8 +234,9 @@ if(!s.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.call(r,s,e))return!1

return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}advanceSelection(e,t){var i,s,n,o=this
o.rtl&&(e*=-1),o.inputValue().length||(g(a,t)||g("shiftKey",t)?(n=(s=o.getLastActive(e))?s.classList.contains("active")?o.getAdjacent(s,e,"item"):s:e>0?o.control_input.nextElementSibling:o.control_input.previousElementSibling)&&(n.classList.contains("active")&&o.removeActiveItem(s),o.setActiveItemClass(n)):o.isFocused&&!o.activeItems.length?o.setCaret(o.caretPos+e):(s=o.getLastActive(e))&&(i=S(s),o.setCaret(e>0?i+1:i),o.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
o.rtl&&(e*=-1),o.inputValue().length||(g(a,t)||g("shiftKey",t)?(n=(s=o.getLastActive(e))?s.classList.contains("active")?o.getAdjacent(s,e,"item"):s:e>0?o.control_input.nextElementSibling:o.control_input.previousElementSibling)&&(n.classList.contains("active")&&o.removeActiveItem(s),o.setActiveItemClass(n)):o.isFocused&&!o.activeItems.length?o.setCaret(o.caretPos+e):(s=o.getLastActive(e))&&(i=A(s),o.setCaret(e>0?i+1:i),o.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
if(t)return t
var i=this.control.querySelectorAll(".active")
return i?A(i,e):void 0}setCaret(e){var t=this
if(e="single"===t.settings.mode||t.settings.controlInput?t.items.length:Math.max(0,Math.min(t.items.length,e)),!t.settings.controlInput&&!t.isPending){var i,s,n=t.controlChildren(),o=n.length
for(i=0;i<o;i++)s=n[i],i<e?t.control_input.insertAdjacentElement("beforebegin",s):t.control.appendChild(s)}t.caretPos=e}controlChildren(){return Array.prototype.filter.call(this.control.children,(e=>"INPUT"!==e.nodeName))}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
return i?S(i,e):void 0}setCaret(e){var t=this
if("single"===t.settings.mode||t.settings.controlInput)e=t.items.length
else if((e=Math.max(0,Math.min(t.items.length,e)))!=t.caretPos&&!t.isPending){var i,s=t.controlChildren()
for(i in s)i<e?t.control_input.insertAdjacentElement("beforebegin",s[i]):t.control.appendChild(s[i])}t.caretPos=e}controlChildren(){return[...this.control.getElementsByClassName(this.settings.itemClass)]}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
e.input.disabled=!0,e.control_input.disabled=!0,e.control_input.tabIndex=-1,e.isDisabled=!0,e.lock()}enable(){var e=this

@@ -249,3 +249,3 @@ e.input.disabled=!1,e.control_input.disabled=!1,e.control_input.tabIndex=e.tabIndex,e.isDisabled=!1,e.unlock()}destroy(){var e=this,t=e.revertSettings

var o=n.settings.render[e]
return"function"!=typeof o?null:(s=o.call(this,t,p))?(s=m(s),"option"===e||"option_create"===e?t[n.settings.disabledField]||x(s,{"data-selectable":""}):"optgroup"===e&&(x(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&x(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(x(s,{"data-value":i}),"item"===e?b(s,n.settings.itemClass):(b(s,n.settings.optionClass),x(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
return"function"!=typeof o?null:(s=o.call(this,t,p))?(s=m(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?x(s,{"aria-disabled":"true"}):x(s,{"data-selectable":""}):"optgroup"===e&&(x(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&x(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(x(s,{"data-value":i}),"item"===e?b(s,n.settings.itemClass):(b(s,n.settings.optionClass),x(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
s[t]=function(){var t,o

@@ -289,3 +289,3 @@ return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return F.define("change_listener",(function(e){var t=this,i=!1

if(!e.isOpen||37!==i.keyCode&&39!==i.keyCode)return t.apply(e,arguments)
r=_(e.activeOption,"[data-group]"),s=S(e.activeOption,"[data-selectable]"),(r=37===i.keyCode?r.previousSibling:r.nextSibling)&&(n=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,s)])&&e.setActiveOption(n)}))})),F.define("remove_button",(function(e){e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e)
r=_(e.activeOption,"[data-group]"),s=A(e.activeOption,"[data-selectable]"),(r=37===i.keyCode?r.previousSibling:r.nextSibling)&&(n=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,s)])&&e.setActiveOption(n)}))})),F.define("remove_button",(function(e){e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e)
var t=this

@@ -292,0 +292,0 @@ if(e.append){var i='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+p(e.title)+'">'+e.label+"</a>"

/**
* Tom Select v1.4.0
* Tom Select v1.4.1
* Licensed under the Apache License, Version 2.0 (the "License");

@@ -10,21 +10,21 @@ */

for(i in s)if(s.hasOwnProperty(i))for(o+=n=s[i].substring(2,s[i].length-1),e=0,t=n.length;e<t;e++)r[n.charAt(e)]=i
var l=new RegExp("["+o+"]","g")
return function(e){return e.replace(l,(function(e){return r[e]})).toLowerCase()}}()
var a=new RegExp("["+o+"]","g")
return function(e){return e.replace(a,(function(e){return r[e]})).toLowerCase()}}()
class o{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t){if(!(e=String(e||"").toLowerCase().trim())||!e.length)return[]
var i,n,o,r,l=[],a=e.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]))
t&&(o="\\b"+o),l.push({string:a[i],regex:new RegExp(o,"i")})}return l}iterator(e,t){(Array.isArray(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;t<i;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)}).apply(e,[t])}getScoreFunction(e,t){var s,n,o,r,l
l=this.prepareSearch(e,t),n=l.tokens,s=l.options.fields,o=n.length,r=l.options.nesting
var a,d=function(e,t){var i,s
return e?-1===(s=(e=String(e||"")).search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i):0},p=(a=s.length)?1===a?function(e,t){return d(i(t,s[0],r),e)}:function(e,t){for(var n=0,o=0;n<a;n++)o+=d(i(t,s[n],r),e)
return o/a}:function(){return 0}
return o?1===o?function(e){return p(n[0],e)}:"and"===l.options.conjunction?function(e){for(var t,i=0,s=0;i<o;i++){if((t=p(n[i],e))<=0)return 0
var i,n,o,r,a=[],l=e.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]))
t&&(o="\\b"+o),a.push({string:l[i],regex:new RegExp(o,"i")})}return a}iterator(e,t){(Array.isArray(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;t<i;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)}).apply(e,[t])}getScoreFunction(e,t){var s,n,o,r,a
a=this.prepareSearch(e,t),n=a.tokens,s=a.options.fields,o=n.length,r=a.options.nesting
var l,d=function(e,t){var i,s
return e?-1===(s=(e=String(e||"")).search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i):0},p=(l=s.length)?1===l?function(e,t){return d(i(t,s[0],r),e)}:function(e,t){for(var n=0,o=0;n<l;n++)o+=d(i(t,s[n],r),e)
return o/l}:function(){return 0}
return o?1===o?function(e){return p(n[0],e)}:"and"===a.options.conjunction?function(e){for(var t,i=0,s=0;i<o;i++){if((t=p(n[i],e))<=0)return 0
s+=t}return s/o}:function(e){for(var t=0,i=0;t<o;t++)i+=p(n[t],e)
return i/o}:function(){return 0}}getSortFunction(e,s){var n,o,r,l,a,d,p,c,u,h,g
if(g=!(e=(r=this).prepareSearch(e,s)).query&&s.sort_empty||s.sort,u=function(e,t){return"$score"===e?t.score:i(r.items[t.id],e,s.nesting)},a=[],g)for(n=0,o=g.length;n<o;n++)(e.query||"$score"!==g[n].field)&&a.push(g[n])
if(e.query){for(h=!0,n=0,o=a.length;n<o;n++)if("$score"===a[n].field){h=!1
break}h&&a.unshift({field:"$score",direction:"desc"})}else for(n=0,o=a.length;n<o;n++)if("$score"===a[n].field){a.splice(n,1)
break}for(c=[],n=0,o=a.length;n<o;n++)c.push("desc"===a[n].direction?-1:1)
return(d=a.length)?1===d?(l=a[0].field,p=c[0],function(e,i){return p*t(u(l,e),u(l,i))}):function(e,i){var s,n,o
for(s=0;s<d;s++)if(o=a[s].field,n=c[s]*t(u(o,e),u(o,i)))return n
return i/o}:function(){return 0}}getSortFunction(e,s){var n,o,r,a,l,d,p,c,u,h,g
if(g=!(e=(r=this).prepareSearch(e,s)).query&&s.sort_empty||s.sort,u=function(e,t){return"$score"===e?t.score:i(r.items[t.id],e,s.nesting)},l=[],g)for(n=0,o=g.length;n<o;n++)(e.query||"$score"!==g[n].field)&&l.push(g[n])
if(e.query){for(h=!0,n=0,o=l.length;n<o;n++)if("$score"===l[n].field){h=!1
break}h&&l.unshift({field:"$score",direction:"desc"})}else for(n=0,o=l.length;n<o;n++)if("$score"===l[n].field){l.splice(n,1)
break}for(c=[],n=0,o=l.length;n<o;n++)c.push("desc"===l[n].direction?-1:1)
return(d=l.length)?1===d?(a=l[0].field,p=c[0],function(e,i){return p*t(u(a,e),u(a,i))}):function(e,i){var s,n,o
for(s=0;s<d;s++)if(o=l[s].field,n=c[s]*t(u(o,e),u(o,i)))return n
return 0}:null}prepareSearch(e,t){if("object"==typeof e)return e

@@ -38,8 +38,8 @@ var i=(t=Object.assign({},t)).fields,s=t.sort,n=t.sort_empty

r.className="highlight"
var l=t.splitText(n)
l.splitText(o[0].length)
var a=l.cloneNode(!0)
r.appendChild(a),l.parentNode.replaceChild(r,l),s=1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var d=0;d<t.childNodes.length;++d)d+=e(t.childNodes[d])
return s}(e)}}const l="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
var a={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,closeAfterSelect:!1,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,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
var a=t.splitText(n)
a.splitText(o[0].length)
var l=a.cloneNode(!0)
r.appendChild(l),a.parentNode.replaceChild(r,a),s=1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&("highlight"!==t.className||"SPAN"!==t.tagName))for(var d=0;d<t.childNodes.length;++d)d+=e(t.childNodes[d])
return s}(e)}}const a="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
var l={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,closeAfterSelect:!1,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,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
function d(e){return null==e?null:"boolean"==typeof e?e?"1":"0":e+""}function p(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(e,t,i){var s,n=e.trigger,o={}

@@ -53,3 +53,3 @@ for(s in e.trigger=function(){var i=arguments[0]

return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)}function m(e,t){var i=document.createEvent("HTMLEvents")
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function y(e,t){Object.assign(e.style,t)}function O(e,...t){var i=b(t);(e=I(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function w(e,...t){var i=b(t);(e=I(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function b(e){var t=[]
i.initEvent(t,!0,!1),e.dispatchEvent(i)}function y(e,t){Object.assign(e.style,t)}function O(e,...t){var i=w(t);(e=I(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))}function b(e,...t){var i=w(t);(e=I(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))}function w(e){var t=[]
for(let i of e)"string"==typeof i&&(i=i.trim().split(/[\11\12\14\15\40]/)),Array.isArray(i)&&(t=t.concat(i))

@@ -70,31 +70,31 @@ return t.filter(Boolean)}function I(e){return Array.isArray(e)||(e=[e]),e}function C(e,t,i){if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e

super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.tab_key=!1,this.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreBlur=!1,this.hasOptions=!1,this.currentResults=null,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],this.renderCache={item:{},option:{}},x++
var s,n,r,l=v(e)
if(l.tomselect)throw new Error("Tom Select already initialized on this element")
l.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(l,null)).getPropertyValue("direction"),this.settings=function(e,t){var i=Object.assign({},a,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,p=i.optgroupLabelField,c=i.optgroupValueField,u=e.tagName.toLowerCase(),h=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
var s,n,r,a=v(e)
if(a.tomselect)throw new Error("Tom Select already initialized on this element")
a.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(a,null)).getPropertyValue("direction"),this.settings=function(e,t){var i=Object.assign({},l,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,a=i.optgroupField,p=i.optgroupLabelField,c=i.optgroupValueField,u=e.tagName.toLowerCase(),h=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
if(!h&&!i.allowEmptyOption){let t=e.querySelector('option[value=""]')
t&&(h=t.textContent)}var g={placeholder:h,options:[],optgroups:[],items:[],maxItems:null}
return"select"===u?(()=>{var t,a=g.options,u={},h=1,f=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
return"select"===u?(()=>{var t,l=g.options,u={},h=1,f=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},v=(e,t)=>{var s=d(e.value)
if(s||i.allowEmptyOption)if(u.hasOwnProperty(s)){if(t){var p=u[s][l]
p?Array.isArray(p)?p.push(t):u[s][l]=[p,t]:u[s][l]=t}}else{var c=f(e)
c[n]=c[n]||e.textContent,c[o]=c[o]||s,c[r]=c[r]||e.disabled,c[l]=c[l]||t,c.$option=e,u[s]=c,a.push(c),e.selected&&g.items.push(s)}},m=e=>{var t,i;(i=f(e))[p]=i[p]||e.getAttribute("label")||"",i[c]=i[c]||h++,i[r]=i[r]||e.disabled,g.optgroups.push(i),t=i[c]
if(s||i.allowEmptyOption)if(u.hasOwnProperty(s)){if(t){var p=u[s][a]
p?Array.isArray(p)?p.push(t):u[s][a]=[p,t]:u[s][a]=t}}else{var c=f(e)
c[n]=c[n]||e.textContent,c[o]=c[o]||s,c[r]=c[r]||e.disabled,c[a]=c[a]||t,c.$option=e,u[s]=c,l.push(c),e.selected&&g.items.push(s)}},m=e=>{var t,i;(i=f(e))[p]=i[p]||e.getAttribute("label")||"",i[c]=i[c]||h++,i[r]=i[r]||e.disabled,g.optgroups.push(i),t=i[c]
for(const i of e.children)v(i,t)}
g.maxItems=e.hasAttribute("multiple")?null:1
for(const i of e.children)"optgroup"===(t=i.tagName.toLowerCase())?m(i):"option"===t&&v(i)})():(()=>{var t,r,l=e.getAttribute(s)
if(l){g.options=JSON.parse(l)
for(const e of g.options)g.items.push(e[o])}else{var a=e.value.trim()||""
if(!i.allowEmptyOption&&!a.length)return
t=a.split(i.delimiter)
for(const i of e.children)"optgroup"===(t=i.tagName.toLowerCase())?m(i):"option"===t&&v(i)})():(()=>{var t,r,a=e.getAttribute(s)
if(a){g.options=JSON.parse(a)
for(const e of g.options)g.items.push(e[o])}else{var l=e.value.trim()||""
if(!i.allowEmptyOption&&!l.length)return
t=l.split(i.delimiter)
for(const e of t)(r={})[n]=e,r[o]=e,g.options.push(r)
g.items=t}})(),Object.assign({},a,g,t)}(l,t),this.input=l,this.tabIndex=l.tabIndex||0,this.is_select_tag="select"===l.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=f(l,"tomselect-"+x),this.isRequired=l.required,this.settings.load&&this.settings.loadThrottle&&(this.settings.load=(s=this.settings.load,n=this.settings.loadThrottle,function(e,t){var i=this
g.items=t}})(),Object.assign({},l,g,t)}(a,t),this.input=a,this.tabIndex=a.tabIndex||0,this.is_select_tag="select"===a.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=f(a,"tomselect-"+x),this.isRequired=a.required,this.settings.load&&this.settings.loadThrottle&&(this.settings.load=(s=this.settings.load,n=this.settings.loadThrottle,function(e,t){var i=this
r&&(i.loading=Math.max(i.loading-1,0)),clearTimeout(r),r=setTimeout((function(){r=null,i.loadedSearches[e]=!0,s.call(i,e,t)}),n)})),this.sifter=new o(this.options,{diacritics:this.settings.diacritics}),this.setupOptions(this.settings.options,this.settings.optgroups),delete this.settings.optgroups,delete this.settings.options,this.settings.mode=this.settings.mode||(1===this.settings.maxItems?"single":"multi"),"boolean"!=typeof this.settings.hideSelected&&(this.settings.hideSelected="multi"===this.settings.mode),"boolean"!=typeof this.settings.hidePlaceholder&&(this.settings.hidePlaceholder="multi"!==this.settings.mode)
var p=this.settings.createFilter
"function"!=typeof p&&("string"==typeof p&&(p=new RegExp(p)),p instanceof RegExp?this.settings.createFilter=e=>p.test(e):this.settings.createFilter=()=>!0),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()}setup(){var e,t,i,s,n,o,r,l,a,d=this,p=d.settings,c=d.input
"function"!=typeof p&&("string"==typeof p&&(p=new RegExp(p)),p instanceof RegExp?this.settings.createFilter=e=>p.test(e):this.settings.createFilter=()=>!0),this.initializePlugins(this.settings.plugins),this.setupCallbacks(),this.setupTemplates(),this.setup()}setup(){var e,t,i,s,n,o,r,a,l,d=this,p=d.settings,c=d.input
const g={passive:!0},m=d.inputId+"-ts-dropdown"
if(o=d.settings.mode,r=c.getAttribute("class")||"",O(e=v("<div>"),p.wrapperClass,r,o),O(t=v('<div class="items">'),p.inputClass),e.append(t),O(s=d.render("dropdown"),p.dropdownClass,o),O(n=v(`<div style="scroll-behavior: smooth;" role="listbox" id="${m}">`),p.dropdownContentClass),s.append(n),v(p.dropdownParent||e).appendChild(s),p.controlInput)i=v(p.controlInput)
if(o=d.settings.mode,r=c.getAttribute("class")||"",O(e=v("<div>"),p.wrapperClass,r,o),O(t=v('<div class="items">'),p.inputClass),e.append(t),O(s=d.render("dropdown"),p.dropdownClass,o),O(n=v(`<div style="scroll-behavior: smooth;" role="listbox" id="${m}" tabindex="-1">`),p.dropdownContentClass),s.append(n),v(p.dropdownParent||e).appendChild(s),p.controlInput)i=v(p.controlInput)
else{i=v('<input type="text" autocomplete="off" />')
for(const e of["autocorrect","autocapitalize","autocomplete"])c.getAttribute(e)&&S(i,{[e]:c.getAttribute(e)})}p.controlInput||(i.tabIndex=c.disabled?-1:d.tabIndex,t.appendChild(i)),S(i,{role:"combobox",haspopup:"listbox","aria-expanded":"false","aria-controls":m}),a=f(i,d.inputId+"-tomselected")
let y="label[for='"+function(e){return e.replace(/['"\\]/g,"\\$&")}(d.inputId)+"']",w=document.querySelector(y)
if(w){S(w,{for:a}),S(n,{"aria-labelledby":f(w,d.inputId+"-ts-label")})}if(d.settings.copyClassesToDropdown&&O(s,r),e.style.width=c.style.width,d.plugins.names.length&&(l="plugin-"+d.plugins.names.join(" plugin-"),O([e,s],l)),(null===p.maxItems||p.maxItems>1)&&d.is_select_tag&&S(c,{multiple:"multiple"}),d.settings.placeholder&&S(i,{placeholder:p.placeholder}),!d.settings.splitOn&&d.settings.delimiter){var b=d.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")
d.settings.splitOn=new RegExp("\\s*"+b+"+\\s*")}d.control=t,d.control_input=i,d.wrapper=e,d.dropdown=s,d.dropdown_content=n,d.control_input.type=c.type,h(s,"mouseenter",(e=>{var t=C(e.target,"[data-selectable]",s)
for(const e of["autocorrect","autocapitalize","autocomplete"])c.getAttribute(e)&&S(i,{[e]:c.getAttribute(e)})}p.controlInput||(i.tabIndex=c.disabled?-1:d.tabIndex,t.appendChild(i)),S(i,{role:"combobox",haspopup:"listbox","aria-expanded":"false","aria-controls":m}),l=f(i,d.inputId+"-tomselected")
let y="label[for='"+function(e){return e.replace(/['"\\]/g,"\\$&")}(d.inputId)+"']",b=document.querySelector(y)
if(b){S(b,{for:l}),S(n,{"aria-labelledby":f(b,d.inputId+"-ts-label")})}if(d.settings.copyClassesToDropdown&&O(s,r),e.style.width=c.style.width,d.plugins.names.length&&(a="plugin-"+d.plugins.names.join(" plugin-"),O([e,s],a)),(null===p.maxItems||p.maxItems>1)&&d.is_select_tag&&S(c,{multiple:"multiple"}),d.settings.placeholder&&S(i,{placeholder:p.placeholder}),!d.settings.splitOn&&d.settings.delimiter){var w=d.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")
d.settings.splitOn=new RegExp("\\s*"+w+"+\\s*")}d.control=t,d.control_input=i,d.wrapper=e,d.dropdown=s,d.dropdown_content=n,d.control_input.type=c.type,h(s,"mouseenter",(e=>{var t=C(e.target,"[data-selectable]",s)
if(t)return d.onOptionHover(e,t)}),{capture:!0}),h(t,"mousedown",(e=>{if(e.target==i)return d.clearActiveItems(),e.stopPropagation(),void d.inputState()

@@ -120,3 +120,3 @@ var s=C(e.target,"."+d.settings.itemClass,t)

if(t.isLocked)9!==e.keyCode&&u(e)
else{switch(e.keyCode){case 65:if(g(l,e))return void t.selectAll()
else{switch(e.keyCode){case 65:if(g(a,e))return void t.selectAll()
break

@@ -133,3 +133,3 @@ case 27:return t.isOpen&&(u(e,!0),t.close()),void t.clearActiveItems()

case 9:return t.settings.selectOnTab&&t.isOpen&&t.activeOption&&(t.tab_key=!0,t.onOptionSelect(e,t.activeOption),u(e),t.tab_key=!1),void(t.settings.create&&t.createItem()&&u(e))
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!g(l,e)&&u(e)}}onKeyUp(e){var t=this
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!g(a,e)&&u(e)}}onKeyUp(e){var t=this
if(t.isLocked)u(e)

@@ -141,14 +141,14 @@ else{var i=t.inputValue()

if(t.isFocused){if(t.isFocused=!1,t.ignoreFocus=!1,!t.ignoreBlur&&document.activeElement===t.dropdown_content)return t.ignoreBlur=!0,void t.onFocus(e)
var i=()=>{t.close(),t.setActiveItem(),t.clearActiveOption(),t.setCaret(t.items.length),t.refreshState(),t.trigger("blur")}
var i=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")}
t.settings.create&&t.settings.createOnBlur?t.createItem(null,!1,i):i()}}onOptionHover(e,t){}onOptionSelect(e,t){var i,s=this
t&&(t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,!0,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=t.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect?s.close():!s.settings.hideSelected&&e.type&&/mouse/.test(e.type)&&s.setActiveOption(s.getOption(i)))))}onItemSelect(e,t){var i=this
i.isLocked||"multi"===i.settings.mode&&(u(e),i.setActiveItem(t,e))}load(e){var t=this,i=t.settings.load
i&&(t.loadedSearches.hasOwnProperty(e)||(O(t.wrapper,t.settings.loadingClass),t.loading++,i.call(t,e,(function(e,i){t.loading=Math.max(t.loading-1,0),t.lastQuery=null,t.clearActiveOption(),t.setupOptions(e,i),t.refreshOptions(t.isFocused&&!t.isInputHidden),t.loading||w(t.wrapper,t.settings.loadingClass),t.trigger("load",e,i)}))))}onSearchChange(e){this.load(e)}setTextboxValue(e){var t=this.control_input
t.value!==e&&(t.value=e,m(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){c(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,a,d=this
i&&(t.loadedSearches.hasOwnProperty(e)||(O(t.wrapper,t.settings.loadingClass),t.loading++,i.call(t,e,(function(e,i){t.loading=Math.max(t.loading-1,0),t.lastQuery=null,t.clearActiveOption(),t.setupOptions(e,i),t.refreshOptions(t.isFocused&&!t.isInputHidden),t.loading||b(t.wrapper,t.settings.loadingClass),t.trigger("load",e,i)}))))}onSearchChange(e){this.load(e)}setTextboxValue(e=""){var t=this.control_input
t.value!==e&&(t.value=e,m(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){c(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,l,d=this
if("single"!==d.settings.mode){if(!e)return d.clearActiveItems(),void(d.isFocused&&d.showInput())
if("mousedown"===(i=t&&t.type.toLowerCase())&&g("shiftKey",t)&&d.activeItems.length){for(a=d.getLastActive(),(n=Array.prototype.indexOf.call(d.control.children,a))>(o=Array.prototype.indexOf.call(d.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=d.control.children[s],-1===d.activeItems.indexOf(e)&&d.setActiveItemClass(e)
u(t)}else"mousedown"===i&&g(l,t)||"keydown"===i&&g("shiftKey",t)?e.classList.contains("active")?d.removeActiveItem(e):d.setActiveItemClass(e):(d.clearActiveItems(),d.setActiveItemClass(e))
if("mousedown"===(i=t&&t.type.toLowerCase())&&g("shiftKey",t)&&d.activeItems.length){for(l=d.getLastActive(),(n=Array.prototype.indexOf.call(d.control.children,l))>(o=Array.prototype.indexOf.call(d.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=d.control.children[s],-1===d.activeItems.indexOf(e)&&d.setActiveItemClass(e)
u(t)}else"mousedown"===i&&g(a,t)||"keydown"===i&&g("shiftKey",t)?e.classList.contains("active")?d.removeActiveItem(e):d.setActiveItemClass(e):(d.clearActiveItems(),d.setActiveItemClass(e))
d.hideInput(),d.isFocused||d.focus()}}setActiveItemClass(e){var t=this.control.querySelector(".last-active")
t&&w(t,"last-active"),O(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
this.activeItems.splice(t,1),w(e,"active")}clearActiveItems(){w(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){var t,i,s
t&&b(t,"last-active"),O(e,"active last-active"),-1==this.activeItems.indexOf(e)&&this.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
this.activeItems.splice(t,1),b(e,"active")}clearActiveItems(){b(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){var t,i,s
if(e===this.activeOption)return

@@ -158,4 +158,4 @@ if(this.clearActiveOption(),!e)return

let n=this.dropdown_content.scrollTop||0
i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(w(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(O(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(""),e.isInputHidden=!0,O(e.wrapper,"input-hidden")):(e.isInputHidden=!1,w(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
i=this.activeOption.offsetHeight,(s=this.activeOption.getBoundingClientRect().top-this.dropdown_content.getBoundingClientRect().top+n)+i>t+n?this.dropdown_content.scrollTop=s-t+i:s<n&&(this.dropdown_content.scrollTop=s)}clearActiveOption(){this.activeOption&&(b(this.activeOption,"active"),this.activeOption.removeAttribute("aria-selected")),this.activeOption=null,this.control_input.removeAttribute("aria-activedescendant")}selectAll(){"single"!==this.settings.mode&&(this.activeItems=this.controlChildren(),this.activeItems.length&&(O(this.activeItems,"active"),this.hideInput(),this.close()),this.focus())}inputState(){var e=this
e.settings.controlInput||(e.activeItems.length>0||!e.isFocused&&this.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0,O(e.wrapper,"input-hidden")):(e.isInputHidden=!1,b(e.wrapper,"input-hidden")))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
e.isDisabled||(e.ignoreFocus=!0,e.control_input.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.control_input.blur(),this.onBlur(null)}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e,t=this.settings

@@ -165,13 +165,13 @@ return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(e){var t,i,s,n=this,o=n.settings,r=this.getSearchOptions()

if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(r,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),o.hideSelected)for(t=i.items.length-1;t>=0;t--)-1!==n.items.indexOf(d(i.items[t].id))&&i.items.splice(t,1)
return i}refreshOptions(e=!0){var t,i,s,n,o,l,a,p,c,u,h,g,f,v=this,m=v.inputValue(),y=v.search(m),O=v.activeOption&&d(v.activeOption.dataset.value),b=v.settings.shouldOpen||!1
for(n=y.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(b=!0),g={},o=[],t=0;t<n;t++){let e=v.options[y.items[t].id],n=d(e[v.settings.valueField]),r=v.getOption(n)
for(r||(r=v.render("option",e)),v.settings.hideSelected||r.classList.toggle("selected",v.items.includes(n)),l=e[v.settings.optgroupField]||"",i=0,s=(a=Array.isArray(l)?l:[l])&&a.length;i<s;i++)l=a[i],v.optgroups.hasOwnProperty(l)||(l=""),g.hasOwnProperty(l)||(g[l]=document.createDocumentFragment(),o.push(l)),i>0&&(r=r.cloneNode(!0),w(r,"active"),r.removeAttribute("aria-selected")),g[l].appendChild(r)}for(l of(this.settings.lockOptgroupOrder&&o.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),p=document.createDocumentFragment(),o))if(v.optgroups.hasOwnProperty(l)&&g[l].children.length){let e=document.createDocumentFragment()
e.appendChild(v.render("optgroup_header",v.optgroups[l])),e.appendChild(g[l])
let t=v.render("optgroup",{group:v.optgroups[l],options:e})
p.appendChild(t)}else p.appendChild(g[l])
return i}refreshOptions(e=!0){var t,i,s,n,o,a,l,p,c,u,h,g,f,v=this,m=v.inputValue(),y=v.search(m),O=v.activeOption&&d(v.activeOption.dataset.value),w=v.settings.shouldOpen||!1
for(n=y.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(w=!0),g={},o=[],t=0;t<n;t++){let e=v.options[y.items[t].id],n=d(e[v.settings.valueField]),r=v.getOption(n)
for(r||(r=v.render("option",e)),v.settings.hideSelected||r.classList.toggle("selected",v.items.includes(n)),a=e[v.settings.optgroupField]||"",i=0,s=(l=Array.isArray(a)?a:[a])&&l.length;i<s;i++)a=l[i],v.optgroups.hasOwnProperty(a)||(a=""),g.hasOwnProperty(a)||(g[a]=document.createDocumentFragment(),o.push(a)),i>0&&(r=r.cloneNode(!0),b(r,"active"),r.removeAttribute("aria-selected")),g[a].appendChild(r)}for(a of(this.settings.lockOptgroupOrder&&o.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),p=document.createDocumentFragment(),o))if(v.optgroups.hasOwnProperty(a)&&g[a].children.length){let e=document.createDocumentFragment()
e.appendChild(v.render("optgroup_header",v.optgroups[a])),e.appendChild(g[a])
let t=v.render("optgroup",{group:v.optgroups[a],options:e})
p.appendChild(t)}else p.appendChild(g[a])
if(v.dropdown_content.innerHTML="",v.dropdown_content.appendChild(p),v.settings.highlight&&(v.dropdown_content,f=document.querySelectorAll("span.highlight"),Array.prototype.forEach.call(f,(function(e,t){var i=e.parentNode
i.replaceChild(e.firstChild,e),i.normalize()})),y.query.length&&y.tokens.length))for(const e of y.tokens)r(v.dropdown_content,e.regex)
var I=e=>{let t=v.render(e,{input:m})
return t&&(b=!0,v.dropdown_content.insertBefore(t,v.dropdown_content.firstChild)),t}
if(v.settings.shouldLoad.call(v,m)?v.loading?I("loading"):0===y.items.length&&I("no_results"):I("not_loading"),(c=v.canCreate(m))&&(h=I("option_create")),v.hasOptions=y.items.length>0||c,b){if(y.items.length>0){if(!(u=O&&v.getOption(O))||!v.dropdown_content.contains(u)){let e=0
return t&&(w=!0,v.dropdown_content.insertBefore(t,v.dropdown_content.firstChild)),t}
if(v.settings.shouldLoad.call(v,m)?v.loading?I("loading"):0===y.items.length&&I("no_results"):I("not_loading"),(c=v.canCreate(m))&&(h=I("option_create")),v.hasOptions=y.items.length>0||c,w){if(y.items.length>0){if(!(u=O&&v.getOption(O))||!v.dropdown_content.contains(u)){let e=0
h&&!v.settings.addPrecedence&&(e=1),u=v.selectable()[e]}}else u=h

@@ -183,5 +183,5 @@ v.setActiveOption(u),e&&!v.isOpen&&v.open()}else v.clearActiveOption(),e&&v.isOpen&&v.close()}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e){var t,i=this

return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var i
t[this.settings.optgroupValueField]=e,(i=this.registerOptionGroup(t))&&this.trigger("optgroup_add",i,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){var i,s,n,o,r,l,a,p=this
t[this.settings.optgroupValueField]=e,(i=this.registerOptionGroup(t))&&this.trigger("optgroup_add",i,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){var i,s,n,o,r,a,l,p=this
if(e=d(e),n=d(t[p.settings.valueField]),null!==e&&p.options.hasOwnProperty(e)){if("string"!=typeof n)throw new Error("Value must be set in option data")
a=p.options[e].$order,n!==e&&(delete p.options[e],-1!==(o=p.items.indexOf(e))&&p.items.splice(o,1,n)),t.$order=t.$order||a,p.options[n]=t,r=p.renderCache.item,l=p.renderCache.option,r&&(delete r[e],delete r[n]),l&&(delete l[e],delete l[n]),-1!==p.items.indexOf(n)&&(i=p.getItem(e),s=p.render("item",t),i.classList.contains("active")&&O(s,"active"),i.parentNode.insertBefore(s,i),i.remove()),p.lastQuery=null,p.isOpen&&p.refreshOptions(!1)}}removeOption(e,t){var i=this
l=p.options[e].$order,n!==e&&(delete p.options[e],-1!==(o=p.items.indexOf(e))&&p.items.splice(o,1,n)),t.$order=t.$order||l,p.options[n]=t,r=p.renderCache.item,a=p.renderCache.option,r&&(delete r[e],delete r[n]),a&&(delete a[e],delete a[n]),-1!==p.items.indexOf(n)&&(i=p.getItem(e),s=p.render("item",t),i.classList.contains("active")&&O(s,"active"),i.parentNode.insertBefore(s,i),i.remove()),p.lastQuery=null,p.isOpen&&p.refreshOptions(!1)}}removeOption(e,t){var i=this
e=d(e)

@@ -192,6 +192,5 @@ var s=i.renderCache.item,n=i.renderCache.option

for(let t in this.options)this.options.hasOwnProperty(t)&&this.items.indexOf(t)>=0&&(e[t]=this.options[t])
this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}getOption(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}getAdjacent(e,t,i="option"){if(e){var s=this,n=s.settings.optionClass,o=s.dropdown
"item"==i&&(o=s.control,n=s.settings.itemClass)
var r=o.querySelectorAll("."+n)
for(let i=0;i<r.length;i++)if(r[i]==e)return t>0?r[i+1]:r[i-1]}}getElementWithValue(e,t){if(null!==(e=d(e)))for(const i of t){let t=i
this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}getOption(e){return this.renderCache.option.hasOwnProperty(e)?this.renderCache.option[e]:this.getElementWithValue(e,this.selectable())}getAdjacent(e,t,i="option"){var s,n=e
if(e){s="item"==i?this.settings.itemClass:this.settings.optionClass
do{if((n=t>0?n.nextSibling:n.previousSibling)&&n.classList.contains(s))return n}while(n)}}getElementWithValue(e,t){if(null!==(e=d(e)))for(const i of t){let t=i
if(t.getAttribute("data-value")===e)return t}}getItem(e){return this.getElementWithValue(e,this.control.children)}addItems(e,t){this.buffer=document.createDocumentFragment()

@@ -206,10 +205,10 @@ for(const e of this.control.children)this.buffer.appendChild(e)

n.refreshOptions(n.isFocused&&"single"!==o),i&&n.setActiveOption(i)}!s.length||n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",e,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&n.refreshState()}}))}removeItem(e,t){var i,s,n=this,o=n.getItem(e)
o&&(e=d(o.dataset.value),-1!==(i=n.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(s=n.activeItems.indexOf(o),n.activeItems.splice(s,1),w(o,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(e)&&n.removeOption(e,t),i<n.caretPos&&n.setCaret(n.caretPos-1),n.updateOriginalInput({silent:t}),n.refreshState(),n.positionDropdown(),n.trigger("item_remove",e,o)))}createItem(e,t=!0,i){var s,n=this,o=n.caretPos
o&&(e=d(o.dataset.value),-1!==(i=n.items.indexOf(e))&&(o.remove(),o.classList.contains("active")&&(s=n.activeItems.indexOf(o),n.activeItems.splice(s,1),b(o,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(e)&&n.removeOption(e,t),i<n.caretPos&&n.setCaret(n.caretPos-1),n.updateOriginalInput({silent:t}),n.refreshState(),n.positionDropdown(),n.trigger("item_remove",e,o)))}createItem(e,t=!0,i){var s,n=this,o=n.caretPos
if(e=e||n.inputValue(),"function"!=typeof i&&(i=()=>{}),!n.canCreate(e))return i(),!1
n.lock()
var r=!1,l=e=>{if(n.unlock(),!e||"object"!=typeof e)return i()
var r=!1,a=e=>{if(n.unlock(),!e||"object"!=typeof e)return i()
var s=d(e[n.settings.valueField])
if("string"!=typeof s)return i()
n.setTextboxValue(""),n.addOption(e),n.setCaret(o),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),r=!0}
return s="function"==typeof n.settings.create?n.settings.create.call(this,e,l):{[n.settings.labelField]:e,[n.settings.valueField]:e},r||l(s),!0}refreshItems(){var e=this
n.setTextboxValue(),n.addOption(e),n.setCaret(o),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),r=!0}
return s="function"==typeof n.settings.create?n.settings.create.call(this,e,a):{[n.settings.labelField]:e,[n.settings.valueField]:e},r||a(s),!0}refreshItems(){var e=this
e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){var e=this

@@ -226,3 +225,3 @@ e.refreshValidityState()

e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,S(e.control_input,{"aria-expanded":"true"}),e.refreshState(),y(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),y(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(){var e=this,t=e.isOpen
"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.tab_key||e.blur()),e.isOpen=!1,S(e.control_input,{"aria-expanded":"false"}),y(e.dropdown,{display:"none"}),e.clearActiveOption(),e.refreshState(),e.setTextboxValue(""),t&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
"single"===e.settings.mode&&e.items.length&&(e.hideInput(),e.tab_key||e.blur()),e.isOpen=!1,S(e.control_input,{"aria-expanded":"false"}),y(e.dropdown,{display:"none"}),e.clearActiveOption(),e.refreshState(),e.setTextboxValue(),t&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
y(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this

@@ -238,11 +237,12 @@ if(t.items.length){var i=t.controlChildren()

return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}advanceSelection(e,t){var i,s,n,o=this
o.rtl&&(e*=-1),o.inputValue().length||(g(l,t)||g("shiftKey",t)?(n=(s=o.getLastActive(e))?s.classList.contains("active")?o.getAdjacent(s,e,"item"):s:e>0?o.control_input.nextElementSibling:o.control_input.previousElementSibling)&&(n.classList.contains("active")&&o.removeActiveItem(s),o.setActiveItemClass(n)):o.isFocused&&!o.activeItems.length?o.setCaret(o.caretPos+e):(s=o.getLastActive(e))&&(i=A(s),o.setCaret(e>0?i+1:i),o.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
o.rtl&&(e*=-1),o.inputValue().length||(g(a,t)||g("shiftKey",t)?(n=(s=o.getLastActive(e))?s.classList.contains("active")?o.getAdjacent(s,e,"item"):s:e>0?o.control_input.nextElementSibling:o.control_input.previousElementSibling)&&(n.classList.contains("active")&&o.removeActiveItem(s),o.setActiveItemClass(n)):o.isFocused&&!o.activeItems.length?o.setCaret(o.caretPos+e):(s=o.getLastActive(e))&&(i=A(s),o.setCaret(e>0?i+1:i),o.setActiveItem()))}getLastActive(e){let t=this.control.querySelector(".last-active")
if(t)return t
var i=this.control.querySelectorAll(".active")
return i?_(i,e):void 0}setCaret(e){var t=this
if(e="single"===t.settings.mode||t.settings.controlInput?t.items.length:Math.max(0,Math.min(t.items.length,e)),!t.settings.controlInput&&!t.isPending){var i,s,n=t.controlChildren(),o=n.length
for(i=0;i<o;i++)s=n[i],i<e?t.control_input.insertAdjacentElement("beforebegin",s):t.control.appendChild(s)}t.caretPos=e}controlChildren(){return Array.prototype.filter.call(this.control.children,(e=>"INPUT"!==e.nodeName))}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
if("single"===t.settings.mode||t.settings.controlInput)e=t.items.length
else if((e=Math.max(0,Math.min(t.items.length,e)))!=t.caretPos&&!t.isPending){var i,s=t.controlChildren()
for(i in s)i<e?t.control_input.insertAdjacentElement("beforebegin",s[i]):t.control.appendChild(s[i])}t.caretPos=e}controlChildren(){return[...this.control.getElementsByClassName(this.settings.itemClass)]}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
e.input.disabled=!0,e.control_input.disabled=!0,e.control_input.tabIndex=-1,e.isDisabled=!0,e.lock()}enable(){var e=this
e.input.disabled=!1,e.control_input.disabled=!1,e.control_input.tabIndex=e.tabIndex,e.isDisabled=!1,e.unlock()}destroy(){var e=this,t=e.revertSettings
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML="",e.input.tabIndex=t.tabIndex,w(e.input,"tomselected"),e.input.removeAttribute("hidden"),e.input.required=this.isRequired
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML="",e.input.tabIndex=t.tabIndex,b(e.input,"tomselected"),e.input.removeAttribute("hidden"),e.input.required=this.isRequired
for(const i of t.children)e.input.appendChild(i)

@@ -252,3 +252,3 @@ e._destroy(),delete e.input.tomselect}render(e,t){var i,s,n=this

var o=n.settings.render[e]
return"function"!=typeof o?null:(s=o.call(this,t,p))?(s=v(s),"option"===e||"option_create"===e?t[n.settings.disabledField]||S(s,{"data-selectable":""}):"optgroup"===e&&(S(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&S(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(S(s,{"data-value":i}),"item"===e?O(s,n.settings.itemClass):(O(s,n.settings.optionClass),S(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
return"function"!=typeof o?null:(s=o.call(this,t,p))?(s=v(s),"option"===e||"option_create"===e?t[n.settings.disabledField]?S(s,{"aria-disabled":"true"}):S(s,{"data-selectable":""}):"optgroup"===e&&(S(s,{"data-group":t.group[n.settings.optgroupValueField]}),t.group[n.settings.disabledField]&&S(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(S(s,{"data-value":i}),"item"===e?O(s,n.settings.itemClass):(O(s,n.settings.optionClass),S(s,{role:"option",id:t.$id})),n.renderCache[e][i]=s),s):s}clearCache(e){void 0===e?this.renderCache={item:{},option:{}}:this.renderCache[e]={}}canCreate(e){return this.settings.create&&e.length&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
s[t]=function(){var t,o

@@ -255,0 +255,0 @@ return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return F.define("dropdown_input",(function(){var e=this,t=e.settings.controlInput||'<input type="text" autocomplete="off" class="dropdown-input" />'

@@ -170,3 +170,3 @@ import Sifter from './contrib/sifter.js';

*/
setTextboxValue(value: string): void;
setTextboxValue(value?: string): void;
/**

@@ -477,2 +477,6 @@ * Returns the value of the control. If multiple items

*
* The input must be moved by leaving it in place and moving the
* siblings, due to the fact that focus cannot be restored once lost
* on mobile webkit devices
*
*/

@@ -484,3 +488,3 @@ setCaret(i: number): void;

*/
controlChildren(): any;
controlChildren(): HTMLElement[];
/**

@@ -487,0 +491,0 @@ * Disables user input on the control. Used while

@@ -19,3 +19,3 @@ {

"homepage": "https://tom-select.js.org",
"version": "1.4.0",
"version": "1.4.1",
"author": "Josh Schmidt (https://github.com/oyejorge)",

@@ -31,8 +31,8 @@ "contributors": [

"devDependencies": {
"@11ty/eleventy": "0.11.1",
"@11ty/eleventy-plugin-syntaxhighlight": "3.1.0",
"@11ty/eleventy": "^0.12.1",
"@11ty/eleventy-plugin-syntaxhighlight": "^3.1.0",
"@atomico/rollup-plugin-sizes": "^1.1.4",
"@babel/core": "^7.13.1",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/preset-env": "^7.13.0",
"@babel/preset-env": "^7.13.12",
"@babel/preset-typescript": "^7.13.0",

@@ -61,3 +61,3 @@ "@lodder/grunt-postcss": "^3.0.0",

"grunt-shell": "^3.0.1",
"jquery": "^3.5.1",
"jquery": "^3.6.0",
"karma": "^6.1.1",

@@ -76,8 +76,8 @@ "karma-accessibility-checker": "^3.1.5",

"load-grunt-tasks": "^5.1.0",
"markdown-it-anchor": "^7.0.1",
"markdown-it-anchor": "^7.1.0",
"mocha": "^8.3.0",
"node-sass": "^5.0.0",
"postcss": "^8.2.6",
"rollup": "^2.39.0",
"rollup-plugin-insert": "^1.3.1",
"rollup": "^2.42.3",
"rollup-plugin-insert": "^1.3.2",
"rollup-plugin-terser": "^7.0.2",

@@ -84,0 +84,0 @@ "rollup-plugin-visualizer": "^4.2.0",

@@ -206,3 +206,3 @@

dropdown_content = getDom(`<div style="scroll-behavior: smooth;" role="listbox" id="${listboxId}">`)
dropdown_content = getDom(`<div style="scroll-behavior: smooth;" role="listbox" id="${listboxId}" tabindex="-1">`);
addClasses(dropdown_content, settings.dropdownContentClass);

@@ -780,5 +780,3 @@ dropdown.append(dropdown_content);

self.setActiveItem();
self.clearActiveOption();
self.setCaret(self.items.length);
self.refreshState();
self.trigger('blur');

@@ -901,3 +899,3 @@ };

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

@@ -1122,3 +1120,3 @@ var changed = input.value !== value;

if( self.activeItems.length > 0 || (!self.isFocused && this.settings.hidePlaceholder && self.items.length > 0) ){
self.setTextboxValue('');
self.setTextboxValue();
self.isInputHidden = true;

@@ -1657,2 +1655,3 @@ addClasses(self.wrapper,'input-hidden');

getAdjacent( option:HTMLElement, direction:number, type:string = 'option' ) : HTMLElement|void{
var self = this, class_type, sibling = option;

@@ -1663,23 +1662,21 @@ if( !option ){

var self = this;
var type_class = self.settings.optionClass;
var parent = self.dropdown;
if( type == 'item' ){
parent = self.control;
type_class = self.settings.itemClass;
class_type = self.settings.itemClass;
}else{
class_type = self.settings.optionClass;
}
var all = parent.querySelectorAll('.'+type_class);
for( let i = 0; i < all.length; i++ ){
if( all[i] != option ){
continue;
do{
if( direction > 0 ){
sibling = sibling.nextSibling as HTMLElement;
}else{
sibling = sibling.previousSibling as HTMLElement;
}
if( direction > 0 ){
return all[i+1] as HTMLElement;
if( sibling && sibling.classList.contains(class_type) ){
return sibling;
}
return all[i-1] as HTMLElement;
}
}while( sibling );
}

@@ -1886,3 +1883,3 @@

self.setTextboxValue('');
self.setTextboxValue();
self.addOption(data);

@@ -2086,3 +2083,3 @@ self.setCaret(caret);

self.refreshState();
self.setTextboxValue('');
self.setTextboxValue();

@@ -2298,2 +2295,6 @@ if (trigger) self.trigger('dropdown_close', self.dropdown);

*
* The input must be moved by leaving it in place and moving the
* siblings, due to the fact that focus cannot be restored once lost
* on mobile webkit devices
*
*/

@@ -2307,19 +2308,12 @@ setCaret(i:number) {

i = Math.max(0, Math.min(self.items.length, i));
}
if (!self.settings.controlInput && !self.isPending) {
// the input must be moved by leaving it in place and moving the
// siblings, due to the fact that focus cannot be restored once lost
// on mobile webkit devices
var j, child,
children = self.controlChildren(),
n = children.length;
if( i != self.caretPos && !self.isPending ){
var j, children = self.controlChildren();
for( j = 0; j < n; j++ ){
child = children[j];
if( j < i ){
self.control_input.insertAdjacentElement('beforebegin', child );
} else {
self.control.appendChild(child);
for( j in children ){
if( j < i ){
self.control_input.insertAdjacentElement('beforebegin', children[j] );
} else {
self.control.appendChild( children[j] );
}
}

@@ -2336,4 +2330,4 @@ }

*/
controlChildren(){
return Array.prototype.filter.call( this.control.children, (node:HTMLElement) => node.nodeName !== 'INPUT' );
controlChildren():HTMLElement[]{
return [...this.control.getElementsByClassName(this.settings.itemClass)] as HTMLElement[];
}

@@ -2450,3 +2444,6 @@

if (templateName === 'option' || templateName === 'option_create') {
if (!data[self.settings.disabledField]) {
if( data[self.settings.disabledField] ){
setAttr(html,{'aria-disabled':'true'});
}else{
setAttr(html,{'data-selectable': ''});

@@ -2453,0 +2450,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is 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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc