@referralgps/selectra 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! Selectra v1.0.7 | Apache-2.0 License */
1
+ /*! Selectra v1.0.9 | Apache-2.0 License */
2
2
  const DIACRITICS = {
3
3
  a: "[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",
4
4
  b: "[b␢βΒB฿𐌁ᛒ]",
@@ -1448,7 +1448,7 @@ function SelectraPlugin(Alpine) {
1448
1448
  }
1449
1449
  });
1450
1450
  }
1451
- SelectraPlugin.version = "1.0.7";
1451
+ SelectraPlugin.version = "1.0.9";
1452
1452
  SelectraPlugin.template = SELECTRA_TEMPLATE;
1453
1453
  export {
1454
1454
  DEFAULTS,
@@ -1,4 +1,4 @@
1
- var Selectra=function(e){"use strict";/*! Selectra v1.0.7 | Apache-2.0 License */const t={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",o:"[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]",p:"[pṔṕṖṗⱣᵽƤƥᵱ]",q:"[qꝖꝗʠɊɋꝘꝙq̃]",r:"[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]",s:"[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]",t:"[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]",u:"[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]",v:"[vṼṽṾṿƲʋꝞꝟⱱʋ]",w:"[wẂẃẀẁŴŵẄẅẆẇẈẉ]",x:"[xẌẍẊẋχ]",y:"[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]",z:"[zŹźẐẑŽžŻżẒẓẔẕƵƶ]"},i=(()=>{const e={};let i="";for(const n in t){const s=t[n].substring(2,t[n].length-1);i+=s;for(let t=0;t<s.length;t++)e[s.charAt(t)]=n}const s=new RegExp("["+i+"]","g");return t=>t.replace(s,t=>e[t]||"").toLowerCase()})();function s(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function n(e,t,i){if(!e||!t)return;if(!i)return e[t];const s=t.split(".");let n=e;for(;s.length&&n;)n=n[s.shift()];return n}function o(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=i(String(e||"")))>(t=i(String(t||"")))?1:t>e?-1:0}class r{constructor(e,t={}){this.items=e,this.settings={diacritics:!0,...t}}tokenize(e,i){if(!(e=String(e||"").toLowerCase().trim()).length)return[];const n=[],o=e.split(/\s+/);for(const r of o){let e=s(r);if(this.settings.diacritics)for(const i in t)e=e.replace(new RegExp(i,"g"),t[i]);i&&(e="\\b"+e),n.push({string:r,regex:new RegExp(e,"i")})}return n}getScoreFunction(e,t){e=this.prepareSearch(e,t);const{tokens:i}=e,{fields:s}=e.options,o=i.length,{nesting:r}=e.options,l=(e,t)=>{if(!e)return 0;const i=(e=String(e||"")).search(t.regex);if(-1===i)return 0;let s=t.string.length/e.length;return 0===i&&(s+=.5),s},c=s.length,h=0===c?()=>0:1===c?(e,t)=>l(n(t,s[0],r),e):(e,t)=>{let i=0;for(let o=0;o<c;o++)i+=l(n(t,s[o],r),e);return i/c};return o?1===o?e=>h(i[0],e):"and"===e.options.conjunction?e=>{let t=0;for(let s=0;s<o;s++){const n=h(i[s],e);if(n<=0)return 0;t+=n}return t/o}:e=>{let t=0;for(let s=0;s<o;s++)t+=h(i[s],e);return t/o}:()=>0}getSortFunction(e,t){const i=!(e=this.prepareSearch(e,t)).query&&t.sort_empty||t.sort,s=(e,i)=>"$score"===e?i.score:n(this.items[i.id],e,t.nesting),r=[];if(i)for(const n of i)(e.query||"$score"!==n.field)&&r.push(n);if(e.query){let e=!0;for(const t of r)if("$score"===t.field){e=!1;break}e&&r.unshift({field:"$score",direction:"desc"})}else{const e=r.findIndex(e=>"$score"===e.field);-1!==e&&r.splice(e,1)}const l=r.map(e=>"desc"===e.direction?-1:1),c=r.length;if(!c)return null;if(1===c){const e=r[0].field,t=l[0];return(i,n)=>t*o(s(e,i),s(e,n))}return(e,t)=>{for(let i=0;i<c;i++){const n=l[i]*o(s(r[i].field,e),s(r[i].field,t));if(n)return n}return 0}}prepareSearch(e,t){return"object"==typeof e?e:((t={...t}).fields&&!Array.isArray(t.fields)&&(t.fields=[t.fields]),t.sort&&!Array.isArray(t.sort)&&(t.sort=[t.sort]),t.sort_empty&&!Array.isArray(t.sort_empty)&&(t.sort_empty=[t.sort_empty]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t.respect_word_boundaries),total:0,items:[]})}search(e,t){const i=this.prepareSearch(e,t),s=i.options,n=i.query,o=s.score||this.getScoreFunction(i),r=this.items;if(n.length){(Array.isArray(r)?e=>r.forEach((t,i)=>e(t,i)):e=>Object.keys(r).forEach(t=>e(r[t],t)))((e,t)=>{const n=o(e);(!1===s.filter||n>0)&&i.items.push({score:n,id:t})})}else{(Array.isArray(r)?e=>r.forEach((t,i)=>e(t,i)):e=>Object.keys(r).forEach(t=>e(r[t],t)))((e,t)=>{i.items.push({score:1,id:t})})}const l=this.getSortFunction(i,s);return l&&i.items.sort(l),i.total=i.items.length,"number"==typeof s.limit&&(i.items=i.items.slice(0,s.limit)),i}}function l(e){return"string"!=typeof e?"":e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let c,h=0;function a(e){return null==e?null:"boolean"==typeof e?e?"1":"0":String(e)}function d(e,t=10){const i=function(e,t){c||(c=document.createElement("canvas"));const i=c.getContext("2d");if(t){const e=window.getComputedStyle(t);i.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`}return i.measureText(e).width}(e.value||e.placeholder||"",e)+t;e.style.width=Math.max(i,60)+"px"}function u(e){return e.tagName&&"select"===e.tagName.toLowerCase()}const p={delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,showAddOptionOnCreate:!0,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1e3,maxItems:null,hideSelected:null,selectOnTab:!0,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,loadThrottle:300,loadingClass:"loading",placeholder:"",dropdownPlaceholder:"",mode:null,search:!0,showArrow:!0,showSelectedCount:!1,valueField:"value",labelField:"text",disabledField:"disabled",optgroupField:"optgroup",optgroupLabelField:"label",optgroupValueField:"value",sortField:"$order",searchField:["text"],searchConjunction:"and",respectWordBoundaries:!1,normalize:!0,plugins:[],render:{option:null,item:null,optionCreate:null,optgroupHeader:null,noResults:null,dropdownPlaceholder:null,loading:null},load:null,score:null,onChange:null,onItemAdd:null,onItemRemove:null,onClear:null,onOptionAdd:null,onOptionRemove:null,onDropdownOpen:null,onDropdownClose:null,onType:null,onFocus:null,onBlur:null,onInitialize:null},f={};function g(e={}){return()=>({isOpen:!1,isFocused:!1,isDisabled:!1,isLocked:!1,isLoading:!1,isInvalid:!1,query:"",activeIndex:-1,caretPos:0,items:[],options:{},optgroups:{},userOptions:{},optionOrder:[],loadedSearches:{},lastQuery:"",_config:{},_sifter:null,_sourceEl:null,_id:"",_rtl:!1,_plugins:[],_renderCache:{},get config(){return this._config},get isMultiple(){return"multi"===this._config.mode},get isSingle(){return"single"===this._config.mode},get isFull(){return null!==this._config.maxItems&&this.items.length>=this._config.maxItems},get hasOptions(){return Object.keys(this.options).length>0},get canCreate(){if(!this._config.create)return!1;if(!this.query.trim())return!1;if(this.isFull)return!1;if(this._config.createFilter){const e=this._config.createFilter;if("function"==typeof e)return e(this.query);if(e instanceof RegExp)return e.test(this.query);if("string"==typeof e)return new RegExp(e).test(this.query)}return!Object.values(this.options).find(e=>{var t;return(null==(t=e[this._config.labelField])?void 0:t.toLowerCase())===this.query.toLowerCase()})},get selectedItems(){return this.items.map(e=>this.options[a(e)]).filter(Boolean)},get filteredOptions(){return this._getFilteredOptions()},get placeholderText(){return this.items.length>0&&this.isSingle?"":this._config.placeholder||""},get selectedCountText(){return this.items.length},get currentValueText(){if(!this.isSingle||!this.items.length)return"";const e=this.options[a(this.items[0])];return e?e[this._config.labelField]:""},init(){if(this._id=function(e="selectize"){return`${e}-${++h}-${Math.random().toString(36).slice(2,8)}`}(),this._config={...p,...e},this._sourceEl=this.$el.querySelector('select, input[type="text"], input[type="hidden"]'),this._sourceEl&&u(this._sourceEl)){const i=function(e){const t=[],i=[],s=[],n=(e,i=null)=>{const n=e.value,o=e.textContent.trim(),r=e.disabled;if(!n&&!o)return;const l={value:n,text:o,disabled:r};if(e.dataset.data)try{Object.assign(l,JSON.parse(e.dataset.data))}catch(c){}null!==i&&(l.optgroup=i),e.selected&&s.push(n),t.push(l)};for(const o of e.children)if("optgroup"===o.tagName.toLowerCase()){const e=o.getAttribute("label")||"";i.push({value:e,label:e,disabled:o.disabled});for(const t of o.children)n(t,e)}else"option"===o.tagName.toLowerCase()&&n(o);return{options:t,optgroups:i,selectedValues:s}}(this._sourceEl),s=i.options.find(e=>""===e.value);s&&!this._config.placeholder&&(this._config.placeholder=s.text);const n=i.selectedValues.filter(e=>""!==e),o=this._config.options||[],r=[...i.options,...o];this._registerOptions(r);for(const e of i.optgroups)this.optgroups[e.value]=e;n.length&&(this.items=[...n]),e.mode||(this._config.mode=this._sourceEl.multiple?"multi":"single"),this._sourceEl.hasAttribute("required")&&(this.isInvalid=!this.items.length),this._sourceEl.disabled&&(this.isDisabled=!0),this._sourceEl.placeholder&&(this._config.placeholder=this._sourceEl.placeholder),this._sourceEl.style.display="none",this._sourceEl.setAttribute("tabindex","-1"),this._rtl=(t=this._sourceEl,"rtl"===window.getComputedStyle(t).direction)}else{const e=this._config.options||[];if(this._registerOptions(e),this._config.optgroups)for(const t of this._config.optgroups)this.optgroups[t[this._config.optgroupValueField]]=t;this._config.items&&(this.items=[...this._config.items])}var t;this._config.mode||(this._config.mode=1===this._config.maxItems?"single":"multi"),"single"===this._config.mode&&(this._config.maxItems=1),null===this._config.hideSelected&&(this._config.hideSelected="multi"===this._config.mode&&!this._config.showSelectedCount),this._config.showSelectedCount&&(this._config.hideSelected=!1),this._sifter=new r(this.options,{diacritics:this._config.diacritics}),this._initPlugins(),this._config.load&&this._config.loadThrottle&&(this._debouncedLoad=function(e,t){let i;return function(...s){clearTimeout(i),i=setTimeout(()=>e.apply(this,s),t)}}(this._performLoad.bind(this),this._config.loadThrottle)),this._config.preload&&this.$nextTick(()=>{"focus"===this._config.preload||this._performLoad("")}),this._trigger("onInitialize"),this._onClickOutside=e=>{this.$el.contains(e.target)||(this.close(),this.blur())},document.addEventListener("mousedown",this._onClickOutside)},destroy(){document.removeEventListener("mousedown",this._onClickOutside),this._sourceEl&&(this._sourceEl.style.display="",this._sourceEl.removeAttribute("tabindex"))},_initPlugins(){const e=this._config.plugins||[];for(const t of e){const e="string"==typeof t?t:t.name,i="string"==typeof t?{}:t.options||{};f[e]?(f[e].call(this,i),this._plugins.push(e)):console.warn(`[selectize] Plugin "${e}" not found.`)}},_registerOptions(e){for(const t of e)this.addOption(t,!0)},addOption(e,t=!1){if(Array.isArray(e)){for(const i of e)this.addOption(i,t);return}const i=a(e[this._config.valueField]);null===i||this.options[i]||(e.$order=e.$order||++this._orderCounter||(this._orderCounter=1),this.options[i]=e,this.optionOrder.push(i),this._sifter&&(this._sifter.items=this.options),this._clearRenderCache(),t||this._trigger("onOptionAdd",i,e))},updateOption(e,t){const i=a(e);if(!i||!this.options[i])return;const s=a(t[this._config.valueField]);if(t.$order=this.options[i].$order,this.options[s]=t,i!==s){delete this.options[i];const e=this.optionOrder.indexOf(i);-1!==e&&(this.optionOrder[e]=s);const t=this.items.indexOf(i);-1!==t&&(this.items[t]=s)}this._sifter&&(this._sifter.items=this.options),this._clearRenderCache()},removeOption(e){const t=a(e);if(!t)return;delete this.options[t],delete this.userOptions[t];const i=this.optionOrder.indexOf(t);-1!==i&&this.optionOrder.splice(i,1),this.items=this.items.filter(e=>e!==t),this._sifter&&(this._sifter.items=this.options),this._clearRenderCache(),this._trigger("onOptionRemove",t)},clearOptions(){const e={};for(const t of this.items)this.options[t]&&(e[t]=this.options[t]);this.options=e,this.optionOrder=Object.keys(e),this.userOptions={},this._sifter&&(this._sifter.items=this.options),this._clearRenderCache()},getOption(e){return this.options[a(e)]||null},addItem(e,t=!1){const i=a(e);i&&this.options[i]&&(this.items.includes(i)||(this.isSingle&&this.items.length&&this.removeItem(this.items[0],!0),this.isFull||(this.items.push(i),this.caretPos=this.items.length,this._syncSourceElement(),this._clearRenderCache(),this.query="",(this._config.closeAfterSelect||this.isSingle)&&this.close(),this.isFull&&this.close(),t||(this._trigger("onItemAdd",i,this.options[i]),this._trigger("onChange",this.getValue())))))},removeItem(e,t=!1){const i=a(e),s=this.items.indexOf(i);-1!==s&&(this.items.splice(s,1),this.caretPos>this.items.length&&(this.caretPos=this.items.length),this._syncSourceElement(),this._clearRenderCache(),t||(this._trigger("onItemRemove",i),this._trigger("onChange",this.getValue())))},clear(e=!1){this.items.length&&(this.items=[],this.caretPos=0,this._syncSourceElement(),this._clearRenderCache(),e||(this._trigger("onClear"),this._trigger("onChange",this.getValue())))},getValue(){return this.isSingle?this.items.length?this.items[0]:"":[...this.items]},setValue(e,t=!1){this.clear(!0);const i=Array.isArray(e)?e:[e];for(const s of i)""!==s&&null!=s&&this.addItem(s,!0);t||this._trigger("onChange",this.getValue())},createItem(e=null){const t=null!==e?e:this.query;if(!t.trim())return;if(!this._config.create)return;const i=this._config.create;let s;"function"==typeof i?(s=i(t,e=>{e&&(this.addOption(e),this.addItem(e[this._config.valueField]))}),s&&"object"==typeof s&&(this.addOption(s),this.addItem(s[this._config.valueField]))):(s={},s[this._config.valueField]=t,s[this._config.labelField]=t,this.addOption(s),this.addItem(t)),this.query="",this._clearRenderCache()},_getFilteredOptions(){const e=this._config;if(!this._sifter)return[];const t=Array.isArray(e.searchField)?e.searchField:[e.searchField];let i;i=e.sortField?"string"==typeof e.sortField?[{field:e.sortField,direction:"asc"}]:Array.isArray(e.sortField)?e.sortField:[e.sortField]:[{field:"$order",direction:"asc"}];let s=this.query;e.normalize&&s&&(s=s.normalize("NFD").replace(/[\u0300-\u036f]/g,""));const n={fields:t,conjunction:e.searchConjunction,sort:i,nesting:t.some(e=>e.includes(".")),respect_word_boundaries:e.respectWordBoundaries,limit:e.maxOptions};e.score&&(n.score=e.score);let o=this._sifter.search(s,n).items.map(e=>{const t=this.options[e.id];return t?{...t,_score:e.score}:null}).filter(Boolean);return e.hideSelected&&(o=o.filter(t=>!this.items.includes(a(t[e.valueField])))),o=o.filter(t=>!t[e.disabledField]),o},open(){this.isOpen||this.isDisabled||this.isLocked||(this.isOpen=!0,this.activeIndex=this._config.setFirstOptionActive?0:-1,this._trigger("onDropdownOpen"),this.$nextTick(()=>{this._scrollToActive()}))},close(){this.isOpen&&(this.isOpen=!1,this.activeIndex=-1,this._trigger("onDropdownClose"))},toggle(){this.isOpen?this.close():this.open()},focus(){if(this.isDisabled)return;this.isFocused=!0;const e=this.$refs.searchInput;e&&this.$nextTick(()=>e.focus()),this._config.openOnFocus&&this.open(),"focus"!==this._config.preload||this.loadedSearches[""]||this._performLoad(""),this._trigger("onFocus")},blur(){this.isFocused&&(this.isFocused=!1,this._config.createOnBlur&&this.query.trim()&&this.canCreate&&this.createItem(),this.close(),this._trigger("onBlur"))},onKeyDown(e){if(this.isDisabled||this.isLocked)return;const t=this.filteredOptions,i=this.canCreate,s=t.length+(i?1:0);switch(e.key){case"ArrowDown":e.preventDefault(),this.isOpen?(this.activeIndex=Math.min(this.activeIndex+1,s-1),this._scrollToActive()):this.open();break;case"ArrowUp":e.preventDefault(),this.isOpen&&(this.activeIndex=Math.max(this.activeIndex-1,0),this._scrollToActive());break;case"Enter":e.preventDefault(),this.isOpen&&this.activeIndex>=0?this.activeIndex<t.length?this.selectOption(t[this.activeIndex]):i&&this.createItem():this.isOpen||this.open();break;case"Escape":e.preventDefault(),this.close();break;case"Tab":this.isOpen&&this._config.selectOnTab&&this.activeIndex>=0&&(e.preventDefault(),this.activeIndex<t.length?this.selectOption(t[this.activeIndex]):i&&this.createItem());break;case"Backspace":if(!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const t=this.items[this.items.length-1];this.removeItem(t)}break;case"Delete":if(!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const t=this.items[this.items.length-1];this.removeItem(t)}break;case"a":case"A":(e.ctrlKey||e.metaKey)&&this.isMultiple&&e.preventDefault()}},onInput(){if(this._trigger("onType",this.query),this.isOpen||this.open(),this.activeIndex=this._config.setFirstOptionActive||this.query?0:-1,this._config.load&&this.query){const e=this.query;this.loadedSearches[e]||(this._debouncedLoad?this._debouncedLoad(e):this._performLoad(e))}this.$refs.searchInput&&this.isMultiple&&d(this.$refs.searchInput)},onPaste(e){if(!this.isMultiple)return;const t=(e.clipboardData||window.clipboardData).getData("text");if(!t)return;const i=this._config.splitOn||this._config.delimiter;if(!i)return;e.preventDefault();const s=i instanceof RegExp?i:new RegExp("["+i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")+"]"),n=t.split(s).map(e=>e.trim()).filter(Boolean);for(const o of n){const e=Object.values(this.options).find(e=>{var t,i;return(null==(t=e[this._config.labelField])?void 0:t.toLowerCase())===o.toLowerCase()||(null==(i=e[this._config.valueField])?void 0:i.toLowerCase())===o.toLowerCase()});e?this.addItem(e[this._config.valueField]):this._config.create&&this.createItem(o)}},selectOption(e){if(!e)return;if(e[this._config.disabledField])return;const t=e[this._config.valueField];if(""===t)return this.clear(),this.close(),this.isFocused=!1,void(this.$refs.searchInput&&this.$refs.searchInput.blur());this._config.showSelectedCount&&this.isMultiple&&this.isSelected(e)?this.removeItem(t):(this.addItem(t),this.query="",this.isSingle?(this.isFocused=!1,this.loadedSearches={},this.$refs.searchInput&&this.$refs.searchInput.blur()):this.$refs.searchInput&&(this.$refs.searchInput.focus(),d(this.$refs.searchInput)))},_performLoad(e){this._config.load&&(this.loadedSearches[e]||(this.isLoading=!0,this.loadedSearches[e]=!0,this._config.load(e,e=>{if(this.isLoading=!1,e&&Array.isArray(e)){for(const t of e)this.addOption(t,!0);this._clearRenderCache()}})))},renderOption(e){var t;const i=this._config,s=e[i.labelField]||"";return(null==(t=i.render)?void 0:t.option)?i.render.option(e,l):i.highlight&&this.query?function(e,t){if(!t||!t.length)return l(e);const i=l(e),s=new RegExp("("+t.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")+")","ig");return i.replace(s,'<span class="font-semibold text-inherit">$1</span>')}(s,this.query):l(s)},renderItem(e){var t;if(!e)return"";const i=this._config,s=e[i.labelField]||"";return(null==(t=i.render)?void 0:t.item)?i.render.item(e,l):l(s)},renderOptionCreate(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.optionCreate)?t.render.optionCreate({input:this.query},l):`Add <span class="font-medium">${l(this.query)}</span>...`},renderNoResults(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.noResults)?t.render.noResults({query:this.query},l):"No results found"},renderDropdownPlaceholder(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.dropdownPlaceholder)?t.render.dropdownPlaceholder({},l):l(t.dropdownPlaceholder||"")},renderLoading(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.loading)?t.render.loading({query:this.query},l):"Loading..."},addOptionGroup(e,t){this.optgroups[e]=t,this._clearRenderCache()},removeOptionGroup(e){delete this.optgroups[e],this._clearRenderCache()},getGroupedOptions(){const e=this.filteredOptions,t=this._config,i={},s=[];for(const o of e){const e=o[t.optgroupField];e&&this.optgroups[e]?(i[e]||(i[e]=[]),i[e].push(o)):s.push(o)}const n=[];for(const[o,r]of Object.entries(i)){const e=this.optgroups[o];n.push({id:o,label:e[t.optgroupLabelField]||o,options:r})}return s.length&&n.push({id:null,label:null,options:s}),n},_getGroupedView(){const e=this.getGroupedOptions();let t=0;return e.map((e,i)=>{const s={key:e.id||"__ungrouped_"+i,label:e.label,options:e.options,offset:t};return t+=e.options.length,s})},get hasOptgroups(){return Object.keys(this.optgroups).length>0},lock(){this.isLocked=!0,this.close()},unlock(){this.isLocked=!1},disable(){this.isDisabled=!0,this.close()},enable(){this.isDisabled=!1},setMaxItems(e){this._config.maxItems=e,this.isFull&&this.close()},_syncSourceElement(){var e;if(this._sourceEl)if(u(this._sourceEl)){for(const e of this._sourceEl.options)e.selected=this.items.includes(e.value);for(const t of this.items){if(!Array.from(this._sourceEl.options).some(e=>e.value===t)){const i=document.createElement("option");i.value=t,i.textContent=(null==(e=this.options[t])?void 0:e[this._config.labelField])||t,i.selected=!0,this._sourceEl.appendChild(i)}}this._sourceEl.dispatchEvent(new Event("change",{bubbles:!0}))}else this._sourceEl.value=this.isSingle?this.items[0]||"":this.items.join(this._config.delimiter),this._sourceEl.dispatchEvent(new Event("input",{bubbles:!0})),this._sourceEl.dispatchEvent(new Event("change",{bubbles:!0}))},_scrollToActive(){this.$nextTick(()=>{const e=this.$refs.dropdown;if(!e)return;const t=e.querySelector('[data-active="true"]');t&&t.scrollIntoView({block:"nearest"})})},_trigger(e,...t){const i=this._config[e];"function"==typeof i&&i.apply(this,t);const s=e.replace(/^on/,"").toLowerCase();this.$el.dispatchEvent(new CustomEvent(`selectra:${s}`,{detail:t,bubbles:!0}))},_clearRenderCache(){this._renderCache={}},isSelected(e){return this.items.includes(a(e[this._config.valueField]))},optionKey(e){return a(e[this._config.valueField])}})}function m(e,t){f[e]=t}m("remove_button",function(e={}){var t;const{label:i="&times;",title:s="Remove",className:n=""}=e,o=null==(t=this._config.render)?void 0:t.item;this._config.render||(this._config.render={});const r=this;this._config.render.item=function(e,t){const i=r._config.labelField;r._config.valueField;return`<span class="inline-flex items-center">${o?o(e,t):t(e[i]||"")}</span>`},this._showRemoveButton=!0,this._removeButtonLabel=i,this._removeButtonTitle=s,this._removeButtonClass=n}),m("clear_button",function(e={}){const{title:t="Clear All",className:i="",label:s="&times;"}=e;this._showClearButton=!0,this._clearButtonTitle=t,this._clearButtonLabel=s,this._clearButtonClass=i}),m("restore_on_backspace",function(e={}){const t=e.text||(e=>e[this._config.labelField]||""),i=this.onKeyDown.bind(this);this.onKeyDown=e=>{if("Backspace"===e.key&&!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const i=this.items[this.items.length-1],s=this.options[i];return this.removeItem(i),void(s&&(this.query=t(s),this.$refs.searchInput&&(this.$refs.searchInput.value=this.query)))}i(e)}}),m("dropdown_header",function(e={}){const{title:t="",showClose:i=!0,headerClass:s=""}=e;this._dropdownHeader=!0,this._dropdownHeaderTitle=t,this._dropdownHeaderShowClose=i,this._dropdownHeaderClass=s}),m("tag_limit",function(e={}){const{tagLimit:t=3}=e;this._tagLimit=t,this._showAllTags=!1,Object.defineProperty(this,"visibleItems",{get(){const e=this.selectedItems;return this.isFocused||this._showAllTags||!this._tagLimit?e:e.slice(0,this._tagLimit)}}),Object.defineProperty(this,"hiddenItemCount",{get(){const e=this.selectedItems;return this.isFocused||this._showAllTags||!this._tagLimit?0:Math.max(0,e.length-this._tagLimit)}})}),m("auto_select_on_type",function(){const e=this.blur.bind(this);this.blur=()=>{if(this.query.trim()&&this.filteredOptions.length){const e=this.filteredOptions[0];this.selectOption(e)}this.query="",e()}}),m("select_on_focus",function(){const e=this.focus.bind(this);this.focus=()=>{if(e(),this.isSingle&&this.items.length){const e=this.options[this.items[0]];e&&(this.query=e[this._config.labelField]||"",this.$refs.searchInput&&this.$nextTick(()=>this.$refs.searchInput.select()))}}}),m("read_only",function(e={}){const{readOnly:t=!0}=e;this._isReadOnly=t,this.readonly=e=>{this._isReadOnly=void 0!==e?e:!this._isReadOnly,this._isReadOnly&&this.close()};const i=this.addItem.bind(this),s=this.removeItem.bind(this),n=this.createItem.bind(this),o=this.clear.bind(this);this.addItem=(e,t)=>{this._isReadOnly||i(e,t)},this.removeItem=(e,t)=>{this._isReadOnly||s(e,t)},this.createItem=e=>{this._isReadOnly||n(e)},this.clear=e=>{this._isReadOnly||o(e)}}),m("auto_position",function(){this._autoPosition=!0;const e=this.open.bind(this);this.open=()=>{e(),this.$nextTick(()=>{const e=this.$refs.dropdown,t=this.$el;if(!e||!t)return;const i=t.getBoundingClientRect(),s=window.innerHeight-i.bottom,n=i.top,o=e.offsetHeight||250;this._dropdownPosition=s<o&&n>s?"top":"bottom"})},this._dropdownPosition="bottom"});
1
+ var Selectra=function(e){"use strict";/*! Selectra v1.0.9 | Apache-2.0 License */const t={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",o:"[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]",p:"[pṔṕṖṗⱣᵽƤƥᵱ]",q:"[qꝖꝗʠɊɋꝘꝙq̃]",r:"[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]",s:"[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]",t:"[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]",u:"[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]",v:"[vṼṽṾṿƲʋꝞꝟⱱʋ]",w:"[wẂẃẀẁŴŵẄẅẆẇẈẉ]",x:"[xẌẍẊẋχ]",y:"[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]",z:"[zŹźẐẑŽžŻżẒẓẔẕƵƶ]"},i=(()=>{const e={};let i="";for(const n in t){const s=t[n].substring(2,t[n].length-1);i+=s;for(let t=0;t<s.length;t++)e[s.charAt(t)]=n}const s=new RegExp("["+i+"]","g");return t=>t.replace(s,t=>e[t]||"").toLowerCase()})();function s(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function n(e,t,i){if(!e||!t)return;if(!i)return e[t];const s=t.split(".");let n=e;for(;s.length&&n;)n=n[s.shift()];return n}function o(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=i(String(e||"")))>(t=i(String(t||"")))?1:t>e?-1:0}class r{constructor(e,t={}){this.items=e,this.settings={diacritics:!0,...t}}tokenize(e,i){if(!(e=String(e||"").toLowerCase().trim()).length)return[];const n=[],o=e.split(/\s+/);for(const r of o){let e=s(r);if(this.settings.diacritics)for(const i in t)e=e.replace(new RegExp(i,"g"),t[i]);i&&(e="\\b"+e),n.push({string:r,regex:new RegExp(e,"i")})}return n}getScoreFunction(e,t){e=this.prepareSearch(e,t);const{tokens:i}=e,{fields:s}=e.options,o=i.length,{nesting:r}=e.options,l=(e,t)=>{if(!e)return 0;const i=(e=String(e||"")).search(t.regex);if(-1===i)return 0;let s=t.string.length/e.length;return 0===i&&(s+=.5),s},c=s.length,h=0===c?()=>0:1===c?(e,t)=>l(n(t,s[0],r),e):(e,t)=>{let i=0;for(let o=0;o<c;o++)i+=l(n(t,s[o],r),e);return i/c};return o?1===o?e=>h(i[0],e):"and"===e.options.conjunction?e=>{let t=0;for(let s=0;s<o;s++){const n=h(i[s],e);if(n<=0)return 0;t+=n}return t/o}:e=>{let t=0;for(let s=0;s<o;s++)t+=h(i[s],e);return t/o}:()=>0}getSortFunction(e,t){const i=!(e=this.prepareSearch(e,t)).query&&t.sort_empty||t.sort,s=(e,i)=>"$score"===e?i.score:n(this.items[i.id],e,t.nesting),r=[];if(i)for(const n of i)(e.query||"$score"!==n.field)&&r.push(n);if(e.query){let e=!0;for(const t of r)if("$score"===t.field){e=!1;break}e&&r.unshift({field:"$score",direction:"desc"})}else{const e=r.findIndex(e=>"$score"===e.field);-1!==e&&r.splice(e,1)}const l=r.map(e=>"desc"===e.direction?-1:1),c=r.length;if(!c)return null;if(1===c){const e=r[0].field,t=l[0];return(i,n)=>t*o(s(e,i),s(e,n))}return(e,t)=>{for(let i=0;i<c;i++){const n=l[i]*o(s(r[i].field,e),s(r[i].field,t));if(n)return n}return 0}}prepareSearch(e,t){return"object"==typeof e?e:((t={...t}).fields&&!Array.isArray(t.fields)&&(t.fields=[t.fields]),t.sort&&!Array.isArray(t.sort)&&(t.sort=[t.sort]),t.sort_empty&&!Array.isArray(t.sort_empty)&&(t.sort_empty=[t.sort_empty]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t.respect_word_boundaries),total:0,items:[]})}search(e,t){const i=this.prepareSearch(e,t),s=i.options,n=i.query,o=s.score||this.getScoreFunction(i),r=this.items;if(n.length){(Array.isArray(r)?e=>r.forEach((t,i)=>e(t,i)):e=>Object.keys(r).forEach(t=>e(r[t],t)))((e,t)=>{const n=o(e);(!1===s.filter||n>0)&&i.items.push({score:n,id:t})})}else{(Array.isArray(r)?e=>r.forEach((t,i)=>e(t,i)):e=>Object.keys(r).forEach(t=>e(r[t],t)))((e,t)=>{i.items.push({score:1,id:t})})}const l=this.getSortFunction(i,s);return l&&i.items.sort(l),i.total=i.items.length,"number"==typeof s.limit&&(i.items=i.items.slice(0,s.limit)),i}}function l(e){return"string"!=typeof e?"":e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let c,h=0;function a(e){return null==e?null:"boolean"==typeof e?e?"1":"0":String(e)}function d(e,t=10){const i=function(e,t){c||(c=document.createElement("canvas"));const i=c.getContext("2d");if(t){const e=window.getComputedStyle(t);i.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`}return i.measureText(e).width}(e.value||e.placeholder||"",e)+t;e.style.width=Math.max(i,60)+"px"}function u(e){return e.tagName&&"select"===e.tagName.toLowerCase()}const p={delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,showAddOptionOnCreate:!0,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1e3,maxItems:null,hideSelected:null,selectOnTab:!0,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,loadThrottle:300,loadingClass:"loading",placeholder:"",dropdownPlaceholder:"",mode:null,search:!0,showArrow:!0,showSelectedCount:!1,valueField:"value",labelField:"text",disabledField:"disabled",optgroupField:"optgroup",optgroupLabelField:"label",optgroupValueField:"value",sortField:"$order",searchField:["text"],searchConjunction:"and",respectWordBoundaries:!1,normalize:!0,plugins:[],render:{option:null,item:null,optionCreate:null,optgroupHeader:null,noResults:null,dropdownPlaceholder:null,loading:null},load:null,score:null,onChange:null,onItemAdd:null,onItemRemove:null,onClear:null,onOptionAdd:null,onOptionRemove:null,onDropdownOpen:null,onDropdownClose:null,onType:null,onFocus:null,onBlur:null,onInitialize:null},f={};function g(e={}){return()=>({isOpen:!1,isFocused:!1,isDisabled:!1,isLocked:!1,isLoading:!1,isInvalid:!1,query:"",activeIndex:-1,caretPos:0,items:[],options:{},optgroups:{},userOptions:{},optionOrder:[],loadedSearches:{},lastQuery:"",_config:{},_sifter:null,_sourceEl:null,_id:"",_rtl:!1,_plugins:[],_renderCache:{},get config(){return this._config},get isMultiple(){return"multi"===this._config.mode},get isSingle(){return"single"===this._config.mode},get isFull(){return null!==this._config.maxItems&&this.items.length>=this._config.maxItems},get hasOptions(){return Object.keys(this.options).length>0},get canCreate(){if(!this._config.create)return!1;if(!this.query.trim())return!1;if(this.isFull)return!1;if(this._config.createFilter){const e=this._config.createFilter;if("function"==typeof e)return e(this.query);if(e instanceof RegExp)return e.test(this.query);if("string"==typeof e)return new RegExp(e).test(this.query)}return!Object.values(this.options).find(e=>{var t;return(null==(t=e[this._config.labelField])?void 0:t.toLowerCase())===this.query.toLowerCase()})},get selectedItems(){return this.items.map(e=>this.options[a(e)]).filter(Boolean)},get filteredOptions(){return this._getFilteredOptions()},get placeholderText(){return this.items.length>0&&this.isSingle?"":this._config.placeholder||""},get selectedCountText(){return this.items.length},get currentValueText(){if(!this.isSingle||!this.items.length)return"";const e=this.options[a(this.items[0])];return e?e[this._config.labelField]:""},init(){if(this._id=function(e="selectize"){return`${e}-${++h}-${Math.random().toString(36).slice(2,8)}`}(),this._config={...p,...e},this._sourceEl=this.$el.querySelector('select, input[type="text"], input[type="hidden"]'),this._sourceEl&&u(this._sourceEl)){const i=function(e){const t=[],i=[],s=[],n=(e,i=null)=>{const n=e.value,o=e.textContent.trim(),r=e.disabled;if(!n&&!o)return;const l={value:n,text:o,disabled:r};if(e.dataset.data)try{Object.assign(l,JSON.parse(e.dataset.data))}catch(c){}null!==i&&(l.optgroup=i),e.selected&&s.push(n),t.push(l)};for(const o of e.children)if("optgroup"===o.tagName.toLowerCase()){const e=o.getAttribute("label")||"";i.push({value:e,label:e,disabled:o.disabled});for(const t of o.children)n(t,e)}else"option"===o.tagName.toLowerCase()&&n(o);return{options:t,optgroups:i,selectedValues:s}}(this._sourceEl),s=i.options.find(e=>""===e.value);s&&!this._config.placeholder&&(this._config.placeholder=s.text);const n=i.selectedValues.filter(e=>""!==e),o=this._config.options||[],r=[...i.options,...o];this._registerOptions(r);for(const e of i.optgroups)this.optgroups[e.value]=e;n.length&&(this.items=[...n]),e.mode||(this._config.mode=this._sourceEl.multiple?"multi":"single"),this._sourceEl.hasAttribute("required")&&(this.isInvalid=!this.items.length),this._sourceEl.disabled&&(this.isDisabled=!0),this._sourceEl.placeholder&&(this._config.placeholder=this._sourceEl.placeholder),this._sourceEl.style.display="none",this._sourceEl.setAttribute("tabindex","-1"),this._rtl=(t=this._sourceEl,"rtl"===window.getComputedStyle(t).direction)}else{const e=this._config.options||[];if(this._registerOptions(e),this._config.optgroups)for(const t of this._config.optgroups)this.optgroups[t[this._config.optgroupValueField]]=t;this._config.items&&(this.items=[...this._config.items])}var t;this._config.mode||(this._config.mode=1===this._config.maxItems?"single":"multi"),"single"===this._config.mode&&(this._config.maxItems=1),null===this._config.hideSelected&&(this._config.hideSelected="multi"===this._config.mode&&!this._config.showSelectedCount),this._config.showSelectedCount&&(this._config.hideSelected=!1),this._sifter=new r(this.options,{diacritics:this._config.diacritics}),this._initPlugins(),this._config.load&&this._config.loadThrottle&&(this._debouncedLoad=function(e,t){let i;return function(...s){clearTimeout(i),i=setTimeout(()=>e.apply(this,s),t)}}(this._performLoad.bind(this),this._config.loadThrottle)),this._config.preload&&this.$nextTick(()=>{"focus"===this._config.preload||this._performLoad("")}),this._trigger("onInitialize"),this._onClickOutside=e=>{this.$el.contains(e.target)||(this.close(),this.blur())},document.addEventListener("mousedown",this._onClickOutside)},destroy(){document.removeEventListener("mousedown",this._onClickOutside),this._sourceEl&&(this._sourceEl.style.display="",this._sourceEl.removeAttribute("tabindex"))},_initPlugins(){const e=this._config.plugins||[];for(const t of e){const e="string"==typeof t?t:t.name,i="string"==typeof t?{}:t.options||{};f[e]?(f[e].call(this,i),this._plugins.push(e)):console.warn(`[selectize] Plugin "${e}" not found.`)}},_registerOptions(e){for(const t of e)this.addOption(t,!0)},addOption(e,t=!1){if(Array.isArray(e)){for(const i of e)this.addOption(i,t);return}const i=a(e[this._config.valueField]);null===i||this.options[i]||(e.$order=e.$order||++this._orderCounter||(this._orderCounter=1),this.options[i]=e,this.optionOrder.push(i),this._sifter&&(this._sifter.items=this.options),this._clearRenderCache(),t||this._trigger("onOptionAdd",i,e))},updateOption(e,t){const i=a(e);if(!i||!this.options[i])return;const s=a(t[this._config.valueField]);if(t.$order=this.options[i].$order,this.options[s]=t,i!==s){delete this.options[i];const e=this.optionOrder.indexOf(i);-1!==e&&(this.optionOrder[e]=s);const t=this.items.indexOf(i);-1!==t&&(this.items[t]=s)}this._sifter&&(this._sifter.items=this.options),this._clearRenderCache()},removeOption(e){const t=a(e);if(!t)return;delete this.options[t],delete this.userOptions[t];const i=this.optionOrder.indexOf(t);-1!==i&&this.optionOrder.splice(i,1),this.items=this.items.filter(e=>e!==t),this._sifter&&(this._sifter.items=this.options),this._clearRenderCache(),this._trigger("onOptionRemove",t)},clearOptions(){const e={};for(const t of this.items)this.options[t]&&(e[t]=this.options[t]);this.options=e,this.optionOrder=Object.keys(e),this.userOptions={},this._sifter&&(this._sifter.items=this.options),this._clearRenderCache()},getOption(e){return this.options[a(e)]||null},addItem(e,t=!1){const i=a(e);i&&this.options[i]&&(this.items.includes(i)||(this.isSingle&&this.items.length&&this.removeItem(this.items[0],!0),this.isFull||(this.items.push(i),this.caretPos=this.items.length,this._syncSourceElement(),this._clearRenderCache(),this.query="",(this._config.closeAfterSelect||this.isSingle)&&this.close(),this.isFull&&this.close(),t||(this._trigger("onItemAdd",i,this.options[i]),this._trigger("onChange",this.getValue())))))},removeItem(e,t=!1){const i=a(e),s=this.items.indexOf(i);-1!==s&&(this.items.splice(s,1),this.caretPos>this.items.length&&(this.caretPos=this.items.length),this._syncSourceElement(),this._clearRenderCache(),t||(this._trigger("onItemRemove",i),this._trigger("onChange",this.getValue())))},clear(e=!1){this.items.length&&(this.items=[],this.caretPos=0,this._syncSourceElement(),this._clearRenderCache(),e||(this._trigger("onClear"),this._trigger("onChange",this.getValue())))},getValue(){return this.isSingle?this.items.length?this.items[0]:"":[...this.items]},setValue(e,t=!1){this.clear(!0);const i=Array.isArray(e)?e:[e];for(const s of i)""!==s&&null!=s&&this.addItem(s,!0);t||this._trigger("onChange",this.getValue())},createItem(e=null){const t=null!==e?e:this.query;if(!t.trim())return;if(!this._config.create)return;const i=this._config.create;let s;"function"==typeof i?(s=i(t,e=>{e&&(this.addOption(e),this.addItem(e[this._config.valueField]))}),s&&"object"==typeof s&&(this.addOption(s),this.addItem(s[this._config.valueField]))):(s={},s[this._config.valueField]=t,s[this._config.labelField]=t,this.addOption(s),this.addItem(t)),this.query="",this._clearRenderCache()},_getFilteredOptions(){const e=this._config;if(!this._sifter)return[];const t=Array.isArray(e.searchField)?e.searchField:[e.searchField];let i;i=e.sortField?"string"==typeof e.sortField?[{field:e.sortField,direction:"asc"}]:Array.isArray(e.sortField)?e.sortField:[e.sortField]:[{field:"$order",direction:"asc"}];let s=this.query;e.normalize&&s&&(s=s.normalize("NFD").replace(/[\u0300-\u036f]/g,""));const n={fields:t,conjunction:e.searchConjunction,sort:i,nesting:t.some(e=>e.includes(".")),respect_word_boundaries:e.respectWordBoundaries,limit:e.maxOptions};e.score&&(n.score=e.score);let o=this._sifter.search(s,n).items.map(e=>{const t=this.options[e.id];return t?{...t,_score:e.score}:null}).filter(Boolean);return e.hideSelected&&(o=o.filter(t=>!this.items.includes(a(t[e.valueField])))),o=o.filter(t=>!t[e.disabledField]),o},open(){this.isOpen||this.isDisabled||this.isLocked||(this.isOpen=!0,this.activeIndex=this._config.setFirstOptionActive?0:-1,this._trigger("onDropdownOpen"),this.$nextTick(()=>{this._scrollToActive()}))},close(){this.isOpen&&(this.isOpen=!1,this.activeIndex=-1,this._trigger("onDropdownClose"))},toggle(){this.isOpen?this.close():this.open()},focus(){if(this.isDisabled)return;this.isFocused=!0;const e=this.$refs.searchInput;e&&this.$nextTick(()=>e.focus()),this._config.openOnFocus&&this.open(),"focus"!==this._config.preload||this.loadedSearches[""]||this._performLoad(""),this._trigger("onFocus")},blur(){this.isFocused&&(this.isFocused=!1,this._config.createOnBlur&&this.query.trim()&&this.canCreate&&this.createItem(),this.close(),this._trigger("onBlur"))},onKeyDown(e){if(this.isDisabled||this.isLocked)return;const t=this.filteredOptions,i=this.canCreate,s=t.length+(i?1:0);switch(e.key){case"ArrowDown":e.preventDefault(),this.isOpen?(this.activeIndex=Math.min(this.activeIndex+1,s-1),this._scrollToActive()):this.open();break;case"ArrowUp":e.preventDefault(),this.isOpen&&(this.activeIndex=Math.max(this.activeIndex-1,0),this._scrollToActive());break;case"Enter":e.preventDefault(),this.isOpen&&this.activeIndex>=0?this.activeIndex<t.length?this.selectOption(t[this.activeIndex]):i&&this.createItem():this.isOpen||this.open();break;case"Escape":e.preventDefault(),this.close();break;case"Tab":this.isOpen&&this._config.selectOnTab&&this.activeIndex>=0&&(e.preventDefault(),this.activeIndex<t.length?this.selectOption(t[this.activeIndex]):i&&this.createItem());break;case"Backspace":if(!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const t=this.items[this.items.length-1];this.removeItem(t)}break;case"Delete":if(!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const t=this.items[this.items.length-1];this.removeItem(t)}break;case"a":case"A":(e.ctrlKey||e.metaKey)&&this.isMultiple&&e.preventDefault()}},onInput(){if(this._trigger("onType",this.query),this.isOpen||this.open(),this.activeIndex=this._config.setFirstOptionActive||this.query?0:-1,this._config.load&&this.query){const e=this.query;this.loadedSearches[e]||(this._debouncedLoad?this._debouncedLoad(e):this._performLoad(e))}this.$refs.searchInput&&this.isMultiple&&d(this.$refs.searchInput)},onPaste(e){if(!this.isMultiple)return;const t=(e.clipboardData||window.clipboardData).getData("text");if(!t)return;const i=this._config.splitOn||this._config.delimiter;if(!i)return;e.preventDefault();const s=i instanceof RegExp?i:new RegExp("["+i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")+"]"),n=t.split(s).map(e=>e.trim()).filter(Boolean);for(const o of n){const e=Object.values(this.options).find(e=>{var t,i;return(null==(t=e[this._config.labelField])?void 0:t.toLowerCase())===o.toLowerCase()||(null==(i=e[this._config.valueField])?void 0:i.toLowerCase())===o.toLowerCase()});e?this.addItem(e[this._config.valueField]):this._config.create&&this.createItem(o)}},selectOption(e){if(!e)return;if(e[this._config.disabledField])return;const t=e[this._config.valueField];if(""===t)return this.clear(),this.close(),this.isFocused=!1,void(this.$refs.searchInput&&this.$refs.searchInput.blur());this._config.showSelectedCount&&this.isMultiple&&this.isSelected(e)?this.removeItem(t):(this.addItem(t),this.query="",this.isSingle?(this.isFocused=!1,this.loadedSearches={},this.$refs.searchInput&&this.$refs.searchInput.blur()):this.$refs.searchInput&&(this.$refs.searchInput.focus(),d(this.$refs.searchInput)))},_performLoad(e){this._config.load&&(this.loadedSearches[e]||(this.isLoading=!0,this.loadedSearches[e]=!0,this._config.load(e,e=>{if(this.isLoading=!1,e&&Array.isArray(e)){for(const t of e)this.addOption(t,!0);this._clearRenderCache()}})))},renderOption(e){var t;const i=this._config,s=e[i.labelField]||"";return(null==(t=i.render)?void 0:t.option)?i.render.option(e,l):i.highlight&&this.query?function(e,t){if(!t||!t.length)return l(e);const i=l(e),s=new RegExp("("+t.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")+")","ig");return i.replace(s,'<span class="font-semibold text-inherit">$1</span>')}(s,this.query):l(s)},renderItem(e){var t;if(!e)return"";const i=this._config,s=e[i.labelField]||"";return(null==(t=i.render)?void 0:t.item)?i.render.item(e,l):l(s)},renderOptionCreate(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.optionCreate)?t.render.optionCreate({input:this.query},l):`Add <span class="font-medium">${l(this.query)}</span>...`},renderNoResults(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.noResults)?t.render.noResults({query:this.query},l):"No results found"},renderDropdownPlaceholder(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.dropdownPlaceholder)?t.render.dropdownPlaceholder({},l):l(t.dropdownPlaceholder||"")},renderLoading(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.loading)?t.render.loading({query:this.query},l):"Loading..."},addOptionGroup(e,t){this.optgroups[e]=t,this._clearRenderCache()},removeOptionGroup(e){delete this.optgroups[e],this._clearRenderCache()},getGroupedOptions(){const e=this.filteredOptions,t=this._config,i={},s=[];for(const o of e){const e=o[t.optgroupField];e&&this.optgroups[e]?(i[e]||(i[e]=[]),i[e].push(o)):s.push(o)}const n=[];for(const[o,r]of Object.entries(i)){const e=this.optgroups[o];n.push({id:o,label:e[t.optgroupLabelField]||o,options:r})}return s.length&&n.push({id:null,label:null,options:s}),n},_getGroupedView(){const e=this.getGroupedOptions();let t=0;return e.map((e,i)=>{const s={key:e.id||"__ungrouped_"+i,label:e.label,options:e.options,offset:t};return t+=e.options.length,s})},get hasOptgroups(){return Object.keys(this.optgroups).length>0},lock(){this.isLocked=!0,this.close()},unlock(){this.isLocked=!1},disable(){this.isDisabled=!0,this.close()},enable(){this.isDisabled=!1},setMaxItems(e){this._config.maxItems=e,this.isFull&&this.close()},_syncSourceElement(){var e;if(this._sourceEl)if(u(this._sourceEl)){for(const e of this._sourceEl.options)e.selected=this.items.includes(e.value);for(const t of this.items){if(!Array.from(this._sourceEl.options).some(e=>e.value===t)){const i=document.createElement("option");i.value=t,i.textContent=(null==(e=this.options[t])?void 0:e[this._config.labelField])||t,i.selected=!0,this._sourceEl.appendChild(i)}}this._sourceEl.dispatchEvent(new Event("change",{bubbles:!0}))}else this._sourceEl.value=this.isSingle?this.items[0]||"":this.items.join(this._config.delimiter),this._sourceEl.dispatchEvent(new Event("input",{bubbles:!0})),this._sourceEl.dispatchEvent(new Event("change",{bubbles:!0}))},_scrollToActive(){this.$nextTick(()=>{const e=this.$refs.dropdown;if(!e)return;const t=e.querySelector('[data-active="true"]');t&&t.scrollIntoView({block:"nearest"})})},_trigger(e,...t){const i=this._config[e];"function"==typeof i&&i.apply(this,t);const s=e.replace(/^on/,"").toLowerCase();this.$el.dispatchEvent(new CustomEvent(`selectra:${s}`,{detail:t,bubbles:!0}))},_clearRenderCache(){this._renderCache={}},isSelected(e){return this.items.includes(a(e[this._config.valueField]))},optionKey(e){return a(e[this._config.valueField])}})}function m(e,t){f[e]=t}m("remove_button",function(e={}){var t;const{label:i="&times;",title:s="Remove",className:n=""}=e,o=null==(t=this._config.render)?void 0:t.item;this._config.render||(this._config.render={});const r=this;this._config.render.item=function(e,t){const i=r._config.labelField;r._config.valueField;return`<span class="inline-flex items-center">${o?o(e,t):t(e[i]||"")}</span>`},this._showRemoveButton=!0,this._removeButtonLabel=i,this._removeButtonTitle=s,this._removeButtonClass=n}),m("clear_button",function(e={}){const{title:t="Clear All",className:i="",label:s="&times;"}=e;this._showClearButton=!0,this._clearButtonTitle=t,this._clearButtonLabel=s,this._clearButtonClass=i}),m("restore_on_backspace",function(e={}){const t=e.text||(e=>e[this._config.labelField]||""),i=this.onKeyDown.bind(this);this.onKeyDown=e=>{if("Backspace"===e.key&&!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const i=this.items[this.items.length-1],s=this.options[i];return this.removeItem(i),void(s&&(this.query=t(s),this.$refs.searchInput&&(this.$refs.searchInput.value=this.query)))}i(e)}}),m("dropdown_header",function(e={}){const{title:t="",showClose:i=!0,headerClass:s=""}=e;this._dropdownHeader=!0,this._dropdownHeaderTitle=t,this._dropdownHeaderShowClose=i,this._dropdownHeaderClass=s}),m("tag_limit",function(e={}){const{tagLimit:t=3}=e;this._tagLimit=t,this._showAllTags=!1,Object.defineProperty(this,"visibleItems",{get(){const e=this.selectedItems;return this.isFocused||this._showAllTags||!this._tagLimit?e:e.slice(0,this._tagLimit)}}),Object.defineProperty(this,"hiddenItemCount",{get(){const e=this.selectedItems;return this.isFocused||this._showAllTags||!this._tagLimit?0:Math.max(0,e.length-this._tagLimit)}})}),m("auto_select_on_type",function(){const e=this.blur.bind(this);this.blur=()=>{if(this.query.trim()&&this.filteredOptions.length){const e=this.filteredOptions[0];this.selectOption(e)}this.query="",e()}}),m("select_on_focus",function(){const e=this.focus.bind(this);this.focus=()=>{if(e(),this.isSingle&&this.items.length){const e=this.options[this.items[0]];e&&(this.query=e[this._config.labelField]||"",this.$refs.searchInput&&this.$nextTick(()=>this.$refs.searchInput.select()))}}}),m("read_only",function(e={}){const{readOnly:t=!0}=e;this._isReadOnly=t,this.readonly=e=>{this._isReadOnly=void 0!==e?e:!this._isReadOnly,this._isReadOnly&&this.close()};const i=this.addItem.bind(this),s=this.removeItem.bind(this),n=this.createItem.bind(this),o=this.clear.bind(this);this.addItem=(e,t)=>{this._isReadOnly||i(e,t)},this.removeItem=(e,t)=>{this._isReadOnly||s(e,t)},this.createItem=e=>{this._isReadOnly||n(e)},this.clear=e=>{this._isReadOnly||o(e)}}),m("auto_position",function(){this._autoPosition=!0;const e=this.open.bind(this);this.open=()=>{e(),this.$nextTick(()=>{const e=this.$refs.dropdown,t=this.$el;if(!e||!t)return;const i=t.getBoundingClientRect(),s=window.innerHeight-i.bottom,n=i.top,o=e.offsetHeight||250;this._dropdownPosition=s<o&&n>s?"top":"bottom"})},this._dropdownPosition="bottom"});
2
2
  /**
3
3
  * Selectra - Alpine.js Plugin
4
4
  *
@@ -26,5 +26,5 @@ var Selectra=function(e){"use strict";/*! Selectra v1.0.7 | Apache-2.0 License *
26
26
  * </select>
27
27
  * </div>
28
28
  */
29
- const _='\n<div class="selectra-control" :class="{\'is-disabled\': isDisabled}">\n <div @click="focus()" class="selectra-input"\n :class="{\'is-focused\': isFocused, \'is-invalid\': isInvalid, \'is-locked\': isLocked, \'is-single\': isSingle, \'has-items\': items.length > 0}">\n <span x-show="_config.showSelectedCount && isMultiple"\n class="selectra-selected-count">\n <span x-text="selectedCountText"></span>\n </span>\n <span x-show="isSingle && items.length && !isFocused"\n x-text="currentValueText"\n class="selectra-single-value"></span>\n <template x-for="val in items" :key="val">\n <span x-show="isMultiple && !_config.showSelectedCount" class="selectra-item">\n <span x-html="options[val] ? renderItem(options[val]) : val"></span>\n <span @click.stop="removeItem(val)" class="selectra-item-remove">&times;</span>\n </span>\n </template>\n <input x-ref="searchInput"\n x-model="query"\n @input="onInput()"\n @focus="focus()"\n @blur.debounce.150ms="blur()"\n @keydown="onKeyDown($event)"\n @paste="onPaste($event)"\n :placeholder="placeholderText"\n x-show="(isSingle || !isFull) && (isMultiple || isFocused || !items.length)"\n :class="{\'selectra-search-with-count\': _config.showSelectedCount && isMultiple}"\n class="selectra-search">\n <span x-show="isFull && isMultiple" class="selectra-max-badge">Max reached</span>\n <div x-show="isLoading && !isOpen" class="selectra-spinner"></div>\n <svg x-show="isSingle"\n class="selectra-arrow" :class="{\'is-open\': isOpen}"\n fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">\n <path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"/>\n </svg>\n </div>\n <div x-show="isOpen" x-ref="dropdown" x-cloak class="selectra-dropdown"\n x-transition:enter="transition ease-out duration-150"\n x-transition:enter-start="opacity-0 -translate-y-1"\n x-transition:enter-end="opacity-100 translate-y-0"\n x-transition:leave="transition ease-in duration-100"\n x-transition:leave-start="opacity-100 translate-y-0"\n x-transition:leave-end="opacity-0 -translate-y-1">\n <div class="selectra-dropdown-content">\n <template x-for="group in _getGroupedView()" :key="group.key">\n <div>\n <div x-show="group.label" x-text="group.label" class="selectra-optgroup-header"></div>\n <template x-for="(option, idx) in group.options" :key="optionKey(option)">\n <div @click="selectOption(option)"\n @mouseenter="activeIndex = group.offset + idx"\n :data-active="activeIndex === group.offset + idx"\n :class="{\'is-active\': activeIndex === group.offset + idx, \'is-selected\': isSelected(option)}"\n class="selectra-option">\n <span x-show="_config.showSelectedCount && isMultiple && isSelected(option)" class="selectra-option-tick">&#10003;</span>\n <span x-html="renderOption(option)"></span>\n </div>\n </template>\n </div>\n </template>\n <div x-show="canCreate"\n @click="createItem()"\n @mouseenter="activeIndex = filteredOptions.length"\n :data-active="activeIndex === filteredOptions.length"\n :class="{\'is-active\': activeIndex === filteredOptions.length}"\n class="selectra-option-create"\n x-html="renderOptionCreate()">\n </div>\n <div x-show="filteredOptions.length === 0 && !isLoading && !canCreate && query.length > 0"\n class="selectra-no-results"\n x-html="renderNoResults()">\n </div>\n <div x-show="filteredOptions.length === 0 && !isLoading && !canCreate && query.length === 0 && _config.dropdownPlaceholder"\n class="selectra-no-results"\n x-html="renderDropdownPlaceholder()">\n </div>\n <div x-show="isLoading" class="selectra-loading">\n <div class="selectra-spinner"></div>\n <span x-html="renderLoading()"></span>\n </div>\n </div>\n </div>\n</div>\n'.trim();function v(e){e.data("selectra",(e={})=>g(e)()),e.directive("selectra",(e,{expression:t},{evaluate:i,cleanup:s})=>{e.querySelector(".selectra-control")||e.insertAdjacentHTML("beforeend",_)})}return v.version="1.0.7",v.template=_,e.DEFAULTS=p,e.SELECTRA_TEMPLATE=_,e.Sifter=r,e.createSelectizeComponent=g,e.default=v,e.escapeHtml=l,e.getDefaults=function(){return{...p}},e.hashKey=a,e.registerPlugin=m,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),e}({});
29
+ const _='\n<div class="selectra-control" :class="{\'is-disabled\': isDisabled}">\n <div @click="focus()" class="selectra-input"\n :class="{\'is-focused\': isFocused, \'is-invalid\': isInvalid, \'is-locked\': isLocked, \'is-single\': isSingle, \'has-items\': items.length > 0}">\n <span x-show="_config.showSelectedCount && isMultiple"\n class="selectra-selected-count">\n <span x-text="selectedCountText"></span>\n </span>\n <span x-show="isSingle && items.length && !isFocused"\n x-text="currentValueText"\n class="selectra-single-value"></span>\n <template x-for="val in items" :key="val">\n <span x-show="isMultiple && !_config.showSelectedCount" class="selectra-item">\n <span x-html="options[val] ? renderItem(options[val]) : val"></span>\n <span @click.stop="removeItem(val)" class="selectra-item-remove">&times;</span>\n </span>\n </template>\n <input x-ref="searchInput"\n x-model="query"\n @input="onInput()"\n @focus="focus()"\n @blur.debounce.150ms="blur()"\n @keydown="onKeyDown($event)"\n @paste="onPaste($event)"\n :placeholder="placeholderText"\n x-show="(isSingle || !isFull) && (isMultiple || isFocused || !items.length)"\n :class="{\'selectra-search-with-count\': _config.showSelectedCount && isMultiple}"\n class="selectra-search">\n <span x-show="isFull && isMultiple" class="selectra-max-badge">Max reached</span>\n <div x-show="isLoading && !isOpen" class="selectra-spinner"></div>\n <svg x-show="isSingle"\n class="selectra-arrow" :class="{\'is-open\': isOpen}"\n fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">\n <path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"/>\n </svg>\n </div>\n <div x-show="isOpen" x-ref="dropdown" x-cloak class="selectra-dropdown"\n x-transition:enter="transition ease-out duration-150"\n x-transition:enter-start="opacity-0 -translate-y-1"\n x-transition:enter-end="opacity-100 translate-y-0"\n x-transition:leave="transition ease-in duration-100"\n x-transition:leave-start="opacity-100 translate-y-0"\n x-transition:leave-end="opacity-0 -translate-y-1">\n <div class="selectra-dropdown-content">\n <template x-for="group in _getGroupedView()" :key="group.key">\n <div>\n <div x-show="group.label" x-text="group.label" class="selectra-optgroup-header"></div>\n <template x-for="(option, idx) in group.options" :key="optionKey(option)">\n <div @click="selectOption(option)"\n @mouseenter="activeIndex = group.offset + idx"\n :data-active="activeIndex === group.offset + idx"\n :class="{\'is-active\': activeIndex === group.offset + idx, \'is-selected\': isSelected(option)}"\n class="selectra-option">\n <span x-show="_config.showSelectedCount && isMultiple && isSelected(option)" class="selectra-option-tick">&#10003;</span>\n <span x-html="renderOption(option)"></span>\n </div>\n </template>\n </div>\n </template>\n <div x-show="canCreate"\n @click="createItem()"\n @mouseenter="activeIndex = filteredOptions.length"\n :data-active="activeIndex === filteredOptions.length"\n :class="{\'is-active\': activeIndex === filteredOptions.length}"\n class="selectra-option-create"\n x-html="renderOptionCreate()">\n </div>\n <div x-show="filteredOptions.length === 0 && !isLoading && !canCreate && query.length > 0"\n class="selectra-no-results"\n x-html="renderNoResults()">\n </div>\n <div x-show="filteredOptions.length === 0 && !isLoading && !canCreate && query.length === 0 && _config.dropdownPlaceholder"\n class="selectra-no-results"\n x-html="renderDropdownPlaceholder()">\n </div>\n <div x-show="isLoading" class="selectra-loading">\n <div class="selectra-spinner"></div>\n <span x-html="renderLoading()"></span>\n </div>\n </div>\n </div>\n</div>\n'.trim();function v(e){e.data("selectra",(e={})=>g(e)()),e.directive("selectra",(e,{expression:t},{evaluate:i,cleanup:s})=>{e.querySelector(".selectra-control")||e.insertAdjacentHTML("beforeend",_)})}return v.version="1.0.9",v.template=_,e.DEFAULTS=p,e.SELECTRA_TEMPLATE=_,e.Sifter=r,e.createSelectizeComponent=g,e.default=v,e.escapeHtml=l,e.getDefaults=function(){return{...p}},e.hashKey=a,e.registerPlugin=m,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),e}({});
30
30
  //# sourceMappingURL=selectra.iife.js.map
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Selectra={})}(this,function(e){"use strict";/*! Selectra v1.0.7 | Apache-2.0 License */const t={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",o:"[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]",p:"[pṔṕṖṗⱣᵽƤƥᵱ]",q:"[qꝖꝗʠɊɋꝘꝙq̃]",r:"[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]",s:"[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]",t:"[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]",u:"[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]",v:"[vṼṽṾṿƲʋꝞꝟⱱʋ]",w:"[wẂẃẀẁŴŵẄẅẆẇẈẉ]",x:"[xẌẍẊẋχ]",y:"[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]",z:"[zŹźẐẑŽžŻżẒẓẔẕƵƶ]"},i=(()=>{const e={};let i="";for(const n in t){const s=t[n].substring(2,t[n].length-1);i+=s;for(let t=0;t<s.length;t++)e[s.charAt(t)]=n}const s=new RegExp("["+i+"]","g");return t=>t.replace(s,t=>e[t]||"").toLowerCase()})();function s(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function n(e,t,i){if(!e||!t)return;if(!i)return e[t];const s=t.split(".");let n=e;for(;s.length&&n;)n=n[s.shift()];return n}function o(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=i(String(e||"")))>(t=i(String(t||"")))?1:t>e?-1:0}class r{constructor(e,t={}){this.items=e,this.settings={diacritics:!0,...t}}tokenize(e,i){if(!(e=String(e||"").toLowerCase().trim()).length)return[];const n=[],o=e.split(/\s+/);for(const r of o){let e=s(r);if(this.settings.diacritics)for(const i in t)e=e.replace(new RegExp(i,"g"),t[i]);i&&(e="\\b"+e),n.push({string:r,regex:new RegExp(e,"i")})}return n}getScoreFunction(e,t){e=this.prepareSearch(e,t);const{tokens:i}=e,{fields:s}=e.options,o=i.length,{nesting:r}=e.options,l=(e,t)=>{if(!e)return 0;const i=(e=String(e||"")).search(t.regex);if(-1===i)return 0;let s=t.string.length/e.length;return 0===i&&(s+=.5),s},c=s.length,h=0===c?()=>0:1===c?(e,t)=>l(n(t,s[0],r),e):(e,t)=>{let i=0;for(let o=0;o<c;o++)i+=l(n(t,s[o],r),e);return i/c};return o?1===o?e=>h(i[0],e):"and"===e.options.conjunction?e=>{let t=0;for(let s=0;s<o;s++){const n=h(i[s],e);if(n<=0)return 0;t+=n}return t/o}:e=>{let t=0;for(let s=0;s<o;s++)t+=h(i[s],e);return t/o}:()=>0}getSortFunction(e,t){const i=!(e=this.prepareSearch(e,t)).query&&t.sort_empty||t.sort,s=(e,i)=>"$score"===e?i.score:n(this.items[i.id],e,t.nesting),r=[];if(i)for(const n of i)(e.query||"$score"!==n.field)&&r.push(n);if(e.query){let e=!0;for(const t of r)if("$score"===t.field){e=!1;break}e&&r.unshift({field:"$score",direction:"desc"})}else{const e=r.findIndex(e=>"$score"===e.field);-1!==e&&r.splice(e,1)}const l=r.map(e=>"desc"===e.direction?-1:1),c=r.length;if(!c)return null;if(1===c){const e=r[0].field,t=l[0];return(i,n)=>t*o(s(e,i),s(e,n))}return(e,t)=>{for(let i=0;i<c;i++){const n=l[i]*o(s(r[i].field,e),s(r[i].field,t));if(n)return n}return 0}}prepareSearch(e,t){return"object"==typeof e?e:((t={...t}).fields&&!Array.isArray(t.fields)&&(t.fields=[t.fields]),t.sort&&!Array.isArray(t.sort)&&(t.sort=[t.sort]),t.sort_empty&&!Array.isArray(t.sort_empty)&&(t.sort_empty=[t.sort_empty]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t.respect_word_boundaries),total:0,items:[]})}search(e,t){const i=this.prepareSearch(e,t),s=i.options,n=i.query,o=s.score||this.getScoreFunction(i),r=this.items;if(n.length){(Array.isArray(r)?e=>r.forEach((t,i)=>e(t,i)):e=>Object.keys(r).forEach(t=>e(r[t],t)))((e,t)=>{const n=o(e);(!1===s.filter||n>0)&&i.items.push({score:n,id:t})})}else{(Array.isArray(r)?e=>r.forEach((t,i)=>e(t,i)):e=>Object.keys(r).forEach(t=>e(r[t],t)))((e,t)=>{i.items.push({score:1,id:t})})}const l=this.getSortFunction(i,s);return l&&i.items.sort(l),i.total=i.items.length,"number"==typeof s.limit&&(i.items=i.items.slice(0,s.limit)),i}}function l(e){return"string"!=typeof e?"":e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let c,h=0;function a(e){return null==e?null:"boolean"==typeof e?e?"1":"0":String(e)}function d(e,t=10){const i=function(e,t){c||(c=document.createElement("canvas"));const i=c.getContext("2d");if(t){const e=window.getComputedStyle(t);i.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`}return i.measureText(e).width}(e.value||e.placeholder||"",e)+t;e.style.width=Math.max(i,60)+"px"}function u(e){return e.tagName&&"select"===e.tagName.toLowerCase()}const p={delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,showAddOptionOnCreate:!0,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1e3,maxItems:null,hideSelected:null,selectOnTab:!0,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,loadThrottle:300,loadingClass:"loading",placeholder:"",dropdownPlaceholder:"",mode:null,search:!0,showArrow:!0,showSelectedCount:!1,valueField:"value",labelField:"text",disabledField:"disabled",optgroupField:"optgroup",optgroupLabelField:"label",optgroupValueField:"value",sortField:"$order",searchField:["text"],searchConjunction:"and",respectWordBoundaries:!1,normalize:!0,plugins:[],render:{option:null,item:null,optionCreate:null,optgroupHeader:null,noResults:null,dropdownPlaceholder:null,loading:null},load:null,score:null,onChange:null,onItemAdd:null,onItemRemove:null,onClear:null,onOptionAdd:null,onOptionRemove:null,onDropdownOpen:null,onDropdownClose:null,onType:null,onFocus:null,onBlur:null,onInitialize:null},f={};function g(e={}){return()=>({isOpen:!1,isFocused:!1,isDisabled:!1,isLocked:!1,isLoading:!1,isInvalid:!1,query:"",activeIndex:-1,caretPos:0,items:[],options:{},optgroups:{},userOptions:{},optionOrder:[],loadedSearches:{},lastQuery:"",_config:{},_sifter:null,_sourceEl:null,_id:"",_rtl:!1,_plugins:[],_renderCache:{},get config(){return this._config},get isMultiple(){return"multi"===this._config.mode},get isSingle(){return"single"===this._config.mode},get isFull(){return null!==this._config.maxItems&&this.items.length>=this._config.maxItems},get hasOptions(){return Object.keys(this.options).length>0},get canCreate(){if(!this._config.create)return!1;if(!this.query.trim())return!1;if(this.isFull)return!1;if(this._config.createFilter){const e=this._config.createFilter;if("function"==typeof e)return e(this.query);if(e instanceof RegExp)return e.test(this.query);if("string"==typeof e)return new RegExp(e).test(this.query)}return!Object.values(this.options).find(e=>{var t;return(null==(t=e[this._config.labelField])?void 0:t.toLowerCase())===this.query.toLowerCase()})},get selectedItems(){return this.items.map(e=>this.options[a(e)]).filter(Boolean)},get filteredOptions(){return this._getFilteredOptions()},get placeholderText(){return this.items.length>0&&this.isSingle?"":this._config.placeholder||""},get selectedCountText(){return this.items.length},get currentValueText(){if(!this.isSingle||!this.items.length)return"";const e=this.options[a(this.items[0])];return e?e[this._config.labelField]:""},init(){if(this._id=function(e="selectize"){return`${e}-${++h}-${Math.random().toString(36).slice(2,8)}`}(),this._config={...p,...e},this._sourceEl=this.$el.querySelector('select, input[type="text"], input[type="hidden"]'),this._sourceEl&&u(this._sourceEl)){const i=function(e){const t=[],i=[],s=[],n=(e,i=null)=>{const n=e.value,o=e.textContent.trim(),r=e.disabled;if(!n&&!o)return;const l={value:n,text:o,disabled:r};if(e.dataset.data)try{Object.assign(l,JSON.parse(e.dataset.data))}catch(c){}null!==i&&(l.optgroup=i),e.selected&&s.push(n),t.push(l)};for(const o of e.children)if("optgroup"===o.tagName.toLowerCase()){const e=o.getAttribute("label")||"";i.push({value:e,label:e,disabled:o.disabled});for(const t of o.children)n(t,e)}else"option"===o.tagName.toLowerCase()&&n(o);return{options:t,optgroups:i,selectedValues:s}}(this._sourceEl),s=i.options.find(e=>""===e.value);s&&!this._config.placeholder&&(this._config.placeholder=s.text);const n=i.selectedValues.filter(e=>""!==e),o=this._config.options||[],r=[...i.options,...o];this._registerOptions(r);for(const e of i.optgroups)this.optgroups[e.value]=e;n.length&&(this.items=[...n]),e.mode||(this._config.mode=this._sourceEl.multiple?"multi":"single"),this._sourceEl.hasAttribute("required")&&(this.isInvalid=!this.items.length),this._sourceEl.disabled&&(this.isDisabled=!0),this._sourceEl.placeholder&&(this._config.placeholder=this._sourceEl.placeholder),this._sourceEl.style.display="none",this._sourceEl.setAttribute("tabindex","-1"),this._rtl=(t=this._sourceEl,"rtl"===window.getComputedStyle(t).direction)}else{const e=this._config.options||[];if(this._registerOptions(e),this._config.optgroups)for(const t of this._config.optgroups)this.optgroups[t[this._config.optgroupValueField]]=t;this._config.items&&(this.items=[...this._config.items])}var t;this._config.mode||(this._config.mode=1===this._config.maxItems?"single":"multi"),"single"===this._config.mode&&(this._config.maxItems=1),null===this._config.hideSelected&&(this._config.hideSelected="multi"===this._config.mode&&!this._config.showSelectedCount),this._config.showSelectedCount&&(this._config.hideSelected=!1),this._sifter=new r(this.options,{diacritics:this._config.diacritics}),this._initPlugins(),this._config.load&&this._config.loadThrottle&&(this._debouncedLoad=function(e,t){let i;return function(...s){clearTimeout(i),i=setTimeout(()=>e.apply(this,s),t)}}(this._performLoad.bind(this),this._config.loadThrottle)),this._config.preload&&this.$nextTick(()=>{"focus"===this._config.preload||this._performLoad("")}),this._trigger("onInitialize"),this._onClickOutside=e=>{this.$el.contains(e.target)||(this.close(),this.blur())},document.addEventListener("mousedown",this._onClickOutside)},destroy(){document.removeEventListener("mousedown",this._onClickOutside),this._sourceEl&&(this._sourceEl.style.display="",this._sourceEl.removeAttribute("tabindex"))},_initPlugins(){const e=this._config.plugins||[];for(const t of e){const e="string"==typeof t?t:t.name,i="string"==typeof t?{}:t.options||{};f[e]?(f[e].call(this,i),this._plugins.push(e)):console.warn(`[selectize] Plugin "${e}" not found.`)}},_registerOptions(e){for(const t of e)this.addOption(t,!0)},addOption(e,t=!1){if(Array.isArray(e)){for(const i of e)this.addOption(i,t);return}const i=a(e[this._config.valueField]);null===i||this.options[i]||(e.$order=e.$order||++this._orderCounter||(this._orderCounter=1),this.options[i]=e,this.optionOrder.push(i),this._sifter&&(this._sifter.items=this.options),this._clearRenderCache(),t||this._trigger("onOptionAdd",i,e))},updateOption(e,t){const i=a(e);if(!i||!this.options[i])return;const s=a(t[this._config.valueField]);if(t.$order=this.options[i].$order,this.options[s]=t,i!==s){delete this.options[i];const e=this.optionOrder.indexOf(i);-1!==e&&(this.optionOrder[e]=s);const t=this.items.indexOf(i);-1!==t&&(this.items[t]=s)}this._sifter&&(this._sifter.items=this.options),this._clearRenderCache()},removeOption(e){const t=a(e);if(!t)return;delete this.options[t],delete this.userOptions[t];const i=this.optionOrder.indexOf(t);-1!==i&&this.optionOrder.splice(i,1),this.items=this.items.filter(e=>e!==t),this._sifter&&(this._sifter.items=this.options),this._clearRenderCache(),this._trigger("onOptionRemove",t)},clearOptions(){const e={};for(const t of this.items)this.options[t]&&(e[t]=this.options[t]);this.options=e,this.optionOrder=Object.keys(e),this.userOptions={},this._sifter&&(this._sifter.items=this.options),this._clearRenderCache()},getOption(e){return this.options[a(e)]||null},addItem(e,t=!1){const i=a(e);i&&this.options[i]&&(this.items.includes(i)||(this.isSingle&&this.items.length&&this.removeItem(this.items[0],!0),this.isFull||(this.items.push(i),this.caretPos=this.items.length,this._syncSourceElement(),this._clearRenderCache(),this.query="",(this._config.closeAfterSelect||this.isSingle)&&this.close(),this.isFull&&this.close(),t||(this._trigger("onItemAdd",i,this.options[i]),this._trigger("onChange",this.getValue())))))},removeItem(e,t=!1){const i=a(e),s=this.items.indexOf(i);-1!==s&&(this.items.splice(s,1),this.caretPos>this.items.length&&(this.caretPos=this.items.length),this._syncSourceElement(),this._clearRenderCache(),t||(this._trigger("onItemRemove",i),this._trigger("onChange",this.getValue())))},clear(e=!1){this.items.length&&(this.items=[],this.caretPos=0,this._syncSourceElement(),this._clearRenderCache(),e||(this._trigger("onClear"),this._trigger("onChange",this.getValue())))},getValue(){return this.isSingle?this.items.length?this.items[0]:"":[...this.items]},setValue(e,t=!1){this.clear(!0);const i=Array.isArray(e)?e:[e];for(const s of i)""!==s&&null!=s&&this.addItem(s,!0);t||this._trigger("onChange",this.getValue())},createItem(e=null){const t=null!==e?e:this.query;if(!t.trim())return;if(!this._config.create)return;const i=this._config.create;let s;"function"==typeof i?(s=i(t,e=>{e&&(this.addOption(e),this.addItem(e[this._config.valueField]))}),s&&"object"==typeof s&&(this.addOption(s),this.addItem(s[this._config.valueField]))):(s={},s[this._config.valueField]=t,s[this._config.labelField]=t,this.addOption(s),this.addItem(t)),this.query="",this._clearRenderCache()},_getFilteredOptions(){const e=this._config;if(!this._sifter)return[];const t=Array.isArray(e.searchField)?e.searchField:[e.searchField];let i;i=e.sortField?"string"==typeof e.sortField?[{field:e.sortField,direction:"asc"}]:Array.isArray(e.sortField)?e.sortField:[e.sortField]:[{field:"$order",direction:"asc"}];let s=this.query;e.normalize&&s&&(s=s.normalize("NFD").replace(/[\u0300-\u036f]/g,""));const n={fields:t,conjunction:e.searchConjunction,sort:i,nesting:t.some(e=>e.includes(".")),respect_word_boundaries:e.respectWordBoundaries,limit:e.maxOptions};e.score&&(n.score=e.score);let o=this._sifter.search(s,n).items.map(e=>{const t=this.options[e.id];return t?{...t,_score:e.score}:null}).filter(Boolean);return e.hideSelected&&(o=o.filter(t=>!this.items.includes(a(t[e.valueField])))),o=o.filter(t=>!t[e.disabledField]),o},open(){this.isOpen||this.isDisabled||this.isLocked||(this.isOpen=!0,this.activeIndex=this._config.setFirstOptionActive?0:-1,this._trigger("onDropdownOpen"),this.$nextTick(()=>{this._scrollToActive()}))},close(){this.isOpen&&(this.isOpen=!1,this.activeIndex=-1,this._trigger("onDropdownClose"))},toggle(){this.isOpen?this.close():this.open()},focus(){if(this.isDisabled)return;this.isFocused=!0;const e=this.$refs.searchInput;e&&this.$nextTick(()=>e.focus()),this._config.openOnFocus&&this.open(),"focus"!==this._config.preload||this.loadedSearches[""]||this._performLoad(""),this._trigger("onFocus")},blur(){this.isFocused&&(this.isFocused=!1,this._config.createOnBlur&&this.query.trim()&&this.canCreate&&this.createItem(),this.close(),this._trigger("onBlur"))},onKeyDown(e){if(this.isDisabled||this.isLocked)return;const t=this.filteredOptions,i=this.canCreate,s=t.length+(i?1:0);switch(e.key){case"ArrowDown":e.preventDefault(),this.isOpen?(this.activeIndex=Math.min(this.activeIndex+1,s-1),this._scrollToActive()):this.open();break;case"ArrowUp":e.preventDefault(),this.isOpen&&(this.activeIndex=Math.max(this.activeIndex-1,0),this._scrollToActive());break;case"Enter":e.preventDefault(),this.isOpen&&this.activeIndex>=0?this.activeIndex<t.length?this.selectOption(t[this.activeIndex]):i&&this.createItem():this.isOpen||this.open();break;case"Escape":e.preventDefault(),this.close();break;case"Tab":this.isOpen&&this._config.selectOnTab&&this.activeIndex>=0&&(e.preventDefault(),this.activeIndex<t.length?this.selectOption(t[this.activeIndex]):i&&this.createItem());break;case"Backspace":if(!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const t=this.items[this.items.length-1];this.removeItem(t)}break;case"Delete":if(!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const t=this.items[this.items.length-1];this.removeItem(t)}break;case"a":case"A":(e.ctrlKey||e.metaKey)&&this.isMultiple&&e.preventDefault()}},onInput(){if(this._trigger("onType",this.query),this.isOpen||this.open(),this.activeIndex=this._config.setFirstOptionActive||this.query?0:-1,this._config.load&&this.query){const e=this.query;this.loadedSearches[e]||(this._debouncedLoad?this._debouncedLoad(e):this._performLoad(e))}this.$refs.searchInput&&this.isMultiple&&d(this.$refs.searchInput)},onPaste(e){if(!this.isMultiple)return;const t=(e.clipboardData||window.clipboardData).getData("text");if(!t)return;const i=this._config.splitOn||this._config.delimiter;if(!i)return;e.preventDefault();const s=i instanceof RegExp?i:new RegExp("["+i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")+"]"),n=t.split(s).map(e=>e.trim()).filter(Boolean);for(const o of n){const e=Object.values(this.options).find(e=>{var t,i;return(null==(t=e[this._config.labelField])?void 0:t.toLowerCase())===o.toLowerCase()||(null==(i=e[this._config.valueField])?void 0:i.toLowerCase())===o.toLowerCase()});e?this.addItem(e[this._config.valueField]):this._config.create&&this.createItem(o)}},selectOption(e){if(!e)return;if(e[this._config.disabledField])return;const t=e[this._config.valueField];if(""===t)return this.clear(),this.close(),this.isFocused=!1,void(this.$refs.searchInput&&this.$refs.searchInput.blur());this._config.showSelectedCount&&this.isMultiple&&this.isSelected(e)?this.removeItem(t):(this.addItem(t),this.query="",this.isSingle?(this.isFocused=!1,this.loadedSearches={},this.$refs.searchInput&&this.$refs.searchInput.blur()):this.$refs.searchInput&&(this.$refs.searchInput.focus(),d(this.$refs.searchInput)))},_performLoad(e){this._config.load&&(this.loadedSearches[e]||(this.isLoading=!0,this.loadedSearches[e]=!0,this._config.load(e,e=>{if(this.isLoading=!1,e&&Array.isArray(e)){for(const t of e)this.addOption(t,!0);this._clearRenderCache()}})))},renderOption(e){var t;const i=this._config,s=e[i.labelField]||"";return(null==(t=i.render)?void 0:t.option)?i.render.option(e,l):i.highlight&&this.query?function(e,t){if(!t||!t.length)return l(e);const i=l(e),s=new RegExp("("+t.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")+")","ig");return i.replace(s,'<span class="font-semibold text-inherit">$1</span>')}(s,this.query):l(s)},renderItem(e){var t;if(!e)return"";const i=this._config,s=e[i.labelField]||"";return(null==(t=i.render)?void 0:t.item)?i.render.item(e,l):l(s)},renderOptionCreate(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.optionCreate)?t.render.optionCreate({input:this.query},l):`Add <span class="font-medium">${l(this.query)}</span>...`},renderNoResults(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.noResults)?t.render.noResults({query:this.query},l):"No results found"},renderDropdownPlaceholder(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.dropdownPlaceholder)?t.render.dropdownPlaceholder({},l):l(t.dropdownPlaceholder||"")},renderLoading(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.loading)?t.render.loading({query:this.query},l):"Loading..."},addOptionGroup(e,t){this.optgroups[e]=t,this._clearRenderCache()},removeOptionGroup(e){delete this.optgroups[e],this._clearRenderCache()},getGroupedOptions(){const e=this.filteredOptions,t=this._config,i={},s=[];for(const o of e){const e=o[t.optgroupField];e&&this.optgroups[e]?(i[e]||(i[e]=[]),i[e].push(o)):s.push(o)}const n=[];for(const[o,r]of Object.entries(i)){const e=this.optgroups[o];n.push({id:o,label:e[t.optgroupLabelField]||o,options:r})}return s.length&&n.push({id:null,label:null,options:s}),n},_getGroupedView(){const e=this.getGroupedOptions();let t=0;return e.map((e,i)=>{const s={key:e.id||"__ungrouped_"+i,label:e.label,options:e.options,offset:t};return t+=e.options.length,s})},get hasOptgroups(){return Object.keys(this.optgroups).length>0},lock(){this.isLocked=!0,this.close()},unlock(){this.isLocked=!1},disable(){this.isDisabled=!0,this.close()},enable(){this.isDisabled=!1},setMaxItems(e){this._config.maxItems=e,this.isFull&&this.close()},_syncSourceElement(){var e;if(this._sourceEl)if(u(this._sourceEl)){for(const e of this._sourceEl.options)e.selected=this.items.includes(e.value);for(const t of this.items){if(!Array.from(this._sourceEl.options).some(e=>e.value===t)){const i=document.createElement("option");i.value=t,i.textContent=(null==(e=this.options[t])?void 0:e[this._config.labelField])||t,i.selected=!0,this._sourceEl.appendChild(i)}}this._sourceEl.dispatchEvent(new Event("change",{bubbles:!0}))}else this._sourceEl.value=this.isSingle?this.items[0]||"":this.items.join(this._config.delimiter),this._sourceEl.dispatchEvent(new Event("input",{bubbles:!0})),this._sourceEl.dispatchEvent(new Event("change",{bubbles:!0}))},_scrollToActive(){this.$nextTick(()=>{const e=this.$refs.dropdown;if(!e)return;const t=e.querySelector('[data-active="true"]');t&&t.scrollIntoView({block:"nearest"})})},_trigger(e,...t){const i=this._config[e];"function"==typeof i&&i.apply(this,t);const s=e.replace(/^on/,"").toLowerCase();this.$el.dispatchEvent(new CustomEvent(`selectra:${s}`,{detail:t,bubbles:!0}))},_clearRenderCache(){this._renderCache={}},isSelected(e){return this.items.includes(a(e[this._config.valueField]))},optionKey(e){return a(e[this._config.valueField])}})}function m(e,t){f[e]=t}m("remove_button",function(e={}){var t;const{label:i="&times;",title:s="Remove",className:n=""}=e,o=null==(t=this._config.render)?void 0:t.item;this._config.render||(this._config.render={});const r=this;this._config.render.item=function(e,t){const i=r._config.labelField;r._config.valueField;return`<span class="inline-flex items-center">${o?o(e,t):t(e[i]||"")}</span>`},this._showRemoveButton=!0,this._removeButtonLabel=i,this._removeButtonTitle=s,this._removeButtonClass=n}),m("clear_button",function(e={}){const{title:t="Clear All",className:i="",label:s="&times;"}=e;this._showClearButton=!0,this._clearButtonTitle=t,this._clearButtonLabel=s,this._clearButtonClass=i}),m("restore_on_backspace",function(e={}){const t=e.text||(e=>e[this._config.labelField]||""),i=this.onKeyDown.bind(this);this.onKeyDown=e=>{if("Backspace"===e.key&&!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const i=this.items[this.items.length-1],s=this.options[i];return this.removeItem(i),void(s&&(this.query=t(s),this.$refs.searchInput&&(this.$refs.searchInput.value=this.query)))}i(e)}}),m("dropdown_header",function(e={}){const{title:t="",showClose:i=!0,headerClass:s=""}=e;this._dropdownHeader=!0,this._dropdownHeaderTitle=t,this._dropdownHeaderShowClose=i,this._dropdownHeaderClass=s}),m("tag_limit",function(e={}){const{tagLimit:t=3}=e;this._tagLimit=t,this._showAllTags=!1,Object.defineProperty(this,"visibleItems",{get(){const e=this.selectedItems;return this.isFocused||this._showAllTags||!this._tagLimit?e:e.slice(0,this._tagLimit)}}),Object.defineProperty(this,"hiddenItemCount",{get(){const e=this.selectedItems;return this.isFocused||this._showAllTags||!this._tagLimit?0:Math.max(0,e.length-this._tagLimit)}})}),m("auto_select_on_type",function(){const e=this.blur.bind(this);this.blur=()=>{if(this.query.trim()&&this.filteredOptions.length){const e=this.filteredOptions[0];this.selectOption(e)}this.query="",e()}}),m("select_on_focus",function(){const e=this.focus.bind(this);this.focus=()=>{if(e(),this.isSingle&&this.items.length){const e=this.options[this.items[0]];e&&(this.query=e[this._config.labelField]||"",this.$refs.searchInput&&this.$nextTick(()=>this.$refs.searchInput.select()))}}}),m("read_only",function(e={}){const{readOnly:t=!0}=e;this._isReadOnly=t,this.readonly=e=>{this._isReadOnly=void 0!==e?e:!this._isReadOnly,this._isReadOnly&&this.close()};const i=this.addItem.bind(this),s=this.removeItem.bind(this),n=this.createItem.bind(this),o=this.clear.bind(this);this.addItem=(e,t)=>{this._isReadOnly||i(e,t)},this.removeItem=(e,t)=>{this._isReadOnly||s(e,t)},this.createItem=e=>{this._isReadOnly||n(e)},this.clear=e=>{this._isReadOnly||o(e)}}),m("auto_position",function(){this._autoPosition=!0;const e=this.open.bind(this);this.open=()=>{e(),this.$nextTick(()=>{const e=this.$refs.dropdown,t=this.$el;if(!e||!t)return;const i=t.getBoundingClientRect(),s=window.innerHeight-i.bottom,n=i.top,o=e.offsetHeight||250;this._dropdownPosition=s<o&&n>s?"top":"bottom"})},this._dropdownPosition="bottom"});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Selectra={})}(this,function(e){"use strict";/*! Selectra v1.0.9 | Apache-2.0 License */const t={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",j:"[jȷĴĵɈɉʝɟʲ]",k:"[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",l:"[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",n:"[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",o:"[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]",p:"[pṔṕṖṗⱣᵽƤƥᵱ]",q:"[qꝖꝗʠɊɋꝘꝙq̃]",r:"[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]",s:"[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]",t:"[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]",u:"[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]",v:"[vṼṽṾṿƲʋꝞꝟⱱʋ]",w:"[wẂẃẀẁŴŵẄẅẆẇẈẉ]",x:"[xẌẍẊẋχ]",y:"[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]",z:"[zŹźẐẑŽžŻżẒẓẔẕƵƶ]"},i=(()=>{const e={};let i="";for(const n in t){const s=t[n].substring(2,t[n].length-1);i+=s;for(let t=0;t<s.length;t++)e[s.charAt(t)]=n}const s=new RegExp("["+i+"]","g");return t=>t.replace(s,t=>e[t]||"").toLowerCase()})();function s(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function n(e,t,i){if(!e||!t)return;if(!i)return e[t];const s=t.split(".");let n=e;for(;s.length&&n;)n=n[s.shift()];return n}function o(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=i(String(e||"")))>(t=i(String(t||"")))?1:t>e?-1:0}class r{constructor(e,t={}){this.items=e,this.settings={diacritics:!0,...t}}tokenize(e,i){if(!(e=String(e||"").toLowerCase().trim()).length)return[];const n=[],o=e.split(/\s+/);for(const r of o){let e=s(r);if(this.settings.diacritics)for(const i in t)e=e.replace(new RegExp(i,"g"),t[i]);i&&(e="\\b"+e),n.push({string:r,regex:new RegExp(e,"i")})}return n}getScoreFunction(e,t){e=this.prepareSearch(e,t);const{tokens:i}=e,{fields:s}=e.options,o=i.length,{nesting:r}=e.options,l=(e,t)=>{if(!e)return 0;const i=(e=String(e||"")).search(t.regex);if(-1===i)return 0;let s=t.string.length/e.length;return 0===i&&(s+=.5),s},c=s.length,h=0===c?()=>0:1===c?(e,t)=>l(n(t,s[0],r),e):(e,t)=>{let i=0;for(let o=0;o<c;o++)i+=l(n(t,s[o],r),e);return i/c};return o?1===o?e=>h(i[0],e):"and"===e.options.conjunction?e=>{let t=0;for(let s=0;s<o;s++){const n=h(i[s],e);if(n<=0)return 0;t+=n}return t/o}:e=>{let t=0;for(let s=0;s<o;s++)t+=h(i[s],e);return t/o}:()=>0}getSortFunction(e,t){const i=!(e=this.prepareSearch(e,t)).query&&t.sort_empty||t.sort,s=(e,i)=>"$score"===e?i.score:n(this.items[i.id],e,t.nesting),r=[];if(i)for(const n of i)(e.query||"$score"!==n.field)&&r.push(n);if(e.query){let e=!0;for(const t of r)if("$score"===t.field){e=!1;break}e&&r.unshift({field:"$score",direction:"desc"})}else{const e=r.findIndex(e=>"$score"===e.field);-1!==e&&r.splice(e,1)}const l=r.map(e=>"desc"===e.direction?-1:1),c=r.length;if(!c)return null;if(1===c){const e=r[0].field,t=l[0];return(i,n)=>t*o(s(e,i),s(e,n))}return(e,t)=>{for(let i=0;i<c;i++){const n=l[i]*o(s(r[i].field,e),s(r[i].field,t));if(n)return n}return 0}}prepareSearch(e,t){return"object"==typeof e?e:((t={...t}).fields&&!Array.isArray(t.fields)&&(t.fields=[t.fields]),t.sort&&!Array.isArray(t.sort)&&(t.sort=[t.sort]),t.sort_empty&&!Array.isArray(t.sort_empty)&&(t.sort_empty=[t.sort_empty]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e,t.respect_word_boundaries),total:0,items:[]})}search(e,t){const i=this.prepareSearch(e,t),s=i.options,n=i.query,o=s.score||this.getScoreFunction(i),r=this.items;if(n.length){(Array.isArray(r)?e=>r.forEach((t,i)=>e(t,i)):e=>Object.keys(r).forEach(t=>e(r[t],t)))((e,t)=>{const n=o(e);(!1===s.filter||n>0)&&i.items.push({score:n,id:t})})}else{(Array.isArray(r)?e=>r.forEach((t,i)=>e(t,i)):e=>Object.keys(r).forEach(t=>e(r[t],t)))((e,t)=>{i.items.push({score:1,id:t})})}const l=this.getSortFunction(i,s);return l&&i.items.sort(l),i.total=i.items.length,"number"==typeof s.limit&&(i.items=i.items.slice(0,s.limit)),i}}function l(e){return"string"!=typeof e?"":e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let c,h=0;function a(e){return null==e?null:"boolean"==typeof e?e?"1":"0":String(e)}function d(e,t=10){const i=function(e,t){c||(c=document.createElement("canvas"));const i=c.getContext("2d");if(t){const e=window.getComputedStyle(t);i.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`}return i.measureText(e).width}(e.value||e.placeholder||"",e)+t;e.style.width=Math.max(i,60)+"px"}function u(e){return e.tagName&&"select"===e.tagName.toLowerCase()}const p={delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,showAddOptionOnCreate:!0,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1e3,maxItems:null,hideSelected:null,selectOnTab:!0,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,loadThrottle:300,loadingClass:"loading",placeholder:"",dropdownPlaceholder:"",mode:null,search:!0,showArrow:!0,showSelectedCount:!1,valueField:"value",labelField:"text",disabledField:"disabled",optgroupField:"optgroup",optgroupLabelField:"label",optgroupValueField:"value",sortField:"$order",searchField:["text"],searchConjunction:"and",respectWordBoundaries:!1,normalize:!0,plugins:[],render:{option:null,item:null,optionCreate:null,optgroupHeader:null,noResults:null,dropdownPlaceholder:null,loading:null},load:null,score:null,onChange:null,onItemAdd:null,onItemRemove:null,onClear:null,onOptionAdd:null,onOptionRemove:null,onDropdownOpen:null,onDropdownClose:null,onType:null,onFocus:null,onBlur:null,onInitialize:null},f={};function g(e={}){return()=>({isOpen:!1,isFocused:!1,isDisabled:!1,isLocked:!1,isLoading:!1,isInvalid:!1,query:"",activeIndex:-1,caretPos:0,items:[],options:{},optgroups:{},userOptions:{},optionOrder:[],loadedSearches:{},lastQuery:"",_config:{},_sifter:null,_sourceEl:null,_id:"",_rtl:!1,_plugins:[],_renderCache:{},get config(){return this._config},get isMultiple(){return"multi"===this._config.mode},get isSingle(){return"single"===this._config.mode},get isFull(){return null!==this._config.maxItems&&this.items.length>=this._config.maxItems},get hasOptions(){return Object.keys(this.options).length>0},get canCreate(){if(!this._config.create)return!1;if(!this.query.trim())return!1;if(this.isFull)return!1;if(this._config.createFilter){const e=this._config.createFilter;if("function"==typeof e)return e(this.query);if(e instanceof RegExp)return e.test(this.query);if("string"==typeof e)return new RegExp(e).test(this.query)}return!Object.values(this.options).find(e=>{var t;return(null==(t=e[this._config.labelField])?void 0:t.toLowerCase())===this.query.toLowerCase()})},get selectedItems(){return this.items.map(e=>this.options[a(e)]).filter(Boolean)},get filteredOptions(){return this._getFilteredOptions()},get placeholderText(){return this.items.length>0&&this.isSingle?"":this._config.placeholder||""},get selectedCountText(){return this.items.length},get currentValueText(){if(!this.isSingle||!this.items.length)return"";const e=this.options[a(this.items[0])];return e?e[this._config.labelField]:""},init(){if(this._id=function(e="selectize"){return`${e}-${++h}-${Math.random().toString(36).slice(2,8)}`}(),this._config={...p,...e},this._sourceEl=this.$el.querySelector('select, input[type="text"], input[type="hidden"]'),this._sourceEl&&u(this._sourceEl)){const i=function(e){const t=[],i=[],s=[],n=(e,i=null)=>{const n=e.value,o=e.textContent.trim(),r=e.disabled;if(!n&&!o)return;const l={value:n,text:o,disabled:r};if(e.dataset.data)try{Object.assign(l,JSON.parse(e.dataset.data))}catch(c){}null!==i&&(l.optgroup=i),e.selected&&s.push(n),t.push(l)};for(const o of e.children)if("optgroup"===o.tagName.toLowerCase()){const e=o.getAttribute("label")||"";i.push({value:e,label:e,disabled:o.disabled});for(const t of o.children)n(t,e)}else"option"===o.tagName.toLowerCase()&&n(o);return{options:t,optgroups:i,selectedValues:s}}(this._sourceEl),s=i.options.find(e=>""===e.value);s&&!this._config.placeholder&&(this._config.placeholder=s.text);const n=i.selectedValues.filter(e=>""!==e),o=this._config.options||[],r=[...i.options,...o];this._registerOptions(r);for(const e of i.optgroups)this.optgroups[e.value]=e;n.length&&(this.items=[...n]),e.mode||(this._config.mode=this._sourceEl.multiple?"multi":"single"),this._sourceEl.hasAttribute("required")&&(this.isInvalid=!this.items.length),this._sourceEl.disabled&&(this.isDisabled=!0),this._sourceEl.placeholder&&(this._config.placeholder=this._sourceEl.placeholder),this._sourceEl.style.display="none",this._sourceEl.setAttribute("tabindex","-1"),this._rtl=(t=this._sourceEl,"rtl"===window.getComputedStyle(t).direction)}else{const e=this._config.options||[];if(this._registerOptions(e),this._config.optgroups)for(const t of this._config.optgroups)this.optgroups[t[this._config.optgroupValueField]]=t;this._config.items&&(this.items=[...this._config.items])}var t;this._config.mode||(this._config.mode=1===this._config.maxItems?"single":"multi"),"single"===this._config.mode&&(this._config.maxItems=1),null===this._config.hideSelected&&(this._config.hideSelected="multi"===this._config.mode&&!this._config.showSelectedCount),this._config.showSelectedCount&&(this._config.hideSelected=!1),this._sifter=new r(this.options,{diacritics:this._config.diacritics}),this._initPlugins(),this._config.load&&this._config.loadThrottle&&(this._debouncedLoad=function(e,t){let i;return function(...s){clearTimeout(i),i=setTimeout(()=>e.apply(this,s),t)}}(this._performLoad.bind(this),this._config.loadThrottle)),this._config.preload&&this.$nextTick(()=>{"focus"===this._config.preload||this._performLoad("")}),this._trigger("onInitialize"),this._onClickOutside=e=>{this.$el.contains(e.target)||(this.close(),this.blur())},document.addEventListener("mousedown",this._onClickOutside)},destroy(){document.removeEventListener("mousedown",this._onClickOutside),this._sourceEl&&(this._sourceEl.style.display="",this._sourceEl.removeAttribute("tabindex"))},_initPlugins(){const e=this._config.plugins||[];for(const t of e){const e="string"==typeof t?t:t.name,i="string"==typeof t?{}:t.options||{};f[e]?(f[e].call(this,i),this._plugins.push(e)):console.warn(`[selectize] Plugin "${e}" not found.`)}},_registerOptions(e){for(const t of e)this.addOption(t,!0)},addOption(e,t=!1){if(Array.isArray(e)){for(const i of e)this.addOption(i,t);return}const i=a(e[this._config.valueField]);null===i||this.options[i]||(e.$order=e.$order||++this._orderCounter||(this._orderCounter=1),this.options[i]=e,this.optionOrder.push(i),this._sifter&&(this._sifter.items=this.options),this._clearRenderCache(),t||this._trigger("onOptionAdd",i,e))},updateOption(e,t){const i=a(e);if(!i||!this.options[i])return;const s=a(t[this._config.valueField]);if(t.$order=this.options[i].$order,this.options[s]=t,i!==s){delete this.options[i];const e=this.optionOrder.indexOf(i);-1!==e&&(this.optionOrder[e]=s);const t=this.items.indexOf(i);-1!==t&&(this.items[t]=s)}this._sifter&&(this._sifter.items=this.options),this._clearRenderCache()},removeOption(e){const t=a(e);if(!t)return;delete this.options[t],delete this.userOptions[t];const i=this.optionOrder.indexOf(t);-1!==i&&this.optionOrder.splice(i,1),this.items=this.items.filter(e=>e!==t),this._sifter&&(this._sifter.items=this.options),this._clearRenderCache(),this._trigger("onOptionRemove",t)},clearOptions(){const e={};for(const t of this.items)this.options[t]&&(e[t]=this.options[t]);this.options=e,this.optionOrder=Object.keys(e),this.userOptions={},this._sifter&&(this._sifter.items=this.options),this._clearRenderCache()},getOption(e){return this.options[a(e)]||null},addItem(e,t=!1){const i=a(e);i&&this.options[i]&&(this.items.includes(i)||(this.isSingle&&this.items.length&&this.removeItem(this.items[0],!0),this.isFull||(this.items.push(i),this.caretPos=this.items.length,this._syncSourceElement(),this._clearRenderCache(),this.query="",(this._config.closeAfterSelect||this.isSingle)&&this.close(),this.isFull&&this.close(),t||(this._trigger("onItemAdd",i,this.options[i]),this._trigger("onChange",this.getValue())))))},removeItem(e,t=!1){const i=a(e),s=this.items.indexOf(i);-1!==s&&(this.items.splice(s,1),this.caretPos>this.items.length&&(this.caretPos=this.items.length),this._syncSourceElement(),this._clearRenderCache(),t||(this._trigger("onItemRemove",i),this._trigger("onChange",this.getValue())))},clear(e=!1){this.items.length&&(this.items=[],this.caretPos=0,this._syncSourceElement(),this._clearRenderCache(),e||(this._trigger("onClear"),this._trigger("onChange",this.getValue())))},getValue(){return this.isSingle?this.items.length?this.items[0]:"":[...this.items]},setValue(e,t=!1){this.clear(!0);const i=Array.isArray(e)?e:[e];for(const s of i)""!==s&&null!=s&&this.addItem(s,!0);t||this._trigger("onChange",this.getValue())},createItem(e=null){const t=null!==e?e:this.query;if(!t.trim())return;if(!this._config.create)return;const i=this._config.create;let s;"function"==typeof i?(s=i(t,e=>{e&&(this.addOption(e),this.addItem(e[this._config.valueField]))}),s&&"object"==typeof s&&(this.addOption(s),this.addItem(s[this._config.valueField]))):(s={},s[this._config.valueField]=t,s[this._config.labelField]=t,this.addOption(s),this.addItem(t)),this.query="",this._clearRenderCache()},_getFilteredOptions(){const e=this._config;if(!this._sifter)return[];const t=Array.isArray(e.searchField)?e.searchField:[e.searchField];let i;i=e.sortField?"string"==typeof e.sortField?[{field:e.sortField,direction:"asc"}]:Array.isArray(e.sortField)?e.sortField:[e.sortField]:[{field:"$order",direction:"asc"}];let s=this.query;e.normalize&&s&&(s=s.normalize("NFD").replace(/[\u0300-\u036f]/g,""));const n={fields:t,conjunction:e.searchConjunction,sort:i,nesting:t.some(e=>e.includes(".")),respect_word_boundaries:e.respectWordBoundaries,limit:e.maxOptions};e.score&&(n.score=e.score);let o=this._sifter.search(s,n).items.map(e=>{const t=this.options[e.id];return t?{...t,_score:e.score}:null}).filter(Boolean);return e.hideSelected&&(o=o.filter(t=>!this.items.includes(a(t[e.valueField])))),o=o.filter(t=>!t[e.disabledField]),o},open(){this.isOpen||this.isDisabled||this.isLocked||(this.isOpen=!0,this.activeIndex=this._config.setFirstOptionActive?0:-1,this._trigger("onDropdownOpen"),this.$nextTick(()=>{this._scrollToActive()}))},close(){this.isOpen&&(this.isOpen=!1,this.activeIndex=-1,this._trigger("onDropdownClose"))},toggle(){this.isOpen?this.close():this.open()},focus(){if(this.isDisabled)return;this.isFocused=!0;const e=this.$refs.searchInput;e&&this.$nextTick(()=>e.focus()),this._config.openOnFocus&&this.open(),"focus"!==this._config.preload||this.loadedSearches[""]||this._performLoad(""),this._trigger("onFocus")},blur(){this.isFocused&&(this.isFocused=!1,this._config.createOnBlur&&this.query.trim()&&this.canCreate&&this.createItem(),this.close(),this._trigger("onBlur"))},onKeyDown(e){if(this.isDisabled||this.isLocked)return;const t=this.filteredOptions,i=this.canCreate,s=t.length+(i?1:0);switch(e.key){case"ArrowDown":e.preventDefault(),this.isOpen?(this.activeIndex=Math.min(this.activeIndex+1,s-1),this._scrollToActive()):this.open();break;case"ArrowUp":e.preventDefault(),this.isOpen&&(this.activeIndex=Math.max(this.activeIndex-1,0),this._scrollToActive());break;case"Enter":e.preventDefault(),this.isOpen&&this.activeIndex>=0?this.activeIndex<t.length?this.selectOption(t[this.activeIndex]):i&&this.createItem():this.isOpen||this.open();break;case"Escape":e.preventDefault(),this.close();break;case"Tab":this.isOpen&&this._config.selectOnTab&&this.activeIndex>=0&&(e.preventDefault(),this.activeIndex<t.length?this.selectOption(t[this.activeIndex]):i&&this.createItem());break;case"Backspace":if(!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const t=this.items[this.items.length-1];this.removeItem(t)}break;case"Delete":if(!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const t=this.items[this.items.length-1];this.removeItem(t)}break;case"a":case"A":(e.ctrlKey||e.metaKey)&&this.isMultiple&&e.preventDefault()}},onInput(){if(this._trigger("onType",this.query),this.isOpen||this.open(),this.activeIndex=this._config.setFirstOptionActive||this.query?0:-1,this._config.load&&this.query){const e=this.query;this.loadedSearches[e]||(this._debouncedLoad?this._debouncedLoad(e):this._performLoad(e))}this.$refs.searchInput&&this.isMultiple&&d(this.$refs.searchInput)},onPaste(e){if(!this.isMultiple)return;const t=(e.clipboardData||window.clipboardData).getData("text");if(!t)return;const i=this._config.splitOn||this._config.delimiter;if(!i)return;e.preventDefault();const s=i instanceof RegExp?i:new RegExp("["+i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")+"]"),n=t.split(s).map(e=>e.trim()).filter(Boolean);for(const o of n){const e=Object.values(this.options).find(e=>{var t,i;return(null==(t=e[this._config.labelField])?void 0:t.toLowerCase())===o.toLowerCase()||(null==(i=e[this._config.valueField])?void 0:i.toLowerCase())===o.toLowerCase()});e?this.addItem(e[this._config.valueField]):this._config.create&&this.createItem(o)}},selectOption(e){if(!e)return;if(e[this._config.disabledField])return;const t=e[this._config.valueField];if(""===t)return this.clear(),this.close(),this.isFocused=!1,void(this.$refs.searchInput&&this.$refs.searchInput.blur());this._config.showSelectedCount&&this.isMultiple&&this.isSelected(e)?this.removeItem(t):(this.addItem(t),this.query="",this.isSingle?(this.isFocused=!1,this.loadedSearches={},this.$refs.searchInput&&this.$refs.searchInput.blur()):this.$refs.searchInput&&(this.$refs.searchInput.focus(),d(this.$refs.searchInput)))},_performLoad(e){this._config.load&&(this.loadedSearches[e]||(this.isLoading=!0,this.loadedSearches[e]=!0,this._config.load(e,e=>{if(this.isLoading=!1,e&&Array.isArray(e)){for(const t of e)this.addOption(t,!0);this._clearRenderCache()}})))},renderOption(e){var t;const i=this._config,s=e[i.labelField]||"";return(null==(t=i.render)?void 0:t.option)?i.render.option(e,l):i.highlight&&this.query?function(e,t){if(!t||!t.length)return l(e);const i=l(e),s=new RegExp("("+t.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")+")","ig");return i.replace(s,'<span class="font-semibold text-inherit">$1</span>')}(s,this.query):l(s)},renderItem(e){var t;if(!e)return"";const i=this._config,s=e[i.labelField]||"";return(null==(t=i.render)?void 0:t.item)?i.render.item(e,l):l(s)},renderOptionCreate(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.optionCreate)?t.render.optionCreate({input:this.query},l):`Add <span class="font-medium">${l(this.query)}</span>...`},renderNoResults(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.noResults)?t.render.noResults({query:this.query},l):"No results found"},renderDropdownPlaceholder(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.dropdownPlaceholder)?t.render.dropdownPlaceholder({},l):l(t.dropdownPlaceholder||"")},renderLoading(){var e;const t=this._config;return(null==(e=t.render)?void 0:e.loading)?t.render.loading({query:this.query},l):"Loading..."},addOptionGroup(e,t){this.optgroups[e]=t,this._clearRenderCache()},removeOptionGroup(e){delete this.optgroups[e],this._clearRenderCache()},getGroupedOptions(){const e=this.filteredOptions,t=this._config,i={},s=[];for(const o of e){const e=o[t.optgroupField];e&&this.optgroups[e]?(i[e]||(i[e]=[]),i[e].push(o)):s.push(o)}const n=[];for(const[o,r]of Object.entries(i)){const e=this.optgroups[o];n.push({id:o,label:e[t.optgroupLabelField]||o,options:r})}return s.length&&n.push({id:null,label:null,options:s}),n},_getGroupedView(){const e=this.getGroupedOptions();let t=0;return e.map((e,i)=>{const s={key:e.id||"__ungrouped_"+i,label:e.label,options:e.options,offset:t};return t+=e.options.length,s})},get hasOptgroups(){return Object.keys(this.optgroups).length>0},lock(){this.isLocked=!0,this.close()},unlock(){this.isLocked=!1},disable(){this.isDisabled=!0,this.close()},enable(){this.isDisabled=!1},setMaxItems(e){this._config.maxItems=e,this.isFull&&this.close()},_syncSourceElement(){var e;if(this._sourceEl)if(u(this._sourceEl)){for(const e of this._sourceEl.options)e.selected=this.items.includes(e.value);for(const t of this.items){if(!Array.from(this._sourceEl.options).some(e=>e.value===t)){const i=document.createElement("option");i.value=t,i.textContent=(null==(e=this.options[t])?void 0:e[this._config.labelField])||t,i.selected=!0,this._sourceEl.appendChild(i)}}this._sourceEl.dispatchEvent(new Event("change",{bubbles:!0}))}else this._sourceEl.value=this.isSingle?this.items[0]||"":this.items.join(this._config.delimiter),this._sourceEl.dispatchEvent(new Event("input",{bubbles:!0})),this._sourceEl.dispatchEvent(new Event("change",{bubbles:!0}))},_scrollToActive(){this.$nextTick(()=>{const e=this.$refs.dropdown;if(!e)return;const t=e.querySelector('[data-active="true"]');t&&t.scrollIntoView({block:"nearest"})})},_trigger(e,...t){const i=this._config[e];"function"==typeof i&&i.apply(this,t);const s=e.replace(/^on/,"").toLowerCase();this.$el.dispatchEvent(new CustomEvent(`selectra:${s}`,{detail:t,bubbles:!0}))},_clearRenderCache(){this._renderCache={}},isSelected(e){return this.items.includes(a(e[this._config.valueField]))},optionKey(e){return a(e[this._config.valueField])}})}function m(e,t){f[e]=t}m("remove_button",function(e={}){var t;const{label:i="&times;",title:s="Remove",className:n=""}=e,o=null==(t=this._config.render)?void 0:t.item;this._config.render||(this._config.render={});const r=this;this._config.render.item=function(e,t){const i=r._config.labelField;r._config.valueField;return`<span class="inline-flex items-center">${o?o(e,t):t(e[i]||"")}</span>`},this._showRemoveButton=!0,this._removeButtonLabel=i,this._removeButtonTitle=s,this._removeButtonClass=n}),m("clear_button",function(e={}){const{title:t="Clear All",className:i="",label:s="&times;"}=e;this._showClearButton=!0,this._clearButtonTitle=t,this._clearButtonLabel=s,this._clearButtonClass=i}),m("restore_on_backspace",function(e={}){const t=e.text||(e=>e[this._config.labelField]||""),i=this.onKeyDown.bind(this);this.onKeyDown=e=>{if("Backspace"===e.key&&!this.query&&this.items.length&&this.isMultiple){e.preventDefault();const i=this.items[this.items.length-1],s=this.options[i];return this.removeItem(i),void(s&&(this.query=t(s),this.$refs.searchInput&&(this.$refs.searchInput.value=this.query)))}i(e)}}),m("dropdown_header",function(e={}){const{title:t="",showClose:i=!0,headerClass:s=""}=e;this._dropdownHeader=!0,this._dropdownHeaderTitle=t,this._dropdownHeaderShowClose=i,this._dropdownHeaderClass=s}),m("tag_limit",function(e={}){const{tagLimit:t=3}=e;this._tagLimit=t,this._showAllTags=!1,Object.defineProperty(this,"visibleItems",{get(){const e=this.selectedItems;return this.isFocused||this._showAllTags||!this._tagLimit?e:e.slice(0,this._tagLimit)}}),Object.defineProperty(this,"hiddenItemCount",{get(){const e=this.selectedItems;return this.isFocused||this._showAllTags||!this._tagLimit?0:Math.max(0,e.length-this._tagLimit)}})}),m("auto_select_on_type",function(){const e=this.blur.bind(this);this.blur=()=>{if(this.query.trim()&&this.filteredOptions.length){const e=this.filteredOptions[0];this.selectOption(e)}this.query="",e()}}),m("select_on_focus",function(){const e=this.focus.bind(this);this.focus=()=>{if(e(),this.isSingle&&this.items.length){const e=this.options[this.items[0]];e&&(this.query=e[this._config.labelField]||"",this.$refs.searchInput&&this.$nextTick(()=>this.$refs.searchInput.select()))}}}),m("read_only",function(e={}){const{readOnly:t=!0}=e;this._isReadOnly=t,this.readonly=e=>{this._isReadOnly=void 0!==e?e:!this._isReadOnly,this._isReadOnly&&this.close()};const i=this.addItem.bind(this),s=this.removeItem.bind(this),n=this.createItem.bind(this),o=this.clear.bind(this);this.addItem=(e,t)=>{this._isReadOnly||i(e,t)},this.removeItem=(e,t)=>{this._isReadOnly||s(e,t)},this.createItem=e=>{this._isReadOnly||n(e)},this.clear=e=>{this._isReadOnly||o(e)}}),m("auto_position",function(){this._autoPosition=!0;const e=this.open.bind(this);this.open=()=>{e(),this.$nextTick(()=>{const e=this.$refs.dropdown,t=this.$el;if(!e||!t)return;const i=t.getBoundingClientRect(),s=window.innerHeight-i.bottom,n=i.top,o=e.offsetHeight||250;this._dropdownPosition=s<o&&n>s?"top":"bottom"})},this._dropdownPosition="bottom"});
2
2
  /**
3
3
  * Selectra - Alpine.js Plugin
4
4
  *
@@ -26,5 +26,5 @@
26
26
  * </select>
27
27
  * </div>
28
28
  */
29
- const _='\n<div class="selectra-control" :class="{\'is-disabled\': isDisabled}">\n <div @click="focus()" class="selectra-input"\n :class="{\'is-focused\': isFocused, \'is-invalid\': isInvalid, \'is-locked\': isLocked, \'is-single\': isSingle, \'has-items\': items.length > 0}">\n <span x-show="_config.showSelectedCount && isMultiple"\n class="selectra-selected-count">\n <span x-text="selectedCountText"></span>\n </span>\n <span x-show="isSingle && items.length && !isFocused"\n x-text="currentValueText"\n class="selectra-single-value"></span>\n <template x-for="val in items" :key="val">\n <span x-show="isMultiple && !_config.showSelectedCount" class="selectra-item">\n <span x-html="options[val] ? renderItem(options[val]) : val"></span>\n <span @click.stop="removeItem(val)" class="selectra-item-remove">&times;</span>\n </span>\n </template>\n <input x-ref="searchInput"\n x-model="query"\n @input="onInput()"\n @focus="focus()"\n @blur.debounce.150ms="blur()"\n @keydown="onKeyDown($event)"\n @paste="onPaste($event)"\n :placeholder="placeholderText"\n x-show="(isSingle || !isFull) && (isMultiple || isFocused || !items.length)"\n :class="{\'selectra-search-with-count\': _config.showSelectedCount && isMultiple}"\n class="selectra-search">\n <span x-show="isFull && isMultiple" class="selectra-max-badge">Max reached</span>\n <div x-show="isLoading && !isOpen" class="selectra-spinner"></div>\n <svg x-show="isSingle"\n class="selectra-arrow" :class="{\'is-open\': isOpen}"\n fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">\n <path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"/>\n </svg>\n </div>\n <div x-show="isOpen" x-ref="dropdown" x-cloak class="selectra-dropdown"\n x-transition:enter="transition ease-out duration-150"\n x-transition:enter-start="opacity-0 -translate-y-1"\n x-transition:enter-end="opacity-100 translate-y-0"\n x-transition:leave="transition ease-in duration-100"\n x-transition:leave-start="opacity-100 translate-y-0"\n x-transition:leave-end="opacity-0 -translate-y-1">\n <div class="selectra-dropdown-content">\n <template x-for="group in _getGroupedView()" :key="group.key">\n <div>\n <div x-show="group.label" x-text="group.label" class="selectra-optgroup-header"></div>\n <template x-for="(option, idx) in group.options" :key="optionKey(option)">\n <div @click="selectOption(option)"\n @mouseenter="activeIndex = group.offset + idx"\n :data-active="activeIndex === group.offset + idx"\n :class="{\'is-active\': activeIndex === group.offset + idx, \'is-selected\': isSelected(option)}"\n class="selectra-option">\n <span x-show="_config.showSelectedCount && isMultiple && isSelected(option)" class="selectra-option-tick">&#10003;</span>\n <span x-html="renderOption(option)"></span>\n </div>\n </template>\n </div>\n </template>\n <div x-show="canCreate"\n @click="createItem()"\n @mouseenter="activeIndex = filteredOptions.length"\n :data-active="activeIndex === filteredOptions.length"\n :class="{\'is-active\': activeIndex === filteredOptions.length}"\n class="selectra-option-create"\n x-html="renderOptionCreate()">\n </div>\n <div x-show="filteredOptions.length === 0 && !isLoading && !canCreate && query.length > 0"\n class="selectra-no-results"\n x-html="renderNoResults()">\n </div>\n <div x-show="filteredOptions.length === 0 && !isLoading && !canCreate && query.length === 0 && _config.dropdownPlaceholder"\n class="selectra-no-results"\n x-html="renderDropdownPlaceholder()">\n </div>\n <div x-show="isLoading" class="selectra-loading">\n <div class="selectra-spinner"></div>\n <span x-html="renderLoading()"></span>\n </div>\n </div>\n </div>\n</div>\n'.trim();function v(e){e.data("selectra",(e={})=>g(e)()),e.directive("selectra",(e,{expression:t},{evaluate:i,cleanup:s})=>{e.querySelector(".selectra-control")||e.insertAdjacentHTML("beforeend",_)})}v.version="1.0.7",v.template=_,e.DEFAULTS=p,e.SELECTRA_TEMPLATE=_,e.Sifter=r,e.createSelectizeComponent=g,e.default=v,e.escapeHtml=l,e.getDefaults=function(){return{...p}},e.hashKey=a,e.registerPlugin=m,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
29
+ const _='\n<div class="selectra-control" :class="{\'is-disabled\': isDisabled}">\n <div @click="focus()" class="selectra-input"\n :class="{\'is-focused\': isFocused, \'is-invalid\': isInvalid, \'is-locked\': isLocked, \'is-single\': isSingle, \'has-items\': items.length > 0}">\n <span x-show="_config.showSelectedCount && isMultiple"\n class="selectra-selected-count">\n <span x-text="selectedCountText"></span>\n </span>\n <span x-show="isSingle && items.length && !isFocused"\n x-text="currentValueText"\n class="selectra-single-value"></span>\n <template x-for="val in items" :key="val">\n <span x-show="isMultiple && !_config.showSelectedCount" class="selectra-item">\n <span x-html="options[val] ? renderItem(options[val]) : val"></span>\n <span @click.stop="removeItem(val)" class="selectra-item-remove">&times;</span>\n </span>\n </template>\n <input x-ref="searchInput"\n x-model="query"\n @input="onInput()"\n @focus="focus()"\n @blur.debounce.150ms="blur()"\n @keydown="onKeyDown($event)"\n @paste="onPaste($event)"\n :placeholder="placeholderText"\n x-show="(isSingle || !isFull) && (isMultiple || isFocused || !items.length)"\n :class="{\'selectra-search-with-count\': _config.showSelectedCount && isMultiple}"\n class="selectra-search">\n <span x-show="isFull && isMultiple" class="selectra-max-badge">Max reached</span>\n <div x-show="isLoading && !isOpen" class="selectra-spinner"></div>\n <svg x-show="isSingle"\n class="selectra-arrow" :class="{\'is-open\': isOpen}"\n fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">\n <path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"/>\n </svg>\n </div>\n <div x-show="isOpen" x-ref="dropdown" x-cloak class="selectra-dropdown"\n x-transition:enter="transition ease-out duration-150"\n x-transition:enter-start="opacity-0 -translate-y-1"\n x-transition:enter-end="opacity-100 translate-y-0"\n x-transition:leave="transition ease-in duration-100"\n x-transition:leave-start="opacity-100 translate-y-0"\n x-transition:leave-end="opacity-0 -translate-y-1">\n <div class="selectra-dropdown-content">\n <template x-for="group in _getGroupedView()" :key="group.key">\n <div>\n <div x-show="group.label" x-text="group.label" class="selectra-optgroup-header"></div>\n <template x-for="(option, idx) in group.options" :key="optionKey(option)">\n <div @click="selectOption(option)"\n @mouseenter="activeIndex = group.offset + idx"\n :data-active="activeIndex === group.offset + idx"\n :class="{\'is-active\': activeIndex === group.offset + idx, \'is-selected\': isSelected(option)}"\n class="selectra-option">\n <span x-show="_config.showSelectedCount && isMultiple && isSelected(option)" class="selectra-option-tick">&#10003;</span>\n <span x-html="renderOption(option)"></span>\n </div>\n </template>\n </div>\n </template>\n <div x-show="canCreate"\n @click="createItem()"\n @mouseenter="activeIndex = filteredOptions.length"\n :data-active="activeIndex === filteredOptions.length"\n :class="{\'is-active\': activeIndex === filteredOptions.length}"\n class="selectra-option-create"\n x-html="renderOptionCreate()">\n </div>\n <div x-show="filteredOptions.length === 0 && !isLoading && !canCreate && query.length > 0"\n class="selectra-no-results"\n x-html="renderNoResults()">\n </div>\n <div x-show="filteredOptions.length === 0 && !isLoading && !canCreate && query.length === 0 && _config.dropdownPlaceholder"\n class="selectra-no-results"\n x-html="renderDropdownPlaceholder()">\n </div>\n <div x-show="isLoading" class="selectra-loading">\n <div class="selectra-spinner"></div>\n <span x-html="renderLoading()"></span>\n </div>\n </div>\n </div>\n</div>\n'.trim();function v(e){e.data("selectra",(e={})=>g(e)()),e.directive("selectra",(e,{expression:t},{evaluate:i,cleanup:s})=>{e.querySelector(".selectra-control")||e.insertAdjacentHTML("beforeend",_)})}v.version="1.0.9",v.template=_,e.DEFAULTS=p,e.SELECTRA_TEMPLATE=_,e.Sifter=r,e.createSelectizeComponent=g,e.default=v,e.escapeHtml=l,e.getDefaults=function(){return{...p}},e.hashKey=a,e.registerPlugin=m,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
30
30
  //# sourceMappingURL=selectra.umd.js.map
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "./css": "./dist/selectra.css"
19
19
  },
20
20
  "description": "Selectra — A powerful, extensible <select> UI control for tagging, contact lists, country selectors, and autocomplete. Built with Alpine.js and Tailwind CSS.",
21
- "version": "1.0.7",
21
+ "version": "1.0.9",
22
22
  "author": "Brijesh Sajeev<mailtobrijesh2003@gmail.com>",
23
23
  "contributors": [
24
24
  "Gajendra Jena <gaju.mca@gmail.com>"