From 06dcea985d17c464ae17f6d1300c71100f6ed09e Mon Sep 17 00:00:00 2001 From: Jeppe Krogh Date: Fri, 17 Jan 2025 10:30:47 +0100 Subject: [PATCH] Corrected root margin for observer to correctly hide weeknumber post resizing --- assets/timeTable.js | 2 +- dist/js/timeTable.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/timeTable.js b/assets/timeTable.js index 9b5205b..152141b 100644 --- a/assets/timeTable.js +++ b/assets/timeTable.js @@ -277,7 +277,7 @@ jQuery(document).ready(function ($) { ".timetable-scroll-container.overflowing", ), threshold: 1, - rootMargin: "0% 0% 0% -566px", + rootMargin: "0% 0% 0% -595px", }, ); diff --git a/dist/js/timeTable.js b/dist/js/timeTable.js index e929158..c749450 100755 --- a/dist/js/timeTable.js +++ b/dist/js/timeTable.js @@ -1 +1 @@ -(()=>{var e={329:(e,t,n)=>{"use strict";function i(e,t){e.split(/\s+/).forEach((e=>{t(e)}))}class r{constructor(){this._events={}}on(e,t){i(e,(e=>{const n=this._events[e]||[];n.push(t),this._events[e]=n}))}off(e,t){var n=arguments.length;0!==n?i(e,(e=>{if(1===n)return void delete this._events[e];const i=this._events[e];void 0!==i&&(i.splice(i.indexOf(t),1),this._events[e]=i)})):this._events={}}trigger(e,...t){var n=this;i(e,(e=>{const i=n._events[e];void 0!==i&&i.forEach((e=>{e.apply(n,t)}))}))}}const o=e=>(e=e.filter(Boolean)).length<2?e[0]||"":1==u(e)?"["+e.join("")+"]":"(?:"+e.join("|")+")",a=e=>{if(!l(e))return e.join("");let t="",n=0;const i=()=>{n>1&&(t+="{"+n+"}")};return e.forEach(((r,o)=>{r!==e[o-1]?(i(),t+=r,n=1):n++})),i(),t},s=e=>{let t=Array.from(e);return o(t)},l=e=>new Set(e).size!==e.length,c=e=>(e+"").replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu,"\\$1"),u=e=>e.reduce(((e,t)=>Math.max(e,d(t))),0),d=e=>Array.from(e).length,p=e=>{if(1===e.length)return[[e]];let t=[];const n=e.substring(1);return p(n).forEach((function(n){let i=n.slice(0);i[0]=e.charAt(0)+i[0],t.push(i),i=n.slice(0),i.unshift(e.charAt(0)),t.push(i)})),t},f=[[0,65535]];let h,g;const m={},v={"/":"⁄∕",0:"߀",a:"ⱥɐɑ",aa:"ꜳ",ae:"æǽǣ",ao:"ꜵ",au:"ꜷ",av:"ꜹꜻ",ay:"ꜽ",b:"ƀɓƃ",c:"ꜿƈȼↄ",d:"đɗɖᴅƌꮷԁɦ",e:"ɛǝᴇɇ",f:"ꝼƒ",g:"ǥɠꞡᵹꝿɢ",h:"ħⱨⱶɥ",i:"ɨı",j:"ɉȷ",k:"ƙⱪꝁꝃꝅꞣ",l:"łƚɫⱡꝉꝇꞁɭ",m:"ɱɯϻ",n:"ꞥƞɲꞑᴎлԉ",o:"øǿɔɵꝋꝍᴑ",oe:"œ",oi:"ƣ",oo:"ꝏ",ou:"ȣ",p:"ƥᵽꝑꝓꝕρ",q:"ꝗꝙɋ",r:"ɍɽꝛꞧꞃ",s:"ßȿꞩꞅʂ",t:"ŧƭʈⱦꞇ",th:"þ",tz:"ꜩ",u:"ʉ",v:"ʋꝟʌ",vy:"ꝡ",w:"ⱳ",y:"ƴɏỿ",z:"ƶȥɀⱬꝣ",hv:"ƕ"};for(let e in v){let t=v[e]||"";for(let n=0;ne.normalize(t),w=e=>Array.from(e).reduce(((e,t)=>e+x(t)),""),x=e=>(e=b(e).toLowerCase().replace(y,(e=>m[e]||"")),b(e,"NFC"));const C=e=>{const t={},n=(e,n)=>{const i=t[e]||new Set,r=new RegExp("^"+s(i)+"$","iu");n.match(r)||(i.add(c(n)),t[e]=i)};for(let t of function*(e){for(const[t,n]of e)for(let e=t;e<=n;e++){let t=String.fromCharCode(e),n=w(t);n!=t.toLowerCase()&&(n.length>3||0!=n.length&&(yield{folded:n,composed:t,code_point:e}))}}(e))n(t.folded,t.folded),n(t.folded,t.composed);return t},D=e=>{const t=C(e),n={};let i=[];for(let e in t){let r=t[e];r&&(n[e]=s(r)),e.length>1&&i.push(c(e))}i.sort(((e,t)=>t.length-e.length));const r=o(i);return g=new RegExp("^"+r,"u"),n},k=(e,t=1)=>(t=Math.max(t,e.length-1),o(p(e).map((e=>((e,t=1)=>{let n=0;return e=e.map((e=>(h[e]&&(n+=e.length),h[e]||e))),n>=t?a(e):""})(e,t))))),T=(e,t=!0)=>{let n=e.length>1?1:0;return o(e.map((e=>{let i=[];const r=t?e.length():e.length()-1;for(let t=0;t{for(const n of t){if(n.start!=e.start||n.end!=e.end)continue;if(n.substrs.join("")!==e.substrs.join(""))continue;let t=e.parts;const i=e=>{for(const n of t){if(n.start===e.start&&n.substr===e.substr)return!1;if(1!=e.length&&1!=n.length){if(e.startn.start)return!0;if(n.starte.start)return!0}}return!1};if(!(n.parts.filter(i).length>0))return!0}return!1};class S{parts;substrs;start;end;constructor(){this.parts=[],this.substrs=[],this.start=0,this.end=0}add(e){e&&(this.parts.push(e),this.substrs.push(e.substr),this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}last(){return this.parts[this.parts.length-1]}length(){return this.parts.length}clone(e,t){let n=new S,i=JSON.parse(JSON.stringify(this.parts)),r=i.pop();for(const e of i)n.add(e);let o=t.substr.substring(0,e-r.start),a=o.length;return n.add({start:r.start,end:r.start+a,length:a,substr:o}),n}}const O=e=>{var t;void 0===h&&(h=D(t||f)),e=w(e);let n="",i=[new S];for(let t=0;t0){s=s.sort(((e,t)=>e.length()-t.length()));for(let e of s)E(e,i)||i.push(e)}else if(t>0&&1==l.size&&!l.has("3")){n+=T(i,!1);let e=new S;const t=i[0];t&&e.add(t.last()),i=[e]}}return n+=T(i,!0),n},M=(e,t)=>{if(e)return e[t]},A=(e,t)=>{if(e){for(var n,i=t.split(".");(n=i.shift())&&(e=e[n]););return e}},I=(e,t,n)=>{var i,r;return e?(e+="",null==t.regex||-1===(r=e.search(t.regex))?0:(i=t.string.length/e.length,0===r&&(i+=.5),i*n)):0},_=(e,t)=>{var n=e[t];if("function"==typeof n)return n;n&&!Array.isArray(n)&&(e[t]=[n])},j=(e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)},L=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e(t=w(t+"").toLowerCase())?1:t>e?-1:0;class N{items;settings;constructor(e,t){this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,n){if(!e||!e.length)return[];const i=[],r=e.split(/\s+/);var o;return n&&(o=new RegExp("^("+Object.keys(n).map(c).join("|")+"):(.*)$")),r.forEach((e=>{let n,r=null,a=null;o&&(n=e.match(o))&&(r=n[1],e=n[2]),e.length>0&&(a=this.settings.diacritics?O(e)||null:c(e),a&&t&&(a="\\b"+a)),i.push({string:e,regex:a?new RegExp(a,"iu"):null,field:r})})),i}getScoreFunction(e,t){var n=this.prepareSearch(e,t);return this._getScoreFunction(n)}_getScoreFunction(e){const t=e.tokens,n=t.length;if(!n)return function(){return 0};const i=e.options.fields,r=e.weights,o=i.length,a=e.getAttrFn;if(!o)return function(){return 1};const s=1===o?function(e,t){const n=i[0].field;return I(a(t,n),e,r[n]||1)}:function(e,t){var n=0;if(e.field){const i=a(t,e.field);!e.regex&&i?n+=1/o:n+=I(i,e,1)}else j(r,((i,r)=>{n+=I(a(t,r),e,i)}));return n/o};return 1===n?function(e){return s(t[0],e)}:"and"===e.options.conjunction?function(e){var i,r=0;for(let n of t){if((i=s(n,e))<=0)return 0;r+=i}return r/n}:function(e){var i=0;return j(t,(t=>{i+=s(t,e)})),i/n}}getSortFunction(e,t){var n=this.prepareSearch(e,t);return this._getSortFunction(n)}_getSortFunction(e){var t,n=[];const i=this,r=e.options,o=!e.query&&r.sort_empty?r.sort_empty:r.sort;if("function"==typeof o)return o.bind(this);const a=function(t,n){return"$score"===t?n.score:e.getAttrFn(i.items[n.id],t)};if(o)for(let t of o)(e.query||"$score"!==t.field)&&n.push(t);if(e.query){t=!0;for(let e of n)if("$score"===e.field){t=!1;break}t&&n.unshift({field:"$score",direction:"desc"})}else n=n.filter((e=>"$score"!==e.field));return n.length?function(e,t){var i,r;for(let o of n){if(r=o.field,i=("desc"===o.direction?-1:1)*L(a(r,e),a(r,t)))return i}return 0}:null}prepareSearch(e,t){const n={};var i=Object.assign({},t);if(_(i,"sort"),_(i,"sort_empty"),i.fields){_(i,"fields");const e=[];i.fields.forEach((t=>{"string"==typeof t&&(t={field:t,weight:1}),e.push(t),n[t.field]="weight"in t?t.weight:1})),i.fields=e}return{options:i,query:e.toLowerCase().trim(),tokens:this.tokenize(e,i.respect_word_boundaries,n),total:0,items:[],weights:n,getAttrFn:i.nesting?A:M}}search(e,t){var n,i,r=this;i=this.prepareSearch(e,t),t=i.options,e=i.query;const o=t.score||r._getScoreFunction(i);e.length?j(r.items,((e,r)=>{n=o(e),(!1===t.filter||n>0)&&i.items.push({score:n,id:r})})):j(r.items,((e,t)=>{i.items.push({score:1,id:t})}));const a=r._getSortFunction(i);return a&&i.items.sort(a),i.total=i.items.length,"number"==typeof t.limit&&(i.items=i.items.slice(0,t.limit)),i}}const F=e=>null==e?null:P(e),P=e=>"boolean"==typeof e?e?"1":"0":e+"",H=e=>(e+"").replace(/&/g,"&").replace(//g,">").replace(/"/g,"""),q=(e,t)=>{var n;return function(i,r){var o=this;n&&(o.loading=Math.max(o.loading-1,0),clearTimeout(n)),n=setTimeout((function(){n=null,o.loadedSearches[i]=!0,e.call(o,i,r)}),t)}},R=(e,t,n)=>{var i,r=e.trigger,o={};for(i of(e.trigger=function(){var n=arguments[0];if(-1===t.indexOf(n))return r.apply(e,arguments);o[n]=arguments},n.apply(e,[]),e.trigger=r,t))i in o&&r.apply(e,o[i])},$=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},B=(e,t,n,i)=>{e.addEventListener(t,n,i)},Y=(e,t)=>!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0)),W=(e,t)=>{const n=e.getAttribute("id");return n||(e.setAttribute("id",t),t)},V=e=>e.replace(/[\\"']/g,"\\$&"),z=(e,t)=>{t&&e.append(t)},U=(e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)},K=e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(X(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)},X=e=>"string"==typeof e&&e.indexOf("<")>-1,J=(e,t)=>{var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!1),e.dispatchEvent(n)},G=(e,t)=>{Object.assign(e.style,t)},Q=(e,...t)=>{var n=ee(t);(e=te(e)).map((e=>{n.map((t=>{e.classList.add(t)}))}))},Z=(e,...t)=>{var n=ee(t);(e=te(e)).map((e=>{n.map((t=>{e.classList.remove(t)}))}))},ee=e=>{var t=[];return U(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\t\n\f\r\s]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},te=e=>(Array.isArray(e)||(e=[e]),e),ne=(e,t,n)=>{if(!n||n.contains(e))for(;e&&e.matches;){if(e.matches(t))return e;e=e.parentNode}},ie=(e,t=0)=>t>0?e[e.length-1]:e[0],re=(e,t)=>{if(!e)return-1;t=t||e.nodeName;for(var n=0;e=e.previousElementSibling;)e.matches(t)&&n++;return n},oe=(e,t)=>{U(t,((t,n)=>{null==t?e.removeAttribute(n):e.setAttribute(n,""+t)}))},ae=(e,t)=>{e.parentNode&&e.parentNode.replaceChild(t,e)},se=(e,t)=>{if(null===t)return;if("string"==typeof t){if(!t.length)return;t=new RegExp(t,"i")}const n=e=>3===e.nodeType?(e=>{var n=e.data.match(t);if(n&&e.data.length>0){var i=document.createElement("span");i.className="highlight";var r=e.splitText(n.index);r.splitText(n[0].length);var o=r.cloneNode(!0);return i.appendChild(o),ae(r,i),1}return 0})(e):((e=>{1!==e.nodeType||!e.childNodes||/(script|style)/i.test(e.tagName)||"highlight"===e.className&&"SPAN"===e.tagName||Array.from(e.childNodes).forEach((e=>{n(e)}))})(e),0);n(e)},le="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey",ce={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,refreshThrottle:300,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-wrapper",controlClass:"ts-control",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:'',copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}};function ue(e,t){var n=Object.assign({},ce,t),i=n.dataAttr,r=n.labelField,o=n.valueField,a=n.disabledField,s=n.optgroupField,l=n.optgroupLabelField,c=n.optgroupValueField,u=e.tagName.toLowerCase(),d=e.getAttribute("placeholder")||e.getAttribute("data-placeholder");if(!d&&!n.allowEmptyOption){let t=e.querySelector('option[value=""]');t&&(d=t.textContent)}var p={placeholder:d,options:[],optgroups:[],items:[],maxItems:null};return"select"===u?(()=>{var t,u=p.options,d={},f=1;let h=0;var g=e=>{var t=Object.assign({},e.dataset),n=i&&t[i];return"string"==typeof n&&n.length&&(t=Object.assign(t,JSON.parse(n))),t},m=(e,t)=>{var i=F(e.value);if(null!=i&&(i||n.allowEmptyOption)){if(d.hasOwnProperty(i)){if(t){var l=d[i][s];l?Array.isArray(l)?l.push(t):d[i][s]=[l,t]:d[i][s]=t}}else{var c=g(e);c[r]=c[r]||e.textContent,c[o]=c[o]||i,c[a]=c[a]||e.disabled,c[s]=c[s]||t,c.$option=e,c.$order=c.$order||++h,d[i]=c,u.push(c)}e.selected&&p.items.push(i)}};p.maxItems=e.hasAttribute("multiple")?null:1,U(e.children,(e=>{var n,i,r;"optgroup"===(t=e.tagName.toLowerCase())?((r=g(n=e))[l]=r[l]||n.getAttribute("label")||"",r[c]=r[c]||f++,r[a]=r[a]||n.disabled,r.$order=r.$order||++h,p.optgroups.push(r),i=r[c],U(n.children,(e=>{m(e,i)}))):"option"===t&&m(e)}))})():(()=>{const t=e.getAttribute(i);if(t)p.options=JSON.parse(t),U(p.options,(e=>{p.items.push(e[o])}));else{var a=e.value.trim()||"";if(!n.allowEmptyOption&&!a.length)return;const t=a.split(n.delimiter);U(t,(e=>{const t={};t[r]=e,t[o]=e,p.options.push(t)})),p.items=t}})(),Object.assign({},ce,p,t)}var de=0;class pe extends(function(e){return e.plugins={},class extends e{constructor(){super(...arguments),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(t,n){e.plugins[t]={name:t,fn:n}}initializePlugins(e){var t,n;const i=this,r=[];if(Array.isArray(e))e.forEach((e=>{"string"==typeof e?r.push(e):(i.plugins.settings[e.name]=e.options,r.push(e.name))}));else if(e)for(t in e)e.hasOwnProperty(t)&&(i.plugins.settings[t]=e[t],r.push(t));for(;n=r.shift();)i.require(n)}loadPlugin(t){var n=this,i=n.plugins,r=e.plugins[t];if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');i.requested[t]=!0,i.loaded[t]=r.fn.apply(n,[n.plugins.settings[t]||{}]),i.names.push(t)}require(e){var t=this,n=t.plugins;if(!t.plugins.loaded.hasOwnProperty(e)){if(n.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")');t.loadPlugin(e)}return n.loaded[e]}}}(r)){constructor(e,t){var n;super(),this.order=0,this.isOpen=!1,this.isDisabled=!1,this.isReadOnly=!1,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreHover=!1,this.hasOptions=!1,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],this.refreshTimeout=null,de++;var i=K(e);if(i.tomselect)throw new Error("Tom Select already initialized on this element");i.tomselect=this,n=(window.getComputedStyle&&window.getComputedStyle(i,null)).getPropertyValue("direction");const r=ue(i,t);this.settings=r,this.input=i,this.tabIndex=i.tabIndex||0,this.is_select_tag="select"===i.tagName.toLowerCase(),this.rtl=/rtl/i.test(n),this.inputId=W(i,"tomselect-"+de),this.isRequired=i.required,this.sifter=new N(this.options,{diacritics:r.diacritics}),r.mode=r.mode||(1===r.maxItems?"single":"multi"),"boolean"!=typeof r.hideSelected&&(r.hideSelected="multi"===r.mode),"boolean"!=typeof r.hidePlaceholder&&(r.hidePlaceholder="multi"!==r.mode);var o=r.createFilter;"function"!=typeof o&&("string"==typeof o&&(o=new RegExp(o)),o instanceof RegExp?r.createFilter=e=>o.test(e):r.createFilter=e=>this.settings.duplicates||!this.options[e]),this.initializePlugins(r.plugins),this.setupCallbacks(),this.setupTemplates();const a=K("
"),s=K("
"),l=this._render("dropdown"),c=K('
'),u=this.input.getAttribute("class")||"",d=r.mode;var p;if(Q(a,r.wrapperClass,u,d),Q(s,r.controlClass),z(a,s),Q(l,r.dropdownClass,d),r.copyClassesToDropdown&&Q(l,u),Q(c,r.dropdownContentClass),z(l,c),K(r.dropdownParent||a).appendChild(l),X(r.controlInput)){p=K(r.controlInput);U(["autocorrect","autocapitalize","autocomplete","spellcheck"],(e=>{i.getAttribute(e)&&oe(p,{[e]:i.getAttribute(e)})})),p.tabIndex=-1,s.appendChild(p),this.focus_node=p}else r.controlInput?(p=K(r.controlInput),this.focus_node=p):(p=K(""),this.focus_node=s);this.wrapper=a,this.dropdown=l,this.dropdown_content=c,this.control=s,this.control_input=p,this.setup()}setup(){const e=this,t=e.settings,n=e.control_input,i=e.dropdown,r=e.dropdown_content,o=e.wrapper,a=e.control,s=e.input,l=e.focus_node,u={passive:!0},d=e.inputId+"-ts-dropdown";oe(r,{id:d}),oe(l,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":d});const p=W(l,e.inputId+"-ts-control"),f="label[for='"+(e=>e.replace(/['"\\]/g,"\\$&"))(e.inputId)+"']",h=document.querySelector(f),g=e.focus.bind(e);if(h){B(h,"click",g),oe(h,{for:p});const t=W(h,e.inputId+"-ts-label");oe(l,{"aria-labelledby":t}),oe(r,{"aria-labelledby":t})}if(o.style.width=s.style.width,e.plugins.names.length){const t="plugin-"+e.plugins.names.join(" plugin-");Q([o,i],t)}(null===t.maxItems||t.maxItems>1)&&e.is_select_tag&&oe(s,{multiple:"multiple"}),t.placeholder&&oe(n,{placeholder:t.placeholder}),!t.splitOn&&t.delimiter&&(t.splitOn=new RegExp("\\s*"+c(t.delimiter)+"+\\s*")),t.load&&t.loadThrottle&&(t.load=q(t.load,t.loadThrottle)),B(i,"mousemove",(()=>{e.ignoreHover=!1})),B(i,"mouseenter",(t=>{var n=ne(t.target,"[data-selectable]",i);n&&e.onOptionHover(t,n)}),{capture:!0}),B(i,"click",(t=>{const n=ne(t.target,"[data-selectable]");n&&(e.onOptionSelect(t,n),$(t,!0))})),B(a,"click",(t=>{var i=ne(t.target,"[data-ts-item]",a);i&&e.onItemSelect(t,i)?$(t,!0):""==n.value&&(e.onClick(),$(t,!0))})),B(l,"keydown",(t=>e.onKeyDown(t))),B(n,"keypress",(t=>e.onKeyPress(t))),B(n,"input",(t=>e.onInput(t))),B(l,"blur",(t=>e.onBlur(t))),B(l,"focus",(t=>e.onFocus(t))),B(n,"paste",(t=>e.onPaste(t)));const m=t=>{const r=t.composedPath()[0];if(!o.contains(r)&&!i.contains(r))return e.isFocused&&e.blur(),void e.inputState();r==n&&e.isOpen?t.stopPropagation():$(t,!0)},v=()=>{e.isOpen&&e.positionDropdown()};B(document,"mousedown",m),B(window,"scroll",v,u),B(window,"resize",v,u),this._destroy=()=>{document.removeEventListener("mousedown",m),window.removeEventListener("scroll",v),window.removeEventListener("resize",v),h&&h.removeEventListener("click",g)},this.revertSettings={innerHTML:s.innerHTML,tabIndex:s.tabIndex},s.tabIndex=-1,s.insertAdjacentElement("afterend",e.wrapper),e.sync(!1),t.items=[],delete t.optgroups,delete t.options,B(s,"invalid",(()=>{e.isValid&&(e.isValid=!1,e.isInvalid=!0,e.refreshState())})),e.updateOriginalInput(),e.refreshItems(),e.close(!1),e.inputState(),e.isSetup=!0,s.disabled?e.disable():s.readOnly?e.setReadOnly(!0):e.enable(),e.on("change",this.onChange),Q(s,"tomselected","ts-hidden-accessible"),e.trigger("initialize"),!0===t.preload&&e.preload()}setupOptions(e=[],t=[]){this.addOptions(e),U(t,(e=>{this.registerOptionGroup(e)}))}setupTemplates(){var e=this,t=e.settings.labelField,n=e.settings.optgroupLabelField,i={optgroup:e=>{let t=document.createElement("div");return t.className="optgroup",t.appendChild(e.options),t},optgroup_header:(e,t)=>'
'+t(e[n])+"
",option:(e,n)=>"
"+n(e[t])+"
",item:(e,n)=>"
"+n(e[t])+"
",option_create:(e,t)=>'
Add '+t(e.input)+"
",no_results:()=>'
No results found
',loading:()=>'
',not_loading:()=>{},dropdown:()=>"
"};e.settings.render=Object.assign({},i,e.settings.render)}setupCallbacks(){var e,t,n={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",item_select:"onItemSelect",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(e in n)(t=this.settings[n[e]])&&this.on(e,t)}sync(e=!0){const t=this,n=e?ue(t.input,{delimiter:t.settings.delimiter}):t.settings;t.setupOptions(n.options,n.optgroups),t.setValue(n.items||[],!0),t.lastQuery=null}onClick(){var e=this;if(e.activeItems.length>0)return e.clearActiveItems(),void e.focus();e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){J(this.input,"input"),J(this.input,"change")}onPaste(e){var t=this;t.isInputHidden||t.isLocked?$(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue();if(e.match(t.settings.splitOn)){var n=e.trim().split(t.settings.splitOn);U(n,(e=>{F(e)&&(this.options[e]?t.addItem(e):t.createItem(e))}))}}),0)}onKeyPress(e){var t=this;if(!t.isLocked){var n=String.fromCharCode(e.keyCode||e.which);return t.settings.create&&"multi"===t.settings.mode&&n===t.settings.delimiter?(t.createItem(),void $(e)):void 0}$(e)}onKeyDown(e){var t=this;if(t.ignoreHover=!0,t.isLocked)9!==e.keyCode&&$(e);else{switch(e.keyCode){case 65:if(Y(le,e)&&""==t.control_input.value)return $(e),void t.selectAll();break;case 27:return t.isOpen&&($(e,!0),t.close()),void t.clearActiveItems();case 40:if(!t.isOpen&&t.hasOptions)t.open();else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1);e&&t.setActiveOption(e)}return void $(e);case 38:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1);e&&t.setActiveOption(e)}return void $(e);case 13:return void(t.canSelect(t.activeOption)?(t.onOptionSelect(e,t.activeOption),$(e)):(t.settings.create&&t.createItem()||document.activeElement==t.control_input&&t.isOpen)&&$(e));case 37:return void t.advanceSelection(-1,e);case 39:return void t.advanceSelection(1,e);case 9:return void(t.settings.selectOnTab&&(t.canSelect(t.activeOption)&&(t.onOptionSelect(e,t.activeOption),$(e)),t.settings.create&&t.createItem()&&$(e)));case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!Y(le,e)&&$(e)}}onInput(e){if(this.isLocked)return;const t=this.inputValue();this.lastValue!==t&&(this.lastValue=t,""!=t?(this.refreshTimeout&&window.clearTimeout(this.refreshTimeout),this.refreshTimeout=((e,t)=>t>0?window.setTimeout(e,t):(e.call(null),null))((()=>{this.refreshTimeout=null,this._onInput()}),this.settings.refreshThrottle)):this._onInput())}_onInput(){const e=this.lastValue;this.settings.shouldLoad.call(this,e)&&this.load(e),this.refreshOptions(),this.trigger("type",e)}onOptionHover(e,t){this.ignoreHover||this.setActiveOption(t,!1)}onFocus(e){var t=this,n=t.isFocused;if(t.isDisabled||t.isReadOnly)return t.blur(),void $(e);t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.preload(),n||t.trigger("focus"),t.activeItems.length||(t.inputState(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){if(!1!==document.hasFocus()){var t=this;if(t.isFocused){t.isFocused=!1,t.ignoreFocus=!1;var n=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")};t.settings.create&&t.settings.createOnBlur?t.createItem(null,n):n()}}}onOptionSelect(e,t){var n,i=this;t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?i.createItem(null,(()=>{i.settings.closeAfterSelect&&i.close()})):void 0!==(n=t.dataset.value)&&(i.lastQuery=null,i.addItem(n),i.settings.closeAfterSelect&&i.close(),!i.settings.hideSelected&&e.type&&/click/.test(e.type)&&i.setActiveOption(t)))}canSelect(e){return!!(this.isOpen&&e&&this.dropdown_content.contains(e))}onItemSelect(e,t){var n=this;return!n.isLocked&&"multi"===n.settings.mode&&($(e),n.setActiveItem(t,e),!0)}canLoad(e){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(e)}load(e){const t=this;if(!t.canLoad(e))return;Q(t.wrapper,t.settings.loadingClass),t.loading++;const n=t.loadCallback.bind(t);t.settings.load.call(t,e,n)}loadCallback(e,t){const n=this;n.loading=Math.max(n.loading-1,0),n.lastQuery=null,n.clearActiveOption(),n.setupOptions(e,t),n.refreshOptions(n.isFocused&&!n.isInputHidden),n.loading||Z(n.wrapper,n.settings.loadingClass),n.trigger("load",e,t)}preload(){var e=this.wrapper.classList;e.contains("preloaded")||(e.add("preloaded"),this.load(""))}setTextboxValue(e=""){var t=this.control_input;t.value!==e&&(t.value=e,J(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){R(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 n,i,r,o,a,s,l=this;if("single"!==l.settings.mode){if(!e)return l.clearActiveItems(),void(l.isFocused&&l.inputState());if("click"===(n=t&&t.type.toLowerCase())&&Y("shiftKey",t)&&l.activeItems.length){for(s=l.getLastActive(),(r=Array.prototype.indexOf.call(l.control.children,s))>(o=Array.prototype.indexOf.call(l.control.children,e))&&(a=r,r=o,o=a),i=r;i<=o;i++)e=l.control.children[i],-1===l.activeItems.indexOf(e)&&l.setActiveItemClass(e);$(t)}else"click"===n&&Y(le,t)||"keydown"===n&&Y("shiftKey",t)?e.classList.contains("active")?l.removeActiveItem(e):l.setActiveItemClass(e):(l.clearActiveItems(),l.setActiveItemClass(e));l.inputState(),l.isFocused||l.focus()}}setActiveItemClass(e){const t=this,n=t.control.querySelector(".last-active");n&&Z(n,"last-active"),Q(e,"active last-active"),t.trigger("item_select",e),-1==t.activeItems.indexOf(e)&&t.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e);this.activeItems.splice(t,1),Z(e,"active")}clearActiveItems(){Z(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e,t=!0){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,oe(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),oe(e,{"aria-selected":"true"}),Q(e,"active"),t&&this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return;const n=this.dropdown_content,i=n.clientHeight,r=n.scrollTop||0,o=e.offsetHeight,a=e.getBoundingClientRect().top-n.getBoundingClientRect().top+r;a+o>i+r?this.scroll(a-i+o,t):a{e.setActiveItemClass(t)})))}inputState(){var e=this;e.control.contains(e.control_input)&&(oe(e.control_input,{placeholder:e.settings.placeholder}),e.activeItems.length>0||!e.isFocused&&e.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0):(e.settings.hidePlaceholder&&e.items.length>0&&oe(e.control_input,{placeholder:""}),e.isInputHidden=!1),e.wrapper.classList.toggle("input-hidden",e.isInputHidden))}inputValue(){return this.control_input.value.trim()}focus(){var e=this;e.isDisabled||e.isReadOnly||(e.ignoreFocus=!0,e.control_input.offsetWidth?e.control_input.focus():e.focus_node.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e=this.settings,t=e.sortField;return"string"==typeof e.sortField&&(t=[{field:e.sortField}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}search(e){var t,n,i=this,r=this.getSearchOptions();if(i.settings.score&&"function"!=typeof(n=i.settings.score.call(i,e)))throw new Error('Tom Select "score" setting must be a function that returns a function');return e!==i.lastQuery?(i.lastQuery=e,t=i.sifter.search(e,Object.assign(r,{score:n})),i.currentResults=t):t=Object.assign({},i.currentResults),i.settings.hideSelected&&(t.items=t.items.filter((e=>{let t=F(e.id);return!(t&&-1!==i.items.indexOf(t))}))),t}refreshOptions(e=!0){var t,n,i,r,o,a,s,l,c,u;const d={},p=[];var f=this,h=f.inputValue();const g=h===f.lastQuery||""==h&&null==f.lastQuery;var m=f.search(h),v=null,y=f.settings.shouldOpen||!1,b=f.dropdown_content;g&&(v=f.activeOption)&&(c=v.closest("[data-group]")),r=m.items.length,"number"==typeof f.settings.maxOptions&&(r=Math.min(r,f.settings.maxOptions)),r>0&&(y=!0);const w=(e,t)=>{let n=d[e];if(void 0!==n){let e=p[n];if(void 0!==e)return[n,e.fragment]}let i=document.createDocumentFragment();return n=p.length,p.push({fragment:i,order:t,optgroup:e}),[n,i]};for(t=0;t0&&(u=u.cloneNode(!0),oe(u,{id:s.$id+"-clone-"+n,"aria-selected":null}),u.classList.add("ts-cloned"),Z(u,"active"),f.activeOption&&f.activeOption.dataset.value==r&&c&&c.dataset.group===o.toString()&&(v=u)),l.appendChild(u),""!=o&&(d[o]=i)}}var x;f.settings.lockOptgroupOrder&&p.sort(((e,t)=>e.order-t.order)),s=document.createDocumentFragment(),U(p,(e=>{let t=e.fragment,n=e.optgroup;if(!t||!t.children.length)return;let i=f.optgroups[n];if(void 0!==i){let e=document.createDocumentFragment(),n=f.render("optgroup_header",i);z(e,n),z(e,t);let r=f.render("optgroup",{group:i,options:e});z(s,r)}else z(s,t)})),b.innerHTML="",z(b,s),f.settings.highlight&&(x=b.querySelectorAll("span.highlight"),Array.prototype.forEach.call(x,(function(e){var t=e.parentNode;t.replaceChild(e.firstChild,e),t.normalize()})),m.query.length&&m.tokens.length&&U(m.tokens,(e=>{se(b,e.regex)})));var C=e=>{let t=f.render(e,{input:h});return t&&(y=!0,b.insertBefore(t,b.firstChild)),t};if(f.loading?C("loading"):f.settings.shouldLoad.call(f,h)?0===m.items.length&&C("no_results"):C("not_loading"),(l=f.canCreate(h))&&(u=C("option_create")),f.hasOptions=m.items.length>0||l,y){if(m.items.length>0){if(v||"single"!==f.settings.mode||null==f.items[0]||(v=f.getOption(f.items[0])),!b.contains(v)){let e=0;u&&!f.settings.addPrecedence&&(e=1),v=f.selectable()[e]}}else u&&(v=u);e&&!f.isOpen&&(f.open(),f.scrollToOption(v,"auto")),f.setActiveOption(v)}else f.clearActiveOption(),e&&f.isOpen&&f.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e,t=!1){const n=this;if(Array.isArray(e))return n.addOptions(e,t),!1;const i=F(e[n.settings.valueField]);return null!==i&&!n.options.hasOwnProperty(i)&&(e.$order=e.$order||++n.order,e.$id=n.inputId+"-opt-"+e.$order,n.options[i]=e,n.lastQuery=null,t&&(n.userOptions[i]=t,n.trigger("option_add",i,e)),i)}addOptions(e,t=!1){U(e,(e=>{this.addOption(e,t)}))}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=F(e[this.settings.optgroupValueField]);return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var n;t[this.settings.optgroupValueField]=e,(n=this.registerOptionGroup(t))&&this.trigger("optgroup_add",n,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){const n=this;var i,r;const o=F(e),a=F(t[n.settings.valueField]);if(null===o)return;const s=n.options[o];if(null==s)return;if("string"!=typeof a)throw new Error("Value must be set in option data");const l=n.getOption(o),c=n.getItem(o);if(t.$order=t.$order||s.$order,delete n.options[o],n.uncacheValue(a),n.options[a]=t,l){if(n.dropdown_content.contains(l)){const e=n._render("option",t);ae(l,e),n.activeOption===l&&n.setActiveOption(e)}l.remove()}c&&(-1!==(r=n.items.indexOf(o))&&n.items.splice(r,1,a),i=n._render("item",t),c.classList.contains("active")&&Q(i,"active"),ae(c,i)),n.lastQuery=null}removeOption(e,t){const n=this;e=P(e),n.uncacheValue(e),delete n.userOptions[e],delete n.options[e],n.lastQuery=null,n.trigger("option_remove",e),n.removeItem(e,t)}clearOptions(e){const t=(e||this.clearFilter).bind(this);this.loadedSearches={},this.userOptions={},this.clearCache();const n={};U(this.options,((e,i)=>{t(e,i)&&(n[i]=e)})),this.options=this.sifter.items=n,this.lastQuery=null,this.trigger("option_clear")}clearFilter(e,t){return this.items.indexOf(t)>=0}getOption(e,t=!1){const n=F(e);if(null===n)return null;const i=this.options[n];if(null!=i){if(i.$div)return i.$div;if(t)return this._render("option",i)}return null}getAdjacent(e,t,n="option"){var i;if(!e)return null;i="item"==n?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]");for(let n=0;n0?i[n+1]:i[n-1];return null}getItem(e){if("object"==typeof e)return e;var t=F(e);return null!==t?this.control.querySelector(`[data-value="${V(t)}"]`):null}addItems(e,t){var n=this,i=Array.isArray(e)?e:[e];const r=(i=i.filter((e=>-1===n.items.indexOf(e))))[i.length-1];i.forEach((e=>{n.isPending=e!==r,n.addItem(e,t)}))}addItem(e,t){R(this,t?[]:["change","dropdown_close"],(()=>{var n,i;const r=this,o=r.settings.mode,a=F(e);if((!a||-1===r.items.indexOf(a)||("single"===o&&r.close(),"single"!==o&&r.settings.duplicates))&&null!==a&&r.options.hasOwnProperty(a)&&("single"===o&&r.clear(t),"multi"!==o||!r.isFull())){if(n=r._render("item",r.options[a]),r.control.contains(n)&&(n=n.cloneNode(!0)),i=r.isFull(),r.items.splice(r.caretPos,0,a),r.insertAtCaret(n),r.isSetup){if(!r.isPending&&r.settings.hideSelected){let e=r.getOption(a),t=r.getAdjacent(e,1);t&&r.setActiveOption(t)}r.isPending||r.settings.closeAfterSelect||r.refreshOptions(r.isFocused&&"single"!==o),0!=r.settings.closeAfterSelect&&r.isFull()?r.close():r.isPending||r.positionDropdown(),r.trigger("item_add",a,n),r.isPending||r.updateOriginalInput({silent:t})}(!r.isPending||!i&&r.isFull())&&(r.inputState(),r.refreshState())}}))}removeItem(e=null,t){const n=this;if(!(e=n.getItem(e)))return;var i,r;const o=e.dataset.value;i=re(e),e.remove(),e.classList.contains("active")&&(r=n.activeItems.indexOf(e),n.activeItems.splice(r,1),Z(e,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(o)&&n.removeOption(o,t),i{}){3===arguments.length&&(t=arguments[2]),"function"!=typeof t&&(t=()=>{});var n,i=this,r=i.caretPos;if(e=e||i.inputValue(),!i.canCreate(e))return t(),!1;i.lock();var o=!1,a=e=>{if(i.unlock(),!e||"object"!=typeof e)return t();var n=F(e[i.settings.valueField]);if("string"!=typeof n)return t();i.setTextboxValue(),i.addOption(e,!0),i.setCaret(r),i.addItem(n),t(e),o=!0};return n="function"==typeof i.settings.create?i.settings.create.call(this,e,a):{[i.settings.labelField]:e,[i.settings.valueField]:e},o||a(n),!0}refreshItems(){var e=this;e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){const e=this;e.refreshValidityState();const t=e.isFull(),n=e.isLocked;e.wrapper.classList.toggle("rtl",e.rtl);const i=e.wrapper.classList;var r;i.toggle("focus",e.isFocused),i.toggle("disabled",e.isDisabled),i.toggle("readonly",e.isReadOnly),i.toggle("required",e.isRequired),i.toggle("invalid",!e.isValid),i.toggle("locked",n),i.toggle("full",t),i.toggle("input-active",e.isFocused&&!e.isInputHidden),i.toggle("dropdown-active",e.isOpen),i.toggle("has-options",(r=e.options,0===Object.keys(r).length)),i.toggle("has-items",e.items.length>0)}refreshValidityState(){var e=this;e.input.validity&&(e.isValid=e.input.validity.valid,e.isInvalid=!e.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){const t=this;var n,i;const r=t.input.querySelector('option[value=""]');if(t.is_select_tag){const o=[],a=t.input.querySelectorAll("option:checked").length;function s(e,n,i){return e||(e=K('")),e!=r&&t.input.append(e),o.push(e),(e!=r||a>0)&&(e.selected=!0),e}t.input.querySelectorAll("option:checked").forEach((e=>{e.selected=!1})),0==t.items.length&&"single"==t.settings.mode?s(r,"",""):t.items.forEach((e=>{if(n=t.options[e],i=n[t.settings.labelField]||"",o.includes(n.$option)){s(t.input.querySelector(`option[value="${V(e)}"]:not(:checked)`),e,i)}else n.$option=s(n.$option,e,i)}))}else t.input.value=t.getValue();t.isSetup&&(e.silent||t.trigger("change",t.getValue()))}open(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,oe(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),G(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),G(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,n=t.isOpen;e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.inputState()),t.isOpen=!1,oe(t.focus_node,{"aria-expanded":"false"}),G(t.dropdown,{display:"none"}),t.settings.hideSelected&&t.clearActiveOption(),t.refreshState(),n&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),n=e.offsetHeight+t.top+window.scrollY,i=t.left+window.scrollX;G(this.dropdown,{width:t.width+"px",top:n+"px",left:i+"px"})}}clear(e){var t=this;if(t.items.length){var n=t.controlChildren();U(n,(e=>{t.removeItem(e,!0)})),t.inputState(),e||t.updateOriginalInput(),t.trigger("clear")}}insertAtCaret(e){const t=this,n=t.caretPos,i=t.control;i.insertBefore(e,i.children[n]||null),t.setCaret(n+1)}deleteSelection(e){var t,n,i,r,o,a=this;t=e&&8===e.keyCode?-1:1,n={start:(o=a.control_input).selectionStart||0,length:(o.selectionEnd||0)-(o.selectionStart||0)};const s=[];if(a.activeItems.length)r=ie(a.activeItems,t),i=re(r),t>0&&i++,U(a.activeItems,(e=>s.push(e)));else if((a.isFocused||"single"===a.settings.mode)&&a.items.length){const e=a.controlChildren();let i;t<0&&0===n.start&&0===n.length?i=e[a.caretPos-1]:t>0&&n.start===a.inputValue().length&&(i=e[a.caretPos]),void 0!==i&&s.push(i)}if(!a.shouldDelete(s,e))return!1;for($(e,!0),void 0!==i&&a.setCaret(i);s.length;)a.removeItem(s.pop());return a.inputState(),a.positionDropdown(),a.refreshOptions(!1),!0}shouldDelete(e,t){const n=e.map((e=>e.dataset.value));return!(!n.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete(n,t))}advanceSelection(e,t){var n,i,r=this;r.rtl&&(e*=-1),r.inputValue().length||(Y(le,t)||Y("shiftKey",t)?(i=(n=r.getLastActive(e))?n.classList.contains("active")?r.getAdjacent(n,e,"item"):n:e>0?r.control_input.nextElementSibling:r.control_input.previousElementSibling)&&(i.classList.contains("active")&&r.removeActiveItem(n),r.setActiveItemClass(i)):r.moveCaret(e))}moveCaret(e){}getLastActive(e){let t=this.control.querySelector(".last-active");if(t)return t;var n=this.control.querySelectorAll(".active");return n?ie(n,e):void 0}setCaret(e){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.setLocked(!0)}unlock(){this.setLocked(!1)}setLocked(e=this.isReadOnly||this.isDisabled){this.isLocked=e,this.refreshState()}disable(){this.setDisabled(!0),this.close()}enable(){this.setDisabled(!1)}setDisabled(e){this.focus_node.tabIndex=e?-1:this.tabIndex,this.isDisabled=e,this.input.disabled=e,this.control_input.disabled=e,this.setLocked()}setReadOnly(e){this.isReadOnly=e,this.input.readOnly=e,this.control_input.readOnly=e,this.setLocked()}destroy(){var e=this,t=e.revertSettings;e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,Z(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){var n,i;const r=this;if("function"!=typeof this.settings.render[e])return null;if(!(i=r.settings.render[e].call(this,t,H)))return null;if(i=K(i),"option"===e||"option_create"===e?t[r.settings.disabledField]?oe(i,{"aria-disabled":"true"}):oe(i,{"data-selectable":""}):"optgroup"===e&&(n=t.group[r.settings.optgroupValueField],oe(i,{"data-group":n}),t.group[r.settings.disabledField]&&oe(i,{"data-disabled":""})),"option"===e||"item"===e){const n=P(t[r.settings.valueField]);oe(i,{"data-value":n}),"item"===e?(Q(i,r.settings.itemClass),oe(i,{"data-ts-item":""})):(Q(i,r.settings.optionClass),oe(i,{role:"option",id:t.$id}),t.$div=i,r.options[n]=t)}return i}_render(e,t){const n=this.render(e,t);if(null==n)throw"HTMLElement expected";return n}clearCache(){U(this.options,(e=>{e.$div&&(e.$div.remove(),delete e.$div)}))}uncacheValue(e){const t=this.getOption(e);t&&t.remove()}canCreate(e){return this.settings.create&&e.length>0&&this.settings.createFilter.call(this,e)}hook(e,t,n){var i=this,r=i[t];i[t]=function(){var t,o;return"after"===e&&(t=r.apply(i,arguments)),o=n.apply(i,arguments),"instead"===e?o:("before"===e&&(t=r.apply(i,arguments)),t)}}}const fe=e=>"boolean"==typeof e?e?"1":"0":e+"",he=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},ge=e=>"string"==typeof e&&e.indexOf("<")>-1;const me=e=>"string"==typeof e&&e.indexOf("<")>-1;const ve=(e,t,n,i)=>{e.addEventListener(t,n,i)},ye=e=>"string"==typeof e&&e.indexOf("<")>-1,be=(e,t)=>{((e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)})(t,((t,n)=>{null==t?e.removeAttribute(n):e.setAttribute(n,""+t)}))};const we=e=>"string"==typeof e&&e.indexOf("<")>-1;const xe=e=>{var t=[];return((e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)})(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\t\n\f\r\s]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},Ce=e=>(Array.isArray(e)||(e=[e]),e);const De=e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(ke(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)},ke=e=>"string"==typeof e&&e.indexOf("<")>-1,Te=e=>{var t=[];return((e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)})(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\t\n\f\r\s]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},Ee=e=>(Array.isArray(e)||(e=[e]),e);const Se=(e,t,n,i)=>{e.addEventListener(t,n,i)};const Oe=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},Me=(e,t,n,i)=>{e.addEventListener(t,n,i)},Ae=e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(Ie(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)},Ie=e=>"string"==typeof e&&e.indexOf("<")>-1;const _e=e=>{var t=[];return((e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)})(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\t\n\f\r\s]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},je=e=>(Array.isArray(e)||(e=[e]),e);pe.define("change_listener",(function(){var e,t,n,i;e=this.input,t="change",n=()=>{this.sync()},e.addEventListener(t,n,i)})),pe.define("checkbox_options",(function(e){var t=this,n=t.onOptionSelect;t.settings.hideSelected=!1;const i=Object.assign({className:"tomselect-checkbox",checkedClassNames:void 0,uncheckedClassNames:void 0},e);var r=function(e,t){t?(e.checked=!0,i.uncheckedClassNames&&e.classList.remove(...i.uncheckedClassNames),i.checkedClassNames&&e.classList.add(...i.checkedClassNames)):(e.checked=!1,i.checkedClassNames&&e.classList.remove(...i.checkedClassNames),i.uncheckedClassNames&&e.classList.add(...i.uncheckedClassNames))},o=function(e){setTimeout((()=>{var t=e.querySelector("input."+i.className);t instanceof HTMLInputElement&&r(t,e.classList.contains("selected"))}),1)};t.hook("after","setupTemplates",(()=>{var e=t.settings.render.option;t.settings.render.option=(n,o)=>{var a=(e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(ge(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)})(e.call(t,n,o)),s=document.createElement("input");i.className&&s.classList.add(i.className),s.addEventListener("click",(function(e){he(e)})),s.type="checkbox";const l=null==(c=n[t.settings.valueField])?null:fe(c);var c;return r(s,!!(l&&t.items.indexOf(l)>-1)),a.prepend(s),a}})),t.on("item_remove",(e=>{var n=t.getOption(e);n&&(n.classList.remove("selected"),o(n))})),t.on("item_add",(e=>{var n=t.getOption(e);n&&o(n)})),t.hook("instead","onOptionSelect",((e,i)=>{if(i.classList.contains("selected"))return i.classList.remove("selected"),t.removeItem(i.dataset.value),t.refreshOptions(),void he(e,!0);n.call(t,e,i),o(i)}))})),pe.define("clear_button",(function(e){const t=this,n=Object.assign({className:"clear-button",title:"Clear All",html:e=>`
`},e);t.on("initialize",(()=>{var e=(e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(me(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)})(n.html(n));e.addEventListener("click",(e=>{t.isLocked||(t.clear(),"single"===t.settings.mode&&t.settings.allowEmptyOption&&t.addItem(""),e.preventDefault(),e.stopPropagation())})),t.control.appendChild(e)}))})),pe.define("drag_drop",(function(){var e=this;if("multi"!==e.settings.mode)return;var t=e.lock,n=e.unlock;let i,r=!0;e.hook("after","setupTemplates",(()=>{var t=e.settings.render.item;e.settings.render.item=(n,o)=>{const a=(e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(ye(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)})(t.call(e,n,o));be(a,{draggable:"true"});const s=e=>{e.preventDefault(),a.classList.add("ts-drag-over"),l(a,i)},l=(e,t)=>{var n,i,r;void 0!==t&&(((e,t)=>{do{var n;if(e==(t=null==(n=t)?void 0:n.previousElementSibling))return!0}while(t&&t.previousElementSibling);return!1})(t,a)?(i=t,null==(r=(n=e).parentNode)||r.insertBefore(i,n.nextSibling)):((e,t)=>{var n;null==(n=e.parentNode)||n.insertBefore(t,e)})(e,t))};return ve(a,"mousedown",(e=>{r||((e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())})(e),e.stopPropagation()})),ve(a,"dragstart",(e=>{i=a,setTimeout((()=>{a.classList.add("ts-dragging")}),0)})),ve(a,"dragenter",s),ve(a,"dragover",s),ve(a,"dragleave",(()=>{a.classList.remove("ts-drag-over")})),ve(a,"dragend",(()=>{var t;document.querySelectorAll(".ts-drag-over").forEach((e=>e.classList.remove("ts-drag-over"))),null==(t=i)||t.classList.remove("ts-dragging"),i=void 0;var n=[];e.control.querySelectorAll("[data-value]").forEach((e=>{if(e.dataset.value){let t=e.dataset.value;t&&n.push(t)}})),e.setValue(n)})),a}})),e.hook("instead","lock",(()=>(r=!1,t.call(e)))),e.hook("instead","unlock",(()=>(r=!0,n.call(e))))})),pe.define("dropdown_header",(function(e){const t=this,n=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:e=>'
'+e.title+'×
'},e);t.on("initialize",(()=>{var e=(e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(we(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)})(n.html(n)),i=e.querySelector("."+n.closeClass);i&&i.addEventListener("click",(e=>{((e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())})(e,!0),t.close()})),t.dropdown.insertBefore(e,t.dropdown.firstChild)}))})),pe.define("caret_position",(function(){var e=this;e.hook("instead","setCaret",(t=>{"single"!==e.settings.mode&&e.control.contains(e.control_input)?(t=Math.max(0,Math.min(e.items.length,t)))==e.caretPos||e.isPending||e.controlChildren().forEach(((n,i)=>{i{if(!e.isFocused)return;const n=e.getLastActive(t);if(n){const i=((e,t)=>{if(!e)return-1;t=t||e.nodeName;for(var n=0;e=e.previousElementSibling;)e.matches(t)&&n++;return n})(n);e.setCaret(t>0?i+1:i),e.setActiveItem(),((e,...t)=>{var n=xe(t);(e=Ce(e)).map((e=>{n.map((t=>{e.classList.remove(t)}))}))})(n,"last-active")}else e.setCaret(e.caretPos+t)}))})),pe.define("dropdown_input",(function(){const e=this;e.settings.shouldOpen=!0,e.hook("before","setup",(()=>{e.focus_node=e.control,((e,...t)=>{var n=Te(t);(e=Ee(e)).map((e=>{n.map((t=>{e.classList.add(t)}))}))})(e.control_input,"dropdown-input");const t=De('